Learn Phases of
Analysis-Compiler Design course at TCCI, Ahmedabad
Definition of Complier
“A compiler
translates a program written in a high-level programming language into the
low-level machine language that is machine can understand.”
Generally,
the source language is a high level language and the target language is a low
level language (machine code). So, there is always need to convert source code
into machine code.
Main two
parts there are in compilation:
Understand
the program (check is it correct or not)
Rewrite the
program in the target language.
To make
perfect structure the whole compilation process is split into several phases
with well-defined interfaces. All of these phases operate in sequence each
phase (except the first) taking the output from the previous phase as its
input.
The first
three phases are called the frontend of the compiler and the last three phases
are collectively called the backendof the compiler.
This is the
initial part: The Data is entered as an INPUT, then read by compiler and
divided into tokens, each of which corresponds to a symbol in the programming
language, e.g., a variable name, keyword or number.
This phase
is also called scanner because it takes data as input.
Syntax analysis:
This phase
takes the list of tokens produced by the lexical analysis and arranges these in
a tree-structure (called the syntax tree) that reflects the structure of the
program. This phase is often called parsing. Parsing is to check that we have a
valid sequence of tokens. Tokens are valid sequence of symbols, keywords,
identifiers etc.
Type checking:
This phase
analyses the syntax tree to determine if the program violates certain
consistency requirements, e.g., Used variable is declared or not, data type are
matched or not. Type checker verifies that the type of a construct (constant,
variable, array, list, and object) matches what is expected in its usage
context.
Intermediate code generation:
The program
is translated to a simple machine independent intermediate language.
Register allocation:
The symbolic
variable names used in the intermediate code are translated to numbers, each of
which corresponds to a register in the target machine code
Machine code generation:
The
intermediate language is translated to assembly language for a specific machine
architecture.
Assembly and linking:
The
assembly-language code is translated into binary representation.
Each phase use an output form of the program produced by an earlier
phase as an input.
Subsequent phases operate on lower-level code representations.
Visit us @http://tccicomputercoaching.com/Course.html
Call us @ 98256 18292.
No comments:
Post a Comment