Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
32 views22 pages

CD Unit - 2 Part 1

1. The document discusses parsing techniques used in computer programming to understand program syntax and construct a parse tree from input strings. 2. Common parsing techniques include top-down parsing and bottom-up parsing. Top-down parsing constructs the parse tree from the root node working towards the leaves, while bottom-up parsing grows the tree from the leaves towards the root. 3. When parsing errors occur, various recovery techniques can be used including error reporting, ignoring input symbols until a complete statement is found, and performing local changes like replacing a missing semicolon.

Uploaded by

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

CD Unit - 2 Part 1

1. The document discusses parsing techniques used in computer programming to understand program syntax and construct a parse tree from input strings. 2. Common parsing techniques include top-down parsing and bottom-up parsing. Top-down parsing constructs the parse tree from the root node working towards the leaves, while bottom-up parsing grows the tree from the leaves towards the root. 3. When parsing errors occur, various recovery techniques can be used including error reporting, ignoring input symbols until a complete statement is found, and performing local changes like replacing a missing semicolon.

Uploaded by

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

yoläx Arayis:

siqnpot
The ammat phys a majo 2ole in cdesigig a Compi leà 4 éB
tenefQ
t s esy lo undessiand the dyntoclic pecjiahon a
dang
pngamming9
parse be built yo Cealain cas

gramas.
gammass ae helngut in onsl Ing
3
The pacpealy desigrned
inlo Cag nocl dbyect 4

The

The pats obtain the 3ings toirens trem the Lezical


Parse lhee.
Qunat the Bynlac le eiris
aralyz PaAseA may jinds the
Duoing this pocces,
sbs Technigues.
f also it can invoKe any

which is yound by tha


taee Contains the forcens
The pase
laical analyj a.
toKon
Jnlesmad ol
LexIca
parsa penkti
analyge
Prgham get to

Bymbo!
Table

There are
’ cyK algouthry
clown PCising9
Bottorn. p pcosing
7p couwn parsngi Jt a proces cornsluchng a pasie liee
fom the ghous
input siing
bwasds Hh leoves.

reCons uct the ínput lotens.

lal;
Bottom -4p psing: This method conslxl; a pAse lhee which
the
at the leaves the thee 4 a gr0w lowrds
oot.

may
The C¡mmon pegamming

bexical o - Thii incucles miaspeling icentyica ,


peratdis. eg: nit

miulaiecd semicolon erlia


ghis
includes
baaes
masing
int ai;

3 Seman his inclu des ype misratch a the opaalas


and peACnols. inG

pAogamme. aho can


ghis can b ia leyt l6
Bogical
mae log cal us.
J3

The esi handlea in a prsee has goals


Riapit the presene g cat cleasly ¢ acusatily.

Recoveay Aom the


minimal ovahead to the paoCeasing g coAAect paams,

-Rocovery arlyzen
the iynlÛx
whenevet h.le Png
echniques.
the
may invoke

J. tanic -ade Rovy input symnbcls cne al a


pase discaxs he
Snchaonging ten
untill
desig nated set
-line
yound, input Bymbola,
mode iipscerssdaable statiment.
+ This tre tntt pr
is öimple ¢ is Auitable

Phaase - lvel Racovoy -


} COA Nc bion on the
inpt
local
chis may puim comma by emicolom
replace
which indudes > o semicolom,
semicolon,
d nseat a mniAsing

Thas is leyt t6 the


Aitua hob.
the

procductons in gamnan uhich occgnize


îndudes 0xlia
This parsAnds the ero
THe
eOs.
Commonly occusing PAoduChcns,
Sing these
psng by
cluing
LMO-|
1
a+a+a
ACG). weSing
Ambiguily-
thre amhguous
% be l6Sid
Nole
Hy
derívations 4õaL Pase
RmD
Atievation
mD -
(CVntios NOlalonal
ooOK Text The ,
CFS cn imal
Tmm45 Fee Contx1
castly
l6 method
s shis *
lime implement
yoce. ( inlams
ingeslion delebion
4 MUmbA
algoithm this saingx inpot an Kot
y lo
t s.ianssms
minimiç
kotens), delelors Tnseolion
t changu( blpOSe the
alsoithm 6iciont have includes
to This
locoDec
n- global
9recsive ¿t has a nonteaninal A
rammas is yt
Such that the d 'valon 9 the john,

tondle he hecuAsi on
Snte the top ceon passer amot racusive prodclon.
be Convested to a
S0 2t has lo

Fo the psoduclior
hecusiye Procuclion

A’pA'

d. kliminali egt RAB0ON he yoltig ganma.

T’T*FF. E(Eid.

Pscduc ion,
o consider the

E’Te

T’T *F|F
a consi da,
FT'
nol aa hecuASIVe
Cosi clea

E ’TE'
E’+Te'6
T’FT'
31

5) Corsider the beleuw ghamma, t ciminalr legt recusion

Consides =}

6alcu)

