class ANTLR3::Error::NoViableAlternative

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.

Attributes

decision_number[RW]
grammar_decision_description[RW]
state_number[RW]

Public Class Methods

new( grammar_decision_description, decision_number, state_number, input ) click to toggle source
Calls superclass method ANTLR3::Error::RecognitionError::new
# 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

Public Instance Methods

message() click to toggle source
# File lib/antlr3/error.rb, line 411
def message
  '%s: %p != [%p]' %
    [ self.class, unexpected_type, @grammar_decision_description ]
end