
1. Pre-processor
- The pre-processor takes the source code and performs tasks such as merging the contents of one or more files and replacing string patterns with another
- The pre-processor scans the code for pre-processor directives
2. Lexical Analysis
- Comments and unneeded spaces are removed
- Converts the source code into a token stream - Numeric representation of the code and stores in a table
- Keywords, constants and identifiers are replaced by 'tokens' (generally hex numbers)
- 2 tables are created
- Reserved word table
- Identifier table
Examples of lexical analysis tables:
Reserved Word (1)
User Identifier (1)
3. Syntax Analysis
- Tokens are checked to see if they match the spelling and grammar expected. 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
4. Semantic Analysis
- Variables are checked to ensure that they have been properly declared and used