antlr3-pANTLR3_BASE_RECOGNIZER man page

pANTLR3_BASE_RECOGNIZER — pANTLR3_BASE_RECOGNIZER Base Recognizer Implementation

The base recognizer interface is implemented by all higher level recognizers such as pANTLR3_PARSER and provides methods common to all recognizers.

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? Return ANTLR3_TRUE if we have and ANTLR3_FALSE if we have not.
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.

Function Documentation

static 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. 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.

References ANTLR3_FALSE, ANTLR3_FPRINTF, 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_TREE_NODE_STREAM_struct::istream, ANTLR3_TOKEN_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_CALLOC, ANTLR3_FALSE, ANTLR3_FREE, ANTLR3_MALLOC, antlr3MTExceptionNew(), antlr3VectorNew(), ANTLR3_RECOGNIZER_SHARED_STATE_struct::backtracking, beginBacktrack(), ANTLR3_BASE_RECOGNIZER_struct::beginBacktrack, beginResync(), ANTLR3_BASE_RECOGNIZER_struct::beginResync, combineFollows(), ANTLR3_BASE_RECOGNIZER_struct::combineFollows, computeCSRuleFollow(), ANTLR3_BASE_RECOGNIZER_struct::computeCSRuleFollow, computeErrorRecoverySet(), ANTLR3_BASE_RECOGNIZER_struct::computeErrorRecoverySet, consumeUntil(), ANTLR3_BASE_RECOGNIZER_struct::consumeUntil, consumeUntilSet(), ANTLR3_BASE_RECOGNIZER_struct::consumeUntilSet, ANTLR3_BASE_RECOGNIZER_struct::debugger, displayRecognitionError(), ANTLR3_BASE_RECOGNIZER_struct::displayRecognitionError, endBacktrack(), ANTLR3_BASE_RECOGNIZER_struct::endBacktrack, endResync(), ANTLR3_BASE_RECOGNIZER_struct::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(), getCurrentInputSymbol(), ANTLR3_BASE_RECOGNIZER_struct::getCurrentInputSymbol, getMissingSymbol(), ANTLR3_BASE_RECOGNIZER_struct::getMissingSymbol, getNumberOfSyntaxErrors(), ANTLR3_BASE_RECOGNIZER_struct::getNumberOfSyntaxErrors, getRuleInvocationStack(), ANTLR3_BASE_RECOGNIZER_struct::getRuleInvocationStack, getRuleInvocationStackNamed(), ANTLR3_BASE_RECOGNIZER_struct::getRuleInvocationStackNamed, getRuleMemoization(), ANTLR3_BASE_RECOGNIZER_struct::getRuleMemoization, ANTLR3_RECOGNIZER_SHARED_STATE_struct::lastErrorIndex, match(), ANTLR3_BASE_RECOGNIZER_struct::match, matchAny(), ANTLR3_BASE_RECOGNIZER_struct::matchAny, memoize(), ANTLR3_BASE_RECOGNIZER_struct::memoize, mismatch(), ANTLR3_BASE_RECOGNIZER_struct::mismatch, mismatchIsMissingToken(), ANTLR3_BASE_RECOGNIZER_struct::mismatchIsMissingToken, mismatchIsUnwantedToken(), ANTLR3_BASE_RECOGNIZER_struct::mismatchIsUnwantedToken, recover(), ANTLR3_BASE_RECOGNIZER_struct::recover, recoverFromMismatchedElement(), recoverFromMismatchedSet(), ANTLR3_BASE_RECOGNIZER_struct::recoverFromMismatchedSet, recoverFromMismatchedToken(), ANTLR3_BASE_RECOGNIZER_struct::recoverFromMismatchedToken, reportError(), ANTLR3_BASE_RECOGNIZER_struct::reportError, reset(), ANTLR3_BASE_RECOGNIZER_struct::reset, ANTLR3_RECOGNIZER_SHARED_STATE_struct::rStreams, ANTLR3_RECOGNIZER_SHARED_STATE_struct::ruleMemo, ANTLR3_RECOGNIZER_SHARED_STATE_struct::sizeHint, ANTLR3_BASE_RECOGNIZER_struct::state, synpred(), ANTLR3_BASE_RECOGNIZER_struct::synpred, ANTLR3_RECOGNIZER_SHARED_STATE_struct::tokenNames, ANTLR3_RECOGNIZER_SHARED_STATE_struct::tokFactory, ANTLR3_RECOGNIZER_SHARED_STATE_struct::tokSource, toStrings(), ANTLR3_BASE_RECOGNIZER_struct::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_API, 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().

