Class: ExpressionEvaluator
- Inherits:
-
Object
show all
- Defined in:
- lib/expression_evaluator_base.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ExpressionEvaluator.
3
4
5
|
# File 'lib/expression_evaluator_base.rb', line 3
def initialize(linq_exp)
@linq_exp = linq_exp
end
|
Instance Method Details
#visit_arg(node) ⇒ Object
26
27
28
|
# File 'lib/expression_evaluator_base.rb', line 26
def visit_arg(node)
node.arg.visit(self)
end
|
#visit_float(node) ⇒ Object
19
20
21
|
# File 'lib/expression_evaluator_base.rb', line 19
def visit_float(node)
node.value
end
|
#visit_integer(node) ⇒ Object
15
16
17
|
# File 'lib/expression_evaluator_base.rb', line 15
def visit_integer(node)
node.value
end
|
#visit_statements(node) ⇒ Object
41
42
43
44
|
# File 'lib/expression_evaluator_base.rb', line 41
def visit_statements(node)
binary_exp = node.elements.first
binary_exp.visit(self)
end
|
#visit_string(node) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/expression_evaluator_base.rb', line 29
def visit_string(node)
output = ""
node.each do |e|
output << e.visit(self)
end
output
end
|
#visit_stringcontent(node) ⇒ Object
37
38
39
|
# File 'lib/expression_evaluator_base.rb', line 37
def visit_stringcontent(node)
node.to_s
end
|
#visit_symbol(node) ⇒ Object
7
8
9
|
# File 'lib/expression_evaluator_base.rb', line 7
def visit_symbol(node)
node.value
end
|
#visit_unary(node) ⇒ Object
22
23
24
25
|
# File 'lib/expression_evaluator_base.rb', line 22
def visit_unary(node)
target = node.operand.visit(self)
target.send("#{node.operator.to_s}@")
end
|
#visit_variable(node) ⇒ Object
11
12
13
|
# File 'lib/expression_evaluator_base.rb', line 11
def visit_variable(node)
@linq_exp.variable_val(node.to_s)
end
|