Home | | Compiler Design | Introduction to Compiling Compilers

Chapter: Principles of Compiler Design : Lexical Analysis

Introduction to Compiling Compilers

A compiler is a program that reads a program written in one language-the source language-and translates it into an equivalent program in another language-the target language.

COMPILERS

 

A compiler is a program that reads a program written in one language-the source language-and translates it into an equivalent program in another language-the target language. As an important part of this translation process, the compiler reports to its user the presence of errors in the source program.


 

Fig. 1.1 A Compiler

 

Compilers are sometimes classified as single-pass, multi-pass, load-and-go, debugging, or optimizing, depending on how they have been constructed or on what function they are supposed to perform. Despite this apparent complexity, the basic tasks that any compiler must perform are essentially the same.

 

The Analysis – Synthesis Model of Compilation

 

There are two parts of compilation.

 

·                 Analysis part

·                 Synthesis Part

The analysis part breaks up the source program into constant piece and creates an

intermediate representation of the source program.

 

The synthesis part constructs the desired target program from the intermediate representation.

 

Software tools used in Analysis part: 1) 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.

 

·                    For example , it can supply key words automatically - while …. do and begin….. end

2) Pretty printers :

 

·                    A pretty printer analyzes a program and prints it in such a way that the structure of the program becomes clearly visible. For example, comments may appear in a special font.

 

3) Static checkers

 

·                    A static checker reads a program, analyzes it, and attempts to discover potential bugs without running the program.

 

·                    For example, a static checker may detect that parts of the source program can never be executed.

 

4) Interpreters :

 Translates from high level language (BASIC, FORTRAN, etc..) into machine language.

 

·                    An interpreter might build a syntax tree and then carry out the operations at the nodes as it walks the tree.

 

·                    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.


Fig. 1.2 A language processing system

 

Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
Principles of Compiler Design : Lexical Analysis : Introduction to Compiling Compilers |


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.