Fig 1.5: preprocessor, linker/loader
Phases - Fig 1.6 and 1.7
- Lexer
- Parser
- Semantic analysis
- Int Code gen
- Optimization
- Code Gen
Token vs lexeme
Lexer and parser generators
- Lex, YACC, FLex, Bison, ANTLR, CUP, Coco/R, JavaCC, SableCC
- AFlex, AYACC, Dmitry Kazakov Simple Components,
AdaCore Langkit
Transforms: sequence of characters, seq of tokens,
abstract parse tree, intermediate code, asm, machine code
- Actually, parser calls lexer
Importance of phases has changed
Cross compiler
Front end, back end, intermediate code
Symbol table: what's in it when it's built
Attributes move up and down tree
- Example: print expression
- Example: evaluate expression
Abstract vs Concrete Parse Tree
Decisions
- Source language: Ada Baby
- Target language/machine
- RISC vs CISC
- x86, SPARC, ARM, MIPS
- Run on: SPARC machine or emulator, RPi, SPIM
- Implementation language: Java or Ada
- Tools or by hand
- Coco/R
- SableCC
- JavaCC
- Ada Tools
- Groups or individual
- Assignment: Try to implement a lexer using Coco or SableCC