Advertisement
ferseg

calc.l

Jul 22nd, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. %{
  2. #include <stdio.h>
  3. #define YY_DECL int yylex()
  4. #include "calc.tab.h"
  5. %}
  6. %option noyywrap
  7. %option yylineno
  8. ignora " "|\t|\n
  9. %%
  10. {ignora}* {;}
  11. [0-9]+\.[0-9]+  {yylval.fval = atof(yytext); return T_FLOAT;}
  12. [0-9]+      {yylval.ival = atoi(yytext); return T_INT;}
  13. ";"         {return T_NEWLINEA;}
  14. "+"         {return T_MAS;}
  15. "-"         {return T_MENOS;}
  16. "*"         {return T_POR;}
  17. "/"         {return T_DIVIDE;}
  18. "("         {return T_PARENT_IZQ;}
  19. ")"         {return T_PARENT_DER;}
  20. "exit"      {return T_QUIT;}
  21. "quit"      {return T_QUIT;}
  22. .           {printf("Error\n");}
  23. %%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement