Commit | Line | Data |
---|---|---|
2cedb9eb BR |
1 | %option noyywrap |
2 | ||
252b5132 | 3 | /* itbl-lex.l |
2571583a | 4 | Copyright (C) 1997-2017 Free Software Foundation, Inc. |
252b5132 RH |
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 | |
ec2655a6 | 10 | the Free Software Foundation; either version 3, or (at your option) |
252b5132 RH |
11 | any later version. |
12 | ||
3739860c | 13 | GAS is distributed in the hope that it will be useful, |
252b5132 RH |
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 | |
4b4da160 NC |
20 | Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA |
21 | 02110-1301, USA. */ | |
252b5132 RH |
22 | |
23 | %{ | |
ebd1c875 | 24 | #include "as.h" |
f17c130b | 25 | #include "itbl-lex.h" |
3d82a647 | 26 | #include <itbl-parse.h> |
252b5132 RH |
27 | |
28 | #ifdef DEBUG | |
29 | #define DBG(x) printf x | |
30 | #define MDBG(x) printf x | |
31 | #else | |
32 | #define DBG(x) | |
33 | #define MDBG(x) | |
34 | #endif | |
35 | ||
36 | int insntbl_line = 1; | |
37 | %} | |
38 | ||
39 | ALNUM [A-Za-z0-9_] | |
40 | DIGIT [0-9] | |
41 | ALPHA [A-Za-z_] | |
42 | HEX [0-9A-Fa-f] | |
43 | ||
44 | %% | |
45 | ||
46 | "creg"|"CREG" { | |
47 | return CREG; | |
48 | } | |
49 | "dreg"|"DREG" { | |
50 | return DREG; | |
51 | } | |
52 | "greg"|"GREG" { | |
53 | return GREG; | |
54 | } | |
55 | "immed"|"IMMED" { | |
56 | return IMMED; | |
57 | } | |
58 | "addr"|"ADDR" { | |
59 | return ADDR; | |
60 | } | |
61 | "insn"|"INSN" { | |
62 | return INSN; | |
63 | } | |
64 | "p"{DIGIT} { | |
65 | yytext[yyleng] = 0; | |
66 | yylval.processor = strtoul (yytext+1, 0, 0); | |
67 | return PNUM; | |
68 | } | |
69 | {DIGIT}+ { | |
70 | yytext[yyleng] = 0; | |
71 | yylval.num = strtoul (yytext, 0, 0); | |
72 | return NUM; | |
73 | } | |
74 | "0x"{HEX}+ { | |
75 | yytext[yyleng] = 0; | |
76 | yylval.num = strtoul (yytext, 0, 0); | |
77 | return NUM; | |
78 | } | |
79 | {ALPHA}{ALNUM}* { | |
80 | yytext[yyleng] = 0; | |
81 | yylval.str = strdup (yytext); | |
82 | return ID; | |
83 | } | |
84 | ";"|"#" { | |
85 | int c; | |
3739860c | 86 | while ((c = input ()) != EOF) |
252b5132 | 87 | { |
3739860c | 88 | if (c == '\n') |
252b5132 RH |
89 | { |
90 | unput (c); | |
91 | break; | |
92 | } | |
93 | } | |
94 | } | |
3739860c L |
95 | "\n" { |
96 | insntbl_line++; | |
252b5132 | 97 | MDBG (("in lex, NL = %d (x%x)\n", NL, NL)); |
3739860c | 98 | return NL; |
252b5132 | 99 | } |
3739860c | 100 | " "|"\t" { |
252b5132 RH |
101 | } |
102 | . { | |
103 | MDBG (("char = %x, %d\n", yytext[0], yytext[0])); | |
104 | return yytext[0]; | |
105 | } | |
106 | %% |