What is
Compiler Design?
A compiler
translates the code written in one language to some other language without
changing the meaning of the program.
A
compiler acts as a translator, transforming human-oriented programming
languages into computer-oriented machine languages.
======================================
Compiler performs two major tasks:
·
Analysis of the source program
·
Synthesis of a machine-language program
Compiler Phases:
The
compilation process is a sequence of various phases.
1.Lexical analysis:
Lexical
analysis is the first phase of a compiler.
It takes
the modified source code from language pre-processors and breaks these
syntaxes into a series of tokens, by removing any whitespace or comments in the
source code.
===========================================================
2. Syntax Analysis:
It
takes the token produced by lexical analysis as input and generates a parse
tree (or syntax tree).
3. Semantic
Analysis:
Semantic
analysis checks whether the parse tree constructed follows the rules of
language. For example, assignment of values is between compatible data types,
and adding string to an integer.
4. Intermediate
Code Generation:
Interpreters
are easier to write and can provide better error messages (symbol table is
still available)
5. Code
Optimization:
The
next phase does code optimization of the intermediate code.
6. Code Generation:
In this
phase, the code generator takes the optimized representation of the
intermediate code and maps it to the target machine language.
===================================
If you
like this post then like this post and also share this post.
Visit
us @ tccicomputercaoching.com
Call us
@ 9825 18292
No comments:
Post a Comment