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
2 years ago
class Error < StandardError
2 years ago
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?
2 years ago
super(token, "[line #{token.line}] #{error}: #{message}")
end
end
2 years ago
RuntimeError = Class.new(Error)
ResolverError = Class.new(Error)
end