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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [binutils-2.18.50/] [binutils/] [defparse.y] - Diff between revs 156 and 816

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 156 Rev 816
%{ /* defparse.y - parser for .def files */
%{ /* defparse.y - parser for .def files */
/* Copyright 1995, 1997, 1998, 1999, 2001, 2004, 2007
/* Copyright 1995, 1997, 1998, 1999, 2001, 2004, 2007
   Free Software Foundation, Inc.
   Free Software Foundation, Inc.
   This file is part of GNU Binutils.
   This file is part of GNU Binutils.
   This program is free software; you can redistribute it and/or modify
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.
   (at your option) any later version.
   This program is distributed in the hope that it will be useful,
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   GNU General Public License 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 this program; if not, write to the Free Software
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
   MA 02110-1301, USA.  */
   MA 02110-1301, USA.  */
#include "sysdep.h"
#include "sysdep.h"
#include "bfd.h"
#include "bfd.h"
#include "libiberty.h"
#include "libiberty.h"
#include "dlltool.h"
#include "dlltool.h"
%}
%}
%union {
%union {
  char *id;
  char *id;
  int number;
  int number;
};
};
%token NAME LIBRARY DESCRIPTION STACKSIZE HEAPSIZE CODE DATA
%token NAME LIBRARY DESCRIPTION STACKSIZE HEAPSIZE CODE DATA
%token SECTIONS EXPORTS IMPORTS VERSIONK BASE CONSTANT
%token SECTIONS EXPORTS IMPORTS VERSIONK BASE CONSTANT
%token READ WRITE EXECUTE SHARED NONSHARED NONAME PRIVATE
%token READ WRITE EXECUTE SHARED NONSHARED NONAME PRIVATE
%token SINGLE MULTIPLE INITINSTANCE INITGLOBAL TERMINSTANCE TERMGLOBAL
%token SINGLE MULTIPLE INITINSTANCE INITGLOBAL TERMINSTANCE TERMGLOBAL
%token  ID
%token  ID
%token  NUMBER
%token  NUMBER
%type   opt_base opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE
%type   opt_base opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE
%type   attr attr_list opt_number
%type   attr attr_list opt_number
%type   opt_name opt_equal_name
%type   opt_name opt_equal_name
%%
%%
start: start command
start: start command
        | command
        | command
        ;
        ;
command:
command:
                NAME opt_name opt_base { def_name ($2, $3); }
                NAME opt_name opt_base { def_name ($2, $3); }
        |       LIBRARY opt_name opt_base option_list { def_library ($2, $3); }
        |       LIBRARY opt_name opt_base option_list { def_library ($2, $3); }
        |       EXPORTS explist
        |       EXPORTS explist
        |       DESCRIPTION ID { def_description ($2);}
        |       DESCRIPTION ID { def_description ($2);}
        |       STACKSIZE NUMBER opt_number { def_stacksize ($2, $3);}
        |       STACKSIZE NUMBER opt_number { def_stacksize ($2, $3);}
        |       HEAPSIZE NUMBER opt_number { def_heapsize ($2, $3);}
        |       HEAPSIZE NUMBER opt_number { def_heapsize ($2, $3);}
        |       CODE attr_list { def_code ($2);}
        |       CODE attr_list { def_code ($2);}
        |       DATA attr_list  { def_data ($2);}
        |       DATA attr_list  { def_data ($2);}
        |       SECTIONS seclist
        |       SECTIONS seclist
        |       IMPORTS implist
        |       IMPORTS implist
        |       VERSIONK NUMBER { def_version ($2,0);}
        |       VERSIONK NUMBER { def_version ($2,0);}
        |       VERSIONK NUMBER '.' NUMBER { def_version ($2,$4);}
        |       VERSIONK NUMBER '.' NUMBER { def_version ($2,$4);}
        ;
        ;
explist:
explist:
                /* EMPTY */
                /* EMPTY */
        |       explist expline
        |       explist expline
        ;
        ;
expline:
expline:
                ID opt_equal_name opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE
                ID opt_equal_name opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE
                        { def_exports ($1, $2, $3, $4, $5, $6, $7);}
                        { def_exports ($1, $2, $3, $4, $5, $6, $7);}
        ;
        ;
implist:
implist:
                implist impline
                implist impline
        |       impline
        |       impline
        ;
        ;
