You are on page 1of 8

Compiler Construction

By Noor wali khan


Uoch
Phases of compiler
• Phase:
• A logical activity which transforms the source code from one representation to another
representation.
• There are eight phases of compiler:
• Lexical Analyzer Formal
Analysis Portion Phases
• Syntax Analyzer
• Semantic Analyzer
• Intermediate Code Generator Synthesis Portion
• Code Optimizer
• Code Generator
• Symbol Table Manager Informal
Phases
• Error handler
Target Code
Explanation
• The first six phases are called formal phases of
compiler. While the last two are informal phases of
compiler.
• The last two symbol table manager and Error Handler
are not the formal phases of compiler but these help
in the activities of the formal phases.
• The first three phases form the bulk of the analysis
portion and 4, 5, 6 are the synthesis portion of
compiler.
Symbol Table Manager
• It is a data structure which contains a record for each
keyword, reserved word, and identifier in the source
program, with fields for various attributes of the
identifier.
• It serves as a dictionary for the compiler.
• Here the identifier can be:
• Variable name
• Function name
Symbol Table Manager
• In case of a variable name the attributes are:
• Type of variable
• Scope of variable
• Storage classes
• Size
• Life time
• In case of function name the attributes are:
• Name
• Method of passing arguments
• Order of arguments
• Return type
Symbol Table Manager
• Different phases of compiler enters information into symbol table e.g.
• lexical analyzer enters identifier names into the symbol table.
• Semantic analyzer enters type information into the symbol table
• e.t.c
• Different phases use information from symbol table e.g.
• Semantic analyzer frequently uses symbol table information
Continue to Next lecture

You might also like