Method: ANTLR3::Lexer#error_message

Defined in:
lib/antlr3/recognizers.rb

#error_message(e) ⇒ Object



1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
# File 'lib/antlr3/recognizers.rb', line 1141

def error_message( e )
  char = character_error_display( e.symbol ) rescue nil
  case e
  when Error::MismatchedToken
    expecting = character_error_display( e.expecting )
    "mismatched character #{ char }; expecting #{ expecting }"
  when Error::NoViableAlternative
    "no viable alternative at character #{ char }"
  when Error::EarlyExit
    "required ( ... )+ loop did not match anything at character #{ char }"
  when Error::MismatchedNotSet
    "mismatched character %s; expecting set %p" % [ char, e.expecting ]
  when Error::MismatchedSet
    "mismatched character %s; expecting set %p" % [ char, e.expecting ]
  when Error::MismatchedRange
    a = character_error_display( e.min )
    b = character_error_display( e.max )
    "mismatched character %s; expecting set %s..%s" % [ char, a, b ]
  else super
  end
end