Class: Nydp::Runner
Instance Attribute Summary
Attributes inherited from Evaluator
Instance Method Summary collapse
-
#initialize(ns, stream, printer = nil, name = nil, manifest = []) ⇒ Runner
constructor
A new instance of Runner.
- #print(val) ⇒ Object
- #run ⇒ Object
Methods inherited from Evaluator
#compile_expr, #eval_compiled, #evaluate, mk_manifest, #mk_ruby_class, #mk_ruby_source
Constructor Details
#initialize(ns, stream, printer = nil, name = nil, manifest = []) ⇒ Runner
Returns a new instance of Runner.
185 186 187 188 189 190 191 |
# File 'lib/nydp/runner.rb', line 185 def initialize ns, stream, printer=nil, name=nil, manifest=[] super ns, name @printer = printer @parser = Nydp.new_parser @tokens = Nydp.new_tokeniser stream @manifest = manifest end |
Instance Method Details
#print(val) ⇒ Object
193 194 195 |
# File 'lib/nydp/runner.rb', line 193 def print val @printer.puts val._nydp_inspect if @printer end |
#run ⇒ Object
197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/nydp/runner.rb', line 197 def run Nydp.apply_function ns, :"script-run", :"script-start", name res = nil begin while !@tokens.finished expr = @parser.expression(@tokens) print(res = evaluate(expr, @manifest)) unless expr.nil? end ensure Nydp.apply_function ns, :"script-run", :"script-end", name end res end |