Sunteți pe pagina 1din 6

Subject : Compiler Design Code: T141

UNIT-I
1. What is compiler? Explain the various phases of compiler with neat sketch?
2. a) Explain the functions of the Lexical Analyzer with its implementation?

[15 M]
[7M +8M]

b) Explain about the LEX tool?


3. a) Explain in detail about the role of Lexical analyzer ?

[7M + 8M]

b) write the compilation process for the following statement.


a:=b+c*100;
4. Describe in detail about input buffering. What are the tools used for constructing a
compiler?
[15M]
5. Explain the various phases of a compiler in detail. Also write down the output for the
following expression after each phase a: =b*c+d
[15M]
6. a) Mention the issues in lexical analyzer?
[7M + 8M]
b) Construct the transition diagram to recognize the tokens for identifiers and digits?.
7. a) Explain about the boot strapping?
b) Explain the pass and phases of compiler?
8 . a) Give the diagrammatic representation of a language processing system.
b) Write the difference between compiler and interpreter?
9 . a) What is a symbol table? Give example.
[7M + 8M]
b) Describe the Analysis - Synthesis Model of compilation.

[7M + 8M]

10. a) Explain the back-end phases of Compiler?


b) What are the different translation rules of a LEX program? Explain.

[7M + 8M]

[7M + 8M]

UNIT-II
1. a) Define a context free grammar?explain with example.
b) Consider the grammar
S->(L)| a
L->L,S|S

[7M + 8M]

i) What are the terminals, non terminals and start symbol


ii) Find parse tree for (i) (a,a) (ii) (a,(a,a) (iii) (a,((a,a),(a,a)))
2. a) Construct the predictive parsing table for the following grammar:
S->(L)|a
L->L,S|S
b) Write short notes on LL (1).

[10M + 5M]

3. Consider the grammar: E->E+T /T, T->T*F/F, F->(E)/id.


construct an LL(1) Parsing table for the given grammar. Give the moves of LL(1) parser on
id*id+id.
[15M]
4. a) Explain about the FIRST and FOLLOW functions?

[7M +

8M]
b) Explain about the backtracking?
5. a) Define ambiguous grammar. Elobarate with suitable example.
8M]

[7M +

b) Construct the recursive descent parser for the following grammar

E->TE
E->+TE|
T->FT
T->*FT|
F->(E)|id
6 .a) Check whether the following grammar is LL(1) or not?
S-> Aa|bAc|Bc|bBa
A->d
B->d
b) Explain about left factoring and left recursion with example?
7. a) Check whether the following grammar is a LL(1) grammar or not?
S->iEtS|iEtSeS|a
E->b
b) Explain about recursive descent parser?

[9M + 6M]

[8M + 7M]

8 . a) Find the predictive parser for the given grammar and parse the sentence (id+id)*id.
E->E+E | E*E | (E) | id.

[9M + 6M]

b) write the problems in TOP DOWN parsing?


9. a) Design a derivation tree for the following grammar
S->aS|aSbS|
Also obtain the LMD and RMD for the string aaabaab
b) eliminate left recursion from the following grammar
E->E+T|T
T->T*F|F
F->(E)|a

[9M + 6M]

10 . a) Define CFG? Explain about ambiguity?


b) Explain the pre processing steps required for predictive parsing?

[7M + 8M]

UNIT-III
1. a) Define bottom up parsing technique? Write the differences between Top-Down

and Bottom Up parsing?


[7M + 8M]
b) Explain the structure of the LR parser?
2. a) Consider the following grammar
[10M + 5M]
S->(L)|a
L->L,S|S
Parse the input string: (a,(a,a)) using Shift Reduce Parser.
b) What is shift reduce conflict?
3. a) Construct the SLR(1) parsing table for
[10M + 8M]
E->E+T|T
T->T*F|F
F->(E)|id
b) explain about the handle pruning?
4. a) Consider the following grammar
S AS | b
[8M + 7M]
A SA | a
Construct the SLR parse table for the grammar. Show the actions of the parser for
the input string abab
b) Explain about the error recovery in predictive parsing?
5 . Find the closure(I) and goto(I) for the following grammar
[15M]
E->E+T|T
T->T*F|F
F->(E)|a
Construct SLR parsing table and parse the input string for a*a+a using above grammar.
6 . a) Describe about the LR parsers?
b) Construct LALR(1) parser for the following grammar.
SL=R
SR
L*R
L id
RL

