|
|
@ -1,5 +1,11 @@
|
|
|
|
module Lox
|
|
|
|
module Lox
|
|
|
|
|
|
|
|
|
|
|
|
class Error < StandardError
|
|
|
|
class Error < StandardError
|
|
|
|
|
|
|
|
attr_reader :token, :message
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def initialize(token, message)
|
|
|
|
|
|
|
|
@token, @message = token, message
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
class ParseError < Error
|
|
|
|
class ParseError < Error
|
|
|
@ -8,16 +14,12 @@ module Lox
|
|
|
|
|
|
|
|
|
|
|
|
error = "Error"
|
|
|
|
error = "Error"
|
|
|
|
error << " at #{where}" unless where.empty?
|
|
|
|
error << " at #{where}" unless where.empty?
|
|
|
|
super("[line #{token.line}] #{error}: #{message}")
|
|
|
|
|
|
|
|
|
|
|
|
super(token, "[line #{token.line}] #{error}: #{message}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
class RuntimeError < Error
|
|
|
|
RuntimeError = Class.new(Error)
|
|
|
|
attr_reader :token
|
|
|
|
ResolverError = Class.new(Error)
|
|
|
|
|
|
|
|
|
|
|
|
def initialize(token, message)
|
|
|
|
|
|
|
|
@token = token
|
|
|
|
|
|
|
|
super(message)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|