
Introduction 13
1.6 A More Detailed Look at Phases of a Compiler
We have already seen that a compiler has the following phases:
c
Pre-processing
c
Scanner – Lexical Analysis
c
Parser – Syntax Analysis
c
Mapper – Semantic Analysis
c
Code Generation
c
Assembler
c
Optimization (spread over several phases)
c
Error Checking (spread over several phases)
A compiler generates intermediate files between these phases, to communicate output of one phase
as input to the next (see Fig. 1.14).
We now discuss each phase of a compiler in some details.
1.6.1 Lexical Analyzer – Scanner
Does lexical analysis, by doing the following:
c
Analyze individual character ...