[5M + 10M]

7 .a) Construct SLR parsing table for the grammar and parse the string: ( )( )$

[10M + 5M]

SS(S)
S
b) Explain about the actions of the LR parser?
8. a) Describe briefly about YACC parser generator.

[8M + 7M]

b) Write the comparisions of LR Parsers?


9 a) Construct CLR parser for the following grammar

[9M + 6M]

S->CC
C->aC|d
b) Write short notes on Shift Reduce Parser?
10 a) Build the SLR(1) parsing table for the following grammar:
E->E+T|T
T->T*F|F
F->F*|a|b
b) Distinguish between the CLR and LALR parsing?

[10M + 5M]

UNIT-IV
1 .a) For the following given grammar construct the Syntax directed definition and generate

code fragment using S attributed definition


[9M + 6M]
S->EN
E->E+T
E->E-T
E->T
T->T*F
T->T/F
T->F
F->(E)
F->digit
N->;
Also calculate the input string 2*3+4; with parser stack using LR parser method.
b) What are the benefits of intermediate code generation?
2 a) What are the various types of intermediate code representation?

[7M + 8M]

b) Give a syntax-directed definition to translate infix expressions into infix expressions


without redundant parenthesis.

3 a) What are the various methods of implementing three address statements? [7M + 8M]

b) Describe briefly about the construction of syntax trees ?


4 a) Explain syntax directed translation schemes.

[7M + 8M]

b) What is a three address code? List the common three address instruction forms.
5 a) To construct the 3- address code for the following expression.
x=-a*b+-a*b

[7M + 8M]

b) What are the different implementation methods for three-address code?


6 a) Explain in detail about the run time storage management.

[7M + 8M]

b) Discuss in detail about the storage allocation strategies.


7 . What is three-address code? Mention its types. How would you implement the three

address statements? Explain with suitable examples.

[15M]

8 a) Draw the syntax tree and DAG for the expression (a*b)+(c-d)*(a*b)+b [7M + 8M]
b) Give the translation scheme that converts infix to postfix form for the following
grammar. Also generate the annotated parse tree for input string 2+6+1
E-> E+T
E->T
T->0|1|2|3|4|5|6|7|8|9
9 . Write short notes on the following

[4M + 4M + 3M + 4M]

a) Activation Record
b) Dynamic scope
c) Call by reference
d) Access links
10. a) How would you generate intermediate code for the flow of control statements?
[8M + 7M]
b) Explain about the S- attributed grammar?

UNIT V
1. a) Explain the design issues of a code generator.

[8M + 7M]

b) What is a DAG? Mention its applications.


2. a) Explain about the peephole optimization.

[8M + 7M]

b) Machine dependent code generation?

3. a) Discuss about the principle sources of code optimization.


b) Explain the DAG representation of Basic blocks with example.

[7M + 8M]

4. a) Explain the code generation algorithm with example?


b) Write short notes on the following
i) Frequency Reduction

[9M + 6M]

ii) Unreachable code

5 a) Write shortly about DAG (Directed Acyclic Graph) representation.Draw the DAG for
the expression a: = b *-c + b*-c.

[7M + 8M]

b) Explain in detail about loop optimization techniques.


6 a) Draw the DAG for the statement a=(a*b+c)-(a*b+c).
[7M + 8M]
b) Explain the register allocation and assignment in target code generation?
7 a) Explain syntax directed translation to draw syntax tree. Draw syntax tree and DAG

for
a + a * (b c) + (b c) * d

[7M + 8M]

b) What is the function of Code Generation and Optimization?


8

a) What are the object code forms ? explain the issues in code generation?

[8M + 7M]

b) Construct the DAG for the following basic block

d:=b*c
e : = a +b
b:=b*c
a:= e- d
9

a) Explain various types of optimization techniques?

[8M + 7M]

b) Explain the simple code generator?


10 a) Discuss about the loop optimization techniques?
b) Explain the copy propagation and dead code elimination with example.
*************

[7M + 8M]

S-ar putea să vă placă și