Stages of compilation Flashcards
1
Q
Lexical analysis
A
- comments and unneeded spaces are removed
- keywords, constants and identifiers are replaced by ‘tokens’
- a symbol table is created which holds the addresses of variables, labels and
subroutines
2
Q
Syntax analysis
A
tokens are checked to see if they match the spelling and grammar expected, using
standard language definitions. This is done by parsing each token to determine if it
uses the correct syntax for the programming language
* if syntax errors are found, error messages are produced
3
Q
Semantic analysis
A
variables are checked to ensure they have been properly declared and used
* variables are checked to ensure they are of the correct data type, e.g. real values
are not being assigned to integers
4
Q
Code generation
A
- machine code is generated
- code optimisation may be employed to make it more efficient/faster/less resource
intense.