Class: Atomy::Grammar::AST::List
- 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) ⇒ List
Returns a new instance of List.
97
98
99
|
# File 'lib/atomy/grammar.rb', line 97
def initialize(nodes)
@nodes = nodes
end
|
Instance Attribute Details
Returns the value of attribute nodes.
100
101
102
|
# File 'lib/atomy/grammar.rb', line 100
def nodes
@nodes
end
|
Instance Method Details
#==(other) ⇒ Object
87
88
89
|
# File 'lib/atomy/node/equality.rb', line 87
def ==(other)
super || other.is_a?(self.class) && @nodes == other.nodes
end
|
#construct(gen) ⇒ Object
131
132
133
134
135
136
137
138
|
# File 'lib/atomy/node/constructable.rb', line 131
def construct(gen)
push_node(gen, :List)
@nodes.each do |node|
node.construct(gen)
end
gen.make_array(@nodes.size)
gen.send(:new, 1)
end
|
#each_child {|:nodes, @nodes| ... } ⇒ Object
170
171
172
|
# File 'lib/atomy/node/meta.rb', line 170
def each_child
yield :nodes, @nodes
end
|
174
175
176
|
# File 'lib/atomy/node/meta.rb', line 174
def through
self.class.new(@nodes.collect { |n| yield n })
end
|
86
87
88
|
# File 'lib/atomy/node/pretty.rb', line 86
def to_s
"[#{@nodes.join(", ")}]"
end
|