Download as pdf or txt
Download as pdf or txt
You are on page 1of 46

EXPERIMENT NO. ..... DATE .

********

NAME OF EXPERIMEN.... PAGENa. 4O1

CONTEXT FREE GRAMMARS AND


LANGUAGES
A Grammar G i 4-tuple druple : (v, T, P.s) where
bet of Variabl es 0 non term:nals

T bet of termfnals

P t bet of_prod
uctions
Each prod ucton #h of the form x*B hee i s a string Fo (VUT
and hen ce Can noE be e and e can not oCceT O the left hend

side of a0H productioo. But, B I a sting fo CvUT)" and hence it

ocludes & alro. So, e can occus oo the right hapd d e of the producoo
S the tast tmbol.

ELamples
on 1 mnals O Vari ables (v)
Jhe ioues case n a M e s uch a expres;On, ojpera los operaOd,
tealnent etc.

Jhe Capital letters the beg fnniog of


neas te alpha bes buch ab
A 8, C, D, etC:,

Jhe lette S s the start ymbol

Tesm?nals (T)
Jhe KeH0rd such as ?f fosch? le, do -ahfle etc,
Ditfrom O 9
such as t, - *,I, etc.,
Smbols
ne louer Cabe Letter near the be #ootog of the alphabel Auch

a a,b, C, d etc.,

Jhe beld faced lettes such as 1d.

Jhe lacser cate etters nea the end of the alphabel Such as

UV X H 3 repreene strng f teimoals.


B.I. T
Grammay S4mbols
Jhe Orammar bol Ca be emnal of noo- e i minal.
Teek lettess
Jhe cap?tal (ettess ethe end of the alph abels uch Gs x,Y,
X,Y, Z,
7,
erc

Choms sy ierar chy


Noam Chomsky h o s the founl of fovmal tanuage theog has claifi ed
the oCmma
ioto VasiOu colagoyies.
Types of Gramm axs Type O rammar Phrabe tructuured rCmm aY)
Type 1 ram Conlex E Aco6'tive eramma)
Hpeèram mar Coolx e e rammcr)

THpe 3 ramma
Regula« rammas)
THpe O Grammar

A gTammGs (V,T P. S) saicd to be ty pe 0 rammaY


2
O unrestricted or

Pharse stricleramm a f all the pyocluctioos are of the form here

oe(vUT)" and B e (vUT)* xe C UE) ye (voE)


In th; and he
type of rCa mmar there are no
restsictjo0s on
length of .
ony etr:cbon that CaO not be e . i . e E Can not app ear o0 the lefe
hand tde of procducton B u e e can appea 00 the toht hanc d e cf
any
the producti oon

the Larges family of gammars more pouserful thao al othe tpea


orammars .
And tanguoge ca be obtaioed fro th's Ùrammar.

Jhe languag generated from ths


Cmma s Called type O languag
6ecO« ive enumerable
Lanuae Oly Tur io ma che ne Can e conie th:s
Lanouao
SoAb e
Example
aA bAA
bA a
EXPERIMENT NO. ***************** ** * ** . DATE

NAME OF EXPERIMENT, PAGENO. 40R


*****'***** ************** **** ****

THpe Grammar
A Qroamms G:(v,T, P,S) P said to be tHpeerammay or cootea
bensitive orammasf au the prDcuc boos are of the form B.
but, there ?s a
setrictoo on leno th of . Jhe leog th ofB must be|
at leas
uch as the len th of ie, Iellxl and v4p
e vUT) ie, e Ccan not appea 60 the lef.t hcod ioht hancd
i de of
a0 prOcd uctioo. It ? a E-free orammas

Jhe languag gencrated


from 1thi ram ma f called tHpe! lenosqg *
os
cendet Aenstive language
neas Bouncded Auometa lLeA) can be censtruc ted to vecoon3e
the lanouaee enerated from this oemmay

eLam ple S aAb


aA BAA
bA aa

THpe Gramnar
Agrammay : (V.7, P,S)s Acaid tobe type rammar or colext free
ammar f a l l tte pro duc60od are of the form A ohere E (VUT)"
and A s noo - lEYmioal. Jhe symbo &
Can appear On the rioht haod

i de of aoH prod ucti on. X-

Jhe lanèuag ener ated frem th:s eramma 6 caled tHpe


-

lanuae O conlExt fee languag


Pushdoon Au lo maloo PDA) be constucted to
can
recooiae the
languog& eerated from this orammar.

esompte S-aB | bA &


A aA lb
B bBal e
X
A
(vuE)
Noo4enin
B.I. T
*Type 3s GYamma O%
Repulov raom a
Jhe sammay
: (V.TP,S) said to be tHpe 3 gramneY 0Teoulas ganma.
fthe èramma ight Goeas Or let Goeas .

A ramm G sa:d to be hht oeas f all the producton are of the


for m
A oB

A
ohere A e and eT
aye vari ables
A ramma h baid to be lefE Goeas tf all the product o are ofhe
form

whee ABe V aLnd eT

elomple fo Tht oea gTammay

aaB bbA|e
A aAlb

bB ale
NOTE e and St g of lEminals, Can appea on RHS of a0H pruducti o o and

Ena DreseoE 60 RH S Of QnH PTodcti on, only one


no afmina Abauld be presco aod t has to be the b t most
bo O0 RHS.

te fo lefe near oramma


S
Baa Abb| e
Aal b
+Bbla le
NOTE: & aod
strog flêrm toals can appear
RHS f. ao produc Goo|
and noo
noo- larminal
? preseot 0o RHS of a0H productbo o, ooly
One should be presene Ond Pt hab to be the
mOst bo L 0o RHS. let
EXPERIMENT NO. DATE .
NAME OF EXPERIMENT P e No. 403
******* * * * * *** "**

NOTE Corhi der the


fotlow fng èramma7
S aA

A aB |b
B Ab Ja

this ram mas, each Psoducboo seithes left oear Or vioht

inear But, the ramma not e thes eft GneaT orieht


Cneas Such type of grammay Calle d oeos orammar.
So, a gTamna7 the
ohi ch has at most One no0 e mnal oo

ght i de of anH psvduct oo thou t res tricto o oo the

Posio of this non-lerminal cale d Gocas rammai

Jhe laoguag C genes atedfrm the reoulas COmar ?s called veulay


Languaoe. Jhe Lanuage accepttd by PA A eçulay languoe So, e
Can con&truct a foite auoma on iven a veoulas orammq aod vce

Vesha

Gromm ar from fotl Aulbmala

Proce d ure Let M: (4,E,S, o, F) be a orle aulonarta accepti8

A a m n as (V.7,P,S) Can be coostructtd here


V e o , b i . + , l n s i.e, the stales Of DfAA of Il be the

Vari ab ies fo the orammar.

