antlr3 1.6.3 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,39 +2,38 @@ group ASTDbg;
2
2
 
3
3
  @parserBody.additionalMembers() ::= <<
4
4
  def self.return_scope_members
5
- super.push(:tree)
5
+ super.push( :tree )
6
6
  end
7
7
 
8
8
  attr_reader :adaptor
9
- def adaptor=(adaptor)
9
+ def adaptor=( adaptor )
10
10
  @adaptor =
11
- adaptor.is_a?(ANTLR3::Debug::TreeAdaptor) ? adaptor :
12
- ANTLR3::Debug::TreeAdaptor.wrap(adaptor, @debug_listener)
11
+ adaptor.is_a?( ANTLR3::Debug::TreeAdaptor ) ? adaptor :
12
+ ANTLR3::Debug::TreeAdaptor.wrap( adaptor, @debug_listener )
13
13
  <grammar.directDelegates:{g|<g:delegateName()>.adaptor = @adaptor}; separator="\n">
14
14
  end
15
15
 
16
16
  alias tree_adaptor adaptor
17
17
  alias tree_adaptor= adaptor=
18
-
19
18
  >>
20
19
 
21
20
 
22
21
  createListenerAndHandshake() ::= <<
23
- options[:debug_listener] ||= begin
24
- port = options[:port]
25
- log = options[:log]
26
- proxy = ANTLR3::Debug::EventSocketProxy.new(
27
- self, :adaptor => adaptor,
28
- :log => log, :port => port
22
+ options[ :debug_listener ] ||= begin
23
+ port = options[ :port ]
24
+ log = options[ :log ]
25
+ proxy = ANTLR3::Debug::EventSocketProxy.new( self,
26
+ :adaptor => adaptor,
27
+ :log => log,
28
+ :port => port
29
29
  )
30
30
  proxy.handshake
31
31
  proxy
32
32
  end
33
33
  >>
34
- @parserConstructor.init() ::= "self.adaptor = adaptor"
35
34
 
35
+ @parserConstructor.init() ::= "self.adaptor = adaptor"
36
36
 
37
37
  @newDelegate.delegateOptions() ::= ", :adaptor => adaptor"
38
38
 
39
-
40
- @rewriteElement.pregen() ::= "@debug_listener.location(<e.line>, <e.pos>)"
39
+ @rewriteElement.pregen() ::= "@debug_listener.location( <e.line>, <e.pos> )"
@@ -10,14 +10,14 @@ end
10
10
  >>
11
11
 
12
12
  @ruleBody.setErrorReturnValue() ::= <<
13
- return_value.tree = @adaptor.create_error_node!(@input, return_value.start, @input.look(-1), re)<\n>
13
+ return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )<\n>
14
14
  >>
15
15
 
16
16
  tokenRef(token,label,elementIndex,hetero) ::= <<
17
17
  <super.tokenRef(...)>
18
18
  <gatedAction({
19
19
  tree_for_<label> = <createNodeFromToken(...)>
20
- @adaptor.add_child(root_0, tree_for_<label>)
20
+ @adaptor.add_child( root_0, tree_for_<label> )
21
21
  })>
22
22
  >>
23
23
 
@@ -27,36 +27,29 @@ tokenRefRuleRoot(token,label,elementIndex,hetero) ::= <<
27
27
  <super.tokenRef(...)>
28
28
  <gatedAction({
29
29
  tree_for_<label> = <createNodeFromToken(...)>
30
- root_0 = @adaptor.become_root(tree_for_<label>, root_0)
30
+ root_0 = @adaptor.become_root( tree_for_<label>, root_0 )
31
31
  })>
32
32
  >>
33
33
 
34
-
35
-
36
34
  tokenRefBangAndListLabel(token,label,elementIndex,hetero) ::= <<
37
35
  <tokenRefBang(...)>
38
36
  <addToList(elem={<label; format="label">},...)>
39
37
  >>
40
38
 
41
-
42
-
43
39
  tokenRefAndListLabel(token,label,elementIndex,hetero) ::= <<
44
40
  <tokenRef(...)>
45
41
  <addToList(elem={<label; format="label">},...)>
46
42
  >>
43
+
47
44
  tokenRefRuleRootAndListLabel(token,label,hetero,elementIndex) ::= <<
48
45
  <tokenRefRuleRoot(...)>
49
46
  <addToList(elem={<label; format="label">},...)>
50
47
  >>
51
48
 
52
-
53
-
54
49
  matchSet(s,label,hetero,elementIndex,postmatchCode) ::= <<
55
- <super.matchSet(..., postmatchCode={<gatedAction({@adaptor.add_child(root_0, <createNodeFromToken(...)>)})>})>
50
+ <super.matchSet(..., postmatchCode={<gatedAction({@adaptor.add_child( root_0, <createNodeFromToken(...)> )})>})>
56
51
  >>
57
52
 
58
-
59
-
60
53
  matchRuleBlockSet(s,label,hetero,elementIndex,postmatchCode,treeLevel="0") ::= <<
61
54
  <matchSet(...)>
62
55
  >>
@@ -68,7 +61,7 @@ matchSetRuleRoot(s,label,hetero,elementIndex,debug) ::= <<
68
61
  <if(label)>
69
62
  <label; format="label"> = @input.look<\n>
70
63
  <endif>
71
- <super.matchSet(..., postmatchCode={<gatedAction({root_0 = @adaptor.become_root(<createNodeFromToken(...)>, root_0)})>})>
64
+ <super.matchSet(..., postmatchCode={<gatedAction({root_0 = @adaptor.become_root( <createNodeFromToken(...)>, root_0 )})>})>
72
65
  >>
73
66
  matchSetRuleRootAndListLabel(s,label,hetero,elementIndex,debug) ::= <<
74
67
  <matchSetRuleRoot(...)>
@@ -79,7 +72,7 @@ matchSetRuleRootAndListLabel(s,label,hetero,elementIndex,debug) ::= <<
79
72
 
80
73
  ruleRef(rule,label,elementIndex,args,scope) ::= <<
81
74
  <super.ruleRef(...)>
82
- <gatedAction({@adaptor.add_child(root_0, <label; format="label">.tree)})>
75
+ <gatedAction({@adaptor.add_child( root_0, <label; format="label">.tree )})>
83
76
  >>
84
77
 
85
78
 
@@ -90,7 +83,7 @@ ruleRefBang(rule,label,elementIndex,args,scope) ::= "<super.ruleRef(...)>"
90
83
 
91
84
  ruleRefRuleRoot(rule,label,elementIndex,args,scope) ::= <<
92
85
  <super.ruleRef(...)>
93
- <gatedAction({root_0 = @adaptor.become_root(<label; format="label">.tree, root_0)})>
86
+ <gatedAction({root_0 = @adaptor.become_root( <label; format="label">.tree, root_0 )})>
94
87
  >>
95
88
 
96
89
 
@@ -117,36 +110,34 @@ ruleRefRuleRootAndListLabel(rule,label,elementIndex,args,scope) ::= <<
117
110
  wildcard(label,elementIndex) ::= <<
118
111
  <super.wildcard(...)>
119
112
  <gatedAction({
120
- tree_for_<label> = @adaptor.create_with_payload!(<label; format="label">)
121
- @adaptor.add_child(root_0, tree_for_<label>)
113
+ tree_for_<label> = @adaptor.create_with_payload( <label; format="label"> )
114
+ @adaptor.add_child( root_0, tree_for_<label> )
122
115
  })>
123
116
  >>
124
117
 
125
-
126
-
127
118
  wildcardBang(label,elementIndex) ::= "<super.wildcard(...)>"
128
119
 
129
120
  wildcardRuleRoot(label,elementIndex) ::= <<
130
121
  <super.wildcard(...)>
131
122
  <gatedAction({
132
- tree_for_<label> = @adaptor.create_with_payload!(<label; format="label">)
133
- root_0 = @adaptor.become_root(tree_for_<label>, root_0)
123
+ tree_for_<label> = @adaptor.create_with_payload( <label; format="label"> )
124
+ root_0 = @adaptor.become_root( tree_for_<label>, root_0 )
134
125
  })>
135
126
  >>
136
127
 
137
128
  createNodeFromToken(label,hetero) ::= <<
138
129
  <if(hetero)>
139
- <hetero; format="constantPath">.new(<label; format="label">)
130
+ <hetero; format="constantPath">.new( <label; format="label"> )
140
131
  <else>
141
- @adaptor.create_with_payload!(<label; format="label">)
132
+ @adaptor.create_with_payload( <label; format="label"> )
142
133
  <endif>
143
134
  >>
144
135
 
145
136
  ruleCleanUp() ::= <<
146
137
  <super.ruleCleanUp()>
147
138
  <gatedAction({
148
- return_value.tree = @adaptor.rule_post_processing(root_0)
149
- @adaptor.set_token_boundaries(return_value.tree, return_value.start, return_value.stop)
139
+ return_value.tree = @adaptor.rule_post_processing( root_0 )
140
+ @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )
150
141
  })>
151
142
  >>
152
143
 
@@ -9,22 +9,17 @@ end
9
9
  <endif>
10
10
  >>
11
11
 
12
-
13
-
14
12
  ruleDeclarations() ::= <<
15
13
  <super.ruleDeclarations()>
16
- _first_0 = nil
17
- _last = nil<\n>
14
+ _last = _first_0 = nil<\n>
18
15
  >>
19
16
 
20
-
21
-
22
17
  noRewrite(rewriteBlockLevel, treeLevel) ::= <<
23
18
  <gatedAction({
24
19
  <if(rewriteMode)>
25
20
  return_value.tree = _first_0
26
- if @adaptor.parent(return_value.tree) && @adaptor.flat_list?(@adaptor.parent(return_value.tree))
27
- return_value.tree = @adaptor.parent(return_value.tree)
21
+ if @adaptor.parent( return_value.tree ) && @adaptor.flat_list?( @adaptor.parent( return_value.tree ) )
22
+ return_value.tree = @adaptor.parent( return_value.tree )
28
23
  end
29
24
  <endif>
30
25
  })>
@@ -32,43 +27,40 @@ end
32
27
 
33
28
  tree(root, actionsAfterRoot, children, nullableChildList,
34
29
  enclosingTreeLevel, treeLevel) ::= <<
35
- _last = @input.look
36
- _save_last_<treeLevel> = _last
30
+ _save_last_<treeLevel> = _last = @input.look
37
31
  _first_<treeLevel> = nil
38
32
  <if(!rewriteMode)>
39
- root_<treeLevel> = @adaptor.create_flat_list!<\n>
33
+ root_<treeLevel> = @adaptor.create_flat_list<\n>
40
34
  <endif>
41
35
  <root:element()>
42
36
  <if(rewriteMode)>
43
37
  <gatedAction({
44
38
  <if(root.el.rule)>
45
- _first_<enclosingTreeLevel>.nil? and _first_<enclosingTreeLevel> = <root.el.label; format="label">.tree<\n>
39
+ _first_<enclosingTreeLevel> ||= <root.el.label; format="label">.tree<\n>
46
40
  <else>
47
- _first_<enclosingTreeLevel>.nil? and _first_<enclosingTreeLevel> = <root.el.label; format="label"><\n>
41
+ _first_<enclosingTreeLevel> ||= <root.el.label; format="label"><\n>
48
42
  <endif>
49
43
  })>
50
44
  <endif>
51
45
  <actionsAfterRoot:element()>
52
46
  <if(nullableChildList)>
53
47
  if @input.peek == DOWN
54
- match(DOWN, nil)
48
+ match( DOWN, nil )
55
49
  <children:element()>
56
- match(UP, nil)
57
- end
50
+ match( UP, nil )
51
+ end<\n>
58
52
  <else>
59
- match(DOWN, nil)
53
+ match( DOWN, nil )
60
54
  <children:element()>
61
- match(UP, nil)<\n>
55
+ match( UP, nil )<\n>
62
56
  <endif>
63
57
  <if(!rewriteMode)>
64
- @adaptor.add_child(root_<enclosingTreeLevel>, root_<treeLevel>)<\n>
58
+ @adaptor.add_child( root_<enclosingTreeLevel>, root_<treeLevel> )<\n>
65
59
  <endif>
66
60
  _last = _save_last_<treeLevel>
67
61
 
68
62
  >>
69
63
 
70
-
71
-
72
64
  tokenRefBang(token,label,elementIndex) ::= <<
73
65
  _last = @input.look
74
66
  <super.tokenRef(...)>
@@ -80,11 +72,11 @@ _last = @input.look
80
72
  <if(!rewriteMode)>
81
73
  <gatedAction({
82
74
  <if(hetero)>
83
- tree_for_<label> = <hetero; format="constantPath">.new(<label; format="label">)
75
+ tree_for_<label> = <hetero; format="constantPath">.new( <label; format="label"> )
84
76
  <else>
85
- tree_for_<label> = @adaptor.copy_node(<label; format="label">)
77
+ tree_for_<label> = @adaptor.copy_node( <label; format="label"> )
86
78
  <endif><\n>
87
- @adaptor.add_child(root_<treeLevel>, tree_for_<label>)
79
+ @adaptor.add_child( root_<treeLevel>, tree_for_<label> )
88
80
  })>
