Class GrammarParserInterpreter.BailButConsumeErrorStrategy

  • Enclosing class:
    GrammarParserInterpreter


    public static class GrammarParserInterpreter.BailButConsumeErrorStrategy
    extends DefaultErrorStrategy
    We want to stop and track the first error but we cannot bail out like BailErrorStrategy as consume() constructs trees. We make sure to create an error node during recovery with this strategy. We consume() 1 token during the "bail out of rule" mechanism in recover() and let it fall out of the rule to finish constructing trees. For recovery in line, we throw InputMismatchException to engage recover().
    • Field Detail

      • firstErrorTokenIndex

        public int firstErrorTokenIndex
    • Constructor Detail

      • BailButConsumeErrorStrategy

        public BailButConsumeErrorStrategy()
    • Method Detail

      • recover

        public void recover(Parser recognizer,
                            RecognitionException e)
      • recoverInline

        public Token recoverInline(Parser recognizer)
                            throws RecognitionException
        Throws:
        RecognitionException
      • sync

        public void sync(Parser recognizer)