T Z ie., the foput alpha bels of DPA are the èminals|


OmMaT

S bo . e , the stast stalé of DFA Ps the stast

mbo 10 the ôramm af

The productioo P from the tanitoos be


cao obtatoec
ab shun belao

BI.T
STCP1 f S ( 1 a ) :; theo otrockuce the troanhetion pr Oducton

STEP 2 If EF :e., is the foa t l e fo FA, then otiroduce the produclon

Q1. Obtain a's.


gramma geeralë sting cobintiog ofaH numbe 0f
G:(vi PiS)
a S (S,a): S SaS V S
Se T a S ish
Si a final stali P2S->as, s a
Jhe grammaT
generale strino consstng of an number af a's is v e n

S aS
G (v,2,6S)
S E

6a. Obtai0 of at leat One


ra eneralë strio eon
6istsog
ScA
S CS,a) A S aA
A AI
S CA,a): A A aA
oR
S a Sa
(OR)
Sa
SaSla S0S

3. Obtaio groammar to oenerale CoOs t af 00 oumber a ' and b4.


string og
a,b 2a,6j
S aS
S bS (OR) S e l a s bS

Q4 Obtaio &rammar o enerale


trng ConA:Atoo
a
af at least tuwo a's
S aa SaA

aS (0R)
AaB G
S
ea8
65 Obtain ramma eral briog CoO'tiog o even number of a*'s
a SaA
S &e
A aS
S aa S
(O)
EXPERIMENT NO. . DATE Banga ore
NAME OF EXPERIMENT
i *********
PAGE NO. 404|
******* ****************** ********

6. Obta:ooramma 6enerale htriog_cons:atiog o4 ultp les


three a's.
O3,6,.
S aaaS (OR) S e aaaS
S Ee
S+aA E
A>a8
a
.BaS

7. Obta:o gramma eneralë Atriogs 04 a's. and b6 Auch that

strng length h multple of 3.


Btriog
S+ahlbA 3,6.
S elAAAS AoßlbB
A a |b BaslLS

8. Obtaio rammar 6enerale Atrn_con&:sbog of and numbe af


a's and bs* ot leasl One a
a,b
S a S bSS

S aS (CR) S aPA
S bS A aA

S las|bS S aAlbS (OR) A bA

AaP bA|& A

9 . Obta:o orammar to enera le stnoo CoOAtog f a umber of


and b'A atb: at least One b.
S a S bA
Sb (OR)
AaA bA &
S aS5
SbS

Q10. Obtain èrammas to generalë stsing Coohtiog ofaod number Of a


and b' wth at least One a Or at least One b.

S alb (oR)
S aS As) (A) SanBA
S bS
AOA|bA &

- B.I. T
a. 0bta:o oramma lo accept the folloco: ng language
erg)
L : lol mod 3 >o ohere e ja} "3 o..a
S a laa

S aaaS

(OR) S aAA
tart a
a AaB |e
BaS e

Gramma from Reoular Expre%:0ns


Obta:o oramma eneralë sbrtog s OFa's and b haviog a substriog|

ab
(atb
( a t b)* ab (a+b)*

SAabA
A el aA | bA

and bs ending th strog


Obta: o rammar to enerale stri og s of a's

ab
(atb) ab
S Aab
A e |aA bA

Q3 Obta'n rammar toeneralé string af a's aod b's tartiono


ab (atb)*

S ab A

elaA bA
Obta: o gramma t eneralë the fotloca:a languoge
L : nalo) mod a O here oe a,b3 *

S &| bs | Sa Sa S e,u,6.8. (a's) S-+LS|oAl&


(Ce ) o (E1b) a (e6))
An no of S
AaSbA
EXPERIMENT NO. DATE

NAME OF EXPERIMENT PAsENO. 405


***********************************************

Dertva tion
Let A Br and B13 are procluctiob 1o rammas 6, where , B

a n d CYe strin Of termin als and lor non- lermtnals, A and B are

non rmina l. The non


- lrm?oal A prectuces the stsioo dp b
Teplacio the non-lesmtoal Bo Br by the Atsin Bby applting the

ProcductSoo B 3 and coo be or teo as

Jhe of termioals and lor


proce Of Obtanfog sting noo- larmioals,
rom the os all poductbo os ?5
tart mbol by applns bone
Calle d deivation.

T f atring s obta ned b apPlyog onlH one pYDcd ucQoo, then


it called one-step deryation and denoted by the

One Os mo<ee procductiooh ave appl?ed to et the strog 3from


A, then

more
Lf3erD or
pYDc)ucbo0 are appCed to oet the strog 1afrom A,
2

the A

Conside the grarmar sbaon beloo from oh:ch aoy art hmetc
expreioo Cao be obtained

E E+ E
E E-E

EE
E EE
E d Obtao the tino d + i d r d and shous the

deivatoo fov the ame.


E E+E Le lm dhE Derivatioo
td +E
tdE E id+fd* E d + td* id
B.I. T
Since the sting d+ td ? obtaned from the tart smbol E by appiog
mose thao O0e procuctioo, thi6 Can be Osteo a5

Senlence
be a oramma. Jhe strin w obtaioed from t e g rammay
Let GCv,T, P, S)
Auch that S o s called Roloce OframMar G. Here, i the Atiog

ermoals.

Lf there adesvation termi oa ls


S x, cohere Contaios tnog of
and lor non-
lerminal b, theo o caled entential form of 6.

Erample td +td * id the enlance of he


Soramas

CEd+E, td +Ee, id +id *


E, d +id id
ase aU sen leotia form Of the rcumnas

Languag
Emincls
A @tvenb orammay Con generale a e t ef tnng consstog of o

order. The sek of such Atrne Callecl


by applyag precluction dfereat
the landa
b he
Let G: Cv,T P. S) be
a pramma.
S
he langueoeLCG)enerated

Tammas

LCG) l s o aod we T

0 emioals (may be e obtaioed fro m the t a r


a stro9 Of
ymbo S bH pply:ing an aybitr av number of produc tions
NOTE:Jhe lmeiale strog of l vmin als and lor no lèrmtoals obtained duing

the derivation proc es 6 called entential form of . Jhe variou A strggs

which are the elesnen of LCG) are called en lên ces

der the S a Ga
Consi follooingramma
C aCalb
What ththe language generated b thib èromnav ?
EXPERIMENT NO. ********* DATE
an PAGE N. 406
NAME OF EXPERIMENT,.....
******** *** "***** ****' ****

I ConA:de e follos :ng 8yamm aY


S aCa aba CLCG)
S aCa S > ata
= a aCaa C aCb
a a a Caaaa hat 6 the lGnouGoe peneratcd

this ov amaM a
aCa
=a ba?

LCG) abaIn2}

Grammass 0Y ofhe Languages

