Class: Atomy::Grammar::AST::Apply

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(node, arguments) ⇒ Apply

Returns a new instance of Apply.



59
60
61
62
# File 'lib/atomy/grammar.rb', line 59

def initialize(node, arguments)
  @node = node
  @arguments = arguments
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



64
65
66
# File 'lib/atomy/grammar.rb', line 64

def arguments
  @arguments
end

#nodeObject (readonly)

Returns the value of attribute node.



63
64
65
# File 'lib/atomy/grammar.rb', line 63

def node
  @node
end

Instance Method Details

#==(other) ⇒ Object



101
102
103
104
105
# File 'lib/atomy/node/equality.rb', line 101

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

#construct(gen) ⇒ Object



151
152
153
154
155
156
157
158
159
# File 'lib/atomy/node/constructable.rb', line 151

def construct(gen)
  push_node(gen, :Apply)
  @node.construct(gen)
  @arguments.each do |node|
    node.construct(gen)
  end
  gen.make_array(@arguments.size)
  gen.send(:new, 2)
end

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

Yields:



191
192
193
194
# File 'lib/atomy/node/meta.rb', line 191

def each_child
  yield :node, @node
  yield :arguments, @arguments
end

#throughObject



196
197
198
# File 'lib/atomy/node/meta.rb', line 196

def through
  self.class.new(yield(@node), @arguments.collect { |a| yield a })
end

#to_sObject



98
99
100
# File 'lib/atomy/node/pretty.rb', line 98

def to_s
  "#@node(#{@arguments.join(", ")})"
end