main
Alpha Chen 2 years ago
parent 0464eb1750
commit 97371d13be

@ -7,7 +7,12 @@ namespace :test do
desc "Run tests on source changes"
task :watch do
loop do
sh "fd .*.rb | entr -d rake test:isolated"
sh <<~SH
while true
do
fd .*.rb | entr -d rake test:isolated
done
SH
end
end
end

@ -0,0 +1,33 @@
module Lox
class Resolver
def initialize(interpreter)
@interpreter = interpreter
@scopes = []
end
def resolve(values)
values.each do
value.accept(self)
end
end
def visit_block(stmt)
with_scope do
resolve(stmt.stmts)
end
nil
end
private
def with_block
@scopes.push({})
yield
@scopes.pop
end
end
end
Loading…
Cancel
Save