Class: RD::Visitor

Inherits:
Object
  • Object
show all
Defined in:
lib/rd/visitor.rb

Direct Known Subclasses

OutputFormatVisitor

Constant Summary collapse

SYSTEM_NAME =
"RDtool Framework -- Visitor"
SYSTEM_VERSION =
"$Version: "+RD::VERSION+"$"
VERSION =
Version.new_from_version_string(SYSTEM_NAME, SYSTEM_VERSION)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.define_visit_Nonterminal(element_type) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/rd/visitor.rb', line 25

def Visitor.define_visit_Nonterminal(element_type)
  eval <<-END_OF_EVAL
  def visit_#{element_type.id2name}(element)
	apply_to_#{element_type.id2name}(element, visit_children(element))
  end
  END_OF_EVAL
end

.define_visit_Terminal(element_type) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/rd/visitor.rb', line 33

def Visitor.define_visit_Terminal(element_type)
  eval <<-END_OF_EVAL
  def visit_#{element_type.id2name}(element)
	apply_to_#{element_type.id2name}(element)
  end
  END_OF_EVAL
end

.versionObject



9
10
11
# File 'lib/rd/visitor.rb', line 9

def Visitor.version
  VERSION
end

Instance Method Details

#visit(tree) ⇒ Object



13
14
15
# File 'lib/rd/visitor.rb', line 13

def visit(tree)
  tree.accept(self)
end

#visit_children(element) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/rd/visitor.rb', line 17

def visit_children(element)
  ret = []
  element.each_child do |i|
	ret.push(i.accept(self))
  end
  ret
end

#visit_DescListItem(element) ⇒ Object



55
56
57
58
# File 'lib/rd/visitor.rb', line 55

def visit_DescListItem(element)
  term = element.term.accept(self)
  apply_to_DescListItem(element, term, visit_children(element))
end

#visit_MethodListItem(element) ⇒ Object



62
63
64
65
# File 'lib/rd/visitor.rb', line 62

def visit_MethodListItem(element)
  term = element.term.accept(self)
  apply_to_MethodListItem(element, term, visit_children(element))
end

#visit_Reference(element) ⇒ Object



77
78
79
80
81
82
83
84
# File 'lib/rd/visitor.rb', line 77

def visit_Reference(element)
  children = visit_children(element)
  begin
	element.result_of_apply_method_of(self, children)
  rescue NameError
	apply_to_Reference(element, children)
  end
end