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