paper 1 - lexical, syntax and semantic stages Flashcards
1
Q
describe the syntax analysis stage
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
1
Q
describe the lexical analysis stage
A
- comments and unneeded spaces are removed
- keywords, constants and identifiers are replaces by tokens
- a symbol table is created which holds the address of variables, labels and sub routines
2
Q
describe the semantic analysis stage
A
- variables are checked to ensure that they have been properly declared and used
- variables are checked to ensure they are of the correct data type (eg. float values are not being assigned to integers)