top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

CS: What are the steps performed by a compiler ?

+2 votes
364 views

What steps are performed by a compiler and how many types of compilers are present and used frequently ?

posted Jan 9, 2017 by Vikram Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

It is very popular question during the interviews either for fresher or lateral hiring. Compiler jobs is to take high level language program and convert into machine level. There are various phases of compiler and defined as follows:
1. Pre-processing:
In this phase, pre-processor expands the program by expanding the pre-processor directives. For example: #include<stdio.h>, #define X 5.

  1. Compilation:
    Now compiler takes expanded program and generates assembly program as output. There are various steps between input (expanded program) and output (assembly program). I would like to list down all those steps:

    • lexical analysis
    • syntax analysis
    • semantic analysis
    • generation of intermediate code
    • optimization of intermediate code
    • generation of pseudo code
  2. Assembling:
    In this steps, assembler takes assembly level code and generates object code (machine instruction)

  3. Linker:
    In this stage, generated object codes are linked to each other to generate a binary (executable)

Hope this will be very helpful.

answer Jan 10, 2017 by Harshita
...