Numerical Question Based On Shift Reduce Parser
Numerical Question Based On Shift Reduce Parser
Numerical Question Based On Shift Reduce Parser
1. What do you understand by a handle? Explain the stack implementation of shift reduce
parser for string id1 + id2 * id3 $.
Productions are
E->E+T
E->E*E
E->(E)
E->id
A->A+B|B
B->B*C|C
C->(A)|id
a. Compute Leading and Trailing for each non-terminal of above grammar.
b. Construct a operator precedence table for above.
Numerical based on LL and Types of LR parser
1.
5.
6. Consider the given grammar with parsing table and parse (using
LL(1))the given string w=”bcba”.
SaAa|BAa|€
AcA|bA|€
B b
Parsing Table:
a b c $
S SaAa S BAa S€
A A € AbA AcA
B Bb
9.
10. Show the following Grammar:
SAaAb|BbBa
A-> €
B-> €
12.
13.
14.
15.
16. Construct the predictive parsing table for the following grammar:
SqABC
Aa|bbD
Ba|€
Cb|€
Dc|€
A-> d
B-> d
18. Construct the canonical LR parsing table for the following grammar.
E->E+T|T
T->T*F|F
F->(E)|id
a. Compute LR (0) items for the grammar
b. Show that the grammar is SLR (1)
c. Construct the SLR (1) parsing table for above grammar
d. Consider the following grammar
S->L=R
S->R
L->*R
L->id
R->L
Show that the grammar is not SLR (1).
S->CC
C->cC|d
(i) Compute LR (1) items for the grammar.
S->CC
C->cC|d
Find the collection of LALR(1) set of items.
(i) Draw the corresponding GOTO graph.
22. show that the following grammar is LR(1) but not SLR(1).
S->AaAb/BbBa
A->e(epsilon)
B->e(epsilon)
T-> TF|F
F-> F*|a|b
Construct the SLR parsing table and also parse the input “a*b+a”.
24.
25. Construct the SLR(1) parsing table for the following grammar: 8
SxAy|xBy|xAz
AqS|q
Bq