Module: ANTLR3::Debug::TreeAdaptor
- Defined in:
- lib/antlr3/tree/debug.rb
Overview
Adds debugging event hooks to TreeAdaptor objects
Instance Attribute Summary collapse
-
#debug_listener ⇒ Object
Returns the value of attribute debug_listener.
Class Method Summary collapse
Instance Method Summary collapse
- #add_child(tree, child) ⇒ Object
- #become_root(new_root, old_root) ⇒ Object
- #copy_node(tree_node) ⇒ Object
- #copy_tree(tree) ⇒ Object
- #create_error_node(input, start, stop, exc) ⇒ Object
- #create_flat_list ⇒ Object
- #create_from_token(token_type, from_token, text = nil) ⇒ Object
- #create_from_type(token_type, text) ⇒ Object
- #create_with_payload(payload) ⇒ Object
- #set_token_boundaries(tree, start_token, stop_token) ⇒ Object
- #simulate_tree_construction(tree) ⇒ Object
Instance Attribute Details
#debug_listener ⇒ Object
Returns the value of attribute debug_listener.
19 20 21 |
# File 'lib/antlr3/tree/debug.rb', line 19 def debug_listener @debug_listener end |
Class Method Details
.wrap(adaptor, debug_listener = nil) ⇒ Object
13 14 15 16 17 |
# File 'lib/antlr3/tree/debug.rb', line 13 def self.wrap( adaptor, debug_listener = nil ) adaptor.extend( self ) adaptor.debug_listener = debug_listener return( adaptor ) end |
Instance Method Details
#add_child(tree, child) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/antlr3/tree/debug.rb', line 72 def add_child( tree, child ) case child when Token node = create_with_payload( child ) add_child( tree, node ) else tree.nil? || child.nil? and return super( tree, child ) @debug_listener.add_child( tree, child ) end end |
#become_root(new_root, old_root) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/antlr3/tree/debug.rb', line 84 def become_root( new_root, old_root ) case new_root when Token n = create_with_payload( new_root ) super( n, old_root ) else n = super( new_root, old_root ) end @debug_listener.become_root( new_root, old_root ) return n end |
#copy_node(tree_node) ⇒ Object
60 61 62 63 64 |
# File 'lib/antlr3/tree/debug.rb', line 60 def copy_node( tree_node ) duplicate = super @debug_listener.create_node duplicate return duplicate end |
#copy_tree(tree) ⇒ Object
45 46 47 48 49 |
# File 'lib/antlr3/tree/debug.rb', line 45 def copy_tree( tree ) t = super simulate_tree_construction( t ) return t end |
#create_error_node(input, start, stop, exc) ⇒ Object
39 40 41 42 43 |
# File 'lib/antlr3/tree/debug.rb', line 39 def create_error_node( input, start, stop, exc ) node = super node.nil? or @debug_listener.error_node( node ) return node end |
#create_flat_list ⇒ Object
66 67 68 69 70 |
# File 'lib/antlr3/tree/debug.rb', line 66 def create_flat_list node = super @debug_listener.flat_node( node ) return node end |
#create_from_token(token_type, from_token, text = nil) ⇒ Object
27 28 29 30 31 |
# File 'lib/antlr3/tree/debug.rb', line 27 def create_from_token( token_type, from_token, text = nil ) node = super @debug_listener.create_node( node ) return node end |
#create_from_type(token_type, text) ⇒ Object
33 34 35 36 37 |
# File 'lib/antlr3/tree/debug.rb', line 33 def create_from_type( token_type, text ) node = super @debug_listener.create_node( node ) return node end |
#create_with_payload(payload) ⇒ Object
21 22 23 24 25 |
# File 'lib/antlr3/tree/debug.rb', line 21 def create_with_payload( payload ) node = super @debug_listener.create_node( node, payload ) return node end |
#set_token_boundaries(tree, start_token, stop_token) ⇒ Object
96 97 98 99 100 101 |
# File 'lib/antlr3/tree/debug.rb', line 96 def set_token_boundaries( tree, start_token, stop_token ) super( tree, start_token, stop_token ) return unless tree && start_token && stop_token @debug_listener.set_token_boundaries( tree, start_token.token_index, stop_token.token_index ) end |
#simulate_tree_construction(tree) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/antlr3/tree/debug.rb', line 51 def simulate_tree_construction( tree ) @debug_listener.create_node( tree ) child_count( tree ).times do |i| child = self.child_of( tree, i ) simulate_tree_construction( child ) @debug_listener.add_child( tree, child ) end end |