Q. Obtaio a ramnay generalë the foll-ing lengua8 e


L: a b o>Ot ab
& aabb
S e | aSb 3 aaaboo°

e
9a.Obtoio a may t entrole the follosing languag
ab
L: ab: o2ia aabb

S ab aSb aoab

3. Obtalo a prommar oenerale the follosoFoglaQguage


O a
L: l a ' : n>o3 aab
S a
a Sb

4. Obtato aorcumma to penerole the follasiqng languag

S baSb

95. Obtaio a gronmas toenerali the follasiog languas


bb
L1ab*4 >o} abb
STbb la Sb

B.I. T
6 Obta:o a oramma togeneya the follocaing lango
S
L laS: n>ot abb L:a n
aa bbbb
Sabb las bb
S eaSbb

&7. Let
ove .
Z: la,b} . 0btao a
rammor Gener attog et of all pel: odromes

Jhe gr cumma to enera le


tros of paliodromes over en b
:(V,T, P. S) where

V: Ls
T: a,b}

S i the Atart tmbol

P: 2 S E
S alb aWa boo

S aSa bSb

08. Obta: aèramma tocoerale the follouin` lanouage


8
L: 1 owR where o e la,bt *3
S e
S a Sa l bsb
S>a Sa|bshle
NOTE L: lwcoR| o e a ,bt*}
S C

S aSa l bSb

Obtaio a rammar toeneralë a language conssto of all non- paGo-


99.
- drome
ove a,b
Jhe oramma to ener ala strngh af non- po Lindyome iven G-(v,T, P,S)
wher e
P: 2 S aSa bSb a ool bb
V S , A .B
S A
T: 2o,b
A a BbbBa ceaLb
abab
|ob|oa
9hthe stare
bo
EXPERIMENT NO. . DATE . .

NAME OF ExPERIMENT.
****

10. Obta.n the pramma to enerale the


Languog
L:io " a" | m>i and nzo
S AB S A Sa

A O|OA (OR) A>OI loAI

B a8

I.Obtai o therammas togenerae the languogS


L:
1 nalo) -
nglw)3
he raumnar to tneral the lanouao L:2wl naleo) = nblw)s is

G (v,T,P,S) cohere

T: a , b}
baba
Sithe tart obo l Obab Sab ba
bbao SS
P 2
S l aSb lb Sa SS a acabbb ababab
2hiaao
bhbaas F

1a. What Ehe Lanouag generattd by the rammay


S OA IE

A 1SB
S

S OA L: o1)° nzo3
=>01S
O1OA
O101S

O101

NOTE S EloIs
S |so1

B.I. T
Q13. Obtain a CFG generale a tring af balanced paventheses
iS
balan ced parentheseh give
Jhe oramma
oenerale a
string of
A
bb G (v,T, P. S) wheye
V s

T:C, }
S ehe tart smbo

P S & c s ) |ss

Q4. Obta:o a rammar to eoeral the Languogc


L o |+ ,1>o andj20
Cv,T. P, S) G Cv,TP.S)
V s.A.B} Vis,A,B,c
T o T o,}
start 6ym bot S Ehe btart mbol
S i6the
(OR
P S 0SL Pi S+BA At leabt o6e U

S A B S ACc

OA lO A OAI |e
B 1B|1
3 C 1C|1

a15. Obta:n arammar to penerale the lanuoge


L o * b" n>o and m>
O: 0 >0
S a AB a ab b

A aAb lab a a o bbb

B b B |E

a16 ramm ar to eoer ale the Languag


obtato a

L:ia b 20, m>ns


EXPERIMENT No. DATE

NAME OF EXPERIMENT
pGE
No. 408
***
****

a : (v.TP,S) 2

V i s , A B3 m m3
T: 1ab gbb, ab bb,a d bbbb
Sithe start symbot ob >o
P
S AB (OR) S aSb lB
A aAb E

B b lb

Q17. Obtaso a ramma to gseral the language

L i abhs| n>3}
0: 3 4 : 5
: (v,T. P, S)
9a20abb .. .
V 2s.AS aaaab

T: a , b3

Sis the btastsumbol

P S aaa A COR) SaSb aaa


A aAb |&

Q18. Obtao aorammar l6eneral the Langua


L: L,La whexe L:i
ab n>o , m>n3

S aS,b B S OS e
B bBlb
V:
1S, So, S, B T: 2a,b, O,S Sithe start 5tmbol
P:2 S S,S2
S as,b B (oR) S S,S
Sa OSII2 t olble
B bBlb
B.I. T
19. Obta:o a rammar enerale the Lanuag L:L,Us ohere

L i o " I o>o, m>n


La o |o
(OR) : (V,T,P,s)
G Cv,T,P,S)
V:S, S,,Sa.B
V S, S,, , A, 8
T: a,b,0,
T: a,b, O,I3
S the tart Aymbol
Sh he start symbol
P: S S IS
P
s s , Sa S as,b 6
S FAB

S OSIe
S
A aAb |E B bB |b
belb

20. Obtato a grammav to penevalê the Language


9L w : lol mod 3+ lol mod a3 00 : ia}
O,a O 7 , 1 , 17,
S aa aaal aaaa| a aaaa | a a
a aaa S , 7, 3
S
e za) x

a1. 0btaio a grammar to çenerale the language


Co.a) (o)
L: : lwl mod 3 lol mod3 oo : la
(4)
s e a laal aaaa aag aa| aaa aaa SS (s)
4 0, (G)
( ) aooa S x()) Q a a a a a&"
3 (
oDS() aaaoaS x (IS (8
aaa X

(10
Qa. Obtaio a rammar generale t t of all stvoo s t h exoctlto1 15
(u)
One a
heo- }a,b} b

S a8bS SbSoOA

B bB E

Obta: o a ammar enerale set of austrings with at least One a


Ga3
cohen : /a, b}3
S b S | aA
A a A l bA|e
EXPERIMENT NO. .... DATE ..

NAME OF EXPERIMENT... 9a oraPlGE NO. 409


6d4. Obtao a rammar to genera lë the
Aet o all tro
more than tbree o's when : 1a.b3
S bS aA I&E
A bAlaBe OR) SB BaB|BaBaB|BaBa BaB
B be aCIe

G bCE

a5. Obtaio a
ramma to generalë the Languoge L : i I nalw) = o
AaA +3
(NOTE A aAb bAa | AA|e nalu)+1 Dew)

OR)
S ABA

A a Ab bA a l AA | e halo) nblw) +

26. Obtafo the


ramnav to
gencralE the longuoge
L: l nalo) > nglo)t
S A8 | BA ABA
A a Ab aAbbAalAAe
A bAa
(OR)
A AA y S a aSb | bsa SS
A &

B a e la

Qa7. Obtato a gammar


enerale a
languag e of tring s
of o's
and 1'b having a substnoo O00.

S AO00A Cou1) 0 o (ou)*


A O A 1A 8

88. Obta: a8amma to genera le the follost ng lanouao e

L: oB" | _ ntam k for n>o , m>o3


S>aSc |A_ -B.I. T
A bAcc
aa9. Obta:n, a gramma to eneralë ole ess
caor
(VT. P,S)
V:D,S,
N A. I}
T
+,, 0,1, a,...., 9
S-T the tart gmbel

SN
N
D ND| DN
S
+ -e
D ollat.. .. 19

Q30. Let G (v, T,P. S) be a CFG here V: sS


T: a, b

P S a S a l bSb le
S 6 the htort ymbot.
Lhat ih the Language generated by this rammar ?
L we a tb"3
Q31 Obta:o
I
a
grammar
Cnd .
er
An
ale an

denti e r
arithme
coo
ticexpekion
stast i th any
usn
of the
the
qperalr
letters

from 2a,b.c and ca be followed by 3ero mose mbol from ia,b.c


GCV T. P,S)

T 1 t - ,*, , ^,a, bc3


S 6 6 the tast simbol

E I
E E+ EE-el e*el e lele AE (E)
I
Ta l iblTcl alblc
.3
EXPERIMENT No. DATE m
or
***

PAGE NO.
4l0
NAME OF ExPERIMENT.
***
****" ********

LeptmoOst Deri vatoo


the deriva tion proces a left most vasi able seplace at

ewes Atep, then


euesy the deivaton said to be lef tmost
Leftmost deiva Coo for he strn
&xample Grammar
E EtE ?d +d* *
-E E E E +E
E E E d+E

E EE t d E E# E (oR) ed+id*id
P+d *E
d +d * fd

R:ghtmo^t Dertvattoo
In the derivaton most variable ts Teplaced cat
proces Pt a ght
eder
ee tep, then the deiva t5oo ?6 said to be ightnost.

ecample :Grammas Riohtmost deivatio fox the tiog

E E+E
E E-E

E E * E E+E *E
E ElE EtEk td (oR) e r d +id x rd
E d E+fd * d

NOTE Let G (V.T,P,s) be a Ce6 ArM Atring oe (vUT)" cohich


derivable from the stat symbol S denoted by S s calleel

aeotial fovn of .
there t a deivatipn of the form S ohese at each slöp

o the destvatioo proces onl a let most variable th Teplace

then s CoLled lef e 6eolên tial form


1f
1f there ih a
deriva tion of the
for m S shere at each
step to the deivatioo proces 0ny a nobt most varable is

Teplaced, then s ca Ued ieht- endeotia ferm


B.I. T
1 Obta:o the leptmost derivation for the stsng aaabbabbba sioo the

follocoog grammar
03..Im
S+ aB bA
A a S | bAA la
B b S | aBB|b
S aB
Sae)
BaBB)
aa a 888 CBaBB)
aaabBB (66)
aaaaaa bbB (eb)
a aa
bba BB BaBB)
a aa bba bB CBb)
aaa bbabbS CBbS)
aaabb abbbh ( S bA
aaa bb abbba (Aa)

Destvati on Tree Parne Tree


deivatoo tree| parse tre e o th the
Let G: Cv,7, P,S) be a CAG. Jhe tree is

follas?og properbes
Jhe T00t bas the labe S

Evesy verttz has a label whrchh fo (vUTUE)


3EvesH leaf node has Label from T and ao oteriov ver la ha a Labe from V.

Lfa Ver le ts Labeled Aaod f X, , X Xa ,X are all ehtldreo of A

o ef E theO H X, x , X . . X must be a productio ?0 P

Ecomple Jhe parse treetor the ht most deivab 0n -fch the strog td+id* ?d

id E E

d
EXPERIMENT No. DATE
PAGE No. 411
NAME OF EXPERIMENT....
..

teld of a tree

Jhe yield of a tree the sbioo of Sgnbol obtained by only reaciog|


othout coos Yde rioè the e-
the leaves Of the treefrom eft to ohe
Hmbol s Jhe Hield of the tree fh derived alco from he roo tE and
the Hetd of the alsas a tey m nal strng
Con6icde Ehe par6e tree

f e read only the lesmina sqmbols to th:s


E to oht oe oet fd r d * id
tree from left
and the eld Of the of veo pas e tree.

Parti al Parse Tree Partial Desivatioo Tree


Let (v,T,P, s) be a CeG. Jhe tree s pas tial cderivatioo tree
wi th the follocoing properties :

Jhe has the label S

Eve vertei has a wh:ch ( v U T


label
e
3 leaf node has Label fro mCvoTo E)
ves le t Labeled
4 Tfa + K,, Xo Aand , Xo Ore all

chtldren aArom lef, thea A>X, XaX3 Xn mus E be a


P roductton fo P.

& Conides the Partia& devatioo fe Lhe gramma

t dhoun beloud
E e tE

E E*E
E+E d

- B.I. T
for thi par tial bt most de rivaion the pastia deriation tsee s

T cleQ fro the por%e tree and partial Paxe tree that a Ehe leaves io pasáe
tsee Csethe ymbolsfrom TUe) Ohere a 9 pvtial Passe tree the leave s ?1 be

from (v OTOE).

Amb: uous Grammas


Let 6: (V,7, P,S) be a Con l i free grcmmay A grcmmaT G amb:uow andl
Otyf therc ei ts a t lease one trngeT ch ch tso os more dferest

pasbe trees e i st
b applg e ther Ehe left most ole rivatio n O hE mos
derivation.

NOT e:
Obto'n the leetmost derivalioo and e t a striog Obtaio the oht mOrse
derivati 0o aod btnog . for bo I the denvati0ns
CoOstrucE the par Ae
tree I4 here are tuoo
cffereot Passe trees Ehen the rammar ambi o uo uN
Obtain the
appn eftmoAE dervab on tei ce and contruct the
pase tree. the tuoo passe t ees are
dfferen Ehe
orcumMGs Ps amb:ouoUs
Obt a 0 the

the pas6e
strog
tree.
b PPlyog ghtmost dervat on tài ce and co0struct
Îthe to parse trecs are
dftereo, Ehe
grammGT ?
APply the
ambouous
leftmost derrvoti oo and et al sbnngApel the
leftmont deiva Uo
agaio and et a dierent btrnd Jhe pahe trees obtaïned
aod do nct Cene to the o? be dffeco
Con clus 00 that the raMmas fs
aobiouous.
EXPERIMENT No. DATE
PABE No. 4
NAME OF EXPERIMENT
"9alore)
*i ***** ****

1 . Co06i de« the shadn os Thmebc


Rrammar belouoom hich aoH_
expreioo can be obtas o ed
E E+E

E EE

E- E

E elE
E E) |I
I id Shos that the eTammar amb: ouou

Senlence

E E E*E
E+E*E

tc +E * E fd+E * E

Pd+id *E
+ 1d * f d +d * ?d

+E E

id E E id
+

d id id

Stoce the two Paa 6e brees are differeo for the same eo lence el +id Kid

by applyin e Emobr desvation, the orammar amb:guou6

a. Ib the fo Il os ng evamma QmbiguOus ?

aSx
X aXla
Stiog aaaa

B.I. T
S a S S X
a a aS ax
= a aX
a aaS
aa a X aaaX
aa a a a a aa
Since there are tuso letmost denvatioos fos the same seolace aaaa, the

gv rammax ambouCds.

3 I the follostn èranma ambiuous ?

S aB bA
A as | bAA la
B bS aB8b

Strng aabbab

B (Sa8) S aB sa8)
aa8B CBaB8) aoBB BaBB)
aabB Ceb) aab SB (Bb)
aabbS CB+6S)
aabbAB (sbA)
aabbaB CSaBB)
aabbab (Aa)
aa bbab (B)
aabbab (B6

a b
B A

ven gramm ar Omnbiouous.


Name of Experiment... ********'**************** Date....
**** ************************

Experiment No.... ********* **** *t*****"**' ****** ***** Experiment Result....


************************'***
No. 413

4 . Obtain he
trin aaa bb abbba by aeplyg left mose
dertvaton and the vamma shown belo).
the passe tree for
I it pOAsible to obtoo the same trog again by apply08
lertmo»t deivation but by electing diffeven P oduc i ons?
S a8 | bA
A bAA aSla
bs oBBIb

S aB s a8) S a B SaB)
aaBeB (B a8 B aa BB BaBB)
aaaBBB (BaBe) aaa BBB (aee)
aaabBB'(8b) aaabSBB (ebs
aaabbB (Bb) aaabbABB (sbA)
aaabba88 (8aBB) aaabba BB CAa)
aaa bbab B (B6) aaa bba bB CB6)
Caoa babbS (6bs) aaa bbabbS CebS
=
aaa bbabb bA CSbA) aaa bbabbbA (SbA)
aaa bbabbba CAa) aaa bbabbba CAa)
S

a 8 B a B B

b b b S b b

b A
Q5.
I the
folloing érammar ambiuouh ?
S CtS | CtSeS | a
G b

String 6 Tbt b t a e a

S CtS S - C t Se S
b t Ss b t SeS
bti
btCt SeS btiCtSeS
bt: btSeS btibt SeS
>tbti btge SS
tbtibtae S
tbtibtae a =tbtibtaea
S

S G tSe S

C S s tSs
a

Stn ce there axe two different passe tsee sfer the stingib5btaea bt

applyin` etme deivatoote iven rammG ambiguouA

