1 /* itbl-lex.l 2 Copyright (C) 1997-2016 Free Software Foundation, Inc. 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 8 the Free Software Foundation; either version 3, or (at your option) 9 any later version. 10 11 GAS is distributed in the hope that it will be useful, 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 18 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 19 02110-1301, USA. */ 20 21 %{ 22 #include "as.h" 23 #include "itbl-lex.h" 24 #include <itbl-parse.h> 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; 84 while ((c = input ()) != EOF) 85 { 86 if (c == '\n') 87 { 88 unput (c); 89 break; 90 } 91 } 92 } 93 "\n" { 94 insntbl_line++; 95 MDBG (("in lex, NL = %d (x%x)\n", NL, NL)); 96 return NL; 97 } 98 " "|"\t" { 99 } 100 . { 101 MDBG (("char = %x, %d\n", yytext[0], yytext[0])); 102 return yytext[0]; 103 } 104 %% 105 106 #ifndef yywrap 107 int 108 yywrap () 109 { 110 return 1; 111 } 112 #endif 113