Lexical Analysis
The Lexical analysis phase of compiler is concerned about generating tokens out of the source program, skipping the white-spaces and comments, and to point out the lexical errors.
For achieving its objectives lexical analyzer scans the source code from a buffer, constructs the finite automata from regular expressions, and assembles the source code in the form of tokens.
This phase also creates a symbol table where tokens and their attributes are entered, which used by the remaining phases of the compiler.
Syntax Analysis
The syntax analysis is compiler phase next to lexical analysis. It is concerned about the grammatical structure of the program and its statements.
The syntax analysis, also called Parsing, is hardware independent and its output, which is a Parse-tree for each HLL statement, is used for intermediate code generation for any machine.
Syntax Directed Translation, storage allocation, intermediate code generation and optimization
The syntax Directed Translation (SDT) makes use of syntax of the grammar to carry out the translation of statements of the corresponding language. SDT is carried out using L-attributed translations, which covers virtually all translations that can be performed during parsing.