A propos de la récursion à gauche (ou à droite) et LR(1).
Il n'y a vraiment aucun problème. (Cela a été dit et redit en cours!)
Pour vous en convaincre, regardez ce que produit menhir quand on a une
grammaire avec une récursion à gauche :
/tmp % zed g.mly
Err 1 pangolin
%token S EOF
%start<unit> s
%%
s: mylist EOF {}
mylist: /* empty */ {}
| mylist S {}
/tmp % menhir --dump g.mly
15:47 pangolin
/tmp % cat g.automaton
15:47 pangolin
State 0:
s' -> . s [ # ]
-- On s shift to state 1
-- On mylist shift to state 2
-- On S reduce production mylist ->
-- On EOF reduce production mylist ->
State 1:
s' -> s . [ # ]
-- On # accept s
State 2:
mylist -> mylist . S [ S EOF ]
s -> mylist . EOF [ # ]
-- On S shift to state 3
-- On EOF shift to state 4
State 3:
mylist -> mylist S . [ S EOF ]
-- On S reduce production mylist -> mylist S
-- On EOF reduce production mylist -> mylist S
State 4:
s -> mylist EOF . [ # ]
-- On # reduce production s -> mylist EOF
2012/5/20 Yann Régis-Gianas <
y...@pps.univ-paris-diderot.fr>: