class Juli::Absyn::Visitor
Abstract VISITOR-pattern around Absyn
tree.
How to add new generator¶ ↑
Document generator, which juli(1) command says, points to 'visitor' internally because it is VISITOR-pattern. After adding new visitor, for example PDF-generator, it can be used by 'juli -g pdf' (let me assume the file name is pdf.rb). Follow the steps below to add new visitor:
-
create LIB/juli/visitor/pdf.rb. Probably, it is easy to copy from another visitor file (e.g. html.rb) as the skelton. Where, LIB is 'lib/' directory in package environment, or one of $LOAD_PATH in installed environment.
-
implement the pdf.rb. It's the most important task, of courseā¦
Public Class Methods
Visitor
object is initialized when juli(1) gen command is executed. In other words, it is NOT initialized for each input text file. Some global initialization can be done here.
Take care that this is executed every juli(1) execution.
# File lib/juli/absyn.rb, line 166 def initialize(opts = {}) @opts = opts.dup end
Public Instance Methods
'run' bulk-mode (when no files are specified at juli(1) command line). Derived class should implement this.
# File lib/juli/absyn.rb, line 172 def run_bulk; end
# File lib/juli/absyn.rb, line 193 def visit_array(n) for node in n.array do node.accept(self) end end
# File lib/juli/absyn.rb, line 198 def visit_chapter(n); end
# File lib/juli/absyn.rb, line 201 def visit_compact_dictionary_list(n); end
# File lib/juli/absyn.rb, line 202 def visit_compact_dictionary_list_item(n); end
# File lib/juli/absyn.rb, line 203 def visit_dictionary_list(n); end
# File lib/juli/absyn.rb, line 204 def visit_dictionary_list_item(n); end
# File lib/juli/absyn.rb, line 199 def visit_ordered_list(n); end
# File lib/juli/absyn.rb, line 191 def visit_str(n); end
# File lib/juli/absyn.rb, line 200 def visit_unordered_list(n); end
# File lib/juli/absyn.rb, line 192 def visit_verbatim(n); end