Resources » Articles/Knowledge Sharing » Education

Principles of Compiler Design Notes - Unit 1-part1


Last Updated:   Category: Education    
Author: Member Level: Silver    Points: 5






Syllabus : Unit – I : INTRODUCTION TO COMPILING

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.


Did you like this resource? Share it with your friends and show your love!




Responses to "Principles of Compiler Design Notes - Unit 1-part1"
Feedbacks      

Post Comment:




  • 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:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index

    Awards & Gifts
    Active Members
    TodayLast 7 Daysmore...

    ISC Technologies, Kochi - India. Copyright © All Rights Reserved.