Vous êtes sur la page 1sur 19

Euwcicc l:

C TDN°2:
Analyse Syntaxique
étbo~es Descendante,;

E liminer la récursivité gauche dans les giammaires suivantes :.·


G 1 : S ➔ aAba / AB /SA G2 : S ➔ al aA G3 : S ➔ Abc/Baa
A ➔ Bb / a A ➔ SclM I c A ➔ Aab /Ab/a
~ B➔ Bb / b

Exercice 2:

On considère la grammaire G : S ➔ AhcJ Baa / AB


A ➔ AaB / Ab / aSc / €
B ➔ bB/t
1. G est-ell~ e-libre ? Justifier.
2. Rendre Ge-libre.
3. Elim~ner la récurivité gauche dans G.

Exercice 3:

Soit la grammaire G suivante :


S ➔ a/b(T)
T➔ T,S /S

a.Eliminer la récursivité gauche dansG


b.Factoriser éventuellement la grammaire obtenue en a
c. La grammaire obtenue est-elle LL(l)?
d. Ecrire un analyseur syntaxique basé sur la descente récursive po• grammaire obtenue en Il
e. Analyser avec chacune des deux méthodes les chaînes: (a,b)# 4 (a,)#

Exercice 4:

Soit la grammaire G suivante:


L ➔ IL IE
I ➔ T id / id = E / print (E)
E ➔ E+E / E-E /id/ num
T ➔ int / float

1. Donner un arbre de dérivation pour la chaîne print (id+id+id). ·1,

2. Eliminer la récurivité gauche dansG.


3. . Factoriser éventuellement la grammaire obtenue en 2.
.4. Calculer les ensembles Debut et Suivant de la grammaire obtane en 3.
5. de
Construire la table d'analyseL L(l) la grammaire obtenuea3.
6. Grammaire obtenue en 3 est-elleLL (l)? Justifier.
/

I 1

Erercice5:
Soit la grammaire G suivante:

E .- E A..'~~D E /EOR E /NOTE / (E}/True / Faht


l . Sans construi:re les tab\es d' anal:pc, dire si \ ~ a i r e G est. e\\e LL(_\l!
2. Donner la grammaire G' LL(l• équivalentcà G_,,en adoptant les conwrtim.s suivantes: <...)
plus prioritaire que NOT, qui at plus priaitam que AND, plus pixiatire que OR, et
1 'associativite est de gauche à droit4
3. Donner Ja table d 'analyse LL( I)i! G '.
4. Analyser la chaine !True 11 Falscl '
'1i

1
Exercice 5:
I
' Soit la grammaire G suivante:

E - E A."ND E i EOR E / NOTE / (E) /True/ False


