itbl-lex.l 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. %option noyywrap
  2. /* itbl-lex.l
  3. Copyright (C) 1997-2022 Free Software Foundation, Inc.
  4. This file is part of GAS, the GNU Assembler.
  5. GAS 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. GAS 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 GAS; 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. %{
  18. #include "itbl-lex.h"
  19. #include <itbl-parse.h>
  20. #ifdef DEBUG
  21. #define DBG(x) printf x
  22. #define MDBG(x) printf x
  23. #else
  24. #define DBG(x)
  25. #define MDBG(x)
  26. #endif
  27. int insntbl_line = 1;
  28. %}
  29. ALNUM [A-Za-z0-9_]
  30. DIGIT [0-9]
  31. ALPHA [A-Za-z_]
  32. HEX [0-9A-Fa-f]
  33. %%
  34. "creg"|"CREG" {
  35. return CREG;
  36. }
  37. "dreg"|"DREG" {
  38. return DREG;
  39. }
  40. "greg"|"GREG" {
  41. return GREG;
  42. }
  43. "immed"|"IMMED" {
  44. return IMMED;
  45. }
  46. "addr"|"ADDR" {
  47. return ADDR;
  48. }
  49. "insn"|"INSN" {
  50. return INSN;
  51. }
  52. "p"{DIGIT} {
  53. yytext[yyleng] = 0;
  54. yylval.processor = strtoul (yytext+1, 0, 0);
  55. return PNUM;
  56. }
  57. {DIGIT}+ {
  58. yytext[yyleng] = 0;
  59. yylval.num = strtoul (yytext, 0, 0);
  60. return NUM;
  61. }
  62. "0x"{HEX}+ {
  63. yytext[yyleng] = 0;
  64. yylval.num = strtoul (yytext, 0, 0);
  65. return NUM;
  66. }
  67. {ALPHA}{ALNUM}* {
  68. yytext[yyleng] = 0;
  69. yylval.str = strdup (yytext);
  70. return ID;
  71. }
  72. ";"|"#" {
  73. int c;
  74. while ((c = input ()) != EOF)
  75. {
  76. if (c == '\n')
  77. {
  78. unput (c);
  79. break;
  80. }
  81. }
  82. }
  83. "\n" {
  84. insntbl_line++;
  85. MDBG (("in lex, NL = %d (x%x)\n", NL, NL));
  86. return NL;
  87. }
  88. " "|"\t" {
  89. }
  90. . {
  91. MDBG (("char = %x, %d\n", yytext[0], yytext[0]));
  92. return yytext[0];
  93. }
  94. %%