0% found this document useful (0 votes)
20 views6 pages

CD QB - Prep

The document is a comprehensive question bank for the Compiler Design course (18CSC304J) at SRMIST, Kattankulathur. It includes a variety of questions covering fundamental concepts such as translators, compilers, grammars, parsing techniques, and code generation. The questions are divided into two parts, with Part-A focusing on definitions and concepts, while Part-B delves into detailed explanations and examples related to compiler construction and parsing methods.

Uploaded by

bm8968
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views6 pages

CD QB - Prep

The document is a comprehensive question bank for the Compiler Design course (18CSC304J) at SRMIST, Kattankulathur. It includes a variety of questions covering fundamental concepts such as translators, compilers, grammars, parsing techniques, and code generation. The questions are divided into two parts, with Part-A focusing on definitions and concepts, while Part-B delves into detailed explanations and examples related to compiler construction and parsing methods.

Uploaded by

bm8968
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

SRMIST, KATTANKULATHUR

School of Computing

QUESTION BANK

18CSC304J- COMPILER DESIGN

PART-A

1. What is a translator?
2. Differentiate interpreters and compilers.
3. What is an assembler?
4. What are the phases of a compiler?
5. What is bootstrapping a compiler?
6. What are the two parts of compilation? Give a Diagram.
7. Give the parse tree for the statement a:=b+c*60.
8. What is the use of scanner generator?
9. What do you mean by syntax and semantics of a language?
10. Give some four compiler-generator tools.
11. Mention the cousins of the compiler.
12. Define a token.
13. What is a preprocessor?
14. What is a symbol table?
15. Define regular expressions.
16. Write down the Algebraic laws obeyed by Regular expressions
17. Define a finite state automation.
18. Draw the NFA for a*b*
19. Draw the NFA for R = (( ε | a ) b* ) *
20. Give the Procedure for ε-Closure
21. What is a transition diagram? Give example.
22. What is a recognizer?
23. What is CFG? Give example.
24. What are the capabilities of CFG?
25. Describe language denoted by the following regular expression:
0(0/1)*0
26. Describe language denoted by the following regular expression:
(0/1)*0(0/1)(0/1)
27. Describe language denoted by the following regular expression:
0*a0*a0*a0*
28. Write the regular definition for the following language:
"All strings of digits with no repeated digits"
29. Give an example for ambiguous grammar and justify it.
30. What is a parse tree?
31. What are the types of Grammars?
32. What is a Linear Grammar? Give ex.
33. What do you mean by BNF? Give Ex.

34. Consider the grammar:


S --> (L) /a
L --> L,S /S
What are the terminals, non-terminals and start symbols?
35. Differentiate NFA and DFA.
36. What type of Grammar is the following, Define it.
S -> Aa | Bb | a
A -> aA | c
B -> bB | c
37. Given the grammar S -> a S b S | b S a S | ε
What is the problem in this grammar?
38. What are the types of derivation?
39. What is right-most and left-most derivation? Give example.
40. What is left-sentential form and right-sentential form?
41. Minimise the given transition table:
states a b
A B C
B B D
C B C
D B E
E B C
Initial State=A Final State=E
42. Write regular definition for a number which can have fraction or exponent part as optional.
43. For the following grammar:
list --> list+digit / list-digit / digit
digit --> 0/1/......../9
Derive the sentence (9+5-4) using left-most derivation.
44. What is a Lexical analyzer?
45. Distinguish tokens, patterns and lexemes.
46. What are the lexical-error recovery actions?
47. What is the need for input buffering?
48. Explain prefix and suffix of the string with example.
49. What is a transition diagram? Give example?
50. Draw the transition diagram for identifiers.
51. What is a parser?
52. What is the need for separating the parser from scanner?
53. What are the problems in Top down parsing?
54. What is ambiguity? Give Ex.
55. Consider the Grammer
S -> (L) | a
L -> L , S | S
56. Construct the left most and Right most derivation for the following sentence
(i) (a, a) ii) (a,( (a,a) , (a,a) ))
57. What is Left recursion? Write the rules to eliminate left recursion.

58. Consider the grammar


S -> aSbS | bSaS | e
Show this grammar is ambiguous by constructing parse tree for the sentence abab.
59. Eliminate the left recursion for the following grammar
S --> (L)/a
L --> L,S/S
60. Eliminate Left Recursion in the following Grammar.
A -> Ac | Aad | bd | €
61. What is Left factoring? How do you eliminate it?
62. What is parsing table?
63. What is the use of LEX?
64. What is a handle?
65. What is handle pruning?
66. What do you mean by Precedence and Associativity ?
67. Compare Shift-Reduce Parsing and Operator-Precedence Parsing
68. What are Precedence Matrices and Precedence Functions?
69. What is the use of Boolean Matrices?
70. Translate the arithmetic expression a*-(b+c) into a syntax tree.
71. Write the FIRST and FOLLOW rules
72. Write the LEADING and TRAILING rules
73. What are LR(0) items?
74. When is a grammer called SLR(1)?
75. What is the advantage of using LALR parsing over SLR parsing?
76. Define the CLOSURE and GOTO procedures
77. Define a Quadruple.How it is different from Triples.
78. Convert the exp into three address code & Quadruple.
S=(a+b)/(c-d)*(e+f)
79. Write the prefix & postfix exp for the following
A=(20+(-5)*6+12)
80. What are Synthesized & Inherited Attributes?
81. Give example for inherited attributes.
82. Write the semantic actions for generating a Syntax tree
83. What are the procedures used for Syntax tree generation?
84. Draw the Syntax tree and DAG for
Y = C + D * T ; C = C + D; X = C + D ;
85. Convert the following expression into Postfix and Triples
Z := (X-Y+K) / (A + B) * C
86. Convert the given exp into three address code
a or b and not c
87. What do you mean by Backpatching, why we are going for backpatching.
88. Draw the syntax tree for the following exp
a:=b* -c + b * -c
89. Write the postfix notation for the following exp
(-(a+b)*(c+d)+(a+b+c)).