the ramm a Ombtàuou ?


S PAB | aoB
A a Aa

B b

Striog aab

S AB S S aaß

AoB aabb

aab
a

a C B

Stoce there Care two pase trees for the strino aab,
tbe iven gYammar Omb ououA
Name of Expeiment... Date....
P a g e No. H+|
Experiment No.... Experiment Result....... .. f.FJ

7. Shos that the follasingr


ramma« h amb:ouous

S a SbS
S bSaS
S e

Strg aababb

S a SbS
(s+aSbs) S
aa SbSbS (SaSbS)
a SbS
aa b SaSbSbS (s~bsaS)
aabaSbSbS CSe)
Cse) a Sb S E
aababSbS
aa babbS Se)
aa ba bb CSe) b S aS

S aSbS ( S aSbs)
aaSbSbS (S-aSbS)
aSb S
aab SbS (Se)
= aaba SbSbS (S->aSbs)
aS b S
aababSbS Se)
aa ba bb S CsE)
asb
aababb (se)

Sioce there axe tuo parne trees fo he stin aababb applsng


leftmost derivatioo, the .èrammar amb;Ùuos A

(oR)
String s abab

SaSbS S aSbS
A a s bSS
a b SaSbS asbS abS
abab
bSaS
E aS bS ab a SbS > c ba b
a8. Obtan the u namb:guousramma fo« the vamma shoon belaa-

