Online Compiler Design Course in Ahmedabad
What is Compiler Design?
A compiler translates the code written in one language to some other language without
changing the meaning of the program. It is also expected that a compiler should make the
target code efficient and optimized in terms of time and space.
A compiler acts as a translator, transforming human-oriented programming languages into
computer-oriented machine languages.
Language Compiler Language
Any compiler must perform two major tasks
Analysis of the source program
Synthesis of a machine-language program
The compilation process is a sequence of various phases. Each phase takes input from its
previous stage, has its own representation of source program, and feeds its output to the
next phase of the compiler. Let us understand the phases of a compiler.
Lexical analysis is the first phase of a compiler. It takes the modified source code from
language pre-processors that are written in the form of sentences. The lexical
analyzer breaks these syntaxes into a series of tokens, by removing any whitespace or
comments in the source code.
A programming language must include the specification of syntax (structure) and semantics
Syntax typically means the context-free syntax because of the almost universal use of
a = b + c is syntactically legal
b + c = a is illegal
The token name is an abstract symbol representing a kind of lexical unit, e.g., a particular
keyword, or sequence of input characters denoting an identifier.
The next phase is called the syntax analysis or parsing. It takes the token produced by le