Exception: RecognitionException
Overview
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.
Direct Known Subclasses
FailedPredicateException, InputMismatchException, LexerNoViableAltException, NoViableAltException
Instance Attribute Summary collapse
-
#ctx ⇒ Object
Returns the value of attribute ctx.
-
#deadEndConfigs ⇒ Object
used by subclassees.
-
#input ⇒ Object
Returns the value of attribute input.
-
#offendingState ⇒ Object
Returns the value of attribute offendingState.
-
#offendingToken ⇒ Object
Returns the value of attribute offendingToken.
-
#recognizer ⇒ Object
Returns the value of attribute recognizer.
-
#startToken ⇒ Object
used by subclassees.
Instance Method Summary collapse
-
#getExpectedTokens ⇒ Object
Gets the set of input symbols which could potentially follow the previously matched symbol at the time this exception was thrown.
-
#initialize(message = nil, recognizer = nil, input = nil, ctx = nil) ⇒ RecognitionException
constructor
A new instance of RecognitionException.
Constructor Details
#initialize(message = nil, recognizer = nil, input = nil, ctx = nil) ⇒ RecognitionException
Returns a new instance of RecognitionException.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/antlr4/error.rb', line 22 def initialize(=nil, recognizer=nil, input=nil, ctx=nil) super() @recognizer = recognizer @input = input @ctx = ctx # The current {@link Token} when an error occurred. Since not all streams # support accessing symbols by index, we have to track the {@link Token} # instance itself. @offendingToken = nil # Get the ATN state number the parser was in at the time the error # occurred. For {@link NoViableAltException} and # {@link LexerNoViableAltException} exceptions, this is the # {@link DecisionState} number. For others, it is the state whose outgoing # edge we couldn't match. @offendingState = -1 if recognizer then @offendingState = recognizer.state end end |
Instance Attribute Details
#ctx ⇒ Object
Returns the value of attribute ctx.
19 20 21 |
# File 'lib/antlr4/error.rb', line 19 def ctx @ctx end |
#deadEndConfigs ⇒ Object
used by subclassees
21 22 23 |
# File 'lib/antlr4/error.rb', line 21 def deadEndConfigs @deadEndConfigs end |
#input ⇒ Object
Returns the value of attribute input.
19 20 21 |
# File 'lib/antlr4/error.rb', line 19 def input @input end |
#offendingState ⇒ Object
Returns the value of attribute offendingState.
19 20 21 |
# File 'lib/antlr4/error.rb', line 19 def offendingState @offendingState end |
#offendingToken ⇒ Object
Returns the value of attribute offendingToken.
19 20 21 |
# File 'lib/antlr4/error.rb', line 19 def offendingToken @offendingToken end |
#recognizer ⇒ Object
Returns the value of attribute recognizer.
19 20 21 |
# File 'lib/antlr4/error.rb', line 19 def recognizer @recognizer end |
#startToken ⇒ Object
used by subclassees
21 22 23 |
# File 'lib/antlr4/error.rb', line 21 def startToken @startToken end |
Instance Method Details
#getExpectedTokens ⇒ Object
Gets the set of input symbols which could potentially follow the previously matched symbol at the time this exception was thrown.
<p>If the set of expected tokens is not known and could not be computed, this method returns null.</p>
state in the ATN, or null if the information is not available. /
54 55 56 57 58 59 60 61 |
# File 'lib/antlr4/error.rb', line 54 def getExpectedTokens() if self.recognizer then @offendingState = recognizer.state return self.recognizer.atn.getExpectedTokens(self.offendingState, self.ctx) else return nil end end |