E E+ GE-E| E*El elE I ce) II GS


I alblc
and Obtain the derivation for the expre%;o0 Catb) * la-b)

be conver ted o l5
Unombiououh r a m m aY hisramma Cao

unombtóuoub gronneyahed o n the


E E +T|E -TT precedence
T T T F ITIFF

F (E) I
OL a lblc
(a+b) * (a-b)
DerivaGen for the strng
E T
NOTE
Ce aMu me + 8 are2 havin9
F*F
highe6t pro+H Comjpared tha of
CE) * F K& and aUthe operaor barelefe
(E+T) * f cLsOCi e
a
, the Yammas ' be of the

(T T) * F form:
=(F+T)* F E E*TIElTIT
(I+T) * F T+FIT- FlF
F (E) T
= (at+ T) *

(ate) * F
alblc

(a+2) x F Lfwe ume +4 are having highest


priorty Compared. to that f * and
( a +6) * F and all Ehe operatot CaYC oht
= (a+b) (E)
a oG a tt the gremm as
i be of h
(ath) * (E -T) fosm
(a+b)* (T-T) E T*E TlElT
T F+T |F-T|F
= (a+6)* (F-T)
=(o+b) * (T - T) (E)
Cat6) k (a-T) able
Cotb) * (a-F) 3Lf cue
aume + 8-Cre hav?ng bighes
(otb) * (o- L) pr o ( asocrcale aheo compased
(a 46) * (a- b) that of CAnd f * and opeTalor 8
ase
nghE Csoc: a lë theèyamm as be ,

thefos m E T *E TIE|T
T Tt FIT-F|F
F(E)T
1 alblc
EXPERIMENT No. ATI******************************

NAME OF EXPERIMENT,. i0PAsE NO. 415


***

* * * * * * * **

Inhesently_ AmbtuoU Grammar


fthere eists a Laooucoe L for cohrch there ?h no unGmb ouoss
grarm ma, then the lanuage s cotlec 1oherently ombtuaus languae 4
the eramm ar fvCm cohith fhe
the Laoou ag s desvedA Ca llecd reot lf
ambipuo us
rammGT

example:L ia bhen m>l, n>I U

Gram ar
S AB |C
A a Ab | ab

B C Bd | cd
aG daDDd
D bDC bcc

Stnng abcd Deriva lion Stioo abcd-Derivatos


S=A8 S C
abBB
aDd /
=abcd >abcd
bolh
So o e cosle the parse tree s fos the dervations, the parte trees are

differen naturTallt the rammar h ambiuous


Tt f noE ponible to obtas the un@mbiouou erammGTfri his so
-

t f oherent Cmb ouous årasnmas

Applicatonb of Context free Grammars


Pctbers
YACC Paf her
Markup lanouaoes
XML

f i n l ë cautomaton
Dotal Des:e
B.I. T
fnile Aulomceto

Obtarn t an ideo tifes .


the oraMmas deotift
identifer <leter<letter-digit
Kletter-dtoit>> <letter <letter- dio t>| <dtÙit> <leter- di? E>[e
letter albl..klAlel.-Iz
olla.. 19

Aart
Oteetel git
doit
lebtes drei t

DiQttal, Desig
Anautomaton co be
Aeful :o dioi tal desin becaus e many Of Ehe
ve«y
Ctycuts are based oo
Conceptsfrom adtema ta theos. Eveo thouoh loical
im plementation of CCuit is o
throyeh trcnAi stovb, vesi stovS,ates, flip-flops
etcan autom aton serves a bridee betoeen E8 fmplementatb oo and
fanctionat
debcrpti of o0
Circcit)
a

YAcc Porser Çeneraloís


Jhe UNIX y sle povi des yACC
a
comm and Uioo ohich etfGeo E passeis
Con be enesoted, Je opuk this comn ao d S a
CFG buE vepr eseoted Sin9
diferen nototionb). In the notatio uked ekcb is
sughtl¥ different from thal-
notationm Uled tO CA6, each
producho0 i5 a k o okecl o?h ao acbon coh:ch
the C coce to be eLeccuted hen the parbe tree is Created
Eomple: E E4E|E-E usio YACC notatio0 cao be ws tteo a
e E E | ele ,
EI
E E)|L lE'E
Ialblc TE ' E
IE E .
I'E'

