by Dinesh Thakur

The phases of a compiler can be grouped as:

Front end

Front end of a compiler consists of the phases

• Lexical analysis.
• Syntax analysis.
• Semantic analysis.
• Intermediate code generation.

Back end

Back end of a compiler contains

• Code optimization.
• Code generation.

Front End

• Front end comprises of phases which are dependent on the input (source language) and independent on the target machine (target language).
• It includes lexical and syntactic analysis, symbol table management, semantic analysis and the generation of intermediate code.
• Code optimization can also be done by the front end.
• It also includes error handling at the phases concerned.

            Front end

Back End

• Back end comprises of those phases of the compiler that are dependent on the target machine and independent on the source language.
• This includes code optimization, code generation.
• In addition to this, it also encompasses error handling and symbol table management operations.

            Back end


• The phases of compiler can be implemented in a single pass by marking the primary actions viz. reading of input file and writing to the output file.
• Several phases of compiler are grouped into one pass in such a way that the operations in each and every phase are incorporated during the pass.
• (eg.) Lexical analysis, syntax analysis, semantic analysis and intermediate code generation might be grouped into one pass. If so, the token stream after lexical analysis may be translated directly into intermediate code.

Reducing the Number of Passes

• Minimizing the number of passes improves the time efficiency as reading from and writing to intermediate files can be reduced.
• When grouping phases into one pass, the entire program has to be kept in memory to ensure proper information flow to each phase because one phase may need information in a different order than the information produced in previous phase.
The source program or target program differs from its internal representation. So, the memory for internal form may be larger than that of input and output.