View Javadoc

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