Java.target.apidocs.org.antlr.v4.runtime.RecognitionException.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.
RecognitionException (ANTLR 4 Runtime (Optimized) 4.13.1.3 API)
org.antlr.v4.runtime
Class RecognitionException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- org.antlr.v4.runtime.RecognitionException
-
- All Implemented Interfaces:
- Serializable
- Direct Known Subclasses:
- FailedPredicateException, InputMismatchException, LexerNoViableAltException, NoViableAltException
public class RecognitionException
extends RuntimeException
The root of the ANTLR exception hierarchy. In general, ANTLR tracks just
3 kinds of errors: prediction errors, failed predicate errors, and
mismatched input errors. In each case, the parser knows where it is
in the input, where it is in the ATN, the rule invocation stack,
and what kind of problem occurred.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors
Constructor and Description
RecognitionException(Lexer lexer,
CharStream input)
RecognitionException(Recognizer<Token,?> recognizer,
IntStream input,
ParserRuleContext ctx)
RecognitionException(String message,
Recognizer<Token,?> recognizer,
IntStream input,
ParserRuleContext ctx)
-
Method Summary
All Methods Instance Methods Concrete Methods
Modifier and Type
Method and Description
RuleContext
getContext()
Gets the RuleContext
at the time this exception was thrown.
IntervalSet
getExpectedTokens()
Gets the set of input symbols which could potentially follow the
previously matched symbol at the time this exception was thrown.
IntStream
getInputStream()
Gets the input stream which is the symbol source for the recognizer where
this exception was thrown.
int
getOffendingState()
Get the ATN state number the parser was in at the time the error
occurred.
Token
getOffendingToken()
<T> T
getOffendingToken(Recognizer<T,?> recognizer)
Recognizer<?,?>
getRecognizer()
Gets the Recognizer
where this exception occurred.
protected void
setOffendingState(int offendingState)
protected <Symbol extends Token>
void
setOffendingToken(Recognizer<Symbol,?> recognizer,
Symbol offendingToken)
-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
Constructor Detail
-
RecognitionException
public RecognitionException(@Nullable
Lexer lexer,
CharStream input)
-
RecognitionException
public RecognitionException(@Nullable
Recognizer<Token,?> recognizer,
@Nullable
IntStream input,
@Nullable
ParserRuleContext ctx)
-
RecognitionException
public RecognitionException(String message,
@Nullable
Recognizer<Token,?> recognizer,
@Nullable
IntStream input,
@Nullable
ParserRuleContext ctx)
-
Method Detail
-
getOffendingState
public int getOffendingState()
Get the ATN state number the parser was in at the time the error
occurred. For NoViableAltException
and
LexerNoViableAltException
exceptions, this is the
DecisionState
number. For others, it is the state whose outgoing
edge we couldn't match.
If the state number is not known, this method returns -1.
-
setOffendingState
protected final void setOffendingState(int offendingState)
-
getExpectedTokens
@Nullable
public IntervalSet getExpectedTokens()
Gets the set of input symbols which could potentially follow the
previously matched symbol at the time this exception was thrown.
If the set of expected tokens is not known and could not be computed,
this method returns null
.
- Returns:
- The set of token types that could potentially follow the current
state in the ATN, or
null
if the information is not available.
-
getContext
@Nullable
public RuleContext getContext()
Gets the RuleContext
at the time this exception was thrown.
If the context is not available, this method returns null
.
- Returns:
- The
RuleContext
at the time this exception was thrown.
If the context is not available, this method returns null
.
-
getInputStream
@Nullable
public IntStream getInputStream()
Gets the input stream which is the symbol source for the recognizer where
this exception was thrown.
If the input stream is not available, this method returns null
.
- Returns:
- The input stream which is the symbol source for the recognizer
where this exception was thrown, or
null
if the stream is not
available.
-
getOffendingToken
@Nullable
public Token getOffendingToken()
-
setOffendingToken
protected final <Symbol extends Token> void setOffendingToken(Recognizer<Symbol,?> recognizer,
@Nullable
Symbol offendingToken)
-
getRecognizer
@Nullable
public Recognizer<?,?> getRecognizer()
Gets the Recognizer
where this exception occurred.
If the recognizer is not available, this method returns null
.
- Returns:
- The recognizer where this exception occurred, or
null
if
the recognizer is not available.
-
getOffendingToken
public <T> T getOffendingToken(Recognizer<T,?> recognizer)
Copyright © 1992–2023 Daniel Sun. All rights reserved.