Class: Ascode::Interpreter::Main
- Inherits:
-
Object
- Object
- Ascode::Interpreter::Main
- Defined in:
- lib/ascode/interpreter/main.rb
Instance Method Summary collapse
- #call(type, name) ⇒ Object
-
#initialize(ast, env = Environment.new) ⇒ Main
constructor
A new instance of Main.
- #run ⇒ Object
Constructor Details
Instance Method Details
#call(type, name) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/ascode/interpreter/main.rb', line 34 def call(type, name) if type == :env @env.send name else @map[type].send name, @env end end |
#run ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ascode/interpreter/main.rb', line 20 def run @env.ast.each do |action| name = action[:action] if name == "push" @env.push(action[:what]) elsif name == "condition" Condition.begin @env, action[:true_block], action[:false_block] else call action[:type], name end end end |