ANTLR3_API void antlr3RecognitionExceptionNew (pANTLR3_BASE_RECOGNIZER recognizer)

References ANTLR3_INT_STREAM_struct::_LA, ANTLR3_TREE_NODE_STREAM_struct::_LT, ANTLR3_TOKEN_STREAM_struct::_LT, ANTLR3_CHARSTREAM, ANTLR3_COMMONTREENODE, ANTLR3_FALSE, ANTLR3_FPRINTF, ANTLR3_INPUT_MASK, ANTLR3_RECOGNITION_EX_NAME, ANTLR3_RECOGNITION_EXCEPTION, ANTLR3_TOKEN_EOF, ANTLR3_TOKENSTREAM, ANTLR3_TRUE, ANTLR3_TYPE_LEXER, ANTLR3_TYPE_PARSER, ANTLR3_TYPE_TREE_PARSER, antlr3ExceptionNew(), ANTLR3_EXCEPTION_struct::c, ANTLR3_EXCEPTION_struct::charPositionInLine, ANTLR3_TREE_PARSER_struct::ctnstream, ANTLR3_RECOGNIZER_SHARED_STATE_struct::error, ANTLR3_RECOGNIZER_SHARED_STATE_struct::exception, ANTLR3_INPUT_STREAM_struct::fileName, getCharPositionInLine(), ANTLR3_INPUT_STREAM_struct::getCharPositionInLine, getLine(), ANTLR3_INPUT_STREAM_struct::getLine, ANTLR3_INT_STREAM_struct::index, ANTLR3_EXCEPTION_struct::index, ANTLR3_LEXER_struct::input, ANTLR3_COMMON_TOKEN_struct::input, ANTLR3_EXCEPTION_struct::input, ANTLR3_INPUT_STREAM_struct::istream, ANTLR3_TREE_NODE_STREAM_struct::istream, ANTLR3_TOKEN_STREAM_struct::istream, ANTLR3_EXCEPTION_struct::line, ANTLR3_EXCEPTION_struct::message, ANTLR3_EXCEPTION_struct::nextException, ANTLR3_BASE_RECOGNIZER_struct::state, ANTLR3_EXCEPTION_struct::streamName, ANTLR3_BASE_RECOGNIZER_struct::super, ANTLR3_TOKEN_STREAM_struct::super, ANTLR3_COMMON_TREE_NODE_STREAM_struct::tnstream, ANTLR3_COMMON_TREE_struct::token, ANTLR3_EXCEPTION_struct::token, ANTLR3_PARSER_struct::tstream, ANTLR3_COMMON_TOKEN_STREAM_struct::tstream, ANTLR3_BASE_RECOGNIZER_struct::type, and ANTLR3_INT_STREAM_struct::type.

Referenced by antlr3MTExceptionNew(), antlr3MTNExceptionNew(), mismatch(), recoverFromMismatchedToken(), and setCharStream().

static void beginBacktrack (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_UINT32 level) [static]

References ANTLR3_DEBUG_EVENT_LISTENER_struct::beginBacktrack, and ANTLR3_BASE_RECOGNIZER_struct::debugger.

Referenced by antlr3BaseRecognizerNew().

static void beginResync (pANTLR3_BASE_RECOGNIZER recognizer) [static]

References ANTLR3_DEBUG_EVENT_LISTENER_struct::beginResync, and ANTLR3_BASE_RECOGNIZER_struct::debugger.

Referenced by antlr3BaseRecognizerNew().

static pANTLR3_BITSET combineFollows (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_BOOLEAN exact) [static]

Compute the current followset for the input stream.

References ANTLR3_EOR_TOKEN_TYPE, ANTLR3_FALSE, ANTLR3_TRUE, antlr3BitsetLoad(), antlr3BitsetNew(), ANTLR3_BITSET_struct::borInPlace, ANTLR3_RECOGNIZER_SHARED_STATE_struct::following, ANTLR3_BITSET_struct::free, ANTLR3_STACK_struct::get, ANTLR3_BITSET_struct::isMember, ANTLR3_BITSET_struct::remove, ANTLR3_STACK_struct::size, and ANTLR3_BASE_RECOGNIZER_struct::state.

