Sei sulla pagina 1di 4

Ahmedabad Institute of Technology

CE Department

Compiler Design (2170701)

Assignment

Assignment -1 (Any Five Question out of 7) -25 Marks


1 Write a brief note on input buffering techniques. 4

2 Explain phases of compiler with example. 7

3 What is symbol table? For what purpose , compiler uses symbol 7

table?

4 Construct NFA for following regular expression using Thompson’s 7

notation and then convert it into DFA. (a/b)*abb#

5 Explain subset construction method with example. 7

6 Define handle and handle pruning. Explain the stack implementation of 7


shift reduce parser with the help of example.

7 Give the translation scheme that converts infix to postfix notation. 7

Generate the annotated parse tree for input string 3-5+4.

Assignment -2 (Any Five Question out of 8) -25 Marks


1 Check given grammar is LL(1) but not SLR(1). 7

S -> AaAb | BbBa


A -> €
B -> €

2 What is left factoring and left recursion? Explain it with suitable example. 7

3 Define syntax tree. What is s-attributed definition? Explain construction of 7


syntax tree for the expression a-4+c using SD

4 Explain parameter passing techniques for procedure. 4


5 Construct LL(1) parsing table for the following Grammar: 7

E -> E+T | T
T -> T*F | F
F -> (E) | a
OR
Check following grammar is LL (1) or not?
S -> aB | €
B -> bC | €
C -> cS | €
OR
S -> aAC | bB
A -> Abc | Abd | e
B -> f | g
C -> h |i
OR
S → iEtS | iEtSeS | a
E→ b

6 Construct SLR parsing table for the following grammar : 7

S ->(L)|a
L->L,S|S
OR
S -> aAb | bB
A -> Aa | ε
B -> Bb |ε

7 Give the difference between synthesized attributes and inherited attributes 4

8 Construct CLR parsing table for the following grammar : 7

S ->AA
A->aA|b
OR
S -> aSA | €
A -> bS | c

Assignment -3 (Any Five Question out of 7) -25 Marks


1 Give the translation scheme that converts infix to postfix expression for the 4
following grammar and also generate the annotated parse tree for input
string “id+id*id”
E -> E+T | T
T -> T*F | F
F -> id

2 What is operator grammar? Check the following grammar is 4

operator or not. Justify your answer.


E-> EOE
E-> id
O-> * | + | -
OR
Define operator precedence grammar. Construct precedence matrix and
precedence graph for arithmetic grammar as shown below:
E -> E + T | T
T -> T * F | F
F -> (E) | id

3 Explain error recovery strategies used by parser. 7

4 What is importance of intermediate code? Discuss various representations 7


of three address code using the given expression. a = b * -c + b * -c . or
a + a * (b- c) + (b – c) * d.

5 Explain Quadruple, triple and indirect triple with suitable example 7

6 What is activation record? Explain stack allocation of activation records 7


using example.

7 What is activation tree? 7

Assignment -4 (Any Five Question out of 8) -25 Marks


1 What is an activation record? Explain how they are used to access local and 7
global variables.

2 Explain three loop optimization techniques with example. 7

3 What is code optimization? Explain data flow equation. 4

4 Describe code generator design issues. 4

5 Define following : DAG, Basic Blocks, Flow graph 7

6 Explain peephole optimization 4

7 Draw syntax tree and DAG for the statement 4

x=(a+b)*(a+b+c)*(a+b+c+d)
Draw a DAG for expression: a + a * (b – c) + (b – c) * d.
OR
d: = b * c
e: = a + b
b: = b * c
a: = e – d

8 Explain dynamic memory allocation strategy.OR 4

Compare: Static v/s Dynamic Memory Allocation.

Prepared By:

Prof. Neha Prajapati,

Asst. Prof. CE Dept, AIT

Potrebbero piacerti anche