Subtopic 1 of 3
1.1The phases, front end to back end
Lexical → Syntax → Semantic → Intermediate code → Optimisation → Code generation. The symbol table and error handler are used by every phase. Front end (analysis) depends on the source language; back end (synthesis) depends on the target machine.
Sourceposition = initial + rate * 60
Tokens-
Syntax tree-
Semantic-
Intermediate code-
Optimised-
Target code-
- Lexical analysis: characters → tokens
- Syntax analysis: tokens → parse/syntax tree (checks structure)
- Semantic analysis: type checking inserts a conversion because id3 is a float
- Intermediate code generation: three-address code
- Optimisation: fold the constant conversion, drop the extra temporary
- Code generation: target instructions with registers
Statement: position = initial + rate * 60 (rate is a float)
Previous year questions: Phases of a Compiler (4)
PYQs are grouped by topic, so this is the full set for Phases of a Compiler; try the ones that match this subtopic. Open all 4 on the topic page.