Blame libcpu/i386_lex.l

Packit 032894
%{
Packit 032894
/* Copyright (C) 2004, 2005, 2007, 2008 Red Hat, Inc.
Packit 032894
   Written by Ulrich Drepper <drepper@redhat.com>, 2004.
Packit 032894
Packit 032894
   This file is free software; you can redistribute it and/or modify
Packit 032894
   it under the terms of either
Packit 032894
Packit 032894
     * the GNU Lesser General Public License as published by the Free
Packit 032894
       Software Foundation; either version 3 of the License, or (at
Packit 032894
       your option) any later version
Packit 032894
Packit 032894
   or
Packit 032894
Packit 032894
     * the GNU General Public License as published by the Free
Packit 032894
       Software Foundation; either version 2 of the License, or (at
Packit 032894
       your option) any later version
Packit 032894
Packit 032894
   or both in parallel, as here.
Packit 032894
Packit 032894
   elfutils is distributed in the hope that it will be useful, but
Packit 032894
   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 032894
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 032894
   General Public License for more details.
Packit 032894
Packit 032894
   You should have received copies of the GNU General Public License and
Packit 032894
   the GNU Lesser General Public License along with this program.  If
Packit 032894
   not, see <http://www.gnu.org/licenses/>.  */
Packit 032894
Packit 032894
#ifdef HAVE_CONFIG_H
Packit 032894
# include <config.h>
Packit 032894
#endif
Packit 032894
Packit 032894
#include <ctype.h>
Packit 032894
#include <libintl.h>
Packit 032894
Packit 032894
#include <libeu.h>
Packit 032894
#include "system.h"
Packit 032894
#include "i386_parse.h"
Packit 032894
Packit 032894
Packit 032894
static void eat_to_eol (void);
Packit 032894
static void invalid_char (int ch);
Packit 032894
%}
Packit 032894
Packit 032894
ID              [a-zA-Z_][a-zA-Z0-9_/]*
Packit 032894
ID2             [a-zA-Z0-9_:/]*
Packit 032894
NUMBER		[0-9]+
Packit 032894
WHITE		[[:space:]]+
Packit 032894
Packit 032894
%option yylineno
Packit 032894
%option never-interactive
Packit 032894
%option noyywrap
Packit 032894
Packit 032894
Packit 032894
%x MAIN
Packit 032894
Packit 032894
%%
Packit 032894
Packit 032894
"%mask"				{ return kMASK; }
Packit 032894
Packit 032894
"%prefix"			{ return kPREFIX; }
Packit 032894
"%suffix"			{ return kSUFFIX; }
Packit 032894
Packit 032894
"%synonym"			{ return kSYNONYM; }
Packit 032894
Packit 032894
{NUMBER}			{ i386_lval.num = strtoul (yytext, NULL, 10);
Packit 032894
				  return kNUMBER; }
Packit 032894
Packit 032894
"%%"				{ BEGIN (MAIN); return kPERCPERC; }
Packit 032894
Packit 032894
Packit 032894
<MAIN>"0"			{ return '0'; }
Packit 032894
<MAIN>"1"			{ return '1'; }
Packit 032894
Packit 032894
<INITIAL,MAIN>"{"{ID2}"}"	{ i386_lval.str = xstrndup (yytext + 1,
Packit 032894
							    yyleng - 2);
Packit 032894
				  return kBITFIELD; }
Packit 032894
Packit 032894
<MAIN>"INVALID"			{ i386_lval.str = (void *) -1l;
Packit 032894
				  return kID; }
Packit 032894
Packit 032894
<MAIN>{ID}			{ i386_lval.str = xstrndup (yytext, yyleng);
Packit 032894
				  return kID; }
Packit 032894
Packit 032894
<MAIN>","			{ return ','; }
Packit 032894
Packit 032894
<MAIN>":"			{ return ':'; }
Packit 032894
Packit 032894
<INITIAL,MAIN>^"\n"		{ /* IGNORE */ }
Packit 032894
Packit 032894
<INITIAL,MAIN>"\n"		{ return '\n'; }
Packit 032894
Packit 032894
<INITIAL,MAIN>^"#"		{ eat_to_eol (); }
Packit 032894
Packit 032894
{WHITE}				{ /* IGNORE */ }
Packit 032894
Packit 032894
<MAIN>{WHITE}			{ return kSPACE; }
Packit 032894
Packit 032894
<MAIN>.				{ i386_lval.ch = *yytext; return kCHAR; }
Packit 032894
Packit 032894
.				{ invalid_char (*yytext); }
Packit 032894
Packit 032894
Packit 032894
%%
Packit 032894
Packit 032894
static void
Packit 032894
eat_to_eol (void)
Packit 032894
{
Packit 032894
  while (1)
Packit 032894
    {
Packit 032894
      int c = input ();
Packit 032894
Packit 032894
      if (c == EOF || c == '\n')
Packit 032894
	break;
Packit 032894
    }
Packit 032894
}
Packit 032894
Packit 032894
static void
Packit 032894
invalid_char (int ch)
Packit 032894
{
Packit 032894
  error (0, 0, (isascii (ch)
Packit 032894
		? gettext ("invalid character '%c' at line %d; ignored")
Packit 032894
		: gettext ("invalid character '\\%o' at line %d; ignored")),
Packit 032894
	 ch, yylineno);
Packit 032894
}
Packit 032894
Packit 032894
// Local Variables:
Packit 032894
// mode: C
Packit 032894
// End: