1
2
3
4
5
6
7
8
9
10 package org.utgenome.format.wig;
11
12
13 import org.antlr.runtime.*;
14 import java.util.Stack;
15 import java.util.List;
16 import java.util.ArrayList;
17
18
19 import org.antlr.runtime.tree.*;
20
21 public class WIGParser extends Parser {
22 public static final String[] tokenNames = new String[] {
23 "<invalid>", "<EOR>", "<DOWN>", "<UP>", "Description", "Name", "Value", "Attribute", "Eq", "Dot", "Digit", "HexDigit", "UnicodeChar", "EscapeSequence", "StringChar", "Int", "Frac", "Exp", "WhiteSpace", "StringChars", "String", "Integer", "Double", "Number", "QName"
24 };
25 public static final int Digit=10;
26 public static final int Frac=16;
27 public static final int HexDigit=11;
28 public static final int Eq=8;
29 public static final int Exp=17;
30 public static final int Int=15;
31 public static final int Description=4;
32 public static final int UnicodeChar=12;
33 public static final int StringChar=14;
34 public static final int Name=5;
35 public static final int String=20;
36 public static final int Attribute=7;
37 public static final int Dot=9;
38 public static final int StringChars=19;
39 public static final int EscapeSequence=13;
40 public static final int QName=24;
41 public static final int EOF=-1;
42 public static final int Integer=21;
43 public static final int Value=6;
44 public static final int Double=22;
45 public static final int WhiteSpace=18;
46 public static final int Number=23;
47
48
49
50
51
52 public WIGParser(TokenStream input) {
53 this(input, new RecognizerSharedState());
54 }
55 public WIGParser(TokenStream input, RecognizerSharedState state) {
56 super(input, state);
57
58 }
59
60 protected TreeAdaptor adaptor = new CommonTreeAdaptor();
61
62 public void setTreeAdaptor(TreeAdaptor adaptor) {
63 this.adaptor = adaptor;
64 }
65 public TreeAdaptor getTreeAdaptor() {
66 return adaptor;
67 }
68
69 public String[] getTokenNames() { return WIGParser.tokenNames; }
70 public String getGrammarFileName() { return "WIG.g"; }
71
72
73 public static class description_return extends ParserRuleReturnScope {
74 Object tree;
75 public Object getTree() { return tree; }
76 };
77
78
79
80 public final WIGParser.description_return description() throws RecognitionException {
81 WIGParser.description_return retval = new WIGParser.description_return();
82 retval.start = input.LT(1);
83
84 Object root_0 = null;
85
86 WIGParser.descriptionName_return descriptionName1 = null;
87
88 WIGParser.attribute_return attribute2 = null;
89
90
91 RewriteRuleSubtreeStream stream_attribute=new RewriteRuleSubtreeStream(adaptor,"rule attribute");
92 RewriteRuleSubtreeStream stream_descriptionName=new RewriteRuleSubtreeStream(adaptor,"rule descriptionName");
93 try {
94
95
96 {
97 pushFollow(FOLLOW_descriptionName_in_description424);
98 descriptionName1=descriptionName();
99
100 state._fsp--;
101
102 stream_descriptionName.add(descriptionName1.getTree());
103
104 loop1:
105 do {
106 int alt1=2;
107 int LA1_0 = input.LA(1);
108
109 if ( (LA1_0==QName) ) {
110 alt1=1;
111 }
112
113
114 switch (alt1) {
115 case 1 :
116
117 {
118 pushFollow(FOLLOW_attribute_in_description426);
119 attribute2=attribute();
120
121 state._fsp--;
122
123 stream_attribute.add(attribute2.getTree());
124
125 }
126 break;
127
128 default :
129 break loop1;
130 }
131 } while (true);
132
133
134
135
136
137
138
139
140
141
142 retval.tree = root_0;
143 RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
144
145 root_0 = (Object)adaptor.nil();
146
147 {
148
149 {
150 Object root_1 = (Object)adaptor.nil();
151 root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(Description, "Description"), root_1);
152
153 adaptor.addChild(root_1, stream_descriptionName.nextTree());
154
155 while ( stream_attribute.hasNext() ) {
156 adaptor.addChild(root_1, stream_attribute.nextTree());
157
158 }
159 stream_attribute.reset();
160
161 adaptor.addChild(root_0, root_1);
162 }
163
164 }
165
166 retval.tree = root_0;
167 }
168
169 retval.stop = input.LT(-1);
170
171 retval.tree = (Object)adaptor.rulePostProcessing(root_0);
172 adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
173
174 }
175
176
177 finally {
178 }
179 return retval;
180 }
181
182
183 public static class descriptionName_return extends ParserRuleReturnScope {
184 Object tree;
185 public Object getTree() { return tree; }
186 };
187
188
189
190 public final WIGParser.descriptionName_return descriptionName() throws RecognitionException {
191 WIGParser.descriptionName_return retval = new WIGParser.descriptionName_return();
192 retval.start = input.LT(1);
193
194 Object root_0 = null;
195
196 Token QName3=null;
197
198 Object QName3_tree=null;
199 RewriteRuleTokenStream stream_QName=new RewriteRuleTokenStream(adaptor,"token QName");
200
201 try {
202
203
204 {
205 QName3=(Token)match(input,QName,FOLLOW_QName_in_descriptionName450);
206 stream_QName.add(QName3);
207
208
209
210
211
212
213
214
215
216
217 retval.tree = root_0;
218 RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
219
220 root_0 = (Object)adaptor.nil();
221
222 {
223 adaptor.addChild(root_0, (Object)adaptor.create(Name, (QName3!=null?QName3.getText():null)));
224
225 }
226
227 retval.tree = root_0;
228 }
229
230 retval.stop = input.LT(-1);
231
232 retval.tree = (Object)adaptor.rulePostProcessing(root_0);
233 adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
234
235 }
236
237
238 finally {
239 }
240 return retval;
241 }
242
243
244 public static class attribute_return extends ParserRuleReturnScope {
245 Object tree;
246 public Object getTree() { return tree; }
247 };
248
249
250
251 public final WIGParser.attribute_return attribute() throws RecognitionException {
252 WIGParser.attribute_return retval = new WIGParser.attribute_return();
253 retval.start = input.LT(1);
254
255 Object root_0 = null;
256
257 Token QName4=null;
258 Token Eq5=null;
259 WIGParser.attributeValue_return attributeValue6 = null;
260
261
262 Object QName4_tree=null;
263 Object Eq5_tree=null;
264 RewriteRuleTokenStream stream_QName=new RewriteRuleTokenStream(adaptor,"token QName");
265 RewriteRuleTokenStream stream_Eq=new RewriteRuleTokenStream(adaptor,"token Eq");
266 RewriteRuleSubtreeStream stream_attributeValue=new RewriteRuleSubtreeStream(adaptor,"rule attributeValue");
267 try {
268
269
270 {
271 QName4=(Token)match(input,QName,FOLLOW_QName_in_attribute464);
272 stream_QName.add(QName4);
273
274 Eq5=(Token)match(input,Eq,FOLLOW_Eq_in_attribute466);
275 stream_Eq.add(Eq5);
276
277 pushFollow(FOLLOW_attributeValue_in_attribute468);
278 attributeValue6=attributeValue();
279
280 state._fsp--;
281
282 stream_attributeValue.add(attributeValue6.getTree());
283
284
285
286
287
288
289
290
291
292 retval.tree = root_0;
293 RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
294
295 root_0 = (Object)adaptor.nil();
296
297 {
298
299 {
300 Object root_1 = (Object)adaptor.nil();
301 root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(Attribute, "Attribute"), root_1);
302
303 adaptor.addChild(root_1, (Object)adaptor.create(Name, (QName4!=null?QName4.getText():null)));
304 adaptor.addChild(root_1, stream_attributeValue.nextTree());
305
306 adaptor.addChild(root_0, root_1);
307 }
308
309 }
310
311 retval.tree = root_0;
312 }
313
314 retval.stop = input.LT(-1);
315
316 retval.tree = (Object)adaptor.rulePostProcessing(root_0);
317 adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
318
319 }
320
321
322 finally {
323 }
324 return retval;
325 }
326
327
328 public static class attributeValue_return extends ParserRuleReturnScope {
329 Object tree;
330 public Object getTree() { return tree; }
331 };
332
333
334
335 public final WIGParser.attributeValue_return attributeValue() throws RecognitionException {
336 WIGParser.attributeValue_return retval = new WIGParser.attributeValue_return();
337 retval.start = input.LT(1);
338
339 Object root_0 = null;
340
341 Token QName7=null;
342 Token String8=null;
343 Token Number9=null;
344
345 Object QName7_tree=null;
346 Object String8_tree=null;
347 Object Number9_tree=null;
348 RewriteRuleTokenStream stream_String=new RewriteRuleTokenStream(adaptor,"token String");
349 RewriteRuleTokenStream stream_Number=new RewriteRuleTokenStream(adaptor,"token Number");
350 RewriteRuleTokenStream stream_QName=new RewriteRuleTokenStream(adaptor,"token QName");
351
352 try {
353
354
355 {
356
357 int alt2=3;
358 switch ( input.LA(1) ) {
359 case QName:
360 {
361 alt2=1;
362 }
363 break;
364 case String:
365 {
366 alt2=2;
367 }
368 break;
369 case Number:
370 {
371 alt2=3;
372 }
373 break;
374 default:
375 NoViableAltException nvae =
376 new NoViableAltException("", 2, 0, input);
377
378 throw nvae;
379 }
380
381 switch (alt2) {
382 case 1 :
383
384 {
385 QName7=(Token)match(input,QName,FOLLOW_QName_in_attributeValue487);
386 stream_QName.add(QName7);
387
388
389 }
390 break;
391 case 2 :
392
393 {
394 String8=(Token)match(input,String,FOLLOW_String_in_attributeValue491);
395 stream_String.add(String8);
396
397
398 }
399 break;
400 case 3 :
401
402 {
403 Number9=(Token)match(input,Number,FOLLOW_Number_in_attributeValue495);
404 stream_Number.add(Number9);
405
406
407 }
408 break;
409
410 }
411
412
413
414
415
416
417
418
419
420
421 retval.tree = root_0;
422 RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
423
424 root_0 = (Object)adaptor.nil();
425
426 {
427 adaptor.addChild(root_0, (Object)adaptor.create(Value, input.toString(retval.start,input.LT(-1))));
428
429 }
430
431 retval.tree = root_0;
432 }
433
434 retval.stop = input.LT(-1);
435
436 retval.tree = (Object)adaptor.rulePostProcessing(root_0);
437 adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
438
439 }
440
441
442 finally {
443 }
444 return retval;
445 }
446
447
448
449
450
451
452
453 public static final BitSet FOLLOW_descriptionName_in_description424 = new BitSet(new long[]{0x0000000001000002L});
454 public static final BitSet FOLLOW_attribute_in_description426 = new BitSet(new long[]{0x0000000001000002L});
455 public static final BitSet FOLLOW_QName_in_descriptionName450 = new BitSet(new long[]{0x0000000000000002L});
456 public static final BitSet FOLLOW_QName_in_attribute464 = new BitSet(new long[]{0x0000000000000100L});
457 public static final BitSet FOLLOW_Eq_in_attribute466 = new BitSet(new long[]{0x0000000001900000L});
458 public static final BitSet FOLLOW_attributeValue_in_attribute468 = new BitSet(new long[]{0x0000000000000002L});
459 public static final BitSet FOLLOW_QName_in_attributeValue487 = new BitSet(new long[]{0x0000000000000002L});
460 public static final BitSet FOLLOW_String_in_attributeValue491 = new BitSet(new long[]{0x0000000000000002L});
461 public static final BitSet FOLLOW_Number_in_attributeValue495 = new BitSet(new long[]{0x0000000000000002L});
462
463 }