syntax.l 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. %{
  2. /* $Id$ */
  3. #include "Lpars.h"
  4. #include "parser.h"
  5. struct idf *opval; /* opcode of returned OPCODE*/
  6. int lastintval; /* value of last integer seen */
  7. int linenum = 1; /*current line number of input file*/
  8. %}
  9. %%
  10. sfit return(SFIT);
  11. ufit return(UFIT);
  12. rotate return(ROTATE);
  13. p return(PSIZE);
  14. w2 return(DWSIZE);
  15. w return(WSIZE);
  16. defined return(DEFINED);
  17. undefined return(UNDEFINED);
  18. samesign return(SAMESIGN);
  19. sameext return(SAMEEXT);
  20. samenam return(SAMENAM);
  21. offset return(OFFSET);
  22. [a-z][a-z][a-z] {
  23. opval = str2idf(yytext,0);
  24. return(OPCODE);
  25. }
  26. [0-9]+ {
  27. lastintval = atoi(yytext);
  28. return(INT);
  29. }
  30. "$" return(PATARG);
  31. "&&" return(LOGAND);
  32. "||" return(LOGOR);
  33. "&" return(BITAND);
  34. "|" return(BITOR);
  35. "^" return(XOR);
  36. "-" return(MINUS);
  37. "+" return(PLUS);
  38. "*" return(TIMES);
  39. "/" return(DIV);
  40. "%" return(MOD);
  41. "==" return(EQ);
  42. "!=" return(NE);
  43. "<" return(LT);
  44. "<=" return(LE);
  45. ">" return(GT);
  46. ">=" return(GE);
  47. "<<" return(LSHIFT);
  48. ">>" return(RSHIFT);
  49. "!" return(NOT);
  50. "~" return(COMP);
  51. "," return(COMMA);
  52. :[ \t]*\n[ \t]+ { linenum++; return(':'); }
  53. ^"# "[0-9]+.*\n { linenum=atoi(yytext+2); }
  54. ^\#.*\n { linenum++; }
  55. ^\n { linenum++; }
  56. [ \t] ;
  57. \n { linenum++; return(yytext[0]);}
  58. . return(yytext[0]);
  59. %%
  60. back_token()
  61. {
  62. yyless(0);
  63. }