Exception: ANTLR3::Error::NoViableAlternative
- Inherits:
-
RecognitionError
- Object
- StandardError
- RecognitionError
- ANTLR3::Error::NoViableAlternative
- Defined in:
- lib/antlr3/error.rb
Overview
error |
NoViableAlternative |
used by |
all recognizers |
occurs when |
A recognizer must choose between multiple possible recognition paths based upon the current and future input symbols, but it has determined that the input does not suit any of the possible recognition alternatives. |
In ANTLR terminology, a rule is composed of one or more alternatives, specifications seperated by | characters. An alternative is composed of a series of elements, including subrules -- rule specifications enclosed within parentheses. When recognition code enters a rule method (or a subrule block) that has multiple alternatives, the recognizer must decide which one of the multiple possible paths to follow by checking a number of future input symbols. Thus, NoViableAlternative errors indicate that the current input does not fit any of the possible paths.
In lexers, this error is often raised by the main tokens! rule, which must choose between all possible token rules. If raised by tokens, it means the current input does not appear to be part of any token specification.
Constant Summary
Constant Summary
Constants included from Constants
Constants::BUILT_IN_TOKEN_NAMES, Constants::DEFAULT, Constants::DOWN, Constants::EOF, Constants::EOF_TOKEN, Constants::EOR_TOKEN_TYPE, Constants::HIDDEN, Constants::INVALID_TOKEN, Constants::INVALID_TOKEN_TYPE, Constants::MEMO_RULE_FAILED, Constants::MEMO_RULE_UNKNOWN, Constants::MIN_TOKEN_TYPE, Constants::SKIP_TOKEN, Constants::UP
Instance Attribute Summary (collapse)
-
- (Object) decision_number
Returns the value of attribute decision_number.
-
- (Object) grammar_decision_description
Returns the value of attribute grammar_decision_description.
-
- (Object) state_number
Returns the value of attribute state_number.
Attributes inherited from RecognitionError
#column, #index, #input, #line, #source_name, #symbol, #token
Instance Method Summary (collapse)
-
- (NoViableAlternative) initialize(grammar_decision_description, decision_number, state_number, input)
constructor
A new instance of NoViableAlternative.
- - (Object) message
Methods inherited from RecognitionError
#approximate_line_info?, #location, #unexpected_type
Constructor Details
- (NoViableAlternative) initialize(grammar_decision_description, decision_number, state_number, input)
A new instance of NoViableAlternative
404 405 406 407 408 409 |
# File 'lib/antlr3/error.rb', line 404 def initialize( grammar_decision_description, decision_number, state_number, input ) @grammar_decision_description = grammar_decision_description @decision_number = decision_number @state_number = state_number super( input ) end |
Instance Attribute Details
- (Object) decision_number
Returns the value of attribute decision_number
403 404 405 |
# File 'lib/antlr3/error.rb', line 403 def decision_number @decision_number end |
- (Object) grammar_decision_description
Returns the value of attribute grammar_decision_description
403 404 405 |
# File 'lib/antlr3/error.rb', line 403 def grammar_decision_description @grammar_decision_description end |
- (Object) state_number
Returns the value of attribute state_number
403 404 405 |
# File 'lib/antlr3/error.rb', line 403 def state_number @state_number end |
Instance Method Details
- (Object) message
411 412 413 414 |
# File 'lib/antlr3/error.rb', line 411 def '%s: %p != [%p]' % [ self.class, unexpected_type, @grammar_decision_description ] end |