I 'a'
EXPERIMENT NO. DATE
aore
NAME OF EXPERIMENT PAGE No. |416

Morkup lanÙUape6
Jh most fcimiliar markup lonouage 15 HTML CHyper Tezt Markup

Lancuage). HTML IS Us ed to Crealé ttaper text documen ts -for use On

the lorld Wide Web. L HTML a block of tecE is SurYOunded

codes that indical . hoco itE shocld oppea 0 the ccompula atree.

K XML
XML S6ands for Exlaos:ble Maykup Lagu a oe. XML a s slem f o

defioino val:dating and shavn daument format. XML ues tags


o diboousb documen t bructures, aod atts butes . Tmtcad

Concenratog 0n fovm atEó the text -


XML i Used todefne the

eman 5ch.
Jan016
Ob&ain a èrammos oenerol tolss and osle derivat'on for the
unsi ned toee 1965. (8 M)
G :(v,T, P,S) wbere Y: D ,S,N,I
T: 1 t , o,!,,3,4,S,6,7,S,9
S: I i the stort stale

P: L I > N ISN
N D| DN| ND

S +1-1e
D ol lal+lse|T|8|9
3
Deivabon fov the inleèer 196S
N
DN (NDN)
1N
(D1)
DN
CNDN)
Lm
9N CD9)
19 DNN
Lm (NDN)
F196N (DG)
B.I. T
196D =>196S (N-D) (D5)
Consider the eraomar

SaS|aSbS|E
a b o v e romm a Ombiguou6 ? Shao that the stsog aab has two

f. Passe rees

. L e t most deivations
i Ripht nost deivatioos
(12M)
G:ven eammar i am biououb.

Pave trees

S a S S aSbS
aaSbs (SaSbS)
aaSbS CSaSs)
ao Sb CSe)
aabS Cse)
aob aab CSE)

LepE mosE desvabonb

S aS S aSbS
a asbS (S+aSbs)
aasbS (S>aS)
Lm
a abS CS+E)
aabS (SE)
aob (S)
aab CSe)
Right mobE dervati onb

S S S=aSbS
a asbS (S-aS bs) asb CSE)
aaSb (S+E) aa Sb Sass)
aab CS+E) aab CSE
ExPERIMENT No.
DATE ** **** *****

NAME OF EXPERIMENT PAGE No. 41T

July 15
2 ubak t 3rummar ? Cxplain the clamification os grommars o eomple
Refer Noles P-lo. 401, 4002
(TM)
Obtaio be @ramna Reseralë be fellausi og longuages
() L:lu | nata) moc a = o,ohere o e Co,b PNo. 4O4 O.No.4
L 1a|a ih a paliodrome,where o e Ca,b)} pNo. 4c6 .No.F
GH)L: |n2l SabblaSbb (6 M)
Shoo that the follousoo èramma i am bouous
S a sa | bSs SSb | SbS
(7M)
Let the sbn be ab aaab
S SSb S Sb S
SaSb CSSa) ab S
Cs-a)
SbSaSb (8 SbS) abSSb (S SSb)
absaSb ( S a ) abasb (Sa)
abaaSb (S+a aba Sab CSSa)
Lm abaaab (Sa)) abaa ab (S+a)

S S b S b

a a
a S S b

b
S a

Jhere cvC too differcnt porse trees foi lhe stioo abaaa b by appl#o
leftmosle derrvation. So theoram mar is ambiouous
ofven

B.I.T
Jan 15 the
3 . Define a Conlait-Free Gramma CFG) and also obtain the CFG' fos

folowing languag
t.
Lo o we lo,s ad na
La a " |m4n :k and m,n
lol mod 3 lo mod P. No 408, .No .0
3 1o e /af (1OM)
S aaAbb

A aAb AO ALe
() S a a Sbc laabc

aaaaa| aaa a aa s
S aa | aao| aaaa

Conide the Ce6 oi h productiOn s 06 M)


E E * T |T Lile the leftmos bE derivation, vtghtmosE dersi vation

T F-T|F and parse tree for the strn O- CC#0) -o).


F (E) |ol1 hiE
E T E
F-T
TF-T CT-Y-T)
CO-T (F+O) F-(ED
C r O-FF
CT-P)
TO-CEe) CF CE)) F-CT
0-C(T) (ET) F - (F-T)
O-CF-T) CT-F-T F
0)
(F- F)
CFCE)
O -CCE)-T) F-(F-0)
C CE4T)-T) E >E4T) F-CCE) -0)
O-(CT4T)-T) ET) (CE #T)-0)
O-(CF4T) -T) CT-F) F - CCEKF)-0)
O-CC14T) -T) (FD F-(CE +0)-0)
O-(C4F)-T) (T-)
F - ( T*0)-0)
= F (CF a6)-0)
0-(Ct+0)- T) (F-+0)
F (C14)-0)
O-(C14 0)-F) (TF) OCI+0) -o)
-(C140)-0) (F-) E
EXPERIMENT NO. DATE
PAGE No. |418
NAME OF EXPERIMENT....
***"*****

Shou hatr the folaetoe rammar ih ombiuous. (O4M)


