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.

24 lines
466 B

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