Class: RD::Visitor
- Inherits:
-
Object
- Object
- RD::Visitor
- Defined in:
- lib/rd/visitor.rb
Direct Known Subclasses
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
- .define_visit_Nonterminal(element_type) ⇒ Object
- .define_visit_Terminal(element_type) ⇒ Object
- .version ⇒ Object
Instance Method Summary collapse
- #visit(tree) ⇒ Object
- #visit_children(element) ⇒ Object
- #visit_DescListItem(element) ⇒ Object
- #visit_MethodListItem(element) ⇒ Object
- #visit_Reference(element) ⇒ Object
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 |
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 |