( l . Sans construise \es tab \es d ' ana\-yse, dire si \a \!,Tfilnma\Te G est e\\e LL( \ )1
2. Donner la grammaire G ' LL(l) éouiva\ente à G, en adoptant les conventions suivantes: ( l
plus prioritaire que NOT, qui est ~lus prioritaire que AND, plus prioritaire que OR, et
1 'associativite est de gauche à droite./
3. Donner la table d'analyse LL(I) de G'.
4. Analyser la chaine !True 11 False #
_ Se.nt n°i ..ALIO-

AnQly1e S~nrClxiq.i.u..

\-{e.\-hoc:lt..t. 1)e~ ri ciQ. n\-e~ .

t ')(e>..ci.c.a O J., ;
t \,mine( \ex ..Ùc.u~v;te 'il~ ; ~Vu--/f..J d-ll ue k
A ---';, Ae1, j j3
\. GÂ: ,5' ~ o. Pi b o. / A'oJ $A .
~
A ~ 1?> b I a. . sA t -J j1A'
Cn ,- '.) ~ 'o. le. lr1' ,_:, ,..;1(-\' / e .
ôn n i mo..( ~ 't1-LI-: 6 A e~t R GD : ;SI f---,} .SA.

GA e&\- ILE, 1: \. ~ 1-------Y A . ~. B 1---;,_,s'

f¼ ~ .B . fl •-A ,

ei 1----:> .s . A~B.

('.)n C.O(YWY\ €.(\ ~ r'l-J. l1;IIM1('\ô.h'ol\ c:lt. \o.. ,Ût.u.(&-11/iri incH·cec.tt.. :

"· Fo..ice a.w o..(cÙ\-ce \o.. '2G-I. e..V'\$:

$ <A ( 6 <.S
'L.__.J L-J
G CD

i. Su.'1,a+-i lu.\;on :

A, ~ da.n .s A:

A~ J a b/ c b / a .
!l, A da.V'lS .$':
f}i R.civ
-j
J-i_, ~r ,., ,_• V.
G_.,': _$ , _ o.. Aba / _,5'abB/ c.b B / a. S/;SYA .
p. .))> {). J. i ~
éln cemôJ\9-'-û- ~ <3~ es\-lt.c.u.<~"Ve. o\icec.h. en.Jf . . ·, 1
v I .
S't----'J a. A bo.p' 1cbB$') at3j' .
~
(\ -> r-, A / f.,
1 j ' '
.$ ,____ a b8 .,f '/ A ,$ 1 J t. . {I -'> ci. /+ Id.. .

1 :,
1

o.Aba..$/c.'oB JJ; 1aBiS''


I
~ o.be,fl / AJ}' If:. .
A 'r---3 ;f"o. b / cb / ~ .

B ~~q_/c .

Ar----4$/c/Ac\/c.

(91'\ ,e.ma.c ru.u


r · cu.u
1
62..er,\1- ~0

A r--4 c.A' ( )JCfC f'I ' .

f\ 1 1 ~ d. f\' 1t .
l.0n o'one(\\-
. S'C::i:><S:
2.. .
'l.

A ~ Aab/~b/o..

13 , ~ Bb /b.

e\- en B : 'R,1--4 B b.

EHM1 f'\cthon oU \a. 't2.6 D ~

En. A:
1
B~ bB •

B'~bB'lt. -
s-~~ t-----4 Ab e ! Bau / AB ·

/\ ~ A c. BI A "o / 0 t C/ E·

B~ 06 / t .

@, X end ce G- E- \i\:, a:
eu. A ~ f.. e\- B E.. : ( Pl :4: p1) el- ( ~ =I:fl) ·
l• f I i rn i 0a. h on r--- ')

A 'oc / be / ~o.a . / o..o.. / Ag ) \; / f't)


E. ·
G' : S t---- -->

B 1--- -? bB I b .

Même. c.o. ~ q..u.,i. · f: r--> A ?


~ _S ._ ,, E d -.,\ l9
A-) t

é Lù n e .

I. <' •· ,.: _ ,~ . / ::' f - - -) c.,._ bA /;} i - -~ u. b A 1(/ 1 a. VJ ·


') t'\ 1- - - - - , , Q 1\ / <fr
A . - o.. \'11 f_
1-=î . - - -~ b i3l b
B t -> b Ôl .b

..S i---> S' I f. .


1

=?
A 1-- -> a.. i1 b i û.. ~· i- o.. bf\
A t --> 0-.P1b /c.. .

Si- --, E e\- S es\- uf"\ Ko 'P

,S' ~ Ab c I bc../8QCl /o..o. / AB /8 IA •

A ~ A o. B / o.. e, / AQ.. / o.. l fi b I


b / a..$ c ·

B ~ bB /b

~u ~r ê- CJn-e
-
ci :
.$ t-- ~ cBf c / c.,P .
6 ,___') a. 6 b / é .
B,___., a.Bb/ Q b .

~ o 1- A ~
r ---~ FI 8 / AQ J 8 b J f_ . -':> lh--~ Pi 13 / A ) 8 / A" / a. / Bb

@) , t\irn;nv., \o.. .Jù..ir~; \lit~ ~a..uc.he do.n~ S:


