Class: ANTLR3::Debug::EventHub

Inherits:
Object
  • Object
show all
Includes:
EventListener
Defined in:
lib/antlr3/debug/event-hub.rb

Overview

A special event listener that intercepts debug events and forwards them to other debug event listners. As debug-mode recognizers are able to send event information to only one listener, EventHubs provide a simple solution in situations where multiple event listners are desired.

Constant Summary

Constants included from EventListener

ANTLR3::Debug::EventListener::EVENTS, ANTLR3::Debug::EventListener::PROTOCOL_VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from EventListener

#enter_subrule, #examine_rule_memoization, #exit_subrule, #on

Constructor Details

#initialize(*listeners) ⇒ EventHub

Returns a new instance of EventHub.


18
19
20
21
# File 'lib/antlr3/debug/event-hub.rb', line 18

def initialize( *listeners )
  @listeners = [ listeners ].flatten!
  @listeners.compact!
end

Instance Attribute Details

#listenersObject (readonly)

Returns the value of attribute listeners


16
17
18
# File 'lib/antlr3/debug/event-hub.rb', line 16

def listeners
  @listeners
end

Instance Method Details

#add(*listeners) ⇒ Object


23
24
25
# File 'lib/antlr3/debug/event-hub.rb', line 23

def add( *listeners )
  @listeners.push( *listeners )
end

#add_child(root, child) ⇒ Object


27
28
29
30
31
# File 'lib/antlr3/debug/event-hub.rb', line 27

def add_child( root, child )
  for listener in @listeners
    listener.add_child( root, child )
  end
end

#backtrack(level) ⇒ Object


33
34
35
36
37
# File 'lib/antlr3/debug/event-hub.rb', line 33

def backtrack( level )
  for listener in @listeners
    listener.backtrack( level )
  end
end

#become_root(new_root, old_root) ⇒ Object


39
40
41
42
43
# File 'lib/antlr3/debug/event-hub.rb', line 39

def become_root( new_root, old_root )
  for listener in @listeners
    listener.become_root( new_root, old_root )
  end
end

#begin_backtrack(level) ⇒ Object


45
46
47
48
49
# File 'lib/antlr3/debug/event-hub.rb', line 45

def begin_backtrack( level )
  for listener in @listeners
    listener.begin_backtrack( level )
  end
end

#begin_resyncObject


51
52
53
54
55
# File 'lib/antlr3/debug/event-hub.rb', line 51

def begin_resync()
  for listener in @listeners
    listener.begin_resync()
  end
end

#commenceObject


57
58
59
60
61
# File 'lib/antlr3/debug/event-hub.rb', line 57

def commence()
  for listener in @listeners
    listener.commence()
  end
end

#consume_hidden_token(tree) ⇒ Object


63
64
65
66
67
# File 'lib/antlr3/debug/event-hub.rb', line 63

def consume_hidden_token( tree )
  for listener in @listeners
    listener.consume_hidden_token( tree )
  end
end

#consume_node(tree) ⇒ Object


69
70
71
72
73
# File 'lib/antlr3/debug/event-hub.rb', line 69

def consume_node( tree )
  for listener in @listeners
    listener.consume_node( tree )
  end
end

#consume_token(tree) ⇒ Object


75
76
77
78
79
# File 'lib/antlr3/debug/event-hub.rb', line 75

def consume_token( tree )
  for listener in @listeners
    listener.consume_token( tree )
  end
end

#create_node(node, token) ⇒ Object


81
82
83
84
85
# File 'lib/antlr3/debug/event-hub.rb', line 81

def create_node( node, token )
  for listener in @listeners
    listener.create_node( node, token )
  end
end

#end_backtrack(level, successful) ⇒ Object


87
88
89
90
91
# File 'lib/antlr3/debug/event-hub.rb', line 87

def end_backtrack( level, successful )
  for listener in @listeners
    listener.end_backtrack( level, successful )
  end
end

#end_resyncObject


93
94
95
96
97
# File 'lib/antlr3/debug/event-hub.rb', line 93

def end_resync()
  for listener in @listeners
    listener.end_resync()
  end
end

#enter_alternative(alt) ⇒ Object


99
100
101
102
103
# File 'lib/antlr3/debug/event-hub.rb', line 99

def enter_alternative( alt )
  for listener in @listeners
    listener.enter_alternative( alt )
  end
