ND-2020-CS 6660-Compiler Design
ND-2020-CS 6660-Compiler Design
2. Construct regular expression for the binary string that starts with 0 and has
odd length or that starts with 1 and has even length.
3. Consider the following grammar and demonstrate that the grammar is ambiguous
by showing two different parse trees for some string.
S → AB |aaB
A → a|Aa
B → b
5. Write the semantic action for the production rule of E ->E1 OR M E2.
6. Translate the arithmetic expression x = (a + b)∗– c/d into quadruples and triples.
X 20407 -2- *X20407*
8. Write the static single assignment form for the below code segment and write
the minimum number of total variables required for the conversion.
x = u – t;
y = x ∗ v;
x = y + w;
y = t – z;
y = x ∗ y;
11. a) i) What are the different error recovery strategies in phases of a compiler ? (5)
ii) What are the tools used for constructing a compiler ? (8)
(OR)
b) What do you mean by passes and phases of a compiler ? Explain the various
phases of a compilation with neat diagram. (13)
12. a) Draw an NFA and then an equivalent DFA for the regular expression :
(10|01) ∗ |100 and also construct optimized DFA using the subset construction
followed by Hopcroft’s minimization procedure. (13)
(OR)
b) i) Discuss the issues involved in designing lexical analyser. (8)
ii) Describe in detail about input buffering. (5)
13. a) i) Explain dangling-else problem with an example and give the unambiguous
grammar for the same. (7)
ii) Consider the following grammar. Parse the input string “abbcde” using
stack implementation of shift-reduce parser. (6)
S → aABe
A → Abc | b
B → d
(OR)
*X20407* -3- X 20407
b) Construct LL (1) parsing table for the following grammar using FIRST and
FOLLOW set. (9)
S → UVW
U→ (S) | aSb |d
V → aV| e
W → cW | e
Give the parsing actions for the input string “(dc)ac”. (4)
15. a) Discuss in detail the role of dead code elimination and loop optimization
during code optimization of a compiler. (13)
(OR)
b) Explain the issues in code generation phase of a compiler. (13)
X 20407 -4- *X20407*
16. a) Construct CLR (1) parsing table for the following grammar. (15)
–––––––––––––