CD Assignment2 2024-25
CD Assignment2 2024-25
Q. Questio
No. ns
1 Demonstrate the problems associated with top-down parsing with the help of
suitable examples
2 Construct the following grammar after removing left recursion-
S → Aa | b | ε
A → Ac | SAd | ε
3 Explain recursive descent parsing. And Also construct recursive descent parsing
for following grammar:
S -> aAS | c
A -> ba | SB
B -> bA |S
4 Contrast the process to compute FIRST and FOLLOW functions and determine the FIRST
and FOLLOW for all non-terminals present in the following grammar:
'
S S#
S ABC
A a | bbD
B a | ε
C b | ε
Dc|ε
5 Consider the following grammar
E->E+(E)
E->id
Contrast the SLR parse table for the grammar. Show the actions of the parser for the input
string “id + (id + (id))”.
6 What do you mean by ambiguous grammar? Check whether the following grammar
ambiguous or unambiguous?
E -> E+E | E-E | E*E | E/E | (E) | id
If the above grammar is ambiguous, then create unambiguous version of above grammar.
7 Construct the LL(1) parsing table and parse the input “a*a+a” using following grammar:
E -> TE’
E’ -> +TE’ | ε
T -> FT’
T’ -> *FT’ | ε
F-> a | (E)
8 Construct parsing table for the following grammar using LALR parser:
S -> CC
C -> aC | b
9 Illustrate the shift-reduce parser for the following grammar using the input string
“cabdbac”:
S -> aSa | bSb | cSc | d
10 Explain the ambiguity in grammar. With the help of an example, also explain how the
grammar is made unambiguous using precedence order and associativity among arithmetic
expression.