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