Some notes and self-study material about compilers and interpreters.
You will find several small programs written in different programming languages to practice the theory behind compilers. Some of these programs may be far from complete. In fact, the purpose of each program is to demonstrate some concepts of compiler construction. Having said that, feel free to send your PRs for whichever issue you spotted.
Below is the list of programs in this repository along with a short description.
An arithmetic calculator written in C++ to practice lexers and parsers. In this small program, you will find
- a simple tokenizer
- a railroad or syntax diagram for the grammar used to implement the interpreter
- a simple recursive descent parser that follows the rules in the railroad diagram
(I stopped working on this one - no plans to continue for now)
Compiler for the Kestrel programming language. This project closely follows Douglas W. Jones' lecture notes on Compiler Construction and the compiler is written in C.
This is a full compiler with a front-end and a beck-end generating code for ARM processors.
In this project, you will find
- a lexer which is implemented as a separate static library
A compiler front-end with a lexer, parser and simple symbol table. The program reads the input source code, which can have assignments, nested program blocks and statements, and then generates a symbol table. The theory for this program is covered in Chapter2 of Compilers: Principles, Techniques and Tools.
Some of the things covered in this program are
- a lexer
- a recursive descent parser
- a simple symbol table implementation
You can visit the repository from this link.
Some good reading material on the subject.
-
Scott Gordon's lecture notes on Computing Theory and Programming Languages. I found this one very concise and easy to follow. The calc program in this repository is implemented based on the information in these lecture notes.
-
Jordan Rose's blog post about being a compiler wizard. Some useful advise from a former Compiler Engineer.