Compiler Design
Compiler Design
1 Answer All
a Define TOKEN, PATTERN and LEXEM.
1
b Find the tokens in the following C statements:
1
if ( a <= b )
C=d;
else
C = 5;
c What are the precedence and associative rules of the operators in the following grammar:
1
E-> E * F | F + E | F,
F->F – F | id
d Define handle. What is handle pruning ?
1
e Define Synthesized attributes and Inherited attributes.
1
f What are the difficulties with Top-down parsing ?
1
g Define Back-patching.
1
h Differentiate between L-attributed and S-attributed grammar.
1
i What is dead code elimination?
1
j Describe various data structures used for implementing symbol table and their respective
1
time complexity for LOOK_UP operation.
2 Answer All
a Write a LEX program to recognise multiple line comment in a C program.
3
b Compute FIRST and FOLLOW for all non terminals in the following grammar:
3
E-> TE'
E' → +TE' | ε
T → FT'
T' → *FT' | ε
F → (E) | id
c Write the algorithm to compute CLOSURE of a set I of LR(0) items.
3
d Construct the syntax tree and draw the DAG for the expression
3
(a * b) + (c - d) * (a * b) + b.
e What is strength reduction? Explain with an example.
3
[P. T. O.]
3 Answer any One
a Design Transition diagram to recognize identifier, single and multiple line comment, and
7
relational operators in C programming language.
b Describe various phases of compiler with a suitable example and a neat diagram.
7