main
Alpha Chen 2 years ago
parent 29d285dc45
commit 23c9bd5174

@ -4,7 +4,14 @@ module Lox
class Interpreter class Interpreter
def initialize(env=Environment.new) def initialize(env=Environment.new)
@env = env @globals = env
@env = @globals
@globals.define("clock", Class.new {
def arity = 0
def call(*) = Time.now.to_f
def to_s = "<native fn>"
})
end end
# The book does printing and error catching here, but # The book does printing and error catching here, but

Loading…
Cancel
Save