Class: Nydp::Runner
Instance Attribute Summary
Attributes inherited from Evaluator
Instance Method Summary collapse
-
#initialize(vm, ns, stream, printer = nil, name = nil) ⇒ Runner
constructor
A new instance of Runner.
- #print(val) ⇒ Object
- #run ⇒ Object
Methods inherited from Evaluator
#compile_and_eval, #evaluate, #pre_compile
Constructor Details
#initialize(vm, ns, stream, printer = nil, name = nil) ⇒ Runner
Returns a new instance of Runner.
68 69 70 71 72 73 |
# File 'lib/nydp/runner.rb', line 68 def initialize vm, ns, stream, printer=nil, name=nil super vm, ns, name @printer = printer @parser = Nydp.new_parser(ns) @tokens = Nydp.new_tokeniser stream end |
Instance Method Details
#print(val) ⇒ Object
75 76 77 |
# File 'lib/nydp/runner.rb', line 75 def print val @printer.puts val.inspect if @printer end |
#run ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/nydp/runner.rb', line 79 def run Nydp.apply_function ns, :"script-run", :"script-start", name res = Nydp::NIL begin while !@tokens.finished expr = @parser.expression(@tokens) print(res = evaluate(expr)) unless expr.nil? end ensure Nydp.apply_function ns, :"script-run", :"script-end", name end res end |