S SbS
S
Conside the strrog a b a b a b a
S
Lm-
SbS SSbS) S SbS (S SbS)
abs (S+a ) SbSbS (SSbs)
a b SbS
(SSbS) SbSbSbS (SSh S)
ab ab S (S+a ) abSbSbS Sa)
ababsbS SsbS) abab Sbs (S+a)
abababS (Sa) abababS (S+a)
abababa (Sa) abababa Sa)

SbS

aSbS b S

a b
S b

Jhere are too dff renE par^e dor ee ezisth -for the same Atioo
ababab0 by apPHig leftmost desvation eoce fveo o rommar is
OmbiouOuS

Define CP6. Wlë CF6 for te follovoing languoges .


(06M)

Gi)L:2 Stroo l of a's and b h egua number of a's and 6s


S OS |o1
() S aSb bSa SSe

Re(er P No. 402

T
hat a n ambiuouk rommar? (1OM)
Sho &hat the folloiogpromna 1 Onbiouous,
EE+e le-el E+El El¬| (E) la
Where E t h e start ymbol. find h unambtguous orammc
Refer P. No. 411

Conside the trng (a+ak a

CE) CE)
CEtE) CE 4E)
Ca+E) (E+E E)
atE*E)
Un
Ca+E+ E)
(ata 4E) E
( a t a *E)
a4+a a) Ca+a ta)
E E

Jhere are two dfferent posoe trees exists for the strog (atata Hence e

give
S
rammay 1 ambjouus.

Unambiououh prommar i

E E +T E -TT
T T&F TIF F
F CE) | I
a

DibcuNs Ehe applications of CFG. (o4 M)


Refe P No. 415 and 416
EXPERIMENT Na.
**
DATE .. a***

NAME OF EXPERIMENT. PAGE No. 419


**************
e*****
Jan 14
****

5 Desne CF6. Dekio a conlxk free èramma for the lanuoge (08M)
(L db, where i=j+k,ij,k>o
Refex P No. 402

) S> aaSbc |E
C8:S 00A
AOA1 lo1

LWhat an
ambiuouh rammar? Shouo that the Ùrammar Ahown
belo ik ambi/uou on the es og "aab".
C6 M)
S A8 |aaB
A Aa|a
b
P: No. 411
Refer
S AB8 S S oas
Aab aab
aa B
aab a
b
There exisbs tuoo differeoE passe treeb for
btono aob. +Hence the oiveo Qrammar ih Ombiouous

Cormicde the ammarE+EE|EE| -EE|zl4. fiod the lect most


dexivation, r1oht most derivation and pas se
tree for the stng+-
E +EE
(06
M)
E+EE
+ * EEE +E +E E
t EEEE +*EE
-1E EE +&E eE

-EE + EEY A
EE
Et-E
+-
t*-EY**
-

B.I.T
July 13
O8M)
6. Conider the follooin rommar
E E+E E-E
C E*E EE

E CE
E alblc
. Obtain the lert most devivation for the stro (atbc)

. Obtain the rght most derivation for the string (atb)*C.

()E E) ECE) ()E E*E


CE +E) ( E E) E C

Ca+E) (E +E E )
CE)*C
Ca4EE) (OR) Ca+e E (E+E) *C
Catb4¬E) (atb+E) CE+b) *C
Catbt c) (a+b kc)
(a+b) *C

Prove that the follasing rammas ambiouou b, Usiog the strsng tbt?btaea
(o8M)
S CS :CSeS a
C b

CESeS
C t S e SS
f b t SeS (C+b)
T t b tfcESeS CS>ictSs)
b t i b E S e S (C+6) CES a b .fCE Se S
Tbti bEaeS CS-+a)
b b
ibtibtaea S+a)
for the stiag
S CES Jhere exists tuso pashe treek
btS Ccb rammar il
Un
"btibtaeo" So, the tven o
bt iceSeS (S+ictSeS)

bE:btSeS Cc+6) ambipuoub


ibEbt aeS CSa)
U

ibtbtaea CS-+a)
Disw% the varous oPplications of conttat free roGmmar. CO4 )
A15 and 416
P.No
Refe
Dec 12 420

7. the
Define follosine texms (OSM)
Lefemost derivation P No. 410 iti. Senteobal fom P.o 4405
P.No. 411
.Rightmost derivation p.alo. 410 iv Yield of a tree

P:No. L410
Pavsing
Desi C t grammar for the Lopeuae e L: w uwibio (a,b3(0SM)
S aSalbsb|&

Desin a conteat free roammar for tbe longugg e L l ob" shere kmh,

S ,m,kof (OSM)
ab Sce |&
Shoo hou ambiu in eramm ars are veted ob an exom pie 0SM)

Dof ambiouous prcimmar


etom ple dervabo0h and perhe tsecs.
Refer. P. do. 411& 412
Jun 12

(o64)
.

8. Desieo cFG for the follosing


of sEsg of O's and , whose nunber of 0's egual to numbe
o
e
S 0S1 |1Solss |e
SSbSla. Jhis promm c ambi Ùuou. Shoo Hhat particula
Coid e ëromnar
bas too . Pasae trees
bbong abababa
. LefE most dervabioos

ti. Picht most derivatos


uO N)
SbS S SbS
SbSbS abS
SbSbSbS abSbS b
ababS
abSbSbS
ababSbS
ababSbS Sb
S b S
abababS
ababobS
ababa b a abababa a S
S b S

O
S SbS
S SbS
Sba
SbSbS
SbSb a
SbSbSbS
Sbaba
SbSbSba
SbSbaba SbS baba
Sboboba
Sbababa

abababa a baa
bababa
Tm
O4 M)
opplicoton of CF6 ib exomple.
Nen one

ReferP.No. 415 0nd 16


Dec 11
Define conlzk- fvee èramma. Obtaio the CFG for the follaoig languages
L 2 u l we io, ol6 at leost one o ccurence of1O
(o8 M)
.LeldHe -j+k,I:la,b,ci
P. Alo. Ao02 9
Refer
S os|1A, A 1A|08,8 1ejoS , C+ocjic e
ii. S aaSbc |e
Explasn the follooing 6 sustable exomples CO6 M)
. Le4e most deivation P.No.41o . Right most derivobon P.No.410 titi. Parse tree
P No 410
shocsn beloo is amb:ouou
LWhat ib ao Onb ouous erammas? Shouo that eramma
S AB laob CoGM)
A Arala
B b
No. 411
Refer P
Consider Ihe 6trino a ab

S Ae
S aaB S
aab
AaB A
T aaB
B a B
aab
b
A b

Jhese ove too passe t ees for the troo aab. Hence, the è iveo rammar

Ombiououh.
EXPERIMENT NO.
DATE .. .
NAME or C PAGE No. | 4 2
RRIMENT.....
******************* ************
* **** **********"*

