Class: Atomy::Grammar::AST::Prefix
- 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
Constructor Details
#initialize(node, operator) ⇒ Prefix
Returns a new instance of Prefix.
123
124
125
126
|
# File 'lib/atomy/grammar.rb', line 123
def initialize(node, operator)
@node = node
@operator = operator
end
|
Instance Attribute Details
Returns the value of attribute node.
127
128
129
|
# File 'lib/atomy/grammar.rb', line 127
def node
@node
end
|
Returns the value of attribute operator.
128
129
130
|
# File 'lib/atomy/grammar.rb', line 128
def operator
@operator
end
|
Instance Method Details
#==(other) ⇒ Object
56
57
58
59
60
|
# File 'lib/atomy/node/equality.rb', line 56
def ==(other)
super || other.is_a?(self.class) && \
@operator == other.operator && \
@node == other.node
end
|
#construct(gen) ⇒ Object
88
89
90
91
92
93
|
# File 'lib/atomy/node/constructable.rb', line 88
def construct(gen)
push_node(gen, :Prefix)
@node.construct(gen)
gen.push_literal(@operator)
gen.send(:new, 2)
end
|
#each_attribute {|:operator, @operator| ... } ⇒ Object
117
118
119
|
# File 'lib/atomy/node/meta.rb', line 117
def each_attribute
yield :operator, @operator
end
|
#each_child {|:node, @node| ... } ⇒ Object
121
122
123
|
# File 'lib/atomy/node/meta.rb', line 121
def each_child
yield :node, @node
end
|
125
126
127
|
# File 'lib/atomy/node/meta.rb', line 125
def through
self.class.new(yield(@node), @operator)
end
|
54
55
56
|
# File 'lib/atomy/node/pretty.rb', line 54
def to_s
"#@operator#@node"
end
|