Class: Trxl::Interpreter

Inherits:
Object
  • Object
show all
Defined in:
lib/trxl/trxl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInterpreter

Returns a new instance of Interpreter.



642
643
644
645
646
# File 'lib/trxl/trxl.rb', line 642

def initialize
  @parser = Calculator.new
  @program = []
  @env = env
end

Instance Attribute Details

#envObject

Returns the value of attribute env.



640
641
642
# File 'lib/trxl/trxl.rb', line 640

def env
  @env
end

#parserObject

Returns the value of attribute parser.



640
641
642
# File 'lib/trxl/trxl.rb', line 640

def parser
  @parser
end

#programObject

Returns the value of attribute program.



640
641
642
# File 'lib/trxl/trxl.rb', line 640

def program
  @program
end

Instance Method Details

#eval(env = []) ⇒ Object



652
653
654
# File 'lib/trxl/trxl.rb', line 652

def eval(env = [])
  @parser.eval(@program.join(' '), env)
end

#stash(loc) ⇒ Object



648
649
650
# File 'lib/trxl/trxl.rb', line 648

def stash(loc)
  @program << loc
end