home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / compcomp / tpyacc / exprlex.l < prev    next >
Text File  |  1991-05-01  |  497b  |  29 lines

  1.  
  2.   (* Lexical analyzer for the sample Yacc program in Expr.y. *)
  3.  
  4. L                [A-Za-z]
  5. D                [0-9]
  6.  
  7. %%
  8.  
  9.   var result : integer;
  10.  
  11. {D}+(\.{D}+)?([Ee][+-]?{D}+)?    begin
  12.                   val(yytext, yylval.yyReal, result);
  13.                   if result=0 then
  14.                     return(NUM)
  15.                   else
  16.                     return(ILLEGAL)
  17.                 end;
  18.  
  19. {L}                begin
  20.                   yylval.yyInteger := ord(upCase(yytext[1]))-
  21.                                       ord('A')+1;
  22.                   return(ID)
  23.                 end;
  24.  
  25. " "                     ;
  26.  
  27. .                |
  28. \n                returnc(yytext[1]);
  29.