001// $ANTLR 2.7.7 (20060906): "EntityParser.g" -> "EntityParser.java"$
002
003package org.apache.commons.flatfile.dsl;
004
005import java.io.IOException;
006import java.util.Map;
007
008import org.apache.commons.flatfile.*;
009
010import antlr.TokenBuffer;
011import antlr.TokenStreamException;
012import antlr.TokenStreamIOException;
013import antlr.ANTLRException;
014import antlr.LLkParser;
015import antlr.Token;
016import antlr.TokenStream;
017import antlr.RecognitionException;
018import antlr.NoViableAltException;
019import antlr.MismatchedTokenException;
020import antlr.SemanticException;
021import antlr.ParserSharedInputState;
022import antlr.collections.impl.BitSet;
023import antlr.collections.AST;
024import java.util.Hashtable;
025import antlr.ASTFactory;
026import antlr.ASTPair;
027import antlr.collections.impl.ASTArray;
028
029public class EntityParser extends antlr.LLkParser       implements EntityTokenTypes
030 {
031
032protected EntityParser(TokenBuffer tokenBuf, int k) {
033  super(tokenBuf,k);
034  tokenNames = _tokenNames;
035  buildTokenTypeASTClassMap();
036  astFactory = new ASTFactory(getTokenTypeToASTClassMap());
037}
038
039public EntityParser(TokenBuffer tokenBuf) {
040  this(tokenBuf,2);
041}
042
043protected EntityParser(TokenStream lexer, int k) {
044  super(lexer,k);
045  tokenNames = _tokenNames;
046  buildTokenTypeASTClassMap();
047  astFactory = new ASTFactory(getTokenTypeToASTClassMap());
048}
049
050public EntityParser(TokenStream lexer) {
051  this(lexer,2);
052}
053
054public EntityParser(ParserSharedInputState state) {
055  super(state,2);
056  tokenNames = _tokenNames;
057  buildTokenTypeASTClassMap();
058  astFactory = new ASTFactory(getTokenTypeToASTClassMap());
059}
060
061        public final void parse() throws RecognitionException, TokenStreamException {
062                
063                returnAST = null;
064                ASTPair currentAST = new ASTPair();
065                AST parse_AST = null;
066                
067                {
068                _loop3:
069                do {
070                        if ((LA(1)==OPTION_BLOCK)) {
071                                optionBlock();
072                                astFactory.addASTChild(currentAST, returnAST);
073                        }
074                        else {
075                                break _loop3;
076                        }
077                        
078                } while (true);
079                }
080                {
081                int _cnt6=0;
082                _loop6:
083                do {
084                        if ((LA(1)==IDENT)) {
085                                explicitAssign();
086                                astFactory.addASTChild(currentAST, returnAST);
087                                {
088                                switch ( LA(1)) {
089                                case COLON:
090                                {
091                                        lengthcheck();
092                                        astFactory.addASTChild(currentAST, returnAST);
093                                        break;
094                                }
095                                case EOF:
096                                case IDENT:
097                                {
098                                        break;
099                                }
100                                default:
101                                {
102                                        throw new NoViableAltException(LT(1), getFilename());
103                                }
104                                }
105                                }
106                        }
107                        else {
108                                if ( _cnt6>=1 ) { break _loop6; } else {throw new NoViableAltException(LT(1), getFilename());}
109                        }
110                        
111                        _cnt6++;
112                } while (true);
113                }
114                match(Token.EOF_TYPE);
115                parse_AST = (AST)currentAST.root;
116                parse_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(ROOT,"root")).add(parse_AST));
117                currentAST.root = parse_AST;
118                currentAST.child = parse_AST!=null &&parse_AST.getFirstChild()!=null ?
119                        parse_AST.getFirstChild() : parse_AST;
120                currentAST.advanceChildToEnd();
121                parse_AST = (AST)currentAST.root;
122                returnAST = parse_AST;
123        }
124        
125        protected final void optionBlock() throws RecognitionException, TokenStreamException {
126                
127                returnAST = null;
128                ASTPair currentAST = new ASTPair();
129                AST optionBlock_AST = null;
130                Token  o = null;
131                AST o_AST = null;
132                
133                o = LT(1);
134                o_AST = astFactory.create(o);
135                astFactory.makeASTRoot(currentAST, o_AST);
136                match(OPTION_BLOCK);
137                o_AST.setType(OPTIONS);
138                {
139                int _cnt9=0;
140                _loop9:
141                do {
142                        if ((_tokenSet_0.member(LA(1)))) {
143                                entityOption();
144                                astFactory.addASTChild(currentAST, returnAST);
145                        }
146                        else {
147                                if ( _cnt9>=1 ) { break _loop9; } else {throw new NoViableAltException(LT(1), getFilename());}
148                        }
149                        
150                        _cnt9++;
151                } while (true);
152                }
153                match(SEMI);
154                optionBlock_AST = (AST)currentAST.root;
155                returnAST = optionBlock_AST;
156        }
157        
158        protected final void explicitAssign() throws RecognitionException, TokenStreamException {
159                
160                returnAST = null;
161                ASTPair currentAST = new ASTPair();
162                AST explicitAssign_AST = null;
163                
164                AST tmp3_AST = null;
165                tmp3_AST = astFactory.create(LT(1));
166                astFactory.addASTChild(currentAST, tmp3_AST);
167                match(IDENT);
168                entity();
169                astFactory.addASTChild(currentAST, returnAST);
170                explicitAssign_AST = (AST)currentAST.root;
171                explicitAssign_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(ASSIGN,"=")).add(explicitAssign_AST));
172                currentAST.root = explicitAssign_AST;
173                currentAST.child = explicitAssign_AST!=null &&explicitAssign_AST.getFirstChild()!=null ?
174                        explicitAssign_AST.getFirstChild() : explicitAssign_AST;
175                currentAST.advanceChildToEnd();
176                explicitAssign_AST = (AST)currentAST.root;
177                returnAST = explicitAssign_AST;
178        }
179        
180        protected final void lengthcheck() throws RecognitionException, TokenStreamException {
181                
182                returnAST = null;
183                ASTPair currentAST = new ASTPair();
184                AST lengthcheck_AST = null;
185                Token  c = null;
186                AST c_AST = null;
187                
188                c = LT(1);
189                c_AST = astFactory.create(c);
190                astFactory.addASTChild(currentAST, c_AST);
191                match(COLON);
192                c_AST.setType(CHECK);
193                length();
194                astFactory.addASTChild(currentAST, returnAST);
195                lengthcheck_AST = (AST)currentAST.root;
196                returnAST = lengthcheck_AST;
197        }
198        
199        protected final void entityOption() throws RecognitionException, TokenStreamException {
200                
201                returnAST = null;
202                ASTPair currentAST = new ASTPair();
203                AST entityOption_AST = null;
204                
205                {
206                switch ( LA(1)) {
207                case IDENT:
208                {
209                        AST tmp4_AST = null;
210                        tmp4_AST = astFactory.create(LT(1));
211                        astFactory.addASTChild(currentAST, tmp4_AST);
212                        match(IDENT);
213                        break;
214                }
215                case STRING_LITERAL:
216                {
217                        AST tmp5_AST = null;
218                        tmp5_AST = astFactory.create(LT(1));
219                        astFactory.addASTChild(currentAST, tmp5_AST);
220                        match(STRING_LITERAL);
221                        break;
222                }
223                case CHAR_LITERAL:
224                {
225                        AST tmp6_AST = null;
226                        tmp6_AST = astFactory.create(LT(1));
227                        astFactory.addASTChild(currentAST, tmp6_AST);
228                        match(CHAR_LITERAL);
229                        break;
230                }
231                case NUMBER:
232                {
233                        AST tmp7_AST = null;
234                        tmp7_AST = astFactory.create(LT(1));
235                        astFactory.addASTChild(currentAST, tmp7_AST);
236                        match(NUMBER);
237                        break;
238                }
239                default:
240                {
241                        throw new NoViableAltException(LT(1), getFilename());
242                }
243                }
244                }
245                AST tmp8_AST = null;
246                tmp8_AST = astFactory.create(LT(1));
247                astFactory.makeASTRoot(currentAST, tmp8_AST);
248                match(ASSIGN);
249                {
250                switch ( LA(1)) {
251                case IDENT:
252                {
253                        AST tmp9_AST = null;
254                        tmp9_AST = astFactory.create(LT(1));
255                        astFactory.addASTChild(currentAST, tmp9_AST);
256                        match(IDENT);
257                        break;
258                }
259                case STRING_LITERAL:
260                {
261                        AST tmp10_AST = null;
262                        tmp10_AST = astFactory.create(LT(1));
263                        astFactory.addASTChild(currentAST, tmp10_AST);
264                        match(STRING_LITERAL);
265                        break;
266                }
267                case CHAR_LITERAL:
268                {
269                        AST tmp11_AST = null;
270                        tmp11_AST = astFactory.create(LT(1));
271                        astFactory.addASTChild(currentAST, tmp11_AST);
272                        match(CHAR_LITERAL);
273                        break;
274                }
275                case NUMBER:
276                {
277                        AST tmp12_AST = null;
278                        tmp12_AST = astFactory.create(LT(1));
279                        astFactory.addASTChild(currentAST, tmp12_AST);
280                        match(NUMBER);
281                        break;
282                }
283                default:
284                {
285                        throw new NoViableAltException(LT(1), getFilename());
286                }
287                }
288                }
289                entityOption_AST = (AST)currentAST.root;
290                returnAST = entityOption_AST;
291        }
292        
293        protected final void entity() throws RecognitionException, TokenStreamException {
294                
295                returnAST = null;
296                ASTPair currentAST = new ASTPair();
297                AST entity_AST = null;
298                String junk = null;
299                
300                switch ( LA(1)) {
301                case CHAR_LITERAL:
302                case STRING_LITERAL:
303                {
304                        valueOnlyEntity();
305                        astFactory.addASTChild(currentAST, returnAST);
306                        entity_AST = (AST)currentAST.root;
307                        break;
308                }
309                case TYPEREF:
310                {
311                        junk=typeRefEntity();
312                        astFactory.addASTChild(currentAST, returnAST);
313                        entity_AST = (AST)currentAST.root;
314                        break;
315                }
316                case LPAREN:
317                case LCURLY:
318                {
319                        fieldOrMapEntity();
320                        astFactory.addASTChild(currentAST, returnAST);
321                        entity_AST = (AST)currentAST.root;
322                        break;
323                }
324                default:
325                {
326                        throw new NoViableAltException(LT(1), getFilename());
327                }
328                }
329                returnAST = entity_AST;
330        }
331        
332        protected final void anonymousAssign() throws RecognitionException, TokenStreamException {
333                
334                returnAST = null;
335                ASTPair currentAST = new ASTPair();
336                AST anonymousAssign_AST = null;
337                
338                AST tmp13_AST = null;
339                tmp13_AST = astFactory.create(LT(1));
340                astFactory.addASTChild(currentAST, tmp13_AST);
341                match(ANON);
342                entity();
343                astFactory.addASTChild(currentAST, returnAST);
344                anonymousAssign_AST = (AST)currentAST.root;
345                anonymousAssign_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(ASSIGN,"=")).add(anonymousAssign_AST));
346                currentAST.root = anonymousAssign_AST;
347                currentAST.child = anonymousAssign_AST!=null &&anonymousAssign_AST.getFirstChild()!=null ?
348                        anonymousAssign_AST.getFirstChild() : anonymousAssign_AST;
349                currentAST.advanceChildToEnd();
350                anonymousAssign_AST = (AST)currentAST.root;
351                returnAST = anonymousAssign_AST;
352        }
353        
354        protected final void length() throws RecognitionException, TokenStreamException {
355                
356                returnAST = null;
357                ASTPair currentAST = new ASTPair();
358                AST length_AST = null;
359                Token  n = null;
360                AST n_AST = null;
361                
362                n = LT(1);
363                n_AST = astFactory.create(n);
364                astFactory.addASTChild(currentAST, n_AST);
365                match(NUMBER);
366                n_AST.setType(LENGTH);
367                length_AST = (AST)currentAST.root;
368                returnAST = length_AST;
369        }
370        
371        protected final void valueOnlyEntity() throws RecognitionException, TokenStreamException {
372                
373                returnAST = null;
374                ASTPair currentAST = new ASTPair();
375                AST valueOnlyEntity_AST = null;
376                AST a_AST = null;
377                AST ast = null;
378                
379                explicitValue();
380                astFactory.addASTChild(currentAST, returnAST);
381                valueOnlyEntity_AST = (AST)currentAST.root;
382                valueOnlyEntity_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(FIELD,"field")).add(valueOnlyEntity_AST)); ast = valueOnlyEntity_AST;
383                currentAST.root = valueOnlyEntity_AST;
384                currentAST.child = valueOnlyEntity_AST!=null &&valueOnlyEntity_AST.getFirstChild()!=null ?
385                        valueOnlyEntity_AST.getFirstChild() : valueOnlyEntity_AST;
386                currentAST.advanceChildToEnd();
387                {
388                switch ( LA(1)) {
389                case BANG:
390                {
391                        immutable();
392                        astFactory.addASTChild(currentAST, returnAST);
393                        break;
394                }
395                case EOF:
396                case IDENT:
397                case ANON:
398                case COLON:
399                case TYPEREF:
400                case LBRACK:
401                case COMMA:
402                case RCURLY:
403                {
404                        break;
405                }
406                default:
407                {
408                        throw new NoViableAltException(LT(1), getFilename());
409                }
410                }
411                }
412                {
413                switch ( LA(1)) {
414                case LBRACK:
415                {
416                        array(ast);
417                        a_AST = (AST)returnAST;
418                        valueOnlyEntity_AST = (AST)currentAST.root;
419                        valueOnlyEntity_AST = a_AST;
420                        currentAST.root = valueOnlyEntity_AST;
421                        currentAST.child = valueOnlyEntity_AST!=null &&valueOnlyEntity_AST.getFirstChild()!=null ?
422                                valueOnlyEntity_AST.getFirstChild() : valueOnlyEntity_AST;
423                        currentAST.advanceChildToEnd();
424                        break;
425                }
426                case EOF:
427                case IDENT:
428                case ANON:
429                case COLON:
430                case TYPEREF:
431                case COMMA:
432                case RCURLY:
433                {
434                        break;
435                }
436                default:
437                {
438                        throw new NoViableAltException(LT(1), getFilename());
439                }
440                }
441                }
442                valueOnlyEntity_AST = (AST)currentAST.root;
443                returnAST = valueOnlyEntity_AST;
444        }
445        
446        protected final String  typeRefEntity() throws RecognitionException, TokenStreamException {
447                String name;
448                
449                returnAST = null;
450                ASTPair currentAST = new ASTPair();
451                AST typeRefEntity_AST = null;
452                Token  t = null;
453                AST t_AST = null;
454                AST a_AST = null;
455                AST ast = null;
456                
457                {
458                t = LT(1);
459                t_AST = astFactory.create(t);
460                astFactory.makeASTRoot(currentAST, t_AST);
461                match(TYPEREF);
462                name = t.getText();
463                {
464                if ((_tokenSet_0.member(LA(1))) && (LA(2)==ASSIGN)) {
465                        entityOptions();
466                        astFactory.addASTChild(currentAST, returnAST);
467                }
468                else if ((_tokenSet_1.member(LA(1))) && (_tokenSet_2.member(LA(2)))) {
469                }
470                else {
471                        throw new NoViableAltException(LT(1), getFilename());
472                }
473                
474                }
475                {
476                switch ( LA(1)) {
477                case CHAR_LITERAL:
478                case STRING_LITERAL:
479                {
480                        value();
481                        astFactory.addASTChild(currentAST, returnAST);
482                        break;
483                }
484                case EOF:
485                case IDENT:
486                case ANON:
487                case COLON:
488                case TYPEREF:
489                case LBRACK:
490                case COMMA:
491                case RCURLY:
492                {
493                        break;
494                }
495                default:
496                {
497                        throw new NoViableAltException(LT(1), getFilename());
498                }
499                }
500                }
501                }
502                typeRefEntity_AST = (AST)currentAST.root;
503                ast = typeRefEntity_AST;
504                {
505                switch ( LA(1)) {
506                case LBRACK:
507                {
508                        array(ast);
509                        a_AST = (AST)returnAST;
510                        typeRefEntity_AST = (AST)currentAST.root;
511                        typeRefEntity_AST = a_AST;
512                        currentAST.root = typeRefEntity_AST;
513                        currentAST.child = typeRefEntity_AST!=null &&typeRefEntity_AST.getFirstChild()!=null ?
514                                typeRefEntity_AST.getFirstChild() : typeRefEntity_AST;
515                        currentAST.advanceChildToEnd();
516                        break;
517                }
518                case EOF:
519                case IDENT:
520                case ANON:
521                case COLON:
522                case TYPEREF:
523                case COMMA:
524                case RCURLY:
525                {
526                        break;
527                }
528                default:
529                {
530                        throw new NoViableAltException(LT(1), getFilename());
531                }
532                }
533                }
534                typeRefEntity_AST = (AST)currentAST.root;
535                returnAST = typeRefEntity_AST;
536                return name;
537        }
538        
539        protected final void fieldOrMapEntity() throws RecognitionException, TokenStreamException {
540                
541                returnAST = null;
542                ASTPair currentAST = new ASTPair();
543                AST fieldOrMapEntity_AST = null;
544                AST a_AST = null;
545                AST ast = null;
546                
547                {
548                switch ( LA(1)) {
549                case LPAREN:
550                {
551                        field();
552                        astFactory.addASTChild(currentAST, returnAST);
553                        break;
554                }
555                case LCURLY:
556                {
557                        map();
558                        astFactory.addASTChild(currentAST, returnAST);
559                        break;
560                }
561                default:
562                {
563                        throw new NoViableAltException(LT(1), getFilename());
564                }
565                }
566                }
567                fieldOrMapEntity_AST = (AST)currentAST.root;
568                ast = fieldOrMapEntity_AST;
569                {
570                switch ( LA(1)) {
571                case LBRACK:
572                {
573                        array(ast);
574                        a_AST = (AST)returnAST;
575                        fieldOrMapEntity_AST = (AST)currentAST.root;
576                        fieldOrMapEntity_AST = a_AST;
577                        currentAST.root = fieldOrMapEntity_AST;
578                        currentAST.child = fieldOrMapEntity_AST!=null &&fieldOrMapEntity_AST.getFirstChild()!=null ?
579                                fieldOrMapEntity_AST.getFirstChild() : fieldOrMapEntity_AST;
580                        currentAST.advanceChildToEnd();
581                        break;
582                }
583                case EOF:
584                case IDENT:
585                case ANON:
586                case COLON:
587                case TYPEREF:
588                case COMMA:
589                case RCURLY:
590                {
591                        break;
592                }
593                default:
594                {
595                        throw new NoViableAltException(LT(1), getFilename());
596                }
597                }
598                }
599                fieldOrMapEntity_AST = (AST)currentAST.root;
600                returnAST = fieldOrMapEntity_AST;
601        }
602        
603        protected final void explicitValue() throws RecognitionException, TokenStreamException {
604                
605                returnAST = null;
606                ASTPair currentAST = new ASTPair();
607                AST explicitValue_AST = null;
608                Token  c = null;
609                AST c_AST = null;
610                Token  s = null;
611                AST s_AST = null;
612                
613                switch ( LA(1)) {
614                case CHAR_LITERAL:
615                {
616                        c = LT(1);
617                        c_AST = astFactory.create(c);
618                        astFactory.addASTChild(currentAST, c_AST);
619                        match(CHAR_LITERAL);
620                        c_AST.setType(VALUE);
621                        explicitValue_AST = (AST)currentAST.root;
622                        break;
623                }
624                case STRING_LITERAL:
625                {
626                        s = LT(1);
627                        s_AST = astFactory.create(s);
628                        astFactory.addASTChild(currentAST, s_AST);
629                        match(STRING_LITERAL);
630                        s_AST.setType(VALUE);
631                        explicitValue_AST = (AST)currentAST.root;
632                        break;
633                }
634                default:
635                {
636                        throw new NoViableAltException(LT(1), getFilename());
637                }
638                }
639                returnAST = explicitValue_AST;
640        }
641        
642        protected final void immutable() throws RecognitionException, TokenStreamException {
643                
644                returnAST = null;
645                ASTPair currentAST = new ASTPair();
646                AST immutable_AST = null;
647                Token  b = null;
648                AST b_AST = null;
649                
650                b = LT(1);
651                b_AST = astFactory.create(b);
652                astFactory.addASTChild(currentAST, b_AST);
653                match(BANG);
654                b_AST.setType(IMMUTABLE);
655                immutable_AST = (AST)currentAST.root;
656                returnAST = immutable_AST;
657        }
658        
659        protected final void array(
660                AST p
661        ) throws RecognitionException, TokenStreamException {
662                
663                returnAST = null;
664                ASTPair currentAST = new ASTPair();
665                AST array_AST = null;
666                Token  a = null;
667                AST a_AST = null;
668                AST o_AST = null;
669                AST v_AST = null;
670                
671                a = LT(1);
672                a_AST = astFactory.create(a);
673                astFactory.makeASTRoot(currentAST, a_AST);
674                match(LBRACK);
675                a_AST.setType(ARRAY);
676                {
677                switch ( LA(1)) {
678                case NUMBER:
679                case RANGE:
680                {
681                        arrayLength();
682                        astFactory.addASTChild(currentAST, returnAST);
683                        break;
684                }
685                case RBRACK:
686                {
687                        break;
688                }
689                default:
690                {
691                        throw new NoViableAltException(LT(1), getFilename());
692                }
693                }
694                }
695                match(RBRACK);
696                array_AST = (AST)currentAST.root;
697                array_AST.addChild((AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(PROTOTYPE,"prototype")).add(p)));
698                {
699                if ((_tokenSet_0.member(LA(1))) && (LA(2)==ASSIGN)) {
700                        entityOptions();
701                        o_AST = (AST)returnAST;
702                        array_AST = (AST)currentAST.root;
703                        array_AST.addChild(o_AST);
704                }
705                else if ((_tokenSet_3.member(LA(1))) && (_tokenSet_4.member(LA(2)))) {
706                }
707                else {
708                        throw new NoViableAltException(LT(1), getFilename());
709                }
710                
711                }
712                {
713                switch ( LA(1)) {
714                case CHAR_LITERAL:
715                case STRING_LITERAL:
716                {
717                        value();
718                        v_AST = (AST)returnAST;
719                        array_AST = (AST)currentAST.root;
720                        array_AST.addChild(v_AST);
721                        break;
722                }
723                case EOF:
724                case IDENT:
725                case ANON:
726                case COLON:
727                case TYPEREF:
728                case COMMA:
729                case RCURLY:
730                {
731                        break;
732                }
733                default:
734                {
735                        throw new NoViableAltException(LT(1), getFilename());
736                }
737                }
738                }
739                array_AST = (AST)currentAST.root;
740                returnAST = array_AST;
741        }
742        
743        protected final void entityOptions() throws RecognitionException, TokenStreamException {
744                
745                returnAST = null;
746                ASTPair currentAST = new ASTPair();
747                AST entityOptions_AST = null;
748                
749                {
750                int _cnt53=0;
751                _loop53:
752                do {
753                        if ((_tokenSet_0.member(LA(1))) && (LA(2)==ASSIGN)) {
754                                entityOption();
755                                astFactory.addASTChild(currentAST, returnAST);
756                        }
757                        else {
758                                if ( _cnt53>=1 ) { break _loop53; } else {throw new NoViableAltException(LT(1), getFilename());}
759                        }
760                        
761                        _cnt53++;
762                } while (true);
763                }
764                entityOptions_AST = (AST)currentAST.root;
765                entityOptions_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(OPTIONS,"options")).add(entityOptions_AST));
766                currentAST.root = entityOptions_AST;
767                currentAST.child = entityOptions_AST!=null &&entityOptions_AST.getFirstChild()!=null ?
768                        entityOptions_AST.getFirstChild() : entityOptions_AST;
769                currentAST.advanceChildToEnd();
770                entityOptions_AST = (AST)currentAST.root;
771                returnAST = entityOptions_AST;
772        }
773        
774        protected final void value() throws RecognitionException, TokenStreamException {
775                
776                returnAST = null;
777                ASTPair currentAST = new ASTPair();
778                AST value_AST = null;
779                
780                {
781                if ((LA(1)==CHAR_LITERAL) && (LA(2)==STAR)) {
782                        fillValue();
783                        astFactory.addASTChild(currentAST, returnAST);
784                }
785                else if ((LA(1)==CHAR_LITERAL||LA(1)==STRING_LITERAL) && (_tokenSet_5.member(LA(2)))) {
786                        explicitValue();
787                        astFactory.addASTChild(currentAST, returnAST);
788                }
789                else {
790                        throw new NoViableAltException(LT(1), getFilename());
791                }
792                
793                }
794                {
795                switch ( LA(1)) {
796                case BANG:
797                {
798                        immutable();
799                        astFactory.addASTChild(currentAST, returnAST);
800                        break;
801                }
802                case EOF:
803                case IDENT:
804                case ANON:
805                case COLON:
806                case TYPEREF:
807                case LBRACK:
808                case COMMA:
809                case RCURLY:
810                {
811                        break;
812                }
813                default:
814                {
815                        throw new NoViableAltException(LT(1), getFilename());
816                }
817                }
818                }
819                value_AST = (AST)currentAST.root;
820                returnAST = value_AST;
821        }
822        
823        protected final void field() throws RecognitionException, TokenStreamException {
824                
825                returnAST = null;
826                ASTPair currentAST = new ASTPair();
827                AST field_AST = null;
828                
829                match(LPAREN);
830                {
831                switch ( LA(1)) {
832                case NUMBER:
833                case RANGE:
834                {
835                        arrayLength();
836                        astFactory.addASTChild(currentAST, returnAST);
837                        break;
838                }
839                case STAR:
840                {
841                        unboundedDynamicField();
842                        astFactory.addASTChild(currentAST, returnAST);
843                        break;
844                }
845                default:
846                {
847                        throw new NoViableAltException(LT(1), getFilename());
848                }
849                }
850                }
851                match(RPAREN);
852                {
853                if ((_tokenSet_0.member(LA(1))) && (LA(2)==ASSIGN)) {
854                        entityOptions();
855                        astFactory.addASTChild(currentAST, returnAST);
856                }
857                else if ((_tokenSet_1.member(LA(1))) && (_tokenSet_2.member(LA(2)))) {
858                }
859                else {
860                        throw new NoViableAltException(LT(1), getFilename());
861                }
862                
863                }
864                {
865                switch ( LA(1)) {
866                case CHAR_LITERAL:
867                case STRING_LITERAL:
868                {
869                        value();
870                        astFactory.addASTChild(currentAST, returnAST);
871                        break;
872                }
873                case EOF:
874                case IDENT:
875                case ANON:
876                case COLON:
877                case TYPEREF:
878                case LBRACK:
879                case COMMA:
880                case RCURLY:
881                {
882                        break;
883                }
884                default:
885                {
886                        throw new NoViableAltException(LT(1), getFilename());
887                }
888                }
889                }
890                field_AST = (AST)currentAST.root;
891                field_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(FIELD,"field")).add(field_AST));
892                currentAST.root = field_AST;
893                currentAST.child = field_AST!=null &&field_AST.getFirstChild()!=null ?
894                        field_AST.getFirstChild() : field_AST;
895                currentAST.advanceChildToEnd();
896                field_AST = (AST)currentAST.root;
897                returnAST = field_AST;
898        }
899        
900        protected final void map() throws RecognitionException, TokenStreamException {
901                
902                returnAST = null;
903                ASTPair currentAST = new ASTPair();
904                AST map_AST = null;
905                Token  m = null;
906                AST m_AST = null;
907                
908                m = LT(1);
909                m_AST = astFactory.create(m);
910                astFactory.makeASTRoot(currentAST, m_AST);
911                match(LCURLY);
912                m_AST.setType(MAP);
913                mapChild();
914                astFactory.addASTChild(currentAST, returnAST);
915                {
916                _loop42:
917                do {
918                        if ((_tokenSet_6.member(LA(1)))) {
919                                {
920                                switch ( LA(1)) {
921                                case COMMA:
922                                {
923                                        match(COMMA);
924                                        break;
925                                }
926                                case IDENT:
927                                case ANON:
928                                case TYPEREF:
929                                {
930                                        break;
931                                }
932                                default:
933                                {
934                                        throw new NoViableAltException(LT(1), getFilename());
935                                }
936                                }
937                                }
938                                mapChild();
939                                astFactory.addASTChild(currentAST, returnAST);
940                        }
941                        else {
942                                break _loop42;
943                        }
944                        
945                } while (true);
946                }
947                match(RCURLY);
948                {
949                if ((_tokenSet_0.member(LA(1))) && (LA(2)==ASSIGN)) {
950                        entityOptions();
951                        astFactory.addASTChild(currentAST, returnAST);
952                }
953                else if ((_tokenSet_1.member(LA(1))) && (_tokenSet_2.member(LA(2)))) {
954                }
955                else {
956                        throw new NoViableAltException(LT(1), getFilename());
957                }
958                
959                }
960                {
961                switch ( LA(1)) {
962                case CHAR_LITERAL:
963                case STRING_LITERAL:
964                {
965                        value();
966                        astFactory.addASTChild(currentAST, returnAST);
967                        break;
968                }
969                case EOF:
970                case IDENT:
971                case ANON:
972                case COLON:
973                case TYPEREF:
974                case LBRACK:
975                case COMMA:
976                case RCURLY:
977                {
978                        break;
979                }
980                default:
981                {
982                        throw new NoViableAltException(LT(1), getFilename());
983                }
984                }
985                }
986                map_AST = (AST)currentAST.root;
987                returnAST = map_AST;
988        }
989        
990        protected final void arrayLength() throws RecognitionException, TokenStreamException {
991                
992                returnAST = null;
993                ASTPair currentAST = new ASTPair();
994                AST arrayLength_AST = null;
995                Token  n = null;
996                AST n_AST = null;
997                Token  n2 = null;
998                AST n2_AST = null;
999                Token  n3 = null;
1000                AST n3_AST = null;
1001                
1002                if ((LA(1)==NUMBER) && (LA(2)==RANGE)) {
1003                        n = LT(1);
1004                        n_AST = astFactory.create(n);
1005                        astFactory.addASTChild(currentAST, n_AST);
1006                        match(NUMBER);
1007                        n_AST.setType(MIN);
1008                        AST tmp19_AST = null;
1009                        tmp19_AST = astFactory.create(LT(1));
1010                        astFactory.makeASTRoot(currentAST, tmp19_AST);
1011                        match(RANGE);
1012                        {
1013                        switch ( LA(1)) {
1014                        case NUMBER:
1015                        {
1016                                n2 = LT(1);
1017                                n2_AST = astFactory.create(n2);
1018                                astFactory.addASTChild(currentAST, n2_AST);
1019                                match(NUMBER);
1020                                n2_AST.setType(MAX);
1021                                break;
1022                        }
1023                        case RBRACK:
1024                        case RPAREN:
1025                        {
1026                                break;
1027                        }
1028                        default:
1029                        {
1030                                throw new NoViableAltException(LT(1), getFilename());
1031                        }
1032                        }
1033                        }
1034                        arrayLength_AST = (AST)currentAST.root;
1035                }
1036                else if ((LA(1)==RANGE)) {
1037                        AST tmp20_AST = null;
1038                        tmp20_AST = astFactory.create(LT(1));
1039                        astFactory.makeASTRoot(currentAST, tmp20_AST);
1040                        match(RANGE);
1041                        n3 = LT(1);
1042                        n3_AST = astFactory.create(n3);
1043                        astFactory.addASTChild(currentAST, n3_AST);
1044                        match(NUMBER);
1045                        n3_AST.setType(MAX);
1046                        arrayLength_AST = (AST)currentAST.root;
1047                }
1048                else if ((LA(1)==NUMBER) && (LA(2)==RBRACK||LA(2)==RPAREN)) {
1049                        length();
1050                        astFactory.addASTChild(currentAST, returnAST);
1051                        arrayLength_AST = (AST)currentAST.root;
1052                }
1053                else {
1054                        throw new NoViableAltException(LT(1), getFilename());
1055                }
1056                
1057                returnAST = arrayLength_AST;
1058        }
1059        
1060        protected final void fillValue() throws RecognitionException, TokenStreamException {
1061                
1062                returnAST = null;
1063                ASTPair currentAST = new ASTPair();
1064                AST fillValue_AST = null;
1065                Token  c = null;
1066                AST c_AST = null;
1067                
1068                c = LT(1);
1069                c_AST = astFactory.create(c);
1070                astFactory.addASTChild(currentAST, c_AST);
1071                match(CHAR_LITERAL);
1072                match(STAR);
1073                c_AST.setType(ALL);
1074                fillValue_AST = (AST)currentAST.root;
1075                returnAST = fillValue_AST;
1076        }
1077        
1078        protected final void unboundedDynamicField() throws RecognitionException, TokenStreamException {
1079                
1080                returnAST = null;
1081                ASTPair currentAST = new ASTPair();
1082                AST unboundedDynamicField_AST = null;
1083                Token  s = null;
1084                AST s_AST = null;
1085                
1086                s = LT(1);
1087                s_AST = astFactory.create(s);
1088                astFactory.makeASTRoot(currentAST, s_AST);
1089                match(STAR);
1090                s_AST.setType(RANGE);
1091                unboundedDynamicField_AST = (AST)currentAST.root;
1092                returnAST = unboundedDynamicField_AST;
1093        }
1094        
1095        protected final void mapChild() throws RecognitionException, TokenStreamException {
1096                
1097                returnAST = null;
1098                ASTPair currentAST = new ASTPair();
1099                AST mapChild_AST = null;
1100                
1101                switch ( LA(1)) {
1102                case IDENT:
1103                {
1104                        explicitAssign();
1105                        astFactory.addASTChild(currentAST, returnAST);
1106                        mapChild_AST = (AST)currentAST.root;
1107                        break;
1108                }
1109                case ANON:
1110                {
1111                        anonymousAssign();
1112                        astFactory.addASTChild(currentAST, returnAST);
1113                        mapChild_AST = (AST)currentAST.root;
1114                        break;
1115                }
1116                case TYPEREF:
1117                {
1118                        implicitTypeAssign();
1119                        astFactory.addASTChild(currentAST, returnAST);
1120                        mapChild_AST = (AST)currentAST.root;
1121                        break;
1122                }
1123                default:
1124                {
1125                        throw new NoViableAltException(LT(1), getFilename());
1126                }
1127                }
1128                returnAST = mapChild_AST;
1129        }
1130        
1131        protected final void implicitTypeAssign() throws RecognitionException, TokenStreamException {
1132                
1133                returnAST = null;
1134                ASTPair currentAST = new ASTPair();
1135                AST implicitTypeAssign_AST = null;
1136                String name = null;
1137                
1138                name=typeRefEntity();
1139                astFactory.addASTChild(currentAST, returnAST);
1140                implicitTypeAssign_AST = (AST)currentAST.root;
1141                implicitTypeAssign_AST = (AST)astFactory.make( (new ASTArray(3)).add(astFactory.create(ASSIGN)).add(astFactory.create(IDENT,name)).add(implicitTypeAssign_AST));
1142                currentAST.root = implicitTypeAssign_AST;
1143                currentAST.child = implicitTypeAssign_AST!=null &&implicitTypeAssign_AST.getFirstChild()!=null ?
1144                        implicitTypeAssign_AST.getFirstChild() : implicitTypeAssign_AST;
1145                currentAST.advanceChildToEnd();
1146                implicitTypeAssign_AST = (AST)currentAST.root;
1147                returnAST = implicitTypeAssign_AST;
1148        }
1149        
1150        
1151        public static final String[] _tokenNames = {
1152                "<0>",
1153                "EOF",
1154                "<2>",
1155                "NULL_TREE_LOOKAHEAD",
1156                "ROOT",
1157                "CHECK",
1158                "VALUE",
1159                "ALL",
1160                "FIELD",
1161                "LENGTH",
1162                "ARRAY",
1163                "IMMUTABLE",
1164                "MAP",
1165                "PROTOTYPE",
1166                "OPTIONS",
1167                "MIN",
1168                "MAX",
1169                "OPTION_BLOCK",
1170                "SEMI",
1171                "IDENT",
1172                "ANON",
1173                "COLON",
1174                "TYPEREF",
1175                "LBRACK",
1176                "RBRACK",
1177                "CHAR_LITERAL",
1178                "STAR",
1179                "STRING_LITERAL",
1180                "BANG",
1181                "LPAREN",
1182                "RPAREN",
1183                "LCURLY",
1184                "COMMA",
1185                "RCURLY",
1186                "NUMBER",
1187                "RANGE",
1188                "ASSIGN",
1189                "WS",
1190                "SL_COMMENT",
1191                "ML_COMMENT",
1192                "NL",
1193                "PTIDENT",
1194                "CHAR_BODY",
1195                "STRING_BODY",
1196                "ESC",
1197                "UNICODE",
1198                "OCTAL",
1199                "HEX_DIGIT"
1200        };
1201        
1202        protected void buildTokenTypeASTClassMap() {
1203                tokenTypeToASTClassMap=null;
1204        };
1205        
1206        private static final long[] mk_tokenSet_0() {
1207                long[] data = { 17348165632L, 0L};
1208                return data;
1209        }
1210        public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
1211        private static final long[] mk_tokenSet_1() {
1212                long[] data = { 13068926978L, 0L};
1213                return data;
1214        }
1215        public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
1216        private static final long[] mk_tokenSet_2() {
1217                long[] data = { 67645210626L, 0L};
1218                return data;
1219        }
1220        public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
1221        private static final long[] mk_tokenSet_3() {
1222                long[] data = { 13060538370L, 0L};
1223                return data;
1224        }
1225        public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3());
1226        private static final long[] mk_tokenSet_4() {
1227                long[] data = { 33268695042L, 0L};
1228                return data;
1229        }
1230        public static final BitSet _tokenSet_4 = new BitSet(mk_tokenSet_4());
1231        private static final long[] mk_tokenSet_5() {
1232                long[] data = { 13169590274L, 0L};
1233                return data;
1234        }
1235        public static final BitSet _tokenSet_5 = new BitSet(mk_tokenSet_5());
1236        private static final long[] mk_tokenSet_6() {
1237                long[] data = { 4300734464L, 0L};
1238                return data;
1239        }
1240        public static final BitSet _tokenSet_6 = new BitSet(mk_tokenSet_6());
1241        
1242        }