You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
518 B

module Lox
class Error < StandardError
attr_reader :token, :message
def initialize(token, message)
@token, @message = token, message
end
end
class ParseError < Error
def initialize(token, message)
where = token.type == :EOF ? "end" : "'#{token.lexeme}'"
error = "Error"
error << " at #{where}" unless where.empty?
super(token, "[line #{token.line}] #{error}: #{message}")
end
end
RuntimeError = Class.new(Error)
ResolverError = Class.new(Error)
end