itbl-lex.l revision 218822
1226048Sobrien/* itbl-lex.l 2226048Sobrien Copyright 1997, 1998, 2001, 2002, 2005, 2006 3330569Sgordon Free Software Foundation, Inc. 468349Sobrien 568349Sobrien This file is part of GAS, the GNU Assembler. 668349Sobrien 768349Sobrien GAS is free software; you can redistribute it and/or modify 868349Sobrien it under the terms of the GNU General Public License as published by 968349Sobrien the Free Software Foundation; either version 2, or (at your option) 1068349Sobrien any later version. 1168349Sobrien 1268349Sobrien GAS is distributed in the hope that it will be useful, 1368349Sobrien but WITHOUT ANY WARRANTY; without even the implied warranty of 1468349Sobrien MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1568349Sobrien GNU General Public License for more details. 1668349Sobrien 1768349Sobrien You should have received a copy of the GNU General Public License 18330569Sgordon along with GAS; see the file COPYING. If not, write to the Free 1968349Sobrien Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 2068349Sobrien 02110-1301, USA. */ 2168349Sobrien 2268349Sobrien%{ 2368349Sobrien#include "as.h" 2468349Sobrien#include "itbl-lex.h" 2568349Sobrien#include <itbl-parse.h> 2668349Sobrien 2768349Sobrien#ifdef DEBUG 2868349Sobrien#define DBG(x) printf x 2968349Sobrien#define MDBG(x) printf x 3068349Sobrien#else 3168349Sobrien#define DBG(x) 3268349Sobrien#define MDBG(x) 3368349Sobrien#endif 3468349Sobrien 3568349Sobrienint insntbl_line = 1; 36139368Sobrien%} 3768349Sobrien 3868349SobrienALNUM [A-Za-z0-9_] 39139368SobrienDIGIT [0-9] 4068349SobrienALPHA [A-Za-z_] 4168349SobrienHEX [0-9A-Fa-f] 4268349Sobrien 4368349Sobrien%% 4468349Sobrien 4568349Sobrien"creg"|"CREG" { 4668349Sobrien return CREG; 4768349Sobrien } 4868349Sobrien"dreg"|"DREG" { 4968349Sobrien return DREG; 5068349Sobrien } 5168349Sobrien"greg"|"GREG" { 5268349Sobrien return GREG; 5368349Sobrien } 5468349Sobrien"immed"|"IMMED" { 5568349Sobrien return IMMED; 56139368Sobrien } 57139368Sobrien"addr"|"ADDR" { 58139368Sobrien return ADDR; 5968349Sobrien } 6068349Sobrien"insn"|"INSN" { 6168349Sobrien return INSN; 62139368Sobrien } 63139368Sobrien"p"{DIGIT} { 64139368Sobrien yytext[yyleng] = 0; 65139368Sobrien yylval.processor = strtoul (yytext+1, 0, 0); 66139368Sobrien return PNUM; 67139368Sobrien } 6868349Sobrien{DIGIT}+ { 6968349Sobrien yytext[yyleng] = 0; 7068349Sobrien yylval.num = strtoul (yytext, 0, 0); 7168349Sobrien return NUM; 72139368Sobrien } 73139368Sobrien"0x"{HEX}+ { 74139368Sobrien yytext[yyleng] = 0; 75139368Sobrien yylval.num = strtoul (yytext, 0, 0); 76139368Sobrien return NUM; 77139368Sobrien } 78139368Sobrien{ALPHA}{ALNUM}* { 79139368Sobrien yytext[yyleng] = 0; 80139368Sobrien 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 107#ifndef yywrap 108int 109yywrap () 110 { 111 return 1; 112 } 113#endif 114