001    // $ANTLR 2.7.4: "subtree-specification.g" -> "AntlrSubtreeSpecificationParser.java"$
002    
003    /*
004     *  Licensed to the Apache Software Foundation (ASF) under one
005     *  or more contributor license agreements.  See the NOTICE file
006     *  distributed with this work for additional information
007     *  regarding copyright ownership.  The ASF licenses this file
008     *  to you under the Apache License, Version 2.0 (the
009     *  "License"); you may not use this file except in compliance
010     *  with the License.  You may obtain a copy of the License at
011     *  
012     *    http://www.apache.org/licenses/LICENSE-2.0
013     *  
014     *  Unless required by applicable law or agreed to in writing,
015     *  software distributed under the License is distributed on an
016     *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017     *  KIND, either express or implied.  See the License for the
018     *  specific language governing permissions and limitations
019     *  under the License. 
020     *  
021     */
022    
023    
024    package org.apache.directory.shared.ldap.subtree;
025    
026    import java.util.Set;
027    import java.util.Map;
028    import java.util.HashSet;
029    import java.util.List;
030    import java.util.ArrayList;
031    
032    import org.apache.directory.shared.ldap.name.LdapDN;
033    import org.apache.directory.shared.ldap.filter.ExprNode;
034    import org.apache.directory.shared.ldap.filter.LeafNode;
035    import org.apache.directory.shared.ldap.filter.BranchNode;
036    import org.apache.directory.shared.ldap.filter.AndNode;
037    import org.apache.directory.shared.ldap.filter.OrNode;
038    import org.apache.directory.shared.ldap.filter.NotNode;
039    import org.apache.directory.shared.ldap.filter.EqualityNode;
040    import org.apache.directory.shared.ldap.filter.FilterParser;
041    import org.apache.directory.shared.ldap.subtree.SubtreeSpecification;
042    import org.apache.directory.shared.ldap.subtree.SubtreeSpecificationModifier;
043    import org.apache.directory.shared.ldap.schema.NormalizerMappingResolver;
044    import org.apache.directory.shared.ldap.schema.normalizers.OidNormalizer;
045    import org.apache.directory.shared.ldap.util.ComponentsMonitor;
046    import org.apache.directory.shared.ldap.util.OptionalComponentsMonitor;
047    import org.apache.directory.shared.ldap.constants.SchemaConstants;
048    import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
049    
050    import org.slf4j.Logger;
051    import org.slf4j.LoggerFactory;
052    
053    import antlr.TokenBuffer;
054    import antlr.TokenStreamException;
055    import antlr.TokenStreamIOException;
056    import antlr.ANTLRException;
057    import antlr.LLkParser;
058    import antlr.Token;
059    import antlr.TokenStream;
060    import antlr.RecognitionException;
061    import antlr.NoViableAltException;
062    import antlr.MismatchedTokenException;
063    import antlr.SemanticException;
064    import antlr.ParserSharedInputState;
065    import antlr.collections.impl.BitSet;
066    
067    /**
068     * The antlr generated subtree specification parser.
069     *
070     * @see <a href="http://www.faqs.org/rfcs/rfc3672.html">RFC 3672</a>
071     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
072     * @version $Rev$
073     */
074    public class AntlrSubtreeSpecificationParser extends antlr.LLkParser       implements AntlrSubtreeSpecificationParserTokenTypes
075     {
076    
077        private static final Logger log = LoggerFactory.getLogger( AntlrSubtreeSpecificationParser.class );
078        
079        private NormalizerMappingResolver resolver;
080        
081        private Set<LdapDN> chopBeforeExclusions = null;
082        private Set<LdapDN> chopAfterExclusions = null;
083    
084        private SubtreeSpecificationModifier ssModifier = null;
085        
086        private Map<String, OidNormalizer> oidsMap;
087        
088        private ComponentsMonitor subtreeSpecificationComponentsMonitor = null;
089    
090        /**
091         * Does nothing.
092         */
093        public void init( Map<String, OidNormalizer> oidsMap )
094        {
095            this.oidsMap = oidsMap;
096        }
097        
098        
099        public void setNormalizerMappingResolver( NormalizerMappingResolver resolver )
100        {
101            this.resolver = resolver;
102        }
103        
104        
105        public boolean isNormalizing()
106        {
107            return this.resolver != null;
108        }
109        
110    
111        private int token2Integer( Token token ) throws RecognitionException
112        {
113            int i = 0;
114            
115            try
116            {
117                i = Integer.parseInt( token.getText());
118            }
119            catch ( NumberFormatException e )
120            {
121                throw new RecognitionException( "Value of INTEGER token " +
122                                                token.getText() +
123                                                " cannot be converted to an Integer" );
124            }
125            
126            return i;
127        }
128    
129    protected AntlrSubtreeSpecificationParser(TokenBuffer tokenBuf, int k) {
130      super(tokenBuf,k);
131      tokenNames = _tokenNames;
132    }
133    
134    public AntlrSubtreeSpecificationParser(TokenBuffer tokenBuf) {
135      this(tokenBuf,1);
136    }
137    
138    protected AntlrSubtreeSpecificationParser(TokenStream lexer, int k) {
139      super(lexer,k);
140      tokenNames = _tokenNames;
141    }
142    
143    public AntlrSubtreeSpecificationParser(TokenStream lexer) {
144      this(lexer,1);
145    }
146    
147    public AntlrSubtreeSpecificationParser(ParserSharedInputState state) {
148      super(state,1);
149      tokenNames = _tokenNames;
150    }
151    
152            public final SubtreeSpecification  wrapperEntryPoint() throws RecognitionException, TokenStreamException {
153                    SubtreeSpecification ss;
154                    
155                    
156                    log.debug( "entered wrapperEntryPoint()" );
157                    ss = null;
158                    SubtreeSpecification tempSs = null;
159                    
160                    
161                    tempSs=subtreeSpecification();
162                    match(LITERAL_end);
163                    
164                    ss = tempSs;
165                    
166                    return ss;
167            }
168            
169            public final SubtreeSpecification  subtreeSpecification() throws RecognitionException, TokenStreamException {
170                    SubtreeSpecification ss;
171                    
172                    
173                    log.debug( "entered subtreeSpecification()" );
174                    // clear out ss, ssModifier, subtreeSpecificationComponentsMonitor,
175                    // chopBeforeExclusions and chopAfterExclusions
176                    // in case something is left from the last parse
177                    ss = null;
178                    ssModifier = new SubtreeSpecificationModifier();
179                    subtreeSpecificationComponentsMonitor = new OptionalComponentsMonitor( 
180                    new String [] { "base", "specificExclusions", "minimum", "maximum", "specificationFilter" } );
181                    chopBeforeExclusions = new HashSet<LdapDN>();
182                    chopAfterExclusions = new HashSet<LdapDN>();
183                    // always create a new filter parser in case we may have some statefulness problems with it
184                    
185                    
186                    match(OPEN_CURLY);
187                    {
188                    _loop1417:
189                    do {
190                            if ((LA(1)==SP)) {
191                                    match(SP);
192                            }
193                            else {
194                                    break _loop1417;
195                            }
196                            
197                    } while (true);
198                    }
199                    {
200                    switch ( LA(1)) {
201                    case ID_base:
202                    case ID_specificExclusions:
203                    case ID_minimum:
204                    case ID_maximum:
205                    case ID_specificationFilter:
206                    {
207                            subtreeSpecificationComponent();
208                            {
209                            _loop1420:
210                            do {
211                                    if ((LA(1)==SP)) {
212                                            match(SP);
213                                    }
214                                    else {
215                                            break _loop1420;
216                                    }
217                                    
218                            } while (true);
219                            }
220                            {
221                            _loop1426:
222                            do {
223                                    if ((LA(1)==SEP)) {
224                                            match(SEP);
225                                            {
226                                            _loop1423:
227                                            do {
228                                                    if ((LA(1)==SP)) {
229                                                            match(SP);
230                                                    }
231                                                    else {
232                                                            break _loop1423;
233                                                    }
234                                                    
235                                            } while (true);
236                                            }
237                                            subtreeSpecificationComponent();
238                                            {
239                                            _loop1425:
240                                            do {
241                                                    if ((LA(1)==SP)) {
242                                                            match(SP);
243                                                    }
244                                                    else {
245                                                            break _loop1425;
246                                                    }
247                                                    
248                                            } while (true);
249                                            }
250                                    }
251                                    else {
252                                            break _loop1426;
253                                    }
254                                    
255                            } while (true);
256                            }
257                            break;
258                    }
259                    case CLOSE_CURLY:
260                    {
261                            break;
262                    }
263                    default:
264                    {
265                            throw new NoViableAltException(LT(1), getFilename());
266                    }
267                    }
268                    }
269                    match(CLOSE_CURLY);
270                    
271                    ss = ssModifier.getSubtreeSpecification();
272                    
273                    return ss;
274            }
275            
276            public final void subtreeSpecificationComponent() throws RecognitionException, TokenStreamException {
277                    
278                    
279                    log.debug( "entered subtreeSpecification()" );
280                    
281                    
282                    try {      // for error handling
283                            switch ( LA(1)) {
284                            case ID_base:
285                            {
286                                    ss_base();
287                                    
288                                    subtreeSpecificationComponentsMonitor.useComponent( "base" );
289                                    
290                                    break;
291                            }
292                            case ID_specificExclusions:
293                            {
294                                    ss_specificExclusions();
295                                    
296                                    subtreeSpecificationComponentsMonitor.useComponent( "specificExclusions" );
297                                    
298                                    break;
299                            }
300                            case ID_minimum:
301                            {
302                                    ss_minimum();
303                                    
304                                    subtreeSpecificationComponentsMonitor.useComponent( "minimum" );
305                                    
306                                    break;
307                            }
308                            case ID_maximum:
309                            {
310                                    ss_maximum();
311                                    
312                                    subtreeSpecificationComponentsMonitor.useComponent( "maximum" );
313                                    
314                                    break;
315                            }
316                            case ID_specificationFilter:
317                            {
318                                    ss_specificationFilter();
319                                    
320                                    subtreeSpecificationComponentsMonitor.useComponent( "specificationFilter" );
321                                    
322                                    break;
323                            }
324                            default:
325                            {
326                                    throw new NoViableAltException(LT(1), getFilename());
327                            }
328                            }
329                    }
330                    catch (IllegalArgumentException e) {
331                            
332                            throw new RecognitionException( e.getMessage() );
333                            
334                    }
335            }
336            
337            public final void ss_base() throws RecognitionException, TokenStreamException {
338                    
339                    
340                    log.debug( "entered ss_base()" );
341                    LdapDN base = null;
342                    
343                    
344                    match(ID_base);
345                    {
346                    int _cnt1430=0;
347                    _loop1430:
348                    do {
349                            if ((LA(1)==SP)) {
350                                    match(SP);
351                            }
352                            else {
353                                    if ( _cnt1430>=1 ) { break _loop1430; } else {throw new NoViableAltException(LT(1), getFilename());}
354                            }
355                            
356                            _cnt1430++;
357                    } while (true);
358                    }
359                    base=distinguishedName();
360                    
361                    ssModifier.setBase( base );
362                    
363            }
364            
365            public final void ss_specificExclusions() throws RecognitionException, TokenStreamException {
366                    
367                    
368                    log.debug( "entered ss_specificExclusions()" );
369                    
370                    
371                    match(ID_specificExclusions);
372                    {
373                    int _cnt1433=0;
374                    _loop1433:
375                    do {
376                            if ((LA(1)==SP)) {
377                                    match(SP);
378                            }
379                            else {
380                                    if ( _cnt1433>=1 ) { break _loop1433; } else {throw new NoViableAltException(LT(1), getFilename());}
381                            }
382                            
383                            _cnt1433++;
384                    } while (true);
385                    }
386                    specificExclusions();
387                    
388                    ssModifier.setChopBeforeExclusions( chopBeforeExclusions );
389                    ssModifier.setChopAfterExclusions( chopAfterExclusions );
390                    
391            }
392            
393            public final void ss_minimum() throws RecognitionException, TokenStreamException {
394                    
395                    
396                    log.debug( "entered ss_minimum()" );
397                    int minimum = 0;
398                    
399                    
400                    match(ID_minimum);
401                    {
402                    int _cnt1459=0;
403                    _loop1459:
404                    do {
405                            if ((LA(1)==SP)) {
406                                    match(SP);
407                            }
408                            else {
409                                    if ( _cnt1459>=1 ) { break _loop1459; } else {throw new NoViableAltException(LT(1), getFilename());}
410                            }
411                            
412                            _cnt1459++;
413                    } while (true);
414                    }
415                    minimum=baseDistance();
416                    
417                    ssModifier.setMinBaseDistance( minimum );
418                    
419            }
420            
421            public final void ss_maximum() throws RecognitionException, TokenStreamException {
422                    
423                    
424                    log.debug( "entered ss_maximum()" );
425                    int maximum = 0;
426                    
427                    
428                    match(ID_maximum);
429                    {
430                    int _cnt1462=0;
431                    _loop1462:
432                    do {
433                            if ((LA(1)==SP)) {
434                                    match(SP);
435                            }
436                            else {
437                                    if ( _cnt1462>=1 ) { break _loop1462; } else {throw new NoViableAltException(LT(1), getFilename());}
438                            }
439                            
440                            _cnt1462++;
441                    } while (true);
442                    }
443                    maximum=baseDistance();
444                    
445                    ssModifier.setMaxBaseDistance( maximum );
446                    
447            }
448            
449            public final void ss_specificationFilter() throws RecognitionException, TokenStreamException {
450                    
451                    
452                    log.debug( "entered ss_specificationFilter()" );
453                    ExprNode filterExpr = null;
454                    
455                    
456                    match(ID_specificationFilter);
457                    {
458                    int _cnt1465=0;
459                    _loop1465:
460                    do {
461                            if ((LA(1)==SP)) {
462                                    match(SP);
463                            }
464                            else {
465                                    if ( _cnt1465>=1 ) { break _loop1465; } else {throw new NoViableAltException(LT(1), getFilename());}
466                            }
467                            
468                            _cnt1465++;
469                    } while (true);
470                    }
471                    {
472                    switch ( LA(1)) {
473                    case ID_item:
474                    case ID_and:
475                    case ID_or:
476                    case ID_not:
477                    {
478                            {
479                            filterExpr=refinement();
480                            }
481                            break;
482                    }
483                    case FILTER:
484                    {
485                            {
486                            filterExpr=filter();
487                            }
488                            break;
489                    }
490                    default:
491                    {
492                            throw new NoViableAltException(LT(1), getFilename());
493                    }
494                    }
495                    }
496                    ssModifier.setRefinement( filterExpr );
497            }
498            
499            public final  LdapDN  distinguishedName() throws RecognitionException, TokenStreamException {
500                     LdapDN name ;
501                    
502                    Token  token = null;
503                    
504                    log.debug( "entered distinguishedName()" );
505                    name = null;
506                    
507                    
508                    try {      // for error handling
509                            token = LT(1);
510                            match(SAFEUTF8STRING);
511                            
512                            name = new LdapDN( token.getText() );
513                            
514                            if ( isNormalizing() )
515                            {
516                            name.normalize( oidsMap );
517                            }
518                            
519                            log.debug( "recognized a DistinguishedName: " + token.getText() );
520                            
521                    }
522                    catch (Exception e) {
523                            
524                            throw new RecognitionException( "dnParser failed for " + token.getText() + " " + e.getMessage() );
525                            
526                    }
527                    return name ;
528            }
529            
530            public final void specificExclusions() throws RecognitionException, TokenStreamException {
531                    
532                    
533                    log.debug( "entered specificExclusions()" );
534                    
535                    
536                    match(OPEN_CURLY);
537                    {
538                    _loop1436:
539                    do {
540                            if ((LA(1)==SP)) {
541                                    match(SP);
542                            }
543                            else {
544                                    break _loop1436;
545                            }
546                            
547                    } while (true);
548                    }
549                    {
550                    switch ( LA(1)) {
551                    case ID_chopBefore:
552                    case ID_chopAfter:
553                    {
554                            specificExclusion();
555                            {
556                            _loop1439:
557                            do {
558                                    if ((LA(1)==SP)) {
559                                            match(SP);
560                                    }
561                                    else {
562                                            break _loop1439;
563                                    }
564                                    
565                            } while (true);
566                            }
567                            {
568                            _loop1445:
569                            do {
570                                    if ((LA(1)==SEP)) {
571                                            match(SEP);
572                                            {
573                                            _loop1442:
574                                            do {
575                                                    if ((LA(1)==SP)) {
576                                                            match(SP);
577                                                    }
578                                                    else {
579                                                            break _loop1442;
580                                                    }
581                                                    
582                                            } while (true);
583                                            }
584                                            specificExclusion();
585                                            {
586                                            _loop1444:
587                                            do {
588                                                    if ((LA(1)==SP)) {
589                                                            match(SP);
590                                                    }
591                                                    else {
592                                                            break _loop1444;
593                                                    }
594                                                    
595                                            } while (true);
596                                            }
597                                    }
598                                    else {
599                                            break _loop1445;
600                                    }
601                                    
602                            } while (true);
603                            }
604                            break;
605                    }
606                    case CLOSE_CURLY:
607                    {
608                            break;
609                    }
610                    default:
611                    {
612                            throw new NoViableAltException(LT(1), getFilename());
613                    }
614                    }
615                    }
616                    match(CLOSE_CURLY);
617            }
618            
619            public final void specificExclusion() throws RecognitionException, TokenStreamException {
620                    
621                    
622                    log.debug( "entered specificExclusion()" );
623                    
624                    
625                    switch ( LA(1)) {
626                    case ID_chopBefore:
627                    {
628                            chopBefore();
629                            break;
630                    }
631                    case ID_chopAfter:
632                    {
633                            chopAfter();
634                            break;
635                    }
636                    default:
637                    {
638                            throw new NoViableAltException(LT(1), getFilename());
639                    }
640                    }
641            }
642            
643            public final void chopBefore() throws RecognitionException, TokenStreamException {
644                    
645                    
646                    log.debug( "entered chopBefore()" );
647                    LdapDN chopBeforeExclusion = null;
648                    
649                    
650                    match(ID_chopBefore);
651                    {
652                    _loop1449:
653                    do {
654                            if ((LA(1)==SP)) {
655                                    match(SP);
656                            }
657                            else {
658                                    break _loop1449;
659                            }
660                            
661                    } while (true);
662                    }
663                    match(COLON);
664                    {
665                    _loop1451:
666                    do {
667                            if ((LA(1)==SP)) {
668                                    match(SP);
669                            }
670                            else {
671                                    break _loop1451;
672                            }
673                            
674                    } while (true);
675                    }
676                    chopBeforeExclusion=distinguishedName();
677                    
678                    chopBeforeExclusions.add( chopBeforeExclusion );
679                    
680            }
681            
682            public final void chopAfter() throws RecognitionException, TokenStreamException {
683                    
684                    
685                    log.debug( "entered chopAfter()" );
686                    LdapDN chopAfterExclusion = null;
687                    
688                    
689                    match(ID_chopAfter);
690                    {
691                    _loop1454:
692                    do {
693                            if ((LA(1)==SP)) {
694                                    match(SP);
695                            }
696                            else {
697                                    break _loop1454;
698                            }
699                            
700                    } while (true);
701                    }
702                    match(COLON);
703                    {
704                    _loop1456:
705                    do {
706                            if ((LA(1)==SP)) {
707                                    match(SP);
708                            }
709                            else {
710                                    break _loop1456;
711                            }
712                            
713                    } while (true);
714                    }
715                    chopAfterExclusion=distinguishedName();
716                    
717                    chopAfterExclusions.add( chopAfterExclusion );
718                    
719            }
720            
721            public final  int  baseDistance() throws RecognitionException, TokenStreamException {
722                     int distance ;
723                    
724                    Token  token = null;
725                    
726                    log.debug( "entered baseDistance()" );
727                    distance = 0;
728                    
729                    
730                    token = LT(1);
731                    match(INTEGER);
732                    
733                    distance = token2Integer( token );
734                    
735                    return distance ;
736            }
737            
738            public final  ExprNode  refinement() throws RecognitionException, TokenStreamException {
739                     ExprNode node ;
740                    
741                    
742                    log.debug( "entered refinement()" );
743                    node = null;
744                    
745                    
746                    switch ( LA(1)) {
747                    case ID_item:
748                    {
749                            node=item();
750                            break;
751                    }
752                    case ID_and:
753                    {
754                            node=and();
755                            break;
756                    }
757                    case ID_or:
758                    {
759                            node=or();
760                            break;
761                    }
762                    case ID_not:
763                    {
764                            node=not();
765                            break;
766                    }
767                    default:
768                    {
769                            throw new NoViableAltException(LT(1), getFilename());
770                    }
771                    }
772                    return node ;
773            }
774            
775            public final ExprNode  filter() throws RecognitionException, TokenStreamException {
776                     ExprNode filterExpr = null ;
777                    
778                    Token  filterToken = null;
779                    
780                    log.debug( "entered filter()" );
781                    
782                    
783                    try {      // for error handling
784                            {
785                            filterToken = LT(1);
786                            match(FILTER);
787                            filterExpr=FilterParser.parse( filterToken.getText() );
788                            }
789                    }
790                    catch (Exception e) {
791                            
792                            throw new RecognitionException( "filterParser failed. " + e.getMessage() );
793                            
794                    }
795                    return filterExpr;
796            }
797            
798            public final  String  oid() throws RecognitionException, TokenStreamException {
799                     String result ;
800                    
801                    
802                    log.debug( "entered oid()" );
803                    result = null;
804                    Token token = null;
805                    
806                    
807                    token = LT( 1 );
808                    {
809                    switch ( LA(1)) {
810                    case DESCR:
811                    {
812                            match(DESCR);
813                            break;
814                    }
815                    case NUMERICOID:
816                    {
817                            match(NUMERICOID);
818                            break;
819                    }
820                    default:
821                    {
822                            throw new NoViableAltException(LT(1), getFilename());
823                    }
824                    }
825                    }
826                    
827                    result = token.getText();
828                    log.debug( "recognized an oid: " + result );
829                    
830                    return result ;
831            }
832            
833            public final  LeafNode  item() throws RecognitionException, TokenStreamException {
834                     LeafNode node ;
835                    
836                    
837                    log.debug( "entered item()" );
838                    node = null;
839                    String oid = null;
840                    
841                    
842                    match(ID_item);
843                    {
844                    _loop1478:
845                    do {
846                            if ((LA(1)==SP)) {
847                                    match(SP);
848                            }
849                            else {
850                                    break _loop1478;
851                            }
852                            
853                    } while (true);
854                    }
855                    match(COLON);
856                    {
857                    _loop1480:
858                    do {
859                            if ((LA(1)==SP)) {
860                                    match(SP);
861                            }
862                            else {
863                                    break _loop1480;
864                            }
865                            
866                    } while (true);
867                    }
868                    oid=oid();
869                    
870                    node = new EqualityNode( SchemaConstants.OBJECT_CLASS_AT, new ClientStringValue( oid ) );
871                    
872                    return node ;
873            }
874            
875            public final  BranchNode  and() throws RecognitionException, TokenStreamException {
876                     BranchNode node ;
877                    
878                    
879                    log.debug( "entered and()" );
880                    node = null;
881                    List<ExprNode> children = null; 
882                    
883                    
884                    match(ID_and);
885                    {
886                    _loop1483:
887                    do {
888                            if ((LA(1)==SP)) {
889                                    match(SP);
890                            }
891                            else {
892                                    break _loop1483;
893                            }
894                            
895                    } while (true);
896                    }
897                    match(COLON);
898                    {
899                    _loop1485:
900                    do {
901                            if ((LA(1)==SP)) {
902                                    match(SP);
903                            }
904                            else {
905                                    break _loop1485;
906                            }
907                            
908                    } while (true);
909                    }
910                    children=refinements();
911                    
912                    node = new AndNode( children );
913                    
914                    return node ;
915            }
916            
917            public final  BranchNode  or() throws RecognitionException, TokenStreamException {
918                     BranchNode node ;
919                    
920                    
921                    log.debug( "entered or()" );
922                    node = null;
923                    List<ExprNode> children = null; 
924                    
925                    
926                    match(ID_or);
927                    {
928                    _loop1488:
929                    do {
930                            if ((LA(1)==SP)) {
931                                    match(SP);
932                            }
933                            else {
934                                    break _loop1488;
935                            }
936                            
937                    } while (true);
938                    }
939                    match(COLON);
940                    {
941                    _loop1490:
942                    do {
943                            if ((LA(1)==SP)) {
944                                    match(SP);
945                            }
946                            else {
947                                    break _loop1490;
948                            }
949                            
950                    } while (true);
951                    }
952                    children=refinements();
953                    
954                    node = new OrNode( children );
955                    
956                    return node ;
957            }
958            
959            public final  BranchNode  not() throws RecognitionException, TokenStreamException {
960                     BranchNode node ;
961                    
962                    
963                    log.debug( "entered not()" );
964                    node = null;
965                    List<ExprNode> children = null;
966                    
967                    
968                    match(ID_not);
969                    {
970                    _loop1493:
971                    do {
972                            if ((LA(1)==SP)) {
973                                    match(SP);
974                            }
975                            else {
976                                    break _loop1493;
977                            }
978                            
979                    } while (true);
980                    }
981                    match(COLON);
982                    {
983                    _loop1495:
984                    do {
985                            if ((LA(1)==SP)) {
986                                    match(SP);
987                            }
988                            else {
989                                    break _loop1495;
990                            }
991                            
992                    } while (true);
993                    }
994                    children=refinements();
995                    
996                    node = new NotNode( children );
997                    
998                    return node ;
999            }
1000            
1001            public final  List<ExprNode>  refinements() throws RecognitionException, TokenStreamException {
1002                     List<ExprNode> children ;
1003                    
1004                    
1005                    log.debug( "entered refinements()" );
1006                    children = null;
1007                    ExprNode child = null;
1008                    List<ExprNode> tempChildren = new ArrayList<ExprNode>();
1009                    
1010                    
1011                    match(OPEN_CURLY);
1012                    {
1013                    _loop1498:
1014                    do {
1015                            if ((LA(1)==SP)) {
1016                                    match(SP);
1017                            }
1018                            else {
1019                                    break _loop1498;
1020                            }
1021                            
1022                    } while (true);
1023                    }
1024                    {
1025                    switch ( LA(1)) {
1026                    case ID_item:
1027                    case ID_and:
1028                    case ID_or:
1029                    case ID_not:
1030                    {
1031                            child=refinement();
1032                            {
1033                            _loop1501:
1034                            do {
1035                                    if ((LA(1)==SP)) {
1036                                            match(SP);
1037                                    }
1038                                    else {
1039                                            break _loop1501;
1040                                    }
1041                                    
1042                            } while (true);
1043                            }
1044                            
1045                            tempChildren.add( child );
1046                            
1047                            {
1048                            _loop1507:
1049                            do {
1050                                    if ((LA(1)==SEP)) {
1051                                            match(SEP);
1052                                            {
1053                                            _loop1504:
1054                                            do {
1055                                                    if ((LA(1)==SP)) {
1056                                                            match(SP);
1057                                                    }
1058                                                    else {
1059                                                            break _loop1504;
1060                                                    }
1061                                                    
1062                                            } while (true);
1063                                            }
1064                                            child=refinement();
1065                                            {
1066                                            _loop1506:
1067                                            do {
1068                                                    if ((LA(1)==SP)) {
1069                                                            match(SP);
1070                                                    }
1071                                                    else {
1072                                                            break _loop1506;
1073                                                    }
1074                                                    
1075                                            } while (true);
1076                                            }
1077                                            
1078                                            tempChildren.add( child );
1079                                            
1080                                    }
1081                                    else {
1082                                            break _loop1507;
1083                                    }
1084                                    
1085                            } while (true);
1086                            }
1087                            break;
1088                    }
1089                    case CLOSE_CURLY:
1090                    {
1091                            break;
1092                    }
1093                    default:
1094                    {
1095                            throw new NoViableAltException(LT(1), getFilename());
1096                    }
1097                    }
1098                    }
1099                    match(CLOSE_CURLY);
1100                    
1101                    children = tempChildren;
1102                    
1103                    return children ;
1104            }
1105            
1106            
1107            public static final String[] _tokenNames = {
1108                    "<0>",
1109                    "EOF",
1110                    "<2>",
1111                    "NULL_TREE_LOOKAHEAD",
1112                    "\"end\"",
1113                    "OPEN_CURLY",
1114                    "SP",
1115                    "SEP",
1116                    "CLOSE_CURLY",
1117                    "\"base\"",
1118                    "\"specificExclusions\"",
1119                    "\"chopBefore\"",
1120                    "COLON",
1121                    "\"chopAfter\"",
1122                    "\"minimum\"",
1123                    "\"maximum\"",
1124                    "\"specificationFilter\"",
1125                    "FILTER",
1126                    "SAFEUTF8STRING",
1127                    "INTEGER",
1128                    "DESCR",
1129                    "NUMERICOID",
1130                    "\"item\"",
1131                    "\"and\"",
1132                    "\"or\"",
1133                    "\"not\"",
1134                    "INTEGER_OR_NUMERICOID",
1135                    "DOT",
1136                    "DIGIT",
1137                    "LDIGIT",
1138                    "ALPHA",
1139                    "SAFEUTF8CHAR",
1140                    "FILTER_VALUE"
1141            };
1142            
1143            
1144            }