scan.l 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. %{
  2. #ifndef NORCSID
  3. static char rcsid2[] = "$Id$";
  4. #endif
  5. /*
  6. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  7. * See the copyright notice in the ACK home directory, in the file "Copyright".
  8. *
  9. * Author: Hans van Staveren
  10. */
  11. extern long atol();
  12. %}
  13. %%
  14. \"[^"]*\" { strncpy(patid,yytext,sizeof(patid)); return(STRING); }
  15. notreg return(NOTREG);
  16. sfit return(SFIT);
  17. ufit return(UFIT);
  18. rotate return(ROTATE);
  19. p return(PSIZE);
  20. w return(WSIZE);
  21. defined return(DEFINED);
  22. samesign return(SAMESIGN);
  23. rom return(ROM);
  24. [a-zA-Z]{3} {
  25. int m;
  26. m = mlookup(yytext);
  27. if (m==0) {
  28. yyless(1);
  29. return yytext[0];
  30. } else {
  31. yylval.y_int = m;
  32. return(MNEM);
  33. }
  34. }
  35. "&&" return(AND2);
  36. "||" return(OR2);
  37. "&" return(AND1);
  38. "|" return(OR1);
  39. "^" return(XOR1);
  40. "+" return(ARPLUS);
  41. "-" return(ARMINUS);
  42. "*" return(ARTIMES);
  43. "/" return(ARDIVIDE);
  44. "%" return(ARMOD);
  45. "==" return(CMPEQ);
  46. "!=" return(CMPNE);
  47. "<" return(CMPLT);
  48. "<=" return(CMPLE);
  49. ">" return(CMPGT);
  50. ">=" return(CMPGE);
  51. "!" return(NOT);
  52. "~" return(COMP);
  53. "<<" return(LSHIFT);
  54. ">>" return(RSHIFT);
  55. [0-9]+ { long l= atol(yytext);
  56. if (l>32767) yyerror("Number too big");
  57. yylval.y_int= (int) l;
  58. return(NUMBER);
  59. }
  60. [ \t] ;
  61. . return(yytext[0]);
  62. \n { lino++; return(yytext[0]); }
  63. :[ \t]*\n[ \t]+ { lino++; return(':'); }
  64. ^"# "[0-9]+.*\n { lino=atoi(yytext+2); }
  65. ^\#.*\n { lino++; }