Class: Atomy::Grammar::AST::Compose

Inherits:
Node show all
Defined in:
lib/atomy/grammar.rb,
lib/atomy/node/meta.rb,
lib/atomy/node/pretty.rb,
lib/atomy/node/equality.rb,
lib/atomy/node/constructable.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from Node

#accept, #attributes, basename, #children, #each_attribute

Constructor Details

#initialize(left, right) ⇒ Compose

Returns a new instance of Compose.



73
74
75
76
# File 'lib/atomy/grammar.rb', line 73

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

Instance Attribute Details

#leftObject (readonly)

Returns the value of attribute left.



77
78
79
# File 'lib/atomy/grammar.rb', line 77

def left
  @left
end

#rightObject (readonly)

Returns the value of attribute right.



78
79
80
# File 'lib/atomy/grammar.rb', line 78

def right
  @right
end

Instance Method Details

#==(other) ⇒ Object



93
94
95
96
97
# File 'lib/atomy/node/equality.rb', line 93

def ==(other)
  super || other.is_a?(self.class) && \
    @left == other.left && \
    @right == other.right
end

#construct(gen) ⇒ Object



142
143
144
145
146
147
# File 'lib/atomy/node/constructable.rb', line 142

def construct(gen)
  push_node(gen, :Compose)
  @left.construct(gen)
  @right.construct(gen)
  gen.send(:new, 2)
end

#each_child {|:left, @left| ... } ⇒ Object

Yields:



180
181
182
183
# File 'lib/atomy/node/meta.rb', line 180

def each_child
  yield :left, @left
  yield :right, @right
end

#throughObject



185
186
187
# File 'lib/atomy/node/meta.rb', line 185

def through
  self.class.new(yield(@left), yield(@right))
end

#to_sObject



92
93
94
# File 'lib/atomy/node/pretty.rb', line 92

def to_s
  "(#@left #@right)"
end