| 1 3 17 18 package org.apache.ojb.odmg.oql; 19 20 21 import java.io.InputStream ; 22 import java.io.Reader ; 23 import java.util.Hashtable ; 24 25 import antlr.ANTLRHashString; 26 import antlr.ByteBuffer; 27 import antlr.CharBuffer; 28 import antlr.CharStreamException; 29 import antlr.CharStreamIOException; 30 import antlr.InputBuffer; 31 import antlr.LexerSharedInputState; 32 import antlr.NoViableAltForCharException; 33 import antlr.RecognitionException; 34 import antlr.Token; 35 import antlr.TokenStream; 36 import antlr.TokenStreamException; 37 import antlr.TokenStreamIOException; 38 import antlr.TokenStreamRecognitionException; 39 import antlr.collections.impl.BitSet; 40 41 60 public class OQLLexer extends antlr.CharScanner implements OQLLexerTokenTypes, TokenStream 61 { 62 public OQLLexer(InputStream in) { 63 this(new ByteBuffer(in)); 64 } 65 public OQLLexer(Reader in) { 66 this(new CharBuffer(in)); 67 } 68 public OQLLexer(InputBuffer ib) { 69 this(new LexerSharedInputState(ib)); 70 } 71 public OQLLexer(LexerSharedInputState state) { 72 super(state); 73 caseSensitiveLiterals = true; 74 setCaseSensitive(true); 75 literals = new Hashtable (); 76 literals.put(new ANTLRHashString("nil", this), new Integer (52)); 77 literals.put(new ANTLRHashString("group", this), new Integer (44)); 78 literals.put(new ANTLRHashString("between", this), new Integer (55)); 79 literals.put(new ANTLRHashString("date", this), new Integer (61)); 80 literals.put(new ANTLRHashString("select", this), new Integer (38)); 81 literals.put(new ANTLRHashString("timestamp", this), new Integer (63)); 82 literals.put(new ANTLRHashString("like", this), new Integer (58)); 83 literals.put(new ANTLRHashString("is_undefined", this), new Integer (56)); 84 literals.put(new ANTLRHashString("asc", this), new Integer (48)); 85 literals.put(new ANTLRHashString("or", this), new Integer (50)); 86 literals.put(new ANTLRHashString("in", this), new Integer (47)); 87 literals.put(new ANTLRHashString("list", this), new Integer (54)); 88 literals.put(new ANTLRHashString("from", this), new Integer (40)); 89 literals.put(new ANTLRHashString("desc", this), new Integer (49)); 90 literals.put(new ANTLRHashString("true", this), new Integer (59)); 91 literals.put(new ANTLRHashString("by", this), new Integer (43)); 92 literals.put(new ANTLRHashString("not", this), new Integer (53)); 93 literals.put(new ANTLRHashString("and", this), new Integer (51)); 94 literals.put(new ANTLRHashString("distinct", this), new Integer (39)); 95 literals.put(new ANTLRHashString("prefetch", this), new Integer (45)); 96 literals.put(new ANTLRHashString("false", this), new Integer (60)); 97 literals.put(new ANTLRHashString("time", this), new Integer (62)); 98 literals.put(new ANTLRHashString("order", this), new Integer (42)); 99 literals.put(new ANTLRHashString("where", this), new Integer (41)); 100 literals.put(new ANTLRHashString("exists", this), new Integer (46)); 101 literals.put(new ANTLRHashString("is_defined", this), new Integer (57)); 102 } 103 104 public Token nextToken() throws TokenStreamException { 105 Token theRetToken=null; 106 tryAgain: 107 for (;;) { 108 Token _token = null; 109 int _ttype = Token.INVALID_TYPE; 110 resetText(); 111 try { try { switch ( LA(1)) { 114 case ')': 115 { 116 mTOK_RPAREN(true); 117 theRetToken=_returnToken; 118 break; 119 } 120 case '(': 121 { 122 mTOK_LPAREN(true); 123 theRetToken=_returnToken; 124 break; 125 } 126 case ',': 127 { 128 mTOK_COMMA(true); 129 theRetToken=_returnToken; 130 break; 131 } 132 case ';': 133 { 134 mTOK_SEMIC(true); 135 theRetToken=_returnToken; 136 break; 137 } 138 case ':': 139 { 140 mTOK_COLON(true); 141 theRetToken=_returnToken; 142 break; 143 } 144 case '|': 145 { 146 mTOK_CONCAT(true); 147 theRetToken=_returnToken; 148 break; 149 } 150 case '=': 151 { 152 mTOK_EQ(true); 153 theRetToken=_returnToken; 154 break; 155 } 156 case '+': 157 { 158 mTOK_PLUS(true); 159 theRetToken=_returnToken; 160 break; 161 } 162 case '*': 163 { 164 mTOK_STAR(true); 165 theRetToken=_returnToken; 166 break; 167 } 168 case '!': 169 { 170 mTOK_NE2(true); 171 theRetToken=_returnToken; 172 break; 173 } 174 case '[': 175 { 176 mTOK_LBRACK(true); 177 theRetToken=_returnToken; 178 break; 179 } 180 case ']': 181 { 182 mTOK_RBRACK(true); 183 theRetToken=_returnToken; 184 break; 185 } 186 case '\'': 187 { 188 mCharLiteral(true); 189 theRetToken=_returnToken; 190 break; 191 } 192 case '"': 193 { 194 mStringLiteral(true); 195 theRetToken=_returnToken; 196 break; 197 } 198 case '\t': case '\r': case ' ': 199 { 200 mWhiteSpace(true); 201 theRetToken=_returnToken; 202 break; 203 } 204 case '\n': 205 { 206 mNewLine(true); 207 theRetToken=_returnToken; 208 break; 209 } 210 default: 211 if ((LA(1)=='-') && (LA(2)=='>')) { 212 mTOK_INDIRECT(true); 213 theRetToken=_returnToken; 214 } 215 else if ((LA(1)=='<') && (LA(2)=='=')) { 216 mTOK_LE(true); 217 theRetToken=_returnToken; 218 } 219 else if ((LA(1)=='>') && (LA(2)=='=')) { 220 mTOK_GE(true); 221 theRetToken=_returnToken; 222 } 223 else if ((LA(1)=='<') && (LA(2)=='>')) { 224 mTOK_NE(true); 225 theRetToken=_returnToken; 226 } 227 else if ((LA(1)=='/') && (LA(2)=='/')) { 228 mCommentLine(true); 229 theRetToken=_returnToken; 230 } 231 else if ((LA(1)=='/') && (LA(2)=='*')) { 232 mMultiLineComment(true); 233 theRetToken=_returnToken; 234 } 235 else if ((LA(1)=='.') && (true)) { 236 mTOK_DOT(true); 237 theRetToken=_returnToken; 238 } 239 else if ((LA(1)=='-') && (true)) { 240 mTOK_MINUS(true); 241 theRetToken=_returnToken; 242 } 243 else if ((LA(1)=='/') && (true)) { 244 mTOK_SLASH(true); 245 theRetToken=_returnToken; 246 } 247 else if ((LA(1)=='<') && (true)) { 248 mTOK_LT(true); 249 theRetToken=_returnToken; 250 } 251 else if ((LA(1)=='>') && (true)) { 252 mTOK_GT(true); 253 theRetToken=_returnToken; 254 } 255 else if ((LA(1)=='$') && (true)) { 256 mTOK_DOLLAR(true); 257 theRetToken=_returnToken; 258 } 259 else if ((_tokenSet_0.member(LA(1))) && (true)) { 260 mIdentifier(true); 261 theRetToken=_returnToken; 262 } 263 else if ((_tokenSet_1.member(LA(1))) && (true)) { 264 mTOK_EXACT_NUMERIC_LITERAL(true); 265 theRetToken=_returnToken; 266 } 267 else { 268 if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);} 269 else {throw new NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());} 270 } 271 } 272 if ( _returnToken==null ) continue tryAgain; _ttype = _returnToken.getType(); 274 _returnToken.setType(_ttype); 275 return _returnToken; 276 } 277 catch (RecognitionException e) { 278 throw new TokenStreamRecognitionException(e); 279 } 280 } 281 catch (CharStreamException cse) { 282 if ( cse instanceof CharStreamIOException ) { 283 throw new TokenStreamIOException(((CharStreamIOException)cse).io); 284 } 285 else { 286 throw new TokenStreamException(cse.getMessage()); 287 } 288 } 289 } 290 } 291 292 public final void mTOK_RPAREN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 293 int _ttype; Token _token=null; int _begin=text.length(); 294 _ttype = TOK_RPAREN; 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 mTOK_LPAREN(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 306 int _ttype; Token _token=null; int _begin=text.length(); 307 _ttype = TOK_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 mTOK_COMMA(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 319 int _ttype; Token _token=null; int _begin=text.length(); 320 _ttype = TOK_COMMA; 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 mTOK_SEMIC(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 332 int _ttype; Token _token=null; int _begin=text.length(); 333 _ttype = TOK_SEMIC; 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 mTOK_COLON(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 345 int _ttype; Token _token=null; int _begin=text.length(); 346 _ttype = TOK_COLON; 347 int _saveIndex; 348 349 match(':'); 350 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 351 _token = makeToken(_ttype); 352 _token.setText(new String (text.getBuffer(), _begin, text.length()-_begin)); 353 } 354 _returnToken = _token; 355 } 356 357 public final void mTOK_DOT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 358 int _ttype; Token _token=null; int _begin=text.length(); 359 _ttype = TOK_DOT; 360 int _saveIndex; 361 362 match('.'); 363 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 364 _token = makeToken(_ttype); 365 _token.setText(new String (text.getBuffer(), _begin, text.length()-_begin)); 366 } 367 _returnToken = _token; 368 } 369 370 public final void mTOK_INDIRECT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 371 int _ttype; Token _token=null; int _begin=text.length(); 372 _ttype = TOK_INDIRECT; 373 int _saveIndex; 374 375 match('-'); 376 match('>'); 377 _ttype = TOK_DOT; 378 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 379 _token = makeToken(_ttype); 380 _token.setText(new String (text.getBuffer(), _begin, text.length()-_begin)); 381 } 382 _returnToken = _token; 383 } 384 385 public final void mTOK_CONCAT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 386 int _ttype; Token _token=null; int _begin=text.length(); 387 _ttype = TOK_CONCAT; 388 int _saveIndex; 389 390 match('|'); 391 match('|'); 392 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 393 _token = makeToken(_ttype); 394 _token.setText(new String (text.getBuffer(), _begin, text.length()-_begin)); 395 } 396 _returnToken = _token; 397 } 398 399 public final void mTOK_EQ(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 400 int _ttype; Token _token=null; int _begin=text.length(); 401 _ttype = TOK_EQ; 402 int _saveIndex; 403 404 match('='); 405 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 406 _token = makeToken(_ttype); 407 _token.setText(new String (text.getBuffer(), _begin, text.length()-_begin)); 408 } 409 _returnToken = _token; 410 } 411 412 public final void mTOK_PLUS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 413 int _ttype; Token _token=null; int _begin=text.length(); 414 _ttype = TOK_PLUS; 415 int _saveIndex; 416 417 match('+'); 418 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 419 _token = makeToken(_ttype); 420 _token.setText(new String (text.getBuffer(), _begin, text.length()-_begin)); 421 } 422 _returnToken = _token; 423 } 424 425 public final void mTOK_MINUS(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 426 int _ttype; Token _token=null; int _begin=text.length(); 427 _ttype = TOK_MINUS; 428 int _saveIndex; 429 430 match('-'); 431 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 432 _token = makeToken(_ttype); 433 _token.setText(new String (text.getBuffer(), _begin, text.length()-_begin)); 434 } 435 _returnToken = _token; 436 } 437 438 public final void mTOK_SLASH(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 439 int _ttype; Token _token=null; int _begin=text.length(); 440 _ttype = TOK_SLASH; 441 int _saveIndex; 442 443 match('/'); 444 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 445 _token = makeToken(_ttype); 446 _token.setText(new String (text.getBuffer(), _begin, text.length()-_begin)); 447 } 448 _returnToken = _token; 449 } 450 451 public final void mTOK_STAR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 452 int _ttype; Token _token=null; int _begin=text.length(); 453 _ttype = TOK_STAR; 454 int _saveIndex; 455 456 match('*'); 457 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 458 _token = makeToken(_ttype); 459 _token.setText(new String (text.getBuffer(), _begin, text.length()-_begin)); 460 } 461 _returnToken = _token; 462 } 463 464 public final void mTOK_LE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 465 int _ttype; Token _token=null; int _begin=text.length(); 466 _ttype = TOK_LE; 467 int _saveIndex; 468 469 match('<'); 470 match('='); 471 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 472 _token = makeToken(_ttype); 473 _token.setText(new String (text.getBuffer(), _begin, text.length()-_begin)); 474 } 475 _returnToken = _token; 476 } 477 478 public final void mTOK_GE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 479 int _ttype; Token _token=null; int _begin=text.length(); 480 _ttype = TOK_GE; 481 int _saveIndex; 482 483 match('>'); 484 match('='); 485 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 486 _token = makeToken(_ttype); 487 _token.setText(new String (text.getBuffer(), _begin, text.length()-_begin)); 488 } 489 _returnToken = _token; 490 } 491 492 public final void mTOK_NE(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 493 int _ttype; Token _token=null; int _begin=text.length(); 494 _ttype = TOK_NE; 495 int _saveIndex; 496 497 match('<'); 498 match('>'); 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 public final void mTOK_NE2(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 507 int _ttype; Token _token=null; int _begin=text.length(); 508 _ttype = TOK_NE2; 509 int _saveIndex; 510 511 match('!'); 512 match('='); 513 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 514 _token = makeToken(_ttype); 515 _token.setText(new String (text.getBuffer(), _begin, text.length()-_begin)); 516 } 517 _returnToken = _token; 518 } 519 520 public final void mTOK_LT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 521 int _ttype; Token _token=null; int _begin=text.length(); 522 _ttype = TOK_LT; 523 int _saveIndex; 524 525 match('<'); 526 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 527 _token = makeToken(_ttype); 528 _token.setText(new String (text.getBuffer(), _begin, text.length()-_begin)); 529 } 530 _returnToken = _token; 531 } 532 533 public final void mTOK_GT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 534 int _ttype; Token _token=null; int _begin=text.length(); 535 _ttype = TOK_GT; 536 int _saveIndex; 537 538 match('>'); 539 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 540 _token = makeToken(_ttype); 541 _token.setText(new String (text.getBuffer(), _begin, text.length()-_begin)); 542 } 543 _returnToken = _token; 544 } 545 546 public final void mTOK_LBRACK(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 547 int _ttype; Token _token=null; int _begin=text.length(); 548 _ttype = TOK_LBRACK; 549 int _saveIndex; 550 551 match('['); 552 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 553 _token = makeToken(_ttype); 554 _token.setText(new String (text.getBuffer(), _begin, text.length()-_begin)); 555 } 556 _returnToken = _token; 557 } 558 559 public final void mTOK_RBRACK(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 560 int _ttype; Token _token=null; int _begin=text.length(); 561 _ttype = TOK_RBRACK; 562 int _saveIndex; 563 564 match(']'); 565 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 566 _token = makeToken(_ttype); 567 _token.setText(new String (text.getBuffer(), _begin, text.length()-_begin)); 568 } 569 _returnToken = _token; 570 } 571 572 public final void mTOK_DOLLAR(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 573 int _ttype; Token _token=null; int _begin=text.length(); 574 _ttype = TOK_DOLLAR; 575 int _saveIndex; 576 577 match('$'); 578 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 579 _token = makeToken(_ttype); 580 _token.setText(new String (text.getBuffer(), _begin, text.length()-_begin)); 581 } 582 _returnToken = _token; 583 } 584 585 protected final void mNameFirstCharacter(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 586 int _ttype; Token _token=null; int _begin=text.length(); 587 _ttype = NameFirstCharacter; 588 int _saveIndex; 589 590 { 591 switch ( LA(1)) { 592 case 'A': case 'B': case 'C': case 'D': 593 case 'E': case 'F': case 'G': case 'H': 594 case 'I': case 'J': case 'K': case 'L': 595 case 'M': case 'N': case 'O': case 'P': 596 case 'Q': case 'R': case 'S': case 'T': 597 case 'U': case 'V': case 'W': case 'X': 598 case 'Y': case 'Z': 599 { 600 matchRange('A','Z'); 601 break; 602 } 603 case 'a': case 'b': case 'c': case 'd': 604 case 'e': case 'f': case 'g': case 'h': 605 case 'i': case 'j': case 'k': case 'l': 606 case 'm': case 'n': case 'o': case 'p': 607 case 'q': case 'r': case 's': case 't': 608 case 'u': case 'v': case 'w': case 'x': 609 case 'y': case 'z': 610 { 611 matchRange('a','z'); 612 break; 613 } 614 case '_': 615 { 616 match('_'); 617 break; 618 } 619 case '.': 620 { 621 mTOK_DOT(false); 622 break; 623 } 624 case '-': 625 { 626 mTOK_INDIRECT(false); 627 break; 628 } 629 case '$': 630 { 631 mTOK_DOLLAR(false); 632 break; 633 } 634 default: 635 { 636 throw new NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn()); 637 } 638 } 639 } 640 if ( _createToken && _token==null && _ttype!=Token.SKIP ) { 641 _token = makeToken(_ttype); 642 _token.setText(new String (text.getBuffer(), _begin, text.length()-_begin)); 643 } 644 _returnToken = _token; 645 } 646 647 protected final void mNameCharacter(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { 648 int _ttype; Token _token=null; int _begin=text.length(); 649 _ttype = NameCharacter; 650 int _saveIndex; 651 652 { 653 switch ( LA(1)) { 654 case '$': case '-': case '.': case 'A': 655 case 'B': case 'C': |