View Javadoc
1   // $ANTLR 2.7.7 (20060906): "schema-extension.g" -> "AntlrSchemaExtensionParser.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   *    http://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  package org.apache.directory.api.ldap.model.schema.syntaxes;
23  
24  import java.io.StringReader;
25  import java.util.List;
26  
27  
28  import antlr.TokenBuffer;
29  import antlr.TokenStreamException;
30  import antlr.TokenStreamIOException;
31  import antlr.ANTLRException;
32  import antlr.LLkParser;
33  import antlr.Token;
34  import antlr.TokenStream;
35  import antlr.RecognitionException;
36  import antlr.NoViableAltException;
37  import antlr.MismatchedTokenException;
38  import antlr.SemanticException;
39  import antlr.ParserSharedInputState;
40  import antlr.collections.impl.BitSet;
41  
42  /**
43   * An antlr generated schema parser. This is a sub-parser used to parse
44   * extensions according to RFC4512.
45   *
46   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
47   */
48  public class AntlrSchemaExtensionParser extends antlr.LLkParser       implements AntlrSchemaExtensionTokenTypes
49   {
50  
51  protected AntlrSchemaExtensionParser(TokenBuffer tokenBuf, int k) {
52    super(tokenBuf,k);
53    tokenNames = _tokenNames;
54  }
55  
56  public AntlrSchemaExtensionParser(TokenBuffer tokenBuf) {
57    this(tokenBuf,3);
58  }
59  
60  protected AntlrSchemaExtensionParser(TokenStream lexer, int k) {
61    super(lexer,k);
62    tokenNames = _tokenNames;
63  }
64  
65  public AntlrSchemaExtensionParser(TokenStream lexer) {
66    this(lexer,3);
67  }
68  
69  public AntlrSchemaExtensionParser(ParserSharedInputState state) {
70    super(state,3);
71    tokenNames = _tokenNames;
72  }
73  
74  /**
75       * extensions = *( SP xstring SP qdstrings )
76       * xstring = "X" HYPHEN 1*( ALPHA / HYPHEN / USCORE )
77       */
78  	public final AntlrSchemaParser.Extension  extension() throws RecognitionException, TokenStreamException {
79  		AntlrSchemaParser.Extension extension = new AntlrSchemaParser.Extension();
80  		
81  		Token  xkey = null;
82  		Token  xvalues = null;
83  		
84  		{
85  		xkey = LT(1);
86  		match(XKEY);
87  		extension.key = xkey.getText();
88  		}
89  		{
90  		xvalues = LT(1);
91  		match(XVALUES);
92  		extension.values = qdstrings(xvalues.getText());
93  		}
94  		return extension;
95  	}
96  	
97  	public final List<String>  qdstrings(
98  		String s
99  	) throws RecognitionException, TokenStreamException {
100 		List<String> qdstrings;
101 		
102 		
103 		try 
104 		{
105 		AntlrSchemaQdstringLexer lexer = new AntlrSchemaQdstringLexer(new StringReader(s));
106 		AntlrSchemaQdstringParser parser = new AntlrSchemaQdstringParser(lexer);
107 		qdstrings = parser.qdstrings();
108 		}
109 		catch (RecognitionException re) {
110 		re.printStackTrace();
111 		throw re;
112 		}
113 		catch (TokenStreamException tse) {
114 		tse.printStackTrace();
115 		throw tse;
116 		}
117 		
118 		
119 		return qdstrings;
120 	}
121 	
122 	
123 	public static final String[] _tokenNames = {
124 		"<0>",
125 		"EOF",
126 		"<2>",
127 		"NULL_TREE_LOOKAHEAD",
128 		"WHSP",
129 		"QUOTE",
130 		"XKEY",
131 		"XVALUES",
132 		"XSTRING",
133 		"VALUES",
134 		"VALUE",
135 		"QUOTED_STRING"
136 	};
137 	
138 	
139 	}