Phases of A Compiler
Phases of A Compiler
The analysis of a source program is divided into mainly three phases. They are:
1. Linear Analysis-
This involves a scanning phase where the stream of characters are
read from left to right. It is then grouped into various tokens having a
collective meaning.
2. Hierarchical Analysis-
In this analysis phase,based on a collective meaning, the tokens are
categorized hierarchically into nested groups.
3. Semantic Analysis-
This phase is used to check whether the components of the source
program are meaningful or not.
The compiler has two modules namely front end and back end.
Front-end constitutes of the Lexical analyzer, semantic analyzer, syntax
analyzer and intermediate code generator.
And the rest are assembled to form the back end.
1. Lexical Analyzer
The first phase of scanner works as a text scanner.
This phase scans the source code as a stream of characters and
converts it into meaningful lexemes.
Lexical analyzer represents these lexemes in the form of tokens as:
<token-name, attribute-value>
Note
All these six phases are associated with the symbol table
manager and error handler as shown in the above block
diagram.