I am looking for a simple compiler that compiles a simple language, I need it to write a paper about it and to learn how compilers work, I am not looking for a sophisticated thing just a simple language (by simple I mean a small code because for example gcc is toooooo big). any help is appreciated.
相关问题
- Correctly parse PDF paragraphs with Python
- R: eval(parse()) error message: cannot ope
- How do shader compilers work?
- C++ Builder - Difference between Lib and Res
- How do I parse a .pls file using PHP? Having troub
相关文章
- How do I get from a type to the TryParse method?
- Slow ANTLR4 generated Parser in Python, but fast i
- How to force Delphi compiler to display all hints
- Xcode - How to change application/project name : w
- What other neat tricks does the SpecialNameAttribu
- Parsing JSON in QML [duplicate]
- What is the purpose of “-Wa,option” in GCC? [close
- Generate Fortran subroutine with SymPy codegen for
LISPes (Scheme, etc) are the simplest actual languages. You can look how to build a primitive Scheme interpreter in perl with this book (paper version here on Lulu). Parsing, type checking are similar in interpreters and compilers. Then, here is a more hardcore book on the compiler design subject (also available as dead tree on Lulu).
The smallest practical compiler I know is MetaII, which has a 40 line self-description and can compile itself, using a special runtime system which admittedly hides some interesting computation (but then, most of the compilers listed here assume some kind of runtime system, surely bigger than the one for MetaII. I've build real compilers starting with this as a foundation, although meta-self-enhanced rather spectacularly.
There's been work to make that even smaller. I don't think there are any practical compilers based on this direction.
These are worth writing a paper about.
Jack Crenshaw, a Ph.D. who has written extensively about practical numerical methods, was scared of compilers for a long time. He finally got tired of being scared, and wrote a multi-part tutorial on compiler construction, based on what he learned as he was teaching himself about the subject.
See "Let's Build a Compiler" for more information. Note that it isn't complete; he ran out of steam before he finished it, but there is a lot of easily-digestible information in there.
Look at the simple compiler for PL/0 (a small pascal-like subset - no parameters, only integer data). The source, written in Pascal, is only about 500 lines of code, and is easy to follow. This may be all you need to look at.
However, if you want to go a little farther, once you are comfortable with that, look at the source to Pascal-S. This is a compiler for a larger subset of Pascal, but includes some additional concepts, such as parameter passing, additional data types, and arrays and records (structures). Still it is only about 2000 lines of code, and is easy to follow once you have mastered PL/0.
You can find the sources here:
http://standardpascal.org/source.html
About 1000 lines of code. Compiles Scheme to LLVM assembler or to C. I would say this is an excellent fit for a paper on compilers. If you want to go deeper, I recommend the book "SICP".
I recommend TinyScheme or jonesforth.