0 1'\ ç t t'Y\o.. ( ~ q..u.' ;\ ~ o. u.ne 'Q. G- D en A : P i ~ f\ o. B / A o.. l Ab .

; , Pi
1 i----,;, o..e,R ' ( a.f'l'/ l:>A' / o..J5'cf'\' )o. ÇA' /FlB/a.lb/a_p'c /a. q .

fn gu.5.: ,
G(o..mmcu.re -pa.(a~ehru:

,=,., ~ bB / o. .Sa ·

J\ t o..u\-h'0..:S.t-e( US. CO..!I ·.

S I. n.-::. 0 -=')
.Oa..c.\-oc ~~u
G e ..,'\- -t .
s,. n. =-" -') G e.5\- no~ - tOa.c.\-o<;sh .
_ \l ~i ~ie.f o....u.~'6i fou.( n =- '2. ë> l l l \-2.) ?
@ · flirnine< \o. .A.i.c..u(<;,i\Jit'e ~~:
G ei.1" R.G Den T : l ~ ,, fl ·
-
1 - ✓)
(
,/ G
/
~ _../\
/
~
_5
-
Vn dori'e.n\- G-' =..:, G :

r /
-\ /
C
J
/\

@. ~a. g(o..mmo.l ce G' e~J- -e.\\.J. LU..\) ·.

.l e~ M "J u.~ :
1. p 1----> a I b LT) . C0Y1d " \Je.',,~,ée

3., •~ , .,ST'/E:, .

d..t'o,1 (_ , ~ T ') r'I 9i'it.,_( i ') ~ c/> ·

-- - - - - - - - - -- -
~ 'ou.t,1 '6,,.-,\J O.fll" ,1

)
s a b # '!>

- - - ------- -- ·- ---- )- ·
\ (À_ b
- - ------ ---
' f_ )
' ' - - -
rammcù.re G' e'E>\-

,
-
1)ebuJ-

t{: , - • e.r
· - ,Il
L ..
n::.rme ru l o. cl'lô...Lne·
,
.)

s; ( t-c E
1)
..1 . ·
o-.:. bLL\- C;s') _ ~ t

~ _s'()_;

Alor~ ~Wfl. ('c.hoJne a.c.up\-.é..t \)

fin.
f\nc,,\jseu c li.~ à: \o.. 'Jrammç.ure
'Proù.d.u.r.(_ ,S ( ) \ * Ano.\ ~s.euv- i f\\-rod..u.ctw.r

Sol,(_ pu ~ <i;"\ IY\ fU-

S10 011 si C.rr..::'b)

. )

~; lj-c f: De'bu.\- CT) - E.)

1 A\G"(.) ï(.):,
-fü.)

Sinon e.cùre (' 1Effe.u.t~ o.. ou b e1'pe.c.tt.d ''):,


- )·
f.Si

fin

,,
1 ( .
)

1)e bu.. l-

s ,· (t C ::. , ,•)

-
a.\ O(" ~ te. :~ t-.s . ;}

'=; (rc é: ~ t>Ll..\- c.s) - E:.)


/ o.,tct :~ S(.) ·
\.l . , - - '
-
T~• ;.
,)