90. Translate the exp (a+b)*(c+d)+(a+b+c) into


Quadruple b) Triples c) Indirect triples.
91. What is an S-attributed definition?
92. What is a L-attributed definition?
93. What are the issues in Code Generation
94. What do you mean by Peep-hole optimization?
95. Construct DAG for the following exp (a+b)-(e-(c+d)).
96. Write the mnemonic code for (a+b)-(e-(c+d)).
97. Construct the DAG for the following basic block
d:=b*c
e:=a+b
b:=b*c
a:=e-d
98. What is Dangling Reference?
99. What are the three storage allocation strategies?
100. What do you mean by binding of a name?
101. What are the components of an Activation record?
102. What are the various parameter passing techniques?
103. Give example for Call by reference
104. Give example for Call by name
105. What are Static & Stack allocations?
106. What is the need for code optimization?
107. What are the loop optimization techniques?
108. Explain about common sub-expression elimination
109. What is the use of Dominator property in flow graphs?
110. What are Basic Blocks? How to identify them?
---------------------------------

PART-B

1. Discuss the compiler construction tools.


2. Discuss about the cousins of the compiler.
3. Explain the phases of the compiler with diagram. Write down the output of each
phase for the expression a := b + c * 50.
4. Write notes on:
(i) Regular expressions.
(ii) Context Free Grammar.

5. Show that the following grammar is ambiguous


S --> aSbS/bSaS/e
6. For a sentence belonging to the above grammar:
a) Draw the parse tree.
b) Construct the left-most and right-most derivations of "abab".

7. Construct a minimal DFA for (a/b)*(a/b) and write the algorithm for
minimizing a DFA.
8. Explain the process of constructing an NFA from the regular expression.
9. Find the NFA for the expression (a/b)*abb.
10. Construct the DFA for (a/b)*abb and minimise the DFA.
11. Convert the Regular expression to DFA using Thompson’s Construction
R = (a | b)* a ( a | b )
12. How would you construct a DFA directly from a regular expression?
13. Write the appropriate rules and algorithm wherever necessary.
14. a. Discuss the Language for specifying Lexical analyzer
b. Explain the design of a Lexical analyzer generator
15. Explain the Thomson's construction technique in detail. Construct the
NFA for the expression d(a/b)*a.
16. Explain Non recursive predictive parsing technique
17. Explain shift-reduce parsing with stack implementation.
18. Explain Shift Reduce Parsing and Perform the stack implementation to show that the
string not ( true or false ) is parsed using the grammar given below
Bexpr -> Bexpr or Bterm | Bterm
Bterm -> Bterm and Bfactor | Bfactor
Bfactor -> not Bfactor | ( Bexpr) | true | false

19. Explain the operator precedence parsing algorithm with example


20. Explain the algorithm for constructing precedence functions with suitable example
21. Construct SLR parsing table for
S -> AS|0, A -> SA|1

22.a. Check whether the following grammar is a LL(1) grammar


S->iEtS | iEtSeS | a
E->b
b. Explain the first and follow procedures to construct a predictive parser.
23. Find (i) FIRST and FOLLOW (ii) LEADING and TRAILING for the grammer in
Q.22
24. Explain the method of constructing Parsing table and error recovery in predictive
parsing.
25. Construct predictive parser for the following grammar
S -> (L) | a
L -> L,S | S
26. Check whether the following grammar is SLR(1) or not. Explain with reasons.
S -> L = R
S -> R
L -> *R
L -> id
R -> L
27. Construct LR(0) items for the grammar in question 26.
28. a. Construct the LR(0) items for the Grammar given below (8)
E -> E + T | T
T -> TF | F
F -> F * | a | b
b. Construct a SLR parsing table for the above

29. Explain the LALR parsing method with example.


30. Show that the Grammar is LL(1) but not SLR(1)
S -> AaAb | BbBa
A -> ε
B-> ε
31.Write short notes on:
a) Left factoring b) Handle pruning c) Left recursion & backtracking
32. Explain LALR parsing, justify how it is efficient over SLR parsing.
33. Explain the various Inter mediate codes with suitable ex.
34. Explain the process of translating assignment statements
35. Describe the process of translating CASE statements.
36. Explain the method of constructing Syntax trees for expressions with suitable
procedures.
37. Discuss the Inherited attributes and Dependency graphs with an example
38. Discuss Back Patching with example
39. With a grammar explain the translation of Boolean expressions using Backpatching
method.
b. Explain the backpatching process for the statement given below
(( a > b ) or (( c > d ) or (e < f)))

40. Describe the process of translating Boolean Expressions.


41. Explain how flow of control statements are translated.
42. Explain the various parameter passing mechanisms of a high level language with
examples.
43. Discuss how access to non-local names is done in storage allocation strategies?
44. Explain in detail about Run Time Storage Allocations.
45. Explain in detail about Local & loop Optimization techniques
46. Explain Frequency reduction and Strength reduction techniques with examples
47. Explain in detail about Peep-Hole Optimization with examples.
48. Discuss the Data Flow Analysis with example
49. Explain the issues in the design of code generator and design a simple Code
generator.
50. Write the algorithm for constructing the DAG . Explain how to optimize using
DAG.
---------------------------------

You might also like