bison -d
on your input gives me:
test.y:6.17-20: symbol CODE is used, but is not defined as a token and has no rules
test.y:6.13-15: symbol DEC is used, but is not defined as a token and has no rules
which tells you exactly what the problem is -- you're using CODE
and DEC
and not defining them. Add them to one of the %token
lines and it works fine...
edit
The error 'start symbol S does not derive any sentence' is telling you that you have unbounded recursion in your grammar, so that no (finite) input can match the start symbol. In you case, S
must include a CODE
, which must include a command
(directly or via a listcommand
), which must contain a boucle
, which must in turn contain another listcommand
. So you end up with an infinite expansion chain of listcommands
-> command
-> boucle
-> listcommands
.
The problem is probably your rule
listcommands: command | listcommands ;
which matches exactly one command, plus a useless (and ambiguous) unbounded noop-expansion of that command. You probably want
listcommands: /*epsilon*/ | listcommands command ;
which matches 0 or more command
s in sequence. Making this change fixes the fatal error, but still leaves a bunch of shift-reduce conflicts, along with the useless rule dectype: dectype
.
To track down and fix shift/reduce conflicts, use bison -v
to produce a .output
file listing the grammar, states and conflicts in detail. Most of yours come from not having a precedence for NOT
, and the other two come from the ambiguous dectype
and CODE
rules.