OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [gengtype-lex.l] - Diff between revs 816 and 826

Only display areas with differences | Details | Blame | View Log

Rev 816 Rev 826
/* -*- indented-text -*- */
/* -*- indented-text -*- */
/* Process source files and output type information.
/* Process source files and output type information.
   Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009
   Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009
   Free Software Foundation, Inc.
   Free Software Foundation, Inc.
This file is part of GCC.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
Software Foundation; either version 3, or (at your option) any later
version.
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.
for more details.
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
along with GCC; see the file COPYING3.  If not see
.  */
.  */
%option noinput
%option noinput
%{
%{
#include "bconfig.h"
#include "bconfig.h"
#include "system.h"
#include "system.h"
#define malloc xmalloc
#define malloc xmalloc
#define realloc xrealloc
#define realloc xrealloc
#include "gengtype.h"
#include "gengtype.h"
#define YY_DECL int yylex (const char **yylval)
#define YY_DECL int yylex (const char **yylval)
#define yyterminate() return EOF_TOKEN
#define yyterminate() return EOF_TOKEN
struct fileloc lexer_line;
struct fileloc lexer_line;
int lexer_toplevel_done;
int lexer_toplevel_done;
static void
static void
update_lineno (const char *l, size_t len)
update_lineno (const char *l, size_t len)
{
{
  while (len-- > 0)
  while (len-- > 0)
    if (*l++ == '\n')
    if (*l++ == '\n')
      lexer_line.line++;
      lexer_line.line++;
}
}
%}
%}
ID      [[:alpha:]_][[:alnum:]_]*
ID      [[:alpha:]_][[:alnum:]_]*
WS      [[:space:]]+
WS      [[:space:]]+
HWS     [ \t\r\v\f]*
HWS     [ \t\r\v\f]*
IWORD   short|long|(un)?signed|char|int|HOST_WIDE_INT|HOST_WIDEST_INT|bool|size_t|BOOL_BITFIELD|CPPCHAR_SIGNED_T|ino_t|dev_t
IWORD   short|long|(un)?signed|char|int|HOST_WIDE_INT|HOST_WIDEST_INT|bool|size_t|BOOL_BITFIELD|CPPCHAR_SIGNED_T|ino_t|dev_t
ITYPE   {IWORD}({WS}{IWORD})*
ITYPE   {IWORD}({WS}{IWORD})*
EOID    [^[:alnum:]_]
EOID    [^[:alnum:]_]
%x in_struct in_struct_comment in_comment
%x in_struct in_struct_comment in_comment
%option warn noyywrap nounput nodefault perf-report
%option warn noyywrap nounput nodefault perf-report
%option 8bit never-interactive
%option 8bit never-interactive
%%
%%
  /* Do this on entry to yylex():  */
  /* Do this on entry to yylex():  */
  *yylval = 0;
  *yylval = 0;
  if (lexer_toplevel_done)
  if (lexer_toplevel_done)
    {
    {
      BEGIN(INITIAL);
      BEGIN(INITIAL);
      lexer_toplevel_done = 0;
      lexer_toplevel_done = 0;
    }
    }
  /* Things we look for in skipping mode: */
  /* Things we look for in skipping mode: */
{
{
^{HWS}typedef/{EOID} {
^{HWS}typedef/{EOID} {
  BEGIN(in_struct);
  BEGIN(in_struct);
  return TYPEDEF;
  return TYPEDEF;
}
}
^{HWS}struct/{EOID} {
^{HWS}struct/{EOID} {
  BEGIN(in_struct);
  BEGIN(in_struct);
  return STRUCT;
  return STRUCT;
}
}
^{HWS}union/{EOID} {
^{HWS}union/{EOID} {
  BEGIN(in_struct);
  BEGIN(in_struct);
  return UNION;
  return UNION;
}
}
^{HWS}extern/{EOID} {
^{HWS}extern/{EOID} {
  BEGIN(in_struct);
  BEGIN(in_struct);
  return EXTERN;
  return EXTERN;
}
}
^{HWS}static/{EOID} {
^{HWS}static/{EOID} {
  BEGIN(in_struct);
  BEGIN(in_struct);
  return STATIC;
  return STATIC;
}
}
^{HWS}DEF_VEC_[OP]/{EOID} {
^{HWS}DEF_VEC_[OP]/{EOID} {
  BEGIN(in_struct);
  BEGIN(in_struct);
  return DEFVEC_OP;
  return DEFVEC_OP;
}
}
^{HWS}DEF_VEC_I/{EOID} {
^{HWS}DEF_VEC_I/{EOID} {
  BEGIN(in_struct);
  BEGIN(in_struct);
  return DEFVEC_I;
  return DEFVEC_I;
}
}
^{HWS}DEF_VEC_ALLOC_[IOP]/{EOID} {
^{HWS}DEF_VEC_ALLOC_[IOP]/{EOID} {
  BEGIN(in_struct);
  BEGIN(in_struct);
  return DEFVEC_ALLOC;
  return DEFVEC_ALLOC;
}
}
}
}
{
{
"/*"                            { BEGIN(in_struct_comment); }
"/*"                            { BEGIN(in_struct_comment); }
{WS}                            { update_lineno (yytext, yyleng); }
{WS}                            { update_lineno (yytext, yyleng); }
\\\n                            { lexer_line.line++; }
\\\n                            { lexer_line.line++; }
"const"/{EOID}                  /* don't care */
"const"/{EOID}                  /* don't care */
"GTY"/{EOID}                    { return GTY_TOKEN; }
"GTY"/{EOID}                    { return GTY_TOKEN; }
"VEC"/{EOID}                    { return VEC_TOKEN; }
"VEC"/{EOID}                    { return VEC_TOKEN; }
"union"/{EOID}                  { return UNION; }
"union"/{EOID}                  { return UNION; }
"struct"/{EOID}                 { return STRUCT; }
"struct"/{EOID}                 { return STRUCT; }
"enum"/{EOID}                   { return ENUM; }
"enum"/{EOID}                   { return ENUM; }
"ptr_alias"/{EOID}              { return PTR_ALIAS; }
"ptr_alias"/{EOID}              { return PTR_ALIAS; }
"nested_ptr"/{EOID}             { return NESTED_PTR; }
"nested_ptr"/{EOID}             { return NESTED_PTR; }
[0-9]+                          { return NUM; }
[0-9]+                          { return NUM; }
"param"[0-9]*"_is"/{EOID}               {
"param"[0-9]*"_is"/{EOID}               {
  *yylval = XDUPVAR (const char, yytext, yyleng, yyleng+1);
  *yylval = XDUPVAR (const char, yytext, yyleng, yyleng+1);
  return PARAM_IS;
  return PARAM_IS;
}
}
{IWORD}({WS}{IWORD})*/{EOID}            |
{IWORD}({WS}{IWORD})*/{EOID}            |
"ENUM_BITFIELD"{WS}?"("{WS}?{ID}{WS}?")"        {
"ENUM_BITFIELD"{WS}?"("{WS}?{ID}{WS}?")"        {
  size_t len;
  size_t len;
  for (len = yyleng; ISSPACE (yytext[len-1]); len--)
  for (len = yyleng; ISSPACE (yytext[len-1]); len--)
    ;
    ;
  *yylval = XDUPVAR (const char, yytext, len, len+1);
  *yylval = XDUPVAR (const char, yytext, len, len+1);
  update_lineno (yytext, yyleng);
  update_lineno (yytext, yyleng);
  return SCALAR;
  return SCALAR;
}
}
{ID}/{EOID}                     {
{ID}/{EOID}                     {
  *yylval = XDUPVAR (const char, yytext, yyleng, yyleng+1);
  *yylval = XDUPVAR (const char, yytext, yyleng, yyleng+1);
  return ID;
  return ID;
}
}
\"([^"\\]|\\.)*\"               {
\"([^"\\]|\\.)*\"               {
  *yylval = XDUPVAR (const char, yytext+1, yyleng-2, yyleng-1);
  *yylval = XDUPVAR (const char, yytext+1, yyleng-2, yyleng-1);
  return STRING;
  return STRING;
}
}
  /* This "terminal" avoids having to parse integer constant expressions.  */
  /* This "terminal" avoids having to parse integer constant expressions.  */
