0% found this document useful (0 votes)
12 views2 pages

AT&CD Tutorial PBM

Complier Design Problems

Uploaded by

Bharani Radha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

AT&CD Tutorial PBM

Complier Design Problems

Uploaded by

Bharani Radha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

UNIT 2

1. Construct the following grammer into Chomsky Normal Form.

S → abSb | a | aAb

A → bS | aAAb | ε

2. When a grammar is said to be in CNF? Convert the following grammar to CNF:

S → 1A | 0B | ε

A → 1AA | 0S | 0

B → 0BB | 1 | A

C → CA | CS

3. Convert the following grammar G into Greibach Normal Form (GNF)

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.

5. Converting a PDA to a CFG

M = ({q0,q1}, {0,1}, {X, Zo}, D, q0, Zo, {})

δ (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).

You might also like