Answer the question
In order to leave comments, you need to log in
Is it possible to write a compiler to machine code in a very high level language?
Is it possible to write a compiler to machine code in a very high level language?
Answer the question
In order to leave comments, you need to log in
Is it possible to write a compiler to machine code in a very high level language?
1. Believe the person who has been writing in C since 1985 (30 years, I guess?) - NEVER write anything in C unless a gun is pointed to your head. The only exception is the OS kernel. And even then ...
2. Anything can be written on anything. A matter of convenience.
3. The compiler must be written in a language with advanced project life support tools. There are two of them - Java and C#. You can (and if you are comfortable with it, then you should) use the functional extensions of the corresponding platforms. Scala/F#.
4. There is no need to write serious things in shit languages. The key property of a shit language is the discussion around it about how poor programmers have gone to the trouble of explicitly prescribing the types of all variables by hand. You can write plugs and lotions on such PLs.
5. Do not use lexical and grammatical analyzer generators until you learn how to write the compiler by hand. The keyword is recursive descent parsing. It's really easy if the grammar of the language is LR1. To begin with, you need to take a simple language. Very simple.
6. A basic compiler with code generation for a stack machine needs to be written in two days. If you want to know how.
7. Backends (real code generation) DO NOT NEED to be written. Generally. You will never write it well. It's easier to generate C output and recompile with a decent C compiler.
Can.
But it's better to use C.
In general, writing compilers is a separate science.
The main thing in the compiler is parsing the code that is at the input. And parsing strings, IMHO, is much easier to learn in Java. And this topic (if you study at the compiler level) is very, very big.
Well, technically, of course, you can also use almost anything, just read a text file, parse it (here is a problem - regular expressions are needed) and write a binary file.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question