"["[^\[\]]*"]"                  {
"["[^\[\]]*"]"                  {
  *yylval = XDUPVAR (const char, yytext+1, yyleng-2, yyleng-1);
  *yylval = XDUPVAR (const char, yytext+1, yyleng-2, yyleng-1);
  return ARRAY;
  return ARRAY;
}
}
"'"("\\".|[^\\])"'"             {
"'"("\\".|[^\\])"'"             {
  *yylval = XDUPVAR (const char, yytext+1, yyleng-2, yyleng);
  *yylval = XDUPVAR (const char, yytext+1, yyleng-2, yyleng);
  return CHAR;
  return CHAR;
}
}
"..."                           { return ELLIPSIS; }
"..."                           { return ELLIPSIS; }
[(){},*:<>;=%|-]                { return yytext[0]; }
[(){},*:<>;=%|-]                { return yytext[0]; }
   /* ignore pp-directives */
   /* ignore pp-directives */
^{HWS}"#"{HWS}[a-z_]+[^\n]*\n   {lexer_line.line++;}
^{HWS}"#"{HWS}[a-z_]+[^\n]*\n   {lexer_line.line++;}
.                               {
.                               {
  error_at_line (&lexer_line, "unexpected character `%s'", yytext);
  error_at_line (&lexer_line, "unexpected character `%s'", yytext);
}
}
}
}
"/*"                    { BEGIN(in_comment); }
"/*"                    { BEGIN(in_comment); }
\n                      { lexer_line.line++; }
\n                      { lexer_line.line++; }
{ID}                    |
{ID}                    |
"'"("\\".|[^\\])"'"     |
"'"("\\".|[^\\])"'"     |
[^"/\n]                 /* do nothing */
[^"/\n]                 /* do nothing */
\"([^"\\]|\\.|\\\n)*\"  { update_lineno (yytext, yyleng); }
\"([^"\\]|\\.|\\\n)*\"  { update_lineno (yytext, yyleng); }
"/"/[^*]                /* do nothing */
"/"/[^*]                /* do nothing */
{
{
\n              { lexer_line.line++; }
\n              { lexer_line.line++; }
[^*\n]{16}      |
[^*\n]{16}      |
[^*\n]          /* do nothing */
[^*\n]          /* do nothing */
"*"/[^/]        /* do nothing */
"*"/[^/]        /* do nothing */
}
}
"*/"    { BEGIN(INITIAL); }
"*/"    { BEGIN(INITIAL); }
"*/"    { BEGIN(in_struct); }
"*/"    { BEGIN(in_struct); }
["/]                    |
["/]                    |
"*"     {
"*"     {
  error_at_line (&lexer_line,
  error_at_line (&lexer_line,
                 "unterminated comment or string; unexpected EOF");
                 "unterminated comment or string; unexpected EOF");
}
}
^{HWS}"#"{HWS}"define"{WS}"GTY(" /* do nothing */
^{HWS}"#"{HWS}"define"{WS}"GTY(" /* do nothing */
%%
%%
void
void
yybegin (const char *fname)
yybegin (const char *fname)
{
{
  yyin = fopen (fname, "r");
  yyin = fopen (fname, "r");
  if (yyin == NULL)
  if (yyin == NULL)
    {
    {
      perror (fname);
      perror (fname);
      exit (1);
      exit (1);
    }
    }
  lexer_line.file = fname;
  lexer_line.file = fname;
  lexer_line.line = 1;
  lexer_line.line = 1;
}
}
void
void
yyend (void)
yyend (void)
{
{
  fclose (yyin);
  fclose (yyin);
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.