org.antlr.runtime.RecognizerSharedState Class Reference

Collaboration diagram for org.antlr.runtime.RecognizerSharedState:

Collaboration graph
[legend]

List of all members.

Public Attributes

BitSet[] following = new BitSet[BaseRecognizer.INITIAL_FOLLOW_STACK_SIZE]
int _fsp = -1
boolean errorRecovery = false
int lastErrorIndex = -1
boolean failed = false
int syntaxErrors = 0
int backtracking = 0
Map[] ruleMemo
Token token
int tokenStartCharIndex = -1
int tokenStartLine
int tokenStartCharPositionInLine
int channel
int type
String text


Detailed Description

The set of fields needed by an abstract recognizer to recognize input and recover from errors etc... As a separate state object, it can be shared among multiple grammars; e.g., when one grammar imports another.

These fields are publically visible but the actual state pointer per parser is protected.

Definition at line 38 of file RecognizerSharedState.java.


Member Data Documentation

Track the set of token types that can follow any rule invocation. Stack grows upwards. When it hits the max, it grows 2x in size and keeps going.

Definition at line 43 of file RecognizerSharedState.java.

Definition at line 44 of file RecognizerSharedState.java.

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.

Definition at line 50 of file RecognizerSharedState.java.

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 naseum. This is a failsafe mechanism to guarantee that at least one token/tree node is consumed for two errors.

Definition at line 58 of file RecognizerSharedState.java.

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

Definition at line 63 of file RecognizerSharedState.java.

Did the recognizer encounter a syntax error? Track how many.

Definition at line 66 of file RecognizerSharedState.java.

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

Definition at line 71 of file RecognizerSharedState.java.

An array[size num rules] of Map<Integer,Integer> that 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 (which it is by default).

Definition at line 80 of file RecognizerSharedState.java.

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. nextToken will return this object after matching lexer rule(s). If you subclass to allow multiple token emissions, then set this to the last token to be matched or something nonnull so that the auto token emit mechanism will not emit another token.

Definition at line 95 of file RecognizerSharedState.java.

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.

Definition at line 101 of file RecognizerSharedState.java.

The line on which the first character of the token resides

Definition at line 104 of file RecognizerSharedState.java.

The character position of first character within the line

Definition at line 107 of file RecognizerSharedState.java.

The channel number for the current token

Definition at line 110 of file RecognizerSharedState.java.

The token type for the current token

Definition at line 113 of file RecognizerSharedState.java.

You can set the text for the current token to override what is in the input char buffer. Use setText() or can set this instance var.

Definition at line 118 of file RecognizerSharedState.java.


The documentation for this class was generated from the following file:

Generated on Wed Oct 1 14:13:42 2008 for ANTLR API by  doxygen 1.5.5