4} Eliminali hesi an 1 the below pastyi cfG.


E’EE + EE * |id,

1 corsicea,

Q. consi dea,

E’ ide
tEte'| E*d |e
llgoithm Tex BoOK.

Factoing -

Cons;clen the Phocloc lor , Now the pars


Aab B acB
altunoives do be used A
cleas ohich the

In gunal,
Parser anngt decid
F the prccluclion , A><P1 Pa
lo

tha psocbchion buomeby

the Commcn pass

IOn lamina!
new

Leyt telBigalan the beleu gmma,


4. Apply
8 ’ absas
S’ 6s|e
Lommon fums

as'
S’ab as

ghe oducton P: 6>as'lbsle


6'6S'|s
33

Apply egt jactsija hion he belous gammat,

Common tems

Jho gammat,
E’ T E

T’ nt

T int T (E)

E TE
Consica, E T tE|I

T ’ i n t T'
(onsida, T ’int *T |in

.. she prcuction Pc
T ’ int T'
36
Aply et yactsiyalion a he belous gammas.

T ’UTU

Top -cloKOn tairg


phoces condaucling the leoves"
he r00t

lytmost cleevalion
"at is been

Soct

Lcaves.

ane
The genval parsing techn:queb,
paasing
t. Recssiye Degcent
Paedicliv passirg
39

Predic Iiye Pansing Method ’

acuasive descent which docsno equie


method.
any bocrlkochig
+ ghis
poning
chooses tho coact delminalidlp)
4ymbols.
phococ lon jor Jatsing by looring a the irput
p0 Jhis methol uses gomnan re daCn g0mmat. hve,
Legt lo Rght scannig input
most cleaiyation
írput symbol at a ime.

allous 6 Chode oniqe


this

based ihe iryot symbol by consliuching


fascuc liorn
passing table.
paediclive

Rules. Predkctive tobe


E’int int)
E)
3. E ( E Op
4. op ’+ 3
6. op’ *
op 5

Cint *int)
( int *int) 4
(E op E ) ( int *in)

E op E ) int *int) $
maich int
int op e)4 int +int)
* intl $
malh
40
int ) $

int) $ ínt ) $ math int

math )

and Follow i

Fiust Funclorn
Algoithr The Don eminals ge cblained by
the

is a leaminal then,
hirst (A) = {a

bonssces the poduclon , the soim


e)

then tirst(A) = tirst(y)


the

SAB hn fisst (S) -biast(A) UbiasBs2

3): Ae thorn
4I

Compulë the Fiast selë ho ihe bebuw gammat.

SaABb
A ’ce

Sol
First (s) = {a} Fust 8)= {d, 6
Fiast (A) 1C, E3

the below amnat,


|a Fird the

A’afl6

601i

Finst (s) = Fust(A) UFist(B) UFiast (G)


= a ¬3 UL b, d.e { c}

a, b, C, d, 83.

Fast CA):a, 63.


Fiast (B) 6,d, &
42
Follaw Funclion -
Alpathm The Follow et ho Tlon leminols Cm be pnd y he
wles.
yalaing
is the BBast symbol Hhon,
4 is the end mSIceA inpt.
Follcw (A)= #,
A on nght
Q. Look the gammat yo al
kide the Prcdic lon.

Longide the prccluclion,

a leeminal than Follow (A) =y3

TON-taminal then Follow( A)= Fast(y) -6

Follow[A): Folawl Q)

ie

the bebw ghammat.


Follow seli
4 Find tte
S>A Bd
A’aA6

Est oli
End
Fist(A)U Fiast (3 ) u di
Fist (s) -

={ a, b, d, 6
b3 a,{d, :
Fust(S) tdsU :(3) Follow
B635
S’ABd
(o): Follouo
Beg. Pollew)
E.Negletc ’
in
(A)Follow v¬d}u Fiast(6) =
PAcd side hignt
ABd S’
cons.da,
$.
add Bymbel
toat sthe s s (B) Folo={$U
w
Bice hight
phsnt
at is ""
s B’6BS. de
Consi
(): Follow
Foliow
Sc Fnd
E6, LB): Fist
{a,E3 (A)= Fast
43
| Find Fust 4 Follow Seli i the belou ghommgt
S’aAd

First Cs)= as
E3
Frst (A) Firsl (B) UFUst(d) u{
£ b, c, 63.
Fiast (3) : (6, 6}
First(G ) = {c,E}.

slap g Find Sela.


Follow( s) = $}.

