1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 package org.apache.directory.api.ldap.schema.converter;
27 import java.util.List ;
28 import java.util.ArrayList ;
29 import java.util.Collections;
30 import java.io.IOException;
31
32 import org.apache.directory.api.ldap.schema.converter.SchemaElement;
33 import org.apache.directory.api.ldap.model.schema.UsageEnum;
34 import org.apache.directory.api.ldap.model.schema.ObjectClassTypeEnum;
35
36 import java.io.InputStream;
37 import antlr.TokenStreamException;
38 import antlr.TokenStreamIOException;
39 import antlr.TokenStreamRecognitionException;
40 import antlr.CharStreamException;
41 import antlr.CharStreamIOException;
42 import antlr.ANTLRException;
43 import java.io.Reader;
44 import java.util.Hashtable;
45 import antlr.CharScanner;
46 import antlr.InputBuffer;
47 import antlr.ByteBuffer;
48 import antlr.CharBuffer;
49 import antlr.Token;
50 import antlr.CommonToken;
51 import antlr.RecognitionException;
52 import antlr.NoViableAltForCharException;
53 import antlr.MismatchedCharException;
54 import antlr.TokenStream;
55 import antlr.ANTLRHashString;
56 import antlr.LexerSharedInputState;
57 import antlr.collections.impl.BitSet;
58 import antlr.SemanticException;
59
60 public class antlrSchemaConverterLexer extends antlr.CharScanner implements antlrSchemaTokenTypes, TokenStream
61 {
62 public antlrSchemaConverterLexer(InputStream in) {
63 this(new ByteBuffer(in));
64 }
65 public antlrSchemaConverterLexer(Reader in) {
66 this(new CharBuffer(in));
67 }
68 public antlrSchemaConverterLexer(InputBuffer ib) {
69 this(new LexerSharedInputState(ib));
70 }
71 public antlrSchemaConverterLexer(LexerSharedInputState state) {
72 super(state);
73 caseSensitiveLiterals = true;
74 setCaseSensitive(false);
75 literals = new Hashtable();
76 literals.put(new ANTLRHashString("NAME", this), new Integer(26));
77 literals.put(new ANTLRHashString("SINGLE-VALUE", this), new Integer(28));
78 literals.put(new ANTLRHashString("COLLECTIVE", this), new Integer(29));
79 literals.put(new ANTLRHashString("ABSTRACT", this), new Integer(20));
80 literals.put(new ANTLRHashString("MAY", this), new Integer(23));
81 literals.put(new ANTLRHashString("END", this), new Integer(17));
82 literals.put(new ANTLRHashString("SUP", this), new Integer(25));
83 literals.put(new ANTLRHashString("EQUALITY", this), new Integer(31));
84 literals.put(new ANTLRHashString("userApplications", this), new Integer(35));
85 literals.put(new ANTLRHashString("dSAOperation", this), new Integer(38));
86 literals.put(new ANTLRHashString("AUXILIARY", this), new Integer(22));
87 literals.put(new ANTLRHashString("objectclass", this), new Integer(18));
88 literals.put(new ANTLRHashString("directoryOperation", this), new Integer(36));
89 literals.put(new ANTLRHashString("OBSOLETE", this), new Integer(19));
90 literals.put(new ANTLRHashString("distributedOperation", this), new Integer(37));
91 literals.put(new ANTLRHashString("STRUCTURAL", this), new Integer(21));
92 literals.put(new ANTLRHashString("USAGE", this), new Integer(34));
93 literals.put(new ANTLRHashString("ORDERING", this), new Integer(33));
94 literals.put(new ANTLRHashString("attributetype", this), new Integer(27));
95 literals.put(new ANTLRHashString("NO-USER-MODIFICATION", this), new Integer(30));
96 literals.put(new ANTLRHashString("SUBSTR", this), new Integer(32));
97 literals.put(new ANTLRHashString("MUST", this), new Integer(24));
98 }
99
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 {
108 try {
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;
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 _loop4:
212 do {
213 if ((_tokenSet_2.member(LA(1)))) {
214 matchNot('\n');
215 }
216 else {
217 break _loop4;
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 _cnt14=0;
363 _loop14:
364 do {
365 if (((LA(1) >= '0' && LA(1) <= '9'))) {
366 matchRange('0','9');
367 }
368 else {
369 if ( _cnt14>=1 ) { break _loop14; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
370 }
371
372 _cnt14++;
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 _cnt17=0;
390 _loop17:
391 do {
392 if ((LA(1)=='.')) {
393 match('.');
394 mNUMERIC_STRING(false);
395 }
396 else {
397 if ( _cnt17>=1 ) { break _loop17; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
398 }
399
400 _cnt17++;
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 _loop21:
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 _loop21;
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 _cnt24=0;
475 _loop24:
476 do {
477 if ((LA(1)=='\\') && (LA(2)=='\'') && ((LA(3) >= '\u0003' && LA(3) <= '\u00ff')) && (true) && (true) && (true) && (true)) {
478 match('\\');
479 match('\'');
480 }
481 else if ((_tokenSet_3.member(LA(1))) && ((LA(2) >= '\u0003' && LA(2) <= '\u00ff')) && (true) && (true) && (true) && (true) && (true)) {
482 matchNot('\'');
483 }
484 else {
485 if ( _cnt24>=1 ) { break _loop24; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
486 }
487
488 _cnt24++;
489 } while (true);
490 }
491 mQUOTE(false);
492 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
493 _token = makeToken(_ttype);
494 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
495 }
496 _returnToken = _token;
497 }
498
499 public final void mSYNTAX(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
500 int _ttype; Token _token=null; int _begin=text.length();
501 _ttype = SYNTAX;
502 int _saveIndex;
503
504 match("syntax");
505 mWS(false);
506 mNUMERICOID(false);
507 {
508 if ((LA(1)=='{')) {
509 mOPEN_BRACKET(false);
510 {
511 int _cnt28=0;
512 _loop28:
513 do {
514 if (((LA(1) >= '0' && LA(1) <= '9'))) {
515 mDIGIT(false);
516 }
517 else {
518 if ( _cnt28>=1 ) { break _loop28; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
519 }
520
521 _cnt28++;
522 } while (true);
523 }
524 mCLOSE_BRACKET(false);
525 }
526 else {
527 }
528
529 }
530 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
531 _token = makeToken(_ttype);
532 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
533 }
534 _returnToken = _token;
535 }
536
537
538 private static final long[] mk_tokenSet_0() {
539 long[] data = { 38654715392L, 0L, 0L, 0L, 0L};
540 return data;
541 }
542 public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
543 private static final long[] mk_tokenSet_1() {
544 long[] data = { 288019269919178752L, 0L, 0L, 0L, 0L};
545 return data;
546 }
547 public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
548 private static final long[] mk_tokenSet_2() {
549 long[] data = new long[8];
550 data[0]=-1032L;
551 for (int i = 1; i<=3; i++) { data[i]=-1L; }
552 return data;
553 }
554 public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
555 private static final long[] mk_tokenSet_3() {
556 long[] data = new long[8];
557 data[0]=-549755813896L;
558 for (int i = 1; i<=3; i++) { data[i]=-1L; }
559 return data;
560 }
561 public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3());
562
563 }