Class: NScript::ParseError
- Inherits:
-
Racc::ParseError
- Object
- Racc::ParseError
- NScript::ParseError
- Defined in:
- lib/nscript/parser/parse_error.rb
Constant Summary collapse
- TOKEN_MAP =
{ 'INDENT' => 'indent', 'OUTDENT' => 'outdent', "\n" => 'newline' }
Instance Method Summary collapse
-
#initialize(token_id, value, stack = nil, message = nil) ⇒ ParseError
constructor
A new instance of ParseError.
- #message ⇒ Object (also: #inspect)
Constructor Details
#initialize(token_id, value, stack = nil, message = nil) ⇒ ParseError
Returns a new instance of ParseError.
9 10 11 |
# File 'lib/nscript/parser/parse_error.rb', line 9 def initialize(token_id, value, stack=nil, =nil) @token_id, @value, @stack, = token_id, value, stack, end |
Instance Method Details
#message ⇒ Object Also known as: inspect
13 14 15 16 17 18 19 |
# File 'lib/nscript/parser/parse_error.rb', line 13 def line = @value.respond_to?(:line) ? @value.line : "END" line_part = "line #{line}:" id_part = @token_id != @value.to_s ? " unexpected #{@token_id.to_s.downcase}" : "" val_part = || "for #{TOKEN_MAP[@value.to_s] || "'#{@value}'"}" "#{line_part} syntax error, #{val_part}#{id_part}" end |