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.



613
614
615
616
617
# File 'lib/trxl/trxl.rb', line 613

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

Instance Attribute Details

#envObject

Returns the value of attribute env.



611
612
613
# File 'lib/trxl/trxl.rb', line 611

def env
  @env
end

#parserObject

Returns the value of attribute parser.



611
612
613
# File 'lib/trxl/trxl.rb', line 611

def parser
  @parser
end

#programObject

Returns the value of attribute program.



611
612
613
# File 'lib/trxl/trxl.rb', line 611

def program
  @program
end

Instance Method Details

#eval(env = []) ⇒ Object



623
624
625
# File 'lib/trxl/trxl.rb', line 623

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

#stash(loc) ⇒ Object



619
620
621
# File 'lib/trxl/trxl.rb', line 619

def stash(loc)
  @program << loc
end