Referenced by antlr3BaseRecognizerNew().

static pANTLR3_BITSET computeCSRuleFollow (pANTLR3_BASE_RECOGNIZER recognizer) [static]

Compute the context-sensitive FOLLOW set for current rule. Documentation below is from the Java runtime.

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_FALSE, and ANTLR3_BASE_RECOGNIZER_struct::combineFollows.

Referenced by antlr3BaseRecognizerNew().

static pANTLR3_BITSET computeErrorRecoverySet (pANTLR3_BASE_RECOGNIZER recognizer) [static]

Compute the error recovery set for the current rule. Documentation below is from the Java implementation.

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=9…

Later, Josef Grosch had some good ideas:

'Efficient and Comfortable Error Recovery in Recursive Descent Parsers': ftp://www.cocolab.com/products/cocktail…

Like Grosch I implemented local FOLLOW sets that are combined at run-time upon error to avoid overhead during parsing.

References ANTLR3_FALSE, and ANTLR3_BASE_RECOGNIZER_struct::combineFollows.

Referenced by antlr3BaseRecognizerNew().

static 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.

References ANTLR3_INT_STREAM_struct::_LA, ANTLR3_FPRINTF, ANTLR3_TOKEN_EOF, ANTLR3_TYPE_PARSER, ANTLR3_TYPE_TREE_PARSER, ANTLR3_INT_STREAM_struct::consume, ANTLR3_TREE_PARSER_struct::ctnstream, ANTLR3_TREE_NODE_STREAM_struct::istream, ANTLR3_TOKEN_STREAM_struct::istream, 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().

static 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.

References ANTLR3_INT_STREAM_struct::_LA, ANTLR3_FALSE, ANTLR3_FPRINTF, ANTLR3_TOKEN_EOF, ANTLR3_TYPE_PARSER, ANTLR3_TYPE_TREE_PARSER, ANTLR3_INT_STREAM_struct::consume, ANTLR3_TREE_PARSER_struct::ctnstream, ANTLR3_TREE_NODE_STREAM_struct::istream, ANTLR3_TOKEN_STREAM_struct::istream, 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().

static void displayRecognitionError (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_UINT8 * tokenNames) [static]

Standard/Example error display method. No generic error message display funciton coudl 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 spearate units. However, ther 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, ANTLR3_FPRINTF, ANTLR3_MISMATCHED_SET_EXCEPTION, ANTLR3_MISMATCHED_TOKEN_EXCEPTION, ANTLR3_MISSING_TOKEN_EXCEPTION, ANTLR3_NO_VIABLE_ALT_EXCEPTION, ANTLR3_RECOGNITION_EXCEPTION, ANTLR3_TOKEN_EOF, ANTLR3_TYPE_PARSER, ANTLR3_TYPE_TREE_PARSER, ANTLR3_UNWANTED_TOKEN_EXCEPTION, antlr3BitsetLoad(), ANTLR3_EXCEPTION_struct::charPositionInLine, ANTLR3_STRING_struct::chars, ANTLR3_TREE_PARSER_struct::ctnstream, ANTLR3_RECOGNIZER_SHARED_STATE_struct::exception, ANTLR3_EXCEPTION_struct::expecting, ANTLR3_EXCEPTION_struct::expectingSet, ANTLR3_BASE_TREE_struct::getCharPositionInLine, ANTLR3_BASE_TREE_struct::getToken, ANTLR3_TREE_NODE_STREAM_struct::istream, ANTLR3_TOKEN_STREAM_struct::istream, ANTLR3_EXCEPTION_struct::line, ANTLR3_EXCEPTION_struct::message, ANTLR3_BITSET_struct::numBits, size(), ANTLR3_BITSET_struct::size, ANTLR3_BASE_RECOGNIZER_struct::state, ANTLR3_EXCEPTION_struct::streamName, ANTLR3_BASE_TREE_struct::super, ANTLR3_BASE_RECOGNIZER_struct::super, ANTLR3_COMMON_TREE_NODE_STREAM_struct::tnstream, ANTLR3_STRING_struct::to8, ANTLR3_EXCEPTION_struct::token, ANTLR3_COMMON_TOKEN_struct::toString, ANTLR3_BASE_TREE_struct::toStringTree, ANTLR3_PARSER_struct::tstream, ANTLR3_BASE_RECOGNIZER_struct::type, ANTLR3_COMMON_TOKEN_struct::type, and ANTLR3_EXCEPTION_struct::type.

