001// $ANTLR 2.7.5 (20050128): "../src/csheets/ext/assertion/AssertionParser.g" -> "AssertionLexer.java"$ 002package csheets.ext.assertion; 003import java.io.InputStream; 004import antlr.TokenStreamException; 005import antlr.TokenStreamIOException; 006import antlr.TokenStreamRecognitionException; 007import antlr.CharStreamException; 008import antlr.CharStreamIOException; 009import antlr.ANTLRException; 010import java.io.Reader; 011import java.util.Hashtable; 012import antlr.CharScanner; 013import antlr.InputBuffer; 014import antlr.ByteBuffer; 015import antlr.CharBuffer; 016import antlr.Token; 017import antlr.CommonToken; 018import antlr.RecognitionException; 019import antlr.NoViableAltForCharException; 020import antlr.MismatchedCharException; 021import antlr.TokenStream; 022import antlr.ANTLRHashString; 023import antlr.LexerSharedInputState; 024import antlr.collections.impl.BitSet; 025import antlr.SemanticException; 026@SuppressWarnings("all") 027public class AssertionLexer extends antlr.CharScanner implements AssertionParserTokenTypes, TokenStream 028 { 029 030 031public AssertionLexer(InputStream in) { 032 this(new ByteBuffer(in)); 033} 034public AssertionLexer(Reader in) { 035 this(new CharBuffer(in)); 036} 037public AssertionLexer(InputBuffer ib) { 038 this(new LexerSharedInputState(ib)); 039} 040public AssertionLexer(LexerSharedInputState state) { 041 super(state); 042 caseSensitiveLiterals = false; 043 setCaseSensitive(false); 044 literals = new Hashtable(); 045} 046 047public Token nextToken() throws TokenStreamException { 048 Token theRetToken=null; 049tryAgain: 050 for (;;) { 051 Token _token = null; 052 int _ttype = Token.INVALID_TYPE; 053 resetText(); 054 try { // for char stream error handling 055 try { // for lexical error handling 056 switch ( LA(1)) { 057 case '\t': case '\n': case '\r': case ' ': 058 { 059 mWS(true); 060 theRetToken=_returnToken; 061 break; 062 } 063 case ',': 064 { 065 mCOMMA(true); 066 theRetToken=_returnToken; 067 break; 068 } 069 case '[': 070 { 071 mLBRACK(true); 072 theRetToken=_returnToken; 073 break; 074 } 075 case ']': 076 { 077 mRBRACK(true); 078 theRetToken=_returnToken; 079 break; 080 } 081 case '-': case '.': case '0': case '1': 082 case '2': case '3': case '4': case '5': 083 case '6': case '7': case '8': case '9': 084 { 085 mNUMBER(true); 086 theRetToken=_returnToken; 087 break; 088 } 089 case 'e': 090 { 091 mEXCEPT(true); 092 theRetToken=_returnToken; 093 break; 094 } 095 case 'i': 096 { 097 mINTEGER(true); 098 theRetToken=_returnToken; 099 break; 100 } 101 case 'o': 102 { 103 mOR(true); 104 theRetToken=_returnToken; 105 break; 106 } 107 case 't': 108 { 109 mTO(true); 110 theRetToken=_returnToken; 111 break; 112 } 113 default: 114 if ((LA(1)=='>') && (LA(2)=='=')) { 115 mGTEQ(true); 116 theRetToken=_returnToken; 117 } 118 else if ((LA(1)=='<') && (LA(2)=='=')) { 119 mLTEQ(true); 120 theRetToken=_returnToken; 121 } 122 else if ((LA(1)=='>') && (true)) { 123 mGT(true); 124 theRetToken=_returnToken; 125 } 126 else if ((LA(1)=='<') && (true)) { 127 mLT(true); 128 theRetToken=_returnToken; 129 } 130 else { 131 if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);} 132 else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} 133 } 134 } 135 if ( _returnToken==null ) continue tryAgain; // found SKIP token 136 _ttype = _returnToken.getType(); 137 _ttype = testLiteralsTable(_ttype); 138 _returnToken.setType(_ttype); 139 return _returnToken; 140 } 141 catch (RecognitionException e) { 142 throw new TokenStreamRecognitionException(e); 143 } 144 } 145 catch (CharStreamException cse) { 146 if ( cse instanceof CharStreamIOException ) { 147 throw new TokenStreamIOException(((CharStreamIOException)cse).io); 148 } 149 else { 150 throw new TokenStreamException(cse.getMessage()); 151 } 152 } 153 } 154} 155 156 protected final void mEOL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 157 int _ttype; Token _token=null; int _begin=text.length(); 158 _ttype = EOL; 159 int _saveIndex; 160 161 { 162 boolean synPredMatched22 = false; 163 if (((LA(1)=='\r') && (LA(2)=='\n'))) { 164 int _m22 = mark(); 165 synPredMatched22 = true; 166 inputState.guessing++; 167 try { 168 { 169 match("\r\n"); 170 } 171 } 172 catch (RecognitionException pe) { 173 synPredMatched22 = false; 174 } 175 rewind(_m22); 176 inputState.guessing--; 177 } 178 if ( synPredMatched22 ) { 179 match("\r\n"); 180 } 181 else if ((LA(1)=='\r') && (true)) { 182 match('\r'); 183 } 184 else if ((LA(1)=='\n')) { 185 match('\n'); 186 } 187 else { 188 throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); 189 } 190 191 } 192 if ( inputState.guessing==0 ) { 193 newline(); text.setLength(_begin); text.append("end of line"); 194 } 195 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 196 _token = makeToken(_ttype); 197 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); 198 } 199 _returnToken = _token; 200 } 201 202 public final void mWS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 203 int _ttype; Token _token=null; int _begin=text.length(); 204 _ttype = WS; 205 int _saveIndex; 206 207 { 208 switch ( LA(1)) { 209 case ' ': 210 { 211 match(' '); 212 break; 213 } 214 case '\t': 215 { 216 match('\t'); 217 break; 218 } 219 case '\n': case '\r': 220 { 221 mEOL(false); 222 break; 223 } 224 default: 225 { 226 throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); 227 } 228 } 229 } 230 if ( inputState.guessing==0 ) { 231 _ttype = Token.SKIP; 232 } 233 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 234 _token = makeToken(_ttype); 235 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); 236 } 237 _returnToken = _token; 238 } 239 240 public final void mCOMMA(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 241 int _ttype; Token _token=null; int _begin=text.length(); 242 _ttype = COMMA; 243 int _saveIndex; 244 245 match(','); 246 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 247 _token = makeToken(_ttype); 248 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); 249 } 250 _returnToken = _token; 251 } 252 253 public final void mGT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 254 int _ttype; Token _token=null; int _begin=text.length(); 255 _ttype = GT; 256 int _saveIndex; 257 258 match(">"); 259 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 260 _token = makeToken(_ttype); 261 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); 262 } 263 _returnToken = _token; 264 } 265 266 public final void mLT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 267 int _ttype; Token _token=null; int _begin=text.length(); 268 _ttype = LT; 269 int _saveIndex; 270 271 match("<"); 272 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 273 _token = makeToken(_ttype); 274 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); 275 } 276 _returnToken = _token; 277 } 278 279 public final void mGTEQ(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 280 int _ttype; Token _token=null; int _begin=text.length(); 281 _ttype = GTEQ; 282 int _saveIndex; 283 284 match(">="); 285 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 286 _token = makeToken(_ttype); 287 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); 288 } 289 _returnToken = _token; 290 } 291 292 public final void mLTEQ(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 293 int _ttype; Token _token=null; int _begin=text.length(); 294 _ttype = LTEQ; 295 int _saveIndex; 296 297 match("<="); 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 mLBRACK(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 306 int _ttype; Token _token=null; int _begin=text.length(); 307 _ttype = LBRACK; 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 mRBRACK(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 319 int _ttype; Token _token=null; int _begin=text.length(); 320 _ttype = RBRACK; 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 protected final void mDIGIT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 332 int _ttype; Token _token=null; int _begin=text.length(); 333 _ttype = DIGIT; 334 int _saveIndex; 335 336 matchRange('0','9'); 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 mNUMBER(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 345 int _ttype; Token _token=null; int _begin=text.length(); 346 _ttype = NUMBER; 347 int _saveIndex; 348 349 boolean synPredMatched38 = false; 350 if (((_tokenSet_0.member(LA(1))) && (_tokenSet_1.member(LA(2))))) { 351 int _m38 = mark(); 352 synPredMatched38 = true; 353 inputState.guessing++; 354 try { 355 { 356 { 357 switch ( LA(1)) { 358 case '-': 359 { 360 mMINUS(false); 361 break; 362 } 363 case '.': case '0': case '1': case '2': 364 case '3': case '4': case '5': case '6': 365 case '7': case '8': case '9': 366 { 367 break; 368 } 369 default: 370 { 371 throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); 372 } 373 } 374 } 375 { 376 _loop37: 377 do { 378 if (((LA(1) >= '0' && LA(1) <= '9'))) { 379 mDIGIT(false); 380 } 381 else { 382 break _loop37; 383 } 384 385 } while (true); 386 } 387 match('.'); 388 } 389 } 390 catch (RecognitionException pe) { 391 synPredMatched38 = false; 392 } 393 rewind(_m38); 394 inputState.guessing--; 395 } 396 if ( synPredMatched38 ) { 397 { 398 switch ( LA(1)) { 399 case '-': 400 { 401 mMINUS(false); 402 break; 403 } 404 case '.': case '0': case '1': case '2': 405 case '3': case '4': case '5': case '6': 406 case '7': case '8': case '9': 407 { 408 break; 409 } 410 default: 411 { 412 throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); 413 } 414 } 415 } 416 { 417 _loop41: 418 do { 419 if (((LA(1) >= '0' && LA(1) <= '9'))) { 420 mDIGIT(false); 421 } 422 else { 423 break _loop41; 424 } 425 426 } while (true); 427 } 428 match('.'); 429 { 430 int _cnt43=0; 431 _loop43: 432 do { 433 if (((LA(1) >= '0' && LA(1) <= '9'))) { 434 mDIGIT(false); 435 } 436 else { 437 if ( _cnt43>=1 ) { break _loop43; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} 438 } 439 440 _cnt43++; 441 } while (true); 442 } 443 { 444 if ((LA(1)=='e')) { 445 mEXPONENT(false); 446 } 447 else { 448 } 449 450 } 451 } 452 else if ((_tokenSet_2.member(LA(1))) && (true)) { 453 { 454 switch ( LA(1)) { 455 case '-': 456 { 457 mMINUS(false); 458 break; 459 } 460 case '0': case '1': case '2': case '3': 461 case '4': case '5': case '6': case '7': 462 case '8': case '9': 463 { 464 break; 465 } 466 default: 467 { 468 throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); 469 } 470 } 471 } 472 { 473 int _cnt47=0; 474 _loop47: 475 do { 476 if (((LA(1) >= '0' && LA(1) <= '9'))) { 477 mDIGIT(false); 478 } 479 else { 480 if ( _cnt47>=1 ) { break _loop47; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} 481 } 482 483 _cnt47++; 484 } while (true); 485 } 486 { 487 if ((LA(1)=='e')) { 488 mEXPONENT(false); 489 } 490 else { 491 } 492 493 } 494 } 495 else { 496 throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); 497 } 498 499 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 500 _token = makeToken(_ttype); 501 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); 502 } 503 _returnToken = _token; 504 } 505 506 protected final void mMINUS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 507 int _ttype; Token _token=null; int _begin=text.length(); 508 _ttype = MINUS; 509 int _saveIndex; 510 511 match('-'); 512 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 513 _token = makeToken(_ttype); 514 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); 515 } 516 _returnToken = _token; 517 } 518 519 protected final void mEXPONENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 520 int _ttype; Token _token=null; int _begin=text.length(); 521 _ttype = EXPONENT; 522 int _saveIndex; 523 524 match('e'); 525 { 526 switch ( LA(1)) { 527 case '+': 528 { 529 match('+'); 530 break; 531 } 532 case '-': 533 { 534 match('-'); 535 break; 536 } 537 case '0': case '1': case '2': case '3': 538 case '4': case '5': case '6': case '7': 539 case '8': case '9': 540 { 541 break; 542 } 543 default: 544 { 545 throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); 546 } 547 } 548 } 549 { 550 int _cnt54=0; 551 _loop54: 552 do { 553 if (((LA(1) >= '0' && LA(1) <= '9'))) { 554 mDIGIT(false); 555 } 556 else { 557 if ( _cnt54>=1 ) { break _loop54; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} 558 } 559 560 _cnt54++; 561 } while (true); 562 } 563 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 564 _token = makeToken(_ttype); 565 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); 566 } 567 _returnToken = _token; 568 } 569 570 protected final void mPLUS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 571 int _ttype; Token _token=null; int _begin=text.length(); 572 _ttype = PLUS; 573 int _saveIndex; 574 575 match('+'); 576 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 577 _token = makeToken(_ttype); 578 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); 579 } 580 _returnToken = _token; 581 } 582 583 public final void mEXCEPT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 584 int _ttype; Token _token=null; int _begin=text.length(); 585 _ttype = EXCEPT; 586 int _saveIndex; 587 588 match("except"); 589 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 590 _token = makeToken(_ttype); 591 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); 592 } 593 _returnToken = _token; 594 } 595 596 public final void mINTEGER(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 597 int _ttype; Token _token=null; int _begin=text.length(); 598 _ttype = INTEGER; 599 int _saveIndex; 600 601 match("integer"); 602 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 603 _token = makeToken(_ttype); 604 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); 605 } 606 _returnToken = _token; 607 } 608 609 public final void mOR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 610 int _ttype; Token _token=null; int _begin=text.length(); 611 _ttype = OR; 612 int _saveIndex; 613 614 match("or"); 615 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 616 _token = makeToken(_ttype); 617 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); 618 } 619 _returnToken = _token; 620 } 621 622 public final void mTO(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 623 int _ttype; Token _token=null; int _begin=text.length(); 624 _ttype = TO; 625 int _saveIndex; 626 627 match("to"); 628 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 629 _token = makeToken(_ttype); 630 _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); 631 } 632 _returnToken = _token; 633 } 634 635 636 private static final long[] mk_tokenSet_0() { 637 long[] data = { 288054454291267584L, 0L, 0L}; 638 return data; 639 } 640 public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0()); 641 private static final long[] mk_tokenSet_1() { 642 long[] data = { 288019269919178752L, 0L, 0L}; 643 return data; 644 } 645 public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1()); 646 private static final long[] mk_tokenSet_2() { 647 long[] data = { 287984085547089920L, 0L, 0L}; 648 return data; 649 } 650 public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2()); 651 652 }