AT&CD Tutorial PBM
AT&CD Tutorial PBM
S → abSb | a | aAb
A → bS | aAAb | ε
S → 1A | 0B | ε
A → 1AA | 0S | 0
B → 0BB | 1 | A
C → CA | CS
S→XA|BB
B→b|SB
X→b
A→a
4. Begin with the grammar S→ 0A0 | 1B1 | BB, A → C,B →S/A, C→ S/ ε and simplify
using safe order Eliminate ε production, unit production and useless symbol and put the
grammar in Chomsky normal form.
δ (q0,0,Z0) = (q0,XZo)
δ (q0,0,X) = (q0,XX)
δ (q0,1,X) = (q1,e)
δ (q1,1,X) = (q1,e)
δ (q1,e,X) = (q1,e)
δ (q1,e,Zo) = (q1,e)
6. How is PDA to CFG conversion done? Consider a PDA that accepts by empty stack,
P=({p,q},{0,1},{Z},δ,p,z); with δ defined as δ(p,0,z)=(p,0z), δ(p,0,0)=(p,00),
δ(p,1,0)=(p,ε), δ(p,ε,z)=(q,ε), Now construct an equivalent CFG.
7. Design a PDA over {x,y} which accepts strings defined by the language L = {xnynxy |
n>=0}. Show acceptance of xyxy.
UNIT -3
1. Consider the grammar with production rules S-> (L)|a and L-> L,S|S. Remove left
recursion in this grammar and show this grammar is LL(1) by constructing predictive
parsing table.
2. Check whether the grammar is SLR (1) or not. Justify the answer with reasons.
S->L=R|R; L->*R|id; R->L
3. Given the following grammar S->AS|b, A->SA|a. Construct a SLR parsing table for the
string baab
4. Find the SLR parsing table for the given grammar and parse the sentence (a+b)*c
E->E+E|E*E| (E) |id
5. Show that the following grammar is LR (1) but not LALR (1).
S->Aa|bAc|Bc|bBa
A->d
B->d
6. Show that the following grammar
S->Aa|bAc|dc|bda
A->d is LALR (1) but not SLR (1).