ANTLR3_RECOGNIZER_SHARED_STATE_struct (3) - Linux Manuals

NAME

ANTLR3_RECOGNIZER_SHARED_STATE_struct -

All the data elements required to track the current state of any recognizer (lexer, parser, tree parser).

SYNOPSIS


#include <antlr3recognizersharedstate.h>

Data Fields


ANTLR3_INT32 backtracking
If 0, no backtracking is going on.
ANTLR3_UINT32 channel
The channel number for the current token.
void * custom

ANTLR3_BOOLEAN error
If set to ANTLR3_TRUE then the recognizer has an exception condition (this is tested by the generated code for the rules of the grammar).
ANTLR3_UINT32 errorCount
When the recognizer terminates, the error handling functions will have incremented this value if any error occurred (that was displayed).
ANTLR3_BOOLEAN errorRecovery
This is true when we see an error and before having successfully matched a token.
pANTLR3_EXCEPTION exception
Points to the first in a possible chain of exceptions that the recognizer has discovered.
ANTLR3_BOOLEAN failed
In lieu of a return value, this indicates that a rule or token has failed to match.
pANTLR3_STACK following
Track the set of token types that can follow any rule invocation.
ANTLR3_MARKER lastErrorIndex
The index into the input stream where the last error occurred.
pANTLR3_VECTOR rStreams
A stack of token/tree rewrite streams that are available for use by a parser or tree parser that is using rewrites to generate an AST.
pANTLR3_INT_TRIE ruleMemo
ANTLR3_VECTOR of ANTLR3_LIST for rule memoizing.
ANTLR3_UINT32 sizeHint
Track around a hint from the creator of the recognizer as to how big this thing is going to get, as the actress said to the bishop.
pANTLR3_STACK streams
Input stream stack, which allows the C programmer to switch input streams easily and allow the standard nextToken() implementation to deal with it as this is a common requirement.
pANTLR3_STRING text
Text for the current token.
pANTLR3_COMMON_TOKEN token
The goal of all lexer rules/methods is to create a token object.
pANTLR3_UINT8 * tokenNames
Pointer to an array of token names that are generally useful in error reporting.
ANTLR3_MARKER tokenStartCharIndex
What character index in the stream did the current token start at? Needed, for example, to get the text for current token.
ANTLR3_INT32 tokenStartCharPositionInLine
The character position of the first character of the current token within the line specified by tokenStartLine.
ANTLR3_INT32 tokenStartLine
The input line (where it makes sense) on which the first character of the current token resides.
pANTLR3_TOKEN_FACTORY tokFactory
The goal of all lexer rules being to create a token, then a lexer needs to build a token factory to create them.
pANTLR3_TOKEN_SOURCE tokSource
A lexer is a source of tokens, produced by all the generated (or hand crafted if you like) matching rules.
ANTLR3_UINT32 type
The token type for the current token.
ANTLR3_UINT32 user1
User controlled variables that will be installed in a newly created token.
ANTLR3_UINT32 user2

ANTLR3_UINT32 user3

void * userp
User programmable pointer that can be used for instance as a place to store some tracking structure specific to the grammar that would not normally be available to the error handling functions.

Detailed Description

All the data elements required to track the current state of any recognizer (lexer, parser, tree parser).

May be share between multiple recognizers such that grammar inheritance is easily supported.

Field Documentation

ANTLR3_INT32 ANTLR3_RECOGNIZER_SHARED_STATE_struct::backtracking

If 0, no backtracking is going on. Safe to exec actions etc... If >0 then it's the level of backtracking.

Referenced by antlr3BaseRecognizerNew(), match(), matchc(), matchRange(), matchs(), noViableAlt(), reset(), and synpred().

ANTLR3_UINT32 ANTLR3_RECOGNIZER_SHARED_STATE_struct::channel

The channel number for the current token.

Referenced by emit(), nextTokenStr(), and reset().

void* ANTLR3_RECOGNIZER_SHARED_STATE_struct::custom

Referenced by emit().

ANTLR3_BOOLEAN ANTLR3_RECOGNIZER_SHARED_STATE_struct::error

If set to ANTLR3_TRUE then the recognizer has an exception condition (this is tested by the generated code for the rules of the grammar).