impline:
impline:
               ID '=' ID '.' ID '.' ID     { def_import ($1,$3,$5,$7, 0); }
               ID '=' ID '.' ID '.' ID     { def_import ($1,$3,$5,$7, 0); }
       |       ID '=' ID '.' ID '.' NUMBER { def_import ($1,$3,$5, 0,$7); }
       |       ID '=' ID '.' ID '.' NUMBER { def_import ($1,$3,$5, 0,$7); }
       |       ID '=' ID '.' ID            { def_import ($1,$3, 0,$5, 0); }
       |       ID '=' ID '.' ID            { def_import ($1,$3, 0,$5, 0); }
       |       ID '=' ID '.' NUMBER        { def_import ($1,$3, 0, 0,$5); }
       |       ID '=' ID '.' NUMBER        { def_import ($1,$3, 0, 0,$5); }
       |       ID '.' ID '.' ID            { def_import ( 0,$1,$3,$5, 0); }
       |       ID '.' ID '.' ID            { def_import ( 0,$1,$3,$5, 0); }
       |       ID '.' ID '.' NUMBER        { def_import ( 0,$1,$3, 0,$5); }
       |       ID '.' ID '.' NUMBER        { def_import ( 0,$1,$3, 0,$5); }
       |       ID '.' ID                   { def_import ( 0,$1, 0,$3, 0); }
       |       ID '.' ID                   { def_import ( 0,$1, 0,$3, 0); }
       |       ID '.' NUMBER               { def_import ( 0,$1, 0, 0,$3); }
       |       ID '.' NUMBER               { def_import ( 0,$1, 0, 0,$3); }
;
;
seclist:
seclist:
                seclist secline
                seclist secline
        |       secline
        |       secline
        ;
        ;
secline:
secline:
        ID attr_list { def_section ($1,$2);}
        ID attr_list { def_section ($1,$2);}
        ;
        ;
attr_list:
attr_list:
        attr_list opt_comma attr
        attr_list opt_comma attr
        | attr
        | attr
        ;
        ;
opt_comma:
opt_comma:
        ','
        ','
        |
        |
        ;
        ;
opt_number: ',' NUMBER { $$=$2;}
opt_number: ',' NUMBER { $$=$2;}
        |          { $$=-1;}
        |          { $$=-1;}
        ;
        ;
attr:
attr:
                READ { $$ = 1; }
                READ { $$ = 1; }
        |       WRITE { $$ = 2; }
        |       WRITE { $$ = 2; }
        |       EXECUTE { $$ = 4; }
        |       EXECUTE { $$ = 4; }
        |       SHARED { $$ = 8; }
        |       SHARED { $$ = 8; }
        |       NONSHARED { $$ = 0; }
        |       NONSHARED { $$ = 0; }
        |       SINGLE { $$ = 0; }
        |       SINGLE { $$ = 0; }
        |       MULTIPLE { $$ = 0; }
        |       MULTIPLE { $$ = 0; }
        ;
        ;
opt_CONSTANT:
opt_CONSTANT:
                CONSTANT {$$=1;}
                CONSTANT {$$=1;}
        |                {$$=0;}
        |                {$$=0;}
        ;
        ;
opt_NONAME:
opt_NONAME:
                NONAME {$$=1;}
                NONAME {$$=1;}
        |                {$$=0;}
        |                {$$=0;}
        ;
        ;
opt_DATA:
opt_DATA:
                DATA { $$ = 1; }
                DATA { $$ = 1; }
        |            { $$ = 0; }
        |            { $$ = 0; }
        ;
        ;
opt_PRIVATE:
opt_PRIVATE:
                PRIVATE { $$ = 1; }
                PRIVATE { $$ = 1; }
        |               { $$ = 0; }
        |               { $$ = 0; }
        ;
        ;
opt_name: ID            { $$ =$1; }
opt_name: ID            { $$ =$1; }
        | ID '.' ID
        | ID '.' ID
          {
          {
            char *name = xmalloc (strlen ($1) + 1 + strlen ($3) + 1);
            char *name = xmalloc (strlen ($1) + 1 + strlen ($3) + 1);
            sprintf (name, "%s.%s", $1, $3);
            sprintf (name, "%s.%s", $1, $3);
            $$ = name;
            $$ = name;
          }
          }
        |               { $$=""; }
        |               { $$=""; }
        ;
        ;
opt_ordinal:
opt_ordinal:
          '@' NUMBER     { $$=$2;}
          '@' NUMBER     { $$=$2;}
        |                { $$=-1;}
        |                { $$=-1;}
        ;
        ;
opt_equal_name:
opt_equal_name:
          '=' ID        { $$ = $2; }
          '=' ID        { $$ = $2; }
        | '=' ID '.' ID
        | '=' ID '.' ID
          {
          {
            char *name = xmalloc (strlen ($2) + 1 + strlen ($4) + 1);
            char *name = xmalloc (strlen ($2) + 1 + strlen ($4) + 1);
            sprintf (name, "%s.%s", $2, $4);
            sprintf (name, "%s.%s", $2, $4);
            $$ = name;
            $$ = name;
          }
          }
        |               { $$ =  0; }
        |               { $$ =  0; }
        ;
        ;
opt_base: BASE  '=' NUMBER      { $$= $3;}
opt_base: BASE  '=' NUMBER      { $$= $3;}
        |       { $$=-1;}
        |       { $$=-1;}
        ;
        ;
option_list:
option_list:
                /* empty */
                /* empty */
        |       option_list opt_comma option
        |       option_list opt_comma option
        ;
        ;
option:
option:
                INITINSTANCE
                INITINSTANCE
        |       INITGLOBAL
        |       INITGLOBAL
        |       TERMINSTANCE
        |       TERMINSTANCE
        |       TERMGLOBAL
        |       TERMGLOBAL
        ;
        ;
 
 

powered by: WebSVN 2.1.0

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