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