Java.target.apidocs.org.antlr.v4.runtime.Recognizer.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of antlr4-perf-testsuite Show documentation
Show all versions of antlr4-perf-testsuite Show documentation
The ANTLR 4 grammar compiler.
Recognizer (ANTLR 4 Runtime (Optimized) 4.7.3 API)
org.antlr.v4.runtime
Class Recognizer<Symbol,ATNInterpreter extends ATNSimulator>
- java.lang.Object
-
- org.antlr.v4.runtime.Recognizer<Symbol,ATNInterpreter>
-
public abstract class Recognizer<Symbol,ATNInterpreter extends ATNSimulator>
extends Object
-
-
Field Summary
Fields
Modifier and Type
Field and Description
protected ATNInterpreter
_interp
static int
EOF
-
Constructor Summary
Constructors
Constructor and Description
Recognizer()
-
Method Summary
Methods
Modifier and Type
Method and Description
void
action(RuleContext _localctx,
int ruleIndex,
int actionIndex)
void
addErrorListener(ANTLRErrorListener<? super Symbol> listener)
ATN
getATN()
Get the ATN
used by the recognizer for prediction.
String
getErrorHeader(RecognitionException e)
What is the error header, normally line/character position information?
ANTLRErrorListener<? super Symbol>
getErrorListenerDispatch()
List<? extends ANTLRErrorListener<? super Symbol>>
getErrorListeners()
abstract String
getGrammarFileName()
For debugging and other purposes, might want the grammar name.
abstract IntStream
getInputStream()
ATNInterpreter
getInterpreter()
Get the ATN interpreter used by the recognizer for prediction.
ParseInfo
getParseInfo()
If profiling during the parse/lex, this will return DecisionInfo records
for each decision in recognizer in a ParseInfo object.
Map<String,Integer>
getRuleIndexMap()
Get a map from rule names to rule indexes.
abstract String[]
getRuleNames()
String
getSerializedATN()
If this recognizer was generated, it will have a serialized ATN
representation of the grammar.
int
getState()
String
getTokenErrorDisplay(Token t)
Deprecated.
This method is not called by the ANTLR 4 Runtime. Specific
implementations of ANTLRErrorStrategy
may provide a similar
feature when necessary. For example, see
DefaultErrorStrategy.getTokenErrorDisplay(org.antlr.v4.runtime.Token)
.
abstract String[]
getTokenNames()
Deprecated.
Use getVocabulary()
instead.
int
getTokenType(String tokenName)
Map<String,Integer>
getTokenTypeMap()
Get a map from token names to token types.
Vocabulary
getVocabulary()
Get the vocabulary used by the recognizer.
boolean
precpred(RuleContext localctx,
int precedence)
void
removeErrorListener(ANTLRErrorListener<? super Symbol> listener)
void
removeErrorListeners()
boolean
sempred(RuleContext _localctx,
int ruleIndex,
int actionIndex)
void
setInterpreter(ATNInterpreter interpreter)
Set the ATN interpreter used by the recognizer for prediction.
void
setState(int atnState)
Indicate that the recognizer has changed internal state that is
consistent with the ATN state passed in.
-
-
Field Detail
-
EOF
public static final int EOF
- See Also:
- Constant Field Values
-
_interp
protected ATNInterpreter extends ATNSimulator _interp
-
Method Detail
-
getTokenNames
@Deprecated
public abstract String[] getTokenNames()
Deprecated. Use getVocabulary()
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
public abstract String[] getRuleNames()
-
getVocabulary
@NotNull
public Vocabulary getVocabulary()
Get the vocabulary used by the recognizer.
- Returns:
- A
Vocabulary
instance providing information about the
vocabulary used by the grammar.
-
getTokenTypeMap
@NotNull
public Map<String,Integer> getTokenTypeMap()
Get a map from token names to token types.
Used for XPath and tree pattern compilation.
-
getRuleIndexMap
@NotNull
public Map<String,Integer> getRuleIndexMap()
Get a map from rule names to rule indexes.
Used for XPath and tree pattern compilation.
-
getTokenType
public int getTokenType(String tokenName)
-
getSerializedATN
@NotNull
public String 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
public abstract String getGrammarFileName()
For debugging and other purposes, might want the grammar name.
Have ANTLR generate an implementation for this method.
-
getATN
@NotNull
public ATN getATN()
Get the ATN
used by the recognizer for prediction.
- Returns:
- The
ATN
used by the recognizer for prediction.
-
getInterpreter
@NotNull
public ATNInterpreter getInterpreter()
Get the ATN interpreter used by the recognizer for prediction.
- Returns:
- The ATN interpreter used by the recognizer for prediction.
-
getParseInfo
public ParseInfo 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
public void setInterpreter(@NotNull
ATNInterpreter interpreter)
Set the ATN interpreter used by the recognizer for prediction.
- Parameters:
interpreter
- The ATN interpreter used by the recognizer for
prediction.
-
getErrorHeader
@NotNull
public String getErrorHeader(@NotNull
RecognitionException e)
What is the error header, normally line/character position information?
-
getTokenErrorDisplay
@Deprecated
public String getTokenErrorDisplay(Token t)
Deprecated. This method is not called by the ANTLR 4 Runtime. Specific
implementations of ANTLRErrorStrategy
may provide a similar
feature when necessary. For example, see
DefaultErrorStrategy.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
public void addErrorListener(@NotNull
ANTLRErrorListener<? super Symbol> listener)
- Throws:
NullPointerException
- if listener
is null
.
-
removeErrorListener
public void removeErrorListener(@NotNull
ANTLRErrorListener<? super Symbol> listener)
-
removeErrorListeners
public void removeErrorListeners()
-
getErrorListeners
@NotNull
public List<? extends ANTLRErrorListener<? super Symbol>> getErrorListeners()
-
getErrorListenerDispatch
public ANTLRErrorListener<? super Symbol> getErrorListenerDispatch()
-
sempred
public boolean sempred(@Nullable
RuleContext _localctx,
int ruleIndex,
int actionIndex)
-
precpred
public boolean precpred(@Nullable
RuleContext localctx,
int precedence)
-
action
public void action(@Nullable
RuleContext _localctx,
int ruleIndex,
int actionIndex)
-
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
public abstract IntStream getInputStream()
Copyright © 1992–2019 Tunnel Vision Laboratories, LLC. All rights reserved.