001: // $ANTLR : "tokdef.g" -> "ANTLRTokdefLexer.java"$
002: package persistence.antlr;
003:
004: import java.io.InputStream;
005: import persistence.antlr.TokenStreamException;
006: import persistence.antlr.TokenStreamIOException;
007: import persistence.antlr.TokenStreamRecognitionException;
008: import persistence.antlr.CharStreamException;
009: import persistence.antlr.CharStreamIOException;
010: import persistence.antlr.ANTLRException;
011: import java.io.Reader;
012: import java.util.Hashtable;
013: import persistence.antlr.CharScanner;
014: import persistence.antlr.InputBuffer;
015: import persistence.antlr.ByteBuffer;
016: import persistence.antlr.CharBuffer;
017: import persistence.antlr.Token;
018: import persistence.antlr.CommonToken;
019: import persistence.antlr.RecognitionException;
020: import persistence.antlr.NoViableAltForCharException;
021: import persistence.antlr.MismatchedCharException;
022: import persistence.antlr.TokenStream;
023: import persistence.antlr.ANTLRHashString;
024: import persistence.antlr.LexerSharedInputState;
025: import persistence.antlr.collections.impl.BitSet;
026: import persistence.antlr.SemanticException;
027:
028: public class ANTLRTokdefLexer extends persistence.antlr.CharScanner
029: implements ANTLRTokdefParserTokenTypes, TokenStream {
030: public ANTLRTokdefLexer(InputStream in) {
031: this (new ByteBuffer(in));
032: }
033:
034: public ANTLRTokdefLexer(Reader in) {
035: this (new CharBuffer(in));
036: }
037:
038: public ANTLRTokdefLexer(InputBuffer ib) {
039: this (new LexerSharedInputState(ib));
040: }
041:
042: public ANTLRTokdefLexer(LexerSharedInputState state) {
043: super (state);
044: caseSensitiveLiterals = true;
045: setCaseSensitive(true);
046: literals = new Hashtable();
047: }
048:
049: public Token nextToken() throws TokenStreamException {
050: Token theRetToken = null;
051: tryAgain: for (;;) {
052: Token _token = null;
053: int _ttype = Token.INVALID_TYPE;
054: resetText();
055: try { // for char stream error handling
056: try { // for lexical error handling
057: switch (LA(1)) {
058: case '\t':
059: case '\n':
060: case '\r':
061: case ' ': {
062: mWS(true);
063: theRetToken = _returnToken;
064: break;
065: }
066: case '(': {
067: mLPAREN(true);
068: theRetToken = _returnToken;
069: break;
070: }
071: case ')': {
072: mRPAREN(true);
073: theRetToken = _returnToken;
074: break;
075: }
076: case '=': {
077: mASSIGN(true);
078: theRetToken = _returnToken;
079: break;
080: }
081: case '"': {
082: mSTRING(true);
083: theRetToken = _returnToken;
084: break;
085: }
086: case 'A':
087: case 'B':
088: case 'C':
089: case 'D':
090: case 'E':
091: case 'F':
092: case 'G':
093: case 'H':
094: case 'I':
095: case 'J':
096: case 'K':
097: case 'L':
098: case 'M':
099: case 'N':
100: case 'O':
101: case 'P':
102: case 'Q':
103: case 'R':
104: case 'S':
105: case 'T':
106: case 'U':
107: case 'V':
108: case 'W':
109: case 'X':
110: case 'Y':
111: case 'Z':
112: case 'a':
113: case 'b':
114: case 'c':
115: case 'd':
116: case 'e':
117: case 'f':
118: case 'g':
119: case 'h':
120: case 'i':
121: case 'j':
122: case 'k':
123: case 'l':
124: case 'm':
125: case 'n':
126: case 'o':
127: case 'p':
128: case 'q':
129: case 'r':
130: case 's':
131: case 't':
132: case 'u':
133: case 'v':
134: case 'w':
135: case 'x':
136: case 'y':
137: case 'z': {
138: mID(true);
139: theRetToken = _returnToken;
140: break;
141: }
142: case '0':
143: case '1':
144: case '2':
145: case '3':
146: case '4':
147: case '5':
148: case '6':
149: case '7':
150: case '8':
151: case '9': {
152: mINT(true);
153: theRetToken = _returnToken;
154: break;
155: }
156: default:
157: if ((LA(1) == '/') && (LA(2) == '/')) {
158: mSL_COMMENT(true);
159: theRetToken = _returnToken;
160: } else if ((LA(1) == '/') && (LA(2) == '*')) {
161: mML_COMMENT(true);
162: theRetToken = _returnToken;
163: } else {
164: if (LA(1) == EOF_CHAR) {
165: uponEOF();
166: _returnToken = makeToken(Token.EOF_TYPE);
167: } else {
168: throw new NoViableAltForCharException(
169: (char) LA(1), getFilename(),
170: getLine(), getColumn());
171: }
172: }
173: }
174: if (_returnToken == null)
175: continue tryAgain; // found SKIP token
176: _ttype = _returnToken.getType();
177: _returnToken.setType(_ttype);
178: return _returnToken;
179: } catch (RecognitionException e) {
180: throw new TokenStreamRecognitionException(e);
181: }
182: } catch (CharStreamException cse) {
183: if (cse instanceof CharStreamIOException) {
184: throw new TokenStreamIOException(
185: ((CharStreamIOException) cse).io);
186: } else {
187: throw new TokenStreamException(cse.getMessage());
188: }
189: }
190: }
191: }
192:
193: public final void mWS(boolean _createToken)
194: throws RecognitionException, CharStreamException,
195: TokenStreamException {
196: int _ttype;
197: Token _token = null;
198: int _begin = text.length();
199: _ttype = WS;
200: int _saveIndex;
201:
202: {
203: switch (LA(1)) {
204: case ' ': {
205: match(' ');
206: break;
207: }
208: case '\t': {
209: match('\t');
210: break;
211: }
212: case '\r': {
213: match('\r');
214: {
215: if ((LA(1) == '\n')) {
216: match('\n');
217: } else {
218: }
219:
220: }
221: newline();
222: break;
223: }
224: case '\n': {
225: match('\n');
226: newline();
227: break;
228: }
229: default: {
230: throw new NoViableAltForCharException((char) LA(1),
231: getFilename(), getLine(), getColumn());
232: }
233: }
234: }
235: _ttype = Token.SKIP;
236: if (_createToken && _token == null && _ttype != Token.SKIP) {
237: _token = makeToken(_ttype);
238: _token.setText(new String(text.getBuffer(), _begin, text
239: .length()
240: - _begin));
241: }
242: _returnToken = _token;
243: }
244:
245: public final void mSL_COMMENT(boolean _createToken)
246: throws RecognitionException, CharStreamException,
247: TokenStreamException {
248: int _ttype;
249: Token _token = null;
250: int _begin = text.length();
251: _ttype = SL_COMMENT;
252: int _saveIndex;
253:
254: match("//");
255: {
256: _loop234: do {
257: if ((_tokenSet_0.member(LA(1)))) {
258: {
259: match(_tokenSet_0);
260: }
261: } else {
262: break _loop234;
263: }
264:
265: } while (true);
266: }
267: {
268: switch (LA(1)) {
269: case '\n': {
270: match('\n');
271: break;
272: }
273: case '\r': {
274: match('\r');
275: {
276: if ((LA(1) == '\n')) {
277: match('\n');
278: } else {
279: }
280:
281: }
282: break;
283: }
284: default: {
285: throw new NoViableAltForCharException((char) LA(1),
286: getFilename(), getLine(), getColumn());
287: }
288: }
289: }
290: _ttype = Token.SKIP;
291: newline();
292: if (_createToken && _token == null && _ttype != Token.SKIP) {
293: _token = makeToken(_ttype);
294: _token.setText(new String(text.getBuffer(), _begin, text
295: .length()
296: - _begin));
297: }
298: _returnToken = _token;
299: }
300:
301: public final void mML_COMMENT(boolean _createToken)
302: throws RecognitionException, CharStreamException,
303: TokenStreamException {
304: int _ttype;
305: Token _token = null;
306: int _begin = text.length();
307: _ttype = ML_COMMENT;
308: int _saveIndex;
309:
310: match("/*");
311: {
312: _loop239: do {
313: if ((LA(1) == '*') && (_tokenSet_1.member(LA(2)))) {
314: match('*');
315: matchNot('/');
316: } else if ((LA(1) == '\n')) {
317: match('\n');
318: newline();
319: } else if ((_tokenSet_2.member(LA(1)))) {
320: matchNot('*');
321: } else {
322: break _loop239;
323: }
324:
325: } while (true);
326: }
327: match("*/");
328: _ttype = Token.SKIP;
329: if (_createToken && _token == null && _ttype != Token.SKIP) {
330: _token = makeToken(_ttype);
331: _token.setText(new String(text.getBuffer(), _begin, text
332: .length()
333: - _begin));
334: }
335: _returnToken = _token;
336: }
337:
338: public final void mLPAREN(boolean _createToken)
339: throws RecognitionException, CharStreamException,
340: TokenStreamException {
341: int _ttype;
342: Token _token = null;
343: int _begin = text.length();
344: _ttype = LPAREN;
345: int _saveIndex;
346:
347: match('(');
348: if (_createToken && _token == null && _ttype != Token.SKIP) {
349: _token = makeToken(_ttype);
350: _token.setText(new String(text.getBuffer(), _begin, text
351: .length()
352: - _begin));
353: }
354: _returnToken = _token;
355: }
356:
357: public final void mRPAREN(boolean _createToken)
358: throws RecognitionException, CharStreamException,
359: TokenStreamException {
360: int _ttype;
361: Token _token = null;
362: int _begin = text.length();
363: _ttype = RPAREN;
364: int _saveIndex;
365:
366: match(')');
367: if (_createToken && _token == null && _ttype != Token.SKIP) {
368: _token = makeToken(_ttype);
369: _token.setText(new String(text.getBuffer(), _begin, text
370: .length()
371: - _begin));
372: }
373: _returnToken = _token;
374: }
375:
376: public final void mASSIGN(boolean _createToken)
377: throws RecognitionException, CharStreamException,
378: TokenStreamException {
379: int _ttype;
380: Token _token = null;
381: int _begin = text.length();
382: _ttype = ASSIGN;
383: int _saveIndex;
384:
385: match('=');
386: if (_createToken && _token == null && _ttype != Token.SKIP) {
387: _token = makeToken(_ttype);
388: _token.setText(new String(text.getBuffer(), _begin, text
389: .length()
390: - _begin));
391: }
392: _returnToken = _token;
393: }
394:
395: public final void mSTRING(boolean _createToken)
396: throws RecognitionException, CharStreamException,
397: TokenStreamException {
398: int _ttype;
399: Token _token = null;
400: int _begin = text.length();
401: _ttype = STRING;
402: int _saveIndex;
403:
404: match('"');
405: {
406: _loop245: do {
407: if ((LA(1) == '\\')) {
408: mESC(false);
409: } else if ((_tokenSet_3.member(LA(1)))) {
410: matchNot('"');
411: } else {
412: break _loop245;
413: }
414:
415: } while (true);
416: }
417: match('"');
418: if (_createToken && _token == null && _ttype != Token.SKIP) {
419: _token = makeToken(_ttype);
420: _token.setText(new String(text.getBuffer(), _begin, text
421: .length()
422: - _begin));
423: }
424: _returnToken = _token;
425: }
426:
427: protected final void mESC(boolean _createToken)
428: throws RecognitionException, CharStreamException,
429: TokenStreamException {
430: int _ttype;
431: Token _token = null;
432: int _begin = text.length();
433: _ttype = ESC;
434: int _saveIndex;
435:
436: match('\\');
437: {
438: switch (LA(1)) {
439: case 'n': {
440: match('n');
441: break;
442: }
443: case 'r': {
444: match('r');
445: break;
446: }
447: case 't': {
448: match('t');
449: break;
450: }
451: case 'b': {
452: match('b');
453: break;
454: }
455: case 'f': {
456: match('f');
457: break;
458: }
459: case '"': {
460: match('"');
461: break;
462: }
463: case '\'': {
464: match('\'');
465: break;
466: }
467: case '\\': {
468: match('\\');
469: break;
470: }
471: case '0':
472: case '1':
473: case '2':
474: case '3': {
475: {
476: matchRange('0', '3');
477: }
478: {
479: if (((LA(1) >= '0' && LA(1) <= '9'))
480: && ((LA(2) >= '\u0003' && LA(2) <= '\u00ff'))) {
481: mDIGIT(false);
482: {
483: if (((LA(1) >= '0' && LA(1) <= '9'))
484: && ((LA(2) >= '\u0003' && LA(2) <= '\u00ff'))) {
485: mDIGIT(false);
486: } else if (((LA(1) >= '\u0003' && LA(1) <= '\u00ff')) && (true)) {
487: } else {
488: throw new NoViableAltForCharException(
489: (char) LA(1), getFilename(),
490: getLine(), getColumn());
491: }
492:
493: }
494: } else if (((LA(1) >= '\u0003' && LA(1) <= '\u00ff')) && (true)) {
495: } else {
496: throw new NoViableAltForCharException(
497: (char) LA(1), getFilename(), getLine(),
498: getColumn());
499: }
500:
501: }
502: break;
503: }
504: case '4':
505: case '5':
506: case '6':
507: case '7': {
508: {
509: matchRange('4', '7');
510: }
511: {
512: if (((LA(1) >= '0' && LA(1) <= '9'))
513: && ((LA(2) >= '\u0003' && LA(2) <= '\u00ff'))) {
514: mDIGIT(false);
515: } else if (((LA(1) >= '\u0003' && LA(1) <= '\u00ff')) && (true)) {
516: } else {
517: throw new NoViableAltForCharException(
518: (char) LA(1), getFilename(), getLine(),
519: getColumn());
520: }
521:
522: }
523: break;
524: }
525: case 'u': {
526: match('u');
527: mXDIGIT(false);
528: mXDIGIT(false);
529: mXDIGIT(false);
530: mXDIGIT(false);
531: break;
532: }
533: default: {
534: throw new NoViableAltForCharException((char) LA(1),
535: getFilename(), getLine(), getColumn());
536: }
537: }
538: }
539: if (_createToken && _token == null && _ttype != Token.SKIP) {
540: _token = makeToken(_ttype);
541: _token.setText(new String(text.getBuffer(), _begin, text
542: .length()
543: - _begin));
544: }
545: _returnToken = _token;
546: }
547:
548: protected final void mDIGIT(boolean _createToken)
549: throws RecognitionException, CharStreamException,
550: TokenStreamException {
551: int _ttype;
552: Token _token = null;
553: int _begin = text.length();
554: _ttype = DIGIT;
555: int _saveIndex;
556:
557: matchRange('0', '9');
558: if (_createToken && _token == null && _ttype != Token.SKIP) {
559: _token = makeToken(_ttype);
560: _token.setText(new String(text.getBuffer(), _begin, text
561: .length()
562: - _begin));
563: }
564: _returnToken = _token;
565: }
566:
567: protected final void mXDIGIT(boolean _createToken)
568: throws RecognitionException, CharStreamException,
569: TokenStreamException {
570: int _ttype;
571: Token _token = null;
572: int _begin = text.length();
573: _ttype = XDIGIT;
574: int _saveIndex;
575:
576: switch (LA(1)) {
577: case '0':
578: case '1':
579: case '2':
580: case '3':
581: case '4':
582: case '5':
583: case '6':
584: case '7':
585: case '8':
586: case '9': {
587: matchRange('0', '9');
588: break;
589: }
590: case 'a':
591: case 'b':
592: case 'c':
593: case 'd':
594: case 'e':
595: case 'f': {
596: matchRange('a', 'f');
597: break;
598: }
599: case 'A':
600: case 'B':
601: case 'C':
602: case 'D':
603: case 'E':
604: case 'F': {
605: matchRange('A', 'F');
606: break;
607: }
608: default: {
609: throw new NoViableAltForCharException((char) LA(1),
610: getFilename(), getLine(), getColumn());
611: }
612: }
613: if (_createToken && _token == null && _ttype != Token.SKIP) {
614: _token = makeToken(_ttype);
615: _token.setText(new String(text.getBuffer(), _begin, text
616: .length()
617: - _begin));
618: }
619: _returnToken = _token;
620: }
621:
622: public final void mID(boolean _createToken)
623: throws RecognitionException, CharStreamException,
624: TokenStreamException {
625: int _ttype;
626: Token _token = null;
627: int _begin = text.length();
628: _ttype = ID;
629: int _saveIndex;
630:
631: {
632: switch (LA(1)) {
633: case 'a':
634: case 'b':
635: case 'c':
636: case 'd':
637: case 'e':
638: case 'f':
639: case 'g':
640: case 'h':
641: case 'i':
642: case 'j':
643: case 'k':
644: case 'l':
645: case 'm':
646: case 'n':
647: case 'o':
648: case 'p':
649: case 'q':
650: case 'r':
651: case 's':
652: case 't':
653: case 'u':
654: case 'v':
655: case 'w':
656: case 'x':
657: case 'y':
658: case 'z': {
659: matchRange('a', 'z');
660: break;
661: }
662: case 'A':
663: case 'B':
664: case 'C':
665: case 'D':
666: case 'E':
667: case 'F':
668: case 'G':
669: case 'H':
670: case 'I':
671: case 'J':
672: case 'K':
673: case 'L':
674: case 'M':
675: case 'N':
676: case 'O':
677: case 'P':
678: case 'Q':
679: case 'R':
680: case 'S':
681: case 'T':
682: case 'U':
683: case 'V':
684: case 'W':
685: case 'X':
686: case 'Y':
687: case 'Z': {
688: matchRange('A', 'Z');
689: break;
690: }
691: default: {
692: throw new NoViableAltForCharException((char) LA(1),
693: getFilename(), getLine(), getColumn());
694: }
695: }
696: }
697: {
698: _loop258: do {
699: switch (LA(1)) {
700: case 'a':
701: case 'b':
702: case 'c':
703: case 'd':
704: case 'e':
705: case 'f':
706: case 'g':
707: case 'h':
708: case 'i':
709: case 'j':
710: case 'k':
711: case 'l':
712: case 'm':
713: case 'n':
714: case 'o':
715: case 'p':
716: case 'q':
717: case 'r':
718: case 's':
719: case 't':
720: case 'u':
721: case 'v':
722: case 'w':
723: case 'x':
724: case 'y':
725: case 'z': {
726: matchRange('a', 'z');
727: break;
728: }
729: case 'A':
730: case 'B':
731: case 'C':
732: case 'D':
733: case 'E':
734: case 'F':
735: case 'G':
736: case 'H':
737: case 'I':
738: case 'J':
739: case 'K':
740: case 'L':
741: case 'M':
742: case 'N':
743: case 'O':
744: case 'P':
745: case 'Q':
746: case 'R':
747: case 'S':
748: case 'T':
749: case 'U':
750: case 'V':
751: case 'W':
752: case 'X':
753: case 'Y':
754: case 'Z': {
755: matchRange('A', 'Z');
756: break;
757: }
758: case '_': {
759: match('_');
760: break;
761: }
762: case '0':
763: case '1':
764: case '2':
765: case '3':
766: case '4':
767: case '5':
768: case '6':
769: case '7':
770: case '8':
771: case '9': {
772: matchRange('0', '9');
773: break;
774: }
775: default: {
776: break _loop258;
777: }
778: }
779: } while (true);
780: }
781: if (_createToken && _token == null && _ttype != Token.SKIP) {
782: _token = makeToken(_ttype);
783: _token.setText(new String(text.getBuffer(), _begin, text
784: .length()
785: - _begin));
786: }
787: _returnToken = _token;
788: }
789:
790: public final void mINT(boolean _createToken)
791: throws RecognitionException, CharStreamException,
792: TokenStreamException {
793: int _ttype;
794: Token _token = null;
795: int _begin = text.length();
796: _ttype = INT;
797: int _saveIndex;
798:
799: {
800: int _cnt261 = 0;
801: _loop261: do {
802: if (((LA(1) >= '0' && LA(1) <= '9'))) {
803: mDIGIT(false);
804: } else {
805: if (_cnt261 >= 1) {
806: break _loop261;
807: } else {
808: throw new NoViableAltForCharException(
809: (char) LA(1), getFilename(), getLine(),
810: getColumn());
811: }
812: }
813:
814: _cnt261++;
815: } while (true);
816: }
817: if (_createToken && _token == null && _ttype != Token.SKIP) {
818: _token = makeToken(_ttype);
819: _token.setText(new String(text.getBuffer(), _begin, text
820: .length()
821: - _begin));
822: }
823: _returnToken = _token;
824: }
825:
826: private static final long[] mk_tokenSet_0() {
827: long[] data = new long[8];
828: data[0] = -9224L;
829: for (int i = 1; i <= 3; i++) {
830: data[i] = -1L;
831: }
832: return data;
833: }
834:
835: public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
836:
837: private static final long[] mk_tokenSet_1() {
838: long[] data = new long[8];
839: data[0] = -140737488355336L;
840: for (int i = 1; i <= 3; i++) {
841: data[i] = -1L;
842: }
843: return data;
844: }
845:
846: public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
847:
848: private static final long[] mk_tokenSet_2() {
849: long[] data = new long[8];
850: data[0] = -4398046512136L;
851: for (int i = 1; i <= 3; i++) {
852: data[i] = -1L;
853: }
854: return data;
855: }
856:
857: public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
858:
859: private static final long[] mk_tokenSet_3() {
860: long[] data = new long[8];
861: data[0] = -17179869192L;
862: data[1] = -268435457L;
863: for (int i = 2; i <= 3; i++) {
864: data[i] = -1L;
865: }
866: return data;
867: }
868:
869: public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3());
870:
871: }
|