1 %option noyywrap 2 3 /* itbl-lex.l 4 Copyright (C) 1997-2020 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 "as.h" 25 #include "itbl-lex.h" 26 #include <itbl-parse.h> 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; 86 while ((c = input ()) != EOF) 87 { 88 if (c == '\n') 89 { 90 unput (c); 91 break; 92 } 93 } 94 } 95 "\n" { 96 insntbl_line++; 97 MDBG (("in lex, NL = %d (x%x)\n", NL, NL)); 98 return NL; 99 } 100 " "|"\t" { 101 } 102 . { 103 MDBG (("char = %x, %d\n", yytext[0], yytext[0])); 104 return yytext[0]; 105 } 106 %% 107