Class: StyleScript::ParseError
- Inherits:
-
Racc::ParseError
- Object
- Racc::ParseError
- StyleScript::ParseError
- Defined in:
- lib/style_script/parse_error.rb
Overview
Racc will raise this Exception whenever a syntax error occurs. The main benefit over the Racc::ParseError is that the StyleScript::ParseError is line-number aware.
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.
14 15 16 |
# File 'lib/style_script/parse_error.rb', line 14 def initialize(token_id, value, stack=nil, =nil) @token_id, @value, @stack, @message = token_id, value, stack, end |
Instance Method Details
#message ⇒ Object Also known as: inspect
18 19 20 21 22 23 24 |
# File 'lib/style_script/parse_error.rb', line 18 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 = @message || "for #{TOKEN_MAP[@value.to_s] || "'#{@value}'"}" "#{line_part} syntax error, #{val_part}#{id_part}" end |