Class: Eggshell::ExpressionEvaluator::Evaluator
- Inherits:
-
Object
- Object
- Eggshell::ExpressionEvaluator::Evaluator
- Defined in:
- lib/eggshell/expression-evaluator/evaluator.rb
Instance Method Summary collapse
- #evaluate(struct) ⇒ Object
-
#get_var(var, do_ptr = false) ⇒ Object
an attempt will be made to match an exact var name with that, otherwise, it will be decomposed and each part will be looked up successively.
-
#initialize(vtable, ftable) ⇒ Evaluator
constructor
A new instance of Evaluator.
- #set_var(var, val) ⇒ Object
Constructor Details
#initialize(vtable, ftable) ⇒ Evaluator
Returns a new instance of Evaluator.
3 4 5 6 |
# File 'lib/eggshell/expression-evaluator/evaluator.rb', line 3 def initialize(vtable, ftable) @vtable = vtable @ftable = ftable end |
Instance Method Details
#evaluate(struct) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/eggshell/expression-evaluator/evaluator.rb', line 8 def evaluate(struct) ret = nil struct.each do |frag| if frag.is_a?(Array) if frag[0] == :op elsif frag[0] == :op_tern elsif frag[0] == :func buff << frag[1] + '(' buff << reassemble(frag[2], ',') buff << ')' elsif frag[0] == :group elsif frag[0] == :var elsif frag[0] == :index_access end else buff << s buff << (frag.is_a?(String) ? '"' + frag.gsub('"', '\\"') + '"' : frag) s = sep end end end |
#get_var(var, do_ptr = false) ⇒ Object
an attempt will be made to match an exact var name with that, otherwise, it will be decomposed and each part will be looked up successively.
38 39 40 |
# File 'lib/eggshell/expression-evaluator/evaluator.rb', line 38 def get_var(var, do_ptr = false) end |
#set_var(var, val) ⇒ Object
42 43 |
# File 'lib/eggshell/expression-evaluator/evaluator.rb', line 42 def set_var(var, val) end |