Deffne CPG. Wrile a CF6-fov 'CO6 MD


. L:
String of as ond bs oih egual numbe of a'b ood b's}
i. L: L i l »zo, i>} U1 c"d°|n,m>o}
S AB S S 1Sa
. S aSb bSa|Ss|E
A aAb |6 S A8
8 c8 c S abScd le
abScdle A aAb le
8 CB|c
Desin a rammaY for valid exprei ons ove operat o - and . Jhe
aruments af ex presi on val:d
Ore
tdentifser ove
tnbol a,b,0
and 1. Devve LMD and RMD for styg : (ail - bo)/ (b00-a01).
Ldle Parse tree for LMD.
E E-E
o M)
E
EE
E CE)
E I
Ialblolilal |bi|o1|1T
EElE (a11-bo) -(boI-E)
CE)IE Co11-b0) - (boo- E)
¬-¬)E Cai1-bo) - (b00-I)
-E)IE TCa11-bD) - (b00 - aL)

o I - E ) |E Call-bo)- (boo-aoI)
Cail-E)/E
Ta11-b0) - (b00-ao1)
Ca11- E)/ E
a11 E)lE
Ca11-bI)|E
(a11-bD)/E
(a11-bo)|(E - E)
Cal1-bo) (1-E)
J o1l-bo)| (bI -E)
B.I.T
E E E#E CE bI) |(b00 -aol)
EEE) Ce-bO)| (bo0-a01)
E E
E E-E) (I-bo)| (boo-ao1)
E CE -I) CI-b0) (b0-ao1)
E (E) EE-ol)
o11-bo)/ (b00-a01)
(e-(E aoI)
-

E E E
ECE ao1) Ca11-bo)Cbco-a01)
E(I-oo1)
I
E(T -a01)
aI bL bI aT E (bor - a01)
E (b00-aoi)
a11 bo boT a0l CEI (bo0-a01)
CE-E | (b00-a01)
b00 a01
CE-1)I (b00-a01
Shoo that the
follosin èrammar ih ambguoub O4 M)
S
Ss|Cs) le over (ooo).
SCs) S sS S
(Ss) s)s
S Um
Ccss) S
Tss)S
Cs)
Ccsss S
(oss) Cos)s
COcs)s) Cs) S
Ccoos)
Css) S S
T(C(s)s)S
S) S
Ccs) (os)s C S

Coos))S
(OOo)s CS CS
(OO O)
Jhere are
ar tuwo
pawse trees exists for he
Hen ce the tno (O)).
tve trno
givengrommaY ambi ououk.
EXPERIMENT NO.
.. DATE...
NAME OF EXPERIMENT..... PAGE No. 422
**

DecTO
10
Depoe conlext free grammar. Wsl ihe èramma for the
follocsiQ8
Languaëes :Refer P No. 402 (o4 M)
. L ** i |n S00A, AoAL OL
i L )m>o and z0f SAB, A aAb|E, Bb8[b
(oR
SasbJ8, B>b8lb
Consides Iheeramm a , cob
productions (08 M)
SPrbB Give le leftmost derivabon, e h t most derivation
A aA le and parse tree for the sting aaaboab.
B aRB |b8l8
SAbB S AbB S
aAb8 AbaB
aaAbB AbabB A B
aaaAbB Abab
aaoab8 aA bab A O

aaabaß aaAbab
aaababB a aaAbab A b
aaabab aaobab
a A

LJhat is amb ouous ramma ? Shoo that the follooteo èramm ar


ombjuous.
(os M)
SAB laaB
a | Aa
A
B+b

P. No. A20
Refe

B.I.T
June. 10
12 Defne CPG. Obtan CPG for the follosg logguaSe
:
(10M)
.L:2wl o ela,bf 3, in the severbal of wf
S aSa lbsb |E
. L: : hah a
substioo abf
8aB]bB]e
SbsaA A +aA |b8,
-8-8 (OR
SAabA, A
,

elaAblbAa

What i ambiguous prom mar ? Sbous


that te foladingamm av is
(10 M)
ambipuou
EEtE lE-EE *E| ElE|CE)|a
where E i Ethe start Hmbol. fiod ihe uoambiÙuous ramma
Refer P.No. 4188

Jan L: lo'"|o>ig e., the 6ek of


13. Define CeG rsle CFG for the Lonpuqpe
i'A
an equal number of
.

al
Stng of one or more o's follaoed bt
(08 M)
Refer P. No. A02
S O1 los!
Comide Ehe oromm ar S aS lasbSle
aab
I thbe above orammar ambiououb ? Shous io pavbicalar that the >trqÇ s
. RighEmos t deivations
Leftmost derivation
.

ha tuoo i. Pasae trees .

C2 M)
Rerer P. lo A16

July 09
14 Conhtruct the cfS for the follous ing LoaQ@Oe 10 M)
8elbS
Lia"" | n>o, m>o SAB, A+el aoA , Ehe
most derivabion for
.L:2d |;-i o j=k} and eneral Let
6nng o 122.

SAB S A8

A EOA OAB AOA)


B 182 OB CAE)
o O 182 CB162)
O1 1B22 C8+I 82)

01122 C8E)
423
Define Ambiguous Gromm. Prove that the fotllasin érammar is Ambjpuous.
ind an unambuouh èrammas. S as laSbS | e 1O M)
Refer P No. 411.
a a a ab 6

Refer P.No. 416 asb

S
S aS |A
nambiouous ramma. A
A aAbAIE S

S b

Jan 09
15. Define conlazt-fTee rammar and con lë conlaztfree èrammar fa the

fouasing Loruage Co4 M)


L: d 14+i :k, i>:o,j>o

S aSc lA , A bAc[&
ti.
S+aSe |A, AbAcle
Conhider herammas E+EE | EEI -EElzt Co8 M)
aod on e
iod leftmost and ohtmost dervation for the string t-1}z
pase tree.
Refer P.do. 19

Lhat i ambiououh prammas? Prove that the folosiog Qrammas i


CO5 M)
ambiuous o bhe stioo "aab, S+asaSbsle
Refer P.No. 41
P. No. 416
Refer
6. Obtain a contee fee rammar lo enerale propery oesttd pareathese
structureh fovolutng three kiods a parenbthes (),CJ & L

S CS)|LsJ| {s} | E| SSSs

.JJhat langug accepted by the folowin èrammarh ?


Lou elo, 1S*3
SS osoliSIl &
paliodromef
( S osolIsiloli L: | wi a

L _ o s | o e Co,*3
C S+ osi |ISIl&
A 08 |i80
B OBo |18I lollE
S CS |cSds|& L jo
S cs dslc L:2ed' t jzo
S ss ds sdlc Lcd l i , jzo

You might also like