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:

  1. 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.

  2. implement the pdf.rb. It's the most important task, of course…

Public Class Methods

new(opts = {}) click to toggle source

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() click to toggle source

'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
run_file(in_file, root) click to toggle source

run for a file and its node-tree. Here is just sample implementation. Derived class can re-implement this.

INPUTS

in_file

input filename

root

Absyn tree root

# File lib/juli/absyn.rb, line 181
def run_file(in_file, root)
  root.accept(self)
end
visit_array(n) click to toggle source
# File lib/juli/absyn.rb, line 193
def visit_array(n)
  for node in n.array do
    node.accept(self)
  end
end
visit_chapter(n) click to toggle source
# File lib/juli/absyn.rb, line 198
def visit_chapter(n); end
visit_compact_dictionary_list(n) click to toggle source
# File lib/juli/absyn.rb, line 201
def visit_compact_dictionary_list(n); end
visit_compact_dictionary_list_item(n) click to toggle source
# File lib/juli/absyn.rb, line 202
def visit_compact_dictionary_list_item(n); end
visit_dictionary_list(n) click to toggle source
# File lib/juli/absyn.rb, line 203
def visit_dictionary_list(n); end
visit_dictionary_list_item(n) click to toggle source
# File lib/juli/absyn.rb, line 204
def visit_dictionary_list_item(n); end
visit_node(n) click to toggle source

Methods for each Absyn node. Derived class should implement these.

INPUTS

n

Absyn node

# File lib/juli/absyn.rb, line 190
def visit_node(n); end
visit_ordered_list(n) click to toggle source
# File lib/juli/absyn.rb, line 199
def visit_ordered_list(n); end
visit_str(n) click to toggle source
# File lib/juli/absyn.rb, line 191
def visit_str(n); end
visit_unordered_list(n) click to toggle source
# File lib/juli/absyn.rb, line 200
def visit_unordered_list(n); end
visit_verbatim(n) click to toggle source
# File lib/juli/absyn.rb, line 192
def visit_verbatim(n); end