Exception: ANTLR3::Error::EarlyExit
- Inherits:
-
RecognitionError
- Object
- StandardError
- RecognitionError
- ANTLR3::Error::EarlyExit
- Defined in:
- lib/antlr3/error.rb
Overview
- error
-
EarlyExit
- used by
-
all recognizers
- occurs when
-
The recognizer is in a
(..)+
subrule, meaning the recognizer must match the body of the subrule one or more times. If it fails to match at least one occurence of the subrule, the recognizer will raise an EarlyExit exception.
Example
consider a grammar like:
lexer grammar EarlyExitDemo;
...
ID: 'a'..'z' ('0'..'9')+;
now in ruby
require 'EarlyExitDemo'
input = ANTLR3::StringStream.new( "ab" )
lexer = EarlyExitDemo::Lexer.new( input )
lexer.next_token
# -> raises EarlyExit: line 1:1 required (...)+ loop did not match
# anything at character "b"
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, Constants::INVALID_NODE, Constants::INVALID_TOKEN, Constants::MEMO_RULE_FAILED, Constants::MEMO_RULE_UNKNOWN, Constants::MIN_TOKEN_TYPE, Constants::SKIP_TOKEN, Constants::UP
Instance Attribute Summary collapse
-
#decision_number ⇒ Object
Returns the value of attribute decision_number.
Attributes inherited from RecognitionError
#column, #index, #input, #line, #source_name, #symbol, #token
Instance Method Summary collapse
-
#initialize(decision_number, input) ⇒ EarlyExit
constructor
A new instance of EarlyExit.
- #message ⇒ Object
Methods inherited from RecognitionError
#approximate_line_info?, #location, #unexpected_type
Constructor Details
#initialize(decision_number, input) ⇒ EarlyExit
Returns a new instance of EarlyExit.
449 450 451 452 |
# File 'lib/antlr3/error.rb', line 449 def initialize( decision_number, input ) @decision_number = decision_number super( input ) end |
Instance Attribute Details
#decision_number ⇒ Object
Returns the value of attribute decision_number.
447 448 449 |
# File 'lib/antlr3/error.rb', line 447 def decision_number @decision_number end |
Instance Method Details
#message ⇒ Object
454 455 456 |
# File 'lib/antlr3/error.rb', line 454 def "The recognizer did not match anything for a (..)+ loop." end |