From It is me, 9 Months ago, written in C++.
Embed
  1. %s FOUND_COMMENT
  2.  
  3. %%
  4.  
  5. [0-9]+(\.[0-9]+)? { yylval.zmp = atof(yytext); return NUMBER; }
  6. [0-9a-fA-F]+h { yylval.zmp = hex2double(yytext); return NUMBER; }
  7. [+-*/=(),] return *yytext;
  8. [mM][aA][xX] return MAXIMUM;
  9. [lL][oO][gG] return LOGARITM;
  10.  
  11. \/\/.+ /* single line comment - ignore */
  12.  
  13. \/\* { BEGIN(FOUND_COMMENT); }
  14. <FOUND_COMMENT>.|\n /* multiple line comment - ignore */
  15. <FOUND_COMMENT>\*\/ { BEGIN(INITIAL);}
  16.  
  17. [ ]+|\n /* allow empty lines */
  18.  
  19. bye return 0;
  20.  
  21. %%
  22.  
  23. int main()
  24. {
  25.   yyin = fopen("input.txt","r");
  26.   yyout = fopen("result.txt","w");
  27.   yylex();  
  28.   fclose(yyin);
  29.   fclose(yyout);
  30.   return 0;
  31. }
  32.