I've found that my grammar recovers as expected inside the plugin but
the parser doesn't behave the same when executed in the code.
For the grammar below, the input :XXX
produces 2 different trees, one in the plugin (I believe the correct
one, or at least better) and a different tree when executed in code.
Also the error messages I get are different:
- IntelliJIdea => line 1:0 extraneous input ':' expecting {'(', Term}
- Running the code => line 1:0 no viable alternative at input ':'
Is there any setting I can add to my code so that it recovers like the plugin?
Check the images below to see the differences.
Note: The number of X is just a typing error, but it doesn't really change the result
This is a simplified grammar that shows the issue:
grammar Combined1;
compileUnit : field EOF ;
field:
fieldName ':' value
| value;
fieldName: Term;
value:
'(' value ')'
| Term;
Term: TERM_START_CHAR TERM_CHAR*;
fragment TERM_START_CHAR: ~( ' ' | '\t' | '\n' | '\r' | ':' );
fragment TERM_CHAR : (TERM_START_CHAR | '.' );
WS : [ \t\r\n\f]+ -> skip;