KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > core > model > schema > parser > SchemaValueLexer


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20
21 // $ANTLR 2.7.5 (20050128): "schemavalue.g" -> "SchemaValueLexer.java"$
22
package org.apache.directory.ldapstudio.browser.core.model.schema.parser;
23
24
25 import java.util.*;
26
27 import java.io.InputStream JavaDoc;
28 import antlr.TokenStreamException;
29 import antlr.TokenStreamIOException;
30 import antlr.TokenStreamRecognitionException;
31 import antlr.CharStreamException;
32 import antlr.CharStreamIOException;
33 import antlr.ANTLRException;
34 import java.io.Reader JavaDoc;
35 import java.util.Hashtable JavaDoc;
36 import antlr.CharScanner;
37 import antlr.InputBuffer;
38 import antlr.ByteBuffer;
39 import antlr.CharBuffer;
40 import antlr.Token;
41 import antlr.CommonToken;
42 import antlr.RecognitionException;
43 import antlr.NoViableAltForCharException;
44 import antlr.MismatchedCharException;
45 import antlr.TokenStream;
46 import antlr.ANTLRHashString;
47 import antlr.LexerSharedInputState;
48 import antlr.collections.impl.BitSet;
49 import antlr.SemanticException;
50
51
52 public class SchemaValueLexer extends antlr.CharScanner implements SchemaValueTokenTypes, TokenStream
53 {
54     public SchemaValueLexer( InputStream JavaDoc in )
55     {
56         this( new ByteBuffer( in ) );
57     }
58
59
60     public SchemaValueLexer( Reader JavaDoc in )
61     {
62         this( new CharBuffer( in ) );
63     }
64
65
66     public SchemaValueLexer( InputBuffer ib )
67     {
68         this( new LexerSharedInputState( ib ) );
69     }
70
71
72     public SchemaValueLexer( LexerSharedInputState state )
73     {
74         super( state );
75         caseSensitiveLiterals = true;
76         setCaseSensitive( false );
77         literals = new Hashtable JavaDoc();
78     }
79
80
81     public Token nextToken() throws TokenStreamException
82     {
83         Token theRetToken = null;
84         tryAgain: for ( ;; )
85         {
86             Token _token = null;
87             int _ttype = Token.INVALID_TYPE;
88             resetText();
89             try
90             { // for char stream error handling
91
try
92                 { // for lexical error handling
93
switch ( LA( 1 ) )
94                     {
95                         case ' ':
96                         {
97                             mWHSP( true );
98                             theRetToken = _returnToken;
99                             break;
100                         }
101                         case '(':
102                         {
103                             mLPAR( true );
104                             theRetToken = _returnToken;
105                             break;
106                         }
107                         case ')':
108                         {
109                             mRPAR( true );
110                             theRetToken = _returnToken;
111                             break;
112                         }
113                         case '\'':
114                         {
115                             mQUOTE( true );
116                             theRetToken = _returnToken;
117                             break;
118                         }
119                         case '$':
120                         {
121                             mDOLLAR( true );
122                             theRetToken = _returnToken;
123                             break;
124                         }
125                         case '}':
126                         {
127                             mRBRACKET( true );
128                             theRetToken = _returnToken;
129                             break;
130                         }
131                         case 'a':
132                         case 'b':
133                         case 'c':
134                         case 'd':
135                         case 'e':
136                         case 'f':
137                         case 'g':
138                         case 'h':
139                         case 'i':
140                         case 'j':
141                         case 'k':
142                         case 'l':
143                         case 'm':
144                         case 'n':
145                         case 'o':
146                         case 'p':
147                         case 'q':
148                         case 'r':
149                         case 's':
150                         case 't':
151                         case 'u':
152                         case 'v':
153                         case 'w':
154                         case 'x':
155                         case 'y':
156                         case 'z':
157                         {
158                             mDESCR( true );
159                             theRetToken = _returnToken;
160                             break;
161                         }
162                         default:
163                             if ( ( LA( 1 ) == '{' ) && ( ( LA( 2 ) >= '0' && LA( 2 ) <= '9' ) ) )
164                             {
165                                 mLEN( true );
166                                 theRetToken = _returnToken;
167                             }
168                             else if ( ( ( LA( 1 ) >= '0' && LA( 1 ) <= '9' ) ) && ( _tokenSet_0.member( LA( 2 ) ) ) )
169                             {
170                                 mNUMERICOID( true );
171                                 theRetToken = _returnToken;
172                             }
173                             else if ( ( LA( 1 ) == '{' ) && ( true ) )
174                             {
175                                 mLBRACKET( true );
176                                 theRetToken = _returnToken;
177                             }
178                             else if ( ( ( LA( 1 ) >= '0' && LA( 1 ) <= '9' ) ) && ( true ) )
179                             {
180                                 mDIGIT( true );
181                                 theRetToken = _returnToken;
182                             }
183                             else
184                             {
185                                 if ( LA( 1 ) == EOF_CHAR )
186                                 {
187                                     uponEOF();
188                                     _returnToken = makeToken( Token.EOF_TYPE );
189                                 }
190                                 else
191                                 {
192                                     throw new NoViableAltForCharException( ( char ) LA( 1 ), getFilename(), getLine(),
193                                         getColumn() );
194                                 }
195                             }
196                     }
197                     if ( _returnToken == null )
198                         continue tryAgain; // found SKIP token
199
_ttype = _returnToken.getType();
200                     _ttype = testLiteralsTable( _ttype );
201                     _returnToken.setType( _ttype );
202                     return _returnToken;
203                 }
204                 catch ( RecognitionException e )
205                 {
206                     throw new TokenStreamRecognitionException( e );
207                 }
208             }
209             catch ( CharStreamException cse )
210             {
211                 if ( cse instanceof CharStreamIOException )
212                 {
213                     throw new TokenStreamIOException( ( ( CharStreamIOException ) cse ).io );
214                 }
215                 else
216                 {
217                     throw new TokenStreamException( cse.getMessage() );
218                 }
219             }
220         }
221     }
222
223
224     public final void mWHSP( boolean _createToken ) throws RecognitionException, CharStreamException,
225         TokenStreamException
226     {
227         int _ttype;
228         Token _token = null;
229         int _begin = text.length();
230         _ttype = WHSP;
231         int _saveIndex;
232
233         {
234             match( ' ' );
235         }
236         _ttype = Token.SKIP;
237         if ( _createToken && _token == null && _ttype != Token.SKIP )
238         {
239             _token = makeToken( _ttype );
240             _token.setText( new String JavaDoc( text.getBuffer(), _begin, text.length() - _begin ) );
241         }
242         _returnToken = _token;
243     }
244
245
246     public final void mLPAR( boolean _createToken ) throws RecognitionException, CharStreamException,
247         TokenStreamException
248     {
249         int _ttype;
250         Token _token = null;
251         int _begin = text.length();
252         _ttype = LPAR;
253         int _saveIndex;
254
255         match( '(' );
256         if ( _createToken && _token == null && _ttype != Token.SKIP )
257         {
258             _token = makeToken( _ttype );
259             _token.setText( new String JavaDoc( text.getBuffer(), _begin, text.length() - _begin ) );
260         }
261         _returnToken = _token;
262     }
263
264
265     public final void mRPAR( boolean _createToken ) throws RecognitionException, CharStreamException,
266         TokenStreamException
267     {
268         int _ttype;
269         Token _token = null;
270         int _begin = text.length();
271         _ttype = RPAR;
272         int _saveIndex;
273
274         match( ')' );
275         if ( _createToken && _token == null && _ttype != Token.SKIP )
276         {
277             _token = makeToken( _ttype );
278             _token.setText( new String JavaDoc( text.getBuffer(), _begin, text.length() - _begin ) );
279         }
280         _returnToken = _token;
281     }
282
283
284     public final void mQUOTE( boolean _createToken ) throws RecognitionException, CharStreamException,
285         TokenStreamException
286     {
287         int _ttype;
288         Token _token = null;
289         int _begin = text.length();
290         _ttype = QUOTE;
291         int _saveIndex;
292
293         match( '\'' );
294         if ( _createToken && _token == null && _ttype != Token.SKIP )
295         {
296             _token = makeToken( _ttype );
297             _token.setText( new String JavaDoc( text.getBuffer(), _begin, text.length() - _begin ) );
298         }
299         _returnToken = _token;
300     }
301
302
303     public final void mDOLLAR( boolean _createToken ) throws RecognitionException, CharStreamException,
304         TokenStreamException
305     {
306         int _ttype;
307         Token _token = null;
308         int _begin = text.length();
309         _ttype = DOLLAR;
310         int _saveIndex;
311
312         match( '$' );
313         if ( _createToken && _token == null && _ttype != Token.SKIP )
314         {
315             _token = makeToken( _ttype );
316             _token.setText( new String JavaDoc( text.getBuffer(), _begin, text.length() - _begin ) );
317         }
318         _returnToken = _token;
319     }
320
321
322     public final void mLBRACKET( boolean _createToken ) throws RecognitionException, CharStreamException,
323         TokenStreamException
324     {
325         int _ttype;
326         Token _token = null;
327         int _begin = text.length();
328         _ttype = LBRACKET;
329         int _saveIndex;
330
331         match( '{' );
332         if ( _createToken && _token == null && _ttype != Token.SKIP )
333         {
334             _token = makeToken( _ttype );
335             _token.setText( new String JavaDoc( text.getBuffer(), _begin, text.length() - _begin ) );
336         }
337         _returnToken = _token;
338     }
339
340
341     public final void mRBRACKET( boolean _createToken ) throws RecognitionException, CharStreamException,
342         TokenStreamException
343     {
344         int _ttype;
345         Token _token = null;
346         int _begin = text.length();
347         _ttype = RBRACKET;
348         int _saveIndex;
349
350         match( '}' );
351         if ( _createToken && _token == null && _ttype != Token.SKIP )
352         {
353             _token = makeToken( _ttype );
354             _token.setText( new String JavaDoc( text.getBuffer(), _begin, text.length() - _begin ) );
355         }
356         _returnToken = _token;
357     }
358
359
360     public final void mLEN( boolean _createToken ) throws RecognitionException, CharStreamException,
361         TokenStreamException
362     {
363         int _ttype;
364         Token _token = null;
365         int _begin = text.length();
366         _ttype = LEN;
367         int _saveIndex;
368
369         mLBRACKET( false );
370         {
371             int _cnt11 = 0;
372             _loop11: do
373             {
374                 if ( ( ( LA( 1 ) >= '0' && LA( 1 ) <= '9' ) ) )
375                 {
376                     mDIGIT( false );
377                 }
378                 else
379                 {
380                     if ( _cnt11 >= 1 )
381                     {
382                         break _loop11;
383                     }
384                     else
385                     {
386                         throw new NoViableAltForCharException( ( char ) LA( 1 ), getFilename(), getLine(), getColumn() );
387                     }
388                 }
389
390                 _cnt11++;
391             }
392             while ( true );
393         }
394         mRBRACKET( false );
395         if ( _createToken && _token == null && _ttype != Token.SKIP )
396         {
397             _token = makeToken( _ttype );
398             _token.setText( new String JavaDoc( text.getBuffer(), _begin, text.length() - _begin ) );
399         }
400         _returnToken = _token;
401     }
402
403
404     public final void mDIGIT( boolean _createToken ) throws RecognitionException, CharStreamException,
405         TokenStreamException
406     {
407         int _ttype;
408         Token _token = null;
409         int _begin = text.length();
410         _ttype = DIGIT;
411         int _saveIndex;
412
413         {
414             matchRange( '0', '9' );
415         }
416         if ( _createToken && _token == null && _ttype != Token.SKIP )
417         {
418             _token = makeToken( _ttype );
419             _token.setText( new String JavaDoc( text.getBuffer(), _begin, text.length() - _begin ) );
420         }
421         _returnToken = _token;
422     }
423
424
425     public final void mNUMERICOID( boolean _createToken ) throws RecognitionException, CharStreamException,
426         TokenStreamException
427     {
428         int _ttype;
429         Token _token = null;
430         int _begin = text.length();
431         _ttype = NUMERICOID;
432         int _saveIndex;
433
434         {
435             int _cnt16 = 0;
436             _loop16: do
437             {
438                 if ( ( ( LA( 1 ) >= '0' && LA( 1 ) <= '9' ) ) )
439                 {
440                     matchRange( '0', '9' );
441                 }
442                 else
443                 {
444                     if ( _cnt16 >= 1 )
445                     {
446                         break _loop16;
447                     }
448                     else
449                     {
450                         throw new NoViableAltForCharException( ( char ) LA( 1 ), getFilename(), getLine(), getColumn() );
451                     }
452                 }
453
454                 _cnt16++;
455             }
456             while ( true );
457         }
458         {
459             int _cnt20 = 0;
460             _loop20: do
461             {
462                 if ( ( LA( 1 ) == '.' ) )
463                 {
464                     match( '.' );
465                     {
466                         int _cnt19 = 0;
467                         _loop19: do
468                         {
469                             if ( ( ( LA( 1 ) >= '0' && LA( 1 ) <= '9' ) ) )
470                             {
471                                 matchRange( '0', '9' );
472                             }
473                             else
474                             {
475                                 if ( _cnt19 >= 1 )
476                                 {
477                                     break _loop19;
478                                 }
479                                 else
480                                 {
481                                     throw new NoViableAltForCharException( ( char ) LA( 1 ), getFilename(), getLine(),
482                                         getColumn() );
483                                 }
484                             }
485
486                             _cnt19++;
487                         }
488                         while ( true );
489                     }
490                 }
491                 else
492                 {
493                     if ( _cnt20 >= 1 )
494                     {
495                         break _loop20;
496                     }
497                     else
498                     {
499                         throw new NoViableAltForCharException( ( char ) LA( 1 ), getFilename(), getLine(), getColumn() );
500                     }
501                 }
502
503                 _cnt20++;
504             }
505             while ( true );
506         }
507         if ( _createToken && _token == null && _ttype != Token.SKIP )
508         {
509             _token = makeToken( _ttype );
510             _token.setText( new String JavaDoc( text.getBuffer(), _begin, text.length() - _begin ) );
511         }
512         _returnToken = _token;
513     }
514
515
516     public final void mDESCR( boolean _createToken ) throws RecognitionException, CharStreamException,
517         TokenStreamException
518     {
519         int _ttype;
520         Token _token = null;
521         int _begin = text.length();
522         _ttype = DESCR;
523         int _saveIndex;
524
525         {
526             matchRange( 'a', 'z' );
527         }
528         {
529             _loop24: do
530             {
531                 switch ( LA( 1 ) )
532                 {
533                     case 'a':
534                     case 'b':
535                     case 'c':
536                     case 'd':
537                     case 'e':
538                     case 'f':
539                     case 'g':
540                     case 'h':
541                     case 'i':
542                     case 'j':
543                     case 'k':
544                     case 'l':
545                     case 'm':
546                     case 'n':
547                     case 'o':
548                     case 'p':
549                     case 'q':
550                     case 'r':
551                     case 's':
552                     case 't':
553                     case 'u':
554                     case 'v':
555                     case 'w':
556                     case 'x':
557                     case 'y':
558                     case 'z':
559                     {
560                         matchRange( 'a', 'z' );
561                         break;
562                     }
563                     case '0':
564                     case '1':
565                     case '2':
566                     case '3':
567                     case '4':
568                     case '5':
569                     case '6':
570                     case '7':
571                     case '8':
572                     case '9':
573                     {
574                         matchRange( '0', '9' );
575                         break;
576                     }
577                     case '-':
578                     {
579                         match( '-' );
580                         break;
581                     }
582                     case ';':
583                     {
584                         match( ';' );
585                         break;
586                     }
587                     case '.':
588                     {
589                         match( '.' );
590                         break;
591                     }
592                     default:
593                     {
594                         break _loop24;
595                     }
596                 }
597             }
598             while ( true );
599         }
600         if ( _createToken && _token == null && _ttype != Token.SKIP )
601         {
602             _token = makeToken( _ttype );
603             _token.setText( new String JavaDoc( text.getBuffer(), _begin, text.length() - _begin ) );
604         }
605         _returnToken = _token;
606     }
607
608
609     private static final long[] mk_tokenSet_0()
610     {
611         long[] data =
612             { 288019269919178752L, 0L, 0L, 0L, 0L };
613         return data;
614     }
615
616     public static final BitSet _tokenSet_0 = new BitSet( mk_tokenSet_0() );
617
618 }
619
Popular Tags