[Yacc] Résoudre des conflits
Bonjour tout le monde,
j'essaye depuis tout à l'heure de résoudre les conflits reduce/reduce et shift/reduce de Yacc mais je bloque.
D'abord, je n'arrive pas à comprendre comment lever exactement l'ambiguïté; ensuite, il y a un conflit que je n'arrive pas à résoudre, le voici au niveau de l'état 24 dans la fichier output :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| state 24
instruction_composee -> error . instructions_optionnelles FIN (rule 49)
instruction -> error . AFFECTATION expression (rule 61)
instruction -> error . expression ALORS instruction SINON instruction (rule 63)
instruction -> error . expression FAIRE instruction (rule 66)
appel_de_procedure -> error . (rule 70)
appel_de_procedure -> error . PAROUV liste_expressions PARFER (rule 71)
error shift, and go to state 48
DEBUT shift, and go to state 16
AFFECTATION shift, and go to state 49
SI shift, and go to state 25
TANT_QUE shift, and go to state 26
NON shift, and go to state 50
PAROUV shift, and go to state 51
IDENT shift, and go to state 52
NBRE shift, and go to state 53
'+' shift, and go to state 54
'-' shift, and go to state 55
error [reduce using rule 70 (appel_de_procedure)]
FIN reduce using rule 51 (instructions_optionnelles)
FIN [reduce using rule 70 (appel_de_procedure)]
SINON reduce using rule 70 (appel_de_procedure)
PVIRG reduce using rule 70 (appel_de_procedure)
instruction_composee go to state 28
instructions_optionnelles go to state 29
liste_instructions go to state 30
instruction go to state 31
appel_de_procedure go to state 32
expression go to state 56
expression_simple go to state 57
terme go to state 58
facteur go to state 59
signe go to state 60
rule 51 : instructions_optionnelles -> /* empty */
rule 70 : appel_de_procedure -> error |
- Et la partie de la grammaire concernée par le conflit :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| Instruction_composée → begin instructions_optionnelles end
instructions_optionnelles →liste_instructions
|ε
liste_instructions →instruction
|liste_instructions ; instruction
Instruction → variable opaffect expression
|appel_de_procédure
|instruction_composée
|if expression
|then instruction
|else instruction
|while expression do
|instruction |
Je ne comprends pas du tout où se situe le problème, si vous avez des docs à partager au sujet de la résolution des conflits avec le fichier output ou si vous pouvez m'aider pour ce cas, ça serait très sympa.
Merci.