Class: Antlr4::Runtime::AbstractParseTreeVisitor

Inherits:
Object
  • Object
show all
Defined in:
lib/antlr4/runtime/abstract_parse_tree_visitor.rb

Instance Method Summary collapse

Instance Method Details

#aggregate_result(_aggregate, next_result) ⇒ Object


35
36
37
# File 'lib/antlr4/runtime/abstract_parse_tree_visitor.rb', line 35

def aggregate_result(_aggregate, next_result)
  next_result
end

#default_resultObject


31
32
33
# File 'lib/antlr4/runtime/abstract_parse_tree_visitor.rb', line 31

def default_result
  nil
end

#should_visit_next_child(_node, _current_result) ⇒ Object


39
40
41
# File 'lib/antlr4/runtime/abstract_parse_tree_visitor.rb', line 39

def should_visit_next_child(_node, _current_result)
  true
end

#visit(tree) ⇒ Object


3
4
5
# File 'lib/antlr4/runtime/abstract_parse_tree_visitor.rb', line 3

def visit(tree)
  tree.accept(self)
end

#visit_children(node) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/antlr4/runtime/abstract_parse_tree_visitor.rb', line 7

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

#visit_error_node(_node) ⇒ Object


27
28
29
# File 'lib/antlr4/runtime/abstract_parse_tree_visitor.rb', line 27

def visit_error_node(_node)
  default_result
end

#visit_terminal(_node) ⇒ Object


23
24
25
# File 'lib/antlr4/runtime/abstract_parse_tree_visitor.rb', line 23

def visit_terminal(_node)
  default_result
end