s~ (k E J..t\xà (T') - t)

J 1
alor'.) 1 (.)j
-\1~;-
-)

{si•
-)

,\ ci" un9 - <yn~cl.u.re.e,r Jou une .


'U n ùrf\ 1-âil.t est- m oin s c.ou !iu.' f (mt mo,(ct J~m ps) 9-U' un o.we

{aY)cri'cM .
~~t t \o. ¼.u \/e5Q.Acu_ ci.e.s \Xlro..m~tu.s, c\es
..2'o.wel àlo. . ~o~ du. rt e.H ou \a_ {""'c:.noo n~a
'f'OU ( Ct.'() ) qu' Ci) r~fw. \JW
~l'e.A ~ lt. \-erm e C.ou( Q.(\ r
a.d( es~s . e\- une . e,(éc.u Ha\ : C'es\-
3 54

lt~ c.hcdne~ :

1
t 1

· A-c.n'on .

t
c\1C\..l ne
-- .. ~ - - - - - ~- -~... ~--- -~-~- - - .. --- ···-.
Aï->~<i!_\ ;f , -
(a.' b) #
1
(o. 1 b) :tf t. ((e.1.J
t

T
1
1

1
@ I@ 1
1

- - -- i- ---
, 1 r ··
i 1 ---
··· ·r @ 10 )
1

'1
1
'
__ _ L
,,·d) id=- E / ?1"icù lE) .

' 1------4 tn\- ) ~\eQ.\--.

cL. cl9-fi\JQ.Y)o(\. vo~ ~lt\ \- (id•H ct-\-i d)



CD. î)of\ nec U.'t') Cl.(~ e

IL/
__ _/
~:~~)
\
(; ~-\(l
(.
\'d /
(QE
-~ - '-

Sc i ~ ~ .U.W..('6')\JIL ~ ')Clllt..YU. .
CULh,mo..n~ , i I f QJ...1..\-- q.u.-t_ \o.. ~ ca.Nw nal~
ne

uY\.t. 1n<o..mmcù<e. ~c.u .r~v~ e1 ~a..u.c.\-u n'esl-


~ ù!Y\&\..rw:..tton. d'L.LV\ cvJir ,e s'dr'\.\--a.)(i cpu '\>ou.<
c.tD S.t3t'1\-o..){i~ me "'r eu fOS ·
~1 Lll'U. i>'\d.ic.a.hO{\- : 7ou.r &o.\.lo 1< ~ \o.. chuJn.e es'r c.oae

p. ~ PicJ..j 'p '


~
\
Pl~ 'fJA -
A;\ ~ cl f\ 1 / é,. .
E' ~ ~fE / -EE
1 1
/ t.

) 1
' \
~e~ \ o.. <s'ct.Tffln<:u.(~ G (;;) G, •.

: L ~ 1 LI E -

T ~ , i d/ l d :::: E. / F'in\- U ~) .

E- t---=:> iolf '/nu.r nf'.

( n. rp\u.Ç.•.
() ( 'Lh . r ,w.(\o .or).
c1-e. bol'\ o..<hrce s'jn\-o..')(i q.u-t.: a.\~û(,~ rn,~M eo f

~e~

~\ôO-.t
__,
~YU_l

·. \

C'esJ IQ JLL
.,
rY\€n1 oct.(
l'!:!{e.d ,' c:. nv.(_ Q.ue.c_ 1
,.U •Ol.(_( '--
0.rr1'f.U.
@ B~ A~ -
Id ~ifl\· inl-' ~loo..l- #
~ )'6-lt' O). ) ~r CS) .
Id r\u.m
L"o-JH fl) ) ~t ( 8)
t' -t - E..

T in\- floo,r·
id
- -·--- -----.. ·-- -·· ---L-- -- - - -- -

l- d
1 L
i id
i

CD
=
--
rp<ïrl'r

(i)
( ) t
-- -
- (\.\J:.'('(\ ,~t ~ #

1
- -- 0 0 ®
--···· --·~--- -- - - ---- -~--- ·
I (9 ® G) Œ)
· ··-- -···--- -- - ---- - -·-- --
® ©
----·--- --- --- - _______
·-@- '--@ :· ---- -··- - ··· _ _ 04 ___ _ _,.,,

@) ® @ @
T
---- - -·- "·•--· .........._... . . .... ~ .. ~
.-- - __,______ ., _______ . --
·-

- ·-· '- {L -.
@ @
- · ---- ------J...... ·- -----·
.)
'

@. 1)e. \o qu..o.~'non ®· \..o...h:Lb~ c\ 1a.V'1Cl.,~>e e.'i,\--~ehzh~in,Ce.

~ ~ o. 9,0.rr.VV\cù<e. t'\
1
e~t' pa~ LUA .).

clt.l:> (..ll ) f\ lS\J(° (L) = </; . = c.<JY1d 3 - ok. Si \1 u.n ch~wu t :> \
1
auÏf e l'\.2. o. ovwu... po- S
é. (..'5)/T) .
;:---r- ~ ,- · ~- ··
, . .

f." K.e""'f½. o\J.. ~Cù.mrv\o..i.r<. lll~J ·.

) ,8 1-------} o. Ae~ I b Pt b o.

LA ~ b / t.__.

~ \ \. f\\ ~a.a. .t:t-


'l'
~ 'd>3 )

éx o. c.i.o o5:

6 : ( ..--,, ê A No ê\ Eol'- E \ N o T E \ (f) \ T<v..t. \ Fccl ,.C · ( 9«>ron-o.<« <lts «(O<Afi oo> .U ;,~l .,:;_. s)

Q). tJn re.ma..<~ ~ ~o. .:ziro.mrt\cù.Ce es\- .,Û.c.u.<-iiv'e.. ~a.u.c.he· ~G n'ef>t- f'°-$ ll..(A) ,

feft"O.<"~ ·.
G , , 1- ""' b i ';j.:;_. , s,;. i I e,c( ,t,_ "" "'or "-';j o. nt- P"-~=" "'"''~ 'lln to.x\'t'-"'• de cl,<; ,o.h"<»
_-y""""',. l,. ""ot- : ïn.,.<. "'~ d Fo.l~t o< T"'--' . / -f ruu_ v\.. !,Jl_ Ç-e.. ôL r I'_,___._

E
1

-' )
rri,t 1

---1/ ~ -.,)
~ d' 0.'1>~ ctÀ.o.'faflr'c. l'î <U.t.<-he. .. d<oi\'e.. eu tùr\ o\roit,_'Ja,uche).
d..t. \11'' oçi li . OR A\\l t) l) +
NOÏ
......... >

G . f , 'l( {A \, . ,. .)
0..!.5ou.o...nv1\-e.: 'ja.u.c..'ne _dro,h. .

E\----'> EF\Nr.>E' \ foR.E' \ E' &1-----;, t 1


AN'DE !E:'oRE \l'

E' 1---4 Tn.u . \ fo..\~e. 1 NOi E l te ) .

C
If\ t
AND

T;~ /\\ E' At-.J 1) t

TLt 1
f'
l(lu..
1
fa.\~e_

1
f ~EOQ.~' \ f: •

E\ ~ t I A N D EIl l E
11
,

EIl ~ NOT 6Ill I E. Ill •


T ~NOTS \ S ·

S ~ ( f; ) l T(LU- 1fcd~
E'11 \--4 ( E) 1 Tn.u. \ fo..\g_
--->-- - - ~-....---· 1 1 \
1

\ '}<_ f ·'jz_~ 1 ~'? ·x.~


\ !
T ·i 'J l i,.c; Ù◄4
-'- ··
1
1
J.
i

L ;, (
·- --- --__ _l _ _ L _

\ , rut \ 1 Ço._\ ~ .:# ·.

-'l , . - - - - --- --- · - - - - - - - -

C h a.in e Ac hori
-- -
'D ~ çY\ U ..A
<::.m0>'-'--'' "--\1 ''- X A
·- - - - - - - -- - - -t--- ·-- ·-- --
·~ ç:>;~
t •'r'\\:) ,L\. HI i'2.- ]_!.\
- --- - --·-·- -- - 1---------
ï f u...:.. Ci~ (-o. \<,.< :fi 'v ~ (:1\ \..v\
E. mrv.. /\. I'--\ l Q -~ '.l-

i;, . ·,·f,:. N~~t~~r Le.. cc. fo.1 "' * 'V•\l"u.,


l¾.f a."' u__ \ .

r-" :. ;c·;,.- - ·- -· W ~ "'1. F ~ -


ls,. ;,, .. ·Lls I" UA
! êm~\...k...,\. H.1\'"2.. ~i
1-~
1

0' ;,· s 1),qnu___, -


·- ·· ·-- -- - -

• ___

!. ""'t· ;cc· ,~=·l,. ~-~:;


F ,ü,g 4t -
E ,n\"'L;:..A. k \ R.
. --------------i
-~ p-- ~,
N a. lt\ L-..,\ -
'.ù..-'l c

.. - ---- - -
1 "HG· F \ ...:..f'<- rc..h-<. =tt J)-2 ~'\ \.J..A .
~t"Y'IÇ'r\L-..,\ H, ,~ -~ 6 \
- ·- ·-- ·- ____ __I ___ -·--· --·-·----·- -· ----·-· . --- - -· ··- --- --1
1

1 o'i2.. Fe~\ '>i.. =# v <('Y\U.,\ -


E mp, U,.,1. k \ R.. ,J:t '2. .

·---··-- - - - --- - -
"'D~0-~ -
Avo..nc:...,, .

1
1 1

l ::t1E'F'
1

i
il=
'
~:,')~\.
1
1 l e·~ u_,,, M.' i2... 'A(;
1 1 \
··-
·"3) <. fi' U:..A .
:::tJ ( :tr 'Re,,
t.c"C\.Ç<l'I w\ ~ \ R.
1
1
---- -·- - ·- - ... ·- -- . - -·- - --- ---· -- --
! 1f Gc<at "'':) n ra...~l ~' l'\.,...,: r
i
+f
A~ ou. Cl.A )-S" , l.---,: , ;s I l
(,>5,' l~\j ; e_ ('\r \ ' o..i re,vr. l

Loj__ SSeA ;5~ , :> t::- eu 6 )

Vous aimerez peut-être aussi