Class: Trxl::BinaryOperation

Inherits:
Treetop::Runtime::SyntaxNode
  • Object
show all
Defined in:
lib/trxl/trxl.rb

Instance Method Summary collapse

Instance Method Details

#apply(a, b) ⇒ Object



167
168
169
# File 'lib/trxl/trxl.rb', line 167

def apply(a, b)
  operator.apply(a, b)
end

#eval(env = Environment.new) ⇒ Object



163
164
165
# File 'lib/trxl/trxl.rb', line 163

def eval(env = Environment.new)
  apply(operand_1.eval(env), operand_2.eval(env))
end

#to_s(env = Environment.new) ⇒ Object



171
172
173
# File 'lib/trxl/trxl.rb', line 171

def to_s(env = Environment.new)
  "#{operand_1.to_s(env)} #{operator.text_value} #{operand_2.to_s(env)}"
end