001 // $ANTLR 2.7.4: "schema-extension.g" -> "AntlrSchemaExtensionLexer.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 package org.apache.directory.shared.ldap.schema.syntax;
023
024 import java.io.StringReader;
025 import java.util.List;
026
027
028 import java.io.InputStream;
029 import antlr.TokenStreamException;
030 import antlr.TokenStreamIOException;
031 import antlr.TokenStreamRecognitionException;
032 import antlr.CharStreamException;
033 import antlr.CharStreamIOException;
034 import antlr.ANTLRException;
035 import java.io.Reader;
036 import java.util.Hashtable;
037 import antlr.CharScanner;
038 import antlr.InputBuffer;
039 import antlr.ByteBuffer;
040 import antlr.CharBuffer;
041 import antlr.Token;
042 import antlr.CommonToken;
043 import antlr.RecognitionException;
044 import antlr.NoViableAltForCharException;
045 import antlr.MismatchedCharException;
046 import antlr.TokenStream;
047 import antlr.ANTLRHashString;
048 import antlr.LexerSharedInputState;
049 import antlr.collections.impl.BitSet;
050 import antlr.SemanticException;
051
052 /**
053 * An antlr generated schema lexer. This is a sub-lexer.
054 *
055 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
056 * @version $Rev$
057 */
058 public class AntlrSchemaExtensionLexer extends antlr.CharScanner implements AntlrSchemaExtensionTokenTypes, TokenStream
059 {
060 public AntlrSchemaExtensionLexer(InputStream in) {
061 this(new ByteBuffer(in));
062 }
063 public AntlrSchemaExtensionLexer(Reader in) {
064 this(new CharBuffer(in));
065 }
066 public AntlrSchemaExtensionLexer(InputBuffer ib) {
067 this(new LexerSharedInputState(ib));
068 }
069 public AntlrSchemaExtensionLexer(LexerSharedInputState state) {
070 super(state);
071 caseSensitiveLiterals = true;
072 setCaseSensitive(false);
073 literals = new Hashtable();
074 }
075
076 public Token nextToken() throws TokenStreamException {
077 Token theRetToken=null;
078 tryAgain:
079 for (;;) {
080 Token _token = null;
081 int _ttype = Token.INVALID_TYPE;
082 resetText();
083 try { // for char stream error handling
084 try { // for lexical error handling
085 switch ( LA(1)) {
086 case 'x':
087 {
088 mXKEY(true);
089 theRetToken=_returnToken;
090 break;
091 }
092 case '\t': case '\n': case '\r': case ' ':
093 case '\'': case '(':
094 {
095 mXVALUES(true);
096 theRetToken=_returnToken;
097 break;
098 }
099 default:
100 {
101 if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);}
102 else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
103 }
104 }
105 if ( _returnToken==null ) continue tryAgain; // found SKIP token
106 _ttype = _returnToken.getType();
107 _ttype = testLiteralsTable(_ttype);
108 _returnToken.setType(_ttype);
109 return _returnToken;
110 }
111 catch (RecognitionException e) {
112 throw new TokenStreamRecognitionException(e);
113 }
114 }
115 catch (CharStreamException cse) {
116 if ( cse instanceof CharStreamIOException ) {
117 throw new TokenStreamIOException(((CharStreamIOException)cse).io);
118 }
119 else {
120 throw new TokenStreamException(cse.getMessage());
121 }
122 }
123 }
124 }
125
126 protected final void mWHSP(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
127 int _ttype; Token _token=null; int _begin=text.length();
128 _ttype = WHSP;
129 int _saveIndex;
130
131 {
132 int _cnt920=0;
133 _loop920:
134 do {
135 if ((LA(1)==' ') && (true)) {
136 match(' ');
137 }
138 else if ((LA(1)=='\t') && (true)) {
139 match('\t');
140 }
141 else if ((LA(1)=='\r') && (true)) {
142 match('\r');
143 {
144 if ((LA(1)=='\n') && (true)) {
145 match('\n');
146 }
147 else {
148 }
149
150 }
151 newline();
152 }
153 else if ((LA(1)=='\n') && (true)) {
154 match('\n');
155 newline();
156 }
157 else {
158 if ( _cnt920>=1 ) { break _loop920; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
159 }
160
161 _cnt920++;
162 } while (true);
163 }
164 _ttype = Token.SKIP;
165 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
166 _token = makeToken(_ttype);
167 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
168 }
169 _returnToken = _token;
170 }
171
172 protected final void mQUOTE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
173 int _ttype; Token _token=null; int _begin=text.length();
174 _ttype = QUOTE;
175 int _saveIndex;
176
177 match('\'');
178 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
179 _token = makeToken(_ttype);
180 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
181 }
182 _returnToken = _token;
183 }
184
185 public final void mXKEY(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
186 int _ttype; Token _token=null; int _begin=text.length();
187 _ttype = XKEY;
188 int _saveIndex;
189 Token xstring=null;
190
191 mXSTRING(true);
192 xstring=_returnToken;
193 setText(xstring.getText().trim());
194 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
195 _token = makeToken(_ttype);
196 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
197 }
198 _returnToken = _token;
199 }
200
201 protected final void mXSTRING(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
202 int _ttype; Token _token=null; int _begin=text.length();
203 _ttype = XSTRING;
204 int _saveIndex;
205
206 {
207 match("x-");
208 {
209 int _cnt927=0;
210 _loop927:
211 do {
212 switch ( LA(1)) {
213 case 'a': case 'b': case 'c': case 'd':
214 case 'e': case 'f': case 'g': case 'h':
215 case 'i': case 'j': case 'k': case 'l':
216 case 'm': case 'n': case 'o': case 'p':
217 case 'q': case 'r': case 's': case 't':
218 case 'u': case 'v': case 'w': case 'x':
219 case 'y': case 'z':
220 {
221 matchRange('a','z');
222 break;
223 }
224 case '-':
225 {
226 match('-');
227 break;
228 }
229 case '_':
230 {
231 match('_');
232 break;
233 }
234 default:
235 {
236 if ( _cnt927>=1 ) { break _loop927; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
237 }
238 }
239 _cnt927++;
240 } while (true);
241 }
242 {
243 if ((_tokenSet_0.member(LA(1)))) {
244 mWHSP(false);
245 }
246 else {
247 }
248
249 }
250 }
251 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
252 _token = makeToken(_ttype);
253 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
254 }
255 _returnToken = _token;
256 }
257
258 public final void mXVALUES(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
259 int _ttype; Token _token=null; int _begin=text.length();
260 _ttype = XVALUES;
261 int _saveIndex;
262 Token values=null;
263
264 mVALUES(true);
265 values=_returnToken;
266 setText(values.getText().trim());
267 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
268 _token = makeToken(_ttype);
269 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
270 }
271 _returnToken = _token;
272 }
273
274 protected final void mVALUES(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
275 int _ttype; Token _token=null; int _begin=text.length();
276 _ttype = VALUES;
277 int _saveIndex;
278
279 {
280 switch ( LA(1)) {
281 case '\t': case '\n': case '\r': case ' ':
282 case '\'':
283 {
284 mVALUE(false);
285 break;
286 }
287 case '(':
288 {
289 match('(');
290 mVALUE(false);
291 {
292 _loop933:
293 do {
294 if ((_tokenSet_1.member(LA(1)))) {
295 {
296 switch ( LA(1)) {
297 case '$':
298 {
299 match('$');
300 break;
301 }
302 case '\t': case '\n': case '\r': case ' ':
303 case '\'':
304 {
305 break;
306 }
307 default:
308 {
309 throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
310 }
311 }
312 }
313 mVALUE(false);
314 }
315 else {
316 break _loop933;
317 }
318
319 } while (true);
320 }
321 match(')');
322 break;
323 }
324 default:
325 {
326 throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
327 }
328 }
329 }
330 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
331 _token = makeToken(_ttype);
332 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
333 }
334 _returnToken = _token;
335 }
336
337 protected final void mVALUE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
338 int _ttype; Token _token=null; int _begin=text.length();
339 _ttype = VALUE;
340 int _saveIndex;
341
342 {
343 switch ( LA(1)) {
344 case '\t': case '\n': case '\r': case ' ':
345 {
346 mWHSP(false);
347 break;
348 }
349 case '\'':
350 {
351 break;
352 }
353 default:
354 {
355 throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
356 }
357 }
358 }
359 {
360 mQUOTED_STRING(false);
361 }
362 {
363 if ((_tokenSet_0.member(LA(1))) && (true)) {
364 mWHSP(false);
365 }
366 else {
367 }
368
369 }
370 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
371 _token = makeToken(_ttype);
372 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
373 }
374 _returnToken = _token;
375 }
376
377 protected final void mQUOTED_STRING(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
378 int _ttype; Token _token=null; int _begin=text.length();
379 _ttype = QUOTED_STRING;
380 int _saveIndex;
381
382 {
383 mQUOTE(false);
384 {
385 _loop941:
386 do {
387 if ((_tokenSet_2.member(LA(1)))) {
388 matchNot('\'');
389 }
390 else {
391 break _loop941;
392 }
393
394 } while (true);
395 }
396 mQUOTE(false);
397 }
398 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
399 _token = makeToken(_ttype);
400 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
401 }
402 _returnToken = _token;
403 }
404
405
406 private static final long[] mk_tokenSet_0() {
407 long[] data = new long[1025];
408 data[0]=4294977024L;
409 return data;
410 }
411 public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
412 private static final long[] mk_tokenSet_1() {
413 long[] data = new long[1025];
414 data[0]=622770267648L;
415 return data;
416 }
417 public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
418 private static final long[] mk_tokenSet_2() {
419 long[] data = new long[2048];
420 data[0]=-549755813889L;
421 for (int i = 1; i<=1022; i++) { data[i]=-1L; }
422 data[1023]=9223372036854775807L;
423 return data;
424 }
425 public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
426
427 }