Compilation Flashcards
1
Q
What are the 4 stages of compilation?
A
- lexical analysis
- syntax analysis
- code generation
- code optimisation
2
Q
Lexical analysis is…?
A
- Comments and white spaces removed
- Remaining code is turned into series of tokens
- Symbol table is created to keep track of variables and subroutines
3
Q
Syntax analysis is…?
A
- Abstract syntax tree is built from tokens produced in the previous stages
- Errors are generated if any tokens break the rules of the language
4
Q
Code generation is…?
A
- Abstracting code tree converted to object code
- Object code is the machine code produced before the final step (linker) is run
5
Q
Code optimisation is…?
A
- Tweaking the code so it will run as quickly and use as little memory as possible