CD Mid1 Answers
CD Mid1 Answers
phase o ComptleT
Sourte ppsam
lexical Analyze7
Sntax Anauyzey
Semantic Analyzer
ETro
hardits
Smbo nte rnediate Code Geneotor
Pable
cOde ptimization
Cocde Generator
laraet pmqram
1xical Anayze 1g
1E is alko Called Scanne
i be pmce O ealinghe ChaaCters om
lelt to ight anod gmcep fota toEens
bouing a Coeci
meanin
Synta nakzr
Secomd phase pthe Compilea aen
Lnoon as parse) t qeisthe tokeo
m the lexico Sseam as inpu
analyze2 pthe Cornpik and aen ega
Suntan taee Cpa se tzee) as the Gutput_
3Semantic Analyze
Tt fs the thid gtageof the Compiler it
getrinut
om-theSyataaunalyzer Atorce treL an chech
LOethen gaenn Systems CoTct_pr nof meanimg
fallp
atermediate Code Generato
4 aLcthphase o the Campller
qeis input
mm the Sematic aaltia and
Canveak inpuE ob
Pucpt as dexmedtate Code Such a
2 alen Crde
Code ptimizatbn
R is Rth phase of the
n
Comptlez
he ntem0eciate Code and
it qi npd
pmducos optimiZed
intermediate code- na Outpuct
6 Cocle Gereyation
ghs inputmm heCodo
taaget cade O obiocttade as Dptimization and pmduo
Sunbol toble mapagemert aresult
Sqmbaltabe is Med isto store all the imtormafi nn
ahau idenidten sed n the Dgann data Shuctre
Containin etorcd on cach Suct
8 Eam Hand loonitien
i
Each phad Can enCocinten eToD& atten
_a phse mLut hadle the detecting
o
cC
Enum to eal (60)
Cads optimizafion
tiol3*num
1did ft
Code Gabion
LDF ida
mul nun
LDF 3 id
ADO F2T-
YF d
a
about input buffaring
Input Bucetng
As chorocters areteaopnn f u t 2aht atght4adh
aah
chasacten Stosed io the lter n dosm ancawingd
_aschoLon belau
token
faroord Ponfe
Begin ig of the
token
butlen cherne
that eonaidea
LL inmdua_a Loo
then Constdaa
lange lpok aheadsSaf lyu
hardles lange
and inmpming inuolving
SepThe'that vestima
SauesKme b
b
cheching t cnd ohuten
Budiens divide into 2 N-chomcder_halve o
Choonbeloo
E M C +22
lexem ouo
binmer
Look ahead Cade h Sentinel
Sotch tonmd4
Cale eo
onaarcd a t end o 4St uflen)
Tead buffer
tora rd begtnoing o 2nd
buffen:
elf(fomdond it at endDfd buffem
2e/oad buffes,
doaudaobegiann o1buffa
dedintien
es
1 usea Submutines
T ET
T ET|
F (E)d
step:Calculating PIesT and oLLO
£TRST CE FTRSTT)-£IRSTLE) = , 1d}
fTRST(T=i*S
TeST E) =\tuE
folLoo
follow E) - , S
fOLLOLO (TD-Fouowa)= t
foLCovo CA t * ,),$}
epa Consimctiag a parke tabe
N 1d C
E ETE ESTE'
E E
T
TFT
T TETAFT| T T>
F Fid F-(E)
Th given opmmman a LLO graMmaa beCau
hare is no ony sakhifECondkct
cent_parsez dor thbe
theecrstve de
Defgn
qmamman
TTF/E
F-C id
kcurstve ACadpnsen aithouf
daon4PKG
the techhatgue ol Top
2 H uca
hacktracking
Ppegnmed b esve lawauag PHS pducbions
Odpduéion
the sting RHS
Theatpbol_
C o e c t alternateVe
t
Lunfquely_deteamine the
OH
choose mIsen
approacb eCtasive aloceit
Themaian
Lwith a nCe dure
iS to_gelate Cach NT
Eaomple
p stream a the
lookahead= a
matchL)_
Ook ahead==+
match
Void A
Chop.se_AnA-pnduchov_A X, X--
or i t o k)_
i ( f s a nan teamiaal)
Call pncadue X O
e ke Ai equalk the carceot ilp SymbDl a)
_adiant the 1p to the Atat umol
elke returns to yAnothe A pmducHon
an e o has OCCued
Given_pamnma
EETT
TTAF |F
f (E)lfd
A ten femorin lotecunAron
PTE'
4TE
T fT
TAETls
F (E) lid.
TO
E TE
pecdue E ) _
P Symbol-fthu
Aol vant
TO
E'O
TfT
pncecure TO_
fO
TO;
f 1d
(E)
pncdue£O
CTOTO
eroT
C ac
C d
tep finaing 1iem&
S
T
s.S 3a.GtP
Cdalda
SaGf Cd
4a/dpaSacyaaF
d.,ald
Panse table
State PCHfon 20to
C
S3 Sy 2
accept
2
S S 5
S3 8
S6
T3
6oSurmMariZe abou LR ponsng2
LR payse Can be Concnucdad to reoqo7t
Vactuallyall
pmgpannrnine lauqLLage Caunstnuet -or Lohich_CEG Can
LR
y.tab.t
ustna LACP mLthod
CCytab.c-ly Jib Conta Ina
a.Out p irq papgro
Yacc Cpeciiatton
Tanslate Yarc Compikr tab.
tob.C Cocopiler S a . O u
ioput a.0ut b u t p u b
Teating an Tlo fanllatnr h yal
declasation
translation ulo
Supporin Cneline
Yacc w-th Ambfq ous
The LALR the agoaitmmk
LOf6 neKatis unt6 acion-
passing
unlen othnuais nktaated
tha psing ackín yacc wi esplued al
. Yecdua reduta Contlkc igna the nbe
Contlict fs tvad by Chopsing sthe
ConIrc tin pncuctfon
ted onyall
s tfn yal
Spectlicabtm.
2shiPE gduce
A shifE edue LonflicE_i e3Dlveol inPavoun
thie ule e solve the Shif-t xedule
danglinq else_amhiguity_Coaneckly
The yoacc uil aetoven by
a
educinga the ewY fp
to eolue noma oasing.