Class: Atomy::Grammar::AST::Sequence

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(nodes) ⇒ Sequence

Returns a new instance of Sequence.



143
144
145
# File 'lib/atomy/grammar.rb', line 143

def initialize(nodes)
  @nodes = nodes
end

Instance Attribute Details

#nodesObject (readonly)

Returns the value of attribute nodes.



146
147
148
# File 'lib/atomy/grammar.rb', line 146

def nodes
  @nodes
end

Instance Method Details

#==(other) ⇒ Object



8
9
10
# File 'lib/atomy/node/equality.rb', line 8

def ==(other)
  super || other.is_a?(self.class) && @nodes == other.nodes
end

#construct(gen) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/atomy/node/constructable.rb', line 21

def construct(gen)
  push_node(gen, :Sequence)
  @nodes.each do |node|
    node.construct(gen)
  end
  gen.make_array(@nodes.size)
  gen.send(:new, 1)
end

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

Yields:



53
54
55
# File 'lib/atomy/node/meta.rb', line 53

def each_child
  yield :nodes, @nodes
end

#throughObject



57
58
59
# File 'lib/atomy/node/meta.rb', line 57

def through
  self.class.new(nodes.collect { |n| yield n })
end

#to_sObject



5
6
7
# File 'lib/atomy/node/pretty.rb', line 5

def to_s
  @nodes.join(", ")
end