Exception: FailedPredicateException
- Inherits:
-
RecognitionException
- Object
- Exception
- RecognitionException
- FailedPredicateException
- Defined in:
- lib/antlr4/error.rb
Overview
A semantic predicate failed during validation. Validation of predicates
occurs when normally parsing the alternative just like matching a token.
Disambiguating predicate evaluation occurs when we test a predicate during
prediction.
Instance Attribute Summary collapse
-
#predicate ⇒ Object
Returns the value of attribute predicate.
-
#predicateIndex ⇒ Object
Returns the value of attribute predicateIndex.
-
#ruleIndex ⇒ Object
Returns the value of attribute ruleIndex.
Attributes inherited from RecognitionException
#ctx, #deadEndConfigs, #input, #offendingState, #offendingToken, #recognizer, #startToken
Instance Method Summary collapse
- #formatMessage(predicate, message) ⇒ Object
-
#initialize(recognizer, predicate = nil, message = nil) ⇒ FailedPredicateException
constructor
A new instance of FailedPredicateException.
Methods inherited from RecognitionException
Constructor Details
#initialize(recognizer, predicate = nil, message = nil) ⇒ FailedPredicateException
Returns a new instance of FailedPredicateException.
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/antlr4/error.rb', line 125 def initialize(recognizer, predicate=nil, =nil) super(self.formatMessage(predicate,), recognizer, recognizer.getInputStream(), recognizer.ctx) s = recognizer.interp.atn.states[recognizer.state] trans = s.transitions[0] if trans.kind_of? PredicateTransition then @ruleIndex = trans.ruleIndex @predicateIndex = trans.predIndex else @ruleIndex = 0 @predicateIndex = 0 end @predicate = predicate @offendingToken = recognizer.getCurrentToken() end |
Instance Attribute Details
#predicate ⇒ Object
Returns the value of attribute predicate.
124 125 126 |
# File 'lib/antlr4/error.rb', line 124 def predicate @predicate end |
#predicateIndex ⇒ Object
Returns the value of attribute predicateIndex.
124 125 126 |
# File 'lib/antlr4/error.rb', line 124 def predicateIndex @predicateIndex end |
#ruleIndex ⇒ Object
Returns the value of attribute ruleIndex.
124 125 126 |
# File 'lib/antlr4/error.rb', line 124 def ruleIndex @ruleIndex end |
Instance Method Details
#formatMessage(predicate, message) ⇒ Object
141 142 143 144 145 146 147 |
# File 'lib/antlr4/error.rb', line 141 def formatMessage(predicate, ) if .nil? "failed predicate: {" + predicate + "}?" else end end |