CS8602 Compiler Design Part B - QB
CS8602 Compiler Design Part B - QB
Mr. V.GURUNATHAN 16. Prove that the following two regular expressions are equivalent
by showing that the minimum state DFA’s are same.
i) (a/b)* ii) (a*/b*)* [Dec 09, May 15] (16)
ASSISTANT PROFESSOR
17. Illustrate Thomson’s construction by drawing a NFA for the
regular expression (a/b)*a. Convert this NFA to DFA using
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
subset construction. Write the algorithm for subset construction. Construct a predictive parsing table for the grammar shown
[May 11] (16) above. Verify whether the input string id + id * id is accepted by
18. Construct the minimized DFA for the regular expression the grammar or not. [Dec 05] (12)
(0+1)*(0+1) 10. [Dec 11] (8) 8. (i) Construct the predictive parser for the following grammar.
19. Draw the DFA for the augmented regular expression (a/b)*# S→(L)|a
directly using syntax tree. [Dec 13] (12) L→L, S|S
20. Construct a DFA directly from an augmented regular expression (ii) Construct the behavior of the parser on the sentence (a,a)
((Ɛ/a)b*)*. [Dec 12] (10) using the grammar specified above. [May 07,12,13] (10)
21. Construct DFA to recognize the language (a/b)*ab. Pg.No.2.50 9. Check whether the following grammar is LL(1) grammar.
[May 16] (8) S→iEtS/iEtSeS/a
22. Explain in detail about LEX. (8) E→b.
23. Explain in detail to convert NFA with Ɛ to without Ɛ with Also define FIRST and FOLLOW procedures. [May 16] (8)
example. (8) 10. Construct non recursive predictive parsing table for the
following grammar.
E→E or E| E and E| not E| (E)| 0| 1. [Dec 12] (16)
UNIT - II SYNTAX ANALYSIS 11. Explain in detail about Bottom-up Parsing with example.
1. Explain in detail about Context Free Grammar.[Dec 05, May 16] [May 10,11,16] (8)
(10) 12. Consider the grammar
2. What is an ambiguous grammar? Is the following grammar E→E + E
ambiguous? Prove E→E+E|E*E|(E)|id. The grammar should be E→E * E
moved to the next line, centered. [May 14] (8) E→ id
3. Explain in detail about Top-down Parsing with example. Perform Shift-Reduce parsing of the input string “id1+id2+id3”.
[May 15] (10) [May 16] (8)
4. Eliminate the left recursion from the following grammar A→Ac| 13. Explain in detail about Operator Precedence Parser with
Aad|bd|c. [May 07] (10) example. [May 06] (8)
5. Write down the algorithm to eliminate left-recursion and left 14. Explain in detail about Simple LR Parser (SLR) with example.
factoring and apply both to the following grammar. [May 11,13,14,15] (16)
E→E+T|E-T|T 15. Construct the SLR(1) parsing table for
T→a|b|(E) [May 15] (8) E→E+T
6. Explain in detail about Predictive Parsing LL(1). [May 11,12,16] E→T
(16)
T→T * F
7. Consider the grammar
T→F
E → TE’
F→ (E)
E’ → + TE’ / Ɛ
T → FT’ F→ id
T’ → *FT’ / Ɛ [May 11] (10)
F → (E) / id 16. List all LR(0) items for the following grammar
S→AS/b 5. Write a top-down translation scheme to produce quadruples for
A→SA/a [May 13] (8) Boolean expression. (8)
17. Generate SLR parsing table for the following grammar 6. Discuss specification of a simple type checker. [May 16] (8)
S→Aa|bAc|Bc|bBa 7. What are the various methods of implementing three address
A→d statements? [May 11,13] (16)
B→d 8. Describe the various types of three address statements.
and parse the sentence “bdc” and “dd” [May 12] (8)
[May 15] (10) 9. Explain the various types of assignment statements. [May 11,13,14]
18. Explain the LR parsing algorithm in detail. (8) (8)
19. Explain in detail about LALR parsing algorithm with example. 10. Translate the following integer array operation into three address
[Dec 06,07,13] (16) code. A[i,j] := B[i,j] + C[k] where A and B are of size 10 x 20
20. Give the LALR parsing table for the grammar. and C contains 50 elements. [May 10] (16)
S→L=R/R 11. Discuss the various methods for translating the Boolean
L → * R / id expression. [May 11,12] (12)
R→L [Dec 06,07] (12) 12. Explain in detail about Case statement. [May 08,14] (16)
21. Compare SLR, LALR and LR parses. (8)
13. Write short note on procedures calls. [Dec 11,13] (8)
22. Explain in detail about the error recovery strategies in paring. 14. Explain in detail about back patching. [May 13,14] (8)
[May 06,07,11] (8)
23. Explain in detail about YACC. UNIT - IV RUN-TIME ENVIRONMENT AND CODE
GENERATION
UNIT-III INTERMEDIATE CODE GENERATION
1. Explain in detail about the storage organization. [May 07] (10)
2. Discuss different storage allocation strategies. [May 11,13,14,16]
1. Explain in detail about Syntax-Directed translation. (16)
[May 15] (8)
2. Give a syntax definition to differentiate expressions formed by 3. Distinguish between the source text of a procedure and its
applying the arithmetic operators + and * to the variable x and activation at own time. [May 11] (8)
constants; expression x * ( 3 * x + x * x ). [May 15] (8) 4. Discuss various ways of implementing symbol table and
3. What is attributed Grammar? Explain with suitable example. compare merits and demerits. May 12, Dec 06,07,10] (8)
(8) 5. Explain in detail about Dynamic storage allocation techniques.
4. Construct a syntax directed definition for constructing a syntax (8)
tree for assignment statements. [May 16] (8)
6. What are the issues to be handled during code generation?
S→id := E
Explain how these issues are handled. Give examples to support
E→E1 + E2
your explanation. [May 11,12,14,16, Dec 10] (16)
E→E1 * E2
7. Explain in detail about simple code generator algorithm with
E→ -E1
example. [May 10,11,12,15,16, Dec 11,14] (16)
E→ (E1)
E→ id
8. Generate assembly language for W : = (A+B) + (A+C) + (A+C). 9. What are the sources of redundancy in code? Give examples
[May 10] (8) using flow graphs. When is a flow graph said to be reducible?
9. Write a code generation algorithm to generate code machine What are the properties of natural loops? [May 11] (16)
instructions for operations and copy statements. Indicate the use 10. Discuss in detail about global data flow analysis. [Dec 13] (16)
of register and address descriptors in code generation. Trace the 11. Explain in detail about the dataflow analysis concept with
algorithm and show the code generated for the following three suitable example. [May 12,14] (16)
address statements: [May 11] (16) 12. Explain in detail about efficient dataflow algorithms with
t =a-b suitable example. [May 13, Dec 09] (16)
u=a-c
v=t+u
a=d
d=v+u
10. Construct DAG and optimal target code for the expression
x = ( (a+b) / (b-c) – (a+b) * (b-c) + f SUBJECT I/C HOD IQAC PRINCIPAL
[May 15] (8)