Search your Topic HERE....

February 26, 2012

The Phases of Compiler

26 comments

sponsored links

There are several Phases in compilers are there. Those are,
  1. Lexical Analyser : Performs Lexical Analysis 
  2. Syntax Analyser : Performs Syntax Analysis
  3. Semantic Analyser : Performs Semantic Analysis
  4. Intermediate Code Generator : Performs Intermediate Code Generation
  5. Code Optimizer : Performs Code Optimization
  6. Code Generator : Generates Target Code 



The Symbol Table is a Data Structure which is useful to store the identifiers in the program. 

The Error Handler is useful in Detecting and Reporting the errors. 

These two are useful from the starting to the ending of the conversion. ( I mean from the starting phase to the ending phase).  

NOTE : We can group these phases into two parts.. 
  • Analysis : In which the compiler ANALYZES the given program. For this, the compiler SCANS and DIVIDES the program into parts. The first THREE phases comes under this category (shortcut : Check the names, if you can find the terms Analysis or Analiser, then that phase comes under the ANALYSIS category
  • Synthesis : In which the compiler JOINS the parts of the divided program and makes the target program. (The last two phases comes under this category)
Now lets have a look at the functionalists of all these phases. 

Lexical Analysis : It is nothing but analyzing the LEXEMs (tokens), in this phase, the compiler scans the entire program and pics the tokens and groups them.

Syntax Analysis : Syntax is nothing but the structure. It is nothing but to Analyze the structure of the program (whether it is correct or not)

Semantic Analysis : In this the compiler checks the MEANING of the program.

(Note : The above two process will execute simultaneously, so in some books they combine these two names and call the process as Syntax and Semantic Analysis)

Intermediate Code Generation : After scanning the program, the compiler generates an intermediate code (which is neither High level code nor Low level code, which looks like the Microprocessor Code)

Note : Most of the compilers generates the TAC (Three Address Code) as the Intermediate Code. It contains, maximum 3 variable, so we call it as the Three Address Code. (note : we can convert any problem into this TAC form).

it just look like, Temp1 = Temp2 + Temp3  (temporary  variables) 
       or Temp2 = Id + Temp4     etc,

Code Optimization : It helps to improve the Intermediate Code. It make assure that the target code will run EFFICIENTLY in LESS TIME ( i mean, it should give the desired output in less amount of time)

Code Generation : It is the final phase. It generates the relocatable machine code or assembly code. It takes care about the target machine and where to store the variables in the target machine. Yea of course, it takes care about the ORDER of the instruction execution too.

That's all for now Friends.. Happy Reading..                        


sponsored links

26 comments:

  1. Thousands of cordial thanks for such an immense help...

    ReplyDelete
  2. thank you very much ............:)

    ReplyDelete
  3. .......................

    ReplyDelete
  4. thank u............

    ReplyDelete
  5. Nice effort dudes!!!! thanks a lot......

    ReplyDelete
  6. Thanks a lot. Its very useful.

    ReplyDelete
  7. Thanks a ton for making the topic so easy by using such good examples.you people are doing a great job.

    ReplyDelete
  8. Thanks and
    plz provide some more extension of data useful for ibps it officers exam

    ReplyDelete
  9. gr8 job,gr8 ambitionz

    ReplyDelete

  10. Hello...
    Nice to see you can you clarify one of my doubt please ....
    as per the notification released by the IBPS ,General Awareness is not the subject for IBPS specialist officer but when comes to the old papers it as the subject of the exam i getting confused(I am applying for IT-officer Scale1)

    ReplyDelete
  11. Thank u so much ..:) Can u add some topics related to Data Mining also...

    ReplyDelete
  12. thanks a lot,its really helpful

    ReplyDelete
  13. thanks a lot..........

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...