Class: Rampi::BinaryExpr

Inherits:
Node
  • Object
show all
Defined in:
lib/rampi/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#!=, #%, #&, #*, #**, #+, #-, #-@, #/, #<, #<<, #<=, #==, #>, #>=, #>>, #^, #|, #~

Constructor Details

#initialize(op, left, right) ⇒ BinaryExpr

Returns a new instance of BinaryExpr.



28
29
30
31
32
# File 'lib/rampi/node.rb', line 28

def initialize(op, left, right)
  @op = op
  @left = left
  @right = right
end

Instance Attribute Details

#leftObject

Returns the value of attribute left.



26
27
28
# File 'lib/rampi/node.rb', line 26

def left
  @left
end

#opObject

Returns the value of attribute op.



26
27
28
# File 'lib/rampi/node.rb', line 26

def op
  @op
end

#rightObject

Returns the value of attribute right.



26
27
28
# File 'lib/rampi/node.rb', line 26

def right
  @right
end

Instance Method Details

#accept(visitor) ⇒ Object



39
40
41
# File 'lib/rampi/node.rb', line 39

def accept(visitor)
  visitor.visit_binary_expr(self)
end

#to_sObject Also known as: inspect



34
35
36
# File 'lib/rampi/node.rb', line 34

def to_s
  "(#{@left} #{@op} #{@right})"
end