eval.l 376 B

123456789101112131415161718192021
  1. /*
  2. Lexical analyser
  3. for `flex`
  4. */
  5. %{
  6. #include "eval.tab.h" // From bison
  7. %}
  8. %option noinput
  9. %option nounput
  10. %option noyywrap
  11. VOID [ \n\t]
  12. %%
  13. [0-9]+ yylval = atoi(yytext); return number; // Number token
  14. [-*+()=/] return yytext[0]; // Operators
  15. {VOID}+ ; // Skip white characters
  16. . fprintf(stderr, "Input '%c' unknown\n", yytext[0]); // Fallback error