89
81
  <else> <! rewrite mode !>
90
82
  <gatedAction({
@@ -106,31 +98,27 @@ _last = @input.look
106
98
  <if(!rewriteMode)>
107
99
  <gatedAction({
108
100
  <if(hetero)>
109
- tree_for_<label> = <hetero; format="constantPath">.new(<label; format="label">)
101
+ tree_for_<label> = <hetero; format="constantPath">.new( <label; format="label"> )
110
102
  <else>
111
- tree_for_<label> = @adaptor.copy_node(<label; format="label">)
103
+ tree_for_<label> = @adaptor.copy_node( <label; format="label"> )
112
104
  <endif><\n>
113
- root_<treeLevel> = @adaptor.become_root(tree_for_<label>, root_<treeLevel>)
105
+ root_<treeLevel> = @adaptor.become_root( tree_for_<label>, root_<treeLevel> )
114
106
  })>
115
107
  <endif>
116
108
  >>
117
109
 
118
-
119
-
120
110
  tokenRefRuleRootAndListLabel(token,label,elementIndex,hetero) ::= <<
121
111
  <tokenRefRuleRoot(...)>
122
112
  <addToList(elem={<label; format="label">},...)>
123
113
  >>
124
114
 
125
-
126
-
127
115
  wildcard(token,label,elementIndex,hetero) ::= <<
128
116
  _last = @input.look
129
117
  <super.wildcard(...)>
130
118
  <if(!rewriteMode)>
131
119
  <gatedAction({
132
- tree_for_<label> = @adaptor.copy_tree(<label; format="label">)
133
- @adaptor.add_child(root_<treeLevel>, tree_for_<label>)
120
+ tree_for_<label> = @adaptor.copy_tree( <label; format="label"> )
121
+ @adaptor.add_child( root_<treeLevel>, tree_for_<label> )
134
122
  })>
135
123
  <else> <! rewrite mode !>
136
124
  <gatedAction({
@@ -145,11 +133,11 @@ _last = @input.look
145
133
  <if(!rewriteMode)>
146
134
  <gatedAction({
147
135
  <if(hetero)>
148
- tree_for_<label> = <hetero; format="constantPath">.new(<label; format="label">)
136
+ tree_for_<label> = <hetero; format="constantPath">.new( <label; format="label"> )
149
137
  <else>
150
- tree_for_<label> = @adaptor.copy_node(<label; format="label">)
138
+ tree_for_<label> = @adaptor.copy_node( <label; format="label"> )
151
139
  <endif><\n>
152
- @adaptor.add_child(root_<treeLevel>, tree_for_<label>)
140
+ @adaptor.add_child( root_<treeLevel>, tree_for_<label> )
153
141
  })>
154
142
  <endif>
155
143
  })>
@@ -159,7 +147,7 @@ tree_for_<label> = @adaptor.copy_node(<label; format="label">)
159
147
 
160
148
  matchRuleBlockSet(s,label,hetero,elementIndex,postmatchCode,treeLevel="0") ::= <<
161
149
  <matchSet(...)>
162
- <noRewrite()> <! set return tree !>
150
+ <noRewrite()>
163
151
  >>
164
152
 
165
153
 
@@ -174,79 +162,63 @@ matchSetRuleRoot(s,label,hetero,elementIndex,debug) ::= <<
174
162
  <if(!rewriteMode)>
175
163
  <gatedAction({
176
164
  <if(hetero)>
177
- tree_for_<label> = <hetero; format="constantPath">.new(<label; format="label">)
165
+ tree_for_<label> = <hetero; format="constantPath">.new( <label; format="label"> )
178
166
  <else>
179
- tree_for_<label> = @adaptor.copy_node(<label; format="label">)
167
+ tree_for_<label> = @adaptor.copy_node( <label; format="label"> )
180
168
  <endif><\n>
181
- root_<treeLevel> = @adaptor.become_root(tree_for_<label>, root_<treeLevel>)
169
+ root_<treeLevel> = @adaptor.become_root( tree_for_<label>, root_<treeLevel> )
182
170
  })>
183
171
  <endif>
184
172
  })>
185
173
  >>
186
174
 
187
-
188
-
189
175
  ruleRef(rule,label,elementIndex,args,scope) ::= <<
190
176
  _last = @input.look
191
177
  <super.ruleRef(...)>
