pANTLR3_BASE_RECOGNIZER(3)
π pANTLR3_BASE_RECOGNIZER(3) β the base recognizer bestie π
okay so. this is a page from the ANTLR3C manual, section 3 (library functions, for the uninitiated π ). it's giving long. it comes in 4 parts and this is part 1, so don't go anywhere bestie, we're just getting started. β¨
β¨ NAME β¨
pANTLR3_BASE_RECOGNIZER β pANTLR3_BASE_RECOGNIZER Base Recognizer Implementation
- The base recognizer interface is implemented by all higher level recognizers such as
pANTLR3_PARSERand provides methods common to all recognizers.
πΈ SYNOPSIS πΈ
π¦ Functions π¦
static ANTLR3_BOOLEAN alreadyParsedRule (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_MARKER ruleIndex)β Has this rule already parsed input at the current index in the input stream?ANTLR3_API pANTLR3_BASE_RECOGNIZER antlr3BaseRecognizerNew (ANTLR3_UINT32 type, ANTLR3_UINT32 sizeHint, pANTLR3_RECOGNIZER_SHARED_STATE state)ANTLR3_API void antlr3MTExceptionNew (pANTLR3_BASE_RECOGNIZER recognizer)β Creates a new Mismatched Token Exception and inserts in the recognizer exception stack.ANTLR3_API void antlr3RecognitionExceptionNew (pANTLR3_BASE_RECOGNIZER recognizer)static void beginBacktrack (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_UINT32 level)static void beginResync (pANTLR3_BASE_RECOGNIZER recognizer)static pANTLR3_BITSET combineFollows (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_BOOLEAN exact)β Compute the current followset for the input stream.static pANTLR3_BITSET computeCSRuleFollow (pANTLR3_BASE_RECOGNIZER recognizer)β Compute the context-sensitive FOLLOW set for current rule.static pANTLR3_BITSET computeErrorRecoverySet (pANTLR3_BASE_RECOGNIZER recognizer)β Compute the error recovery set for the current rule.static void consumeUntil (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_UINT32 tokenType)β Eat tokens from the input stream until we get one of JUST the right type.static void consumeUntilSet (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_BITSET set)β Eat tokens from the input stream until we find one that belongs to the supplied set.static void displayRecognitionError (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_UINT8 *tokenNames)β Standard/Example error display method.static void endBacktrack (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_UINT32 level, ANTLR3_BOOLEAN successful)static void endResync (pANTLR3_BASE_RECOGNIZER recognizer)static void freeBR (pANTLR3_BASE_RECOGNIZER recognizer)static void ANTLR3_CDECL freeIntTrie (void *trie)static void * getCurrentInputSymbol (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_INT_STREAM istream)static void * getMissingSymbol (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_INT_STREAM istream, pANTLR3_EXCEPTION e, ANTLR3_UINT32 expectedTokenType, pANTLR3_BITSET_LIST follow)static ANTLR3_UINT32 getNumberOfSyntaxErrors (pANTLR3_BASE_RECOGNIZER recognizer)β Return how many syntax errors were detected by this recognizer.static pANTLR3_STACK getRuleInvocationStack (pANTLR3_BASE_RECOGNIZER recognizer)β Return the rule invocation stack (how we got here in the parse.static pANTLR3_STACK getRuleInvocationStackNamed (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_UINT8 name)static ANTLR3_MARKER getRuleMemoization (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_INTKEY ruleIndex, ANTLR3_MARKER ruleParseStart)β Pointer to a function to return whether the rule has parsed input starting at the supplied start index before.static void * match (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_UINT32 ttype, pANTLR3_BITSET_LIST follow)β Match current input symbol against ttype.static void matchAny (pANTLR3_BASE_RECOGNIZER recognizer)β Consumes the next token, whatever it is, and resets the recognizer state so that it is not in error.static void memoize (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_MARKER ruleIndex, ANTLR3_MARKER ruleParseStart)β Record whether or not this rule parsed the input at this position successfully.static void mismatch (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_UINT32 ttype, pANTLR3_BITSET_LIST follow)β Factor out what to do upon token mismatch so tree parsers can behave differently.static ANTLR3_BOOLEAN mismatchIsMissingToken (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_INT_STREAM is, pANTLR3_BITSET_LIST follow)static ANTLR3_BOOLEAN mismatchIsUnwantedToken (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_INT_STREAM is, ANTLR3_UINT32 ttype)static void recover (pANTLR3_BASE_RECOGNIZER recognizer)β Recover from an error found on the input stream.static ANTLR3_BOOLEAN recoverFromMismatchedElement (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_BITSET_LIST followBits)β This code is factored out from mismatched token and mismatched set recovery.static void * recoverFromMismatchedSet (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_BITSET_LIST follow)static void * recoverFromMismatchedToken (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_UINT32 ttype, pANTLR3_BITSET_LIST follow)β Attempt to recover from a single missing or extra token.static void reportError (pANTLR3_BASE_RECOGNIZER recognizer)β Report a recognition problem.static void reset (pANTLR3_BASE_RECOGNIZER recognizer)static ANTLR3_BOOLEAN synpred (pANTLR3_BASE_RECOGNIZER recognizer, void *ctx, void(*predicate)(void *ctx))β A syntactic predicate.static pANTLR3_HASH_TABLE toStrings (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_HASH_TABLE tokens)β Convenience method for template rewrites - NYI.
π Detailed Description π
The base recognizer interface is implemented by all higher level recognizers such as pANTLR3_PARSER and provides methods common to all recognizers.
like, think of it as the main character energy that every recognizer inherits. they all show up wearing the same fit. π
π Function Documentation π
π ANTLR3_BOOLEAN alreadyParsedRule (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_MARKER ruleIndex) [static] π
Has this rule already parsed input at the current index in the input stream? Return ANTLR3_TRUE if we have and ANTLR3_FALSE if we have not.
bestie, heads up β this method has a side-effect: if we have seen this input for this rule and successfully parsed before, then seek ahead to 1 past the stop token matched for this rule last time. not me casually moving the cursor, but okay. π
References:
ANTLR3_FALSE, ANTLR3_TRUE, ANTLR3_TYPE_LEXER, ANTLR3_TYPE_PARSER, ANTLR3_TYPE_TREE_PARSER, ANTLR3_TREE_PARSER_struct::ctnstream, ANTLR3_RECOGNIZER_SHARED_STATE_struct::failed, ANTLR3_BASE_RECOGNIZER_struct::getRuleMemoization, ANTLR3_INT_STREAM_struct::index, ANTLR3_LEXER_struct::input, ANTLR3_INPUT_STREAM_struct::istream, ANTLR3_TOKEN_STREAM_struct::istream, ANTLR3_TREE_NODE_STREAM_struct::istream, MEMO_RULE_FAILED, MEMO_RULE_UNKNOWN, ANTLR3_INT_STREAM_struct::seek, ANTLR3_BASE_RECOGNIZER_struct::state, ANTLR3_BASE_RECOGNIZER_struct::super, ANTLR3_COMMON_TREE_NODE_STREAM_struct::tnstream, ANTLR3_PARSER_struct::tstream, and ANTLR3_BASE_RECOGNIZER_struct::type.
Referenced by antlr3BaseRecognizerNew().
πΈ ANTLR3_API pANTLR3_BASE_RECOGNIZER antlr3BaseRecognizerNew (ANTLR3_UINT32 type, ANTLR3_UINT32 sizeHint, pANTLR3_RECOGNIZER_SHARED_STATE state) πΈ
References alreadyParsedRule(), ANTLR3_BASE_RECOGNIZER_struct::alreadyParsedRule, ANTLR3_FALSE, antlr3MTExceptionNew(), antlr3VectorNew(), ANTLR3_RECOGNIZER_SHARED_STATE_struct::backtracking, ANTLR3_BASE_RECOGNIZER_struct::beginBacktrack, beginBacktrack(), ANTLR3_BASE_RECOGNIZER_struct::beginResync, beginResync(), ANTLR3_BASE_RECOGNIZER_struct::combineFollows, combineFollows(), ANTLR3_BASE_RECOGNIZER_struct::computeCSRuleFollow, computeCSRuleFollow(), ANTLR3_BASE_RECOGNIZER_struct::computeErrorRecoverySet, computeErrorRecoverySet(), ANTLR3_BASE_RECOGNIZER_struct::consumeUntil, consumeUntil(), ANTLR3_BASE_RECOGNIZER_struct::consumeUntilSet, consumeUntilSet(), ANTLR3_BASE_RECOGNIZER_struct::debugger, ANTLR3_BASE_RECOGNIZER_struct::displayRecognitionError, displayRecognitionError(), ANTLR3_BASE_RECOGNIZER_struct::endBacktrack, endBacktrack(), ANTLR3_BASE_RECOGNIZER_struct::endResync, endResync(), ANTLR3_RECOGNIZER_SHARED_STATE_struct::errorCount, ANTLR3_RECOGNIZER_SHARED_STATE_struct::errorRecovery, ANTLR3_BASE_RECOGNIZER_struct::exConstruct, ANTLR3_RECOGNIZER_SHARED_STATE_struct::failed, ANTLR3_RECOGNIZER_SHARED_STATE_struct::following, ANTLR3_BASE_RECOGNIZER_struct::free, freeBR(), ANTLR3_BASE_RECOGNIZER_struct::getCurrentInputSymbol, getCurrentInputSymbol(), ANTLR3_BASE_RECOGNIZER_struct::getMissingSymbol, getMissingSymbol(), ANTLR3_BASE_RECOGNIZER_struct::getNumberOfSyntaxErrors, getNumberOfSyntaxErrors(), ANTLR3_BASE_RECOGNIZER_struct::getRuleInvocationStack, getRuleInvocationStack(), ANTLR3_BASE_RECOGNIZER_struct::getRuleInvocationStackNamed, getRuleInvocationStackNamed(), ANTLR3_BASE_RECOGNIZER_struct::getRuleMemoization, getRuleMemoization(), ANTLR3_RECOGNIZER_SHARED_STATE_struct::lastErrorIndex, ANTLR3_BASE_RECOGNIZER_struct::match, match(), ANTLR3_BASE_RECOGNIZER_struct::matchAny, matchAny(), ANTLR3_BASE_RECOGNIZER_struct::memoize, memoize(), ANTLR3_BASE_RECOGNIZER_struct::mismatch, mismatch(), ANTLR3_BASE_RECOGNIZER_struct::mismatchIsMissingToken, mismatchIsMissingToken(), ANTLR3_BASE_RECOGNIZER_struct::mismatchIsUnwantedToken, mismatchIsUnwantedToken(), ANTLR3_BASE_RECOGNIZER_struct::recover, recover(), recoverFromMismatchedElement(), ANTLR3_BASE_RECOGNIZER_struct::recoverFromMismatchedSet, recoverFromMismatchedSet(), ANTLR3_BASE_RECOGNIZER_struct::recoverFromMismatchedToken, recoverFromMismatchedToken(), ANTLR3_BASE_RECOGNIZER_struct::reportError, reportError(), ANTLR3_BASE_RECOGNIZER_struct::reset, reset(), ANTLR3_RECOGNIZER_SHARED_STATE_struct::rStreams, ANTLR3_RECOGNIZER_SHARED_STATE_struct::ruleMemo, ANTLR3_RECOGNIZER_SHARED_STATE_struct::sizeHint, ANTLR3_BASE_RECOGNIZER_struct::state, ANTLR3_BASE_RECOGNIZER_struct::synpred, synpred(), ANTLR3_RECOGNIZER_SHARED_STATE_struct::tokenNames, ANTLR3_RECOGNIZER_SHARED_STATE_struct::tokFactory, ANTLR3_RECOGNIZER_SHARED_STATE_struct::tokSource, ANTLR3_BASE_RECOGNIZER_struct::toStrings, toStrings(), and ANTLR3_BASE_RECOGNIZER_struct::type.
Referenced by antlr3LexerNew(), antlr3ParserNew(), and antlr3TreeParserNewStream().
π¦ ANTLR3_API void antlr3MTExceptionNew (pANTLR3_BASE_RECOGNIZER recognizer) π¦
Creates a new Mismatched Token Exception and inserts in the recognizer exception stack.
Parameters
- recognizer β Context pointer for this recognizer
References ANTLR3_MISMATCHED_EX_NAME, ANTLR3_MISMATCHED_TOKEN_EXCEPTION, antlr3RecognitionExceptionNew(), ANTLR3_RECOGNIZER_SHARED_STATE_struct::exception, ANTLR3_EXCEPTION_struct::name, ANTLR3_BASE_RECOGNIZER_struct::state, and ANTLR3_EXCEPTION_struct::type.
Referenced by antlr3BaseRecognizerNew(), antlr3ParserNew(), and mismatch().
okay part 1 is done, don't go anywhere, more of this saga is coming π
π ANTLR3_API void antlr3RecognitionExceptionNew (pANTLR3_BASE_RECOGNIZER recognizer)
bestie, this one doesn't come with a lil description in the docs, but it comes with a whole entourage of things it touches. it's giving "main character with a huge group chat". here's who's in the chat:
ANTLR3_INT_STREAM_struct::_LAANTLR3_TOKEN_STREAM_struct::_LTANTLR3_TREE_NODE_STREAM_struct::_LTANTLR3_CHARSTREAMANTLR3_COMMONTREENODEANTLR3_FALSEANTLR3_INPUT_MASKANTLR3_RECOGNITION_EX_NAMEANTLR3_RECOGNITION_EXCEPTIONANTLR3_TOKEN_EOFANTLR3_TOKENSTREAMANTLR3_TRUEANTLR3_TYPE_LEXERANTLR3_TYPE_PARSERANTLR3_TYPE_TREE_PARSERantlr3ExceptionNew()ANTLR3_EXCEPTION_struct::cANTLR3_EXCEPTION_struct::charPositionInLineANTLR3_TREE_PARSER_struct::ctnstreamANTLR3_RECOGNIZER_SHARED_STATE_struct::errorANTLR3_RECOGNIZER_SHARED_STATE_struct::exceptionANTLR3_INPUT_STREAM_struct::fileNameANTLR3_INPUT_STREAM_struct::getCharPositionInLinegetCharPositionInLine()ANTLR3_INPUT_STREAM_struct::getLinegetLine()ANTLR3_EXCEPTION_struct::indexANTLR3_INT_STREAM_struct::indexANTLR3_COMMON_TOKEN_struct::inputANTLR3_EXCEPTION_struct::inputANTLR3_LEXER_struct::inputANTLR3_INPUT_STREAM_struct::istreamANTLR3_TOKEN_STREAM_struct::istreamANTLR3_TREE_NODE_STREAM_struct::istreamANTLR3_EXCEPTION_struct::lineANTLR3_EXCEPTION_struct::messageANTLR3_EXCEPTION_struct::nextExceptionANTLR3_BASE_RECOGNIZER_struct::stateANTLR3_EXCEPTION_struct::streamNameANTLR3_BASE_RECOGNIZER_struct::superANTLR3_TOKEN_STREAM_struct::superANTLR3_COMMON_TREE_NODE_STREAM_struct::tnstreamANTLR3_COMMON_TREE_struct::tokenANTLR3_EXCEPTION_struct::tokenANTLR3_COMMON_TOKEN_STREAM_struct::tstreamANTLR3_PARSER_struct::tstreamANTLR3_BASE_RECOGNIZER_struct::typeANTLR3_INT_STREAM_struct::type
and who's out here calling it? the girlies:
antlr3MTExceptionNew()antlr3MTNExceptionNew()mismatch()recoverFromMismatchedToken()setCharStream()
β¨ void beginBacktrack (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_UINT32 level) [static]
the little static helper that kicks off a backtrack, and yes it says hi to the debugger on the way. it's linked up with:
ANTLR3_DEBUG_EVENT_LISTENER_struct::beginBacktrackANTLR3_BASE_RECOGNIZER_struct::debugger
and it gets referenced by:
antlr3BaseRecognizerNew()antlr3DebugListenerNew()
β¨ void beginResync (pANTLR3_BASE_RECOGNIZER recognizer) [static]
same energy, different vibe β this one announces that we're resyncing, debugger girlies notified π . it references:
ANTLR3_DEBUG_EVENT_LISTENER_struct::beginResyncANTLR3_BASE_RECOGNIZER_struct::debugger
referenced by:
antlr3BaseRecognizerNew()antlr3DebugListenerNew()
β¨ pANTLR3_BITSET combineFollows (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_BOOLEAN exact) [static]
literally just: compute the current followset for the input stream. that's the whole job. periodt.
references:
ANTLR3_EOR_TOKEN_TYPEANTLR3_FALSEANTLR3_TRUEantlr3BitsetLoad()antlr3BitsetNew()ANTLR3_BITSET_struct::borInPlaceANTLR3_RECOGNIZER_SHARED_STATE_struct::followingANTLR3_BITSET_struct::freeANTLR3_STACK_struct::getANTLR3_BITSET_struct::isMemberANTLR3_BITSET_struct::removeANTLR3_STACK_struct::sizeANTLR3_BASE_RECOGNIZER_struct::state
referenced by antlr3BaseRecognizerNew().
β¨ pANTLR3_BITSET computeCSRuleFollow (pANTLR3_BASE_RECOGNIZER recognizer) [static]
okay so this one computes the context-sensitive FOLLOW set for the current rule. and the docs below? straight-up lifted from the Java runtime, no cap. get comfy, this is a whole lecture π
this is the set of token types that can follow a specific rule reference given a specific call chain. you get the set of viable tokens that can possibly come next (look ahead depth 1) given the current call chain. contrast this with the definition of plain FOLLOW for rule r:
FOLLOW(r)={x | S=>*alpha r beta in G and x in FIRST(beta)}
where x in T* and alpha, beta in V*; T is set of terminals and V is the set of terminals and non terminals. in other words, FOLLOW(r) is the set of all tokens that can possibly follow references to r in any sentential form (context). at runtime, however, we know precisely which context applies as we have the call chain. we may compute the exact (rather than covering superset) set of following tokens.
for example, consider grammar:
stat : ID '=' expr ';' // FOLLOW(stat)=={EOF} | "return" expr '.' ; expr
: atom ('+' atom)* ; // FOLLOW(expr)=={';','.',')'} atom : INT //
FOLLOW(atom)=={'+',')',';','.'} | '(' expr ')' ;
the FOLLOW sets are all inclusive whereas context-sensitive FOLLOW sets are precisely what could follow a rule reference. for input input "i=(3);", here is the derivation:
stat => ID '=' expr ';' => ID '=' atom ('+' atom)* ';' => ID '=' '('
expr ')' ('+' atom)* ';' => ID '=' '(' atom ')' ('+' atom)* ';' => ID
'=' '(' INT ')' ('+' atom)* ';' => ID '=' '(' INT ')' ';'
at the "3" token, you'd have a call chain of
stat -> expr -> atom -> expr -> atom
what can follow that specific nested ref to atom? exactly ')' as you can see by looking at the derivation of this specific input. contrast this with the FOLLOW(atom)={'+',')',';','.'}.
you want the exact viable token set when recovering from a token mismatch. upon token mismatch, if LA(1) is member of the viable next token set, then you know there is most likely a missing token in the input stream. "Insert" one by just not throwing an exception. β¨
references:
ANTLR3_FALSEANTLR3_BASE_RECOGNIZER_struct::combineFollows
referenced by antlr3BaseRecognizerNew().
β¨ pANTLR3_BITSET computeErrorRecoverySet (pANTLR3_BASE_RECOGNIZER recognizer) [static]
compute the error recovery set for the current rule. docs below are from the Java implementation, so buckle up bestie, this is a long one π
during rule invocation, the parser pushes the set of tokens that can follow that rule reference on the stack; this amounts to computing FIRST of what follows the rule reference in the enclosing rule. this local follow set only includes tokens from within the rule; i.e., the FIRST computation done by ANTLR stops at the end of a rule. EXAMPLE when you find a "no viable alt exception", the input is not consistent with any of the alternatives for rule r. the best thing to do is to consume tokens until you see something that can legally follow a call to r or any rule that called r. you don't want the exact set of viable next tokens because the input might just be missing a token--you might consume the rest of the input looking for one of the missing tokens.
consider grammar:
a : '[' b ']' | '(' b ')' ; b : c '^' INT ; c : ID | INT ;
at each rule invocation, the set of tokens that could follow that rule is pushed on a stack. here are the various "local" follow sets:
FOLLOW(b1_in_a) = FIRST(']') = ']' FOLLOW(b2_in_a) = FIRST(')') = ')' FOLLOW(c_in_b) = FIRST('^') = '^'
upon erroneous input "[]", the call chain is
a -> b -> c
and, hence, the follow context stack is:
depth local follow set after call to rule 0 <EOF> a (from main()) 1 ']' b 3 '^' c
notice that ')' is not included, because b would have to have been called from a different context in rule a for ')' to be included.
for error recovery, we cannot consider FOLLOW(c) (context-sensitive or otherwise). we need the combined set of all context-sensitive FOLLOW sets--the set of all tokens that could follow any reference in the call chain. we need to resync to one of those tokens. note that FOLLOW(c)='^' and if we resync'd to that token, we'd consume until EOF. we need to sync to context-sensitive FOLLOWs for a, b, and c: {']','^'}. in this case, for input "[]", LA(1) is in this set so we would not consume anything and after printing an error rule c would return normally. it would not find the required '^' though. at this point, it gets a mismatched token error and throws an exception (since LA(1) is not in the viable following token set). the rule exception handler tries to recover, but finds the same recovery set and doesn't consume anything. rule b exits normally returning to rule a. now it finds the ']' (and with the successful match exits errorRecovery mode).
so, you can see that the parser walks up call chain looking for the token that was a member of the recovery set.
errors are not generated in errorRecovery mode.
ANTLR's error recovery mechanism is based upon original ideas:
"Algorithms + Data Structures = Programs" by Niklaus Wirth
and
"A note on error recovery in recursive descent parsers": http://portal.acm.org/citation.cfm?id=947902.947905
later, Josef Grosch had some good ideas:
"Efficient and Comfortable Error Recovery in Recursive DescentParsers": ftp://www.cocolab.com/products/cocktail/doca4.ps/ell.ps.zip
like Grosch I implemented local FOLLOW sets that are combined at run-time upon error to avoid overhead during parsing.
references:
ANTLR3_FALSEANTLR3_BASE_RECOGNIZER_struct::combineFollows
referenced by antlr3BaseRecognizerNew().
β¨ void consumeUntil (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_UINT32 tokenType) [static]
eat tokens from the input stream until we get one of JUST the right type. snacking on tokens until the right one shows up, iconic behavior honestly π
references:
ANTLR3_INT_STREAM_struct::_LAANTLR3_TOKEN_EOFANTLR3_TYPE_PARSERANTLR3_TYPE_TREE_PARSERANTLR3_INT_STREAM_struct::consumeANTLR3_TREE_PARSER_struct::ctnstreamANTLR3_TOKEN_STREAM_struct::istreamANTLR3_TREE_NODE_STREAM_struct::istreamANTLR3_BASE_RECOGNIZER_struct::superANTLR3_COMMON_TREE_NODE_STREAM_struct::tnstreamANTLR3_PARSER_struct::tstreamANTLR3_BASE_RECOGNIZER_struct::type
referenced by antlr3BaseRecognizerNew().
β¨ void consumeUntilSet (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_BITSET set) [static]
eat tokens from the input stream until we find one that belongs to the supplied set. same snack energy, but the target is a whole set instead of one type. queen of "i'll know it when i see it" π
references:
ANTLR3_INT_STREAM_struct::_LAANTLR3_FALSEANTLR3_TOKEN_EOFANTLR3_TYPE_PARSERANTLR3_TYPE_TREE_PARSERANTLR3_INT_STREAM_struct::consumeANTLR3_TREE_PARSER_struct::ctnstreamANTLR3_BITSET_struct::isMemberANTLR3_TOKEN_STREAM_struct::istreamANTLR3_TREE_NODE_STREAM_struct::istreamANTLR3_BASE_RECOGNIZER_struct::superANTLR3_COMMON_TREE_NODE_STREAM_struct::tnstreamANTLR3_PARSER_struct::tstreamANTLR3_BASE_RECOGNIZER_struct::type
referenced by antlr3BaseRecognizerNew().
β¨ void displayRecognitionError (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_UINT8 * tokenNames) [static]
standard/example error display method. no generic error message display function could possibly do everything correctly for all possible parsers. hence you are provided with this example routine, which you should override in your parser/tree parser to do as you will.
here we depart somewhat from the Java runtime as that has now split up a lot of the error display routines into separate units. however, there is little advantage to this in the C version as you will probably implement all such routines as a separate translation unit, rather than install them all as pointers to functions in the base recognizer.
- References β
ANTLR3_EARLY_EXIT_EXCEPTION</p>,ANTLR3_MISMATCHED_SET_EXCEPTION</p>,ANTLR3_MISMATCHED_TOKEN_EXCEPTION</p>,ANTLR3_MISSING_TOKEN_EXCEPTION</p>,ANTLR3_NO_VIABLE_ALT_EXCEPTION</p>,ANTLR3_RECOGNITION_EXCEPTION</p>,ANTLR3_TOKEN_EOF</p>,ANTLR3_TYPE_PARSER</p>,ANTLR3_TYPE_TREE_PARSER</p>,ANTLR3_UNWANTED_TOKEN_EXCEPTION</p>,antlr3BitsetLoad()</p>,ANTLR3_EXCEPTION_struct::charPositionInLine</p>,ANTLR3_STRING_struct::chars</p>,ANTLR3_TREE_PARSER_struct::ctnstream</p>,ANTLR3_RECOGNIZER_SHARED_STATE_struct::exception</p>,ANTLR3_EXCEPTION_struct::expecting</p>,ANTLR3_EXCEPTION_struct::expectingSet</p>,ANTLR3_BASE_TREE_struct::getCharPositionInLine</p>,ANTLR3_BASE_TREE_struct::getToken</p>,ANTLR3_TOKEN_STREAM_struct::istream</p>,ANTLR3_TREE_NODE_STREAM_struct::istream</p>,ANTLR3_EXCEPTION_struct::line</p>,ANTLR3_EXCEPTION_struct::message</p>,ANTLR3_BITSET_struct::numBits</p>,ANTLR3_BITSET_struct::size</p>,size()</p>,ANTLR3_BASE_RECOGNIZER_struct::state</p>,ANTLR3_EXCEPTION_struct::streamName</p>,ANTLR3_BASE_RECOGNIZER_struct::super</p>,ANTLR3_BASE_TREE_struct::super</p>,ANTLR3_COMMON_TREE_NODE_STREAM_struct::tnstream</p>,ANTLR3_STRING_struct::to8</p>,ANTLR3_EXCEPTION_struct::token</p>,ANTLR3_COMMON_TOKEN_struct::toString</p>,ANTLR3_BASE_TREE_struct::toStringTree</p>,ANTLR3_PARSER_struct::tstream</p>,ANTLR3_BASE_RECOGNIZER_struct::type</p>,ANTLR3_COMMON_TOKEN_struct::type</p>, andANTLR3_EXCEPTION_struct::type</p>. - Referenced by β
antlr3BaseRecognizerNew()</p>, andantlr3LexerNew()</p>.
void endBacktrack(pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_UINT32 level, ANTLR3_BOOLEAN successful) [static]
References: ANTLR3_BASE_RECOGNIZER_struct::debugger</p>, and ANTLR3_DEBUG_EVENT_LISTENER_struct::endBacktrack</p>.
Referenced by: antlr3BaseRecognizerNew()</p>, and antlr3DebugListenerNew()</p>.
void endResync(pANTLR3_BASE_RECOGNIZER recognizer) [static]
References: ANTLR3_BASE_RECOGNIZER_struct::debugger</p>, and ANTLR3_DEBUG_EVENT_LISTENER_struct::endResync</p>.
Referenced by: antlr3BaseRecognizerNew()</p>, and antlr3DebugListenerNew()</p>.
void freeBR(pANTLR3_BASE_RECOGNIZER recognizer) [static]
References: ANTLR3_TOKEN_FACTORY_struct::close</p>, ANTLR3_RECOGNIZER_SHARED_STATE_struct::exception</p>, ANTLR3_INT_TRIE_struct::free</p>, ANTLR3_EXCEPTION_struct::freeEx</p>, ANTLR3_RECOGNIZER_SHARED_STATE_struct::rStreams</p>, ANTLR3_RECOGNIZER_SHARED_STATE_struct::ruleMemo</p>, ANTLR3_BASE_RECOGNIZER_struct::state</p>, and ANTLR3_RECOGNIZER_SHARED_STATE_struct::tokFactory</p>.
Referenced by: antlr3BaseRecognizerNew()</p>.
void ANTLR3_CDECL freeIntTrie(void * trie) [static]
Referenced by: getRuleMemoization()</p>.
void * getCurrentInputSymbol(pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_INT_STREAM istream) [static]
References: ANTLR3_INT_STREAM_struct::super</p>.
Referenced by: antlr3BaseRecognizerNew()</p>, antlr3LexerNew()</p>, and antlr3TreeParserNewStream()</p>.
void * getMissingSymbol(pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_INT_STREAM istream, pANTLR3_EXCEPTION e, ANTLR3_UINT32 expectedTokenType, pANTLR3_BITSET_LIST follow) [static]
References: ANTLR3_TOKEN_STREAM_struct::_LT</p>, ANTLR3_TOKEN_DEFAULT_CHANNEL</p>, ANTLR3_TOKEN_EOF</p>, antlr3TokenFactoryNew()</p>, ANTLR3_STRING_struct::append8</p>, ANTLR3_COMMON_TOKEN_struct::custom</p>, ANTLR3_COMMON_TOKEN_struct::getCharPositionInLine</p>, ANTLR3_COMMON_TOKEN_struct::getLine</p>, ANTLR3_COMMON_TOKEN_struct::getText</p>, ANTLR3_COMMON_TOKEN_struct::getType</p>, ANTLR3_COMMON_TOKEN_struct::input</p>, ANTLR3_COMMON_TOKEN_struct::lineStart</p>, ANTLR3_TOKEN_FACTORY_struct::newToken</p>, ANTLR3_COMMON_TOKEN_struct::setChannel</p>, ANTLR3_COMMON_TOKEN_struct::setCharPositionInLine</p>, ANTLR3_COMMON_TOKEN_struct::setLine</p>, ANTLR3_COMMON_TOKEN_struct::setText8</p>, ANTLR3_COMMON_TOKEN_struct::setType</p>, ANTLR3_BASE_RECOGNIZER_struct::state</p>, ANTLR3_INT_STREAM_struct::super</p>, ANTLR3_TOKEN_STREAM_struct::super</p>, ANTLR3_RECOGNIZER_SHARED_STATE_struct::tokenNames</p>, ANTLR3_RECOGNIZER_SHARED_STATE_struct::tokFactory</p>, ANTLR3_COMMON_TOKEN_struct::user1</p>, ANTLR3_COMMON_TOKEN_struct::user2</p>, and ANTLR3_COMMON_TOKEN_struct::user3</p>.
Referenced by: antlr3BaseRecognizerNew()</p>, antlr3LexerNew()</p>, and antlr3TreeParserNewStream()</p>.
ANTLR3_UINT32 getNumberOfSyntaxErrors(pANTLR3_BASE_RECOGNIZER recognizer) [static]
Ok so this one literally tells you how many syntax errors were detected by this recognizer. That's the whole vibe. π
References: ANTLR3_RECOGNIZER_SHARED_STATE_struct::errorCount</p>, and ANTLR3_BASE_RECOGNIZER_struct::state</p>.
Referenced by: antlr3BaseRecognizerNew()</p>.
pANTLR3_STACK getRuleInvocationStack(pANTLR3_BASE_RECOGNIZER recognizer) [static]
Returns the rule invocation stack β aka how we got here in the parse. And then, bestie, the plot twist: in the java version Ter just asks the JVM for all the information but in C we don't get this information, so I am going to do nothing right now. π Not me reading a whole function whose whole deal is doing nothing. Iconic honestly. π«Ά
Referenced by: antlr3BaseRecognizerNew()</p>.
pANTLR3_STACK getRuleInvocationStackNamed(pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_UINT8 name) [static]
Referenced by: antlr3BaseRecognizerNew()</p>.
ANTLR3_MARKER getRuleMemoization(pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_INTKEY ruleIndex, ANTLR3_MARKER ruleParseStart) [static]
Pointer to a function that returns whether the rule has parsed input starting at the supplied start index before. So if the rule has not parsed input starting from the supplied start index, it returns ANTLR3_MEMO_RULE_UNKNOWN. And if it has parsed from the suppled start point, it returns the point where it last stopped parsing after that start point. (Yes, "suppled", the original said that, we're keeping it, no notes. β¨)
Remarks
The rule memos are an ANTLR3_LIST of ANTLR3_LISTS, however if this becomes any kind of performance issue (it probably won't, the hash tables are pretty quick) then we could make a special int only version of the table. Lowkey a glow-up waiting to happen but also lowkey unnecessary, iykyk. π
References: ANTLR3_INT_TRIE_struct::add</p>, ANTLR3_FUNC_PTR</p>, ANTLR3_HASH_TYPE_STR</p>, antlr3IntTrieNew()</p>, ANTLR3_TRIE_ENTRY_struct::data</p>, freeIntTrie()</p>, ANTLR3_INT_TRIE_struct::get</p>, ANTLR3_TRIE_ENTRY_struct::intVal</p>, MEMO_RULE_UNKNOWN</p>, ANTLR3_TRIE_ENTRY_struct::ptr</p>, ANTLR3_RECOGNIZER_SHARED_STATE_struct::ruleMemo</p>, and ANTLR3_BASE_RECOGNIZER_struct::state</p>.
Referenced by: antlr3BaseRecognizerNew()</p>.
void * match(pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_UINT32 ttype, pANTLR3_BITSET_LIST follow) [static]
Matches the current input symbol against ttype. Upon error, it does one token insertion or deletion if possible. πΈ
To turn off single token insertion or deletion error recovery, override mismatchRecover() and have it call plain mismatch(), which does not recover. Then any error in a rule will cause an exception and immediate exit from rule. The rule would recover by resynchronizing to the set of symbols that can follow the rule ref.
References: ANTLR3_INT_STREAM_struct::_LA</p>, ANTLR3_FALSE</p>, ANTLR3_TRUE</p>, ANTLR3_TYPE_PARSER</p>, ANTLR3_TYPE_TREE_PARSER</p>, ANTLR3_RECOGNIZER_SHARED_STATE_struct::backtracking</p>, ANTLR3_INT_STREAM_struct::consume</p>, ANTLR3_TREE_PARSER_struct::ctnstream</p>, ANTLR3_RECOGNIZER_SHARED_STATE_struct::errorRecovery</p>, ANTLR3_RECOGNIZER_SHARED_STATE_struct::failed</p>, ANTLR3_BASE_RECOGNIZER_struct::getCurrentInputSymbol</p>, ANTLR3_TOKEN_STREAM_struct::istream</p>, ANTLR3_TREE_NODE_STREAM_struct::istream</p>, ANTLR3_BASE_RECOGNIZER_struct::recoverFromMismatchedToken</p>, ANTLR3_BASE_RECOGNIZER_struct::state</p>, ANTLR3_BASE_RECOGNIZER_struct::super</p>, ANTLR3_COMMON_TREE_NODE_STREAM_struct::tnstream</p>, ANTLR3_PARSER_struct::tstream</p>, and ANTLR3_BASE_RECOGNIZER_struct::type</p>.
Referenced by: antlr3BaseRecognizerNew()</p>.
void matchAny(pANTLR3_BASE_RECOGNIZER recognizer) [static]
Consumes the next token, whatever it is, and resets the recognizer state so that it is not in error. No thoughts, head empty, just vibes β it takes the token and moves on. π¦
Parameters
- recognizer β Recognizer context pointer
References: ANTLR3_FALSE</p>, ANTLR3_TYPE_PARSER</p>, ANTLR3_TYPE_TREE_PARSER</p>, ANTLR3_INT_STREAM_struct::consume</p>, ANTLR3_TREE_PARSER_struct::ctnstream</p>, ANTLR3_RECOGNIZER_SHARED_STATE_struct::errorRecovery</p>, ANTLR3_RECOGNIZER_SHARED_STATE_struct::failed</p>, ANTLR3_TOKEN_STREAM_struct::istream</p>, ANTLR3_TREE_NODE_STREAM_struct::istream</p>, ANTLR3_BASE_RECOGNIZER_struct::state</p>, ANTLR3_BASE_RECOGNIZER_struct::super</p>, ANTLR3_COMMON_TREE_NODE_STREAM_struct::tnstream</p>, ANTLR3_PARSER_struct::tstream</p>, and ANTLR3_BASE_RECOGNIZER_struct::type</p>.
Referenced by: antlr3BaseRecognizerNew()</p>, and antlr3LexerNew()</p>.
void memoize(pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_MARKER ruleIndex, ANTLR3_MARKER ruleParseStart) [static]
Records whether or not this rule parsed the input at this position successfully. Receipts, basically. π§Ύβ¨
References: ANTLR3_INT_TRIE_struct::add</p>, ANTLR3_HASH_TYPE_INT</p>, ANTLR3_TRUE</p>, ANTLR3_TYPE_LEXER</p>, ANTLR3_TYPE_PARSER</p>, ANTLR3_TYPE_TREE_PARSER</p>, ANTLR3_TREE_PARSER_struct::ctnstream</p>, ANTLR3_TRIE_ENTRY_struct::data</p>, ANTLR3_RECOGNIZER_SHARED_STATE_struct::failed</p>, ANTLR3_INT_TRIE_struct::get</p>, ANTLR3_INT_STREAM_struct::index</p>, ANTLR3_LEXER_struct::input</p>, ANTLR3_INPUT_STREAM_struct::istream</p>, ANTLR3_TOKEN_STREAM_struct::istream</p>, ANTLR3_TREE_NODE_STREAM_struct::istream</p>, MEMO_RULE_FAILED</p>, ANTLR3_TRIE_ENTRY_struct::ptr</p>, ANTLR3_RECOGNIZER_SHARED_STATE_struct::ruleMemo</p>, ANTLR3_BASE_RECOGNIZER_struct::state</p>, ANTLR3_BASE_RECOGNIZER_struct::super</p>, ANTLR3_COMMON_TREE_NODE_STREAM_struct::tnstream</p>, ANTLR3_PARSER_struct::tstream</p>, and ANTLR3_BASE_RECOGNIZER_struct::type</p>.
Referenced by: antlr3BaseRecognizerNew()</p>.
void mismatch(pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_UINT32 ttype, pANTLR3_BITSET_LIST follow) [static]
Factors out what to do upon token mismatch so tree parsers can behave differently. Override it and call mismatchRecover(input, ttype, follow) to get single token insertion and deletion. Use this one to turn off single token insertion and deletion. Or, plot twist, override mismatchRecover to call this instead. π
Remarks
π¨ Bestie, listen: mismatch only works for parsers and must be overridden for anything else. Do not come crying to me when your tree parser is confused. It's giving "read the fine print" energy. π
References: ANTLR3_MISSING_TOKEN_EXCEPTION</p>, ANTLR3_MISSING_TOKEN_EXCEPTION_NAME</p>, ANTLR3_TYPE_PARSER</p>, ANTLR3_UNWANTED_TOKEN_EXCEPTION</p>, ANTLR3_UNWANTED_TOKEN_EXCEPTION_NAME</p>, antlr3MTExceptionNew()</p>, antlr3RecognitionExceptionNew()</p>, ANTLR3_RECOGNIZER_SHARED_STATE_struct::exception</p>, ANTLR3_EXCEPTION_struct::expecting</p>, ANTLR3_TOKEN_STREAM_struct::istream</p>, mismatchIsMissingToken()</p>, mismatchIsUnwantedToken()</p>, ANTLR3_EXCEPTION_struct::name</p>, ANTLR3_BASE_RECOGNIZER_struct::state</p>, ANTLR3_BASE_RECOGNIZER_struct::super</p>, ANTLR3_PARSER_struct::tstream</p>, ANTLR3_BASE_RECOGNIZER_struct::type</p>, and ANTLR3_EXCEPTION_struct::type</p>.
Referenced by: antlr3BaseRecognizerNew()</p>, and antlr3TreeParserNewStream()</p>.
ANTLR3_BOOLEAN mismatchIsMissingToken(pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_INT_STREAM is, pANTLR3_BITSET_LIST follow) [static]
If the current token is consistent with what could come after the set, then we know we're missing a token β and error recovery is free to "insert" the missing token. π
And a lil heads up, bestie: BitSet cannot handle negative numbers like -1 (that's EOF π), so I leave EOR in the follow set to indicate that the fall of the start symbol is in the set (EOF can follow).
π¦ ANTLR3_BOOLEAN mismatchIsUnwantedToken (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_INT_STREAM is, ANTLR3_UINT32 ttype) [static]
Refs it's leaning on:
ANTLR3_INT_STREAM_struct::_LAANTLR3_FALSEANTLR3_TRUEANTLR3_RECOGNIZER_SHARED_STATE_struct::exceptionANTLR3_EXCEPTION_struct::expectingANTLR3_BASE_RECOGNIZER_struct::state
Referenced by: antlr3BaseRecognizerNew(), and mismatch().
π«Ά void recover (pANTLR3_BASE_RECOGNIZER recognizer) [static]
Okay so this one is the get back up bestie function πͺ. It recovers from an error found on the input stream. Mostly this is NoViableAlt exceptions, but it could also be a mismatched token that the match() routine could not recover from.
Refs it's leaning on:
ANTLR3_FALSEANTLR3_TYPE_PARSERANTLR3_TYPE_TREE_PARSERANTLR3_BASE_RECOGNIZER_struct::beginResyncANTLR3_BASE_RECOGNIZER_struct::computeErrorRecoverySetANTLR3_INT_STREAM_struct::consumeANTLR3_BASE_RECOGNIZER_struct::consumeUntilSetANTLR3_TREE_PARSER_struct::ctnstreamANTLR3_BASE_RECOGNIZER_struct::endResyncANTLR3_RECOGNIZER_SHARED_STATE_struct::errorANTLR3_RECOGNIZER_SHARED_STATE_struct::failedANTLR3_BITSET_struct::freeANTLR3_INT_STREAM_struct::indexANTLR3_TOKEN_STREAM_struct::istreamANTLR3_TREE_NODE_STREAM_struct::istreamANTLR3_RECOGNIZER_SHARED_STATE_struct::lastErrorIndexANTLR3_BASE_RECOGNIZER_struct::stateANTLR3_BASE_RECOGNIZER_struct::superANTLR3_COMMON_TREE_NODE_STREAM_struct::tnstreamANTLR3_PARSER_struct::tstreamANTLR3_BASE_RECOGNIZER_struct::type
Referenced by: antlr3BaseRecognizerNew(), and antlr3LexerNew().
πΈ ANTLR3_BOOLEAN recoverFromMismatchedElement (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_BITSET_LIST followBits) [static]
This code is factored out from mismatched token and mismatched set recovery. It handles "single token insertion" error recovery for both. No tokens are consumed to recover from insertions. Returns true if recovery was possible, else returns false. No cap, that's literally the whole job β¨.
Refs it's leaning on:
ANTLR3_INT_STREAM_struct::_LAANTLR3_EOR_TOKEN_TYPEANTLR3_FALSEANTLR3_TRUEANTLR3_TYPE_PARSERANTLR3_TYPE_TREE_PARSERantlr3BitsetLoad()ANTLR3_BASE_RECOGNIZER_struct::computeCSRuleFollowANTLR3_TREE_PARSER_struct::ctnstreamANTLR3_RECOGNIZER_SHARED_STATE_struct::errorANTLR3_RECOGNIZER_SHARED_STATE_struct::failedANTLR3_BITSET_struct::freeANTLR3_BITSET_struct::isMemberANTLR3_TOKEN_STREAM_struct::istreamANTLR3_TREE_NODE_STREAM_struct::istreamANTLR3_BITSET_struct::removeANTLR3_BASE_RECOGNIZER_struct::reportErrorANTLR3_BASE_RECOGNIZER_struct::stateANTLR3_BASE_RECOGNIZER_struct::superANTLR3_COMMON_TREE_NODE_STREAM_struct::tnstreamANTLR3_PARSER_struct::tstreamANTLR3_BASE_RECOGNIZER_struct::type
Referenced by: antlr3BaseRecognizerNew().
π
void * recoverFromMismatchedSet (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_BITSET_LIST follow) [static]
Refs it's leaning on:
ANTLR3_FALSEANTLR3_MISSING_TOKEN_EXCEPTIONANTLR3_TOKEN_INVALIDANTLR3_TRUEANTLR3_TYPE_PARSERANTLR3_TYPE_TREE_PARSERANTLR3_TREE_PARSER_struct::ctnstreamANTLR3_RECOGNIZER_SHARED_STATE_struct::errorANTLR3_RECOGNIZER_SHARED_STATE_struct::exceptionANTLR3_RECOGNIZER_SHARED_STATE_struct::failedANTLR3_BASE_RECOGNIZER_struct::getMissingSymbolANTLR3_TOKEN_STREAM_struct::istreamANTLR3_TREE_NODE_STREAM_struct::istreamANTLR3_BASE_RECOGNIZER_struct::mismatchIsMissingTokenANTLR3_BASE_RECOGNIZER_struct::reportErrorANTLR3_BASE_RECOGNIZER_struct::stateANTLR3_BASE_RECOGNIZER_struct::superANTLR3_COMMON_TREE_NODE_STREAM_struct::tnstreamANTLR3_EXCEPTION_struct::tokenANTLR3_PARSER_struct::tstreamANTLR3_BASE_RECOGNIZER_struct::typeANTLR3_EXCEPTION_struct::type
Referenced by: antlr3BaseRecognizerNew().
π₯ void * recoverFromMismatchedToken (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_UINT32 ttype, pANTLR3_BITSET_LIST follow) [static]
Attempt to recover from a single missing or extra token. Bestie, there are two flavours and you need to know both π
EXTRA TOKEN
LA(1) is not what we are looking for. If LA(2) has the right token, however, then assume LA(1) is some extra spurious token. Delete it and LA(2) as if we were doing a normal match(), which advances the input.
MISSING TOKEN
If current token is consistent with what could come after ttype then it is ok to "insert" the missing token, else throw exception. For example, Input "i=(3;" is clearly missing the ')'. When the parser returns from the nested call to expr, it will have call chain:
stat -> expr -> atom
and it will be trying to match the ')' at this point in the derivation:
=> ID '=' '(' INT ')' ('+' atom)* ';'
^
match() will see that ';' doesn't match ')' and report a mismatched token error. To recover, it sees that LA(1)==';' is in the set of tokens that can follow the ')' token reference in rule atom. It can assume that you forgot the ')'.
The exception that was passed in, in the java implementation is sorted in the recognizer exception stack in the C version. To 'throw' it we set the error flag and rules cascade back when this is set.
Refs it's leaning on:
ANTLR3_FALSEANTLR3_MISSING_TOKEN_EXCEPTIONANTLR3_MISSING_TOKEN_EXCEPTION_NAMEANTLR3_TRUEANTLR3_TYPE_PARSERANTLR3_TYPE_TREE_PARSERANTLR3_UNWANTED_TOKEN_EXCEPTIONANTLR3_UNWANTED_TOKEN_EXCEPTION_NAMEantlr3RecognitionExceptionNew()ANTLR3_BASE_RECOGNIZER_struct::beginResyncANTLR3_DEBUG_EVENT_LISTENER_struct::beginResyncANTLR3_INT_STREAM_struct::consumeANTLR3_TREE_PARSER_struct::ctnstreamANTLR3_BASE_RECOGNIZER_struct::debuggerANTLR3_BASE_RECOGNIZER_struct::endResyncANTLR3_DEBUG_EVENT_LISTENER_struct::endResyncANTLR3_RECOGNIZER_SHARED_STATE_struct::errorANTLR3_RECOGNIZER_SHARED_STATE_struct::exceptionANTLR3_EXCEPTION_struct::expectingANTLR3_BASE_RECOGNIZER_struct::getCurrentInputSymbolANTLR3_BASE_RECOGNIZER_struct::getMissingSymbolANTLR3_TOKEN_STREAM_struct::istreamANTLR3_TREE_NODE_STREAM_struct::istreamANTLR3_EXCEPTION_struct::messagemismatchIsMissingToken()ANTLR3_BASE_RECOGNIZER_struct::mismatchIsUnwantedTokenANTLR3_BASE_RECOGNIZER_struct::reportErrorANTLR3_BASE_RECOGNIZER_struct::stateANTLR3_BASE_RECOGNIZER_struct::superANTLR3_COMMON_TREE_NODE_STREAM_struct::tnstreamANTLR3_EXCEPTION_struct::tokenANTLR3_PARSER_struct::tstreamANTLR3_BASE_RECOGNIZER_struct::typeANTLR3_EXCEPTION_struct::type
Referenced by: antlr3BaseRecognizerNew().
π void reportError (pANTLR3_BASE_RECOGNIZER recognizer) [static]
Report a recognition problem. This method sets errorRecovery to indicate the parser is recovering, not parsing. Once in recovery mode, no errors are generated. To get out of recovery mode, the parser must successfully match a token (after a resync). So it will go:
- error occurs
- enter recovery mode, report error
- consume until token found in resynch set
- try to resume parsing
- next
match()will reseterrorRecoverymode
If you override, make sure to update errorCount if you care about that. (Not me guilt-tripping you, the manpage said it π)
Refs it's leaning on:
ANTLR3_TRUEANTLR3_BASE_RECOGNIZER_struct::debuggerANTLR3_BASE_RECOGNIZER_struct::displayRecognitionErrorANTLR3_RECOGNIZER_SHARED_STATE_struct::errorCountANTLR3_RECOGNIZER_SHARED_STATE_struct::errorRecoveryANTLR3_RECOGNIZER_SHARED_STATE_struct::exceptionANTLR3_DEBUG_EVENT_LISTENER_struct::recognitionExceptionANTLR3_BASE_RECOGNIZER_struct::stateANTLR3_RECOGNIZER_SHARED_STATE_struct::tokenNames
Referenced by: antlr3BaseRecognizerNew(), and antlr3LexerNew().
π§ void reset (pANTLR3_BASE_RECOGNIZER recognizer) [static]
The factory-reset of the recognizer world. Clean slate, new era, main character energy π.
Refs it's leaning on:
ANTLR3_FALSEantlr3IntTrieNew()antlr3StackNew()ANTLR3_RECOGNIZER_SHARED_STATE_struct::backtrackingANTLR3_RECOGNIZER_SHARED_STATE_struct::errorCountANTLR3_RECOGNIZER_SHARED_STATE_struct::errorRecoveryANTLR3_RECOGNIZER_SHARED_STATE_struct::exceptionANTLR3_RECOGNIZER_SHARED_STATE_struct::failedANTLR3_RECOGNIZER_SHARED_STATE_struct::followingANTLR3_INT_TRIE_struct::freeANTLR3_STACK_struct::freeANTLR3_EXCEPTION_struct::freeExANTLR3_RECOGNIZER_SHARED_STATE_struct::lastErrorIndexANTLR3_RECOGNIZER_SHARED_STATE_struct::ruleMemoANTLR3_BASE_RECOGNIZER_struct::state
Referenced by: antlr3BaseRecognizerNew(), antlr3CommonTokenStreamNew(), antlr3CommonTreeNodeStreamNew(), antlr3CommonTreeNodeStreamNewStream(), antlr3LexerNew(), and antlr3RewriteRuleElementStreamNewAE().
β ANTLR3_BOOLEAN synpred (pANTLR3_BASE_RECOGNIZER recognizer, void * ctx, void(* predicate )(void *ctx)) [static]
A syntactic predicate. Returns true/false depending on whether the specified grammar fragment matches the current input stream. This resets the failed instance var afterwards. It's giving "peek before you commit" and honestly? obsessed π«Ά.
Refs it's leaning on:
ANTLR3_FALSEANTLR3_TRUEANTLR3_TYPE_PARSERANTLR3_TYPE_TREE_PARSERANTLR3_RECOGNIZER_SHARED_STATE_struct::backtrackingANTLR3_TREE_PARSER_struct::ctnstreamANTLR3_RECOGNIZER_SHARED_STATE_struct::failedANTLR3_TOKEN_STREAM_struct::istreamANTLR3_TREE_NODE_STREAM_struct::istreamANTLR3_INT_STREAM_struct::markANTLR3_INT_STREAM_struct::rewindANTLR3_BASE_RECOGNIZER_struct::stateANTLR3_BASE_RECOGNIZER_struct::superANTLR3_COMMON_TREE_NODE_STREAM_struct::tnstreamANTLR3_PARSER_struct::tstreamANTLR3_BASE_RECOGNIZER_struct::type
Referenced by: antlr3BaseRecognizerNew().
π pANTLR3_HASH_TABLE toStrings (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_HASH_TABLE tokens) [static]
Convenience method for template rewrites - NYI. (Not Yet Implemented, bestie β it's on the vision board, not in the code π)
Referenced by: antlr3BaseRecognizerNew().
π Author
Generated automatically by Doxygen for ANTLR3C from the source code. Not a human, not a vibe curator β a robot wrote the receipts and I just gave them a glow-up β¨
And that's a wrap on part 4, bestie!! π This whole page is from ANTLR3C, version 3.3.1, dated Tue Jul 29 2025 00:00:00 β so if you're citing it, that's your girl. Go forth and recover() from your errors, fr fr. π
π¦πΈ
π¦ where this page comes from
- fedora 43: antlr3-C-devel 1:3.4-3.5.3.14.fc43 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms