When a compiler is created for a particular language, do the people who develop the compiler define the language and it's commands right from the beginning as if the language never existed (This seems unreal)? or is there a way to use previous compilers? or how else do they do it?
preguntado el 08 de noviembre de 11 a las 11:11
Either they define a [domain specific] language or implement some already existing language.
A language is typically written in a certain form called BNF
One method to create a compiler (or at least lexer and parser) is to use a tool, there are several tools like yacc/lex, ANTLR etc which can be used to generate the raw plumbing for the compiler, tokenizing the file and parsing the tokens. Check out antlr.org for some examples of a pretty easy to use tool that generates C#, Java or C code parser/lexers.
I'm guessing you are assuming that the compiler is written in the same language it compiles. This is not the case. The process is called bootstrapping. The first C# compiler was written in C++. The first C++ compiler was written in C. The first C compiler was written in B. The first B compiler was written in BCPL. Beyond which it gets fuzzy, ancient history and all that. This does ultimately go back to somebody entering a program into a machine with toggle switches.
Addressing the first part of your question: yes. Nobody sets out writing a compiler without a very strong definition of the grammar of the language. This can be worked out on paper.
It all depends on the language. If the language doesn't exist (and remember that none did in the beginning) then of course it must be designed before the compiler. But if you just want to make changes to an existing language it might be easier to take an existing compiler and make the changes you want.
I have personally made a few compilers for little languages that I thought up my self, and created the compilers from scratch. Sometimes using tools such as lex y Yacc, sometimes by hand-coding it all.
The evaluation of Language have started since the born of computer, and the first optimzation compiler came up in around 1960s.
The simplest answer to your question is that language design comes up first, and then compiler developer develop the compiler follow the standard. And then the language designer get feed back from the user community,and make changes to the language standard, and the compiler developer work on this new standard again.
Usually, compiler developer develop new language feature support only use the already supported feature of the compiler.