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