/** * \remark Mismatch only works for parsers and must be overridden for anything else. */ static void mismatch(pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_UINT32 ttype, pANTLR3_BITSET follow) { pANTLR3_PARSER parser; pANTLR3_TREE_PARSER tparser; pANTLR3_INT_STREAM is; /* Install a mismatched token exception in the exception stack */ antlr3MTExceptionNew(recognizer); recognizer->exception->expecting = ttype; switch (recognizer->type) { case ANTLR3_TYPE_PARSER: parser = (pANTLR3_PARSER) (recognizer->super); tparser = NULL; is = parser->tstream->istream; break; default: fprintf(stderr, "Base recognizerfunction 'mismatch' called by unknown parser type - provide override for this function\n"); return; break; } /* Enter error recovery mode */ recognizer->recoverFromMismatchedToken(recognizer, ttype, follow); return; }
/** Override for standard base recognizer mismatch function * as we have DOWN/UP nodes in the stream that have no line info, * plus we want to alter the exception type. */ static void mismatch (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_UINT32 ttype, pANTLR3_BITSET_LIST follow) { recognizer->exConstruct(recognizer); recognizer->recoverFromMismatchedToken(recognizer, ttype, follow); }