Tokens are analysed against the grammar
and rules of the programming language, and any tokens that break the rules of the programming language are flagged as syntax errors, and added to a list of errors.
- Parsing is used to systematically apply a set of rules to each statement in the source code
- Examples of syntax errors: undeclared variable types, incomplete set of brackets, etc
The priorities of arithmetic operations can be clarified, and expressions can be converted into simpler forms so that machine code can be generated easily.
An abstract syntax tree is produced (a representation of the source code in the form of a tree)
Any further detail about the identifiers is also added to the symbol table
Semantic analysis is also carried out, where logic mistakes are detected within the program
- semantic errors examples: multiple declaration, undeclared identifiers, etc