syslex.l 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. %option noinput nounput noyywrap
  2. %{
  3. /* Copyright (C) 2001-2022 Free Software Foundation, Inc.
  4. This file is part of GNU Binutils.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3, or (at your option)
  8. any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GLD; see the file COPYING. If not, write to the Free
  15. Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
  16. 02110-1301, USA. */
  17. /* Note: config.h is #included via syslex_wrap.c. */
  18. #include <string.h>
  19. #include "sysinfo.h"
  20. #ifndef YY_NO_UNPUT
  21. #define YY_NO_UNPUT
  22. #endif
  23. extern int yylex (void);
  24. %}
  25. %%
  26. "(" { return '(';}
  27. ")" { return ')';}
  28. "[" { return '[';}
  29. "]" { return ']';}
  30. " " { ; }
  31. ";".* { ; }
  32. "\t" { ; }
  33. "\n" { ; }
  34. "\""[^\"]*"\"" {
  35. yylval.s = malloc (yyleng - 1);
  36. memcpy (yylval.s, yytext + 1, yyleng - 2);
  37. yylval.s[yyleng - 2] = '\0';
  38. return NAME;
  39. }
  40. 0x[0-9a-f]+ {
  41. yylval.i = strtol(yytext,0,16);
  42. return NUMBER;
  43. }
  44. [0-9]+ {
  45. yylval.i = atoi(yytext);
  46. return NUMBER;
  47. }
  48. "bits" { yylval.i =1 ;return UNIT;}
  49. "bit" { yylval.i = 1; return UNIT;}
  50. "bytes" { yylval.i= 8; return UNIT;}
  51. "byte" { yylval.i = 8; return UNIT;}
  52. "int" { yylval.s = "INT"; return TYPE;}
  53. "barray" { yylval.s = "BARRAY"; return TYPE;}
  54. "chars" { yylval.s = "CHARS"; return TYPE;}
  55. "variable" { yylval.i = 0; return NUMBER;}
  56. "counted" { yylval.i = -4; return NUMBER;}
  57. "addrsize" { yylval.i = -2; return NUMBER; }
  58. "segsize" { yylval.i = -1; return NUMBER; }
  59. "cond" { return COND;}
  60. "repeat" { return REPEAT;}