1 * ANTLR-generated file resulting from grammar tokdef.g
3 *
4 * Terence Parr, MageLang Institute
5 * with John Lilley, Empathy Software
6 * ANTLR Version 2.5.0; 1996,1997
7 */
8 package antlr;
9 import java.io.InputStream;
10 import java.io.Reader;
11 import java.io.IOException;
12 import java.util.Hashtable;
13 import antlr.CharScanner;
14 import antlr.InputBuffer;
15 import antlr.ByteBuffer;
16 import antlr.CharBuffer;
17 import antlr.Token;
18 import antlr.CommonToken;
19 import antlr.ScannerException;
20 import antlr.Tokenizer;
21 import antlr.ANTLRHashString;
22 import antlr.collections.impl.BitSet;
23 public class ANTLRTokdefLexer extends CharScannercanner implements ANTLRTokdefParserTokenTypes, Tokenizer
24 {
25 public ANTLRTokdefLexer(InputStream in) {
26 this(new ByteBuffer(in));
27 }
28 public ANTLRTokdefLexer(Reader in) {
29 this(new CharBuffer(in));
30 }
31 public ANTLRTokdefLexer(InputBuffer ib) {
32 super(ib);
33 literals = new Hashtable();
34 caseSensitiveLiterals = true;
35 setCaseSensitive(true);
36 }
37
38 public Token nextToken() throws IOException {
39 Token _rettoken=null;
40 tryAgain:
41 for (;;) {
42 Token _token = null;
43 int _ttype = Token.INVALID_TYPE;
44 resetText();
45 try { switch ( LA(1)) {
47 case '\t': case '\n': case '\r': case ' ':
48 {
49 mWS(true);
50 _rettoken=_returnToken;
51 break;
52 }
53 case '(':
54 {
55 mLPAREN(true);
56 _rettoken=_returnToken;
57 break;
58 }
59 case ')':
60 {
61 mRPAREN(true);
62 _rettoken=_returnToken;
63 break;
64 }
65 case '=':
66 {
67 mASSIGN(true);
68 _rettoken=_returnToken;
69 break;
70 }
71 case '"':
72 {
73 mSTRING(true);
74 _rettoken=_returnToken;
75 break;
76 }
77 case 'A': case 'B': case 'C': case 'D':
78 case 'E': case 'F': case 'G': case 'H':
79 case 'I': case 'J': case 'K': case 'L':
80 case 'M': case 'N': case 'O': case 'P':
81 case 'Q': case 'R': case 'S': case 'T':
82 case 'U': case 'V': case 'W': case 'X':
83 case 'Y': case 'Z': case 'a': case 'b':
84 case 'c': case 'd': case 'e': case 'f':
85 case 'g': case 'h': case 'i': case 'j':
86 case 'k': case 'l': case 'm': case 'n':
87 case 'o': case 'p': case 'q': case 'r':
88 case 's': case 't': case 'u': case 'v':
89 case 'w': case 'x': case 'y': case 'z':
90 {
91 mID(true);
92 _rettoken=_returnToken;
93 break;
94 }
95 case '0': case '1': case '2': case '3':
96 case '4': case '5': case '6': case '7':
97 case '8': case '9':
98 {
99 mINT(true);
100 _rettoken=_returnToken;
101 break;
102 }
103 default:
104 if ((LA(1)=='/') && (LA(2)=='/')) {
105 mSL_COMMENT(true);
106 _rettoken=_returnToken;
107 }
108 else if ((LA(1)=='/') && (LA(2)=='*')) {
109 mML_COMMENT(true);
110 _rettoken=_returnToken;
111 }
112 else {
113 if (LA(1)==EOF_CHAR) {_returnToken = makeToken(Token.EOF_TYPE);}
114 else {throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());}
115 }
116 }
117 if ( _returnToken==null ) continue tryAgain; _ttype = _returnToken.getType();
119 _returnToken.setType(_ttype);
120 return _returnToken;
121 }
122 catch (ScannerException e) {
123 reportError(e);
124 consume();
125 }
126 }
127 }
128
129 public final void mWS(boolean _createToken) throws ScannerException, IOException {
130 int _ttype; Token _token=null; int _begin=text.length();
131 _ttype = WS;
132 int _saveIndex;
133
134 {
135 switch ( LA(1)) {
136 case ' ':
137 {
138 match(' ');
139 break;
140 }
141 case '\t':
142 {
143 match('\t');
144 break;
145 }
146 case '\r':
147 {
148 match('\r');
149 {
150 if ((LA(1)=='\n')) {
151 match('\n');
152 }
153 else {
154 }
155
156 }
157 newline();
158 break;
159 }
160 case '\n':
161 {
162 match('\n');
163 newline();
164 break;
165 }
166 default:
167 {
168 throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());
169 }
170 }
171 }
172 _ttype = Token.SKIP;
173 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
174 _token = makeToken(_ttype);
175 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
176 }
177 _returnToken = _token;
178 }
179
180 public final void mSL_COMMENT(boolean _createToken) throws ScannerException, IOException {
181 int _ttype; Token _token=null; int _begin=text.length();
182 _ttype = SL_COMMENT;
183 int _saveIndex;
184
185 match("//");
186 {
187 _loop12:
188 do {
189 if ((_tokenSet_0.member(LA(1)))) {
190 {
191 match(_tokenSet_0);
192 }
193 }
194 else {
195 break _loop12;
196 }
197
198 } while (true);
199 }
200 {
201 switch ( LA(1)) {
202 case '\n':
203 {
204 match('\n');
205 break;
206 }
207 case '\r':
208 {
209 match('\r');
210 {
211 if ((LA(1)=='\n')) {
212 match('\n');
213 }
214 else {
215 }
216
217 }
218 break;
219 }
220 default:
221 {
222 throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());
223 }
224 }
225 }
226 _ttype = Token.SKIP; newline();
227 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
228 _token = makeToken(_ttype);
229 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
230 }
231 _returnToken = _token;
232 }
233
234 public final void mML_COMMENT(boolean _createToken) throws ScannerException, IOException {
235 int _ttype; Token _token=null; int _begin=text.length();
236 _ttype = ML_COMMENT;
237 int _saveIndex;
238
239 match("/*");
240 {
241 _loop17:
242 do {
243 switch ( LA(1)) {
244 case '\n':
245 {
246 match('\n');
247 newline();
248 break;
249 }
250 case '\3': case '\4': case '\5': case '\6':
251 case '\7': case '\10': case '\t': case '\13':
252 case '\14': case '\r': case '\16': case '\17':
253 case '\20': case '\21': case '\22': case '\23':
254 case '\24': case '\25': case '\26': case '\27':
255 case '\30': case '\31': case '\32': case '\33':
256 case '\34': case '\35': case '\36': case '\37':
257 case ' ': case '!': case '"': case '#':
258 case '$': case '%': case '&': case '\'':
259 case '(': case ')': case '+': case ',':
260 case '-': case '.': case '/': case '0':
261 case '1': case '2': case '3': case '4':
262 case '5': case '6': case '7': case '8':
263 case '9': case ':': case ';': case '<':
264 case '=': case '>': case '?': case '@':
265 case 'A': case 'B': case 'C': case 'D':
266 case 'E': case 'F': case 'G': case 'H':
267 case 'I': case 'J': case 'K': case 'L':
268 case 'M': case 'N': case 'O': case 'P':
269 case 'Q': case 'R': case 'S': case 'T':
270 case 'U': case 'V': case 'W': case 'X':
271 case 'Y': case 'Z': case '[': case '\\':
272 case ']': case '^': case '_': case '`':
273 case 'a': case 'b': case 'c': case 'd':
274 case 'e': case 'f': case 'g': case 'h':
275 case 'i': case 'j': case 'k': case 'l':
276 case 'm': case 'n': case 'o': case 'p':
277 case 'q': case 'r': case 's': case 't':
278 case 'u': case 'v': case 'w': case 'x':
279 case 'y': case 'z': case '{': case '|':
280 case '}': case '~':
281 {
282 matchNot('*');
283 break;
284 }
285 default:
286 if ((LA(1)=='*') && (_tokenSet_1.member(LA(2)))) {
287 match('*');
288 matchNot('/');
289 }
290 else {
291 break _loop17;
292 }
293 }
294 } while (true);
295 }
296 match("*/");
297 _ttype = Token.SKIP;
298 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
299 _token = makeToken(_ttype);
300 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
301 }
302 _returnToken = _token;
303 }
304
305 public final void mLPAREN(boolean _createToken) throws ScannerException, IOException {
306 int _ttype; Token _token=null; int _begin=text.length();
307 _ttype = LPAREN;
308 int _saveIndex;
309
310 match('(');
311 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
312 _token = makeToken(_ttype);
313 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
314 }
315 _returnToken = _token;
316 }
317
318 public final void mRPAREN(boolean _createToken) throws ScannerException, IOException {
319 int _ttype; Token _token=null; int _begin=text.length();
320 _ttype = RPAREN;
321 int _saveIndex;
322
323 match(')');
324 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
325 _token = makeToken(_ttype);
326 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
327 }
328 _returnToken = _token;
329 }
330
331 public final void mASSIGN(boolean _createToken) throws ScannerException, IOException {
332 int _ttype; Token _token=null; int _begin=text.length();
333 _ttype = ASSIGN;
334 int _saveIndex;
335
336 match('=');
337 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
338 _token = makeToken(_ttype);
339 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
340 }
341 _returnToken = _token;
342 }
343
344 public final void mSTRING(boolean _createToken) throws ScannerException, IOException {
345 int _ttype; Token _token=null; int _begin=text.length();
346 _ttype = STRING;
347 int _saveIndex;
348
349 match('"');
350 {
351 _loop23:
352 do {
353 switch ( LA(1)) {
354 case '\\':
355 {
356 mESC(false);
357 break;
358 }
359 case '\3': case '\4': case '\5': case '\6':
360 case '\7': case '\10': case '\t': case '\n':
361 case '\13': case '\14': case '\r': case '\16':
362 case '\17': case '\20': case '\21': case '\22':
363 case '\23': case '\24': case '\25': case '\26':
364 case '\27': case '\30': case '\31': case '\32':
365 case '\33': case '\34': case '\35': case '\36':
366 case '\37': case ' ': case '!': case '#':
367 case '$': case '%': case '&': case '\'':
368 case '(': case ')': case '*': case '+':
369 case ',': case '-': case '.': case '/':
370 case '0': case '1': case '2': case '3':
371 case '4': case '5': case '6': case '7':
372 case '8': case '9': case ':': case ';':
373 case '<': case '=': case '>': case '?':
374 case '@': case 'A': case 'B': case 'C':
375 case 'D': case 'E': case 'F': case 'G':
376 case 'H': case 'I': case 'J': case 'K':
377 case 'L': case 'M': case 'N': case 'O':
378 case 'P': case 'Q': case 'R': case 'S':
379 case 'T': case 'U': case 'V': case 'W':
380 case 'X': case 'Y': case 'Z': case '[':
381 case ']': case '^': case '_': case '`':
382 case 'a': case 'b': case 'c': case 'd':
383 case 'e': case 'f': case 'g': case 'h':
384 case 'i': case 'j': case 'k': case 'l':
385 case 'm': case 'n': case 'o': case 'p':
386 case 'q': case 'r': case 's': case 't':
387 case 'u': case 'v': case 'w': case 'x':
388 case 'y': case 'z': case '{': case '|':
389 case '}': case '~':
390 {
391 matchNot('"');
392 break;
393 }
394 default:
395 {
396 break _loop23;
397 }
398 }
399 } while (true);
400 }
401 match('"');
402 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
403 _token = makeToken(_ttype);
404 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
405 }
406 _returnToken = _token;
407 }
408
409 protected final void mESC(boolean _createToken) throws ScannerException, IOException {
410 int _ttype; Token _token=null; int _begin=text.length();
411 _ttype = ESC;
412 int _saveIndex;
413
414 match('\\');
415 {
416 switch ( LA(1)) {
417 case 'n':
418 {
419 match('n');
420 break;
421 }
422 case 'r':
423 {
424 match('r');
425 break;
426 }
427 case 't':
428 {
429 match('t');
430 break;
431 }
432 case 'b':
433 {
434 match('b');
435 break;
436 }
437 case 'f':
438 {
439 match('f');
440 break;
441 }
442 case '"':
443 {
444 match('"');
445 break;
446 }
447 case '\'':
448 {
449 match('\'');
450 break;
451 }
452 case '\\':
453 {
454 match('\\');
455 break;
456 }
457 case '0': case '1': case '2': case '3':
458 {
459 {
460 matchRange('0','3');
461 }
462 {
463 if (((LA(1) >= '0' && LA(1) <= '9')) && ((LA(2) >= '\3' && LA(2) <= '~'))) {
464 mDIGIT(false);
465 {
466 if (((LA(1) >= '0' && LA(1) <= '9')) && ((LA(2) >= '\3' && LA(2) <= '~'))) {
467 mDIGIT(false);
468 }
469 else if (((LA(1) >= '\3' && LA(1) <= '~'))) {
470 }
471 else {
472 throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());
473 }
474
475 }
476 }
477 else if (((LA(1) >= '\3' && LA(1) <= '~'))) {
478 }
479 else {
480 throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());
481 }
482
483 }
484 break;
485 }
486 case '4': case '5': case '6': case '7':
487 {
488 {
489 matchRange('4','7');
490 }
491 {
492 if (((LA(1) >= '0' && LA(1) <= '9')) && ((LA(2) >= '\3' && LA(2) <= '~'))) {
493 mDIGIT(false);
494 }
495 else if (((LA(1) >= '\3' && LA(1) <= '~'))) {
496 }
497 else {
498 throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());
499 }
500
501 }
502 break;
503 }
504 case 'u':
505 {
506 match('u');
507 mXDIGIT(false);
508 mXDIGIT(false);
509 mXDIGIT(false);
510 mXDIGIT(false);
511 break;
512 }
513 default:
514 {
515 throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());
516 }
517 }
518 }
519 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
520 _token = makeToken(_ttype);
521 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
522 }
523 _returnToken = _token;
524 }
525
526 protected final void mDIGIT(boolean _createToken) throws ScannerException, IOException {
527 int _ttype; Token _token=null; int _begin=text.length();
528 _ttype = DIGIT;
529 int _saveIndex;
530
531 matchRange('0','9');
532 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
533 _token = makeToken(_ttype);
534 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
535 }
536 _returnToken = _token;
537 }
538
539 protected final void mXDIGIT(boolean _createToken) throws ScannerException, IOException {
540 int _ttype; Token _token=null; int _begin=text.length();
541 _ttype = XDIGIT;
542 int _saveIndex;
543
544 switch ( LA(1)) {
545 case '0': case '1': case '2': case '3':
546 case '4': case '5': case '6': case '7':
547 case '8': case '9':
548 {
549 matchRange('0','9');
550 break;
551 }
552 case 'a': case 'b': case 'c': case 'd':
553 case 'e': case 'f':
554 {
555 matchRange('a','f');
556 break;
557 }
558 case 'A': case 'B': case 'C': case 'D':
559 case 'E': case 'F':
560 {
561 matchRange('A','F');
562 break;
563 }
564 default:
565 {
566 throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());
567 }
568 }
569 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
570 _token = makeToken(_ttype);
571 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
572 }
573 _returnToken = _token;
574 }
575
576 protected final void mVOCAB(boolean _createToken) throws ScannerException, IOException {
577 int _ttype; Token _token=null; int _begin=text.length();
578 _ttype = VOCAB;
579 int _saveIndex;
580
581 matchRange('\3','\176');
582 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
583 _token = makeToken(_ttype);
584 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
585 }
586 _returnToken = _token;
587 }
588
589 public final void mID(boolean _createToken) throws ScannerException, IOException {
590 int _ttype; Token _token=null; int _begin=text.length();
591 _ttype = ID;
592 int _saveIndex;
593
594 {
595 switch ( LA(1)) {
596 case 'a': case 'b': case 'c': case 'd':
597 case 'e': case 'f': case 'g': case 'h':
598 case 'i': case 'j': case 'k': case 'l':
599 case 'm': case 'n': case 'o': case 'p':
600 case 'q': case 'r': case 's': case 't':
601 case 'u': case 'v': case 'w': case 'x':
602 case 'y': case 'z':
603 {
604 matchRange('a','z');
605 break;
606 }
607 case 'A': case 'B': case 'C': case 'D':
608 case 'E': case 'F': case 'G': case 'H':
609 case 'I': case 'J': case 'K': case 'L':
610 case 'M': case 'N': case 'O': case 'P':
611 case 'Q': case 'R': case 'S': case 'T':
612 case 'U': case 'V': case 'W': case 'X':
613 case 'Y': case 'Z':
614 {
615 matchRange('A','Z');
616 break;
617 }
618 default:
619 {
620 throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());
621 }
622 }
623 }
624 {
625 _loop37:
626 do {
627 switch ( LA(1)) {
628 case 'a': case 'b': case 'c': case 'd':
629 case 'e': case 'f': case 'g': case 'h':
630 case 'i': case 'j': case 'k': case 'l':
631 case 'm': case 'n': case 'o': case 'p':
632 case 'q': case 'r': case 's': case 't':
633 case 'u': case 'v': case 'w': case 'x':
634 case 'y': case 'z':
635 {
636 matchRange('a','z');
637 break;
638 }
639 case 'A': case 'B': case 'C': case 'D':
640 case 'E': case 'F': case 'G': case 'H':
641 case 'I': case 'J': case 'K': case 'L':
642 case 'M': case 'N': case 'O': case 'P':
643 case 'Q': case 'R': case 'S': case 'T':
644 case 'U': case 'V': case 'W': case 'X':
645 case 'Y': case 'Z':
646 {
647 matchRange('A','Z');
648 break;
649 }
650 case '_':
651 {
652 match('_');
653 break;
654 }
655 case '0': case '1': case '2': case '3':
656 case '4': case '5': case '6': case '7':
657 case '8': case '9':
658 {
659 matchRange('0','9');
660 break;
661 }
662 default:
663 {
664 break _loop37;
665 }
666 }
667 } while (true);
668 }
669 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
670 _token = makeToken(_ttype);
671 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
672 }
673 _returnToken = _token;
674 }
675
676 public final void mINT(boolean _createToken) throws ScannerException, IOException {
677 int _ttype; Token _token=null; int _begin=text.length();
678 _ttype = INT;
679 int _saveIndex;
680
681 {
682 int _cnt40=0;
683 _loop40:
684 do {
685 if (((LA(1) >= '0' && LA(1) <= '9'))) {
686 mDIGIT(false);
687 }
688 else {
689 if ( _cnt40>=1 ) { break _loop40; } else {throw new ScannerException("no viable alt for char: "+(char)LA(1),getLine());}
690 }
691
692 _cnt40++;
693 } while (true);
694 }
695 if ( _createToken && _token==null && _ttype!=Token.SKIP ) {
696 _token = makeToken(_ttype);
697 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin));
698 }
699 _returnToken = _token;
700 }
701
702
703 private static final long _tokenSet_0_data_[] = { -9224L, 9223372036854775807L, 0L, 0L };
704 public static final BitSet _tokenSet_0 = new BitSet(_tokenSet_0_data_);
705 private static final long _tokenSet_1_data_[] = { -140737488355336L, 9223372036854775807L, 0L, 0L };
706 public static final BitSet _tokenSet_1 = new BitSet(_tokenSet_1_data_);
707
708 }
709