Class: Riml::Compiler::BinaryOperatorNodeVisitor

Inherits:
Visitor
  • Object
show all
Defined in:
lib/riml/compiler.rb

Overview

operator, operands

Instance Method Summary collapse

Methods inherited from Visitor

#initialize, #visit

Constructor Details

This class inherits a constructor from Riml::Compiler::Visitor

Instance Method Details

#compile(node) ⇒ Object



434
435
436
437
438
439
440
441
442
443
444
445
446
# File 'lib/riml/compiler.rb', line 434

def compile(node)
  op1, op2 = node.operand1, node.operand2
  [op1, op2].each {|n| n.parent = node}
  op1.accept(visitor_for_node(op1))
  if node.ignorecase_capable_operator?(node.operator)
    operator_suffix = "# "
  else
    operator_suffix = " "
  end
  node.compiled_output << " #{node.operator}#{operator_suffix}"
  op2.accept(visitor_for_node(op2))
  node.compiled_output
end