192
178
  <gatedAction({
193
179
  <if(!rewriteMode)>
194
- @adaptor.add_child(root_<treeLevel>, <label; format="label">.tree)
195
- <else> <! rewrite mode !>
196
- _first_<treeLevel>.nil? and _first_<treeLevel> = <label; format="label">.tree<\n>
180
+ @adaptor.add_child( root_<treeLevel>, <label; format="label">.tree )
181
+ <else>
182
+ _first_<treeLevel> ||= <label; format="label">.tree<\n>
197
183
  <endif>
198
184
  })>
199
185
  >>
200
186
 
201
-
202
-
203
187
  ruleRefAndListLabel(rule,label,elementIndex,args,scope) ::= <<
204
188
  <ruleRef(...)>
205
189
  <addToList(elem={<label; format="label">.tree},...)>
206
190
  >>
207
191
 
208
-
209
-
210
192
  ruleRefRuleRoot(rule,label,elementIndex,args,scope) ::= <<
211
193
  _last = @input.look
212
194
  <super.ruleRef(...)>
213
195
  <if(!rewriteMode)>
214
196
  <gatedAction({
215
- root_<treeLevel> = @adaptor.become_root(<label; format="label">.tree, root_<treeLevel>)
197
+ root_<treeLevel> = @adaptor.become_root( <label; format="label">.tree, root_<treeLevel> )
216
198
  })>
217
199
  <endif>
218
200
  >>
219
201
 
220
-
221
-
222
202
  ruleRefRuleRootAndListLabel(rule,label,elementIndex,args,scope) ::= <<
223
203
  <ruleRefRuleRoot(...)>
224
204
  <addToList(elem={<label; format="label">.tree},...)>
225
205
  >>
226
206
 
227
-
228
-
229
207
  ruleRefTrack(rule,label,elementIndex,args,scope) ::= <<
230
208
  _last = @input.look
231
209
  <super.ruleRefTrack(...)>
232
210
  >>
233
211
 
234
-
235
-
236
212
  ruleRefTrackAndListLabel(rule,label,elementIndex,args,scope) ::= <<
237
213
  _last = @input.look
238
214
  <super.ruleRefTrackAndListLabel(...)>
239
215
  >>
240
216
 
241
-
242
-
243
217
  ruleRefRuleRootTrack(rule,label,elementIndex,args,scope) ::= <<
244
218
  _last = @input.look
245
219
  <super.ruleRefRootTrack(...)>
246
220
  >>
247
221
 
248
-
249
-
250
222
  ruleRefRuleRootTrackAndListLabel(rule,label,elementIndex,args,scope) ::= <<
251
223
  _last = @input.look
252
224
  <super.ruleRefRuleRootTrackAndListLabel(...)>
@@ -254,7 +226,7 @@ _last = @input.look
254
226
 
255
227
  createRewriteNodeFromElement(token,hetero,scope) ::= <<
256
228
  <if(hetero)>
257
- <hetero; format="constantPath">.new(stream_<token>.next_node)
229
+ <hetero; format="constantPath">.new( stream_<token>.next_node )
258
230
  <else>
259
231
  stream_<token>.next_node
260
232
  <endif>
@@ -264,9 +236,7 @@ ruleCleanUp() ::= <<
264
236
  <super.ruleCleanUp()>
265
237
  <if(!rewriteMode)>
266
238
  <gatedAction({
267
- return_value.tree = @adaptor.rule_post_processing(root_0)
239
+ return_value.tree = @adaptor.rule_post_processing( root_0 )
268
240
  })>
269
241
  <endif>
270
242
  >>
271
-
272
-
@@ -156,17 +156,17 @@ element() ::= <<
156
156
 
157
157
 
158
158
  @dfaState.noViableAltException() ::= <<
159
- @debug_listener.recognition_exception(nvae)
160
- raise(nvae)
159
+ nvae = NoViableAlternative( "<description>", <decisionNumber>, <stateNumber> )
160
+ @debug_listener.recognition_exception( nvae )
161
+ raise( nvae )<\n>
161
162
  >>
162
163
 
163
-
164
164
  @dfaStateSwitch.noViableAltException() ::= <<
165
- @debug_listener.recognition_exception nvae
166
- raise nvae
165
+ nvae = NoViableAlternative( "<description>", <decisionNumber>, <stateNumber> )
166
+ @debug_listener.recognition_exception( nvae )
167
+ raise( nvae )<\n>
167
168
  >>
168
169
 
169
-
170
170
  dfaDecision(decisionNumber,description) ::= <<
171
171
  begin
172
172
  @state.cyclic_decision = true