Follow( A) = (d}.
FollDw (A)
Follow(8) = FstCG ) U

Follow( d) Folow(A)
-{ d3,

the
beluw ghamnat.
Frst f Follow bels
3). Compuli
S’AC8|Cb8]Ba
A da BC
45

slap 1: Find
Fnsk (5) = Fist( A) UFistlc) U Fistl8) u L6, at

= {a, b, god,h, &}

Fusl (a) = fd}u Fiast(8) UFstCC)

Fast cc ) : {h, 6}.

Slapa i Find Follow

ERllowLs ) = ( ¢3
sansid, s’ACB
Follao A):
Follouw (A): Fiast ( C) U FiRstCG) U FOllow (S)

Follow (A) : consi cla, s ’ ACB Cb8Da


ABC
{a}u FAstCC)u Follow(A)
Follouw (B) = Folow($)U

Fist (8) Folilow(s )


Fojlow( G): FoHOOA) Uc63u
47
kAC1) ghammas i
hC1) then Predicleve Paosing
method it
nethod cloes mot require backliackirg

becornes delminglt.

Leyt to ight cannig input


clearevahian
’ Leyt mast
ne énput aynbol at Cach slap.

&kl) than it is a non- clelaminigli ic

ambiquas

SHa S
mulhple
A entiies

Delaminislit tablk iqunique enie.


Non - de liiminiai ie amb.guly
Hence the gammos is in SoHence it s mot in dhli)

table Conlains muliple eniy then it it


a Predic lve
othotise.
a non deleaminislic & amhiquous gharMa
it is caliminisl gfammar
Phedicli Pasng table go he belaw gommas,
) Consiuct
S’afAB6

aclons d the slang ac db


give the parsirg

n, Facung tgnbiguy
Kemoe et acuesi
gcist.
No Such hamnat
First and Follow seli.
Find
Fisst Cs ) : {a}
Fust (A) =<C, 63
Fisll6) fd, e3

Folow (s) : ¬43ko Folo (8) :4 b}.


Follow( A)= Fiast (B) U463
= 4d, b

Slap 3- Censiuct e Rxdelive Daasing


Remask
acdbs Aseo
a d$ aABb$ acdb mgha
cdb
A’EA’CA6 (db matth d
C Bb
Bb db
B Bd
d6$ match d
db¢
b4 math b
Tt Contains unique emlies Hema it 6
Ac op
50

table tO,
ay Consauct
PrsciclveRassing
3 ’ aBDh

D’EF

Sol
No Such gammas eus b.

Fiast ( s) as
Folow (B) = Fst(0) 04h3
Fiastc) Lb,6}v
Fiast D) = FistlE)U FiSHlF) Fcllow (C) Foliou (B) U Fcilcw C)

Followw (D) {ht


CF)U Folow(D)
Follow (E)= FAst

TFolla(F) Folow (0)

b h

SS-a Bbh
|Bc4

D’EF D’&
D

E
F’E
o he below hamma.
Consliuct kali) fparsing table
6’6tTT
F’ id

Soln
ionsidt

E’TE'
d’+7'|
T’
F’id

ted RRMai
Sipa ;- ugve t ammar ist in p.
ávch

Sap3 Remore mbiguily i


ambigucus gamnas,

Foilcw(G)= Folw(e) U Folow (e

Fast (F) id} Follow (T): Fistle')U FOj0w (e) UD|Bwle]

Follow (F): Folow (T) {t, $}


slöp 5

id + This table conlains


ETE Unique emiu o qil the
t+Te'E'5 temnal
F F’id Hence it u a
56
xonsi der the beiow gramna,

the DeCeLsaNy changes to make


RLble.
iiy coslavct prediclíve pansing

considet

erir t in p.
No Lagt actoied gamnat
Remore abigly amb gucus gamet.
The

Staph i Folbw (6) = Fast CA')v Fojow a)UFOlioe()

Fast (e) a, C}
FCllow( ) Follow(A) UFollb (K?

gps: consiuct cl) parsing tab

) This a tabe Cantans


Unque enlais
Hleee P
ss Famma.
|’[Ls

You might also like