end

#enter_decision(decision_number) ⇒ Object


105
106
107
108
109
# File 'lib/antlr3/debug/event-hub.rb', line 105

def enter_decision( decision_number )
  for listener in @listeners
    listener.enter_decision( decision_number )
  end
end

#enter_rule(grammar_file_name, rule_name) ⇒ Object


111
112
113
114
115
# File 'lib/antlr3/debug/event-hub.rb', line 111

def enter_rule( grammar_file_name, rule_name )
  for listener in @listeners
    listener.enter_rule( grammar_file_name, rule_name )
  end
end

#enter_sub_rule(decision_number) ⇒ Object


117
118
119
120
121
# File 'lib/antlr3/debug/event-hub.rb', line 117

def enter_sub_rule( decision_number )
  for listener in @listeners
    listener.enter_sub_rule( decision_number )
  end
end

#error_node(tree) ⇒ Object


123
124
125
126
127
# File 'lib/antlr3/debug/event-hub.rb', line 123

def error_node( tree )
  for listener in @listeners
    listener.error_node( tree )
  end
end

#exit_decision(decision_number) ⇒ Object


129
130
131
132
133
# File 'lib/antlr3/debug/event-hub.rb', line 129

def exit_decision( decision_number )
  for listener in @listeners
    listener.exit_decision( decision_number )
  end
end

#exit_rule(grammar_file_name, rule_name) ⇒ Object


135
136
137
138
139
# File 'lib/antlr3/debug/event-hub.rb', line 135

def exit_rule( grammar_file_name, rule_name )
  for listener in @listeners
    listener.exit_rule( grammar_file_name, rule_name )
  end
end

#exit_sub_rule(decision_number) ⇒ Object


141
142
143
144
145
# File 'lib/antlr3/debug/event-hub.rb', line 141

def exit_sub_rule( decision_number )
  for listener in @listeners
    listener.exit_sub_rule( decision_number )
  end
end

#flat_node(tree) ⇒ Object


147
148
149
150
151
# File 'lib/antlr3/debug/event-hub.rb', line 147

def flat_node( tree )
  for listener in @listeners
    listener.flat_node( tree )
  end
end

#location(line, position) ⇒ Object


153
154
155
156
157
# File 'lib/antlr3/debug/event-hub.rb', line 153

def location( line, position )
  for listener in @listeners
    listener.location( line, position )
  end
end

#look(i, tree) ⇒ Object


159
160
161
162
163
# File 'lib/antlr3/debug/event-hub.rb', line 159

def look( i, tree )
  for listener in @listeners
    listener.look( i, tree )
  end
end

#mark(marker) ⇒ Object


165
166
167
168
169
# File 'lib/antlr3/debug/event-hub.rb', line 165

def mark( marker )
  for listener in @listeners
    listener.mark( marker )
  end
end

#recognition_exception(exception) ⇒ Object


171
172
173
174
175
# File 'lib/antlr3/debug/event-hub.rb', line 171

def recognition_exception( exception )
  for listener in @listeners
    listener.recognition_exception( exception )
  end
end

#resyncObject


177
178
179
180
181
# File 'lib/antlr3/debug/event-hub.rb', line 177

def resync()
  for listener in @listeners
    listener.resync()
  end
end

#rewind(marker) ⇒ Object


183
184
185
186
187
# File 'lib/antlr3/debug/event-hub.rb', line 183

def rewind( marker )
  for listener in @listeners
    listener.rewind( marker )
  end
end

#semantic_predicate(result, predicate) ⇒ Object


189
190
191
192
193
# File 'lib/antlr3/debug/event-hub.rb', line 189

def semantic_predicate( result, predicate )
  for listener in @listeners
    listener.semantic_predicate( result, predicate )
  end
end

#set_token_boundaries(tree, token_start_index, token_stop_index) ⇒ Object


195
196
197
198
199
# File 'lib/antlr3/debug/event-hub.rb', line 195

def set_token_boundaries( tree, token_start_index, token_stop_index )
  for listener in @listeners
    listener.set_token_boundaries( tree, token_start_index, token_stop_index )
  end
end

#terminateObject


201
202
203
204
205
# File 'lib/antlr3/debug/event-hub.rb', line 201

def terminate()
  for listener in @listeners
    listener.terminate()
  end
end