CD Ques

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

MODEL I

1. Describe the various phases of a compiler and tract it with the program segment (position
initial rate 60)
2. (i) Explain language processing system with neat diagram
(i) Write notes on compiler construction tools
3. Use direct method to construct DFA from the following RE (a/b)+(ab).
4. Give the minimized DFA for the following expression using Thomson subset construction
algorithm. (a/b)*abb.
5. Describe the language for specifying lexical Analyzer.
6. Write in detail about
(i) Recursive descent parsing with algorithm.
(ii) Top down parsing with algorithm.
7. Consider the grammar
(i) S->ABD
(ii) A->a | Dbc
(iii) B-> gD | dAc
(iv) D-> e l f
Construct FIRST and FOLLOW for each nonterminal of the above grammar.
Construct the predictive parsing table for the grammar.
Show the parsing action on a valid string and on an invalid string
Check whether the grammar is LL (1). Give justification.
8. Construct stack implementation of shift reduce parsing for the grammar
(i) E->E+E
(ii) E->E*E
(iii) E->(E)
(iv) E->id
(v) and the input string id1+id*id3.
9. Constract SLR parsing for the following grammar
(i) E->E+T I T
(ii) T->T*F | F
(iii) F-> (E) | id

10. Write the algorithm for construction of LALR parsing table for a given grammar
(i) S'->S
(ii) S->aAd | bBd | aBe | bAe
(iii) A-> c
(iv) B-> c
11. Construct NFA for the following Regular Expression (a*/b*)*.
12. Construct Optimized DFA for the following Regular Expression (a/b)*a(a/b).
MODEL II
13. Construct the Syntax-Directed Definition and annotated parse tree from the given grammar
for the input expression: "int a, b, e".
(i) D-TL
(ii) T-int
(iii) T-float
(iv) L-L, id
(v) L-id

14. Explain in detail about Evaluation orders for syntax directed definition with suitable
examples.

15. Define three address code and explain the different ways of implementing the three-address
code for the following statements:
(i) A=b*-c+b*-c;

16. Discuss in detail about types and declarations.

17. Describe the below with suitable example,


(i) Operations within expression
(ii) Incremental translation
(iii) Addressing array elements

18. Explain static and dynamic allocation in details.

19. Describe the below with suitable example,


(i) Activation Tree
(ii) ii) Activation Record
(iii) iii) Calling Sequences
(iv) iv) Variable-Length Data on the Stack

20. Elaborate the various Heap management in detail

21. Describe in details about a simple code Generator

22. Elaborate the various imues in code generation with examples.

23. Elaborate the various imues in code generation with examples.


24. Generate an intermediate code for the following code segment with the ( required syntax-
directed translation scheme.
(i) if (a>b)
(ii) xa+b
(iii) else
(iv) xa-b

MODEL III

25. Construct the NFA from the (a/b)*a(a/b) using Thompson's construction algorithm.

26. (i) Analyze the role of lexical analyser with suitable examples. (7)
(i) (ii)Draw and explain the transition diagram that recognizes the lexemes matching
the token relop (relational operator)

27. Construct predictive parsing table and parse the string NOT(true OR false)
(i) bexpr-bexpr OR bterm | bterm
(ii) bterm-bterm AND bfactor | bfactor
(iii) bfactor--NOT bfactor | (bezpr) | true | false

28. (1) Find the language from


(i) S-0510A1A-1A0110
(ii) Define Parse tree, Regular Expression, Left most derivation Right most
derivation, and write example for each.
(iii) Write algorithm de convert NFA from Regular expression
(iv) iv) Find the language from
(v) S-0S10A|0|1B|1
(vi) A-0A10
(vii) B-1B 1
29. Write Syntax Directed Definition and evaluate 9*3+2 with parser stack using LR parsing
method.
30. Construct parse tree, syntax tree and annotated parse tree for the input string is 5*6+7 with
three address instructions.
31. Illustrate the algorithm that generates code for a single basic block with three address
instructions.
32. Explain in detail about Access to Nonlocal Data on the Stack
33. Explain the principle sources of optimization in detail.
34. Optimize the following code using various optimization techniques:
(i) i=1,s=0;
(ii) for(i=1;i<=3;i++)
(iii) for(j=1;j<=3;j++) c[i][j]c[i][j]+a[i][j]+b[i][j];

35. Write and explain the algorithm for construction of basic blocks. Construct the DAG for the
following basic block.
(i) x=a[i]
(ii) a[j]=y
(iii) z=a[i]
36. Consider the Context-Free Grammar(CFG) depicted below where "begin","end" and "x" are
all terminal symbols of the grammar and stat is considered the starting symbol for this
grammar. Productions are numbered in parenthesis and you can abbreviate "begin" to "b"
and "end" to "e" respectively. Stat Block
(i) Block begin Block end
(ii) Block Body
(iii) Body x
Compute the set of LR(1) items for this grammar and draw the corresponding DFA. Do not
forget to augment the grammar with the initial production S→Starts as the production(0).
Construct the corresponding LR parsing table.

You might also like