O'Reilly logo

Compilers: Principles and Practice by Himanshu B. Dave, Parag H. Dave

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

1.6 A More Detailed Look at Phases of a Compiler

We have already seen that a compiler has the following phases:

  • Pre-processing
  • Scanner – Lexical Analysis
  • Parser – Syntax Analysis
  • Mapper – Semantic Analysis
  • Code Generation
  • Assembler
  • Optimization (spread over several phases)
  • 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.

 

Phases of a compiler and intermediate outputs

 

Fig. 1.14 Phases of a compiler and intermediate outputs

1.6.1 Lexical Analyzer - Scanner

Does lexical analysis, by doing the following: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required