001 // $ANTLR 2.7.4: "schema.g" -> "antlrSchemaLexer.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 * Keep the semicolon right next to the package name or else there will be a
024 * bug that comes into the foreground in the new antlr release.
025 */
026 package org.apache.directory.shared.converter.schema;
027 import java.util.List ;
028 import java.util.ArrayList ;
029 import java.util.Collections;
030 import java.io.IOException;
031
032 import org.apache.directory.shared.ldap.schema.UsageEnum;
033 import org.apache.directory.shared.converter.schema.SchemaElement;
034 import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
035
036 import java.io.InputStream;
037 import antlr.TokenStreamException;
038 import antlr.TokenStreamIOException;
039 import antlr.TokenStreamRecognitionException;
040 import antlr.CharStreamException;
041 import antlr.CharStreamIOException;
042 import antlr.ANTLRException;
043 import java.io.Reader;
044 import java.util.Hashtable;
045 import antlr.CharScanner;
046 import antlr.InputBuffer;
047 import antlr.ByteBuffer;
048 import antlr.CharBuffer;
049 import antlr.Token;
050 import antlr.CommonToken;
051 import antlr.RecognitionException;
052 import antlr.NoViableAltForCharException;
053 import antlr.MismatchedCharException;
054 import antlr.TokenStream;
055 import antlr.ANTLRHashString;
056 import antlr.LexerSharedInputState;
057 import antlr.collections.impl.BitSet;
058 import antlr.SemanticException;
059
060 public class antlrSchemaLexer extends antlr.CharScanner implements antlrSchemaTokenTypes, TokenStream
061 {
062 public antlrSchemaLexer(InputStream in) {
063 this(new ByteBuffer(in));
064 }
065 public antlrSchemaLexer(Reader in) {
066 this(new CharBuffer(in));
067 }
068 public antlrSchemaLexer(InputBuffer ib) {
069 this(new LexerSharedInputState(ib));
070 }
071 public antlrSchemaLexer(LexerSharedInputState state) {
072 super(state);
073 caseSensitiveLiterals = true;
074 setCaseSensitive(false);
075 literals = new Hashtable();
076 literals.put(new ANTLRHashString("NAME", this), new Integer(26));
077 literals.put(new ANTLRHashString("SINGLE-VALUE", this), new Integer(28));
078 literals.put(new ANTLRHashString("COLLECTIVE", this), new Integer(29));
079 literals.put(new ANTLRHashString("ABSTRACT", this), new Integer(20));
080 literals.put(new ANTLRHashString("MAY", this), new Integer(23));
081 literals.put(new ANTLRHashString("END", this), new Integer(17));
082 literals.put(new ANTLRHashString("SUP", this), new Integer(25));
083 literals.put(new ANTLRHashString("EQUALITY", this), new Integer(31));
084 literals.put(new ANTLRHashString("userApplications", this), new Integer(35));
085 literals.put(new ANTLRHashString("dSAOperation", this), new Integer(38));
086 literals.put(new ANTLRHashString("AUXILIARY", this), new Integer(22));
087 literals.put(new ANTLRHashString("objectclass", this), new Integer(18));
088 literals.put(new ANTLRHashString("directoryOperation", this), new Integer(36));
089 literals.put(new ANTLRHashString("OBSOLETE", this), new Integer(19));
090 literals.put(new ANTLRHashString("distributedOperation", this), new Integer(37));
091 literals.put(new ANTLRHashString("STRUCTURAL", this), new Integer(21));
092 literals.put(new ANTLRHashString("USAGE", this), new Integer(34));
093 literals.put(new ANTLRHashString("ORDERING", this), new Integer(33));
094 literals.put(new ANTLRHashString("attributetype", this), new Integer(27));
095 literals.put(new ANTLRHashString("NO-USER-MODIFICATION", this), new Integer(30));
096 literals.put(new ANTLRHashString("SUBSTR", this), new Integer(32));
097 literals.put(new ANTLRHashString("MUST", this), new Integer(24));
098 }
099
100 public Token nextToken() throws TokenStreamException {
101 Token theRetToken=null;
102 tryAgain:
103 for (;;) {
104 Token _token = null;
105 int _ttype = Token.INVALID_TYPE;
106 resetText();
107 try { // for char stream error handling
108 try { // for lexical error handling
109 switch ( LA(1)) {
110 case '\t': case '\n': case '\r': case ' ':
111 case '#':
112 {
113 mWS(true);
114 theRetToken=_returnToken;
115 break;
116 }
117 case '\'':
118 {
119 mQUOTE(true);
120 theRetToken=_returnToken;
121 break;
122 }
123 case '$':
124 {
125 mDOLLAR(true);
126 theRetToken=_returnToken;
127 break;
128 }
129 case '(':
130 {
131 mOPEN_PAREN(true);
132 theRetToken=_returnToken;
133 break;
134 }
135 case ')':
136 {
137 mCLOSE_PAREN(true);
138 theRetToken=_returnToken;
139 break;
140 }
141 case '{':
142 {
143 mOPEN_BRACKET(true);
144 theRetToken=_returnToken;
145 break;
146 }
147 case '}':
148 {
149 mCLOSE_BRACKET(true);
150 theRetToken=_returnToken;
151 break;
152 }
153 default:
154 if ((LA(1)=='s') && (LA(2)=='y') && (LA(3)=='n') && (LA(4)=='t') && (LA(5)=='a') && (LA(6)=='x') && (_tokenSet_0.member(LA(7)))) {
155 mSYNTAX(true);
156 theRetToken=_returnToken;
157 }
158 else if ((LA(1)=='d') && (LA(2)=='e') && (LA(3)=='s') && (LA(4)=='c') && (_tokenSet_0.member(LA(5)))) {
159 mDESC(true);
160 theRetToken=_returnToken;
161 }
162 else if (((LA(1) >= '0' && LA(1) <= '9')) && (_tokenSet_1.member(LA(2)))) {
163 mNUMERICOID(true);
164 theRetToken=_returnToken;
165 }
166 else if (((LA(1) >= '0' && LA(1) <= '9')) && (true)) {
167 mDIGIT(true);
168 theRetToken=_returnToken;
169 }
170 else if (((LA(1) >= 'a' && LA(1) <= 'z')) && (true) && (true) && (true) && (true) && (true) && (true)) {
171 mIDENTIFIER(true);
172 theRetToken=_returnToken;
173 }
174 else {
175 if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);}
176 else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
177 }
178 }
179 if ( _returnToken==null ) continue tryAgain; // found SKIP token
180 _ttype = _returnToken.getType();
181 _ttype = testLiteralsTable(_ttype);
182 _returnToken.setType(_ttype);
183 return _returnToken;
184 }
185 catch (RecognitionException e) {
186 throw new TokenStreamRecognitionException(e);
187 }
188 }
189 catch (CharStreamException cse) {
190 if ( cse instanceof CharStreamIOException ) {
191 throw new TokenStreamIOException(((CharStreamIOException)cse).io);
192 }
193 else {
194 throw new TokenStreamException(cse.getMessage());
195 }
196 }
197 }
198 }
199
200 public final void mWS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
201 int _ttype; Token _token=null; int _begin=text.length();
202 _ttype = WS;
203 int _saveIndex;
204
205 {
206 switch ( LA(1)) {
207 case '#':
208 {
209 match('#');
210 {
211 _loop1980:
212 do {
213 if ((_tokenSet_2.member(LA(1)))) {
214 matchNot('\n');
215 }
216 else {
217 break _loop1980;
218 }
219
220 } while (true);
221 }
222 match('\n');
223 newline();
224 break;
225 }
226 case ' ':
227 {
228 match(' ');
229 break;
230 }
231 case '\t':
232 {
233 match('\t');
234 break;
235 }
236 case '\n':
237 {
238 match('\n');
239 newline();
240 break;
241 }
242 default:
243 if ((LA(1)=='\r') && (LA(2)=='\n')) {
244 match('\r');
245 match('\n');
246 newline();
247 }
248 else if ((LA(1)=='\r') && (true)) {
249 match('\r');
250 newline();
251 }
252 else {
253 throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
254 }
255 }
256 }
257 _ttype = Token.SKIP;
258 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
259 _token = makeToken(_ttype);
260 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
261 }
262 _returnToken = _token;
263 }
264
265 public final void mQUOTE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
266 int _ttype; Token _token=null; int _begin=text.length();
267 _ttype = QUOTE;
268 int _saveIndex;
269
270 match('\'');
271 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
272 _token = makeToken(_ttype);
273 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
274 }
275 _returnToken = _token;
276 }
277
278 public final void mDIGIT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
279 int _ttype; Token _token=null; int _begin=text.length();
280 _ttype = DIGIT;
281 int _saveIndex;
282
283 matchRange('0','9');
284 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
285 _token = makeToken(_ttype);
286 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
287 }
288 _returnToken = _token;
289 }
290
291 public final void mDOLLAR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
292 int _ttype; Token _token=null; int _begin=text.length();
293 _ttype = DOLLAR;
294 int _saveIndex;
295
296 match('$');
297 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
298 _token = makeToken(_ttype);
299 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
300 }
301 _returnToken = _token;
302 }
303
304 public final void mOPEN_PAREN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
305 int _ttype; Token _token=null; int _begin=text.length();
306 _ttype = OPEN_PAREN;
307 int _saveIndex;
308
309 match('(');
310 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
311 _token = makeToken(_ttype);
312 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
313 }
314 _returnToken = _token;
315 }
316
317 public final void mCLOSE_PAREN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
318 int _ttype; Token _token=null; int _begin=text.length();
319 _ttype = CLOSE_PAREN;
320 int _saveIndex;
321
322 match(')');
323 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
324 _token = makeToken(_ttype);
325 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
326 }
327 _returnToken = _token;
328 }
329
330 public final void mOPEN_BRACKET(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
331 int _ttype; Token _token=null; int _begin=text.length();
332 _ttype = OPEN_BRACKET;
333 int _saveIndex;
334
335 match('{');
336 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
337 _token = makeToken(_ttype);
338 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
339 }
340 _returnToken = _token;
341 }
342
343 public final void mCLOSE_BRACKET(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
344 int _ttype; Token _token=null; int _begin=text.length();
345 _ttype = CLOSE_BRACKET;
346 int _saveIndex;
347
348 match('}');
349 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
350 _token = makeToken(_ttype);
351 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
352 }
353 _returnToken = _token;
354 }
355
356 protected final void mNUMERIC_STRING(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
357 int _ttype; Token _token=null; int _begin=text.length();
358 _ttype = NUMERIC_STRING;
359 int _saveIndex;
360
361 {
362 int _cnt1990=0;
363 _loop1990:
364 do {
365 if (((LA(1) >= '0' && LA(1) <= '9'))) {
366 matchRange('0','9');
367 }
368 else {
369 if ( _cnt1990>=1 ) { break _loop1990; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
370 }
371
372 _cnt1990++;
373 } while (true);
374 }
375 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
376 _token = makeToken(_ttype);
377 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
378 }
379 _returnToken = _token;
380 }
381
382 public final void mNUMERICOID(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
383 int _ttype; Token _token=null; int _begin=text.length();
384 _ttype = NUMERICOID;
385 int _saveIndex;
386
387 mNUMERIC_STRING(false);
388 {
389 int _cnt1993=0;
390 _loop1993:
391 do {
392 if ((LA(1)=='.')) {
393 match('.');
394 mNUMERIC_STRING(false);
395 }
396 else {
397 if ( _cnt1993>=1 ) { break _loop1993; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
398 }
399
400 _cnt1993++;
401 } while (true);
402 }
403 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
404 _token = makeToken(_ttype);
405 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
406 }
407 _returnToken = _token;
408 }
409
410 public final void mIDENTIFIER(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
411 int _ttype; Token _token=null; int _begin=text.length();
412 _ttype = IDENTIFIER;
413 int _saveIndex;
414
415 {
416 matchRange('a','z');
417 }
418 {
419 _loop1997:
420 do {
421 switch ( LA(1)) {
422 case 'a': case 'b': case 'c': case 'd':
423 case 'e': case 'f': case 'g': case 'h':
424 case 'i': case 'j': case 'k': case 'l':
425 case 'm': case 'n': case 'o': case 'p':
426 case 'q': case 'r': case 's': case 't':
427 case 'u': case 'v': case 'w': case 'x':
428 case 'y': case 'z':
429 {
430 matchRange('a','z');
431 break;
432 }
433 case '0': case '1': case '2': case '3':
434 case '4': case '5': case '6': case '7':
435 case '8': case '9':
436 {
437 matchRange('0','9');
438 break;
439 }
440 case '-':
441 {
442 match('-');
443 break;
444 }
445 case ';':
446 {
447 match(';');
448 break;
449 }
450 default:
451 {
452 break _loop1997;
453 }
454 }
455 } while (true);
456 }
457 _ttype = testLiteralsTable(_ttype);
458 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
459 _token = makeToken(_ttype);
460 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
461 }
462 _returnToken = _token;
463 }
464
465 public final void mDESC(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
466 int _ttype; Token _token=null; int _begin=text.length();
467 _ttype = DESC;
468 int _saveIndex;
469
470 match("desc");
471 mWS(false);
472 mQUOTE(false);
473 {
474 int _cnt2000=0;
475 _loop2000:
476 do {
477 if ((_tokenSet_3.member(LA(1)))) {
478 matchNot('\'');
479 }
480 else {
481 if ( _cnt2000>=1 ) { break _loop2000; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
482 }
483
484 _cnt2000++;
485 } while (true);
486 }
487 mQUOTE(false);
488 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
489 _token = makeToken(_ttype);
490 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
491 }
492 _returnToken = _token;
493 }
494
495 public final void mSYNTAX(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
496 int _ttype; Token _token=null; int _begin=text.length();
497 _ttype = SYNTAX;
498 int _saveIndex;
499
500 match("syntax");
501 mWS(false);
502 mNUMERICOID(false);
503 {
504 if ((LA(1)=='{')) {
505 mOPEN_BRACKET(false);
506 {
507 int _cnt2004=0;
508 _loop2004:
509 do {
510 if (((LA(1) >= '0' && LA(1) <= '9'))) {
511 mDIGIT(false);
512 }
513 else {
514 if ( _cnt2004>=1 ) { break _loop2004; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
515 }
516
517 _cnt2004++;
518 } while (true);
519 }
520 mCLOSE_BRACKET(false);
521 }
522 else {
523 }
524
525 }
526 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
527 _token = makeToken(_ttype);
528 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
529 }
530 _returnToken = _token;
531 }
532
533
534 private static final long[] mk_tokenSet_0() {
535 long[] data = { 38654715392L, 0L, 0L, 0L, 0L};
536 return data;
537 }
538 public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
539 private static final long[] mk_tokenSet_1() {
540 long[] data = { 288019269919178752L, 0L, 0L, 0L, 0L};
541 return data;
542 }
543 public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
544 private static final long[] mk_tokenSet_2() {
545 long[] data = new long[8];
546 data[0]=-1032L;
547 for (int i = 1; i<=3; i++) { data[i]=-1L; }
548 return data;
549 }
550 public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
551 private static final long[] mk_tokenSet_3() {
552 long[] data = new long[8];
553 data[0]=-549755813896L;
554 for (int i = 1; i<=3; i++) { data[i]=-1L; }
555 return data;
556 }
557 public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3());
558
559 }