Principles of Compiler Design Notes - Unit 1-part1


Compilers – Analysis of source program – Phases of a Complier – Cousins of the Complier – Grouping of Phases – Complier construction tools – Lexical Analysis – Role of Lexical Analysis – Input Buffering – Specification of Tokens.

Notes :

Compiler :

A Compiler is a program that reads a program written in one language (Source Language like C,C++,etc…) and translate it into an equivalent program in another language (Target Language like Machine Language) and the complier reports to its user the presence of errors in the source program.

Classification of Compiler :

1. Single Pass Complier
2. Multi-Pass Complier
3. Load and Go Complier
4. Debugging or Optimizing Complier.

Software Tools :
Many software tools that manipulate source programs first perform some kind of analysis. Some examples of such tools include:

? Structure Editors :
? A structure editor takes as input a sequence of commands to build a source program.
? The structure editor not only performs the text-creation and modification functions of an ordinary text editor, but it also analyzes the program text, putting an appropriate hierarchical structure on the source program.
? Example – while …. do and begin….. end.
? Pretty printers :
? A pretty printer analyzes a program and prints it in such a way that the structure of the program becomes clearly visible.
? Static Checkers :
? A static checker reads a program, analyzes it, and attempts to discover potential bugs without running the program.

? Interpreters :
? Translate from high level language ( BASIC, FORTRAN, etc..) into assembly or machine language.
? Interpreters are frequently used to execute command language, since each operator executed in a command language is usually an invocation of a complex routine such as an editor or complier.
? The analysis portion in each of the following examples is similar to that of a conventional complier.
? Text formatters.
? Silicon Compiler.
? Query interpreters.

Analysis of Source Program :
The analysis phase breaks up the source program into constituent pieces and creates an intermediate representation of the source program. Analysis consists of three phases:
Linear analysis (Lexical analysis or Scanning)) :
? The lexical analysis phase reads the characters in the source program and grouped into them tokens that are sequence of characters having a collective meaning.
? Example : position : = initial + rate * 60
? Identifiers – position, initial, rate.
? Assignment symbol - : =
? Operators - + , *
? Number - 60
? Blanks – eliminated.

Hierarchical analysis (Syntax analysis or Parsing) :
? It involves grouping the tokens of the source program into grammatical phrases that are used by the complier to synthesize output.
? Example : position : = initial + rate * 60
Semantic analysis :
? In this phase checks the source program for semantic errors and gathers type information for subsequent code generation phase.
? An important component of semantic analysis is type checking.
? Example : int to real conversion.

Cousins of the Complier (Language Processing System) :
? Preprocessors :
? It produces input to Compiler. They may perform the following functions.
? Macro Processing :
A preprocessor may allow a user to define macros that are shorthands for longer constructs.
? File inclusion :
A preprocessor may include header files into the program text.
? Rational preprocessors :
These preprocessors augment older language with more modern flow of control and data structuring facilities.
? Language extensions :
These preprocessor attempt to add capabilities to the language by what amounts to built in macros.
? Complier :
? It converts the source program(HLL) into target program (LLL).
? Assembler :
? It converts an assembly language (LLL) into machine code.
? Loader and Link Editors :
? Loader :
? The process of loading consists of taking relocatable machine code, altering the relocatable addresses and placing the altered instructions and data in memory at the proper locations.
? Link Editor :
? It allows us to make a single program from several files of relocatable machine code.

Related Articles

Indian Premier League (IPL), show of BCCI's might

This article is about Indian Premier League (IPL), the brand sporting event organised by BCCI. This article reveals about the IPL's extragavancy and obviously the magnitude of money involved in the league which is known for its high magnitude entertainment. This article gives a clear picture about how the IPL make BCCI, franchise bank balances green, sponsors and the brand value of each team.

Time schedule of IPL 2012

In this article I am presenting the time schedule and time table of Indian Premier League IPL 2012. Four seasons of Indian premier league has passed now the time of IPL session 5 at April 4th. The first match between Chennai Super Kings v Mumbai Indians M.A. Chidambaram Stadium, Chennai.

IPL-5 auction news makers

This article deals with the interesting features of IPL-5 auctions held at Bengaluru on Saturday, the 4th of February 2012. The top pick of the IPL-5 was Ravindra Jadeja who bagged $2m (Rs.9.71crore). He is bought by Chennai Super Kings in a tie breaker with Deccan Chargers. 8 teams bid for 25 players. Mumbai Indians and Rajasthan Royals had maximum buys with 5 players each. The article names the top 5 picks of the IPL-5. The names of all the 25 players and the teams which bought them are given.

Indian Premier League 6 (IPL 6) 2013- Schedules and latest grasps

DLF IPL 6 is coming soon, live in stadium and on Sony Max at homes. Here is an article about the schedules, ticket booking and latest grasps from IPL 6 2013. This article also contains a short review of 1-5 IPLs played in last 5 years. This article is relates "Indian Premier League 6 (IPL 6) 2013- Schedules and latest gasps".

More articles: Ipl Ipl


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: