syslex.l 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. %option noinput nounput noyywrap
  2. %{
  3. /* Copyright (C) 2001-2017 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. #ifdef HAVE_STRING_H
  19. #include <string.h>
  20. #else
  21. #ifdef HAVE_STRINGS_H
  22. #include <strings.h>
  23. #endif
  24. #endif
  25. #include "sysinfo.h"
  26. #ifndef YY_NO_UNPUT
  27. #define YY_NO_UNPUT
  28. #endif
  29. extern int yylex (void);
  30. %}
  31. %%
  32. "(" { return '(';}
  33. ")" { return ')';}
  34. "[" { return '[';}
  35. "]" { return ']';}
  36. " " { ; }
  37. ";".* { ; }
  38. "\t" { ; }
  39. "\n" { ; }
  40. "\""[^\"]*"\"" {
  41. yylval.s = malloc (yyleng - 1);
  42. memcpy (yylval.s, yytext + 1, yyleng - 2);
  43. yylval.s[yyleng - 2] = '\0';
  44. return NAME;
  45. }
  46. 0x[0-9a-f]+ {
  47. yylval.i = strtol(yytext,0,16);
  48. return NUMBER;
  49. }
  50. [0-9]+ {
  51. yylval.i = atoi(yytext);
  52. return NUMBER;
  53. }
  54. "bits" { yylval.i =1 ;return UNIT;}
  55. "bit" { yylval.i = 1; return UNIT;}
  56. "bytes" { yylval.i= 8; return UNIT;}
  57. "byte" { yylval.i = 8; return UNIT;}
  58. "int" { yylval.s = "INT"; return TYPE;}
  59. "barray" { yylval.s = "BARRAY"; return TYPE;}
  60. "chars" { yylval.s = "CHARS"; return TYPE;}
  61. "variable" { yylval.i = 0; return NUMBER;}
  62. "counted" { yylval.i = -4; return NUMBER;}
  63. "addrsize" { yylval.i = -2; return NUMBER; }
  64. "segsize" { yylval.i = -1; return NUMBER; }
  65. "cond" { return COND;}
  66. "repeat" { return REPEAT;}