Referenced by antlr3BaseRecognizerNew().

static void endBacktrack (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_UINT32 level, ANTLR3_BOOLEAN successful) [static]

References ANTLR3_BASE_RECOGNIZER_struct::debugger, and ANTLR3_DEBUG_EVENT_LISTENER_struct::endBacktrack.

Referenced by antlr3BaseRecognizerNew().

static void endResync (pANTLR3_BASE_RECOGNIZER recognizer) [static]

References ANTLR3_BASE_RECOGNIZER_struct::debugger, and ANTLR3_DEBUG_EVENT_LISTENER_struct::endResync.

Referenced by antlr3BaseRecognizerNew().

static void freeBR (pANTLR3_BASE_RECOGNIZER recognizer) [static]

References ANTLR3_API, ANTLR3_FREE, ANTLR3_TOKEN_FACTORY_struct::close, ANTLR3_RECOGNIZER_SHARED_STATE_struct::exception, ANTLR3_INT_TRIE_struct::free, ANTLR3_EXCEPTION_struct::freeEx, ANTLR3_RECOGNIZER_SHARED_STATE_struct::rStreams, ANTLR3_RECOGNIZER_SHARED_STATE_struct::ruleMemo, ANTLR3_BASE_RECOGNIZER_struct::state, and ANTLR3_RECOGNIZER_SHARED_STATE_struct::tokFactory.

Referenced by antlr3BaseRecognizerNew().

static void ANTLR3_CDECL freeIntTrie (void * trie) [static]

Referenced by getRuleMemoization().

static void * getCurrentInputSymbol (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_INT_STREAM istream) [static]

References ANTLR3_INT_STREAM_struct::super.

Referenced by antlr3BaseRecognizerNew().

static 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, ANTLR3_TOKEN_DEFAULT_CHANNEL, ANTLR3_TOKEN_EOF, antlr3TokenFactoryNew(), ANTLR3_STRING_struct::append8, ANTLR3_COMMON_TOKEN_struct::custom, ANTLR3_COMMON_TOKEN_struct::getCharPositionInLine, ANTLR3_COMMON_TOKEN_struct::getLine, ANTLR3_COMMON_TOKEN_struct::getText, ANTLR3_COMMON_TOKEN_struct::getType, ANTLR3_COMMON_TOKEN_struct::input, ANTLR3_COMMON_TOKEN_struct::lineStart, ANTLR3_TOKEN_FACTORY_struct::newToken, ANTLR3_COMMON_TOKEN_struct::setChannel, ANTLR3_COMMON_TOKEN_struct::setCharPositionInLine, ANTLR3_COMMON_TOKEN_struct::setLine, ANTLR3_COMMON_TOKEN_struct::setText8, ANTLR3_COMMON_TOKEN_struct::setType, ANTLR3_BASE_RECOGNIZER_struct::state, ANTLR3_INT_STREAM_struct::super, ANTLR3_TOKEN_STREAM_struct::super, ANTLR3_RECOGNIZER_SHARED_STATE_struct::tokenNames, ANTLR3_RECOGNIZER_SHARED_STATE_struct::tokFactory, ANTLR3_COMMON_TOKEN_struct::user1, ANTLR3_COMMON_TOKEN_struct::user2, and ANTLR3_COMMON_TOKEN_struct::user3.

Referenced by antlr3BaseRecognizerNew().

static ANTLR3_UINT32 getNumberOfSyntaxErrors (pANTLR3_BASE_RECOGNIZER recognizer) [static]

Return how many syntax errors were detected by this recognizer.

References ANTLR3_RECOGNIZER_SHARED_STATE_struct::errorCount, and ANTLR3_BASE_RECOGNIZER_struct::state.

Referenced by antlr3BaseRecognizerNew().

static pANTLR3_STACK getRuleInvocationStack (pANTLR3_BASE_RECOGNIZER recognizer) [static]

