Thursday 31 May 2012

The Compilation process


The objective of the compiler is to transform a program written a high-level programming language from source code into object . Programmers write in a high-level programming languages from source code into object code. Programmers write program in a form called source code. Source code must go through several steps before it becomes an executable program.
The first step is to pass the source code through a compiler, which translates the high-level languages instruction into object code. At last it producing an executable code. After produced object code , it is pass to the linker. The linker combines modules and gives real values to all symbolic addresses.

Every high-level programming language comes with a compiler. The compiler the language, because it defines which instructions are acceptable.
Compilers translates source code into object code, which is unique for each type of computer, many compilers are available for the same language.
General models of compilers(Phases of C)
1.Lexical analysis : recognition of basic elements and creation of uniform symbols.
2.Syntax analysis : recognition of basic syntactic constructs through reductions.
3.Interpretation (Symantec analysis) : definition of exact meaning, creation of matrix and tables by action routines.
4.Machine independent : creation of more optimal matrix.
5.Storage assignment : modification of identifier and literal tables. It makes entries in the matrix that allow code generation to create code that allocates dynamic storage, and that also allow the assembly phase to reserve the proper amounts of static.
6.Code generation : use of macro processor to produce more optimal assembly code.
7.Assembly and output : resolving symbolic addresses and generating language.
Compiler also manage the database, in the database it manages
A.Source code
B.Uniform symbol
C.Terminal table
D.Identifier table
E.Literal table
F.Reductions
G.Matrix
H.Code productions
I.Assembly code
J.Relocatable object code
1.Source code : program
2.Uniform symbol table : Consist of a full or partial list of the token as they appear in the program. Created by lexical analysis and used for syntax analysis and Symantec analysis.
3.Terminal table :  a permanent table which lists all key words and special symbols of the language in symbolic form.
4.Identifier table : it contains all variables in the program and temporary storage and any information needed to reference or allocate storage for them.
5.Literal table : it contains all constants in the program creation and use similar to the identifier table.
6.Reductions : permanent table of decision rules in the form of patterns for matching with the uniform symbol table.
7.Matrix : intermediate table of decision rules in the form of pattern for matching with the uniform symbol table.
8.Code productions : permanent table of definitions. There is one entry defining code for each possible matrix operator.
9.Assembly code : assembly language version of the program which is created by the code generation phase.
10.Reloadable object code : final output of the assembly phase, ready to be used as input to loader.




1 comment: