I’m posting a series on writing a compiler in Haskell for a subset of Java called NewL using Alex and Happy for the lexing and parsing. I’ve completed the following topics so far.
1. Go over the grammar of NewL.
2. Scanner for NewL using Alex.
3. Parser for NewL using Happy.
4. Error recover and reporting for the scanner and parser (I’m keeping it simple and abort on the first error and print the line and column number).
5. Symbol table and how it’s used in semantic analysis and code generation.
6. Revised NewL language and more symbol tables.
7. Type Checking.
8. Preliminaries on using LLVM for code generation.
9. The basics of LLVM.
The code is available on GitHub at http://github.com/bjwbell/NewL-Compiler.