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.
613 614 615 616 617 |
# File 'lib/trxl/trxl.rb', line 613 def initialize @parser = Calculator.new @program = [] @env = env end |
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env.
611 612 613 |
# File 'lib/trxl/trxl.rb', line 611 def env @env end |
#parser ⇒ Object
Returns the value of attribute parser.
611 612 613 |
# File 'lib/trxl/trxl.rb', line 611 def parser @parser end |
#program ⇒ Object
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 |