1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.struts.validator.validwhen;
20
21 import antlr.ANTLRHashString;
22 import antlr.ByteBuffer;
23 import antlr.CharBuffer;
24 import antlr.CharStreamException;
25 import antlr.CharStreamIOException;
26 import antlr.InputBuffer;
27 import antlr.LexerSharedInputState;
28 import antlr.NoViableAltForCharException;
29 import antlr.RecognitionException;
30 import antlr.Token;
31 import antlr.TokenStream;
32 import antlr.TokenStreamException;
33 import antlr.TokenStreamIOException;
34 import antlr.TokenStreamRecognitionException;
35 import antlr.collections.impl.BitSet;
36
37 import java.io.InputStream;
38 import java.io.Reader;
39
40 import java.util.Hashtable;
41
42 public class ValidWhenLexer extends antlr.CharScanner
43 implements ValidWhenParserTokenTypes, TokenStream {
44 public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
45 public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
46
47 public ValidWhenLexer(InputStream in) {
48 this(new ByteBuffer(in));
49 }
50
51 public ValidWhenLexer(Reader in) {
52 this(new CharBuffer(in));
53 }
54
55 public ValidWhenLexer(InputBuffer ib) {
56 this(new LexerSharedInputState(ib));
57 }
58
59 public ValidWhenLexer(LexerSharedInputState state) {
60 super(state);
61 caseSensitiveLiterals = true;
62 setCaseSensitive(false);
63 literals = new Hashtable();
64 literals.put(new ANTLRHashString("null", this), new Integer(11));
65 literals.put(new ANTLRHashString("or", this), new Integer(16));
66 literals.put(new ANTLRHashString("and", this), new Integer(15));
67 }
68
69 public Token nextToken() throws TokenStreamException {
70 Token theRetToken = null;
71
72 tryAgain:
73 for (;;) {
74 Token _token = null;
75 int _ttype = Token.INVALID_TYPE;
76
77 resetText();
78
79 try {
80
81 try {
82
83 switch (LA(1)) {
84 case '\t':
85 case '\n':
86 case '\r':
87 case ' ': {
88 mWS(true);
89 theRetToken = _returnToken;
90
91 break;
92 }
93
94 case '-':
95 case '1':
96 case '2':
97 case '3':
98 case '4':
99 case '5':
100 case '6':
101 case '7':
102 case '8':
103 case '9': {
104 mDECIMAL_LITERAL(true);
105 theRetToken = _returnToken;
106
107 break;
108 }
109
110 case '"':
111 case '\'': {
112 mSTRING_LITERAL(true);
113 theRetToken = _returnToken;
114
115 break;
116 }
117
118 case '[': {
119 mLBRACKET(true);
120 theRetToken = _returnToken;
121
122 break;
123 }
124
125 case ']': {
126 mRBRACKET(true);
127 theRetToken = _returnToken;
128
129 break;
130 }
131
132 case '(': {
133 mLPAREN(true);
134 theRetToken = _returnToken;
135
136 break;
137 }
138
139 case ')': {
140 mRPAREN(true);
141 theRetToken = _returnToken;
142
143 break;
144 }
145
146 case '*': {
147 mTHIS(true);
148 theRetToken = _returnToken;
149
150 break;
151 }
152
153 case '.':
154 case '_':
155 case 'a':
156 case 'b':
157 case 'c':
158 case 'd':
159 case 'e':
160 case 'f':
161 case 'g':
162 case 'h':
163 case 'i':
164 case 'j':
165 case 'k':
166 case 'l':
167 case 'm':
168 case 'n':
169 case 'o':
170 case 'p':
171 case 'q':
172 case 'r':
173 case 's':
174 case 't':
175 case 'u':
176 case 'v':
177 case 'w':
178 case 'x':
179 case 'y':
180 case 'z': {
181 mIDENTIFIER(true);
182 theRetToken = _returnToken;
183
184 break;
185 }
186
187 case '=': {
188 mEQUALSIGN(true);
189 theRetToken = _returnToken;
190
191 break;
192 }
193
194 case '!': {
195 mNOTEQUALSIGN(true);
196 theRetToken = _returnToken;
197
198 break;
199 }
200
201 default:
202
203 if ((LA(1) == '0') && (LA(2) == 'x')) {
204 mHEX_LITERAL(true);
205 theRetToken = _returnToken;
206 } else if ((LA(1) == '<') && (LA(2) == '=')) {
207 mLESSEQUALSIGN(true);
208 theRetToken = _returnToken;
209 } else if ((LA(1) == '>') && (LA(2) == '=')) {
210 mGREATEREQUALSIGN(true);
211 theRetToken = _returnToken;
212 } else if ((LA(1) == '0') && (true)) {
213 mOCTAL_LITERAL(true);
214 theRetToken = _returnToken;
215 } else if ((LA(1) == '<') && (true)) {
216 mLESSTHANSIGN(true);
217 theRetToken = _returnToken;
218 } else if ((LA(1) == '>') && (true)) {
219 mGREATERTHANSIGN(true);
220 theRetToken = _returnToken;
221 } else {
222 if (LA(1) == EOF_CHAR) {
223 uponEOF();
224 _returnToken = makeToken(Token.EOF_TYPE);
225 } else {
226 throw new NoViableAltForCharException((char) LA(
227 1), getFilename(), getLine(),
228 getColumn());
229 }
230 }
231 }
232
233 if (_returnToken == null) {
234 continue tryAgain;
235 }
236
237 _ttype = _returnToken.getType();
238 _ttype = testLiteralsTable(_ttype);
239 _returnToken.setType(_ttype);
240
241 return _returnToken;
242 } catch (RecognitionException e) {
243 throw new TokenStreamRecognitionException(e);
244 }
245 } catch (CharStreamException cse) {
246 if (cse instanceof CharStreamIOException) {
247 throw new TokenStreamIOException(
248 ((CharStreamIOException) cse).io);
249 } else {
250 throw new TokenStreamException(cse.getMessage());
251 }
252 }
253 }
254 }
255
256 public final void mWS(boolean _createToken)
257 throws RecognitionException, CharStreamException, TokenStreamException {
258 int _ttype;
259 Token _token = null;
260 int _begin = text.length();
261
262 _ttype = WS;
263
264 int _saveIndex;
265
266 {
267 int _cnt15 = 0;
268
269 _loop15:
270 do {
271 switch (LA(1)) {
272 case ' ': {
273 match(' ');
274
275 break;
276 }
277
278 case '\t': {
279 match('\t');
280
281 break;
282 }
283
284 case '\n': {
285 match('\n');
286
287 break;
288 }
289
290 case '\r': {
291 match('\r');
292
293 break;
294 }
295
296 default: {
297 if (_cnt15 >= 1) {
298 break _loop15;
299 } else {
300 throw new NoViableAltForCharException((char) LA(1),
301 getFilename(), getLine(), getColumn());
302 }
303 }
304 }
305
306 _cnt15++;
307 } while (true);
308 }
309
310 _ttype = Token.SKIP;
311
312 if (_createToken && (_token == null) && (_ttype != Token.SKIP)) {
313 _token = makeToken(_ttype);
314 _token.setText(new String(text.getBuffer(), _begin,
315 text.length() - _begin));
316 }
317
318 _returnToken = _token;
319 }
320
321 public final void mDECIMAL_LITERAL(boolean _createToken)
322 throws RecognitionException, CharStreamException, TokenStreamException {
323 int _ttype;
324 Token _token = null;
325 int _begin = text.length();
326
327 _ttype = DECIMAL_LITERAL;
328
329 int _saveIndex;
330
331 switch (LA(1)) {
332 case '-': {
333 match('-');
334
335 break;
336 }
337
338 case '1':
339 case '2':
340 case '3':
341 case '4':
342 case '5':
343 case '6':
344 case '7':
345 case '8':
346 case '9':
347 break;
348
349 default:
350 throw new NoViableAltForCharException((char) LA(1), getFilename(),
351 getLine(), getColumn());
352 }
353
354 matchRange('1', '9');
355 _loop20:
356 do {
357 if ((((LA(1) >= '0') && (LA(1) <= '9')))) {
358 matchRange('0', '9');
359 } else {
360 break _loop20;
361 }
362 } while (true);
363
364 if (_createToken && (_token == null) && (_ttype != Token.SKIP)) {
365 _token = makeToken(_ttype);
366 _token.setText(new String(text.getBuffer(), _begin,
367 text.length() - _begin));
368 }
369
370 _returnToken = _token;
371 }
372
373 public final void mHEX_LITERAL(boolean _createToken)
374 throws RecognitionException, CharStreamException, TokenStreamException {
375 int _ttype;
376 Token _token = null;
377 int _begin = text.length();
378
379 _ttype = HEX_LITERAL;
380
381 int _saveIndex;
382
383 match('0');
384 match('x');
385
386 {
387 int _cnt23 = 0;
388
389 _loop23:
390 do {
391 switch (LA(1)) {
392 case '0':
393 case '1':
394 case '2':
395 case '3':
396 case '4':
397 case '5':
398 case '6':
399 case '7':
400 case '8':
401 case '9': {
402 matchRange('0', '9');
403
404 break;
405 }
406
407 case 'a':
408 case 'b':
409 case 'c':
410 case 'd':
411 case 'e':
412 case 'f': {
413 matchRange('a', 'f');
414
415 break;
416 }
417
418 default: {
419 if (_cnt23 >= 1) {
420 break _loop23;
421 } else {
422 throw new NoViableAltForCharException((char) LA(1),
423 getFilename(), getLine(), getColumn());
424 }
425 }
426 }
427
428 _cnt23++;
429 } while (true);
430 }
431
432 if (_createToken && (_token == null) && (_ttype != Token.SKIP)) {
433 _token = makeToken(_ttype);
434 _token.setText(new String(text.getBuffer(), _begin,
435 text.length() - _begin));
436 }
437
438 _returnToken = _token;
439 }
440
441 public final void mOCTAL_LITERAL(boolean _createToken)
442 throws RecognitionException, CharStreamException, TokenStreamException {
443 int _ttype;
444 Token _token = null;
445 int _begin = text.length();
446
447 _ttype = OCTAL_LITERAL;
448
449 int _saveIndex;
450
451 match('0');
452 _loop26:
453 do {
454 if ((((LA(1) >= '0') && (LA(1) <= '7')))) {
455 matchRange('0', '7');
456 } else {
457 break _loop26;
458 }
459 } while (true);
460
461 if (_createToken && (_token == null) && (_ttype != Token.SKIP)) {
462 _token = makeToken(_ttype);
463 _token.setText(new String(text.getBuffer(), _begin,
464 text.length() - _begin));
465 }
466
467 _returnToken = _token;
468 }
469
470 public final void mSTRING_LITERAL(boolean _createToken)
471 throws RecognitionException, CharStreamException, TokenStreamException {
472 int _ttype;
473 Token _token = null;
474 int _begin = text.length();
475
476 _ttype = STRING_LITERAL;
477
478 int _saveIndex;
479
480 switch (LA(1)) {
481 case '\'': {
482 match('\'');
483
484 {
485 int _cnt30 = 0;
486
487 _loop30:
488 do {
489 if ((_tokenSet_0.member(LA(1)))) {
490 matchNot('\'');
491 } else {
492 if (_cnt30 >= 1) {
493 break _loop30;
494 } else {
495 throw new NoViableAltForCharException((char) LA(1),
496 getFilename(), getLine(), getColumn());
497 }
498 }
499
500 _cnt30++;
501 } while (true);
502 }
503
504 match('\'');
505
506 break;
507 }
508
509 case '"': {
510 match('\"');
511
512 {
513 int _cnt33 = 0;
514
515 _loop33:
516 do {
517 if ((_tokenSet_1.member(LA(1)))) {
518 matchNot('\"');
519 } else {
520 if (_cnt33 >= 1) {
521 break _loop33;
522 } else {
523 throw new NoViableAltForCharException((char) LA(1),
524 getFilename(), getLine(), getColumn());
525 }
526 }
527
528 _cnt33++;
529 } while (true);
530 }
531
532 match('\"');
533
534 break;
535 }
536
537 default:
538 throw new NoViableAltForCharException((char) LA(1), getFilename(),
539 getLine(), getColumn());
540 }
541
542 if (_createToken && (_token == null) && (_ttype != Token.SKIP)) {
543 _token = makeToken(_ttype);
544 _token.setText(new String(text.getBuffer(), _begin,
545 text.length() - _begin));
546 }
547
548 _returnToken = _token;
549 }
550
551 public final void mLBRACKET(boolean _createToken)
552 throws RecognitionException, CharStreamException, TokenStreamException {
553 int _ttype;
554 Token _token = null;
555 int _begin = text.length();
556
557 _ttype = LBRACKET;
558
559 int _saveIndex;
560
561 match('[');
562
563 if (_createToken && (_token == null) && (_ttype != Token.SKIP)) {
564 _token = makeToken(_ttype);
565 _token.setText(new String(text.getBuffer(), _begin,
566 text.length() - _begin));
567 }
568
569 _returnToken = _token;
570 }
571
572 public final void mRBRACKET(boolean _createToken)
573 throws RecognitionException, CharStreamException, TokenStreamException {
574 int _ttype;
575 Token _token = null;
576 int _begin = text.length();
577
578 _ttype = RBRACKET;
579
580 int _saveIndex;
581
582 match(']');
583
584 if (_createToken && (_token == null) && (_ttype != Token.SKIP)) {
585 _token = makeToken(_ttype);
586 _token.setText(new String(text.getBuffer(), _begin,
587 text.length() - _begin));
588 }
589
590 _returnToken = _token;
591 }
592
593 public final void mLPAREN(boolean _createToken)
594 throws RecognitionException, CharStreamException, TokenStreamException {
595 int _ttype;
596 Token _token = null;
597 int _begin = text.length();
598
599 _ttype = LPAREN;
600
601 int _saveIndex;
602
603 match('(');
604
605 if (_createToken && (_token == null) && (_ttype != Token.SKIP)) {
606 _token = makeToken(_ttype);
607 _token.setText(new String(text.getBuffer(), _begin,
608 text.length() - _begin));
609 }
610
611 _returnToken = _token;
612 }
613
614 public final void mRPAREN(boolean _createToken)
615 throws RecognitionException, CharStreamException, TokenStreamException {
616 int _ttype;
617 Token _token = null;
618 int _begin = text.length();
619
620 _ttype = RPAREN;
621
622 int _saveIndex;
623
624 match(')');
625
626 if (_createToken && (_token == null) && (_ttype != Token.SKIP)) {
627 _token = makeToken(_ttype);
628 _token.setText(new String(text.getBuffer(), _begin,
629 text.length() - _begin));
630 }
631
632 _returnToken = _token;
633 }
634
635 public final void mTHIS(boolean _createToken)
636 throws RecognitionException, CharStreamException, TokenStreamException {
637 int _ttype;
638 Token _token = null;
639 int _begin = text.length();
640
641 _ttype = THIS;
642
643 int _saveIndex;
644
645 match("*this*");
646
647 if (_createToken && (_token == null) && (_ttype != Token.SKIP)) {
648 _token = makeToken(_ttype);
649 _token.setText(new String(text.getBuffer(), _begin,
650 text.length() - _begin));
651 }
652
653 _returnToken = _token;
654 }
655
656 public final void mIDENTIFIER(boolean _createToken)
657 throws RecognitionException, CharStreamException, TokenStreamException {
658 int _ttype;
659 Token _token = null;
660 int _begin = text.length();
661
662 _ttype = IDENTIFIER;
663
664 int _saveIndex;
665
666 switch (LA(1)) {
667 case 'a':
668 case 'b':
669 case 'c':
670 case 'd':
671 case 'e':
672 case 'f':
673 case 'g':
674 case 'h':
675 case 'i':
676 case 'j':
677 case 'k':
678 case 'l':
679 case 'm':
680 case 'n':
681 case 'o':
682 case 'p':
683 case 'q':
684 case 'r':
685 case 's':
686 case 't':
687 case 'u':
688 case 'v':
689 case 'w':
690 case 'x':
691 case 'y':
692 case 'z': {
693 matchRange('a', 'z');
694
695 break;
696 }
697
698 case '.': {
699 match('.');
700
701 break;
702 }
703
704 case '_': {
705 match('_');
706
707 break;
708 }
709
710 default:
711 throw new NoViableAltForCharException((char) LA(1), getFilename(),
712 getLine(), getColumn());
713 }
714
715 {
716 int _cnt42 = 0;
717
718 _loop42:
719 do {
720 switch (LA(1)) {
721 case 'a':
722 case 'b':
723 case 'c':
724 case 'd':
725 case 'e':
726 case 'f':
727 case 'g':
728 case 'h':
729 case 'i':
730 case 'j':
731 case 'k':
732 case 'l':
733 case 'm':
734 case 'n':
735 case 'o':
736 case 'p':
737 case 'q':
738 case 'r':
739 case 's':
740 case 't':
741 case 'u':
742 case 'v':
743 case 'w':
744 case 'x':
745 case 'y':
746 case 'z': {
747 matchRange('a', 'z');
748
749 break;
750 }
751
752 case '0':
753 case '1':
754 case '2':
755 case '3':
756 case '4':
757 case '5':
758 case '6':
759 case '7':
760 case '8':
761 case '9': {
762 matchRange('0', '9');
763
764 break;
765 }
766
767 case '.': {
768 match('.');
769
770 break;
771 }
772
773 case '_': {
774 match('_');
775
776 break;
777 }
778
779 default: {
780 if (_cnt42 >= 1) {
781 break _loop42;
782 } else {
783 throw new NoViableAltForCharException((char) LA(1),
784 getFilename(), getLine(), getColumn());
785 }
786 }
787 }
788
789 _cnt42++;
790 } while (true);
791 }
792
793 if (_createToken && (_token == null) && (_ttype != Token.SKIP)) {
794 _token = makeToken(_ttype);
795 _token.setText(new String(text.getBuffer(), _begin,
796 text.length() - _begin));
797 }
798
799 _returnToken = _token;
800 }
801
802 public final void mEQUALSIGN(boolean _createToken)
803 throws RecognitionException, CharStreamException, TokenStreamException {
804 int _ttype;
805 Token _token = null;
806 int _begin = text.length();
807
808 _ttype = EQUALSIGN;
809
810 int _saveIndex;
811
812 match('=');
813 match('=');
814
815 if (_createToken && (_token == null) && (_ttype != Token.SKIP)) {
816 _token = makeToken(_ttype);
817 _token.setText(new String(text.getBuffer(), _begin,
818 text.length() - _begin));
819 }
820
821 _returnToken = _token;
822 }
823
824 public final void mNOTEQUALSIGN(boolean _createToken)
825 throws RecognitionException, CharStreamException, TokenStreamException {
826 int _ttype;
827 Token _token = null;
828 int _begin = text.length();
829
830 _ttype = NOTEQUALSIGN;
831
832 int _saveIndex;
833
834 match('!');
835 match('=');
836
837 if (_createToken && (_token == null) && (_ttype != Token.SKIP)) {
838 _token = makeToken(_ttype);
839 _token.setText(new String(text.getBuffer(), _begin,
840 text.length() - _begin));
841 }
842
843 _returnToken = _token;
844 }
845
846 public final void mLESSTHANSIGN(boolean _createToken)
847 throws RecognitionException, CharStreamException, TokenStreamException {
848 int _ttype;
849 Token _token = null;
850 int _begin = text.length();
851
852 _ttype = LESSTHANSIGN;
853
854 int _saveIndex;
855
856 match('<');
857
858 if (_createToken && (_token == null) && (_ttype != Token.SKIP)) {
859 _token = makeToken(_ttype);
860 _token.setText(new String(text.getBuffer(), _begin,
861 text.length() - _begin));
862 }
863
864 _returnToken = _token;
865 }
866
867 public final void mGREATERTHANSIGN(boolean _createToken)
868 throws RecognitionException, CharStreamException, TokenStreamException {
869 int _ttype;
870 Token _token = null;
871 int _begin = text.length();
872
873 _ttype = GREATERTHANSIGN;
874
875 int _saveIndex;
876
877 match('>');
878
879 if (_createToken && (_token == null) && (_ttype != Token.SKIP)) {
880 _token = makeToken(_ttype);
881 _token.setText(new String(text.getBuffer(), _begin,
882 text.length() - _begin));
883 }
884
885 _returnToken = _token;
886 }
887
888 public final void mLESSEQUALSIGN(boolean _createToken)
889 throws RecognitionException, CharStreamException, TokenStreamException {
890 int _ttype;
891 Token _token = null;
892 int _begin = text.length();
893
894 _ttype = LESSEQUALSIGN;
895
896 int _saveIndex;
897
898 match('<');
899 match('=');
900
901 if (_createToken && (_token == null) && (_ttype != Token.SKIP)) {
902 _token = makeToken(_ttype);
903 _token.setText(new String(text.getBuffer(), _begin,
904 text.length() - _begin));
905 }
906
907 _returnToken = _token;
908 }
909
910 public final void mGREATEREQUALSIGN(boolean _createToken)
911 throws RecognitionException, CharStreamException, TokenStreamException {
912 int _ttype;
913 Token _token = null;
914 int _begin = text.length();
915
916 _ttype = GREATEREQUALSIGN;
917
918 int _saveIndex;
919
920 match('>');
921 match('=');
922
923 if (_createToken && (_token == null) && (_ttype != Token.SKIP)) {
924 _token = makeToken(_ttype);
925 _token.setText(new String(text.getBuffer(), _begin,
926 text.length() - _begin));
927 }
928
929 _returnToken = _token;
930 }
931
932 private static final long[] mk_tokenSet_0() {
933 long[] data = { 8358512713185371648L, 576460746532061184L, 0L, 0L };
934
935 return data;
936 }
937
938 private static final long[] mk_tokenSet_1() {
939 long[] data = { 8358513245761316352L, 576460746532061184L, 0L, 0L };
940
941 return data;
942 }
943 }