KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > validator > validwhen > ValidWhenLexer


1 // $ANTLR 2.7.2: "ValidWhenParser.g" -> "ValidWhenLexer.java"$
2

3 /*
4  * $Id: ValidWhenLexer.java 54929 2004-10-16 16:38:42Z germuska $
5  *
6  * Copyright 2003-2004 The Apache Software Foundation.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * 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, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */

20
21 package org.apache.struts.validator.validwhen;
22
23 import java.util.Stack JavaDoc;
24 import org.apache.commons.validator.util.ValidatorUtils;
25
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 public class ValidWhenLexer extends antlr.CharScanner implements ValidWhenParserTokenTypes, TokenStream
52  {
53 public ValidWhenLexer(InputStream JavaDoc in) {
54     this(new ByteBuffer(in));
55 }
56 public ValidWhenLexer(Reader JavaDoc in) {
57     this(new CharBuffer(in));
58 }
59 public ValidWhenLexer(InputBuffer ib) {
60     this(new LexerSharedInputState(ib));
61 }
62 public ValidWhenLexer(LexerSharedInputState state) {
63     super(state);
64     caseSensitiveLiterals = true;
65     setCaseSensitive(false);
66     literals = new Hashtable JavaDoc();
67     literals.put(new ANTLRHashString("null", this), new Integer JavaDoc(11));
68     literals.put(new ANTLRHashString("or", this), new Integer JavaDoc(16));
69     literals.put(new ANTLRHashString("and", this), new Integer JavaDoc(15));
70 }
71
72 public Token nextToken() throws TokenStreamException {
73     Token theRetToken=null;
74 tryAgain:
75     for (;;) {
76         Token _token = null;
77         int _ttype = Token.INVALID_TYPE;
78         resetText();
79         try { // for char stream error handling
80
try { // for lexical error handling
81
switch ( LA(1)) {
82                 case '\t': case '\n': case '\r': case ' ':
83                 {
84                     mWS(true);
85                     theRetToken=_returnToken;
86                     break;
87                 }
88                 case '-': case '1': case '2': case '3':
89                 case '4': case '5': case '6': case '7':
90                 case '8': case '9':
91                 {
92                     mDECIMAL_LITERAL(true);
93                     theRetToken=_returnToken;
94                     break;
95                 }
96                 case '"': case '\'':
97                 {
98                     mSTRING_LITERAL(true);
99                     theRetToken=_returnToken;
100                     break;
101                 }
102                 case '[':
103                 {
104                     mLBRACKET(true);
105                     theRetToken=_returnToken;
106                     break;
107                 }
108                 case ']':
109                 {
110                     mRBRACKET(true);
111                     theRetToken=_returnToken;
112                     break;
113                 }
114                 case '(':
115                 {
116                     mLPAREN(true);
117                     theRetToken=_returnToken;
118                     break;
119                 }
120                 case ')':
121                 {
122                     mRPAREN(true);
123                     theRetToken=_returnToken;
124                     break;
125                 }
126                 case '*':
127                 {
128                     mTHIS(true);
129                     theRetToken=_returnToken;
130                     break;
131                 }
132                 case '.': case '_': case 'a': case 'b':
133                 case 'c': case 'd': case 'e': case 'f':
134                 case 'g': case 'h': case 'i': case 'j':
135                 case 'k': case 'l': case 'm': case 'n':
136                 case 'o': case 'p': case 'q': case 'r':
137                 case 's': case 't': case 'u': case 'v':
138                 case 'w': case 'x': case 'y': case 'z':
139                 {
140                     mIDENTIFIER(true);
141                     theRetToken=_returnToken;
142                     break;
143                 }
144                 case '=':
145                 {
146                     mEQUALSIGN(true);
147                     theRetToken=_returnToken;
148                     break;
149                 }
150                 case '!':
151                 {
152                     mNOTEQUALSIGN(true);
153                     theRetToken=_returnToken;
154                     break;
155                 }
156                 default:
157                     if ((LA(1)=='0') && (LA(2)=='x')) {
158                         mHEX_LITERAL(true);
159                         theRetToken=_returnToken;
160                     }
161                     else if ((LA(1)=='<') && (LA(2)=='=')) {
162                         mLESSEQUALSIGN(true);
163                         theRetToken=_returnToken;
164                     }
165                     else if ((LA(1)=='>') && (LA(2)=='=')) {
166                         mGREATEREQUALSIGN(true);
167                         theRetToken=_returnToken;
168                     }
169                     else if ((LA(1)=='0') && (true)) {
170                         mOCTAL_LITERAL(true);
171                         theRetToken=_returnToken;
172                     }
173                     else if ((LA(1)=='<') && (true)) {
174                         mLESSTHANSIGN(true);
175                         theRetToken=_returnToken;
176                     }
177                     else if ((LA(1)=='>') && (true)) {
178                         mGREATERTHANSIGN(true);
179                         theRetToken=_returnToken;
180                     }
181                 else {
182                     if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);}
183                 else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
184                 }
185                 }
186                 if ( _returnToken==null ) continue tryAgain; // found SKIP token
187
_ttype = _returnToken.getType();
188                 _ttype = testLiteralsTable(_ttype);
189                 _returnToken.setType(_ttype);
190                 return _returnToken;
191             }
192             catch (RecognitionException e) {
193                 throw new TokenStreamRecognitionException(e);
194             }
195         }
196         catch (CharStreamException cse) {
197             if ( cse instanceof CharStreamIOException ) {
198                 throw new TokenStreamIOException(((CharStreamIOException)cse).io);
199             }
200             else {
201                 throw new TokenStreamException(cse.getMessage());
202             }
203         }
204     }
205 }
206
207     public final void mWS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
208         int _ttype; Token _token=null; int _begin=text.length();
209         _ttype = WS;
210         int _saveIndex;
211         
212         {
213         int _cnt15=0;
214         _loop15:
215         do {
216             switch ( LA(1)) {
217             case ' ':
218             {
219                 match(' ');
220                 break;
221             }
222             case '\t':
223             {
224                 match('\t');
225                 break;
226             }
227             case '\n':
228             {
229                 match('\n');
230                 break;
231             }
232             case '\r':
233             {
234                 match('\r');
235                 break;
236             }
237             default:
238             {
239                 if ( _cnt15>=1 ) { break _loop15; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
240             }
241             }
242             _cnt15++;
243         } while (true);
244         }
245         _ttype = Token.SKIP;
246         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
247             _token = makeToken(_ttype);
248             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
249         }
250         _returnToken = _token;
251     }
252     
253     public final void mDECIMAL_LITERAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
254         int _ttype; Token _token=null; int _begin=text.length();
255         _ttype = DECIMAL_LITERAL;
256         int _saveIndex;
257         
258         {
259         switch ( LA(1)) {
260         case '-':
261         {
262             match('-');
263             break;
264         }
265         case '1': case '2': case '3': case '4':
266         case '5': case '6': case '7': case '8':
267         case '9':
268         {
269             break;
270         }
271         default:
272         {
273             throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
274         }
275         }
276         }
277         {
278         matchRange('1','9');
279         }
280         {
281         _loop20:
282         do {
283             if (((LA(1) >= '0' && LA(1) <= '9'))) {
284                 matchRange('0','9');
285             }
286             else {
287                 break _loop20;
288             }
289             
290         } while (true);
291         }
292         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
293             _token = makeToken(_ttype);
294             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
295         }
296         _returnToken = _token;
297     }
298     
299     public final void mHEX_LITERAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
300         int _ttype; Token _token=null; int _begin=text.length();
301         _ttype = HEX_LITERAL;
302         int _saveIndex;
303         
304         match('0');
305         match('x');
306         {
307         int _cnt23=0;
308         _loop23:
309         do {
310             switch ( LA(1)) {
311             case '0': case '1': case '2': case '3':
312             case '4': case '5': case '6': case '7':
313             case '8': case '9':
314             {
315                 matchRange('0','9');
316                 break;
317             }
318             case 'a': case 'b': case 'c': case 'd':
319             case 'e': case 'f':
320             {
321                 matchRange('a','f');
322                 break;
323             }
324             default:
325             {
326                 if ( _cnt23>=1 ) { break _loop23; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
327             }
328             }
329             _cnt23++;
330         } while (true);
331         }
332         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
333             _token = makeToken(_ttype);
334             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
335         }
336         _returnToken = _token;
337     }
338     
339     public final void mOCTAL_LITERAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
340         int _ttype; Token _token=null; int _begin=text.length();
341         _ttype = OCTAL_LITERAL;
342         int _saveIndex;
343         
344         match('0');
345         {
346         _loop26:
347         do {
348             if (((LA(1) >= '0' && LA(1) <= '7'))) {
349                 matchRange('0','7');
350             }
351             else {
352                 break _loop26;
353             }
354             
355         } while (true);
356         }
357         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
358             _token = makeToken(_ttype);
359             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
360         }
361         _returnToken = _token;
362     }
363     
364     public final void mSTRING_LITERAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
365         int _ttype; Token _token=null; int _begin=text.length();
366         _ttype = STRING_LITERAL;
367         int _saveIndex;
368         
369         switch ( LA(1)) {
370         case '\'':
371         {
372             {
373             match('\'');
374             {
375             int _cnt30=0;
376             _loop30:
377             do {
378                 if ((_tokenSet_0.member(LA(1)))) {
379                     matchNot('\'');
380                 }
381                 else {
382                     if ( _cnt30>=1 ) { break _loop30; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
383                 }
384                 
385                 _cnt30++;
386             } while (true);
387             }
388             match('\'');
389             }
390             break;
391         }
392         case '"':
393         {
394             {
395             match('\"');
396             {
397             int _cnt33=0;
398             _loop33:
399             do {
400                 if ((_tokenSet_1.member(LA(1)))) {
401                     matchNot('\"');
402                 }
403                 else {
404                     if ( _cnt33>=1 ) { break _loop33; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
405                 }
406                 
407                 _cnt33++;
408             } while (true);
409             }
410             match('\"');
411             }
412             break;
413         }
414         default:
415         {
416             throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
417         }
418         }
419         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
420             _token = makeToken(_ttype);
421             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
422         }
423         _returnToken = _token;
424     }
425     
426     public final void mLBRACKET(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
427         int _ttype; Token _token=null; int _begin=text.length();
428         _ttype = LBRACKET;
429         int _saveIndex;
430         
431         match('[');
432         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
433             _token = makeToken(_ttype);
434             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
435         }
436         _returnToken = _token;
437     }
438     
439     public final void mRBRACKET(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
440         int _ttype; Token _token=null; int _begin=text.length();
441         _ttype = RBRACKET;
442         int _saveIndex;
443         
444         match(']');
445         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
446             _token = makeToken(_ttype);
447             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
448         }
449         _returnToken = _token;
450     }
451     
452     public final void mLPAREN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
453         int _ttype; Token _token=null; int _begin=text.length();
454         _ttype = LPAREN;
455         int _saveIndex;
456         
457         match('(');
458         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
459             _token = makeToken(_ttype);
460             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
461         }
462         _returnToken = _token;
463     }
464     
465     public final void mRPAREN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
466         int _ttype; Token _token=null; int _begin=text.length();
467         _ttype = RPAREN;
468         int _saveIndex;
469         
470         match(')');
471         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
472             _token = makeToken(_ttype);
473             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
474         }
475         _returnToken = _token;
476     }
477     
478     public final void mTHIS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
479         int _ttype; Token _token=null; int _begin=text.length();
480         _ttype = THIS;
481         int _saveIndex;
482         
483         match("*this*");
484         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
485             _token = makeToken(_ttype);
486             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
487         }
488         _returnToken = _token;
489     }
490     
491     public final void mIDENTIFIER(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
492         int _ttype; Token _token=null; int _begin=text.length();
493         _ttype = IDENTIFIER;
494         int _saveIndex;
495         
496         {
497         switch ( LA(1)) {
498         case 'a': case 'b': case 'c': case 'd':
499         case 'e': case 'f': case 'g': case 'h':
500         case 'i': case 'j': case 'k': case 'l':
501         case 'm': case 'n': case 'o': case 'p':
502         case 'q': case 'r': case 's': case 't':
503         case 'u': case 'v': case 'w': case 'x':
504         case 'y': case 'z':
505         {
506             matchRange('a','z');
507             break;
508         }
509         case '.':
510         {
511             match('.');
512             break;
513         }
514         case '_':
515         {
516             match('_');
517             break;
518         }
519         default:
520         {
521             throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());
522         }
523         }
524         }
525         {
526         int _cnt42=0;
527         _loop42:
528         do {
529             switch ( LA(1)) {
530             case 'a': case 'b': case 'c': case 'd':
531             case 'e': case 'f': case 'g': case 'h':
532             case 'i': case 'j': case 'k': case 'l':
533             case 'm': case 'n': case 'o': case 'p':
534             case 'q': case 'r': case 's': case 't':
535             case 'u': case 'v': case 'w': case 'x':
536             case 'y': case 'z':
537             {
538                 matchRange('a','z');
539                 break;
540             }
541             case '0': case '1': case '2': case '3':
542             case '4': case '5': case '6': case '7':
543             case '8': case '9':
544             {
545                 matchRange('0','9');
546                 break;
547             }
548             case '.':
549             {
550                 match('.');
551                 break;
552             }
553             case '_':
554             {
555                 match('_');
556                 break;
557             }
558             default:
559             {
560                 if ( _cnt42>=1 ) { break _loop42; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());}
561             }
562             }
563             _cnt42++;
564         } while (true);
565         }
566         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
567             _token = makeToken(_ttype);
568             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
569         }
570         _returnToken = _token;
571     }
572     
573     public final void mEQUALSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
574         int _ttype; Token _token=null; int _begin=text.length();
575         _ttype = EQUALSIGN;
576         int _saveIndex;
577         
578         match('=');
579         match('=');
580         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
581             _token = makeToken(_ttype);
582             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
583         }
584         _returnToken = _token;
585     }
586     
587     public final void mNOTEQUALSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
588         int _ttype; Token _token=null; int _begin=text.length();
589         _ttype = NOTEQUALSIGN;
590         int _saveIndex;
591         
592         match('!');
593         match('=');
594         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
595             _token = makeToken(_ttype);
596             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
597         }
598         _returnToken = _token;
599     }
600     
601     public final void mLESSTHANSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
602         int _ttype; Token _token=null; int _begin=text.length();
603         _ttype = LESSTHANSIGN;
604         int _saveIndex;
605         
606         match('<');
607         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
608             _token = makeToken(_ttype);
609             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
610         }
611         _returnToken = _token;
612     }
613     
614     public final void mGREATERTHANSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
615         int _ttype; Token _token=null; int _begin=text.length();
616         _ttype = GREATERTHANSIGN;
617         int _saveIndex;
618         
619         match('>');
620         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
621             _token = makeToken(_ttype);
622             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
623         }
624         _returnToken = _token;
625     }
626     
627     public final void mLESSEQUALSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
628         int _ttype; Token _token=null; int _begin=text.length();
629         _ttype = LESSEQUALSIGN;
630         int _saveIndex;
631         
632         match('<');
633         match('=');
634         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
635             _token = makeToken(_ttype);
636             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
637         }
638         _returnToken = _token;
639     }
640     
641     public final void mGREATEREQUALSIGN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException {
642         int _ttype; Token _token=null; int _begin=text.length();
643         _ttype = GREATEREQUALSIGN;
644         int _saveIndex;
645         
646         match('>');
647         match('=');
648         if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
649             _token = makeToken(_ttype);
650             _token.setText(new String JavaDoc(text.getBuffer(), _begin, text.length()-_begin));
651         }
652         _returnToken = _token;
653     }
654     
655     
656     private static final long[] mk_tokenSet_0() {
657         long[] data = { 8358512713185371648L, 576460746532061184L, 0L, 0L};
658         return data;
659     }
660     public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
661     private static final long[] mk_tokenSet_1() {
662         long[] data = { 8358513245761316352L, 576460746532061184L, 0L, 0L};
663         return data;
664     }
665     public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
666     
667     }
668
Popular Tags