Class: Trxl::Interpreter
- Inherits:
-
Object
- Object
- Trxl::Interpreter
- Defined in:
- lib/trxl/trxl.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
Returns the value of attribute env.
-
#parser ⇒ Object
Returns the value of attribute parser.
-
#program ⇒ Object
Returns the value of attribute program.
Instance Method Summary collapse
- #eval(env = []) ⇒ Object
-
#initialize ⇒ Interpreter
constructor
A new instance of Interpreter.
- #stash(loc) ⇒ Object
Constructor Details
#initialize ⇒ Interpreter
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
#env ⇒ Object
Returns the value of attribute env.
640 641 642 |
# File 'lib/trxl/trxl.rb', line 640 def env @env end |
#parser ⇒ Object
Returns the value of attribute parser.
640 641 642 |
# File 'lib/trxl/trxl.rb', line 640 def parser @parser end |
#program ⇒ Object
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 |