You are on page 1of 4

S.

No Compiler Design BTCS3602 Question Bank for CAT-1


1 Describe an ambiguous grammar with example
2 Define the terms Language Translator and compiler.
3 Demonstrate left factoring of grammars through an example.
4 Consider the following grammar: S→B|SabS, B→bB|ε Compute FOLLOW(B)
5 Explain the terms phases and passes.
6 Differentiate Lexeme, token and pattern.
7 Explain the role of parser.
Construct the FIRST and FOLLOW of the given grammar.
E→E+T
8 T→T*F
F→(E)
F→id

Construct the predictive parsing table for the following grammar:


S→AaAb | BbBa
9 A→ ε
B→ ε
Show that this grammar is LL (1).

Consider the following grammar:


E→E + T | T
10 T→T * F |F
F→ (E) | id
Remove left recursion from the grammar and construct a predictive parsing table.
Construct parse tree with translations and show the moves of desk calculator on input: (7+4) * 249 /
11 +26.
S→ E$, E→E+E, E→E*E, E→E | E , E→(E), E→I, I→I digit, I→digit.
12 Explain the concept of left recursion and left factoring. How these can be eliminated?
13 Demonstrate left factoring of grammars through an example.
Consider the following grammar:
14 S→B|SabS, B→bB|ε
Compute FOLLOW(B)
15 Write the algorithm for finding FIRST and FOLLOW.
16 Explain the working of a compiler with the help of a block diagram
17 Describe the classification of parsing techniques.

Find the first and follow sets for all the non-terminals in the following grammar.
E -> T E’
18 E’ -> + T E’ | ε
T -> F T’
T’-> * F T’ | ε
F -> ( E ) | id
Write short notes on:
a. Ambiguous grammer
19 b. Left factoring
c. Left recursion
d. YACC compiler

Construct the predictive parsing table for:


E -> T E’
E’ -> + T E’ | ε
20
T -> F T’
T’-> * F T’ | ε
F -> ( E ) | id

Explain the algorithm for finding the FIRST and FOLLOW positions for a given non-terminal.
Consider the grammar,
21 E ->TE E->+TE|@ T ->FT T->*FT|@ F->(E)|id.
Construct a predictive parsing table for the grammar given above.
Verify whether the input string id + id * id is accepted by the grammar or not.

Find the first and follow sets for all the non-terminals in the following grammar.
E -> T E’
E’ -> + T E’ | ε
T -> F T’
T’-> * F T’ | ε
F -> ( E ) | id

22 Define tokens, patterns and lexemes.

Construct the predictive parsing table for:


E -> T E’
E’ -> + T E’ | ε
T -> F T’
T’-> * F T’ | ε
F -> ( E ) | id

Eliminate the left recursion for the grammar.


23 S → Aa | b
A →Ac | Sd |ε
Compute FIRST and FOLLOW for the following grammar
S → AS
24 S →b
A →SA
A→a
25 Describe the concepts of Predictive parsing .
26 Write an algorithm for finding FOLLOW.
27 Explain the main idea of Left factoring? Give an example.
28 Define LL(1) Grammar.
29 Solve the following grammar is ambiguous: S→aSbS / bSaS / €
Eliminate left recursion and left factoring for the following grammar.
30 E→E+T|E-T|T
T → a | b | ( E ).
31 Explain left recursion and Left Factoring.
Construct a parse tree for the input string using top down parser .
32
S->cAd A->ab|a
33 Parse the input string 000111 for the grammar S-> 0S1| 0
(i) Give the predictive parser table for the following grammar.
S→ (L) | a
34
L→ L, S | S
Parse the string (a, (a, a)) .

Eliminate the left recursion for the grammar.


S → Aa | b
A →Ac | Sd |ε

(i) Explain Leftmost derivation and Rightmost derivation .


35 Draw leftmost derivation and Rightmost derivation for the following.
E->E+E|E*E| id
Analyze the give grammar to construct predictive parser
36
S→ +SS | *SS | a with the string “+*aa.
(i) Evaluate predictive parsing table for the following grammar E→E+T | T
37 T→T*F | F F→(E) | id
Parse the string id+id*id
38 Describe on detail about the various types of parser. Discuss about the context-free grammar
(i) Explain is Leftmost derivation and Rightmost derivation .
39 Draw leftmost derivation and Rightmost derivation for the following.
E->E+E|E*E| id
Consider the following grammar:
E→E + T | T
T→T * F |F
F→ (E) | id
Remove left recursion from the grammar and construct a predictive parsing table.
(i) Explain is an ambiguous and unambiguous grammar? Identify the following grammar is
40 ambiguous or not.
E→E+E | E*E | (E)|-E |id for the sentence id +id*id
41 Explain in detail about the various types of Top –down parsing.
42 Analyze the LR parsing algorithm with an example
43 Consider the following grammar: S→B|SabS, B→bB|ε Compute FOLLOW(B)

Construct the predictive parsing table for the following grammar:


44 S→AaAb | BbBa
A→ ε
B→ ε
Show that this grammar is LL (1).

45 Consider the following grammar:


S→B|SabS, B→bB|ε
Compute FOLLOW(B)

46 Eliminate left recursion and left factoring for the following grammar.
E→E+T|E-T|T
T → a | b | ( E ).

You might also like