View Javadoc
1   // $ANTLR 2.7.7 (20060906): "subtree-specification.g" -> "AntlrSubtreeSpecificationParser.java"$
2   
3   /*
4    *  Licensed to the Apache Software Foundation (ASF) under one
5    *  or more contributor license agreements.  See the NOTICE file
6    *  distributed with this work for additional information
7    *  regarding copyright ownership.  The ASF licenses this file
8    *  to you under the Apache License, Version 2.0 (the
9    *  "License"); you may not use this file except in compliance
10   *  with the License.  You may obtain a copy of the License at
11   *  
12   *    https://www.apache.org/licenses/LICENSE-2.0
13   *  
14   *  Unless required by applicable law or agreed to in writing,
15   *  software distributed under the License is distributed on an
16   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   *  KIND, either express or implied.  See the License for the
18   *  specific language governing permissions and limitations
19   *  under the License. 
20   *  
21   */
22  
23  
24  package org.apache.directory.api.ldap.model.subtree;
25  
26  import java.util.Set;
27  import java.util.Map;
28  import java.util.HashSet;
29  import java.util.List;
30  import java.util.ArrayList;
31  
32  import org.apache.directory.api.i18n.I18n;
33  import org.apache.directory.api.ldap.model.name.Dn;
34  import org.apache.directory.api.ldap.model.filter.ExprNode;
35  import org.apache.directory.api.ldap.model.filter.LeafNode;
36  import org.apache.directory.api.ldap.model.filter.BranchNode;
37  import org.apache.directory.api.ldap.model.filter.AndNode;
38  import org.apache.directory.api.ldap.model.filter.OrNode;
39  import org.apache.directory.api.ldap.model.filter.NotNode;
40  import org.apache.directory.api.ldap.model.filter.EqualityNode;
41  import org.apache.directory.api.ldap.model.filter.FilterParser;
42  import org.apache.directory.api.ldap.model.schema.ObjectClass;
43  import org.apache.directory.api.ldap.model.schema.SchemaManager;
44  import org.apache.directory.api.ldap.model.subtree.SubtreeSpecification;
45  import org.apache.directory.api.ldap.model.subtree.SubtreeSpecificationModifier;
46  import org.apache.directory.api.ldap.model.schema.NormalizerMappingResolver;
47  import org.apache.directory.api.ldap.model.schema.normalizers.OidNormalizer;
48  import org.apache.directory.api.util.ComponentsMonitor;
49  import org.apache.directory.api.util.OptionalComponentsMonitor;
50  import org.apache.directory.api.ldap.model.constants.SchemaConstants;
51  import org.apache.directory.api.ldap.model.entry.Value;
52  import org.apache.directory.api.ldap.model.exception.LdapException;
53  import org.apache.directory.api.ldap.model.schema.AttributeType;
54  
55  import org.slf4j.Logger;
56  import org.slf4j.LoggerFactory;
57  
58  import antlr.TokenBuffer;
59  import antlr.TokenStreamException;
60  import antlr.TokenStreamIOException;
61  import antlr.ANTLRException;
62  import antlr.LLkParser;
63  import antlr.Token;
64  import antlr.TokenStream;
65  import antlr.RecognitionException;
66  import antlr.NoViableAltException;
67  import antlr.MismatchedTokenException;
68  import antlr.SemanticException;
69  import antlr.ParserSharedInputState;
70  import antlr.collections.impl.BitSet;
71  
72  /**
73   * The antlr generated subtree specification parser.
74   *
75   * @see <a href="http://www.faqs.org/rfcs/rfc3672.html">RFC 3672</a>
76   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
77   */
78  public class AntlrSubtreeSpecificationParser extends antlr.LLkParser       implements AntlrSubtreeSpecificationParserTokenTypes
79   {
80  
81      private static final Logger LOG = LoggerFactory.getLogger( AntlrSubtreeSpecificationParser.class );
82      
83      private NormalizerMappingResolver resolver;
84      
85      private Set<Dn> chopBeforeExclusions = null;
86      private Set<Dn> chopAfterExclusions = null;
87  
88      private SubtreeSpecificationModifier ssModifier = null;
89      
90      /** The schemaManager */
91      private SchemaManager schemaManager;
92      
93      /** The ObjectClass AT */
94      AttributeType OBJECT_CLASS_AT;
95      
96      private ComponentsMonitor subtreeSpecificationComponentsMonitor = null;
97      
98      
99  
100     /**
101      * Initialize the parser
102      *
103      * @param schemaManager the SchemaManager instance
104      */
105     public void init( SchemaManager schemaManager )
106     {
107         this.schemaManager = schemaManager;
108         
109         if ( schemaManager != null )
110         {
111             OBJECT_CLASS_AT = schemaManager.getAttributeType( SchemaConstants.OBJECT_CLASS_AT );
112         }
113     }
114     
115     
116     public void setNormalizerMappingResolver( NormalizerMappingResolver resolver )
117     {
118         this.resolver = resolver;
119     }
120     
121     
122     public boolean isNormalizing()
123     {
124         return this.resolver != null;
125     }
126     
127 
128     private int token2Integer( Token token ) throws RecognitionException
129     {
130         int i = 0;
131         
132         try
133         {
134             i = Integer.parseInt( token.getText());
135         }
136         catch ( NumberFormatException e )
137         {
138             throw new RecognitionException( I18n.err( I18n.ERR_13900_INTEGER_TOKEN_NOT_INTEGER, token.getText() ) );
139         }
140         
141         return i;
142     }
143 
144 protected AntlrSubtreeSpecificationParser(TokenBuffer tokenBuf, int k) {
145   super(tokenBuf,k);
146   tokenNames = _tokenNames;
147 }
148 
149 public AntlrSubtreeSpecificationParser(TokenBuffer tokenBuf) {
150   this(tokenBuf,1);
151 }
152 
153 protected AntlrSubtreeSpecificationParser(TokenStream lexer, int k) {
154   super(lexer,k);
155   tokenNames = _tokenNames;
156 }
157 
158 public AntlrSubtreeSpecificationParser(TokenStream lexer) {
159   this(lexer,1);
160 }
161 
162 public AntlrSubtreeSpecificationParser(ParserSharedInputState state) {
163   super(state,1);
164   tokenNames = _tokenNames;
165 }
166 
167 	public final SubtreeSpecification  wrapperEntryPoint() throws RecognitionException, TokenStreamException {
168 		SubtreeSpecification ss;
169 		
170 		
171 		LOG.debug( "entered wrapperEntryPoint()" );
172 		ss = null;
173 		SubtreeSpecification tempSs = null;
174 		
175 		
176 		tempSs=subtreeSpecification();
177 		match(LITERAL_end);
178 		
179 		ss = tempSs;
180 		
181 		return ss;
182 	}
183 	
184 	public final SubtreeSpecification  subtreeSpecification() throws RecognitionException, TokenStreamException {
185 		SubtreeSpecification ss;
186 		
187 		
188 		LOG.debug( "entered subtreeSpecification()" );
189 		// clear out ss, ssModifier, subtreeSpecificationComponentsMonitor,
190 		// chopBeforeExclusions and chopAfterExclusions
191 		// in case something is left from the last parse
192 		ss = null;
193 		ssModifier = new SubtreeSpecificationModifier();
194 		subtreeSpecificationComponentsMonitor = new OptionalComponentsMonitor( 
195 		new String [] { "base", "specificExclusions", "minimum", "maximum", "specificationFilter" } );
196 		chopBeforeExclusions = new HashSet<Dn>();
197 		chopAfterExclusions = new HashSet<Dn>();
198 		// always create a new filter parser in case we may have some statefulness problems with it
199 		
200 		
201 		match(OPEN_CURLY);
202 		{
203 		_loop4:
204 		do {
205 			if ((LA(1)==SP)) {
206 				match(SP);
207 			}
208 			else {
209 				break _loop4;
210 			}
211 			
212 		} while (true);
213 		}
214 		{
215 		switch ( LA(1)) {
216 		case ID_base:
217 		case ID_specificExclusions:
218 		case ID_minimum:
219 		case ID_maximum:
220 		case ID_specificationFilter:
221 		{
222 			subtreeSpecificationComponent();
223 			{
224 			_loop7:
225 			do {
226 				if ((LA(1)==SP)) {
227 					match(SP);
228 				}
229 				else {
230 					break _loop7;
231 				}
232 				
233 			} while (true);
234 			}
235 			{
236 			_loop13:
237 			do {
238 				if ((LA(1)==SEP)) {
239 					match(SEP);
240 					{
241 					_loop10:
242 					do {
243 						if ((LA(1)==SP)) {
244 							match(SP);
245 						}
246 						else {
247 							break _loop10;
248 						}
249 						
250 					} while (true);
251 					}
252 					subtreeSpecificationComponent();
253 					{
254 					_loop12:
255 					do {
256 						if ((LA(1)==SP)) {
257 							match(SP);
258 						}
259 						else {
260 							break _loop12;
261 						}
262 						
263 					} while (true);
264 					}
265 				}
266 				else {
267 					break _loop13;
268 				}
269 				
270 			} while (true);
271 			}
272 			break;
273 		}
274 		case CLOSE_CURLY:
275 		{
276 			break;
277 		}
278 		default:
279 		{
280 			throw new NoViableAltException(LT(1), getFilename());
281 		}
282 		}
283 		}
284 		match(CLOSE_CURLY);
285 		
286 		ss = ssModifier.getSubtreeSpecification();
287 		
288 		return ss;
289 	}
290 	
291 	public final void subtreeSpecificationComponent() throws RecognitionException, TokenStreamException {
292 		
293 		
294 		LOG.debug( "entered subtreeSpecification()" );
295 		
296 		
297 		try {      // for error handling
298 			switch ( LA(1)) {
299 			case ID_base:
300 			{
301 				ss_base();
302 				
303 				subtreeSpecificationComponentsMonitor.useComponent( "base" );
304 				
305 				break;
306 			}
307 			case ID_specificExclusions:
308 			{
309 				ss_specificExclusions();
310 				
311 				subtreeSpecificationComponentsMonitor.useComponent( "specificExclusions" );
312 				
313 				break;
314 			}
315 			case ID_minimum:
316 			{
317 				ss_minimum();
318 				
319 				subtreeSpecificationComponentsMonitor.useComponent( "minimum" );
320 				
321 				break;
322 			}
323 			case ID_maximum:
324 			{
325 				ss_maximum();
326 				
327 				subtreeSpecificationComponentsMonitor.useComponent( "maximum" );
328 				
329 				break;
330 			}
331 			case ID_specificationFilter:
332 			{
333 				ss_specificationFilter();
334 				
335 				subtreeSpecificationComponentsMonitor.useComponent( "specificationFilter" );
336 				
337 				break;
338 			}
339 			default:
340 			{
341 				throw new NoViableAltException(LT(1), getFilename());
342 			}
343 			}
344 		}
345 		catch (IllegalArgumentException e) {
346 			
347 			throw new RecognitionException( I18n.err( I18n.ERR_13901_MESSAGE, e.getMessage() ) );
348 			
349 		}
350 	}
351 	
352 	public final void ss_base() throws RecognitionException, TokenStreamException {
353 		
354 		
355 		LOG.debug( "entered ss_base()" );
356 		Dn base = null;
357 		
358 		
359 		match(ID_base);
360 		{
361 		int _cnt17=0;
362 		_loop17:
363 		do {
364 			if ((LA(1)==SP)) {
365 				match(SP);
366 			}
367 			else {
368 				if ( _cnt17>=1 ) { break _loop17; } else {throw new NoViableAltException(LT(1), getFilename());}
369 			}
370 			
371 			_cnt17++;
372 		} while (true);
373 		}
374 		base=distinguishedName();
375 		
376 		ssModifier.setBase( base );
377 		
378 	}
379 	
380 	public final void ss_specificExclusions() throws RecognitionException, TokenStreamException {
381 		
382 		
383 		LOG.debug( "entered ss_specificExclusions()" );
384 		
385 		
386 		match(ID_specificExclusions);
387 		{
388 		int _cnt20=0;
389 		_loop20:
390 		do {
391 			if ((LA(1)==SP)) {
392 				match(SP);
393 			}
394 			else {
395 				if ( _cnt20>=1 ) { break _loop20; } else {throw new NoViableAltException(LT(1), getFilename());}
396 			}
397 			
398 			_cnt20++;
399 		} while (true);
400 		}
401 		specificExclusions();
402 		
403 		ssModifier.setChopBeforeExclusions( chopBeforeExclusions );
404 		ssModifier.setChopAfterExclusions( chopAfterExclusions );
405 		
406 	}
407 	
408 	public final void ss_minimum() throws RecognitionException, TokenStreamException {
409 		
410 		
411 		LOG.debug( "entered ss_minimum()" );
412 		int minimum = 0;
413 		
414 		
415 		match(ID_minimum);
416 		{
417 		int _cnt46=0;
418 		_loop46:
419 		do {
420 			if ((LA(1)==SP)) {
421 				match(SP);
422 			}
423 			else {
424 				if ( _cnt46>=1 ) { break _loop46; } else {throw new NoViableAltException(LT(1), getFilename());}
425 			}
426 			
427 			_cnt46++;
428 		} while (true);
429 		}
430 		minimum=baseDistance();
431 		
432 		ssModifier.setMinBaseDistance( minimum );
433 		
434 	}
435 	
436 	public final void ss_maximum() throws RecognitionException, TokenStreamException {
437 		
438 		
439 		LOG.debug( "entered ss_maximum()" );
440 		int maximum = 0;
441 		
442 		
443 		match(ID_maximum);
444 		{
445 		int _cnt49=0;
446 		_loop49:
447 		do {
448 			if ((LA(1)==SP)) {
449 				match(SP);
450 			}
451 			else {
452 				if ( _cnt49>=1 ) { break _loop49; } else {throw new NoViableAltException(LT(1), getFilename());}
453 			}
454 			
455 			_cnt49++;
456 		} while (true);
457 		}
458 		maximum=baseDistance();
459 		
460 		ssModifier.setMaxBaseDistance( maximum );
461 		
462 	}
463 	
464 	public final void ss_specificationFilter() throws RecognitionException, TokenStreamException {
465 		
466 		
467 		LOG.debug( "entered ss_specificationFilter()" );
468 		ExprNode filterExpr = null;
469 		
470 		
471 		match(ID_specificationFilter);
472 		{
473 		int _cnt52=0;
474 		_loop52:
475 		do {
476 			if ((LA(1)==SP)) {
477 				match(SP);
478 			}
479 			else {
480 				if ( _cnt52>=1 ) { break _loop52; } else {throw new NoViableAltException(LT(1), getFilename());}
481 			}
482 			
483 			_cnt52++;
484 		} while (true);
485 		}
486 		{
487 		switch ( LA(1)) {
488 		case ID_item:
489 		case ID_and:
490 		case ID_or:
491 		case ID_not:
492 		{
493 			{
494 			filterExpr=refinement();
495 			}
496 			break;
497 		}
498 		case FILTER:
499 		{
500 			{
501 			filterExpr=filter();
502 			}
503 			break;
504 		}
505 		default:
506 		{
507 			throw new NoViableAltException(LT(1), getFilename());
508 		}
509 		}
510 		}
511 		ssModifier.setRefinement( filterExpr );
512 	}
513 	
514 	public final  Dn  distinguishedName() throws RecognitionException, TokenStreamException {
515 		 Dn name ;
516 		
517 		Token  token = null;
518 		
519 		LOG.debug( "entered distinguishedName()" );
520 		name = null;
521 		
522 		
523 		try {      // for error handling
524 			token = LT(1);
525 			match(SAFEUTF8STRING);
526 			
527 			name = new Dn( schemaManager, token.getText() );
528 			
529 			if ( LOG.isDebugEnabled() )
530 			{
531 			LOG.debug( "recognized a DistinguishedName: {}", token.getText() );
532 			}
533 			
534 		}
535 		catch (Exception e) {
536 			
537 			throw new RecognitionException( I18n.err( I18n.ERR_13903_DN_PARSER_FAILED, token.getText(), e.getMessage() ) );
538 			
539 		}
540 		return name ;
541 	}
542 	
543 	public final void specificExclusions() throws RecognitionException, TokenStreamException {
544 		
545 		
546 		LOG.debug( "entered specificExclusions()" );
547 		
548 		
549 		match(OPEN_CURLY);
550 		{
551 		_loop23:
552 		do {
553 			if ((LA(1)==SP)) {
554 				match(SP);
555 			}
556 			else {
557 				break _loop23;
558 			}
559 			
560 		} while (true);
561 		}
562 		{
563 		switch ( LA(1)) {
564 		case ID_chopBefore:
565 		case ID_chopAfter:
566 		{
567 			specificExclusion();
568 			{
569 			_loop26:
570 			do {
571 				if ((LA(1)==SP)) {
572 					match(SP);
573 				}
574 				else {
575 					break _loop26;
576 				}
577 				
578 			} while (true);
579 			}
580 			{
581 			_loop32:
582 			do {
583 				if ((LA(1)==SEP)) {
584 					match(SEP);
585 					{
586 					_loop29:
587 					do {
588 						if ((LA(1)==SP)) {
589 							match(SP);
590 						}
591 						else {
592 							break _loop29;
593 						}
594 						
595 					} while (true);
596 					}
597 					specificExclusion();
598 					{
599 					_loop31:
600 					do {
601 						if ((LA(1)==SP)) {
602 							match(SP);
603 						}
604 						else {
605 							break _loop31;
606 						}
607 						
608 					} while (true);
609 					}
610 				}
611 				else {
612 					break _loop32;
613 				}
614 				
615 			} while (true);
616 			}
617 			break;
618 		}
619 		case CLOSE_CURLY:
620 		{
621 			break;
622 		}
623 		default:
624 		{
625 			throw new NoViableAltException(LT(1), getFilename());
626 		}
627 		}
628 		}
629 		match(CLOSE_CURLY);
630 	}
631 	
632 	public final void specificExclusion() throws RecognitionException, TokenStreamException {
633 		
634 		
635 		LOG.debug( "entered specificExclusion()" );
636 		
637 		
638 		switch ( LA(1)) {
639 		case ID_chopBefore:
640 		{
641 			chopBefore();
642 			break;
643 		}
644 		case ID_chopAfter:
645 		{
646 			chopAfter();
647 			break;
648 		}
649 		default:
650 		{
651 			throw new NoViableAltException(LT(1), getFilename());
652 		}
653 		}
654 	}
655 	
656 	public final void chopBefore() throws RecognitionException, TokenStreamException {
657 		
658 		
659 		LOG.debug( "entered chopBefore()" );
660 		Dn chopBeforeExclusion = null;
661 		
662 		
663 		match(ID_chopBefore);
664 		{
665 		_loop36:
666 		do {
667 			if ((LA(1)==SP)) {
668 				match(SP);
669 			}
670 			else {
671 				break _loop36;
672 			}
673 			
674 		} while (true);
675 		}
676 		match(COLON);
677 		{
678 		_loop38:
679 		do {
680 			if ((LA(1)==SP)) {
681 				match(SP);
682 			}
683 			else {
684 				break _loop38;
685 			}
686 			
687 		} while (true);
688 		}
689 		chopBeforeExclusion=distinguishedName();
690 		
691 		chopBeforeExclusions.add( chopBeforeExclusion );
692 		
693 	}
694 	
695 	public final void chopAfter() throws RecognitionException, TokenStreamException {
696 		
697 		
698 		LOG.debug( "entered chopAfter()" );
699 		Dn chopAfterExclusion = null;
700 		
701 		
702 		match(ID_chopAfter);
703 		{
704 		_loop41:
705 		do {
706 			if ((LA(1)==SP)) {
707 				match(SP);
708 			}
709 			else {
710 				break _loop41;
711 			}
712 			
713 		} while (true);
714 		}
715 		match(COLON);
716 		{
717 		_loop43:
718 		do {
719 			if ((LA(1)==SP)) {
720 				match(SP);
721 			}
722 			else {
723 				break _loop43;
724 			}
725 			
726 		} while (true);
727 		}
728 		chopAfterExclusion=distinguishedName();
729 		
730 		chopAfterExclusions.add( chopAfterExclusion );
731 		
732 	}
733 	
734 	public final  int  baseDistance() throws RecognitionException, TokenStreamException {
735 		 int distance ;
736 		
737 		Token  token = null;
738 		
739 		LOG.debug( "entered baseDistance()" );
740 		distance = 0;
741 		
742 		
743 		token = LT(1);
744 		match(INTEGER);
745 		
746 		distance = token2Integer( token );
747 		
748 		return distance ;
749 	}
750 	
751 	public final  ExprNode  refinement() throws RecognitionException, TokenStreamException {
752 		 ExprNode node ;
753 		
754 		
755 		LOG.debug( "entered refinement()" );
756 		node = null;
757 		
758 		
759 		switch ( LA(1)) {
760 		case ID_item:
761 		{
762 			node=item();
763 			break;
764 		}
765 		case ID_and:
766 		{
767 			node=and();
768 			break;
769 		}
770 		case ID_or:
771 		{
772 			node=or();
773 			break;
774 		}
775 		case ID_not:
776 		{
777 			node=not();
778 			break;
779 		}
780 		default:
781 		{
782 			throw new NoViableAltException(LT(1), getFilename());
783 		}
784 		}
785 		return node ;
786 	}
787 	
788 	public final ExprNode  filter() throws RecognitionException, TokenStreamException {
789 		 ExprNode filterExpr = null ;
790 		
791 		Token  filterToken = null;
792 		
793 		LOG.debug( "entered filter()" );
794 		
795 		
796 		try {      // for error handling
797 			{
798 			filterToken = LT(1);
799 			match(FILTER);
800 			filterExpr=FilterParser.parse( schemaManager, filterToken.getText() );
801 			}
802 		}
803 		catch (Exception e) {
804 			
805 			throw new RecognitionException( I18n.err( I18n.ERR_13902_FILTER_PARSER_FAILED, e.getMessage() ) );
806 			
807 		}
808 		return filterExpr;
809 	}
810 	
811 	public final  String  oid() throws RecognitionException, TokenStreamException {
812 		 String result ;
813 		
814 		
815 		LOG.debug( "entered oid()" );
816 		result = null;
817 		Token token = null;
818 		
819 		
820 		token = LT( 1 );
821 		{
822 		switch ( LA(1)) {
823 		case DESCR:
824 		{
825 			match(DESCR);
826 			break;
827 		}
828 		case NUMERICOID:
829 		{
830 			match(NUMERICOID);
831 			break;
832 		}
833 		default:
834 		{
835 			throw new NoViableAltException(LT(1), getFilename());
836 		}
837 		}
838 		}
839 		
840 		result = token.getText();
841 		
842 		if ( LOG.isDebugEnabled() )
843 		{
844 		LOG.debug( "recognized an oid: {}", result );
845 		}
846 		
847 		return result ;
848 	}
849 	
850 	public final  LeafNode  item() throws RecognitionException, TokenStreamException {
851 		 LeafNode node ;
852 		
853 		
854 		LOG.debug( "entered item()" );
855 		node = null;
856 		String oid = null;
857 		ObjectClass objectClass;
858 		
859 		
860 		match(ID_item);
861 		{
862 		_loop65:
863 		do {
864 			if ((LA(1)==SP)) {
865 				match(SP);
866 			}
867 			else {
868 				break _loop65;
869 			}
870 			
871 		} while (true);
872 		}
873 		match(COLON);
874 		{
875 		_loop67:
876 		do {
877 			if ((LA(1)==SP)) {
878 				match(SP);
879 			}
880 			else {
881 				break _loop67;
882 			}
883 			
884 		} while (true);
885 		}
886 		oid=oid();
887 		
888 		try
889 		{
890 		objectClass = schemaManager.lookupObjectClassRegistry( oid );
891 		}
892 		catch ( LdapException le )
893 		{
894 		// The oid does not exist
895 		// TODO : deal with such an exception
896 		}
897 		
898 		node = new EqualityNode( OBJECT_CLASS_AT, new Value( oid ) );
899 		
900 		return node ;
901 	}
902 	
903 	public final  BranchNode  and() throws RecognitionException, TokenStreamException {
904 		 BranchNode node ;
905 		
906 		
907 		LOG.debug( "entered and()" );
908 		node = null;
909 		List<ExprNode> children = null; 
910 		
911 		
912 		match(ID_and);
913 		{
914 		_loop70:
915 		do {
916 			if ((LA(1)==SP)) {
917 				match(SP);
918 			}
919 			else {
920 				break _loop70;
921 			}
922 			
923 		} while (true);
924 		}
925 		match(COLON);
926 		{
927 		_loop72:
928 		do {
929 			if ((LA(1)==SP)) {
930 				match(SP);
931 			}
932 			else {
933 				break _loop72;
934 			}
935 			
936 		} while (true);
937 		}
938 		children=refinements();
939 		
940 		node = new AndNode( children );
941 		
942 		return node ;
943 	}
944 	
945 	public final  BranchNode  or() throws RecognitionException, TokenStreamException {
946 		 BranchNode node ;
947 		
948 		
949 		LOG.debug( "entered or()" );
950 		node = null;
951 		List<ExprNode> children = null; 
952 		
953 		
954 		match(ID_or);
955 		{
956 		_loop75:
957 		do {
958 			if ((LA(1)==SP)) {
959 				match(SP);
960 			}
961 			else {
962 				break _loop75;
963 			}
964 			
965 		} while (true);
966 		}
967 		match(COLON);
968 		{
969 		_loop77:
970 		do {
971 			if ((LA(1)==SP)) {
972 				match(SP);
973 			}
974 			else {
975 				break _loop77;
976 			}
977 			
978 		} while (true);
979 		}
980 		children=refinements();
981 		
982 		node = new OrNode( children );
983 		
984 		return node ;
985 	}
986 	
987 	public final  BranchNode  not() throws RecognitionException, TokenStreamException {
988 		 BranchNode node ;
989 		
990 		
991 		LOG.debug( "entered not()" );
992 		node = null;
993 		ExprNode child = null;
994 		
995 		
996 		match(ID_not);
997 		{
998 		_loop80:
999 		do {
1000 			if ((LA(1)==SP)) {
1001 				match(SP);
1002 			}
1003 			else {
1004 				break _loop80;
1005 			}
1006 			
1007 		} while (true);
1008 		}
1009 		match(COLON);
1010 		{
1011 		_loop82:
1012 		do {
1013 			if ((LA(1)==SP)) {
1014 				match(SP);
1015 			}
1016 			else {
1017 				break _loop82;
1018 			}
1019 			
1020 		} while (true);
1021 		}
1022 		child=refinement();
1023 		
1024 		node = new NotNode( child );
1025 		
1026 		return node ;
1027 	}
1028 	
1029 	public final  List<ExprNode>  refinements() throws RecognitionException, TokenStreamException {
1030 		 List<ExprNode> children ;
1031 		
1032 		
1033 		LOG.debug( "entered refinements()" );
1034 		children = null;
1035 		ExprNode child = null;
1036 		List<ExprNode> tempChildren = new ArrayList<ExprNode>();
1037 		
1038 		
1039 		match(OPEN_CURLY);
1040 		{
1041 		_loop85:
1042 		do {
1043 			if ((LA(1)==SP)) {
1044 				match(SP);
1045 			}
1046 			else {
1047 				break _loop85;
1048 			}
1049 			
1050 		} while (true);
1051 		}
1052 		{
1053 		switch ( LA(1)) {
1054 		case ID_item:
1055 		case ID_and:
1056 		case ID_or:
1057 		case ID_not:
1058 		{
1059 			child=refinement();
1060 			{
1061 			_loop88:
1062 			do {
1063 				if ((LA(1)==SP)) {
1064 					match(SP);
1065 				}
1066 				else {
1067 					break _loop88;
1068 				}
1069 				
1070 			} while (true);
1071 			}
1072 			
1073 			tempChildren.add( child );
1074 			
1075 			{
1076 			_loop94:
1077 			do {
1078 				if ((LA(1)==SEP)) {
1079 					match(SEP);
1080 					{
1081 					_loop91:
1082 					do {
1083 						if ((LA(1)==SP)) {
1084 							match(SP);
1085 						}
1086 						else {
1087 							break _loop91;
1088 						}
1089 						
1090 					} while (true);
1091 					}
1092 					child=refinement();
1093 					{
1094 					_loop93:
1095 					do {
1096 						if ((LA(1)==SP)) {
1097 							match(SP);
1098 						}
1099 						else {
1100 							break _loop93;
1101 						}
1102 						
1103 					} while (true);
1104 					}
1105 					
1106 					tempChildren.add( child );
1107 					
1108 				}
1109 				else {
1110 					break _loop94;
1111 				}
1112 				
1113 			} while (true);
1114 			}
1115 			break;
1116 		}
1117 		case CLOSE_CURLY:
1118 		{
1119 			break;
1120 		}
1121 		default:
1122 		{
1123 			throw new NoViableAltException(LT(1), getFilename());
1124 		}
1125 		}
1126 		}
1127 		match(CLOSE_CURLY);
1128 		
1129 		children = tempChildren;
1130 		
1131 		return children ;
1132 	}
1133 	
1134 	
1135 	public static final String[] _tokenNames = {
1136 		"<0>",
1137 		"EOF",
1138 		"<2>",
1139 		"NULL_TREE_LOOKAHEAD",
1140 		"\"end\"",
1141 		"OPEN_CURLY",
1142 		"SP",
1143 		"SEP",
1144 		"CLOSE_CURLY",
1145 		"\"base\"",
1146 		"\"specificExclusions\"",
1147 		"\"chopBefore\"",
1148 		"COLON",
1149 		"\"chopAfter\"",
1150 		"\"minimum\"",
1151 		"\"maximum\"",
1152 		"\"specificationFilter\"",
1153 		"FILTER",
1154 		"SAFEUTF8STRING",
1155 		"INTEGER",
1156 		"DESCR",
1157 		"NUMERICOID",
1158 		"\"item\"",
1159 		"\"and\"",
1160 		"\"or\"",
1161 		"\"not\"",
1162 		"INTEGER_OR_NUMERICOID",
1163 		"DOT",
1164 		"DIGIT",
1165 		"LDIGIT",
1166 		"ALPHA",
1167 		"SAFEUTF8CHAR",
1168 		"FILTER_VALUE"
1169 	};
1170 	
1171 	
1172 	}