708a0c195cafec2ac0c8b853e84038f4af434fe7
[debian/jabref.git] / src / java / net / sf / jabref / bst / Bst.java
1 package net.sf.jabref.bst;
2 // $ANTLR 3.0b4 bst.g 2006-09-17 01:45:41
3
4 import org.antlr.runtime.*;
5 import java.util.Stack;
6 import java.util.List;
7 import java.util.ArrayList;
8
9
10 import org.antlr.runtime.tree.*;
11
12 public class Bst extends Parser {
13     public static final String[] tokenNames = new String[] {
14         "<invalid>", "<EOR>", "<DOWN>", "<UP>", "IDLIST", "STACK", "ENTRY", "COMMANDS", "STRINGS", "INTEGERS", "FUNCTION", "MACRO", "STRING", "READ", "EXECUTE", "ITERATE", "REVERSE", "SORT", "IDENTIFIER", "INTEGER", "QUOTED", "LETTER", "NUMERAL", "WS", "LINE_COMMENT", "'{'", "'}'", "'<'", "'>'", "'='", "'+'", "'-'", "':='", "'*'", "'add.period$'", "'call.type$'", "'change.case$'", "'chr.to.int$'", "'cite$'", "'duplicat$'", "'empty$'", "'format.name$'", "'if$'", "'int.to.chr$'", "'int.to.str$'", "'missing$'", "'newline$'", "'num.names$'", "'pop$'", "'preamble$'", "'purify$'", "'quote$'", "'skip$'", "'stack$'", "'substring$'", "'swap$'", "'text.length$'", "'text.prefix$'", "'top$'", "'type$'", "'warning$'", "'while$'", "'width$'", "'write$'"
15     };
16     public static final int LETTER=21;
17     public static final int ENTRY=6;
18     public static final int INTEGERS=9;
19     public static final int WS=23;
20     public static final int COMMANDS=7;
21     public static final int STRING=12;
22     public static final int EXECUTE=14;
23     public static final int LINE_COMMENT=24;
24     public static final int SORT=17;
25     public static final int STACK=5;
26     public static final int REVERSE=16;
27     public static final int QUOTED=20;
28     public static final int INTEGER=19;
29     public static final int ITERATE=15;
30     public static final int FUNCTION=10;
31     public static final int EOF=-1;
32     public static final int STRINGS=8;
33     public static final int IDENTIFIER=18;
34     public static final int MACRO=11;
35     public static final int IDLIST=4;
36     public static final int NUMERAL=22;
37     public static final int READ=13;
38
39         public Bst(TokenStream input) {
40             super(input);
41         }
42         
43     protected TreeAdaptor adaptor = new CommonTreeAdaptor();
44
45     public void setTreeAdaptor(TreeAdaptor adaptor) {
46         this.adaptor = adaptor;
47     }
48     public TreeAdaptor getTreeAdaptor() {
49         return adaptor;
50     }
51
52     public String[] getTokenNames() { return tokenNames; }
53     public String getGrammarFileName() { return "bst.g"; }
54
55
56     public static class program_return extends ParserRuleReturnScope {
57         Object tree;
58         public Object getTree() { return tree; }
59     };
60
61     // $ANTLR start program
62     // bst.g:14:1: program : ( commands )+ -> ^( COMMANDS ( commands )+ ) ;
63     public program_return program() throws RecognitionException {   
64         program_return retval = new program_return();
65         retval.start = input.LT(1);
66
67         Object root_0 = null;
68
69         commands_return commands1 = null;
70
71         List list_commands=new ArrayList();
72
73         try {
74             // bst.g:14:11: ( ( commands )+ -> ^( COMMANDS ( commands )+ ) )
75             // bst.g:14:11: ( commands )+
76             {
77             // bst.g:14:11: ( commands )+
78             int cnt1=0;
79             loop1:
80             do {
81                 int alt1=2;
82                 int LA1_0 = input.LA(1);
83                 if ( (LA1_0==ENTRY||(LA1_0>=STRINGS && LA1_0<=MACRO)||(LA1_0>=READ && LA1_0<=SORT)) ) {
84                     alt1=1;
85                 }
86
87
88                 switch (alt1) {
89                 case 1 :
90                     // bst.g:14:11: commands
91                     {
92                     pushFollow(FOLLOW_commands_in_program45);
93                     commands1=commands();
94                     _fsp--;
95
96                     list_commands.add(commands1.tree);
97
98                     }
99                     break;
100
101                 default :
102                     if ( cnt1 >= 1 ) break loop1;
103                         EarlyExitException eee =
104                             new EarlyExitException(1, input);
105                         throw eee;
106                 }
107                 cnt1++;
108             } while (true);
109
110
111             // AST REWRITE
112             int i_0 = 0;
113             retval.tree = root_0;
114             root_0 = (Object)adaptor.nil();
115             // 14:21: -> ^( COMMANDS ( commands )+ )
116             {
117                 // bst.g:14:24: ^( COMMANDS ( commands )+ )
118                 {
119                 Object root_1 = (Object)adaptor.nil();
120                 root_1 = (Object)adaptor.becomeRoot(adaptor.create(COMMANDS, "COMMANDS"), root_1);
121
122                 // bst.g:14:35: ( commands )+
123                 {
124                 int n_1 = list_commands == null ? 0 : list_commands.size();
125                  
126
127
128                 if ( n_1==0 ) throw new RuntimeException("Must have more than one element for (...)+ loops");
129                 for (int i_1=0; i_1<n_1; i_1++) {
130                     adaptor.addChild(root_1, list_commands.get(i_1));
131
132                 }
133                 }
134
135                 adaptor.addChild(root_0, root_1);
136                 }
137
138             }
139
140
141
142             }
143
144         }
145         catch (RecognitionException re) {
146             reportError(re);
147             recover(input,re);
148         }
149         finally {
150             retval.stop = input.LT(-1);
151
152                 retval.tree = (Object)adaptor.rulePostProcessing(root_0);
153                 adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
154
155         }
156         return retval;
157     }
158     // $ANTLR end program
159
160     public static class commands_return extends ParserRuleReturnScope {
161         Object tree;
162         public Object getTree() { return tree; }
163     };
164
165     // $ANTLR start commands
166     // bst.g:16:1: commands : ( STRINGS^^ idList | INTEGERS^^ idList | FUNCTION^^ id stack | MACRO^^ id '{'! STRING '}'! | READ^^ | EXECUTE^^ '{'! function '}'! | ITERATE^^ '{'! function '}'! | REVERSE^^ '{'! function '}'! | ENTRY^^ idList0 idList0 idList0 | SORT^^ );
167     public commands_return commands() throws RecognitionException {   
168         commands_return retval = new commands_return();
169         retval.start = input.LT(1);
170
171         Object root_0 = null;
172
173         Token STRINGS2=null;
174         Token INTEGERS4=null;
175         Token FUNCTION6=null;
176         Token MACRO9=null;
177         Token char_literal11=null;
178         Token STRING12=null;
179         Token char_literal13=null;
180         Token READ14=null;
181         Token EXECUTE15=null;
182         Token char_literal16=null;
183         Token char_literal18=null;
184         Token ITERATE19=null;
185         Token char_literal20=null;
186         Token char_literal22=null;
187         Token REVERSE23=null;
188         Token char_literal24=null;
189         Token char_literal26=null;
190         Token ENTRY27=null;
191         Token SORT31=null;
192         idList_return idList3 = null;
193
194         idList_return idList5 = null;
195
196         id_return id7 = null;
197
198         stack_return stack8 = null;
199
200         id_return id10 = null;
201
202         function_return function17 = null;
203
204         function_return function21 = null;
205
206         function_return function25 = null;
207
208         idList0_return idList028 = null;
209
210         idList0_return idList029 = null;
211
212         idList0_return idList030 = null;
213
214
215         Object STRINGS2_tree=null;
216         Object INTEGERS4_tree=null;
217         Object FUNCTION6_tree=null;
218         Object MACRO9_tree=null;
219         Object char_literal11_tree=null;
220         Object STRING12_tree=null;
221         Object char_literal13_tree=null;
222         Object READ14_tree=null;
223         Object EXECUTE15_tree=null;
224         Object char_literal16_tree=null;
225         Object char_literal18_tree=null;
226         Object ITERATE19_tree=null;
227         Object char_literal20_tree=null;
228         Object char_literal22_tree=null;
229         Object REVERSE23_tree=null;
230         Object char_literal24_tree=null;
231         Object char_literal26_tree=null;
232         Object ENTRY27_tree=null;
233         Object SORT31_tree=null;
234
235         try {
236             // bst.g:17:4: ( STRINGS^^ idList | INTEGERS^^ idList | FUNCTION^^ id stack | MACRO^^ id '{'! STRING '}'! | READ^^ | EXECUTE^^ '{'! function '}'! | ITERATE^^ '{'! function '}'! | REVERSE^^ '{'! function '}'! | ENTRY^^ idList0 idList0 idList0 | SORT^^ )
237             int alt2=10;
238             switch ( input.LA(1) ) {
239             case STRINGS:
240                 alt2=1;
241                 break;
242             case INTEGERS:
243                 alt2=2;
244                 break;
245             case FUNCTION:
246                 alt2=3;
247                 break;
248             case MACRO:
249                 alt2=4;
250                 break;
251             case READ:
252                 alt2=5;
253                 break;
254             case EXECUTE:
255                 alt2=6;
256                 break;
257             case ITERATE:
258                 alt2=7;
259                 break;
260             case REVERSE:
261                 alt2=8;
262                 break;
263             case ENTRY:
264                 alt2=9;
265                 break;
266             case SORT:
267                 alt2=10;
268                 break;
269             default:
270                 NoViableAltException nvae =
271                     new NoViableAltException("16:1: commands : ( STRINGS^^ idList | INTEGERS^^ idList | FUNCTION^^ id stack | MACRO^^ id '{'! STRING '}'! | READ^^ | EXECUTE^^ '{'! function '}'! | ITERATE^^ '{'! function '}'! | REVERSE^^ '{'! function '}'! | ENTRY^^ idList0 idList0 idList0 | SORT^^ );", 2, 0, input);
272
273                 throw nvae;
274             }
275
276             switch (alt2) {
277                 case 1 :
278                     // bst.g:17:4: STRINGS^^ idList
279                     {
280                     root_0 = (Object)adaptor.nil();
281
282                     STRINGS2=(Token)input.LT(1);
283                     match(input,STRINGS,FOLLOW_STRINGS_in_commands65); 
284                     STRINGS2_tree = (Object)adaptor.create(STRINGS2);
285                     root_0 = (Object)adaptor.becomeRoot(STRINGS2_tree, root_0);
286
287                     pushFollow(FOLLOW_idList_in_commands68);
288                     idList3=idList();
289                     _fsp--;
290
291                     adaptor.addChild(root_0, idList3.tree);
292
293                     }
294                     break;
295                 case 2 :
296                     // bst.g:18:4: INTEGERS^^ idList
297                     {
298                     root_0 = (Object)adaptor.nil();
299
300                     INTEGERS4=(Token)input.LT(1);
301                     match(input,INTEGERS,FOLLOW_INTEGERS_in_commands73); 
302                     INTEGERS4_tree = (Object)adaptor.create(INTEGERS4);
303                     root_0 = (Object)adaptor.becomeRoot(INTEGERS4_tree, root_0);
304
305                     pushFollow(FOLLOW_idList_in_commands76);
306                     idList5=idList();
307                     _fsp--;
308
309                     adaptor.addChild(root_0, idList5.tree);
310
311                     }
312                     break;
313                 case 3 :
314                     // bst.g:19:4: FUNCTION^^ id stack
315                     {
316                     root_0 = (Object)adaptor.nil();
317
318                     FUNCTION6=(Token)input.LT(1);
319                     match(input,FUNCTION,FOLLOW_FUNCTION_in_commands81); 
320                     FUNCTION6_tree = (Object)adaptor.create(FUNCTION6);
321                     root_0 = (Object)adaptor.becomeRoot(FUNCTION6_tree, root_0);
322
323                     pushFollow(FOLLOW_id_in_commands84);
324                     id7=id();
325                     _fsp--;
326
327                     adaptor.addChild(root_0, id7.tree);
328                     pushFollow(FOLLOW_stack_in_commands86);
329                     stack8=stack();
330                     _fsp--;
331
332                     adaptor.addChild(root_0, stack8.tree);
333
334                     }
335                     break;
336                 case 4 :
337                     // bst.g:20:4: MACRO^^ id '{'! STRING '}'!
338                     {
339                     root_0 = (Object)adaptor.nil();
340
341                     MACRO9=(Token)input.LT(1);
342                     match(input,MACRO,FOLLOW_MACRO_in_commands91); 
343                     MACRO9_tree = (Object)adaptor.create(MACRO9);
344                     root_0 = (Object)adaptor.becomeRoot(MACRO9_tree, root_0);
345
346                     pushFollow(FOLLOW_id_in_commands94);
347                     id10=id();
348                     _fsp--;
349
350                     adaptor.addChild(root_0, id10.tree);
351                     char_literal11=(Token)input.LT(1);
352                     match(input,25,FOLLOW_25_in_commands96); 
353                     STRING12=(Token)input.LT(1);
354                     match(input,STRING,FOLLOW_STRING_in_commands99); 
355                     STRING12_tree = (Object)adaptor.create(STRING12);
356                     adaptor.addChild(root_0, STRING12_tree);
357
358                     char_literal13=(Token)input.LT(1);
359                     match(input,26,FOLLOW_26_in_commands101); 
360
361                     }
362                     break;
363                 case 5 :
364                     // bst.g:21:4: READ^^
365                     {
366                     root_0 = (Object)adaptor.nil();
367
368                     READ14=(Token)input.LT(1);
369                     match(input,READ,FOLLOW_READ_in_commands107); 
370                     READ14_tree = (Object)adaptor.create(READ14);
371                     root_0 = (Object)adaptor.becomeRoot(READ14_tree, root_0);
372
373
374                     }
375                     break;
376                 case 6 :
377                     // bst.g:22:4: EXECUTE^^ '{'! function '}'!
378                     {
379                     root_0 = (Object)adaptor.nil();
380
381                     EXECUTE15=(Token)input.LT(1);
382                     match(input,EXECUTE,FOLLOW_EXECUTE_in_commands113); 
383                     EXECUTE15_tree = (Object)adaptor.create(EXECUTE15);
384                     root_0 = (Object)adaptor.becomeRoot(EXECUTE15_tree, root_0);
385
386                     char_literal16=(Token)input.LT(1);
387                     match(input,25,FOLLOW_25_in_commands116); 
388                     pushFollow(FOLLOW_function_in_commands119);
389                     function17=function();
390                     _fsp--;
391
392                     adaptor.addChild(root_0, function17.tree);
393                     char_literal18=(Token)input.LT(1);
394                     match(input,26,FOLLOW_26_in_commands121); 
395
396                     }
397                     break;
398                 case 7 :
399                     // bst.g:23:4: ITERATE^^ '{'! function '}'!
400                     {
401                     root_0 = (Object)adaptor.nil();
402
403                     ITERATE19=(Token)input.LT(1);
404                     match(input,ITERATE,FOLLOW_ITERATE_in_commands127); 
405                     ITERATE19_tree = (Object)adaptor.create(ITERATE19);
406                     root_0 = (Object)adaptor.becomeRoot(ITERATE19_tree, root_0);
407
408                     char_literal20=(Token)input.LT(1);
409                     match(input,25,FOLLOW_25_in_commands130); 
410                     pushFollow(FOLLOW_function_in_commands133);
411                     function21=function();
412                     _fsp--;
413
414                     adaptor.addChild(root_0, function21.tree);
415                     char_literal22=(Token)input.LT(1);
416                     match(input,26,FOLLOW_26_in_commands135); 
417
418                     }
419                     break;
420                 case 8 :
421                     // bst.g:24:4: REVERSE^^ '{'! function '}'!
422                     {
423                     root_0 = (Object)adaptor.nil();
424
425                     REVERSE23=(Token)input.LT(1);
426                     match(input,REVERSE,FOLLOW_REVERSE_in_commands141); 
427                     REVERSE23_tree = (Object)adaptor.create(REVERSE23);
428                     root_0 = (Object)adaptor.becomeRoot(REVERSE23_tree, root_0);
429
430                     char_literal24=(Token)input.LT(1);
431                     match(input,25,FOLLOW_25_in_commands144); 
432                     pushFollow(FOLLOW_function_in_commands147);
433                     function25=function();
434                     _fsp--;
435
436                     adaptor.addChild(root_0, function25.tree);
437                     char_literal26=(Token)input.LT(1);
438                     match(input,26,FOLLOW_26_in_commands149); 
439
440                     }
441                     break;
442                 case 9 :
443                     // bst.g:25:4: ENTRY^^ idList0 idList0 idList0
444                     {
445                     root_0 = (Object)adaptor.nil();
446
447                     ENTRY27=(Token)input.LT(1);
448                     match(input,ENTRY,FOLLOW_ENTRY_in_commands155); 
449                     ENTRY27_tree = (Object)adaptor.create(ENTRY27);
450                     root_0 = (Object)adaptor.becomeRoot(ENTRY27_tree, root_0);
451
452                     pushFollow(FOLLOW_idList0_in_commands158);
453                     idList028=idList0();
454                     _fsp--;
455
456                     adaptor.addChild(root_0, idList028.tree);
457                     pushFollow(FOLLOW_idList0_in_commands160);
458                     idList029=idList0();
459                     _fsp--;
460
461                     adaptor.addChild(root_0, idList029.tree);
462                     pushFollow(FOLLOW_idList0_in_commands162);
463                     idList030=idList0();
464                     _fsp--;
465
466                     adaptor.addChild(root_0, idList030.tree);
467
468                     }
469                     break;
470                 case 10 :
471                     // bst.g:26:4: SORT^^
472                     {
473                     root_0 = (Object)adaptor.nil();
474
475                     SORT31=(Token)input.LT(1);
476                     match(input,SORT,FOLLOW_SORT_in_commands167); 
477                     SORT31_tree = (Object)adaptor.create(SORT31);
478                     root_0 = (Object)adaptor.becomeRoot(SORT31_tree, root_0);
479
480
481                     }
482                     break;
483
484             }
485         }
486         catch (RecognitionException re) {
487             reportError(re);
488             recover(input,re);
489         }
490         finally {
491             retval.stop = input.LT(-1);
492
493                 retval.tree = (Object)adaptor.rulePostProcessing(root_0);
494                 adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
495
496         }
497         return retval;
498     }
499     // $ANTLR end commands
500
501     public static class identifier_return extends ParserRuleReturnScope {
502         Object tree;
503         public Object getTree() { return tree; }
504     };
505
506     // $ANTLR start identifier
507     // bst.g:28:1: identifier : IDENTIFIER ;
508     public identifier_return identifier() throws RecognitionException {   
509         identifier_return retval = new identifier_return();
510         retval.start = input.LT(1);
511
512         Object root_0 = null;
513
514         Token IDENTIFIER32=null;
515
516         Object IDENTIFIER32_tree=null;
517
518         try {
519             // bst.g:29:4: ( IDENTIFIER )
520             // bst.g:29:4: IDENTIFIER
521             {
522             root_0 = (Object)adaptor.nil();
523
524             IDENTIFIER32=(Token)input.LT(1);
525             match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_identifier178); 
526             IDENTIFIER32_tree = (Object)adaptor.create(IDENTIFIER32);
527             adaptor.addChild(root_0, IDENTIFIER32_tree);
528
529
530             }
531
532         }
533         catch (RecognitionException re) {
534             reportError(re);
535             recover(input,re);
536         }
537         finally {
538             retval.stop = input.LT(-1);
539
540                 retval.tree = (Object)adaptor.rulePostProcessing(root_0);
541                 adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
542
543         }
544         return retval;
545     }
546     // $ANTLR end identifier
547
548     public static class id_return extends ParserRuleReturnScope {
549         Object tree;
550         public Object getTree() { return tree; }
551     };
552
553     // $ANTLR start id
554     // bst.g:31:1: id : '{'! identifier '}'! ;
555     public id_return id() throws RecognitionException {   
556         id_return retval = new id_return();
557         retval.start = input.LT(1);
558
559         Object root_0 = null;
560
561         Token char_literal33=null;
562         Token char_literal35=null;
563         identifier_return identifier34 = null;
564
565
566         Object char_literal33_tree=null;
567         Object char_literal35_tree=null;
568
569         try {
570             // bst.g:32:4: ( '{'! identifier '}'! )
571             // bst.g:32:4: '{'! identifier '}'!
572             {
573             root_0 = (Object)adaptor.nil();
574
575             char_literal33=(Token)input.LT(1);
576             match(input,25,FOLLOW_25_in_id188); 
577             pushFollow(FOLLOW_identifier_in_id191);
578             identifier34=identifier();
579             _fsp--;
580
581             adaptor.addChild(root_0, identifier34.tree);
582             char_literal35=(Token)input.LT(1);
583             match(input,26,FOLLOW_26_in_id193); 
584
585             }
586
587         }
588         catch (RecognitionException re) {
589             reportError(re);
590             recover(input,re);
591         }
592         finally {
593             retval.stop = input.LT(-1);
594
595                 retval.tree = (Object)adaptor.rulePostProcessing(root_0);
596                 adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
597
598         }
599         return retval;
600     }
601     // $ANTLR end id
602
603     public static class idList_return extends ParserRuleReturnScope {
604         Object tree;
605         public Object getTree() { return tree; }
606     };
607
608     // $ANTLR start idList
609     // bst.g:34:1: idList : '{' ( identifier )+ '}' -> ^( IDLIST ( identifier )+ ) ;
610     public idList_return idList() throws RecognitionException {   
611         idList_return retval = new idList_return();
612         retval.start = input.LT(1);
613
614         Object root_0 = null;
615
616         Token char_literal36=null;
617         Token char_literal38=null;
618         identifier_return identifier37 = null;
619
620         List list_identifier=new ArrayList();
621         List list_26=new ArrayList();
622         List list_25=new ArrayList();
623         Object char_literal36_tree=null;
624         Object char_literal38_tree=null;
625
626         try {
627             // bst.g:35:4: ( '{' ( identifier )+ '}' -> ^( IDLIST ( identifier )+ ) )
628             // bst.g:35:4: '{' ( identifier )+ '}'
629             {
630             char_literal36=(Token)input.LT(1);
631             match(input,25,FOLLOW_25_in_idList205); 
632             list_25.add(char_literal36);
633
634             // bst.g:35:8: ( identifier )+
635             int cnt3=0;
636             loop3:
637             do {
638                 int alt3=2;
639                 int LA3_0 = input.LA(1);
640                 if ( (LA3_0==IDENTIFIER) ) {
641                     alt3=1;
642                 }
643
644
645                 switch (alt3) {
646                 case 1 :
647                     // bst.g:35:8: identifier
648                     {
649                     pushFollow(FOLLOW_identifier_in_idList207);
650                     identifier37=identifier();
651                     _fsp--;
652
653                     list_identifier.add(identifier37.tree);
654
655                     }
656                     break;
657
658                 default :
659                     if ( cnt3 >= 1 ) break loop3;
660                         EarlyExitException eee =
661                             new EarlyExitException(3, input);
662                         throw eee;
663                 }
664                 cnt3++;
665             } while (true);
666
667             char_literal38=(Token)input.LT(1);
668             match(input,26,FOLLOW_26_in_idList210); 
669             list_26.add(char_literal38);
670
671
672             // AST REWRITE
673             int i_0 = 0;
674             retval.tree = root_0;
675             root_0 = (Object)adaptor.nil();
676             // 35:24: -> ^( IDLIST ( identifier )+ )
677             {
678                 // bst.g:35:27: ^( IDLIST ( identifier )+ )
679                 {
680                 Object root_1 = (Object)adaptor.nil();
681                 root_1 = (Object)adaptor.becomeRoot(adaptor.create(IDLIST, "IDLIST"), root_1);
682
683                 // bst.g:35:36: ( identifier )+
684                 {
685                 int n_1 = list_identifier == null ? 0 : list_identifier.size();
686                  
687
688
689                 if ( n_1==0 ) throw new RuntimeException("Must have more than one element for (...)+ loops");
690                 for (int i_1=0; i_1<n_1; i_1++) {
691                     adaptor.addChild(root_1, list_identifier.get(i_1));
692
693                 }
694                 }
695
696                 adaptor.addChild(root_0, root_1);
697                 }
698
699             }
700
701
702
703             }
704
705         }
706         catch (RecognitionException re) {
707             reportError(re);
708             recover(input,re);
709         }
710         finally {
711             retval.stop = input.LT(-1);
712
713                 retval.tree = (Object)adaptor.rulePostProcessing(root_0);
714                 adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
715
716         }
717         return retval;
718     }
719     // $ANTLR end idList
720
721     public static class idList0_return extends ParserRuleReturnScope {
722         Object tree;
723         public Object getTree() { return tree; }
724     };
725
726     // $ANTLR start idList0
727     // bst.g:37:1: idList0 : '{' ( identifier )* '}' -> ^( IDLIST ( identifier )* ) ;
728     public idList0_return idList0() throws RecognitionException {   
729         idList0_return retval = new idList0_return();
730         retval.start = input.LT(1);
731
732         Object root_0 = null;
733
734         Token char_literal39=null;
735         Token char_literal41=null;
736         identifier_return identifier40 = null;
737
738         List list_identifier=new ArrayList();
739         List list_26=new ArrayList();
740         List list_25=new ArrayList();
741         Object char_literal39_tree=null;
742         Object char_literal41_tree=null;
743
744         try {
745             // bst.g:38:4: ( '{' ( identifier )* '}' -> ^( IDLIST ( identifier )* ) )
746             // bst.g:38:4: '{' ( identifier )* '}'
747             {
748             char_literal39=(Token)input.LT(1);
749             match(input,25,FOLLOW_25_in_idList0230); 
750             list_25.add(char_literal39);
751
752             // bst.g:38:8: ( identifier )*
753             loop4:
754             do {
755                 int alt4=2;
756                 int LA4_0 = input.LA(1);
757                 if ( (LA4_0==IDENTIFIER) ) {
758                     alt4=1;
759                 }
760
761
762                 switch (alt4) {
763                 case 1 :
764                     // bst.g:38:8: identifier
765                     {
766                     pushFollow(FOLLOW_identifier_in_idList0232);
767                     identifier40=identifier();
768                     _fsp--;
769
770                     list_identifier.add(identifier40.tree);
771
772                     }
773                     break;
774
775                 default :
776                     break loop4;
777                 }
778             } while (true);
779
780             char_literal41=(Token)input.LT(1);
781             match(input,26,FOLLOW_26_in_idList0235); 
782             list_26.add(char_literal41);
783
784
785             // AST REWRITE
786             int i_0 = 0;
787             retval.tree = root_0;
788             root_0 = (Object)adaptor.nil();
789             // 38:24: -> ^( IDLIST ( identifier )* )
790             {
791                 // bst.g:38:27: ^( IDLIST ( identifier )* )
792                 {
793                 Object root_1 = (Object)adaptor.nil();
794                 root_1 = (Object)adaptor.becomeRoot(adaptor.create(IDLIST, "IDLIST"), root_1);
795
796                 // bst.g:38:36: ( identifier )*
797                 {
798                 int n_1 = list_identifier == null ? 0 : list_identifier.size();
799                  
800
801
802                 for (int i_1=0; i_1<n_1; i_1++) {
803                     adaptor.addChild(root_1, list_identifier.get(i_1));
804
805                 }
806                 }
807
808                 adaptor.addChild(root_0, root_1);
809                 }
810
811             }
812
813
814
815             }
816
817         }
818         catch (RecognitionException re) {
819             reportError(re);
820             recover(input,re);
821         }
822         finally {
823             retval.stop = input.LT(-1);
824
825                 retval.tree = (Object)adaptor.rulePostProcessing(root_0);
826                 adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
827
828         }
829         return retval;
830     }
831     // $ANTLR end idList0
832
833     public static class function_return extends ParserRuleReturnScope {
834         Object tree;
835         public Object getTree() { return tree; }
836     };
837
838     // $ANTLR start function
839     // bst.g:40:1: function : ( '<' | '>' | '=' | '+' | '-' | ':=' | '*' | 'add.period$' | 'call.type$' | 'change.case$' | 'chr.to.int$' | 'cite$' | 'duplicat$' | 'empty$' | 'format.name$' | 'if$' | 'int.to.chr$' | 'int.to.str$' | 'missing$' | 'newline$' | 'num.names$' | 'pop$' | 'preamble$' | 'purify$' | 'quote$' | 'skip$' | 'stack$' | 'substring$' | 'swap$' | 'text.length$' | 'text.prefix$' | 'top$' | 'type$' | 'warning$' | 'while$' | 'width$' | 'write$' | identifier );
840     public function_return function() throws RecognitionException {   
841         function_return retval = new function_return();
842         retval.start = input.LT(1);
843
844         Object root_0 = null;
845
846         Token char_literal42=null;
847         Token char_literal43=null;
848         Token char_literal44=null;
849         Token char_literal45=null;
850         Token char_literal46=null;
851         Token string_literal47=null;
852         Token char_literal48=null;
853         Token string_literal49=null;
854         Token string_literal50=null;
855         Token string_literal51=null;
856         Token string_literal52=null;
857         Token string_literal53=null;
858         Token string_literal54=null;
859         Token string_literal55=null;
860         Token string_literal56=null;
861         Token string_literal57=null;
862         Token string_literal58=null;
863         Token string_literal59=null;
864         Token string_literal60=null;
865         Token string_literal61=null;
866         Token string_literal62=null;
867         Token string_literal63=null;
868         Token string_literal64=null;
869         Token string_literal65=null;
870         Token string_literal66=null;
871         Token string_literal67=null;
872         Token string_literal68=null;
873         Token string_literal69=null;
874         Token string_literal70=null;
875         Token string_literal71=null;
876         Token string_literal72=null;
877         Token string_literal73=null;
878         Token string_literal74=null;
879         Token string_literal75=null;
880         Token string_literal76=null;
881         Token string_literal77=null;
882         Token string_literal78=null;
883         identifier_return identifier79 = null;
884
885
886         Object char_literal42_tree=null;
887         Object char_literal43_tree=null;
888         Object char_literal44_tree=null;
889         Object char_literal45_tree=null;
890         Object char_literal46_tree=null;
891         Object string_literal47_tree=null;
892         Object char_literal48_tree=null;
893         Object string_literal49_tree=null;
894         Object string_literal50_tree=null;
895         Object string_literal51_tree=null;
896         Object string_literal52_tree=null;
897         Object string_literal53_tree=null;
898         Object string_literal54_tree=null;
899         Object string_literal55_tree=null;
900         Object string_literal56_tree=null;
901         Object string_literal57_tree=null;
902         Object string_literal58_tree=null;
903         Object string_literal59_tree=null;
904         Object string_literal60_tree=null;
905         Object string_literal61_tree=null;
906         Object string_literal62_tree=null;
907         Object string_literal63_tree=null;
908         Object string_literal64_tree=null;
909         Object string_literal65_tree=null;
910         Object string_literal66_tree=null;
911         Object string_literal67_tree=null;
912         Object string_literal68_tree=null;
913         Object string_literal69_tree=null;
914         Object string_literal70_tree=null;
915         Object string_literal71_tree=null;
916         Object string_literal72_tree=null;
917         Object string_literal73_tree=null;
918         Object string_literal74_tree=null;
919         Object string_literal75_tree=null;
920         Object string_literal76_tree=null;
921         Object string_literal77_tree=null;
922         Object string_literal78_tree=null;
923
924         try {
925             // bst.g:41:4: ( '<' | '>' | '=' | '+' | '-' | ':=' | '*' | 'add.period$' | 'call.type$' | 'change.case$' | 'chr.to.int$' | 'cite$' | 'duplicat$' | 'empty$' | 'format.name$' | 'if$' | 'int.to.chr$' | 'int.to.str$' | 'missing$' | 'newline$' | 'num.names$' | 'pop$' | 'preamble$' | 'purify$' | 'quote$' | 'skip$' | 'stack$' | 'substring$' | 'swap$' | 'text.length$' | 'text.prefix$' | 'top$' | 'type$' | 'warning$' | 'while$' | 'width$' | 'write$' | identifier )
926             int alt5=38;
927             switch ( input.LA(1) ) {
928             case 27:
929                 alt5=1;
930                 break;
931             case 28:
932                 alt5=2;
933                 break;
934             case 29:
935                 alt5=3;
936                 break;
937             case 30:
938                 alt5=4;
939                 break;
940             case 31:
941                 alt5=5;
942                 break;
943             case 32:
944                 alt5=6;
945                 break;
946             case 33:
947                 alt5=7;
948                 break;
949             case 34:
950                 alt5=8;
951                 break;
952             case 35:
953                 alt5=9;
954                 break;
955             case 36:
956                 alt5=10;
957                 break;
958             case 37:
959                 alt5=11;
960                 break;
961             case 38:
962                 alt5=12;
963                 break;
964             case 39:
965                 alt5=13;
966                 break;
967             case 40:
968                 alt5=14;
969                 break;
970             case 41:
971                 alt5=15;
972                 break;
973             case 42:
974                 alt5=16;
975                 break;
976             case 43:
977                 alt5=17;
978                 break;
979             case 44:
980                 alt5=18;
981                 break;
982             case 45:
983                 alt5=19;
984                 break;
985             case 46:
986                 alt5=20;
987                 break;
988             case 47:
989                 alt5=21;
990                 break;
991             case 48:
992                 alt5=22;
993                 break;
994             case 49:
995                 alt5=23;
996                 break;
997             case 50:
998                 alt5=24;
999                 break;
1000             case 51:
1001                 alt5=25;
1002                 break;
1003             case 52:
1004                 alt5=26;
1005                 break;
1006             case 53:
1007                 alt5=27;
1008                 break;
1009             case 54:
1010                 alt5=28;
1011                 break;
1012             case 55:
1013                 alt5=29;
1014                 break;
1015             case 56:
1016                 alt5=30;
1017                 break;
1018             case 57:
1019                 alt5=31;
1020                 break;
1021             case 58:
1022                 alt5=32;
1023                 break;
1024             case 59:
1025                 alt5=33;
1026                 break;
1027             case 60:
1028                 alt5=34;
1029                 break;
1030             case 61:
1031                 alt5=35;
1032                 break;
1033             case 62:
1034                 alt5=36;
1035                 break;
1036             case 63:
1037                 alt5=37;
1038                 break;
1039             case IDENTIFIER:
1040                 alt5=38;
1041                 break;
1042             default:
1043                 NoViableAltException nvae =
1044                     new NoViableAltException("40:1: function : ( '<' | '>' | '=' | '+' | '-' | ':=' | '*' | 'add.period$' | 'call.type$' | 'change.case$' | 'chr.to.int$' | 'cite$' | 'duplicat$' | 'empty$' | 'format.name$' | 'if$' | 'int.to.chr$' | 'int.to.str$' | 'missing$' | 'newline$' | 'num.names$' | 'pop$' | 'preamble$' | 'purify$' | 'quote$' | 'skip$' | 'stack$' | 'substring$' | 'swap$' | 'text.length$' | 'text.prefix$' | 'top$' | 'type$' | 'warning$' | 'while$' | 'width$' | 'write$' | identifier );", 5, 0, input);
1045
1046                 throw nvae;
1047             }
1048
1049             switch (alt5) {
1050                 case 1 :
1051                     // bst.g:41:4: '<'
1052                     {
1053                     root_0 = (Object)adaptor.nil();
1054
1055                     char_literal42=(Token)input.LT(1);
1056                     match(input,27,FOLLOW_27_in_function254); 
1057                     char_literal42_tree = (Object)adaptor.create(char_literal42);
1058                     adaptor.addChild(root_0, char_literal42_tree);
1059
1060
1061                     }
1062                     break;
1063                 case 2 :
1064                     // bst.g:41:10: '>'
1065                     {
1066                     root_0 = (Object)adaptor.nil();
1067
1068                     char_literal43=(Token)input.LT(1);
1069                     match(input,28,FOLLOW_28_in_function258); 
1070                     char_literal43_tree = (Object)adaptor.create(char_literal43);
1071                     adaptor.addChild(root_0, char_literal43_tree);
1072
1073
1074                     }
1075                     break;
1076                 case 3 :
1077                     // bst.g:41:16: '='
1078                     {
1079                     root_0 = (Object)adaptor.nil();
1080
1081                     char_literal44=(Token)input.LT(1);
1082                     match(input,29,FOLLOW_29_in_function262); 
1083                     char_literal44_tree = (Object)adaptor.create(char_literal44);
1084                     adaptor.addChild(root_0, char_literal44_tree);
1085
1086
1087                     }
1088                     break;
1089                 case 4 :
1090                     // bst.g:41:22: '+'
1091                     {
1092                     root_0 = (Object)adaptor.nil();
1093
1094                     char_literal45=(Token)input.LT(1);
1095                     match(input,30,FOLLOW_30_in_function266); 
1096                     char_literal45_tree = (Object)adaptor.create(char_literal45);
1097                     adaptor.addChild(root_0, char_literal45_tree);
1098
1099
1100                     }
1101                     break;
1102                 case 5 :
1103                     // bst.g:41:28: '-'
1104                     {
1105                     root_0 = (Object)adaptor.nil();
1106
1107                     char_literal46=(Token)input.LT(1);
1108                     match(input,31,FOLLOW_31_in_function270); 
1109                     char_literal46_tree = (Object)adaptor.create(char_literal46);
1110                     adaptor.addChild(root_0, char_literal46_tree);
1111
1112
1113                     }
1114                     break;
1115                 case 6 :
1116                     // bst.g:41:34: ':='
1117                     {
1118                     root_0 = (Object)adaptor.nil();
1119
1120                     string_literal47=(Token)input.LT(1);
1121                     match(input,32,FOLLOW_32_in_function274); 
1122                     string_literal47_tree = (Object)adaptor.create(string_literal47);
1123                     adaptor.addChild(root_0, string_literal47_tree);
1124
1125
1126                     }
1127                     break;
1128                 case 7 :
1129                     // bst.g:41:41: '*'
1130                     {
1131                     root_0 = (Object)adaptor.nil();
1132
1133                     char_literal48=(Token)input.LT(1);
1134                     match(input,33,FOLLOW_33_in_function278); 
1135                     char_literal48_tree = (Object)adaptor.create(char_literal48);
1136                     adaptor.addChild(root_0, char_literal48_tree);
1137
1138
1139                     }
1140                     break;
1141                 case 8 :
1142                     // bst.g:41:47: 'add.period$'
1143                     {
1144                     root_0 = (Object)adaptor.nil();
1145
1146                     string_literal49=(Token)input.LT(1);
1147                     match(input,34,FOLLOW_34_in_function282); 
1148                     string_literal49_tree = (Object)adaptor.create(string_literal49);
1149                     adaptor.addChild(root_0, string_literal49_tree);
1150
1151
1152                     }
1153                     break;
1154                 case 9 :
1155                     // bst.g:41:63: 'call.type$'
1156                     {
1157                     root_0 = (Object)adaptor.nil();
1158
1159                     string_literal50=(Token)input.LT(1);
1160                     match(input,35,FOLLOW_35_in_function286); 
1161                     string_literal50_tree = (Object)adaptor.create(string_literal50);
1162                     adaptor.addChild(root_0, string_literal50_tree);
1163
1164
1165                     }
1166                     break;
1167                 case 10 :
1168                     // bst.g:41:78: 'change.case$'
1169                     {
1170                     root_0 = (Object)adaptor.nil();
1171
1172                     string_literal51=(Token)input.LT(1);
1173                     match(input,36,FOLLOW_36_in_function290); 
1174                     string_literal51_tree = (Object)adaptor.create(string_literal51);
1175                     adaptor.addChild(root_0, string_literal51_tree);
1176
1177
1178                     }
1179                     break;
1180                 case 11 :
1181                     // bst.g:41:95: 'chr.to.int$'
1182                     {
1183                     root_0 = (Object)adaptor.nil();
1184
1185                     string_literal52=(Token)input.LT(1);
1186                     match(input,37,FOLLOW_37_in_function294); 
1187                     string_literal52_tree = (Object)adaptor.create(string_literal52);
1188                     adaptor.addChild(root_0, string_literal52_tree);
1189
1190
1191                     }
1192                     break;
1193                 case 12 :
1194                     // bst.g:42:4: 'cite$'
1195                     {
1196                     root_0 = (Object)adaptor.nil();
1197
1198                     string_literal53=(Token)input.LT(1);
1199                     match(input,38,FOLLOW_38_in_function299); 
1200                     string_literal53_tree = (Object)adaptor.create(string_literal53);
1201                     adaptor.addChild(root_0, string_literal53_tree);
1202
1203
1204                     }
1205                     break;
1206                 case 13 :
1207                     // bst.g:42:14: 'duplicat$'
1208                     {
1209                     root_0 = (Object)adaptor.nil();
1210
1211                     string_literal54=(Token)input.LT(1);
1212                     match(input,39,FOLLOW_39_in_function303); 
1213                     string_literal54_tree = (Object)adaptor.create(string_literal54);
1214                     adaptor.addChild(root_0, string_literal54_tree);
1215
1216
1217                     }
1218                     break;
1219                 case 14 :
1220                     // bst.g:42:28: 'empty$'
1221                     {
1222                     root_0 = (Object)adaptor.nil();
1223
1224                     string_literal55=(Token)input.LT(1);
1225                     match(input,40,FOLLOW_40_in_function307); 
1226                     string_literal55_tree = (Object)adaptor.create(string_literal55);
1227                     adaptor.addChild(root_0, string_literal55_tree);
1228
1229
1230                     }
1231                     break;
1232                 case 15 :
1233                     // bst.g:42:39: 'format.name$'
1234                     {
1235                     root_0 = (Object)adaptor.nil();
1236
1237                     string_literal56=(Token)input.LT(1);
1238                     match(input,41,FOLLOW_41_in_function311); 
1239                     string_literal56_tree = (Object)adaptor.create(string_literal56);
1240                     adaptor.addChild(root_0, string_literal56_tree);
1241
1242
1243                     }
1244                     break;
1245                 case 16 :
1246                     // bst.g:42:56: 'if$'
1247                     {
1248                     root_0 = (Object)adaptor.nil();
1249
1250                     string_literal57=(Token)input.LT(1);
1251                     match(input,42,FOLLOW_42_in_function315); 
1252                     string_literal57_tree = (Object)adaptor.create(string_literal57);
1253                     adaptor.addChild(root_0, string_literal57_tree);
1254
1255
1256                     }
1257                     break;
1258                 case 17 :
1259                     // bst.g:42:64: 'int.to.chr$'
1260                     {
1261                     root_0 = (Object)adaptor.nil();
1262
1263                     string_literal58=(Token)input.LT(1);
1264                     match(input,43,FOLLOW_43_in_function319); 
1265                     string_literal58_tree = (Object)adaptor.create(string_literal58);
1266                     adaptor.addChild(root_0, string_literal58_tree);
1267
1268
1269                     }
1270                     break;
1271                 case 18 :
1272                     // bst.g:42:80: 'int.to.str$'
1273                     {
1274                     root_0 = (Object)adaptor.nil();
1275
1276                     string_literal59=(Token)input.LT(1);
1277                     match(input,44,FOLLOW_44_in_function323); 
1278                     string_literal59_tree = (Object)adaptor.create(string_literal59);
1279                     adaptor.addChild(root_0, string_literal59_tree);
1280
1281
1282                     }
1283                     break;
1284                 case 19 :
1285                     // bst.g:42:96: 'missing$'
1286                     {
1287                     root_0 = (Object)adaptor.nil();
1288
1289                     string_literal60=(Token)input.LT(1);
1290                     match(input,45,FOLLOW_45_in_function327); 
1291                     string_literal60_tree = (Object)adaptor.create(string_literal60);
1292                     adaptor.addChild(root_0, string_literal60_tree);
1293
1294
1295                     }
1296                     break;
1297                 case 20 :
1298                     // bst.g:43:4: 'newline$'
1299                     {
1300                     root_0 = (Object)adaptor.nil();
1301
1302                     string_literal61=(Token)input.LT(1);
1303                     match(input,46,FOLLOW_46_in_function332); 
1304                     string_literal61_tree = (Object)adaptor.create(string_literal61);
1305                     adaptor.addChild(root_0, string_literal61_tree);
1306
1307
1308                     }
1309                     break;
1310                 case 21 :
1311                     // bst.g:43:17: 'num.names$'
1312                     {
1313                     root_0 = (Object)adaptor.nil();
1314
1315                     string_literal62=(Token)input.LT(1);
1316                     match(input,47,FOLLOW_47_in_function336); 
1317                     string_literal62_tree = (Object)adaptor.create(string_literal62);
1318                     adaptor.addChild(root_0, string_literal62_tree);
1319
1320
1321                     }
1322                     break;
1323                 case 22 :
1324                     // bst.g:43:32: 'pop$'
1325                     {
1326                     root_0 = (Object)adaptor.nil();
1327
1328                     string_literal63=(Token)input.LT(1);
1329                     match(input,48,FOLLOW_48_in_function340); 
1330                     string_literal63_tree = (Object)adaptor.create(string_literal63);
1331                     adaptor.addChild(root_0, string_literal63_tree);
1332
1333
1334                     }
1335                     break;
1336                 case 23 :
1337                     // bst.g:43:41: 'preamble$'
1338                     {
1339                     root_0 = (Object)adaptor.nil();
1340
1341                     string_literal64=(Token)input.LT(1);
1342                     match(input,49,FOLLOW_49_in_function344); 
1343                     string_literal64_tree = (Object)adaptor.create(string_literal64);
1344                     adaptor.addChild(root_0, string_literal64_tree);
1345
1346
1347                     }
1348                     break;
1349                 case 24 :
1350                     // bst.g:43:55: 'purify$'
1351                     {
1352                     root_0 = (Object)adaptor.nil();
1353
1354                     string_literal65=(Token)input.LT(1);
1355                     match(input,50,FOLLOW_50_in_function348); 
1356                     string_literal65_tree = (Object)adaptor.create(string_literal65);
1357                     adaptor.addChild(root_0, string_literal65_tree);
1358
1359
1360                     }
1361                     break;
1362                 case 25 :
1363                     // bst.g:43:67: 'quote$'
1364                     {
1365                     root_0 = (Object)adaptor.nil();
1366
1367                     string_literal66=(Token)input.LT(1);
1368                     match(input,51,FOLLOW_51_in_function352); 
1369                     string_literal66_tree = (Object)adaptor.create(string_literal66);
1370                     adaptor.addChild(root_0, string_literal66_tree);
1371
1372
1373                     }
1374                     break;
1375                 case 26 :
1376                     // bst.g:43:78: 'skip$'
1377                     {
1378                     root_0 = (Object)adaptor.nil();
1379
1380                     string_literal67=(Token)input.LT(1);
1381                     match(input,52,FOLLOW_52_in_function356); 
1382                     string_literal67_tree = (Object)adaptor.create(string_literal67);
1383                     adaptor.addChild(root_0, string_literal67_tree);
1384
1385
1386                     }
1387                     break;
1388                 case 27 :
1389                     // bst.g:43:88: 'stack$'
1390                     {
1391                     root_0 = (Object)adaptor.nil();
1392
1393                     string_literal68=(Token)input.LT(1);
1394                     match(input,53,FOLLOW_53_in_function360); 
1395                     string_literal68_tree = (Object)adaptor.create(string_literal68);
1396                     adaptor.addChild(root_0, string_literal68_tree);
1397
1398
1399                     }
1400                     break;
1401                 case 28 :
1402                     // bst.g:43:99: 'substring$'
1403                     {
1404                     root_0 = (Object)adaptor.nil();
1405
1406                     string_literal69=(Token)input.LT(1);
1407                     match(input,54,FOLLOW_54_in_function364); 
1408                     string_literal69_tree = (Object)adaptor.create(string_literal69);
1409                     adaptor.addChild(root_0, string_literal69_tree);
1410
1411
1412                     }
1413                     break;
1414                 case 29 :
1415                     // bst.g:44:4: 'swap$'
1416                     {
1417                     root_0 = (Object)adaptor.nil();
1418
1419                     string_literal70=(Token)input.LT(1);
1420                     match(input,55,FOLLOW_55_in_function369); 
1421                     string_literal70_tree = (Object)adaptor.create(string_literal70);
1422                     adaptor.addChild(root_0, string_literal70_tree);
1423
1424
1425                     }
1426                     break;
1427                 case 30 :
1428                     // bst.g:44:14: 'text.length$'
1429                     {
1430                     root_0 = (Object)adaptor.nil();
1431
1432                     string_literal71=(Token)input.LT(1);
1433                     match(input,56,FOLLOW_56_in_function373); 
1434                     string_literal71_tree = (Object)adaptor.create(string_literal71);
1435                     adaptor.addChild(root_0, string_literal71_tree);
1436
1437
1438                     }
1439                     break;
1440                 case 31 :
1441                     // bst.g:44:31: 'text.prefix$'
1442                     {
1443                     root_0 = (Object)adaptor.nil();
1444
1445                     string_literal72=(Token)input.LT(1);
1446                     match(input,57,FOLLOW_57_in_function377); 
1447                     string_literal72_tree = (Object)adaptor.create(string_literal72);
1448                     adaptor.addChild(root_0, string_literal72_tree);
1449
1450
1451                     }
1452                     break;
1453                 case 32 :
1454                     // bst.g:44:48: 'top$'
1455                     {
1456                     root_0 = (Object)adaptor.nil();
1457
1458                     string_literal73=(Token)input.LT(1);
1459                     match(input,58,FOLLOW_58_in_function381); 
1460                     string_literal73_tree = (Object)adaptor.create(string_literal73);
1461                     adaptor.addChild(root_0, string_literal73_tree);
1462
1463
1464                     }
1465                     break;
1466                 case 33 :
1467                     // bst.g:44:57: 'type$'
1468                     {
1469                     root_0 = (Object)adaptor.nil();
1470
1471                     string_literal74=(Token)input.LT(1);
1472                     match(input,59,FOLLOW_59_in_function385); 
1473                     string_literal74_tree = (Object)adaptor.create(string_literal74);
1474                     adaptor.addChild(root_0, string_literal74_tree);
1475
1476
1477                     }
1478                     break;
1479                 case 34 :
1480                     // bst.g:44:67: 'warning$'
1481                     {
1482                     root_0 = (Object)adaptor.nil();
1483
1484                     string_literal75=(Token)input.LT(1);
1485                     match(input,60,FOLLOW_60_in_function389); 
1486                     string_literal75_tree = (Object)adaptor.create(string_literal75);
1487                     adaptor.addChild(root_0, string_literal75_tree);
1488
1489
1490                     }
1491                     break;
1492                 case 35 :
1493                     // bst.g:44:80: 'while$'
1494                     {
1495                     root_0 = (Object)adaptor.nil();
1496
1497                     string_literal76=(Token)input.LT(1);
1498                     match(input,61,FOLLOW_61_in_function393); 
1499                     string_literal76_tree = (Object)adaptor.create(string_literal76);
1500                     adaptor.addChild(root_0, string_literal76_tree);
1501
1502
1503                     }
1504                     break;
1505                 case 36 :
1506                     // bst.g:44:91: 'width$'
1507                     {
1508                     root_0 = (Object)adaptor.nil();
1509
1510                     string_literal77=(Token)input.LT(1);
1511                     match(input,62,FOLLOW_62_in_function397); 
1512                     string_literal77_tree = (Object)adaptor.create(string_literal77);
1513                     adaptor.addChild(root_0, string_literal77_tree);
1514
1515
1516                     }
1517                     break;
1518                 case 37 :
1519                     // bst.g:45:4: 'write$'
1520                     {
1521                     root_0 = (Object)adaptor.nil();
1522
1523                     string_literal78=(Token)input.LT(1);
1524                     match(input,63,FOLLOW_63_in_function402); 
1525                     string_literal78_tree = (Object)adaptor.create(string_literal78);
1526                     adaptor.addChild(root_0, string_literal78_tree);
1527
1528
1529                     }
1530                     break;
1531                 case 38 :
1532                     // bst.g:45:15: identifier
1533                     {
1534                     root_0 = (Object)adaptor.nil();
1535
1536                     pushFollow(FOLLOW_identifier_in_function406);
1537                     identifier79=identifier();
1538                     _fsp--;
1539
1540                     adaptor.addChild(root_0, identifier79.tree);
1541
1542                     }
1543                     break;
1544
1545             }
1546         }
1547         catch (RecognitionException re) {
1548             reportError(re);
1549             recover(input,re);
1550         }
1551         finally {
1552             retval.stop = input.LT(-1);
1553
1554                 retval.tree = (Object)adaptor.rulePostProcessing(root_0);
1555                 adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
1556
1557         }
1558         return retval;
1559     }
1560     // $ANTLR end function
1561
1562     public static class stack_return extends ParserRuleReturnScope {
1563         Object tree;
1564         public Object getTree() { return tree; }
1565     };
1566
1567     // $ANTLR start stack
1568     // bst.g:47:1: stack : '{' ( stackitem )+ '}' -> ^( STACK ( stackitem )+ ) ;
1569     public stack_return stack() throws RecognitionException {   
1570         stack_return retval = new stack_return();
1571         retval.start = input.LT(1);
1572
1573         Object root_0 = null;
1574
1575         Token char_literal80=null;
1576         Token char_literal82=null;
1577         stackitem_return stackitem81 = null;
1578
1579         List list_stackitem=new ArrayList();
1580         List list_26=new ArrayList();
1581         List list_25=new ArrayList();
1582         Object char_literal80_tree=null;
1583         Object char_literal82_tree=null;
1584
1585         try {
1586             // bst.g:48:4: ( '{' ( stackitem )+ '}' -> ^( STACK ( stackitem )+ ) )
1587             // bst.g:48:4: '{' ( stackitem )+ '}'
1588             {
1589             char_literal80=(Token)input.LT(1);
1590             match(input,25,FOLLOW_25_in_stack417); 
1591             list_25.add(char_literal80);
1592
1593             // bst.g:48:8: ( stackitem )+
1594             int cnt6=0;
1595             loop6:
1596             do {
1597                 int alt6=2;
1598                 int LA6_0 = input.LA(1);
1599                 if ( (LA6_0==STRING||(LA6_0>=IDENTIFIER && LA6_0<=QUOTED)||LA6_0==25||(LA6_0>=27 && LA6_0<=63)) ) {
1600                     alt6=1;
1601                 }
1602
1603
1604                 switch (alt6) {
1605                 case 1 :
1606                     // bst.g:48:8: stackitem
1607                     {
1608                     pushFollow(FOLLOW_stackitem_in_stack419);
1609                     stackitem81=stackitem();
1610                     _fsp--;
1611
1612                     list_stackitem.add(stackitem81.tree);
1613
1614                     }
1615                     break;
1616
1617                 default :
1618                     if ( cnt6 >= 1 ) break loop6;
1619                         EarlyExitException eee =
1620                             new EarlyExitException(6, input);
1621                         throw eee;
1622                 }
1623                 cnt6++;
1624             } while (true);
1625
1626             char_literal82=(Token)input.LT(1);
1627             match(input,26,FOLLOW_26_in_stack422); 
1628             list_26.add(char_literal82);
1629
1630
1631             // AST REWRITE
1632             int i_0 = 0;
1633             retval.tree = root_0;
1634             root_0 = (Object)adaptor.nil();
1635             // 48:23: -> ^( STACK ( stackitem )+ )
1636             {
1637                 // bst.g:48:26: ^( STACK ( stackitem )+ )
1638                 {
1639                 Object root_1 = (Object)adaptor.nil();
1640                 root_1 = (Object)adaptor.becomeRoot(adaptor.create(STACK, "STACK"), root_1);
1641
1642                 // bst.g:48:34: ( stackitem )+
1643                 {
1644                 int n_1 = list_stackitem == null ? 0 : list_stackitem.size();
1645                  
1646
1647
1648                 if ( n_1==0 ) throw new RuntimeException("Must have more than one element for (...)+ loops");
1649                 for (int i_1=0; i_1<n_1; i_1++) {
1650                     adaptor.addChild(root_1, list_stackitem.get(i_1));
1651
1652                 }
1653                 }
1654
1655                 adaptor.addChild(root_0, root_1);
1656                 }
1657
1658             }
1659
1660
1661
1662             }
1663
1664         }
1665         catch (RecognitionException re) {
1666             reportError(re);
1667             recover(input,re);
1668         }
1669         finally {
1670             retval.stop = input.LT(-1);
1671
1672                 retval.tree = (Object)adaptor.rulePostProcessing(root_0);
1673                 adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
1674
1675         }
1676         return retval;
1677     }
1678     // $ANTLR end stack
1679
1680     public static class stackitem_return extends ParserRuleReturnScope {
1681         Object tree;
1682         public Object getTree() { return tree; }
1683     };
1684
1685     // $ANTLR start stackitem
1686     // bst.g:50:1: stackitem : ( function | STRING | INTEGER | QUOTED | stack );
1687     public stackitem_return stackitem() throws RecognitionException {   
1688         stackitem_return retval = new stackitem_return();
1689         retval.start = input.LT(1);
1690
1691         Object root_0 = null;
1692
1693         Token STRING84=null;
1694         Token INTEGER85=null;
1695         Token QUOTED86=null;
1696         function_return function83 = null;
1697
1698         stack_return stack87 = null;
1699
1700
1701         Object STRING84_tree=null;
1702         Object INTEGER85_tree=null;
1703         Object QUOTED86_tree=null;
1704
1705         try {
1706             // bst.g:51:4: ( function | STRING | INTEGER | QUOTED | stack )
1707             int alt7=5;
1708             switch ( input.LA(1) ) {
1709             case IDENTIFIER:
1710             case 27:
1711             case 28:
1712             case 29:
1713             case 30:
1714             case 31:
1715             case 32:
1716             case 33:
1717             case 34:
1718             case 35:
1719             case 36:
1720             case 37:
1721             case 38:
1722             case 39:
1723             case 40:
1724             case 41:
1725             case 42:
1726             case 43:
1727             case 44:
1728             case 45:
1729             case 46:
1730             case 47:
1731             case 48:
1732             case 49:
1733             case 50:
1734             case 51:
1735             case 52:
1736             case 53:
1737             case 54:
1738             case 55:
1739             case 56:
1740             case 57:
1741             case 58:
1742             case 59:
1743             case 60:
1744             case 61:
1745             case 62:
1746             case 63:
1747                 alt7=1;
1748                 break;
1749             case STRING:
1750                 alt7=2;
1751                 break;
1752             case INTEGER:
1753                 alt7=3;
1754                 break;
1755             case QUOTED:
1756                 alt7=4;
1757                 break;
1758             case 25:
1759                 alt7=5;
1760                 break;
1761             default:
1762                 NoViableAltException nvae =
1763                     new NoViableAltException("50:1: stackitem : ( function | STRING | INTEGER | QUOTED | stack );", 7, 0, input);
1764
1765                 throw nvae;
1766             }
1767
1768             switch (alt7) {
1769                 case 1 :
1770                     // bst.g:51:4: function
1771                     {
1772                     root_0 = (Object)adaptor.nil();
1773
1774                     pushFollow(FOLLOW_function_in_stackitem441);
1775                     function83=function();
1776                     _fsp--;
1777
1778                     adaptor.addChild(root_0, function83.tree);
1779
1780                     }
1781                     break;
1782                 case 2 :
1783                     // bst.g:52:4: STRING
1784                     {
1785                     root_0 = (Object)adaptor.nil();
1786
1787                     STRING84=(Token)input.LT(1);
1788                     match(input,STRING,FOLLOW_STRING_in_stackitem446); 
1789                     STRING84_tree = (Object)adaptor.create(STRING84);
1790                     adaptor.addChild(root_0, STRING84_tree);
1791
1792
1793                     }
1794                     break;
1795                 case 3 :
1796                     // bst.g:53:4: INTEGER
1797                     {
1798                     root_0 = (Object)adaptor.nil();
1799
1800                     INTEGER85=(Token)input.LT(1);
1801                     match(input,INTEGER,FOLLOW_INTEGER_in_stackitem452); 
1802                     INTEGER85_tree = (Object)adaptor.create(INTEGER85);
1803                     adaptor.addChild(root_0, INTEGER85_tree);
1804
1805
1806                     }
1807                     break;
1808                 case 4 :
1809                     // bst.g:54:4: QUOTED
1810                     {
1811                     root_0 = (Object)adaptor.nil();
1812
1813                     QUOTED86=(Token)input.LT(1);
1814                     match(input,QUOTED,FOLLOW_QUOTED_in_stackitem458); 
1815                     QUOTED86_tree = (Object)adaptor.create(QUOTED86);
1816                     adaptor.addChild(root_0, QUOTED86_tree);
1817
1818
1819                     }
1820                     break;
1821                 case 5 :
1822                     // bst.g:55:4: stack
1823                     {
1824                     root_0 = (Object)adaptor.nil();
1825
1826                     pushFollow(FOLLOW_stack_in_stackitem463);
1827                     stack87=stack();
1828                     _fsp--;
1829
1830                     adaptor.addChild(root_0, stack87.tree);
1831
1832                     }
1833                     break;
1834
1835             }
1836         }
1837         catch (RecognitionException re) {
1838             reportError(re);
1839             recover(input,re);
1840         }
1841         finally {
1842             retval.stop = input.LT(-1);
1843
1844                 retval.tree = (Object)adaptor.rulePostProcessing(root_0);
1845                 adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
1846
1847         }
1848         return retval;
1849     }
1850     // $ANTLR end stackitem
1851
1852
1853  
1854
1855     public static final BitSet FOLLOW_commands_in_program45 = new BitSet(new long[]{0x000000000003EF42L});
1856     public static final BitSet FOLLOW_STRINGS_in_commands65 = new BitSet(new long[]{0x0000000002000000L});
1857     public static final BitSet FOLLOW_idList_in_commands68 = new BitSet(new long[]{0x0000000000000002L});
1858     public static final BitSet FOLLOW_INTEGERS_in_commands73 = new BitSet(new long[]{0x0000000002000000L});
1859     public static final BitSet FOLLOW_idList_in_commands76 = new BitSet(new long[]{0x0000000000000002L});
1860     public static final BitSet FOLLOW_FUNCTION_in_commands81 = new BitSet(new long[]{0x0000000002000000L});
1861     public static final BitSet FOLLOW_id_in_commands84 = new BitSet(new long[]{0x0000000002000000L});
1862     public static final BitSet FOLLOW_stack_in_commands86 = new BitSet(new long[]{0x0000000000000002L});
1863     public static final BitSet FOLLOW_MACRO_in_commands91 = new BitSet(new long[]{0x0000000002000000L});
1864     public static final BitSet FOLLOW_id_in_commands94 = new BitSet(new long[]{0x0000000002000000L});
1865     public static final BitSet FOLLOW_25_in_commands96 = new BitSet(new long[]{0x0000000000001000L});
1866     public static final BitSet FOLLOW_STRING_in_commands99 = new BitSet(new long[]{0x0000000004000000L});
1867     public static final BitSet FOLLOW_26_in_commands101 = new BitSet(new long[]{0x0000000000000002L});
1868     public static final BitSet FOLLOW_READ_in_commands107 = new BitSet(new long[]{0x0000000000000002L});
1869     public static final BitSet FOLLOW_EXECUTE_in_commands113 = new BitSet(new long[]{0x0000000002000000L});
1870     public static final BitSet FOLLOW_25_in_commands116 = new BitSet(new long[]{0xFFFFFFFFF8040000L});
1871     public static final BitSet FOLLOW_function_in_commands119 = new BitSet(new long[]{0x0000000004000000L});
1872     public static final BitSet FOLLOW_26_in_commands121 = new BitSet(new long[]{0x0000000000000002L});
1873     public static final BitSet FOLLOW_ITERATE_in_commands127 = new BitSet(new long[]{0x0000000002000000L});
1874     public static final BitSet FOLLOW_25_in_commands130 = new BitSet(new long[]{0xFFFFFFFFF8040000L});
1875     public static final BitSet FOLLOW_function_in_commands133 = new BitSet(new long[]{0x0000000004000000L});
1876     public static final BitSet FOLLOW_26_in_commands135 = new BitSet(new long[]{0x0000000000000002L});
1877     public static final BitSet FOLLOW_REVERSE_in_commands141 = new BitSet(new long[]{0x0000000002000000L});
1878     public static final BitSet FOLLOW_25_in_commands144 = new BitSet(new long[]{0xFFFFFFFFF8040000L});
1879     public static final BitSet FOLLOW_function_in_commands147 = new BitSet(new long[]{0x0000000004000000L});
1880     public static final BitSet FOLLOW_26_in_commands149 = new BitSet(new long[]{0x0000000000000002L});
1881     public static final BitSet FOLLOW_ENTRY_in_commands155 = new BitSet(new long[]{0x0000000002000000L});
1882     public static final BitSet FOLLOW_idList0_in_commands158 = new BitSet(new long[]{0x0000000002000000L});
1883     public static final BitSet FOLLOW_idList0_in_commands160 = new BitSet(new long[]{0x0000000002000000L});
1884     public static final BitSet FOLLOW_idList0_in_commands162 = new BitSet(new long[]{0x0000000000000002L});
1885     public static final BitSet FOLLOW_SORT_in_commands167 = new BitSet(new long[]{0x0000000000000002L});
1886     public static final BitSet FOLLOW_IDENTIFIER_in_identifier178 = new BitSet(new long[]{0x0000000000000002L});
1887     public static final BitSet FOLLOW_25_in_id188 = new BitSet(new long[]{0x0000000000040000L});
1888     public static final BitSet FOLLOW_identifier_in_id191 = new BitSet(new long[]{0x0000000004000000L});
1889     public static final BitSet FOLLOW_26_in_id193 = new BitSet(new long[]{0x0000000000000002L});
1890     public static final BitSet FOLLOW_25_in_idList205 = new BitSet(new long[]{0x0000000000040000L});
1891     public static final BitSet FOLLOW_identifier_in_idList207 = new BitSet(new long[]{0x0000000004040000L});
1892     public static final BitSet FOLLOW_26_in_idList210 = new BitSet(new long[]{0x0000000000000002L});
1893     public static final BitSet FOLLOW_25_in_idList0230 = new BitSet(new long[]{0x0000000004040000L});
1894     public static final BitSet FOLLOW_identifier_in_idList0232 = new BitSet(new long[]{0x0000000004040000L});
1895     public static final BitSet FOLLOW_26_in_idList0235 = new BitSet(new long[]{0x0000000000000002L});
1896     public static final BitSet FOLLOW_27_in_function254 = new BitSet(new long[]{0x0000000000000002L});
1897     public static final BitSet FOLLOW_28_in_function258 = new BitSet(new long[]{0x0000000000000002L});
1898     public static final BitSet FOLLOW_29_in_function262 = new BitSet(new long[]{0x0000000000000002L});
1899     public static final BitSet FOLLOW_30_in_function266 = new BitSet(new long[]{0x0000000000000002L});
1900     public static final BitSet FOLLOW_31_in_function270 = new BitSet(new long[]{0x0000000000000002L});
1901     public static final BitSet FOLLOW_32_in_function274 = new BitSet(new long[]{0x0000000000000002L});
1902     public static final BitSet FOLLOW_33_in_function278 = new BitSet(new long[]{0x0000000000000002L});
1903     public static final BitSet FOLLOW_34_in_function282 = new BitSet(new long[]{0x0000000000000002L});
1904     public static final BitSet FOLLOW_35_in_function286 = new BitSet(new long[]{0x0000000000000002L});
1905     public static final BitSet FOLLOW_36_in_function290 = new BitSet(new long[]{0x0000000000000002L});
1906     public static final BitSet FOLLOW_37_in_function294 = new BitSet(new long[]{0x0000000000000002L});
1907     public static final BitSet FOLLOW_38_in_function299 = new BitSet(new long[]{0x0000000000000002L});
1908     public static final BitSet FOLLOW_39_in_function303 = new BitSet(new long[]{0x0000000000000002L});
1909     public static final BitSet FOLLOW_40_in_function307 = new BitSet(new long[]{0x0000000000000002L});
1910     public static final BitSet FOLLOW_41_in_function311 = new BitSet(new long[]{0x0000000000000002L});
1911     public static final BitSet FOLLOW_42_in_function315 = new BitSet(new long[]{0x0000000000000002L});
1912     public static final BitSet FOLLOW_43_in_function319 = new BitSet(new long[]{0x0000000000000002L});
1913     public static final BitSet FOLLOW_44_in_function323 = new BitSet(new long[]{0x0000000000000002L});
1914     public static final BitSet FOLLOW_45_in_function327 = new BitSet(new long[]{0x0000000000000002L});
1915     public static final BitSet FOLLOW_46_in_function332 = new BitSet(new long[]{0x0000000000000002L});
1916     public static final BitSet FOLLOW_47_in_function336 = new BitSet(new long[]{0x0000000000000002L});
1917     public static final BitSet FOLLOW_48_in_function340 = new BitSet(new long[]{0x0000000000000002L});
1918     public static final BitSet FOLLOW_49_in_function344 = new BitSet(new long[]{0x0000000000000002L});
1919     public static final BitSet FOLLOW_50_in_function348 = new BitSet(new long[]{0x0000000000000002L});
1920     public static final BitSet FOLLOW_51_in_function352 = new BitSet(new long[]{0x0000000000000002L});
1921     public static final BitSet FOLLOW_52_in_function356 = new BitSet(new long[]{0x0000000000000002L});
1922     public static final BitSet FOLLOW_53_in_function360 = new BitSet(new long[]{0x0000000000000002L});
1923     public static final BitSet FOLLOW_54_in_function364 = new BitSet(new long[]{0x0000000000000002L});
1924     public static final BitSet FOLLOW_55_in_function369 = new BitSet(new long[]{0x0000000000000002L});
1925     public static final BitSet FOLLOW_56_in_function373 = new BitSet(new long[]{0x0000000000000002L});
1926     public static final BitSet FOLLOW_57_in_function377 = new BitSet(new long[]{0x0000000000000002L});
1927     public static final BitSet FOLLOW_58_in_function381 = new BitSet(new long[]{0x0000000000000002L});
1928     public static final BitSet FOLLOW_59_in_function385 = new BitSet(new long[]{0x0000000000000002L});
1929     public static final BitSet FOLLOW_60_in_function389 = new BitSet(new long[]{0x0000000000000002L});
1930     public static final BitSet FOLLOW_61_in_function393 = new BitSet(new long[]{0x0000000000000002L});
1931     public static final BitSet FOLLOW_62_in_function397 = new BitSet(new long[]{0x0000000000000002L});
1932     public static final BitSet FOLLOW_63_in_function402 = new BitSet(new long[]{0x0000000000000002L});
1933     public static final BitSet FOLLOW_identifier_in_function406 = new BitSet(new long[]{0x0000000000000002L});
1934     public static final BitSet FOLLOW_25_in_stack417 = new BitSet(new long[]{0xFFFFFFFFFA1C1000L});
1935     public static final BitSet FOLLOW_stackitem_in_stack419 = new BitSet(new long[]{0xFFFFFFFFFE1C1000L});
1936     public static final BitSet FOLLOW_26_in_stack422 = new BitSet(new long[]{0x0000000000000002L});
1937     public static final BitSet FOLLOW_function_in_stackitem441 = new BitSet(new long[]{0x0000000000000002L});
1938     public static final BitSet FOLLOW_STRING_in_stackitem446 = new BitSet(new long[]{0x0000000000000002L});
1939     public static final BitSet FOLLOW_INTEGER_in_stackitem452 = new BitSet(new long[]{0x0000000000000002L});
1940     public static final BitSet FOLLOW_QUOTED_in_stackitem458 = new BitSet(new long[]{0x0000000000000002L});
1941     public static final BitSet FOLLOW_stack_in_stackitem463 = new BitSet(new long[]{0x0000000000000002L});
1942
1943 }