You are on page 1of 1

A Compiler Design Program in C

Each module's output is another module's input. After going thru all the phases,all modules
need to be integrated. The total number of lines of code shud be around 4000-5000 or more..

A) FIRST MODULE: The Lexical Analyzer: Data Types and other language features need to
be defined including the other keywords,relational operators,expressions ..2) After the
identification of the keywords,operators,data types etc.they need to be stored in a symbol
table,which'll be data structure,an array for eg.Say for example, whenver the input program is
being scanned by the compiler, whenever a word "if" is found,its corresponding entry shud b
made in the data structure...and if its entry has already been made, then no entry needs to b
made.In a similar manner,entries corresponding to operators,data types,identifiers-all need to be
made in the table.
3)The lexical analyzer must remove all comments from between as the blank spaces have been
eliminated.

B) SECOND MODULE: The Syntax Analyzer (Parser): It will take input from the tokens
generated by the lexical analyzer..It will check whether the syntax of the input program is correct
or not by generating a tree,ie.the syntax tree..Postfix Expressions can be generated for this
purpose.

C) THIRD MODULE: The Semantic Analyzer: After the syntax of the program is found to be
correct, "the type checking" will be done by this module to check whether the meaning of the
program is correct or not. The output of this phase will be fed into the next phase.

D) FOURTH MODULE: Intermediate code generation: The output of semantic analyzer will be
fed as input and an intermediate code,i.e.the three address code will be generated.

D) FIFTH MODULE: The Code Optimization Phase: The intermediate code will be fed as input
to this phase. This module is basically constructed to reduce the unnecessary and useless lines
of code,by doing some easy peephole optimizations like dead code eliminations (eg.removing
declarations of variables which have never been used) ,constant folding etc. The output will be a
program which reduces the run-time of the program since all the errors,useless and time and
space consuming variables and operations have been eliminated at this stage only.

E) SIXTH MODULE: The Code Generation Phase: The final code (i.e. in the assembly
language) is generated which will be the final output.

You might also like