1 %option noyywrap
2 
3 /* itbl-lex.l
4    Copyright (C) 1997-2021 Free Software Foundation, Inc.
5 
6    This file is part of GAS, the GNU Assembler.
7 
8    GAS is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3, or (at your option)
11    any later version.
12 
13    GAS is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17 
18    You should have received a copy of the GNU General Public License
19    along with GAS; see the file COPYING.  If not, write to the Free
20    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
21    02110-1301, USA.  */
22 
23 %{
24 #include "itbl-lex.h"
25 #include <itbl-parse.h>
26 
27 #ifdef DEBUG
28 #define DBG(x) printf x
29 #define MDBG(x) printf x
30 #else
31 #define DBG(x)
32 #define MDBG(x)
33 #endif
34 
35 int insntbl_line = 1;
36 %}
37 
38 ALNUM	[A-Za-z0-9_]
39 DIGIT	[0-9]
40 ALPHA	[A-Za-z_]
41 HEX	[0-9A-Fa-f]
42 
43 %%
44 
45 "creg"|"CREG" {
46     return CREG;
47   }
48 "dreg"|"DREG" {
49     return DREG;
50   }
51 "greg"|"GREG" {
52     return GREG;
53   }
54 "immed"|"IMMED" {
55     return IMMED;
56   }
57 "addr"|"ADDR" {
58     return ADDR;
59   }
60 "insn"|"INSN" {
61     return INSN;
62   }
63 "p"{DIGIT} {
64     yytext[yyleng] = 0;
65     yylval.processor = strtoul (yytext+1, 0, 0);
66     return PNUM;
67   }
68 {DIGIT}+ {
69     yytext[yyleng] = 0;
70     yylval.num = strtoul (yytext, 0, 0);
71     return NUM;
72   }
73 "0x"{HEX}+ {
74     yytext[yyleng] = 0;
75     yylval.num = strtoul (yytext, 0, 0);
76     return NUM;
77   }
78 {ALPHA}{ALNUM}*	{
79     yytext[yyleng] = 0;
80     yylval.str = strdup (yytext);
81     return ID;
82   }
83 ";"|"#"	{
84     int c;
85     while ((c = input ()) !=  EOF)
86       {
87         if (c ==  '\n')
88     	{
89     		unput (c);
90     		break;
91     	}
92       }
93   }
94 "\n"	{
95     insntbl_line++;
96     MDBG (("in lex, NL = %d (x%x)\n", NL, NL));
97     return NL;
98   }
99 " "|"\t" {
100   }
101 . {
102     MDBG (("char = %x, %d\n", yytext[0], yytext[0]));
103     return yytext[0];
104   }
105 %%
106