Advertisement
cd62131

z.lex calculator lexer

Dec 6th, 2018
472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. %{
  2. #include "y.tab.h"
  3. %}
  4. %option noyywrap noinput nounput batch
  5. %%
  6. [ \t\n]
  7. print return PRT;
  8. dimension return DIM;
  9. [][+=*/%();-] return yytext[0];
  10. "//" return QUO;
  11. A { yylval.ival = 0; return ID; }
  12. B { yylval.ival = 1; return ID; }
  13. C { yylval.ival = 2; return ID; }
  14. D { yylval.ival = 3; return ID; }
  15. WW { yylval.ival = 0; return ID2; }
  16. XX { yylval.ival = 1; return ID2; }
  17. YY { yylval.ival = 2; return ID2; }
  18. ZZ { yylval.ival = 3; return ID2; }
  19. [0-9]+ { yylval.dval = atof(yytext); return NUM; }
  20. %%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement