Sha256: e3a43ebb1a474aabe06a08507328ec5abbd669686f31e2f8f41d43a55aa07128

Contents?: true

Size: 781 Bytes

Versions: 14

Compression:

Stored size: 781 Bytes

Contents

module Antlr4::Runtime
  class AbstractParseTreeVisitor
    def visit(tree)
      tree.accept(self)
    end

    def visit_children(node)
      result = default_result
      n = node.child_count
      i = 0
      while i < n
        break unless should_visit_next_child(node, result)

        c = node.child_at(i)
        child_result = c.accept(self)
        result = aggregate_result(result, child_result)
        i += 1
      end

      result
    end

    def visit_terminal(_node)
      default_result
    end

    def visit_error_node(_node)
      default_result
    end

    def default_result
      nil
    end

    def aggregate_result(_aggregate, next_result)
      next_result
    end

    def should_visit_next_child(_node, _current_result)
      true
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
antlr4-runtime-0.2.12 lib/antlr4/runtime/abstract_parse_tree_visitor.rb
antlr4-runtime-0.2.11 lib/antlr4/runtime/abstract_parse_tree_visitor.rb
antlr4-runtime-0.2.10 lib/antlr4/runtime/abstract_parse_tree_visitor.rb
antlr4-runtime-0.2.9 lib/antlr4/runtime/abstract_parse_tree_visitor.rb
antlr4-runtime-0.2.8 lib/antlr4/runtime/abstract_parse_tree_visitor.rb
antlr4-runtime-0.2.7 lib/antlr4/runtime/abstract_parse_tree_visitor.rb
antlr4-runtime-0.2.6 lib/antlr4/runtime/abstract_parse_tree_visitor.rb
antlr4-runtime-0.2.5 lib/antlr4/runtime/abstract_parse_tree_visitor.rb
antlr4-runtime-0.2.4 lib/antlr4/runtime/abstract_parse_tree_visitor.rb
antlr4-runtime-0.2.3 lib/antlr4/runtime/abstract_parse_tree_visitor.rb
antlr4-runtime-0.2.2 lib/antlr4/runtime/abstract_parse_tree_visitor.rb
antlr4-runtime-0.2.1 lib/antlr4/runtime/abstract_parse_tree_visitor.rb
antlr4-runtime-0.2.0 lib/antlr4/runtime/abstract_parse_tree_visitor.rb
antlr4-runtime-0.1.0 lib/antlr4/runtime/abstract_parse_tree_visitor.rb