In your production for TERMINE
, the second alternative is useless; you might as well write
< TERMINE: ( < NUM_SEGNO > | "(-" < VARIABILE > ")" ) >
That's what the error message is telling you. Why is it useless? JavaCC's regular expressions obey the three rules explained in FAQ 3.3. Go read about them, before you read further. ... Ok you're back. You now should understand that, if the longest prefix of the input that matches any rule matches the rule for < VARIABILE >
(and therefore also your rule for <TERMINE>
), then the rule for < VARIABILE >
will beat the rule for < TERMINE >
by virtue of being first in the .jj file.
What to do to fix this depends on what you want to achieve. My guess is that you should move the choice up to the parser level. I.e. delete the rule for TERMINE
and replace it with a syntactic rule
void Termine() : {} {
<NUM_SEGNO>
|
<VARIABILE>
|
"(-" <VARIABLE> ")"
}
For other possibilities, see FAQ 3.6 and FAQ 4.19.