deflex.l 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. %option noinput nounput
  2. %{/* deflex.l - Lexer for .def files */
  3. /* Copyright (C) 1995-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 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 = xstrdup (yytext+1);
  59. yylval.id[yyleng-2] = 0;
  60. return ID;
  61. }
  62. "\'"[^\']*"\'" {
  63. yylval.id = xstrdup (yytext+1);
  64. yylval.id[yyleng-2] = 0;
  65. return ID;
  66. }
  67. "*".* { }
  68. ";".* { }
  69. " " { }
  70. "\t" { }
  71. "\r" { }
  72. "\n" { linenumber ++ ;}
  73. "==" { return EQUAL;}
  74. "=" { return '=';}
  75. "." { return '.';}
  76. "@" { return '@';}
  77. "," { return ',';}
  78. %%
  79. #ifndef yywrap
  80. /* Needed for lex, though not flex. */
  81. int yywrap(void) { return 1; }
  82. #endif