Open mattkindy opened 6 years ago
Think the reason this is happening is greedy checks on the following:
shiftExpression
: additiveExpression
| shiftExpression '<<' additiveExpression
| shiftExpression '>>' additiveExpression
| shiftExpression '>>>' additiveExpression
;
These tokens are implicit during lexing and have match priority. The solution is probably
shiftExpression
: additiveExpression
| shiftExpression '<' '<' additiveExpression
| shiftExpression '>' '>' additiveExpression
| shiftExpression '>' '>' '>' additiveExpression
;
As another note, this seems to have happened when the Java9 grammar was made to support shiftExpression
since the Java8 grammar here seems to lack them. When shift tokens were commented out, it didn't cause errors because they weren't used in the parser rules. In general, the parser rules should not use string literals. I would prefer
shiftExpression
: additiveExpression
| shiftExpression LT LT additiveExpression
| shiftExpression GT GT additiveExpression
| shiftExpression GT GT GT additiveExpression
;
As an example,
will cause an error, while
is handled properly.