Referenced by antlr3dfapredict(), antlr3RecognitionExceptionNew(), nextTokenStr(), recover(), recoverFromMismatchedElement(), recoverFromMismatchedSet(), and recoverFromMismatchedToken().

ANTLR3_UINT32 ANTLR3_RECOGNIZER_SHARED_STATE_struct::errorCount

When the recognizer terminates, the error handling functions will have incremented this value if any error occurred (that was displayed). It can then be used by the grammar programmer without having to use static globals.

Referenced by antlr3BaseRecognizerNew(), getNumberOfSyntaxErrors(), reportError(), and reset().

ANTLR3_BOOLEAN ANTLR3_RECOGNIZER_SHARED_STATE_struct::errorRecovery

This is true when we see an error and before having successfully matched a token. Prevents generation of more than one error message per error.

Referenced by antlr3BaseRecognizerNew(), match(), matchAny(), reportError(), and reset().

pANTLR3_EXCEPTION ANTLR3_RECOGNIZER_SHARED_STATE_struct::exception

Points to the first in a possible chain of exceptions that the recognizer has discovered.

Referenced by antlr3MTExceptionNew(), antlr3MTNExceptionNew(), antlr3RecognitionExceptionNew(), displayRecognitionError(), freeBR(), mismatch(), mismatchIsUnwantedToken(), noViableAlt(), recoverFromMismatchedSet(), and recoverFromMismatchedToken().

ANTLR3_BOOLEAN ANTLR3_RECOGNIZER_SHARED_STATE_struct::failed

In lieu of a return value, this indicates that a rule or token has failed to match. Reset to false upon valid token match.

Referenced by alreadyParsedRule(), antlr3BaseRecognizerNew(), match(), matchAny(), matchc(), matchRange(), matchs(), memoize(), nextTokenStr(), noViableAlt(), recover(), recoverFromMismatchedElement(), recoverFromMismatchedSet(), reset(), and synpred().

pANTLR3_STACK ANTLR3_RECOGNIZER_SHARED_STATE_struct::following

Track the set of token types that can follow any rule invocation. Stack structure, to support: List<BitSet>.

Referenced by antlr3BaseRecognizerNew(), combineFollows(), freeParser(), mismatchIsMissingToken(), and reset().

ANTLR3_MARKER ANTLR3_RECOGNIZER_SHARED_STATE_struct::lastErrorIndex

The index into the input stream where the last error occurred. This is used to prevent infinite loops where an error is found but no token is consumed during recovery...another error is found, ad nauseam. This is a failsafe mechanism to guarantee that at least one token/tree node is consumed for two errors.

Referenced by antlr3BaseRecognizerNew(), recover(), and reset().

pANTLR3_VECTOR ANTLR3_RECOGNIZER_SHARED_STATE_struct::rStreams

A stack of token/tree rewrite streams that are available for use by a parser or tree parser that is using rewrites to generate an AST. This saves each rule in the recongizer from having to allocate and deallocate rewtire streams on entry and exit. As the parser recurses throgh the rules it will reach a steady state of the maximum number of allocated streams, which instead of deallocating them at rule exit, it will place on this stack for reuse. The streams are then all finally freed when this stack is freed.

Referenced by antlr3BaseRecognizerNew(), antlr3RewriteRuleElementStreamNewAE(), freeBR(), freeNodeRS(), and freeRS().

pANTLR3_INT_TRIE ANTLR3_RECOGNIZER_SHARED_STATE_struct::ruleMemo

ANTLR3_VECTOR of ANTLR3_LIST for rule memoizing. Tracks the stop token index for each rule. ruleMemo[ruleIndex] is the memoization table for ruleIndex. For key ruleStartIndex, you get back the stop token for associated rule or MEMO_RULE_FAILED.

This is only used if rule memoization is on.

Referenced by antlr3BaseRecognizerNew(), freeBR(), getRuleMemoization(), memoize(), and reset().

ANTLR3_UINT32 ANTLR3_RECOGNIZER_SHARED_STATE_struct::sizeHint

Track around a hint from the creator of the recognizer as to how big this thing is going to get, as the actress said to the bishop. This allows us to tune hash tables accordingly. This might not be the best place for this in the end but we will see.

