definitions
must end with ENDS
(;, apparently), which means that defn_stmt
must end with ;. However, a stmt
must always be followed by a ;. So the grammar insists that a definition be followed by two semicolons.
You should remove the ENDS
from the defn_stmt
productions. Also, you might want to factor out the two occurrences of MATID OPENSQ NUMBER COMMA NUMBER CLOSEQ
; that's not the cause of your problems, though.
One obvious ambiguity (actually, two) is in the productions:
mat_contents: NUMBER
| mat_contents COMMA mat_contents
| mat_contents RANGE mat_contents
since it is (exponentially) ambiguous how to parse:
NUMBER COMMA NUMBER COMMA NUMBER RANGE NUMBER COMMA NUMBER
You could solve this with precedence declarations, or you could be more precise in your grammar.