Class: Atomy::Grammar::AST::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/atomy/grammar.rb,
lib/atomy/grammar.rb,
lib/atomy/node/meta.rb,
lib/atomy/node/equality.rb,
lib/atomy/node/constructable.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#lineObject

Returns the value of attribute line.



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

def line
  @line
end

Class Method Details

.basenameObject



4
5
6
# File 'lib/atomy/node/meta.rb', line 4

def basename
  @basename ||= name.split("::").last.to_sym
end

Instance Method Details

#accept(x) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/atomy/node/meta.rb', line 35

def accept(x)
  name = :"visit_#{self.class.basename.downcase}"

  if x.respond_to?(name)
    x.send(name, self)
  else
    x.visit(self)
  end
end

#attributesObject



25
26
27
28
29
30
31
32
33
# File 'lib/atomy/node/meta.rb', line 25

def attributes
  names = []

  each_attribute do |name, _|
    names << name
  end

  names
end

#childrenObject



15
16
17
18
19
20
21
22
23
# File 'lib/atomy/node/meta.rb', line 15

def children
  names = []

  each_child do |name, _|
    names << name
  end

  names
end

#construct(gen) ⇒ Object



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

def construct(gen)
  raise "no #construct for #{self.class}"
end

#each_attributeObject



12
13
# File 'lib/atomy/node/meta.rb', line 12

def each_attribute
end

#each_childObject



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

def each_child
end

#throughObject

Recreate the node, calling the block for sub-nodes and using its return value in place of the node



47
48
49
# File 'lib/atomy/node/meta.rb', line 47

def through
  dup
end