Hello ,
How to create my own compiler and which language is good for that ?
Compilers
Re:Compilers
You don't ask for much, do you?
While there are several ways to write a compiler, there are really only two practical approaches: either write it using a LL(1) pattern-matching recursive-descent parser that emits code more or less directly, or use compiler-generator tools for the lexer and parser (i.e., LEX and YACC) and write a semantic analyser and code generator that uses their output.
Either way, you waill want to have as complete a BNF grammar for the language you'll be compiling as you can, and as specific a description of the semantics as possible. The grammar is particularly important, as you'll be building your parser directly from it; but an unambigous semantics is also important, otherwise the language may not always do what you expect.
You can in principle use any language you wish to. However, there are some languages which are better suited than others; the ones I would most strongly recommend are Java, Scheme, Icon, or (believe it or not) Prolog. That having been said, most compilers today are written in C, and most compiler-generators are designed to work with C preferentially.
You may want to read a few of the following threads for more information:
Making a Compiler?
OS Dev Compiler
Finding Simple Codes of Compiler
Making your own programming language?
While there are several ways to write a compiler, there are really only two practical approaches: either write it using a LL(1) pattern-matching recursive-descent parser that emits code more or less directly, or use compiler-generator tools for the lexer and parser (i.e., LEX and YACC) and write a semantic analyser and code generator that uses their output.
Either way, you waill want to have as complete a BNF grammar for the language you'll be compiling as you can, and as specific a description of the semantics as possible. The grammar is particularly important, as you'll be building your parser directly from it; but an unambigous semantics is also important, otherwise the language may not always do what you expect.
You can in principle use any language you wish to. However, there are some languages which are better suited than others; the ones I would most strongly recommend are Java, Scheme, Icon, or (believe it or not) Prolog. That having been said, most compilers today are written in C, and most compiler-generators are designed to work with C preferentially.
You may want to read a few of the following threads for more information:
Making a Compiler?
OS Dev Compiler
Finding Simple Codes of Compiler
Making your own programming language?
Re:Compilers
Certainly true. However, not everyone has seen the light yet.sdkub wrote: it might be a lot easier a (lisp) interpreter instead ..