Return the rule invocation stack (how we got here in the parse. 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.

Referenced by antlr3BaseRecognizerNew().

static pANTLR3_STACK getRuleInvocationStackNamed (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_UINT8 name) [static]

Referenced by antlr3BaseRecognizerNew().

static ANTLR3_MARKER getRuleMemoization (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_INTKEY ruleIndex, ANTLR3_MARKER ruleParseStart) [static]

Pointer to a function to return whether the rule has parsed input starting at the supplied start index before. If the rule has not parsed input starting from the supplied start index, then it will return ANTLR3_MEMO_RULE_UNKNOWN. If it has parsed from the suppled start point then it will return the point where it last stopped parsing after that start point.

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.

References ANTLR3_INT_TRIE_struct::add, ANTLR3_FUNC_PTR, ANTLR3_HASH_TYPE_STR, antlr3IntTrieNew(), ANTLR3_TRIE_ENTRY_struct::data, freeIntTrie(), ANTLR3_INT_TRIE_struct::get, ANTLR3_TRIE_ENTRY_struct::intVal, MEMO_RULE_UNKNOWN, ANTLR3_TRIE_ENTRY_struct::ptr, ANTLR3_RECOGNIZER_SHARED_STATE_struct::ruleMemo, and ANTLR3_BASE_RECOGNIZER_struct::state.

Referenced by antlr3BaseRecognizerNew().

static void * match (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_UINT32 ttype, pANTLR3_BITSET_LIST follow) [static]

Match current input symbol against ttype. Upon error, do 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. Rule would recover by resynchronizing to the set of symbols that can follow rule ref.

References ANTLR3_INT_STREAM_struct::_LA, ANTLR3_FALSE, ANTLR3_FPRINTF, ANTLR3_TRUE, ANTLR3_TYPE_PARSER, ANTLR3_TYPE_TREE_PARSER, ANTLR3_RECOGNIZER_SHARED_STATE_struct::backtracking, ANTLR3_INT_STREAM_struct::consume, ANTLR3_TREE_PARSER_struct::ctnstream, ANTLR3_RECOGNIZER_SHARED_STATE_struct::errorRecovery, ANTLR3_RECOGNIZER_SHARED_STATE_struct::failed, ANTLR3_BASE_RECOGNIZER_struct::getCurrentInputSymbol, ANTLR3_TREE_NODE_STREAM_struct::istream, ANTLR3_TOKEN_STREAM_struct::istream, ANTLR3_BASE_RECOGNIZER_struct::recoverFromMismatchedToken, 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().

static 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.

Parameters:

recognizer Recognizer context pointer

References ANTLR3_FALSE, ANTLR3_FPRINTF, ANTLR3_TYPE_PARSER, ANTLR3_TYPE_TREE_PARSER, ANTLR3_INT_STREAM_struct::consume, ANTLR3_TREE_PARSER_struct::ctnstream, ANTLR3_RECOGNIZER_SHARED_STATE_struct::errorRecovery, ANTLR3_RECOGNIZER_SHARED_STATE_struct::failed, ANTLR3_TREE_NODE_STREAM_struct::istream, ANTLR3_TOKEN_STREAM_struct::istream, 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().

static void memoize (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_MARKER ruleIndex, ANTLR3_MARKER ruleParseStart) [static]

Record whether or not this rule parsed the input at this position successfully.

References ANTLR3_INT_TRIE_struct::add, ANTLR3_FPRINTF, ANTLR3_HASH_TYPE_INT, ANTLR3_TRUE, ANTLR3_TYPE_LEXER, ANTLR3_TYPE_PARSER, ANTLR3_TYPE_TREE_PARSER, ANTLR3_TREE_PARSER_struct::ctnstream, ANTLR3_TRIE_ENTRY_struct::data, ANTLR3_RECOGNIZER_SHARED_STATE_struct::failed, ANTLR3_INT_TRIE_struct::get, ANTLR3_INT_STREAM_struct::index, ANTLR3_LEXER_struct::input, ANTLR3_INPUT_STREAM_struct::istream, ANTLR3_TREE_NODE_STREAM_struct::istream, ANTLR3_TOKEN_STREAM_struct::istream, MEMO_RULE_FAILED, ANTLR3_TRIE_ENTRY_struct::ptr, ANTLR3_RECOGNIZER_SHARED_STATE_struct::ruleMemo, 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().

static void mismatch (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_UINT32 ttype, pANTLR3_BITSET_LIST follow) [static]

Factor out what to do upon token mismatch so tree parsers can behave differently. Override and call mismatchRecover(input, ttype, follow) to get single token insertion and deletion. Use this to turn off single token insertion and deletion. Override mismatchRecover to call this instead.

Remarks:

mismatch only works for parsers and must be overridden for anything else.

References ANTLR3_FPRINTF, ANTLR3_MISSING_TOKEN_EXCEPTION, ANTLR3_MISSING_TOKEN_EXCEPTION_NAME, ANTLR3_TYPE_PARSER, ANTLR3_UNWANTED_TOKEN_EXCEPTION, ANTLR3_UNWANTED_TOKEN_EXCEPTION_NAME, antlr3MTExceptionNew(), antlr3RecognitionExceptionNew(), ANTLR3_RECOGNIZER_SHARED_STATE_struct::exception, ANTLR3_EXCEPTION_struct::expecting, ANTLR3_TOKEN_STREAM_struct::istream, mismatchIsMissingToken(), mismatchIsUnwantedToken(), ANTLR3_EXCEPTION_struct::name, ANTLR3_BASE_RECOGNIZER_struct::state, ANTLR3_BASE_RECOGNIZER_struct::super, ANTLR3_PARSER_struct::tstream, ANTLR3_BASE_RECOGNIZER_struct::type, and ANTLR3_EXCEPTION_struct::type.

Referenced by antlr3BaseRecognizerNew().

static ANTLR3_BOOLEAN mismatchIsMissingToken (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_INT_STREAM is, pANTLR3_BITSET_LIST follow) [static]

if current token is consistent with what could come after set then we know we're missing a token; error recovery is free to 'insert' the missing token

BitSet cannot handle negative numbers like -1 (EOF) so I leave EOR in follow set to indicate that the fall of the start symbol is in the set (EOF can follow).

References ANTLR3_INT_STREAM_struct::_LA, ANTLR3_EOR_TOKEN_TYPE, ANTLR3_FALSE, ANTLR3_TRUE, antlr3BitsetLoad(), ANTLR3_BITSET_struct::borInPlace, ANTLR3_BASE_RECOGNIZER_struct::computeCSRuleFollow, ANTLR3_BITSET_struct::free, ANTLR3_BITSET_struct::isMember, and ANTLR3_BITSET_struct::remove.

Referenced by antlr3BaseRecognizerNew(), mismatch(), and recoverFromMismatchedToken().

static ANTLR3_BOOLEAN mismatchIsUnwantedToken (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_INT_STREAM is, ANTLR3_UINT32 ttype) [static]

References ANTLR3_INT_STREAM_struct::_LA, ANTLR3_FALSE, ANTLR3_TRUE, ANTLR3_RECOGNIZER_SHARED_STATE_struct::exception, ANTLR3_EXCEPTION_struct::expecting, and ANTLR3_BASE_RECOGNIZER_struct::state.

Referenced by antlr3BaseRecognizerNew(), and mismatch().

static void recover (pANTLR3_BASE_RECOGNIZER recognizer) [static]

Recover from an error found on the input stream. Mostly this is NoViableAlt exceptions, but could be a mismatched token that the match() routine could not recover from.

References ANTLR3_FALSE, ANTLR3_FPRINTF, ANTLR3_TYPE_PARSER, ANTLR3_TYPE_TREE_PARSER, ANTLR3_BASE_RECOGNIZER_struct::beginResync, ANTLR3_BASE_RECOGNIZER_struct::computeErrorRecoverySet, ANTLR3_INT_STREAM_struct::consume, ANTLR3_BASE_RECOGNIZER_struct::consumeUntilSet, ANTLR3_TREE_PARSER_struct::ctnstream, ANTLR3_BASE_RECOGNIZER_struct::endResync, ANTLR3_RECOGNIZER_SHARED_STATE_struct::error, ANTLR3_RECOGNIZER_SHARED_STATE_struct::failed, ANTLR3_BITSET_struct::free, ANTLR3_INT_STREAM_struct::index, ANTLR3_TREE_NODE_STREAM_struct::istream, ANTLR3_TOKEN_STREAM_struct::istream, ANTLR3_RECOGNIZER_SHARED_STATE_struct::lastErrorIndex, 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().

static 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. Return true if recovery was possible else return false.

References ANTLR3_INT_STREAM_struct::_LA, ANTLR3_EOR_TOKEN_TYPE, ANTLR3_FALSE, ANTLR3_FPRINTF, ANTLR3_TRUE, ANTLR3_TYPE_PARSER, ANTLR3_TYPE_TREE_PARSER, antlr3BitsetLoad(), ANTLR3_BASE_RECOGNIZER_struct::computeCSRuleFollow, ANTLR3_TREE_PARSER_struct::ctnstream, ANTLR3_RECOGNIZER_SHARED_STATE_struct::error, ANTLR3_RECOGNIZER_SHARED_STATE_struct::failed, ANTLR3_BITSET_struct::free, ANTLR3_BITSET_struct::isMember, ANTLR3_TREE_NODE_STREAM_struct::istream, ANTLR3_TOKEN_STREAM_struct::istream, ANTLR3_BITSET_struct::remove, ANTLR3_BASE_RECOGNIZER_struct::reportError, 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().

static void * recoverFromMismatchedSet (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_BITSET_LIST follow) [static]

References ANTLR3_FALSE, ANTLR3_FPRINTF, ANTLR3_MISSING_TOKEN_EXCEPTION, ANTLR3_TOKEN_INVALID, ANTLR3_TRUE, ANTLR3_TYPE_PARSER, ANTLR3_TYPE_TREE_PARSER, ANTLR3_TREE_PARSER_struct::ctnstream, ANTLR3_RECOGNIZER_SHARED_STATE_struct::error, ANTLR3_RECOGNIZER_SHARED_STATE_struct::exception, ANTLR3_RECOGNIZER_SHARED_STATE_struct::failed, ANTLR3_BASE_RECOGNIZER_struct::getMissingSymbol, ANTLR3_TREE_NODE_STREAM_struct::istream, ANTLR3_TOKEN_STREAM_struct::istream, ANTLR3_BASE_RECOGNIZER_struct::mismatchIsMissingToken, ANTLR3_BASE_RECOGNIZER_struct::reportError, ANTLR3_BASE_RECOGNIZER_struct::state, ANTLR3_BASE_RECOGNIZER_struct::super, ANTLR3_COMMON_TREE_NODE_STREAM_struct::tnstream, ANTLR3_EXCEPTION_struct::token, ANTLR3_PARSER_struct::tstream, ANTLR3_BASE_RECOGNIZER_struct::type, and ANTLR3_EXCEPTION_struct::type.

Referenced by antlr3BaseRecognizerNew().

static void * recoverFromMismatchedToken (pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_UINT32 ttype, pANTLR3_BITSET_LIST follow) [static]

Attempt to recover from a single missing or extra token. 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.

References ANTLR3_FALSE, ANTLR3_FPRINTF, ANTLR3_MISSING_TOKEN_EXCEPTION, ANTLR3_MISSING_TOKEN_EXCEPTION_NAME, ANTLR3_TRUE, ANTLR3_TYPE_PARSER, ANTLR3_TYPE_TREE_PARSER, ANTLR3_UNWANTED_TOKEN_EXCEPTION, ANTLR3_UNWANTED_TOKEN_EXCEPTION_NAME, antlr3RecognitionExceptionNew(), ANTLR3_BASE_RECOGNIZER_struct::beginResync, ANTLR3_DEBUG_EVENT_LISTENER_struct::beginResync, ANTLR3_INT_STREAM_struct::consume, ANTLR3_TREE_PARSER_struct::ctnstream, ANTLR3_BASE_RECOGNIZER_struct::debugger, ANTLR3_BASE_RECOGNIZER_struct::endResync, ANTLR3_DEBUG_EVENT_LISTENER_struct::endResync, ANTLR3_RECOGNIZER_SHARED_STATE_struct::error, ANTLR3_RECOGNIZER_SHARED_STATE_struct::exception, ANTLR3_EXCEPTION_struct::expecting, ANTLR3_BASE_RECOGNIZER_struct::getCurrentInputSymbol, ANTLR3_BASE_RECOGNIZER_struct::getMissingSymbol, ANTLR3_TREE_NODE_STREAM_struct::istream, ANTLR3_TOKEN_STREAM_struct::istream, ANTLR3_EXCEPTION_struct::message, mismatchIsMissingToken(), ANTLR3_BASE_RECOGNIZER_struct::mismatchIsUnwantedToken, ANTLR3_BASE_RECOGNIZER_struct::reportError, ANTLR3_BASE_RECOGNIZER_struct::state, ANTLR3_BASE_RECOGNIZER_struct::super, ANTLR3_COMMON_TREE_NODE_STREAM_struct::tnstream, ANTLR3_EXCEPTION_struct::token, ANTLR3_PARSER_struct::tstream, ANTLR3_BASE_RECOGNIZER_struct::type, and ANTLR3_EXCEPTION_struct::type.

Referenced by antlr3BaseRecognizerNew().

static 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:

1. error occurs
2. enter recovery mode, report error
3. consume until token found in resynch set
4. try to resume parsing
5. next match() will reset errorRecovery mode

If you override, make sure to update errorCount if you care about that.

References ANTLR3_TRUE, ANTLR3_BASE_RECOGNIZER_struct::debugger, ANTLR3_BASE_RECOGNIZER_struct::displayRecognitionError, ANTLR3_RECOGNIZER_SHARED_STATE_struct::errorCount, ANTLR3_RECOGNIZER_SHARED_STATE_struct::errorRecovery, ANTLR3_RECOGNIZER_SHARED_STATE_struct::exception, ANTLR3_DEBUG_EVENT_LISTENER_struct::recognitionException, ANTLR3_BASE_RECOGNIZER_struct::state, and ANTLR3_RECOGNIZER_SHARED_STATE_struct::tokenNames.

Referenced by antlr3BaseRecognizerNew().

static void reset (pANTLR3_BASE_RECOGNIZER recognizer) [static]

References ANTLR3_FALSE, antlr3IntTrieNew(), antlr3StackNew(), ANTLR3_RECOGNIZER_SHARED_STATE_struct::backtracking, ANTLR3_RECOGNIZER_SHARED_STATE_struct::errorCount, ANTLR3_RECOGNIZER_SHARED_STATE_struct::errorRecovery, ANTLR3_RECOGNIZER_SHARED_STATE_struct::exception, ANTLR3_RECOGNIZER_SHARED_STATE_struct::failed, ANTLR3_RECOGNIZER_SHARED_STATE_struct::following, ANTLR3_STACK_struct::free, ANTLR3_INT_TRIE_struct::free, ANTLR3_EXCEPTION_struct::freeEx, ANTLR3_RECOGNIZER_SHARED_STATE_struct::lastErrorIndex, ANTLR3_RECOGNIZER_SHARED_STATE_struct::ruleMemo, and ANTLR3_BASE_RECOGNIZER_struct::state.

Referenced by antlr3BaseRecognizerNew().

static ANTLR3_BOOLEAN synpred (pANTLR3_BASE_RECOGNIZER recognizer, void * ctx, void(*)(void *ctx) predicate) [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.

References ANTLR3_FALSE, ANTLR3_FPRINTF, ANTLR3_TRUE, ANTLR3_TYPE_PARSER, ANTLR3_TYPE_TREE_PARSER, ANTLR3_RECOGNIZER_SHARED_STATE_struct::backtracking, ANTLR3_TREE_PARSER_struct::ctnstream, ANTLR3_RECOGNIZER_SHARED_STATE_struct::failed, ANTLR3_TREE_NODE_STREAM_struct::istream, ANTLR3_TOKEN_STREAM_struct::istream, ANTLR3_INT_STREAM_struct::mark, ANTLR3_INT_STREAM_struct::rewind, 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().

static pANTLR3_HASH_TABLE toStrings (pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_HASH_TABLE tokens) [static]

Convenience method for template rewrites - NYI.

References ANTLR3_CDECL.

Referenced by antlr3BaseRecognizerNew().

Author

Generated automatically by Doxygen for ANTLR3C from the source code.

Referenced By

antlr3-alreadyParsedRule(3), antlr3BaseRecognizerNew(3), antlr3-combineFollows(3), antlr3-computeCSRuleFollow(3), antlr3-computeErrorRecoverySet(3), antlr3-consumeUntil(3), antlr3-consumeUntilSet(3), antlr3-freeBR(3), antlr3-freeIntTrie(3), antlr3-getNumberOfSyntaxErrors(3), antlr3-getRuleInvocationStack(3), antlr3-getRuleInvocationStackNamed(3), antlr3-getRuleMemoization(3), antlr3-match(3), antlr3-memoize(3), antlr3-mismatchIsMissingToken(3), antlr3-mismatchIsUnwantedToken(3), antlr3MTExceptionNew(3), antlr3RecognitionExceptionNew(3), antlr3-recoverFromMismatchedElement(3), antlr3-recoverFromMismatchedSet(3), antlr3-recoverFromMismatchedToken(3), antlr3-synpred(3) and antlr3-toStrings(3) are aliases of antlr3-pANTLR3_BASE_RECOGNIZER(3).

Tue Oct 4 2016 Version 3.3.1 ANTLR3C