1%{ 2/* Copyright (C) 2004, 2005, 2007, 2008 Red Hat, Inc. 3 Written by Ulrich Drepper <drepper@redhat.com>, 2004. 4 5 This file is free software; you can redistribute it and/or modify 6 it under the terms of either 7 8 * the GNU Lesser General Public License as published by the Free 9 Software Foundation; either version 3 of the License, or (at 10 your option) any later version 11 12 or 13 14 * the GNU General Public License as published by the Free 15 Software Foundation; either version 2 of the License, or (at 16 your option) any later version 17 18 or both in parallel, as here. 19 20 elfutils is distributed in the hope that it will be useful, but 21 WITHOUT ANY WARRANTY; without even the implied warranty of 22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 General Public License for more details. 24 25 You should have received copies of the GNU General Public License and 26 the GNU Lesser General Public License along with this program. If 27 not, see <http://www.gnu.org/licenses/>. */ 28 29#ifdef HAVE_CONFIG_H 30# include <config.h> 31#endif 32 33#include <ctype.h> 34 35#include <libeu.h> 36#include "system.h" 37#include "i386_parse.h" 38 39 40static void eat_to_eol (void); 41static void invalid_char (int ch); 42%} 43 44ID [a-zA-Z_][a-zA-Z0-9_/]* 45ID2 [a-zA-Z0-9_:/]* 46NUMBER [0-9]+ 47WHITE [[:space:]]+ 48 49%option yylineno 50%option never-interactive 51%option noyywrap 52 53 54%x MAIN 55 56%% 57 58"%mask" { return kMASK; } 59 60"%prefix" { return kPREFIX; } 61"%suffix" { return kSUFFIX; } 62 63"%synonym" { return kSYNONYM; } 64 65{NUMBER} { i386_lval.num = strtoul (yytext, NULL, 10); 66 return kNUMBER; } 67 68"%%" { BEGIN (MAIN); return kPERCPERC; } 69 70 71<MAIN>"0" { return '0'; } 72<MAIN>"1" { return '1'; } 73 74<INITIAL,MAIN>"{"{ID2}"}" { i386_lval.str = xstrndup (yytext + 1, 75 yyleng - 2); 76 return kBITFIELD; } 77 78<MAIN>"INVALID" { i386_lval.str = (void *) -1l; 79 return kID; } 80 81<MAIN>{ID} { i386_lval.str = xstrndup (yytext, yyleng); 82 return kID; } 83 84<MAIN>"," { return ','; } 85 86<MAIN>":" { return ':'; } 87 88<INITIAL,MAIN>^"\n" { /* IGNORE */ } 89 90<INITIAL,MAIN>"\n" { return '\n'; } 91 92<INITIAL,MAIN>^"#" { eat_to_eol (); } 93 94{WHITE} { /* IGNORE */ } 95 96<MAIN>{WHITE} { return kSPACE; } 97 98<MAIN>. { i386_lval.ch = *yytext; return kCHAR; } 99 100. { invalid_char (*yytext); } 101 102 103%% 104 105static void 106eat_to_eol (void) 107{ 108 while (1) 109 { 110 int c = input (); 111 112 if (c == EOF || c == '\n') 113 break; 114 } 115} 116 117static void 118invalid_char (int ch) 119{ 120 error (0, 0, (isascii (ch) 121 ? _("invalid character '%c' at line %d; ignored") 122 : _("invalid character '\\%o' at line %d; ignored")), 123 ch, yylineno); 124} 125 126// Local Variables: 127// mode: C 128// End: 129