I have a grammar (antlr4) file with both lexer and parser rules. I have extended the generated *BaseListener
class and overridden
public void visitErrorNode(@NotNull ErrorNode node) {}
method. Inside the method body I am trying to get the next possible parser rule (in this case I need to know that 'op' is the rule which is expected as next rule for the given input). visitErrorNode
is the right method to get this or any other ways to get the desired information.
combined grammar:-
ratingCriteria : 'rating' op NUMBER
op: '>' | '>=' | '<' ;
Input Text:
rating
actual error I got:
no viable alternative at input 'rating'