DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
2007-2008, EVEN SEMESTER
PRINCIPLES OF COMPILER DESIGN-CS1352
1. What does translator mean?
A translator is a program that takes a input program on one programming
language (source language) and produces output in another language (object
language or target language).
2. What are the phases of a compiler?
• Lexical analysis phase or scanning phase
• Syntax analysis phase
Intermediate code generation
• Code optimization
• Code generation
3. What is the role of lexical analysis phase?
Lexical analyzer reads the source program one character at a time, and
grouped into a sequence of atomic units called tokens. Identifiers, keywords,
constants, operators and punctuation symbols such as commas, parenthesis, are
4. Define lexeme?
The character sequence forming a token is called lexeme for the token.
5. What are the two functions of parser?
It checks the tokens appearing in its input, which is output of the lexical
It involves grouping the tokens of source program into grammatical
phrases that are used by the compiler to synthesize the output. Usually
grammatical phrases of the source program are represented by tree like
structure called parse tree.
6. Mention the role of semantic analysis?
Semantic analysis checks the source program for semantic errors and
gathers information for the subsequent code-generation phase.
It uses hierarchical structure to identify the operators and operands of
expressions and statements.
□ An important component of semantic analysis is type checking .In type
checking the compiler checks that each operator has operands that are
permitted by the source language specification.
In such cases, certain programming language supports operand coercion or
type coercion also.
7. Name some variety of intermediate forms.
o Postfix notation or polish notation.
o Syntax tree
o Three address code
8. Write th