deflex.l 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. %option noinput nounput noyywrap
  2. %{/* deflex.l - Lexer for .def files */
  3. /* Copyright (C) 1995-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 of the License, or
  8. (at your option) 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 this program; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  16. MA 02110-1301, USA. */
  17. /* Contributed by Steve Chamberlain: sac@cygnus.com */
  18. #define DONTDECLARE_MALLOC
  19. #include "libiberty.h"
  20. #include "defparse.h"
  21. #include "dlltool.h"
  22. int linenumber;
  23. %}
  24. %%
  25. "NAME" { return NAME;}
  26. "LIBRARY" { return LIBRARY;}
  27. "DESCRIPTION" { return DESCRIPTION;}
  28. "STACKSIZE" { return STACKSIZE;}
  29. "HEAPSIZE" { return HEAPSIZE;}
  30. "CODE" { return CODE;}
  31. "DATA" { return DATA;}
  32. "SECTIONS" { return SECTIONS;}
  33. "EXPORTS" { return EXPORTS;}
  34. "IMPORTS" { return IMPORTS;}
  35. "VERSION" { return VERSIONK;}
  36. "BASE" { return BASE;}
  37. "CONSTANT" { return CONSTANT; }
  38. "NONAME" { return NONAME; }
  39. "PRIVATE" { return PRIVATE; }
  40. "READ" { return READ;}
  41. "WRITE" { return WRITE;}
  42. "EXECUTE" { return EXECUTE;}
  43. "SHARED" { return SHARED;}
  44. "NONSHARED" { return NONSHARED;}
  45. "SINGLE" { return SINGLE;}
  46. "MULTIPLE" { return MULTIPLE;}
  47. "INITINSTANCE" { return INITINSTANCE;}
  48. "INITGLOBAL" { return INITGLOBAL;}
  49. "TERMINSTANCE" { return TERMINSTANCE;}
  50. "TERMGLOBAL" { return TERMGLOBAL;}
  51. [0-9][x0-9A-Fa-f]* { yylval.number = strtol (yytext,0,0);
  52. return NUMBER; }
  53. (@)?[A-Za-z$:\-\_?][A-Za-z0-9/$:\<\>\-\_@?+]* {
  54. yylval.id = xstrdup (yytext);
  55. return ID;
  56. }
  57. "\""[^\"]*"\"" {
  58. yylval.id = xmemdup (yytext + 1, yyleng - 2, yyleng - 1);
  59. return ID;
  60. }
  61. "\'"[^\']*"\'" {
  62. yylval.id = xmemdup (yytext + 1, yyleng - 2, yyleng - 1);
  63. return ID;
  64. }
  65. "*".* { }
  66. ";".* { }
  67. " " { }
  68. "\t" { }
  69. "\r" { }
  70. "\n" { linenumber ++ ;}
  71. "==" { return EQUAL;}
  72. "=" { return '=';}
  73. "." { return '.';}
  74. "@" { return '@';}
  75. "," { return ',';}
  76. %%