Compiler is a program that translates one language (source program) as input and translates into an equivalent another language (target program).
  • During this process of translation if some errors are encountered then compiler displays them as error messages.The basic model of complier can be represented as follows

Fig :Compiler

The compiler takes a source program as high level language such as C,PASCAL, FORTRAN, etc., and converts it into low level language or machinelanguage such as assembly language.
The compilation can be done in two parts
  1.  Analysis 
  2. Synthesis

  •  In analysis part the source program is read and broken down into constituentpieces. 
  • The syntax and the meaning of the source string is determined and then an intermediate code is created from the input source program. 
  • In synthesis part, this intermediate form of the source language is taken andconverted into an equivalent target program.
  • During this process, if certain code has to be optimized for efficient executionthen the required code is optimized.

FIG 2.49: Analysis and Synthesis Model

The analysis part is carried out in three sub parts
FIG 2.50: Analysis Part

Lexical Analysis

  • In this step the source program is read and then it is broken into a stream of strings. 
  • Such strings are called tokens. 
  • Hence tokens are nothing but the collection of characters having somemeaning.

Syntax Analysis

  •  In this step the tokens are arranged in hierarchical structure that ultimately helps in finding the syntax of the so urce string.

Related blog 
Next Post »