Package org.antlr.v4.runtime
Class Recognizer<Symbol,ATNInterpreter extends ATNSimulator>
java.lang.Object
org.antlr.v4.runtime.Recognizer<Symbol,ATNInterpreter>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ATNInterpreter
private List
<ANTLRErrorListener> private int
static final int
private static final Map
<Vocabulary, Map<String, Integer>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
action
(RuleContext _localctx, int ruleIndex, int actionIndex) void
addErrorListener
(ANTLRErrorListener listener) abstract ATN
getATN()
Get theATN
used by the recognizer for prediction.What is the error header, normally line/character position information?List
<? extends ANTLRErrorListener> abstract String
For debugging and other purposes, might want the grammar name.abstract IntStream
Get the ATN interpreter used by the recognizer for prediction.If profiling during the parse/lex, this will return DecisionInfo records for each decision in recognizer in a ParseInfo object.Get a map from rule names to rule indexes.abstract String[]
If this recognizer was generated, it will have a serialized ATN representation of the grammar.final int
getState()
Deprecated.This method is not called by the ANTLR 4 Runtime.abstract TokenFactory
<?> abstract String[]
Deprecated.UsegetVocabulary()
instead.int
getTokenType
(String tokenName) Get a map from token names to token types.Get the vocabulary used by the recognizer.boolean
precpred
(RuleContext localctx, int precedence) void
removeErrorListener
(ANTLRErrorListener listener) void
boolean
sempred
(RuleContext _localctx, int ruleIndex, int actionIndex) abstract void
setInputStream
(IntStream input) void
setInterpreter
(ATNInterpreter interpreter) Set the ATN interpreter used by the recognizer for prediction.final void
setState
(int atnState) Indicate that the recognizer has changed internal state that is consistent with the ATN state passed in.abstract void
setTokenFactory
(TokenFactory<?> input)
-
Field Details
-
EOF
public static final int EOF- See Also:
-
tokenTypeMapCache
-
ruleIndexMapCache
-
_listeners
-
_interp
-
_stateNumber
private int _stateNumber
-
-
Constructor Details
-
Recognizer
public Recognizer()
-
-
Method Details
-
getTokenNames
Deprecated.UsegetVocabulary()
instead.Used to print out token names like ID during debugging and error reporting. The generated parsers implement a method that overrides this to point to their String[] tokenNames. -
getRuleNames
-
getVocabulary
Get the vocabulary used by the recognizer.- Returns:
- A
Vocabulary
instance providing information about the vocabulary used by the grammar.
-
getTokenTypeMap
Get a map from token names to token types.Used for XPath and tree pattern compilation.
-
getRuleIndexMap
Get a map from rule names to rule indexes.Used for XPath and tree pattern compilation.
-
getTokenType
-
getSerializedATN
If this recognizer was generated, it will have a serialized ATN representation of the grammar.For interpreters, we don't know their serialized ATN despite having created the interpreter from it.
-
getGrammarFileName
For debugging and other purposes, might want the grammar name. Have ANTLR generate an implementation for this method. -
getATN
Get theATN
used by the recognizer for prediction.- Returns:
- The
ATN
used by the recognizer for prediction.
-
getInterpreter
Get the ATN interpreter used by the recognizer for prediction.- Returns:
- The ATN interpreter used by the recognizer for prediction.
-
getParseInfo
If profiling during the parse/lex, this will return DecisionInfo records for each decision in recognizer in a ParseInfo object.- Since:
- 4.3
-
setInterpreter
Set the ATN interpreter used by the recognizer for prediction.- Parameters:
interpreter
- The ATN interpreter used by the recognizer for prediction.
-
getErrorHeader
What is the error header, normally line/character position information? -
getTokenErrorDisplay
Deprecated.This method is not called by the ANTLR 4 Runtime. Specific implementations ofANTLRErrorStrategy
may provide a similar feature when necessary. For example, seeDefaultErrorStrategy.getTokenErrorDisplay(org.antlr.v4.runtime.Token)
.How should a token be displayed in an error message? The default is to display just the text, but during development you might want to have a lot of information spit out. Override in that case to use t.toString() (which, for CommonToken, dumps everything about the token). This is better than forcing you to override a method in your token objects because you don't have to go modify your lexer so that it creates a new Java type. -
addErrorListener
- Throws:
NullPointerException
- iflistener
isnull
.
-
removeErrorListener
-
removeErrorListeners
public void removeErrorListeners() -
getErrorListeners
-
getErrorListenerDispatch
-
sempred
-
precpred
-
action
-
getState
public final int getState() -
setState
public final void setState(int atnState) Indicate that the recognizer has changed internal state that is consistent with the ATN state passed in. This way we always know where we are in the ATN as the parser goes along. The rule context objects form a stack that lets us see the stack of invoking rules. Combine this and we have complete ATN configuration information. -
getInputStream
-
setInputStream
-
getTokenFactory
-
setTokenFactory
-