Referenced by antlr3BaseRecognizerNew().

pANTLR3_STACK ANTLR3_RECOGNIZER_SHARED_STATE_struct::streams

Input stream stack, which allows the C programmer to switch input streams easily and allow the standard nextToken() implementation to deal with it as this is a common requirement.

Referenced by freeLexer(), nextToken(), popCharStream(), and pushCharStream().

pANTLR3_STRING ANTLR3_RECOGNIZER_SHARED_STATE_struct::text

Text for the current token. This can be overridden by setting this variable directly or by using the SETTEXT() macro (preferred) in your lexer rules.

Referenced by emit(), getText(), nextTokenStr(), reset(), and setCharStream().

pANTLR3_COMMON_TOKEN ANTLR3_RECOGNIZER_SHARED_STATE_struct::token

The goal of all lexer rules/methods is to create a token object. This is an instance variable as multiple rules may collaborate to create a single token. For example, NUM : INT | FLOAT ; In this case, you want the INT or FLOAT rule to set token and not have it reset to a NUM token in rule NUM.

Referenced by emit(), emitNew(), nextTokenStr(), reset(), and setCharStream().

pANTLR3_UINT8* ANTLR3_RECOGNIZER_SHARED_STATE_struct::tokenNames

Pointer to an array of token names that are generally useful in error reporting. The generated parsers install this pointer. The table it points to is statically allocated as 8 bit ascii at parser compile time - grammar token names are thus restricted in character sets, which does not seem to terrible.

Referenced by antlr3BaseRecognizerNew(), getMissingSymbol(), and reportError().

ANTLR3_MARKER ANTLR3_RECOGNIZER_SHARED_STATE_struct::tokenStartCharIndex

What character index in the stream did the current token start at? Needed, for example, to get the text for current token. Set at the start of nextToken.

Referenced by displayRecognitionError(), emit(), getText(), nextTokenStr(), reset(), and setCharStream().

ANTLR3_INT32 ANTLR3_RECOGNIZER_SHARED_STATE_struct::tokenStartCharPositionInLine

The character position of the first character of the current token within the line specified by tokenStartLine.

Referenced by displayRecognitionError(), emit(), nextTokenStr(), and reset().

ANTLR3_INT32 ANTLR3_RECOGNIZER_SHARED_STATE_struct::tokenStartLine

The input line (where it makes sense) on which the first character of the current token resides.

Referenced by displayRecognitionError(), emit(), nextTokenStr(), and reset().

pANTLR3_TOKEN_FACTORY ANTLR3_RECOGNIZER_SHARED_STATE_struct::tokFactory

The goal of all lexer rules being to create a token, then a lexer needs to build a token factory to create them.

Referenced by antlr3BaseRecognizerNew(), antlr3LexerNew(), emit(), freeBR(), freeLexer(), getMissingSymbol(), and setCharStream().

pANTLR3_TOKEN_SOURCE ANTLR3_RECOGNIZER_SHARED_STATE_struct::tokSource

A lexer is a source of tokens, produced by all the generated (or hand crafted if you like) matching rules. As such it needs to provide a token source interface implementation.

Referenced by antlr3BaseRecognizerNew(), antlr3LexerNew(), freeLexer(), and setCharStream().

ANTLR3_UINT32 ANTLR3_RECOGNIZER_SHARED_STATE_struct::type

The token type for the current token.

Referenced by emit(), and reset().

ANTLR3_UINT32 ANTLR3_RECOGNIZER_SHARED_STATE_struct::user1

User controlled variables that will be installed in a newly created token.

Referenced by emit().

ANTLR3_UINT32 ANTLR3_RECOGNIZER_SHARED_STATE_struct::user2

Referenced by emit().

ANTLR3_UINT32 ANTLR3_RECOGNIZER_SHARED_STATE_struct::user3

Referenced by emit().

void* ANTLR3_RECOGNIZER_SHARED_STATE_struct::userp

User programmable pointer that can be used for instance as a place to store some tracking structure specific to the grammar that would not normally be available to the error handling functions.

Author

Generated automatically by Doxygen for ANTLR3C from the source code.