syslex.l 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. %option noinput nounput
  2. %{
  3. /* Copyright (C) 2001-2015 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. #ifndef yywrap
  30. static int yywrap (void) { return 1; }
  31. #endif
  32. extern int yylex (void);
  33. %}
  34. %%
  35. "(" { return '(';}
  36. ")" { return ')';}
  37. "[" { return '[';}
  38. "]" { return ']';}
  39. " " { ; }
  40. ";".* { ; }
  41. "\t" { ; }
  42. "\n" { ; }
  43. "\""[^\"]*"\"" {
  44. yylval.s = malloc (yyleng - 1);
  45. memcpy (yylval.s, yytext + 1, yyleng - 2);
  46. yylval.s[yyleng - 2] = '\0';
  47. return NAME;
  48. }
  49. 0x[0-9a-f]+ {
  50. yylval.i = strtol(yytext,0,16);
  51. return NUMBER;
  52. }
  53. [0-9]+ {
  54. yylval.i = atoi(yytext);
  55. return NUMBER;
  56. }
  57. "bits" { yylval.i =1 ;return UNIT;}
  58. "bit" { yylval.i = 1; return UNIT;}
  59. "bytes" { yylval.i= 8; return UNIT;}
  60. "byte" { yylval.i = 8; return UNIT;}
  61. "int" { yylval.s = "INT"; return TYPE;}
  62. "barray" { yylval.s = "BARRAY"; return TYPE;}
  63. "chars" { yylval.s = "CHARS"; return TYPE;}
  64. "variable" { yylval.i = 0; return NUMBER;}
  65. "counted" { yylval.i = -4; return NUMBER;}
  66. "addrsize" { yylval.i = -2; return NUMBER; }
  67. "segsize" { yylval.i = -1; return NUMBER; }
  68. "cond" { return COND;}
  69. "repeat" { return REPEAT;}