Class: Atomy::Grammar::AST::Constant

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_child, #through

Constructor Details

#initialize(text) ⇒ Constant

Returns a new instance of Constant.



81
82
83
# File 'lib/atomy/grammar.rb', line 81

def initialize(text)
  @text = text
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



84
85
86
# File 'lib/atomy/grammar.rb', line 84

def text
  @text
end

Instance Method Details

#==(other) ⇒ Object



44
45
46
# File 'lib/atomy/node/equality.rb', line 44

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

#construct(gen) ⇒ Object



72
73
74
75
76
# File 'lib/atomy/node/constructable.rb', line 72

def construct(gen)
  push_node(gen, :Constant)
  gen.push_literal(@text)
  gen.send(:new, 1)
end

#each_attribute {|:text, @text| ... } ⇒ Object

Yields:



105
106
107
# File 'lib/atomy/node/meta.rb', line 105

def each_attribute
  yield :text, @text
end

#to_sObject



41
42
43
# File 'lib/atomy/node/pretty.rb', line 41

def to_s
  @text.to_s
end