Class: Juli::Visitor::Tree
Overview
Another VISITOR-pattern for Absyn tree to print tree structure around each node.
Instance Method Summary
collapse
Methods included from Util
#camelize, conf, find_template, in_filename, juli_repo, mkdir, out_filename, str_limit, str_trim, to_wikiname, underscore, usage, visitor, visitor_list
#initialize, #run_bulk, #visit_node
Instance Method Details
#run_file(in_file, root) ⇒ Object
visit root to generate absyn-tree structure.
39
40
41
42
|
# File 'lib/juli/visitor/tree.rb', line 39
def run_file(in_file, root)
@depth = 0
super
end
|
#visit_array(n) ⇒ Object
57
58
59
60
61
62
63
64
65
|
# File 'lib/juli/visitor/tree.rb', line 57
def visit_array(n)
print_depth
printf("Array\n")
@depth += 1
for child in n.array do
child.accept(self)
end
@depth -= 1
end
|
#visit_chapter(n) ⇒ Object
67
68
69
70
71
72
73
|
# File 'lib/juli/visitor/tree.rb', line 67
def visit_chapter(n)
print_depth
printf("Chapter(%d %s)\n", n.level, n.str)
@depth += 1
n.blocks.accept(self)
@depth -= 1
end
|
#visit_compact_dictionary_list(n) ⇒ Object
83
84
85
|
# File 'lib/juli/visitor/tree.rb', line 83
def visit_compact_dictionary_list(n)
visit_list("CompactDictionaryList\n", n)
end
|
#visit_compact_dictionary_list_item(n) ⇒ Object
87
88
89
|
# File 'lib/juli/visitor/tree.rb', line 87
def visit_compact_dictionary_list_item(n)
visit_x_dictionary_list_item(n, "CompactDictionaryListItem\n")
end
|
#visit_dictionary_list(n) ⇒ Object
91
92
93
|
# File 'lib/juli/visitor/tree.rb', line 91
def visit_dictionary_list(n)
visit_list("DictionaryList\n", n)
end
|
#visit_dictionary_list_item(n) ⇒ Object
95
96
97
|
# File 'lib/juli/visitor/tree.rb', line 95
def visit_dictionary_list_item(n)
visit_x_dictionary_list_item(n, "DictionaryListItem\n")
end
|
#visit_ordered_list(n) ⇒ Object
75
76
77
|
# File 'lib/juli/visitor/tree.rb', line 75
def visit_ordered_list(n)
visit_list("OrderedList\n", n)
end
|
#visit_quote(n) ⇒ Object
99
100
101
102
|
# File 'lib/juli/visitor/tree.rb', line 99
def visit_quote(n)
print_depth
printf("QuoteNode(%s)\n", str_trim(n.str))
end
|
#visit_str(n) ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/juli/visitor/tree.rb', line 44
def visit_str(n)
print_depth
printf("StrNode(%d)\n", -1)
@depth += 1
process_str(n.str)
@depth -= 1
end
|
#visit_unordered_list(n) ⇒ Object
79
80
81
|
# File 'lib/juli/visitor/tree.rb', line 79
def visit_unordered_list(n)
visit_list("UnorderedList\n", n)
end
|
#visit_verbatim(n) ⇒ Object
52
53
54
55
|
# File 'lib/juli/visitor/tree.rb', line 52
def visit_verbatim(n)
print_depth
printf("verbatim: %s\n", str_trim(n.str))
end
|