001// lexical analyzer for GSQLParser component java version 002 003/**************************************************** 004 Lexical analizer for GSQLParser Java component 005 Copyright (c) 2004-2015 by Gudu software 006****************************************************/ 007 008package gudusoft.gsqlparser; 009 010import java.util.HashMap; 011import java.io.InputStreamReader; 012 013import java.util.Locale; 014import java.io.BufferedReader; 015import java.io.IOException; 016 017 018public class TLexerAnsi extends TCustomLexer{ 019 020 static int yynmarks = 0 ; 021 static int yynmatches ; 022 static int yyntrans ; 023 static int yynstates ; 024 static int[] yyk,yym ; // 1 based 025 static int[] yytint; // 1 based 026 static TYytRec[] yyt ; // 1 based 027 static int[] yykl,yykh,yyml,yymh,yytl,yyth ; // 0 based 028 private static String[] keywordlist; 029 static String table_file; 030 static HashMap<String, Integer> keywordValueList; 031 static HashMap<Integer, Integer> keywordTypeList; 032 static int[][] yystateTable; 033 034 static { 035 keywordValueList = new HashMap<String, Integer>(); 036 keywordTypeList = new HashMap<Integer, Integer>(); 037 table_file = "/gudusoft/gsqlparser/parser/ansi/ansi_lex_table.txt"; 038 if (TBaseType.enterprise_edition||TBaseType.ansi_edition){ 039 inittable(); 040 } 041 } 042 043 TLexerAnsi(){ 044 super(); 045 dbvendor = EDbVendor.dbvansi; 046 } 047 048public boolean canBeColumnName(int tokencode){ 049 //http://blog.csdn.net/superbeck/article/details/5387476 050 boolean ret = false; 051 int modifiers = keyword_type_identifier | keyword_type_column ; 052 Integer s = keywordTypeList.get(tokencode); 053 if (s != null){ 054 int modifier = s; 055 ret = (modifiers & modifier) == modifier; 056 } 057 058 return ret; 059} 060 061 public int iskeyword(String str){ 062 int ret = -1; 063 Integer s = keywordValueList.get(str.toUpperCase(Locale.ENGLISH)); 064 if( s != null){ 065 ret = s; 066 } 067 return ret;// -1 means not a keyword 068 } 069 070 public int getkeywordvalue(String keyword){ 071 int ret = 0; 072 Integer s = keywordValueList.get(keyword.toUpperCase(Locale.ENGLISH)); 073 if( s != null){ 074 ret = s; 075 } 076 return ret;// 0 means not a keyword 077 } 078 079 public static EKeywordType getKeywordType(String keyword){ 080 return TCustomLexer.getKeywordType(keyword,keywordValueList,keywordTypeList); 081 } 082 083 static void yystateLookupConfigure() { 084 int yystates = yytl.length; 085 yystateTable = new int[257][yystates]; 086 087 // initialize to empty 088 for(int i = 0; i < yystates; i++) { 089 for (int j = 0; j < 257; j++) 090 yystateTable[j][i] = -1; 091 } 092 093 for(int i = 0; i < yystates; i++) { 094 int low = yytl[i]; 095 int high = yyth[i]; 096 for (int j = low; j <= high; j++) { 097 for (char c: yyt[j].cc) { 098 yystateTable[c][i] = j; 099 } 100 } 101 } 102 } 103 104 int yylex(){ 105 int yyn; 106 while (true) { // top level while 107 yynew(); 108 while (true){ //scan 109 for(yyn = yykl[yystate]; yyn <= yykh[yystate]; yyn++){ 110 yymark(yyk[yyn]); 111 } 112 113 for(yyn=yymh[yystate]; yyn>= yyml[yystate]; yyn--){ 114 yymatch(yym[yyn]); 115 } 116 117 if(yytl[yystate] > yyth[yystate]){ 118 break; 119 } 120 121 yyscan(); 122// yyn = yytl[yystate]; 123 totablechar(); 124// while( (yyn <= yyth[yystate]) && (!(charinarray(yytablechar,yyt[yyn].cc))) ){ 125// yyn++; 126// } 127// if (yyn > yyth[yystate]){ 128// break; 129// } 130 131 yyn = yystateTable[yytablechar][yystate]; 132 if (yyn == -1) 133 break; 134 135 yystate = yyt[yyn].s; 136 } //scan 137 138 while (true){ //action 139 int yyrule; 140 if ( (yyrule = yyfind()) != -1 ){ 141 yyaction(yyrule); 142 if (yyreject){ 143 continue; 144 } 145 }else if( (!yydefault() ) && (yywrap()) ){ 146 yyclear(); 147 returni(0); 148 } 149 break; 150 } 151 152 if (!yydone) { 153 continue; 154 } 155 break; 156 } // top level while 157 158 return yyretval; 159 } 160 161 static void inittable(){ 162 163 //if (yynmarks > 0) return; //init table already 164 165 String line; 166 boolean inyyk=false,inyym=false,inyykl=false,inyykh=false,inyyml=false,inyymh=false,inyytl=false,inyyth=false,inyytint=false,inyyt=false,inkeyword=false; 167 int yyk_count=0,yym_count=0,yykl_count=0,yykh_count=0,yyml_count=0,yymh_count=0,yytl_count=0,yyth_count=0,yytint_count=0,yyt_count=0; 168 int c=0; 169 keywordValueList.clear(); 170 keywordTypeList.clear(); 171 172 BufferedReader br = new BufferedReader(new InputStreamReader(TLexerAnsi.class.getResourceAsStream(table_file))); 173 174 try{ 175 while( (line = br.readLine()) != null){ 176 if (line.trim().startsWith("yynmarks=")){ 177 String[] ss = line.split("[=;]"); 178 yynmarks=Integer.parseInt(ss[1].trim()); 179 yyk = new int[yynmarks+1]; 180 }else if (line.trim().startsWith("yynmatches=")){ 181 String[] ss = line.split("[=;]"); 182 yynmatches=Integer.parseInt(ss[1].trim()); 183 yym = new int[yynmatches+1]; 184 }else if (line.trim().startsWith("yyntrans=")){ 185 String[] ss = line.split("[=;]"); 186 yyntrans=Integer.parseInt(ss[1].trim()); 187 yytint = new int[yyntrans+1]; 188 yyt = new TYytRec[yyntrans+1]; 189 }else if (line.trim().startsWith("yynstates=")){ 190 String[] ss = line.split("[=;]"); 191 yynstates=Integer.parseInt(ss[1].trim()); 192 yykl = new int[yynstates]; 193 yykh = new int[yynstates]; 194 yyml = new int[yynstates]; 195 yymh = new int[yynstates]; 196 yytl = new int[yynstates]; 197 yyth = new int[yynstates]; 198 }else if (line.trim().startsWith("<end>")){ 199 if (inyyk){ 200 inyyk = false; 201 if (yynmarks+1 != yyk_count ){ 202 System.out.println("required1:"+(yynmarks)+" actually:"+(yyk_count-1)); 203 } 204 } 205 else if(inyym){ 206 inyym = false; 207 if (yynmatches+1 != yym_count ){ 208 System.out.println("required2:"+(yynmatches)+" actually:"+(yym_count-1)); 209 } 210 } 211 else if(inyykl){ 212 inyykl = false; 213 if (yynstates != yykl_count ){ 214 System.out.println("required3:"+(yynstates)+" actually:"+(yykl_count)); 215 } 216 } 217 else if(inyykh){ 218 inyykh = false; 219 if (yynstates != yykh_count ){ 220 System.out.println("required4:"+(yynstates)+" actually:"+(yykh_count)); 221 } 222 } 223 else if(inyyml){ 224 inyyml = false; 225 if (yynstates != yyml_count ){ 226 System.out.println("required5:"+(yynstates)+" actually:"+(yyml_count)); 227 } 228 } 229 else if(inyymh){ 230 inyymh = false; 231 if (yynstates != yymh_count ){ 232 System.out.println("required:"+(yynstates)+" actually:"+(yymh_count)); 233 } 234 } 235 else if(inyytl){ 236 inyytl = false; 237 if (yynstates != yytl_count ){ 238 System.out.println("required6:"+(yynstates)+" actually:"+(yytl_count)); 239 } 240 } 241 else if(inyyth){ 242 inyyth = false; 243 if (yynstates != yyth_count ){ 244 System.out.println("required7:"+(yynstates)+" actually:"+(yyth_count)); 245 } 246 } 247 else if(inyytint){ 248 inyytint = false; 249 if (yyntrans + 1 != yytint_count ){ 250 System.out.println("required8:"+(yyntrans)+" actually:"+(yytint_count-1)); 251 } 252 } 253 else if(inyyt){ 254 inyyt = false; 255 if (yyntrans+1 != yyt_count ){ 256 System.out.println("required9:"+(yyntrans)+" actually:"+(yyt_count-1)); 257 } 258 } 259 else if(inkeyword){ 260 inkeyword = false; 261 } 262 }else if(line.trim().startsWith("yyk =")){ 263 inyyk = true; 264 }else if(line.trim().startsWith("yym =")){ 265 inyym = true; 266 }else if(line.trim().startsWith("yykl =")){ 267 inyykl = true; 268 }else if(line.trim().startsWith("yykh =")){ 269 inyykh = true; 270 }else if(line.trim().startsWith("yyml =")){ 271 inyyml = true; 272 }else if(line.trim().startsWith("yymh =")){ 273 inyymh = true; 274 }else if(line.trim().startsWith("yytl =")){ 275 inyytl = true; 276 }else if(line.trim().startsWith("yyth =")){ 277 inyyth = true; 278 }else if(line.trim().startsWith("yytint =")){ 279 inyytint = true; 280 }else if(line.trim().startsWith("yyt =")){ 281 inyyt = true; 282 }else if(line.trim().startsWith("keywordsvalue =")){ 283 inkeyword = true; 284 }else if(inyyk){ 285 String[] ss = line.split("[,]"); 286 for(int j=0;j<ss.length;j++){ 287 // System.out.println(ss[j].trim()); 288 yyk[yyk_count++] = Integer.parseInt(ss[j].trim()); 289 } 290 }else if(inyym){ 291 String[] ss = line.split("[,]"); 292 for(int j=0;j<ss.length;j++){ 293 // System.out.println(ss[j].trim()); 294 yym[yym_count++] = Integer.parseInt(ss[j].trim()); 295 } 296 }else if(inyykl){ 297 String[] ss = line.split("[,]"); 298 for(int j=0;j<ss.length;j++){ 299 // System.out.println(ss[j].trim()); 300 yykl[yykl_count++] = Integer.parseInt(ss[j].trim()); 301 } 302 }else if(inyykh){ 303 String[] ss = line.split("[,]"); 304 for(int j=0;j<ss.length;j++){ 305 // System.out.println(ss[j].trim()); 306 yykh[yykh_count++] = Integer.parseInt(ss[j].trim()); 307 } 308 }else if(inyyml){ 309 String[] ss = line.split("[,]"); 310 for(int j=0;j<ss.length;j++){ 311 // System.out.println(ss[j].trim()); 312 yyml[yyml_count++] = Integer.parseInt(ss[j].trim()); 313 } 314 }else if(inyymh){ 315 String[] ss = line.split("[,]"); 316 for(int j=0;j<ss.length;j++){ 317 // System.out.println(ss[j].trim()); 318 yymh[yymh_count++] = Integer.parseInt(ss[j].trim()); 319 } 320 }else if(inyytl){ 321 String[] ss = line.split("[,]"); 322 for(int j=0;j<ss.length;j++){ 323 // System.out.println(ss[j].trim()); 324 yytl[yytl_count++] = Integer.parseInt(ss[j].trim()); 325 } 326 }else if(inyyth){ 327 String[] ss = line.split("[,]"); 328 for(int j=0;j<ss.length;j++){ 329 // System.out.println(ss[j].trim()); 330 yyth[yyth_count++] = Integer.parseInt(ss[j].trim()); 331 } 332 }else if(inyytint){ 333 String[] ss = line.split("[,]"); 334 for(int j=0;j<ss.length;j++){ 335 // System.out.println(ss[j].trim()); 336 yytint[yytint_count++] = Integer.parseInt(ss[j].trim()); 337 } 338 }else if(inyyt){ 339 //System.out.println(line.trim()); 340 341 c = 0; 342 String[] st = line.trim().split(",,"); 343 char[] tmp = new char[st.length]; 344 for(int i=0;i<st.length;i++){ 345 346 if(st[i].startsWith("\'")) { 347 if(st[i].length() == 3){ // 'a' 348 tmp[c++] = st[i].charAt(1); 349 }else if(st[i].length() == 4) { // '\\' 350 tmp[c++] = st[i].charAt(2); 351 }else{ 352 System.out.println(" read yytstr error, error string is "+st[i]+ "line: "+ yyt_count); 353 } 354 }else{ 355 try{ 356 tmp[c++] = (char)Integer.parseInt(st[i]); // char in number like 32 that represent space 357 } catch (NumberFormatException nfe) { 358 System.out.println("NumberFormatException: " + nfe.getMessage()); 359 } 360 } 361 } //while hasmoreTokens 362 363 //yyt[lineno] = new YYTrec(tmp,yytint[lineno]); 364 yyt[yyt_count] = new TYytRec(tmp,yytint[yyt_count]); 365 yyt_count++; 366 367 }else if(inkeyword){ 368 String[] ss =line.split("[=]"); 369 370 int val1 = -1; 371 int val2 = -1; 372 try { 373 val1 = Integer.parseInt(ss[1]); 374 val2 = Integer.parseInt(ss[2]); 375 } 376 catch (NumberFormatException nfe) { 377 System.out.println("NumberFormatException: " + nfe.getMessage()); 378 } 379 keywordValueList.put(ss[0].toUpperCase(),val1); 380 keywordTypeList.put(val1,val2); 381 382 } 383 } 384 }catch(IOException e){ 385 System.out.println(e.toString()); 386 } 387 388 yystateLookupConfigure(); 389 390 } 391 392 393 394 void yyaction(int yyruleno){ 395 396 397 int ic; 398 char[] tmparray = {'=','+','-','*','/','>','<'}; 399 char[] tmparray2 = {':','&','?'}; 400 401 yylvalstr = getyytext(); 402 /* actions: */ 403 switch(yyruleno){ 404 case 1: 405 406 { 407 addlit(yylvalstr,yytextlen); 408 if (xcdepth <= 0) 409 { 410 start(init); 411 yylvalstr = litbufdup(); 412 returni(cmtslashstar); 413 } 414 else 415 xcdepth--; 416 417 break; 418 } 419 420 421 case 2: 422 423 { 424 xcdepth++; 425 yyless(2); 426 addlit(yylvalstr,yytextlen); 427 break; 428 } 429 430 case 3: 431 432 { 433 434 if (getyysstate() == xq) 435 { 436 nchars = yytextlen; 437 addlit(yylvalstr, yytextlen-1); 438 yyless(nchars-1); 439 return;//exit; 440 } 441 442 xcdepth = 0; 443 start(xc); 444 startlit(); 445 yyless(2); 446 addlit(yylvalstr,yytextlen); 447 448 break; 449 } 450 451 case 4: 452 453 { 454 addlit(yylvalstr,yytextlen); 455 break; 456 } 457 458 case 5: 459 460 { 461 addlitchar(yylvalstr.charAt(0)); 462 break; 463 } 464 465 case 6: 466 467 { 468 start(init); 469 addlit(yylvalstr, yytextlen); 470 yylvalstr = litbufdup(); 471 returni(sconst); 472 break; 473 } 474 475 case 7: 476 477 { 478 if (insqlpluscmd){ 479 480 yyless(0); //rollback all tokens 481 yylvalstr = litbufdup(); 482 start(init); 483 returni(sconst); 484 } 485 else 486 { addlit(yylvalstr,yytextlen);} 487 488 break; 489 } 490 491 case 8: 492 493 { 494 if (getyysstate() == xq) 495 { 496 nchars = yytextlen; 497 addlit(yylvalstr, yytextlen-1); 498 yyless(nchars-1); 499 return;//exit; 500 } 501 502 start(xq); 503 startlit(); 504 addlit(yylvalstr,yytextlen); 505 break; 506 } 507 508 case 9: 509 510 { 511 start(xq); 512 startlit(); 513 addlit(yylvalstr, yytextlen); 514 dummych1 = get_char(); 515 if (dummych1 == '\\') // recognize string like '\' 516 { 517 dummych2 = get_char(); 518 if (dummych2 == '\'') 519 { 520 start(init); 521 addlit("\\", 1); 522 addlit("\'", 1); 523 yylvalstr = litbufdup(); 524 returni(sconst); 525 } 526 else 527 { 528 unget_char(dummych2); 529 unget_char(dummych1); 530 } 531 } 532 else 533 { unget_char(dummych1);} 534 535 break; 536 } 537 538 539 case 10: 540 541 { 542 addlit(yylvalstr, yytextlen); 543 break; 544 } 545 546 case 11: 547 548 { // single quote 549 dummych1 = get_char(); 550 unget_char(dummych1); 551 if (dummych1 == (char)0){ 552 returni (error); 553 break; 554 } 555 if (dummych1 == (char)10) 556 { 557 if (insqlpluscmd){ 558 nchars = yytextlen; 559 if(yylvalstr.charAt(nchars-1) == (char)13){ 560 yyless(nchars - 1); 561 yylvalstr = yylvalstr.substring(0,nchars); 562 } 563 start(init); 564 addlit(yylvalstr, nchars-1); 565 yylvalstr = litbufdup(); 566 returni(sconst); //in sqlplus command, characters between ' and return is treated as a string 567 568 }else{ 569 dummych1 = get_char(); 570 addlit(yylvalstr+dummych1, yytextlen+1); 571 } 572 } else if (dummych1 == '\\') 573 { 574 dummych1 = get_char(); 575 dummych2 = get_char(); 576 addlit(yylvalstr+dummych1+dummych2, yytextlen+2); 577 } 578 else 579 { addlit(yylvalstr, yytextlen);} 580 581 break; 582 } 583 584 case 12: 585 586 { 587 addlit(yylvalstr, yytextlen); 588 break; 589 } 590 591 592 593 case 13: 594 595 { 596 start(init); 597 addlit(yylvalstr, yytextlen); 598 if ((literallen == 0) && (!insqlpluscmd)) 599 {returni (error);} 600 if (literallen >= namedatalen) 601 { 602 setlengthofliteralbuf(namedatalen); 603 literallen = namedatalen; 604 } 605 yylvalstr = litbufdup(); 606 returni (ident); 607 608 break; 609 } 610 611 case 14: 612 613 { 614 if (insqlpluscmd){ 615 yyless(0); 616 yylvalstr = litbufdup(); 617 start(init); 618 returni(sconst); 619 }else{ 620 addlit(yylvalstr, yytextlen); 621 } 622 623 break; 624 } 625 626 case 15: 627 628 { 629 addlit(yylvalstr, yytextlen); 630 break; 631 } 632 633 case 16: 634 635 { 636 start(xd); 637 startlit(); 638 addlit(yylvalstr, yytextlen); 639 break; 640 } 641 case 17: 642 643 { // double quote 644 dummych1 = get_char(); 645 unget_char(dummych1); 646 if (dummych1 == (char)0){ 647 returni (error); 648 break; 649 } 650 if (dummych1 == (char)10) 651 { 652 if (insqlpluscmd){ 653 nchars = yytextlen; 654 if(yylvalstr.charAt(nchars-1) == (char)13){ 655 yyless(nchars - 1); 656 yylvalstr = yylvalstr.substring(0,nchars); 657 } 658 start(init); 659 addlit(yylvalstr, nchars-1); 660 yylvalstr = litbufdup(); 661 returni(sconst); //in sqlplus command, characters between ' and return is treated as a string 662 663 }else{ 664 dummych1 = get_char(); 665 addlit(yylvalstr+dummych1, yytextlen+1); 666 667 dummych1 = get_char(); 668 unget_char(dummych1); 669 if (dummych1 == (char)0){ 670 returni (error); 671 break; 672 } 673 674 } 675 676 } else{ 677 678 addlit(yylvalstr, yytextlen); 679 } 680 break; 681 } 682 683 case 18: 684 685 { 686 returni(lexnewline); 687 break; 688 } 689 case 19: 690 691 { 692 returni(lexspace); 693 break; 694 } 695 696 case 20: 697 698 { 699 if ((getyysstate() == xq) 700 || (getyysstate() == xd) 701 || (getyysstate() == xc) 702 ) 703 { 704 addlit(yylvalstr, 1); 705 yyless(1); 706 return;//exit; 707 } 708 709 returni(cmtdoublehyphen); 710 break; 711 } 712 713 case 21: 714 715 { 716 returnc(yylvalstr.charAt(0)); 717 break; 718 } 719 720 case 22: 721 722 { 723 returni(cmpop); 724 break; 725 } 726 727 728 case 23: 729 730 { 731 732 if (getyysstate() == xc) 733 { 734 slashstar = yylvalstr.indexOf("*/"); 735 if (slashstar > 0) 736 { 737 start(init); 738 addlit(yylvalstr,slashstar+2); 739 yylvalstr = litbufdup(); 740 yyless(slashstar+2); 741 returni(cmtslashstar); 742 } 743 else 744 { 745 addlit(yylvalstr,1); 746 yyless(1); 747 } 748 } 749 else if (getyysstate() == xq){ 750 addlit(yylvalstr,1); 751 yyless(1); 752 } 753 else 754 { 755 nchars = yytextlen; 756 slashstar = yylvalstr.indexOf("/*"); 757 dashdash = yylvalstr.indexOf("--"); 758 if ((slashstar > 0) && (dashdash > 0)) 759 { 760 //if both appear, take the first one 761 if (slashstar > dashdash) 762 {slashstar = dashdash;} 763 } 764 else 765 { 766 // if slashstar=0 then slashstar := dashdash; 767 // add (getyysstate <> xc) to avoid something like this */--,here */ should be handled instead of -- 768 if ((slashstar > 0) && (getyysstate() != xc)) { 769 nchars = slashstar; 770 } 771 } 772 773 while ((nchars > 1) 774 && ( (yylvalstr.charAt(nchars-1) == '+' ) 775 || (yylvalstr.charAt(nchars-1) =='-')) 776 && (getyysstate() != xc)) 777 { 778 for (ic = nchars - 1; ic>=1; ic--) 779 { 780 if (isopchar(yylvalstr.charAt(ic-1))) break; 781 } 782 if (ic >= 1) break; 783 nchars--; 784 } 785 786 if (nchars < yytextlen) 787 { 788 //Strip the unwanted chars from the token 789 yyless(nchars); 790 yylvalstr = yylvalstr.substring(0,nchars); 791 } 792 793 ///* 794 // * If what we have left is only one char, and it's 795 // * one of the characters matching "self", then 796 // * return it as a character token the same way 797 // * that the "self" rule would have. 798 // * make sure @ return as self char, by james wang 799 // */ 800 if ((nchars == 1) && (isselfchar(yylvalstr.charAt(0)) || (yylvalstr.charAt(0) == '@'))) 801 { 802 returnc(yylvalstr.charAt(0)); 803 } 804 else if ( 805 (nchars >= 2) 806 &&( 807 charinarray(yylvalstr.charAt(nchars-1-1), tmparray) 808 && ( charinarray(yylvalstr.charAt(nchars-1),tmparray2)) 809 ) 810 ) 811 { 812 yyless(nchars-1); 813 yylvalstr = yylvalstr.substring(0,nchars-1); 814 if (nchars == 2) 815 returnc(yylvalstr.charAt(0)); 816 else 817 returni(op); 818 } 819 else if ( (nchars == 2) && (yylvalstr.charAt(0) == '.') && (yylvalstr.charAt(1) == '*')) 820 { 821 yyless(1); 822 returnc(yylvalstr.charAt(0)); 823 } 824 else if ( (nchars == 2) && (yylvalstr.charAt(0) == '*') && (yylvalstr.charAt(1) == '.')) 825 { 826 yyless(1); 827 returnc(yylvalstr.charAt(0)); 828 } 829 else if ((nchars == 2) && ((yylvalstr.charAt(0) == '=') && ( (yylvalstr.charAt(1) == '?')) )) 830 { 831 yyless(1); 832 returnc(yylvalstr.charAt(0)); 833 } 834 else if ( (nchars >= 2) && (yylvalstr.charAt(0) == '@')) 835 { 836 yyless(1); 837 returnc(yylvalstr.charAt(0)); 838 } 839 else if ( (nchars >= 2) && (yylvalstr.charAt(0) == '?')) 840 { 841 yyless(1); 842 returnc(yylvalstr.charAt(0)); 843 } 844 else if ( (nchars >= 2) && (yylvalstr.charAt(0)== '|') && (yylvalstr.charAt(1) == '|')) 845 { //||--sss ,just get || only 846 yyless(2); 847 yylvalstr = yylvalstr.substring(0,2); 848 returni(op); 849 } 850 else if ( (nchars >= 2) && (yylvalstr.charAt(0)== '!') && (yylvalstr.charAt(1) == '=')) 851 { 852 yyless(2); 853 yylvalstr = yylvalstr.substring(0,2); 854 returni(cmpop); 855 } 856 else if ( (nchars >= 3) && (yylvalstr.charAt(nchars-1) == '$' ) && (yylvalstr.charAt(nchars-2) == '$' )) 857 { // =$$abc 858 if (nchars == 3){ 859 yyless(1); 860 returnc(yylvalstr.charAt(0)); 861 }else{ 862 yyless(nchars-2); 863 yylvalstr = yylvalstr.substring(0,nchars-2); 864 returni(cmpop); 865 } 866 } 867 else if (((nchars > 2) && (yylvalstr.charAt(0) == '*')) 868 && (yylvalstr.charAt(1) == '/') 869 && (getyysstate() == xc) 870 ) 871 { //in comment, and find */ , then it must the end of comment 872 yyless(2); 873 addlit(yylvalstr,yytextlen); 874 if (xcdepth <= 0) 875 { 876 start(init); 877 yylvalstr = litbufdup(); 878 returni(cmtslashstar); 879 } 880 else 881 xcdepth--; 882 } 883 else 884 returni(op); 885 } 886 887 break; 888 } 889 890 891 892 case 24: 893 894 { 895 returni(iconst); 896 break; 897 } 898 899 case 25: 900 901 { 902 ///* for i in 1..5 loop, we can't recognize 1. as a decimal,but 1 as decimal 903 nchars = yytextlen; 904 if (yylvalstr.charAt(nchars-1) == '.') 905 { 906 dummych1 = get_char(); 907 unget_char(dummych1); 908 if (dummych1 == '.') 909 { 910 yyless(nchars-1); 911 yylvalstr = yylvalstr.substring(0,nchars - 1); 912 returni (iconst); 913 return;//exit; 914 } 915 } 916 returni (fconst); 917 break; 918 } 919 case 26: 920 921 { 922 returni (fconst); 923 break; 924 } 925 926 case 27: 927 928 { 929 int rw; 930 if ( (rw = iskeyword(yylvalstr)) != -1) { returni(rw);} 931 else 932 {returni(ident);} 933 break; 934 } 935 936 case 28: 937 938 { 939 returni (outer_join); 940 break; 941 } 942 943 944 case 29: 945 946 { 947 returni (k_clause); 948 break; 949 } 950 951 case 30: 952 953 { 954 returni (m_clause); 955 break; 956 } 957 958 959 case 31: 960 961 { 962 returni (bind_v); 963 break; 964 } 965 966 case 32: 967 968 { 969 returni (db2label); 970 break; 971 } 972 973 case 33: 974 975 { 976 returni (ident); 977 break; 978 } 979 980 case 34: 981 982 { 983 returni (TBaseType.rrw_jdbc_escape_fn); 984 break; 985 } 986 987 case 35: 988 989 { 990 returni (TBaseType.rrw_jdbc_escape_end); 991 break; 992 } 993 994 case 36: 995 996 { 997 returni (error); 998 break; 999 } 1000 1001 default:{ 1002 System.out.println("fatal error in yyaction"); 1003 } 1004 }//switch 1005}/*yyaction*/; 1006 1007 1008 1009 }