โ Compiler Design learning pathCompiler Design ยท Module 10 of 10
Compiler tools and practice
Building a small compiler.
๐ Key ideas
- Classic tools: Lex/Flex for scanners, Yacc/Bison for parsers; ANTLR generates both from one grammar.
- LLVM provides a reusable back end; many languages (Rust, Swift, Clang) use it.
- A good student project: a calculator or a tiny language that compiles to stack-machine code or Python bytecode.
- Test compilers with many small programs, including invalid ones, and compare output with expected results.
- Compiler skills apply to linters, formatters, query engines, template engines and IDE features.
๐ก Real-life example: Building a tiny compiler is like building a model engine: small, but every part works the same way as the real one.
ANTLRParser generator producing lexer and parser
LLVMReusable compiler back-end infrastructure
LinterTool that analyses code for errors and style
Stack machineTarget that evaluates using a stack of values