Advertisement
AnindyaBiswas

Exp.l

May 25th, 2023
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1.  
  2.  
  3. %{
  4. //LEX with YACC
  5. #include<stdio.h>
  6. #include<stdlib.h>
  7.  
  8. void yyerror(char*);
  9. #include "y.tab.h"
  10. %}
  11. %%
  12.  
  13.  
  14. [0-9]* { yylval = atoi(yytext);
  15. return NUM;}
  16.  
  17. "(" { return L; }
  18. ")" { return R; }
  19.  
  20. "&" { return LOGICAL_AND; }
  21. "&&" { return BIT_AND; }
  22. "|" { return LOGICAL_OR; }
  23. "||" { return BIT_OR;}
  24. "^" { return LOGICAL_EXOR; }
  25. "^^" { return BIT_EXOR;}
  26. "~" { return LOGICAL_NOT; }
  27. "<<" { return SHIFT_LEFT; }
  28. ">>" { return SHIFT_RIGHT; }
  29. "+" { return REL_EQ; }
  30. ">" { return REL_GT; }
  31. "<" { return REL_LT; }
  32. ">=" { return REL_GE; }
  33. "<=" { return REL_LE; }
  34.  
  35.  
  36. %%
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement