001// $ANTLR 2.7.7 (20060906): "EntityTreeParser.g" -> "EntityTreeParser.java"$
002
003package org.apache.commons.flatfile.dsl;
004
005import java.io.IOException;
006
007import java.util.List;
008import java.util.Stack;
009import java.util.Iterator;
010import java.util.ArrayList;
011import java.util.HashMap;
012
013import org.apache.commons.flatfile.*;
014import org.apache.commons.flatfile.util.ApplyOptions;
015
016import antlr.TreeParser;
017import antlr.Token;
018import antlr.collections.AST;
019import antlr.RecognitionException;
020import antlr.ANTLRException;
021import antlr.NoViableAltException;
022import antlr.MismatchedTokenException;
023import antlr.SemanticException;
024import antlr.collections.impl.BitSet;
025import antlr.ASTPair;
026import antlr.collections.impl.ASTArray;
027
028
029public class EntityTreeParser extends antlr.TreeParser       implements EntityTreeParserTokenTypes
030 {
031
032        private java.lang.ref.WeakReference<ParserEntityFactory> entityFactoryRef;
033        private Stack<String> stk = new Stack<String>();
034
035        public synchronized Entity createEntity(EntityDefinition def) {
036                String name = def.getName();
037                if (stk.contains(def.getName())) {
038                        throw new IllegalStateException("Circular reference detected for entity type " + name);
039                }
040                stk.push(def.getName());
041                try {
042                        Entity result = entity(def.getAst());
043                        runChecks(def, result);
044                        return result;
045                } catch (ANTLRException e) {
046                        throw new RuntimeException(e);
047                } finally {
048                        String x = stk.pop();
049                        if (!x.equals(def.getName())) {
050                                throw new IllegalStateException("Stack out of balance; encountered " + x);
051                        }
052                }
053        }
054
055        public void setEntityFactory(ParserEntityFactory entityFactory) {
056                this.entityFactoryRef = new java.lang.ref.WeakReference<ParserEntityFactory>(entityFactory);
057        }
058
059        private void runChecks(EntityDefinition def, Entity e) {
060                for (AST check : def.getChecks()) {
061                        switch (check.getType()) {
062                                case LENGTH :
063                                        int expected = Integer.parseInt(check.getText());
064                                        int actual = e.length();
065                                        if (expected != actual) {
066                                                throw new IllegalStateException(
067                                                                "expected entity " + def.getName() + " length=" + expected + "; actually " + actual);
068                                        }
069                                        break;
070                                default :
071                                        throw new IllegalArgumentException("Unknown check: " + check);
072                        }
073                }
074        }
075
076        private byte[] getBytes(String s) {
077                try {
078                        return s.getBytes("UTF-8");
079                } catch (IOException e) {
080                        throw new RuntimeException(e);
081                }
082        }
083
084        private ParserEntityFactory getEntityFactory() {
085                return entityFactoryRef.get();
086        }
087public EntityTreeParser() {
088        tokenNames = _tokenNames;
089}
090
091        public final void load(AST _t) throws RecognitionException {
092                
093                AST load_AST_in = (_t == ASTNULL) ? null : (AST)_t;
094                AST e = null;
095                AST c = null;
096                List<AST> checks = new ArrayList<AST>(); String name = null;
097                
098                AST __t2 = _t;
099                AST tmp1_AST_in = (AST)_t;
100                match(_t,ROOT);
101                _t = _t.getFirstChild();
102                {
103                _loop4:
104                do {
105                        if (_t==null) _t=ASTNULL;
106                        if ((_t.getType()==OPTIONS)) {
107                                defaultOptions(_t);
108                                _t = _retTree;
109                        }
110                        else {
111                                break _loop4;
112                        }
113                        
114                } while (true);
115                }
116                {
117                int _cnt9=0;
118                _loop9:
119                do {
120                        if (_t==null) _t=ASTNULL;
121                        if ((_t.getType()==ASSIGN)) {
122                                AST __t6 = _t;
123                                AST tmp2_AST_in = (AST)_t;
124                                match(_t,ASSIGN);
125                                _t = _t.getFirstChild();
126                                name=name(_t);
127                                _t = _retTree;
128                                e = (AST)_t;
129                                if ( _t==null ) throw new MismatchedTokenException();
130                                _t = _t.getNextSibling();
131                                _t = __t6;
132                                _t = _t.getNextSibling();
133                                {
134                                _loop8:
135                                do {
136                                        if (_t==null) _t=ASTNULL;
137                                        if ((_t.getType()==CHECK)) {
138                                                AST tmp3_AST_in = (AST)_t;
139                                                match(_t,CHECK);
140                                                _t = _t.getNextSibling();
141                                                c = (AST)_t;
142                                                if ( _t==null ) throw new MismatchedTokenException();
143                                                _t = _t.getNextSibling();
144                                                
145                                                                                                checks.add(c);
146                                                                                        
147                                        }
148                                        else {
149                                                break _loop8;
150                                        }
151                                        
152                                } while (true);
153                                }
154                                
155                                                                        EntityDefinition ed = new EntityDefinition(name, e);
156                                                                        if (!checks.isEmpty()) {
157                                                                                ed.setChecks(new ArrayList<AST>(checks));
158                                                                                checks.clear();
159                                                                        }
160                                                                        getEntityFactory().add(name, ed);
161                                                                
162                        }
163                        else {
164                                if ( _cnt9>=1 ) { break _loop9; } else {throw new NoViableAltException(_t);}
165                        }
166                        
167                        _cnt9++;
168                } while (true);
169                }
170                _t = __t2;
171                _t = _t.getNextSibling();
172                _retTree = _t;
173        }
174        
175        protected final void defaultOptions(AST _t) throws RecognitionException {
176                
177                AST defaultOptions_AST_in = (_t == ASTNULL) ? null : (AST)_t;
178                AST o = null;
179                HashMap<String, String> m = new HashMap<String, String>(); String key = null, value = null;
180                
181                AST __t11 = _t;
182                o = _t==ASTNULL ? null :(AST)_t;
183                match(_t,OPTIONS);
184                _t = _t.getFirstChild();
185                {
186                int _cnt14=0;
187                _loop14:
188                do {
189                        if (_t==null) _t=ASTNULL;
190                        if ((_t.getType()==ASSIGN)) {
191                                AST __t13 = _t;
192                                AST tmp4_AST_in = (AST)_t;
193                                match(_t,ASSIGN);
194                                _t = _t.getFirstChild();
195                                key=optionKV(_t);
196                                _t = _retTree;
197                                value=optionKV(_t);
198                                _t = _retTree;
199                                m.put(key, value);
200                                _t = __t13;
201                                _t = _t.getNextSibling();
202                        }
203                        else {
204                                if ( _cnt14>=1 ) { break _loop14; } else {throw new NoViableAltException(_t);}
205                        }
206                        
207                        _cnt14++;
208                } while (true);
209                }
210                _t = __t11;
211                _t = _t.getNextSibling();
212                getEntityFactory().setDefaultOptions(o.getText(), m);
213                _retTree = _t;
214        }
215        
216        protected final String  name(AST _t) throws RecognitionException {
217                String s = null;
218                
219                AST name_AST_in = (_t == ASTNULL) ? null : (AST)_t;
220                AST i = null;
221                
222                if (_t==null) _t=ASTNULL;
223                switch ( _t.getType()) {
224                case IDENT:
225                {
226                        i = (AST)_t;
227                        match(_t,IDENT);
228                        _t = _t.getNextSibling();
229                        s = i.getText();
230                        break;
231                }
232                case ANON:
233                {
234                        AST tmp5_AST_in = (AST)_t;
235                        match(_t,ANON);
236                        _t = _t.getNextSibling();
237                        break;
238                }
239                default:
240                {
241                        throw new NoViableAltException(_t);
242                }
243                }
244                _retTree = _t;
245                return s;
246        }
247        
248        protected final String  optionKV(AST _t) throws RecognitionException {
249                String result = null;
250                
251                AST optionKV_AST_in = (_t == ASTNULL) ? null : (AST)_t;
252                AST c = null;
253                AST s = null;
254                AST n = null;
255                AST i = null;
256                
257                if (_t==null) _t=ASTNULL;
258                switch ( _t.getType()) {
259                case CHAR_LITERAL:
260                {
261                        c = (AST)_t;
262                        match(_t,CHAR_LITERAL);
263                        _t = _t.getNextSibling();
264                        result = c.getText();
265                        break;
266                }
267                case STRING_LITERAL:
268                {
269                        s = (AST)_t;
270                        match(_t,STRING_LITERAL);
271                        _t = _t.getNextSibling();
272                        result = s.getText();
273                        break;
274                }
275                case NUMBER:
276                {
277                        n = (AST)_t;
278                        match(_t,NUMBER);
279                        _t = _t.getNextSibling();
280                        result = n.getText();
281                        break;
282                }
283                case IDENT:
284                {
285                        i = (AST)_t;
286                        match(_t,IDENT);
287                        _t = _t.getNextSibling();
288                        result = i.getText();
289                        break;
290                }
291                default:
292                {
293                        throw new NoViableAltException(_t);
294                }
295                }
296                _retTree = _t;
297                return result;
298        }
299        
300        protected final Entity  entity(AST _t) throws RecognitionException {
301                Entity e = null;
302                
303                AST entity_AST_in = (_t == ASTNULL) ? null : (AST)_t;
304                
305                if (_t==null) _t=ASTNULL;
306                switch ( _t.getType()) {
307                case ARRAY:
308                {
309                        e=array(_t);
310                        _t = _retTree;
311                        break;
312                }
313                case FIELD:
314                {
315                        e=field(_t);
316                        _t = _retTree;
317                        break;
318                }
319                case MAP:
320                {
321                        e=map(_t);
322                        _t = _retTree;
323                        break;
324                }
325                case TYPEREF:
326                {
327                        e=typeRef(_t);
328                        _t = _retTree;
329                        break;
330                }
331                default:
332                {
333                        throw new NoViableAltException(_t);
334                }
335                }
336                _retTree = _t;
337                return e;
338        }
339        
340        protected final IndexedEntityCollection  array(AST _t) throws RecognitionException {
341                IndexedEntityCollection a = null;
342                
343                AST array_AST_in = (_t == ASTNULL) ? null : (AST)_t;
344                AST l = null;
345                AST m = null;
346                AST n = null;
347                Entity prototype = null, e = null; Integer len = null, min = null, max = null;
348                
349                AST __t22 = _t;
350                AST tmp6_AST_in = (AST)_t;
351                match(_t,ARRAY);
352                _t = _t.getFirstChild();
353                {
354                if (_t==null) _t=ASTNULL;
355                switch ( _t.getType()) {
356                case LENGTH:
357                {
358                        l = (AST)_t;
359                        match(_t,LENGTH);
360                        _t = _t.getNextSibling();
361                        len = Integer.valueOf(l.getText());
362                        break;
363                }
364                case RANGE:
365                {
366                        AST __t24 = _t;
367                        AST tmp7_AST_in = (AST)_t;
368                        match(_t,RANGE);
369                        _t = _t.getFirstChild();
370                        {
371                        if (_t==null) _t=ASTNULL;
372                        switch ( _t.getType()) {
373                        case MIN:
374                        {
375                                m = (AST)_t;
376                                match(_t,MIN);
377                                _t = _t.getNextSibling();
378                                min = Integer.valueOf(m.getText());
379                                break;
380                        }
381                        case 3:
382                        case MAX:
383                        {
384                                break;
385                        }
386                        default:
387                        {
388                                throw new NoViableAltException(_t);
389                        }
390                        }
391                        }
392                        {
393                        if (_t==null) _t=ASTNULL;
394                        switch ( _t.getType()) {
395                        case MAX:
396                        {
397                                n = (AST)_t;
398                                match(_t,MAX);
399                                _t = _t.getNextSibling();
400                                max = Integer.valueOf(n.getText());
401                                break;
402                        }
403                        case 3:
404                        {
405                                break;
406                        }
407                        default:
408                        {
409                                throw new NoViableAltException(_t);
410                        }
411                        }
412                        }
413                        _t = __t24;
414                        _t = _t.getNextSibling();
415                        break;
416                }
417                case PROTOTYPE:
418                {
419                        break;
420                }
421                default:
422                {
423                        throw new NoViableAltException(_t);
424                }
425                }
426                }
427                AST __t27 = _t;
428                AST tmp8_AST_in = (AST)_t;
429                match(_t,PROTOTYPE);
430                _t = _t.getFirstChild();
431                prototype=entity(_t);
432                _t = _retTree;
433                _t = __t27;
434                _t = _t.getNextSibling();
435                        a = new EntityArray(prototype);
436                                                if (len != null) {
437                                                        ((EntityArray) a).setSize(len.intValue());
438                                                } else {
439                                                        if (min != null) {
440                                                                ((EntityArray) a).setMinimumSize(min.intValue());
441                                                        }
442                                                        if (max != null) {
443                                                                ((EntityArray) a).setMaximumSize(max.intValue());
444                                                        }
445                                                }
446                                        
447                {
448                if (_t==null) _t=ASTNULL;
449                switch ( _t.getType()) {
450                case OPTIONS:
451                {
452                        entityOptions(_t,a);
453                        _t = _retTree;
454                        break;
455                }
456                case 3:
457                case VALUE:
458                case ALL:
459                {
460                        break;
461                }
462                default:
463                {
464                        throw new NoViableAltException(_t);
465                }
466                }
467                }
468                {
469                if (_t==null) _t=ASTNULL;
470                switch ( _t.getType()) {
471                case VALUE:
472                case ALL:
473                {
474                        e=value(_t,a);
475                        _t = _retTree;
476                        a = (IndexedEntityCollection) e;
477                        break;
478                }
479                case 3:
480                {
481                        break;
482                }
483                default:
484                {
485                        throw new NoViableAltException(_t);
486                }
487                }
488                }
489                _t = __t22;
490                _t = _t.getNextSibling();
491                _retTree = _t;
492                return a;
493        }
494        
495        protected final Entity  field(AST _t) throws RecognitionException {
496                Entity e = null;
497                
498                AST field_AST_in = (_t == ASTNULL) ? null : (AST)_t;
499                
500                AST __t34 = _t;
501                AST tmp9_AST_in = (AST)_t;
502                match(_t,FIELD);
503                _t = _t.getFirstChild();
504                e=fieldDef(_t);
505                _t = _retTree;
506                _t = __t34;
507                _t = _t.getNextSibling();
508                _retTree = _t;
509                return e;
510        }
511        
512        protected final NamedEntityCollection  map(AST _t) throws RecognitionException {
513                NamedEntityCollection m = new EntityMap();
514                
515                AST map_AST_in = (_t == ASTNULL) ? null : (AST)_t;
516                String name = null; Entity temp = null;
517                
518                AST __t45 = _t;
519                AST tmp10_AST_in = (AST)_t;
520                match(_t,MAP);
521                _t = _t.getFirstChild();
522                {
523                int _cnt48=0;
524                _loop48:
525                do {
526                        if (_t==null) _t=ASTNULL;
527                        if ((_t.getType()==ASSIGN)) {
528                                AST __t47 = _t;
529                                AST tmp11_AST_in = (AST)_t;
530                                match(_t,ASSIGN);
531                                _t = _t.getFirstChild();
532                                name=name(_t);
533                                _t = _retTree;
534                                temp=entity(_t);
535                                _t = _retTree;
536                                ((EntityMap) m).add(name, temp);
537                                _t = __t47;
538                                _t = _t.getNextSibling();
539                        }
540                        else {
541                                if ( _cnt48>=1 ) { break _loop48; } else {throw new NoViableAltException(_t);}
542                        }
543                        
544                        _cnt48++;
545                } while (true);
546                }
547                {
548                if (_t==null) _t=ASTNULL;
549                switch ( _t.getType()) {
550                case OPTIONS:
551                {
552                        entityOptions(_t,m);
553                        _t = _retTree;
554                        break;
555                }
556                case 3:
557                case VALUE:
558                case ALL:
559                {
560                        break;
561                }
562                default:
563                {
564                        throw new NoViableAltException(_t);
565                }
566                }
567                }
568                {
569                if (_t==null) _t=ASTNULL;
570                switch ( _t.getType()) {
571                case VALUE:
572                case ALL:
573                {
574                        temp=value(_t,m);
575                        _t = _retTree;
576                        m = (NamedEntityCollection) temp;
577                        break;
578                }
579                case 3:
580                {
581                        break;
582                }
583                default:
584                {
585                        throw new NoViableAltException(_t);
586                }
587                }
588                }
589                _t = __t45;
590                _t = _t.getNextSibling();
591                _retTree = _t;
592                return m;
593        }
594        
595        protected final Entity  typeRef(AST _t) throws RecognitionException {
596                Entity e = null;
597                
598                AST typeRef_AST_in = (_t == ASTNULL) ? null : (AST)_t;
599                AST t = null;
600                
601                AST __t18 = _t;
602                t = _t==ASTNULL ? null :(AST)_t;
603                match(_t,TYPEREF);
604                _t = _t.getFirstChild();
605                e = getEntityFactory().getEntity(t.getText());
606                {
607                if (_t==null) _t=ASTNULL;
608                switch ( _t.getType()) {
609                case OPTIONS:
610                {
611                        entityOptions(_t,e);
612                        _t = _retTree;
613                        break;
614                }
615                case 3:
616                case VALUE:
617                case ALL:
618                {
619                        break;
620                }
621                default:
622                {
623                        throw new NoViableAltException(_t);
624                }
625                }
626                }
627                {
628                if (_t==null) _t=ASTNULL;
629                switch ( _t.getType()) {
630                case VALUE:
631                case ALL:
632                {
633                        e=value(_t,e);
634                        _t = _retTree;
635                        break;
636                }
637                case 3:
638                {
639                        break;
640                }
641                default:
642                {
643                        throw new NoViableAltException(_t);
644                }
645                }
646                }
647                _t = __t18;
648                _t = _t.getNextSibling();
649                _retTree = _t;
650                return e;
651        }
652        
653        protected final void entityOptions(AST _t,
654                Entity e
655        ) throws RecognitionException {
656                
657                AST entityOptions_AST_in = (_t == ASTNULL) ? null : (AST)_t;
658                
659                AST __t53 = _t;
660                AST tmp12_AST_in = (AST)_t;
661                match(_t,OPTIONS);
662                _t = _t.getFirstChild();
663                {
664                int _cnt55=0;
665                _loop55:
666                do {
667                        if (_t==null) _t=ASTNULL;
668                        if ((_t.getType()==ASSIGN)) {
669                                entityOption(_t,e);
670                                _t = _retTree;
671                        }
672                        else {
673                                if ( _cnt55>=1 ) { break _loop55; } else {throw new NoViableAltException(_t);}
674                        }
675                        
676                        _cnt55++;
677                } while (true);
678                }
679                _t = __t53;
680                _t = _t.getNextSibling();
681                _retTree = _t;
682        }
683        
684        protected final Entity  value(AST _t,
685                Entity e
686        ) throws RecognitionException {
687                Entity result = e;
688                
689                AST value_AST_in = (_t == ASTNULL) ? null : (AST)_t;
690                AST a = null;
691                AST v = null;
692                
693                try {      // for error handling
694                        {
695                        if (_t==null) _t=ASTNULL;
696                        switch ( _t.getType()) {
697                        case ALL:
698                        {
699                                a = (AST)_t;
700                                match(_t,ALL);
701                                _t = _t.getNextSibling();
702                                e.fill(getBytes(a.getText())[0]);
703                                break;
704                        }
705                        case VALUE:
706                        {
707                                v = (AST)_t;
708                                match(_t,VALUE);
709                                _t = _t.getNextSibling();
710                                e.setValue(getBytes(v.getText()));
711                                break;
712                        }
713                        default:
714                        {
715                                throw new NoViableAltException(_t);
716                        }
717                        }
718                        }
719                        {
720                        if (_t==null) _t=ASTNULL;
721                        switch ( _t.getType()) {
722                        case IMMUTABLE:
723                        {
724                                result=immutable(_t,e);
725                                _t = _retTree;
726                                break;
727                        }
728                        case 3:
729                        {
730                                break;
731                        }
732                        default:
733                        {
734                                throw new NoViableAltException(_t);
735                        }
736                        }
737                        }
738                }
739                catch (IOException exc) {
740                        
741                                        throw new RuntimeException(exc);
742                                
743                }
744                _retTree = _t;
745                return result;
746        }
747        
748        protected final Entity  immutable(AST _t,
749                Entity e
750        ) throws RecognitionException {
751                Entity result = null;
752                
753                AST immutable_AST_in = (_t == ASTNULL) ? null : (AST)_t;
754                
755                AST tmp13_AST_in = (AST)_t;
756                match(_t,IMMUTABLE);
757                _t = _t.getNextSibling();
758                result = ImmutableEntity.of(e);
759                _retTree = _t;
760                return result;
761        }
762        
763        protected final Entity  fieldDef(AST _t) throws RecognitionException {
764                Entity e = null;
765                
766                AST fieldDef_AST_in = (_t == ASTNULL) ? null : (AST)_t;
767                AST l = null;
768                AST v = null;
769                AST n = null;
770                AST x = null;
771                AST v2 = null;
772                
773                {
774                if (_t==null) _t=ASTNULL;
775                switch ( _t.getType()) {
776                case LENGTH:
777                {
778                        l = (AST)_t;
779                        match(_t,LENGTH);
780                        _t = _t.getNextSibling();
781                        e = getEntityFactory().createField(Integer.parseInt(l.getText()));
782                        {
783                        if (_t==null) _t=ASTNULL;
784                        switch ( _t.getType()) {
785                        case OPTIONS:
786                        {
787                                entityOptions(_t,e);
788                                _t = _retTree;
789                                break;
790                        }
791                        case 3:
792                        case VALUE:
793                        case ALL:
794                        {
795                                break;
796                        }
797                        default:
798                        {
799                                throw new NoViableAltException(_t);
800                        }
801                        }
802                        }
803                        {
804                        if (_t==null) _t=ASTNULL;
805                        switch ( _t.getType()) {
806                        case VALUE:
807                        case ALL:
808                        {
809                                e=value(_t,e);
810                                _t = _retTree;
811                                break;
812                        }
813                        case 3:
814                        {
815                                break;
816                        }
817                        default:
818                        {
819                                throw new NoViableAltException(_t);
820                        }
821                        }
822                        }
823                        break;
824                }
825                case VALUE:
826                {
827                        v = (AST)_t;
828                        match(_t,VALUE);
829                        _t = _t.getNextSibling();
830                        e = getEntityFactory().createField(getBytes(v.getText()));
831                        {
832                        if (_t==null) _t=ASTNULL;
833                        switch ( _t.getType()) {
834                        case IMMUTABLE:
835                        {
836                                e=immutable(_t,e);
837                                _t = _retTree;
838                                break;
839                        }
840                        case 3:
841                        {
842                                break;
843                        }
844                        default:
845                        {
846                                throw new NoViableAltException(_t);
847                        }
848                        }
849                        }
850                        break;
851                }
852                case RANGE:
853                {
854                        AST __t40 = _t;
855                        AST tmp14_AST_in = (AST)_t;
856                        match(_t,RANGE);
857                        _t = _t.getFirstChild();
858                        e = getEntityFactory().createDynamicField();
859                        {
860                        if (_t==null) _t=ASTNULL;
861                        switch ( _t.getType()) {
862                        case MIN:
863                        {
864                                n = (AST)_t;
865                                match(_t,MIN);
866                                _t = _t.getNextSibling();
867                                ((DynamicField) e).getBounds().setMinimum(Integer.parseInt(n.getText()));
868                                break;
869                        }
870                        case 3:
871                        case MAX:
872                        {
873                                break;
874                        }
875                        default:
876                        {
877                                throw new NoViableAltException(_t);
878                        }
879                        }
880                        }
881                        {
882                        if (_t==null) _t=ASTNULL;
883                        switch ( _t.getType()) {
884                        case MAX:
885                        {
886                                x = (AST)_t;
887                                match(_t,MAX);
888                                _t = _t.getNextSibling();
889                                ((DynamicField) e).getBounds().setMaximum(Integer.parseInt(x.getText()));
890                                break;
891                        }
892                        case 3:
893                        {
894                                break;
895                        }
896                        default:
897                        {
898                                throw new NoViableAltException(_t);
899                        }
900                        }
901                        }
902                        _t = __t40;
903                        _t = _t.getNextSibling();
904                        {
905                        if (_t==null) _t=ASTNULL;
906                        switch ( _t.getType()) {
907                        case VALUE:
908                        {
909                                v2 = (AST)_t;
910                                match(_t,VALUE);
911                                _t = _t.getNextSibling();
912                                e.setValue(getBytes(v2.getText()));
913                                break;
914                        }
915                        case 3:
916                        {
917                                break;
918                        }
919                        default:
920                        {
921                                throw new NoViableAltException(_t);
922                        }
923                        }
924                        }
925                        break;
926                }
927                default:
928                {
929                        throw new NoViableAltException(_t);
930                }
931                }
932                }
933                _retTree = _t;
934                return e;
935        }
936        
937        protected final void entityOption(AST _t,
938                Entity e
939        ) throws RecognitionException {
940                
941                AST entityOption_AST_in = (_t == ASTNULL) ? null : (AST)_t;
942                String key = null, value = null;
943                
944                AST __t57 = _t;
945                AST tmp15_AST_in = (AST)_t;
946                match(_t,ASSIGN);
947                _t = _t.getFirstChild();
948                key=optionKV(_t);
949                _t = _retTree;
950                value=optionKV(_t);
951                _t = _retTree;
952                ApplyOptions.apply(e, key, value);
953                _t = __t57;
954                _t = _t.getNextSibling();
955                _retTree = _t;
956        }
957        
958        
959        public static final String[] _tokenNames = {
960                "<0>",
961                "EOF",
962                "<2>",
963                "NULL_TREE_LOOKAHEAD",
964                "ROOT",
965                "CHECK",
966                "VALUE",
967                "ALL",
968                "FIELD",
969                "LENGTH",
970                "ARRAY",
971                "IMMUTABLE",
972                "MAP",
973                "PROTOTYPE",
974                "OPTIONS",
975                "MIN",
976                "MAX",
977                "OPTION_BLOCK",
978                "SEMI",
979                "IDENT",
980                "ANON",
981                "COLON",
982                "TYPEREF",
983                "LBRACK",
984                "RBRACK",
985                "CHAR_LITERAL",
986                "STAR",
987                "STRING_LITERAL",
988                "BANG",
989                "LPAREN",
990                "RPAREN",
991                "LCURLY",
992                "COMMA",
993                "RCURLY",
994                "NUMBER",
995                "RANGE",
996                "ASSIGN",
997                "WS",
998                "SL_COMMENT",
999                "ML_COMMENT",
1000                "NL",
1001                "PTIDENT",
1002                "CHAR_BODY",
1003                "STRING_BODY",
1004                "ESC",
1005                "UNICODE",
1006                "OCTAL",
1007                "HEX_DIGIT"
1008        };
1009        
1010        }
1011