1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

added nice syntax errors

This commit is contained in:
Jeremy Ashkenas 2009-12-17 10:04:43 -05:00
parent 1590713576
commit 1eec05d23a
6 changed files with 56 additions and 8 deletions

View file

@ -0,0 +1,19 @@
module CoffeeScript
class ParseError < Racc::ParseError
def initialize(token_id, value, stack)
@token_id, @value, @stack = token_id, value, stack
end
def message(source_file=nil)
line = @value.respond_to?(:line) ? @value.line : "END"
line_part = source_file ? "#{source_file}:#{line}:" : "line #{line}:"
id_part = @token_id != @value.inspect ? ", unexpected #{@token_id.downcase}" : ""
"#{line_part} syntax error for '#{@value.to_s}'#{id_part}"
end
alias_method :inspect, :message
end
end