home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / apps / math / lpsolves / lex.l < prev    next >
Text File  |  1992-08-06  |  1KB  |  66 lines

  1. WS   [ \n\t]+
  2. LT   [A-Za-z]
  3. KR   [A-Za-z0-9_]
  4. DI   [0-9]
  5. NM   {DI}*\.?{DI}+([Ee][-+]?{DI}+)?
  6. VR   {LT}{KR}*"'"?
  7. S_OP [-+ \t\n]+        
  8. LOG  [<>]?=?    
  9.  
  10. %start COMMENT
  11.  
  12. %%
  13. <INITIAL>"/*"                {
  14.            BEGIN COMMENT;        } /* begin skip comment */
  15.  
  16. <COMMENT>"*/"                {
  17.            BEGIN INITIAL;        } /* end skip comment */
  18.  
  19. <COMMENT>.                              {
  20.                                         }
  21.  
  22. <COMMENT>\n                             {
  23.                                         }
  24.  
  25. <INITIAL>{WS}                           {
  26.                                         }
  27.  
  28. <INITIAL>","                            {
  29.     return(COMMA);
  30.                                         }
  31.  
  32. <INITIAL>{NM}                {
  33.         sscanf(yytext,"%lf",&f);
  34.         return(CONS);                  
  35.                                         } /* f contains the last float */
  36.  
  37. <INITIAL>{S_OP}                { Sign=0;
  38.                       for(x=0;x<yyleng;x++)
  39.                         if(yytext[x]=='-'||yytext[x]=='+')
  40.                           Sign=(Sign==(yytext[x]=='+'));
  41.                       return (SIGN);
  42.                     /* Sign is TRUE if the sign-string
  43.                        represents a '-'. Otherwise Sign
  44.                        is FALSE */
  45.                     }
  46.  
  47.  
  48. <INITIAL>{VR}                {
  49.           {strcpy(Last_var, yytext);}
  50.           return(VAR);
  51.                                         }
  52.  
  53. <INITIAL>"*"                {
  54.           return(AR_M_OP);        }
  55.  
  56. <INITIAL>{LOG}                {
  57.           return(RE_OP);        }
  58.  
  59. <INITIAL>";"                {
  60.           return(END_C);        }
  61.  
  62. <INITIAL>.                {
  63.           fprintf(stderr,"LEX ERROR : %s lineno %d \n" ,yytext,yylineno);     }
  64.  
  65. %%
  66.