* Stream of characters in the source program is grouped into meaningful sequences called lexemes. Tokens are produced for each lexeme. A token is an abstract symbol generated during lexical analysis. * Generally, a token has an attribute value attached to it. It denotes the position of the variable in a symbol table. A symbol table is a table which stores information about an identifier and is referred at various stages of compilation.
* The syntax analyzer checks each line of the code and spots every tiny mistake that the programmer has committed while typing the code. * The compiler follows a detailed procedure using the tokens creates by the lexical analyzer and creates a tree-like structure called the syntax tree. * The syntax analyzer checks whether the order of tokens conform to the rules of the programming language. Unmatched parenthesis, missing semicolons are some of the errors detected in this phase. * If there are no errors in the code, the syntax analyser successfully constructs a syntax tree which is later used by the semantic analyser.
* “Semantic” by definition is concerned with meanings. A semantic analyser is mainly concerned with what the program means and how it executes. * Type checking is an important aspect of semantic analysis where each operator should be compatible with its operands.
Intermediate Code Generation
* A compiler may construct intermediate representations while converting a source program to a target program. * The representation should be easy to convert into a target language. It is then passed onto the second phase of compiler design: the synthesis phase. This phase involves the actual construction of target program and includes code optimisation and code generation.
* As the name suggests, this phase aims at optimising the target code. * The code can be optimised in terms of time taken to execute,...
Please join StudyMode to read the full document