Home | History | Annotate | Line # | Download | only in ld
deffilep.c revision 1.3
      1  1.3  christos /* A Bison parser, made by GNU Bison 3.0.  */
      2  1.1  christos 
      3  1.3  christos /* Bison implementation for Yacc-like parsers in C
      4  1.1  christos 
      5  1.3  christos    Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
      6  1.1  christos 
      7  1.3  christos    This program is free software: you can redistribute it and/or modify
      8  1.1  christos    it under the terms of the GNU General Public License as published by
      9  1.3  christos    the Free Software Foundation, either version 3 of the License, or
     10  1.3  christos    (at your option) any later version.
     11  1.1  christos 
     12  1.1  christos    This program is distributed in the hope that it will be useful,
     13  1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15  1.1  christos    GNU General Public License for more details.
     16  1.1  christos 
     17  1.1  christos    You should have received a copy of the GNU General Public License
     18  1.3  christos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     19  1.1  christos 
     20  1.1  christos /* As a special exception, you may create a larger work that contains
     21  1.1  christos    part or all of the Bison parser skeleton and distribute that work
     22  1.1  christos    under terms of your choice, so long as that work isn't itself a
     23  1.1  christos    parser generator using the skeleton or a modified version thereof
     24  1.1  christos    as a parser skeleton.  Alternatively, if you modify or redistribute
     25  1.1  christos    the parser skeleton itself, you may (at your option) remove this
     26  1.1  christos    special exception, which will cause the skeleton and the resulting
     27  1.1  christos    Bison output files to be licensed under the GNU General Public
     28  1.1  christos    License without this special exception.
     29  1.1  christos 
     30  1.1  christos    This special exception was added by the Free Software Foundation in
     31  1.1  christos    version 2.2 of Bison.  */
     32  1.1  christos 
     33  1.1  christos /* C LALR(1) parser skeleton written by Richard Stallman, by
     34  1.1  christos    simplifying the original so-called "semantic" parser.  */
     35  1.1  christos 
     36  1.1  christos /* All symbols defined below should begin with yy or YY, to avoid
     37  1.1  christos    infringing on user name space.  This should be done even for local
     38  1.1  christos    variables, as they might otherwise be expanded by user macros.
     39  1.1  christos    There are some unavoidable exceptions within include files to
     40  1.1  christos    define necessary library symbols; they are noted "INFRINGES ON
     41  1.1  christos    USER NAME SPACE" below.  */
     42  1.1  christos 
     43  1.1  christos /* Identify Bison output.  */
     44  1.1  christos #define YYBISON 1
     45  1.1  christos 
     46  1.1  christos /* Bison version.  */
     47  1.3  christos #define YYBISON_VERSION "3.0"
     48  1.1  christos 
     49  1.1  christos /* Skeleton name.  */
     50  1.1  christos #define YYSKELETON_NAME "yacc.c"
     51  1.1  christos 
     52  1.1  christos /* Pure parsers.  */
     53  1.1  christos #define YYPURE 0
     54  1.1  christos 
     55  1.3  christos /* Push parsers.  */
     56  1.3  christos #define YYPUSH 0
     57  1.1  christos 
     58  1.3  christos /* Pull parsers.  */
     59  1.3  christos #define YYPULL 1
     60  1.1  christos 
     61  1.1  christos 
     62  1.1  christos 
     63  1.1  christos 
     64  1.1  christos /* Copy the first part of user declarations.  */
     65  1.3  christos #line 1 "deffilep.y" /* yacc.c:339  */
     66  1.1  christos  /* deffilep.y - parser for .def files */
     67  1.1  christos 
     68  1.3  christos /*   Copyright (C) 1995-2015 Free Software Foundation, Inc.
     69  1.1  christos 
     70  1.1  christos      This file is part of GNU Binutils.
     71  1.1  christos 
     72  1.1  christos      This program is free software; you can redistribute it and/or modify
     73  1.1  christos      it under the terms of the GNU General Public License as published by
     74  1.1  christos      the Free Software Foundation; either version 3 of the License, or
     75  1.1  christos      (at your option) any later version.
     76  1.1  christos 
     77  1.1  christos      This program is distributed in the hope that it will be useful,
     78  1.1  christos      but WITHOUT ANY WARRANTY; without even the implied warranty of
     79  1.1  christos      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     80  1.1  christos      GNU General Public License for more details.
     81  1.1  christos 
     82  1.1  christos      You should have received a copy of the GNU General Public License
     83  1.1  christos      along with this program; if not, write to the Free Software
     84  1.1  christos      Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
     85  1.1  christos      MA 02110-1301, USA.  */
     86  1.1  christos 
     87  1.1  christos #include "sysdep.h"
     88  1.1  christos #include "libiberty.h"
     89  1.1  christos #include "safe-ctype.h"
     90  1.1  christos #include "bfd.h"
     91  1.1  christos #include "ld.h"
     92  1.1  christos #include "ldmisc.h"
     93  1.1  christos #include "deffile.h"
     94  1.1  christos 
     95  1.1  christos #define TRACE 0
     96  1.1  christos 
     97  1.1  christos #define ROUND_UP(a, b) (((a)+((b)-1))&~((b)-1))
     98  1.1  christos 
     99  1.1  christos /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
    100  1.1  christos    as well as gratuitiously global symbol names, so we can have multiple
    101  1.1  christos    yacc generated parsers in ld.  Note that these are only the variables
    102  1.1  christos    produced by yacc.  If other parser generators (bison, byacc, etc) produce
    103  1.1  christos    additional global names that conflict at link time, then those parser
    104  1.1  christos    generators need to be fixed instead of adding those names to this list.  */
    105  1.1  christos 
    106  1.1  christos #define	yymaxdepth def_maxdepth
    107  1.1  christos #define	yyparse	def_parse
    108  1.1  christos #define	yylex	def_lex
    109  1.1  christos #define	yyerror	def_error
    110  1.1  christos #define	yylval	def_lval
    111  1.1  christos #define	yychar	def_char
    112  1.1  christos #define	yydebug	def_debug
    113  1.3  christos #define	yypact	def_pact
    114  1.3  christos #define	yyr1	def_r1
    115  1.3  christos #define	yyr2	def_r2
    116  1.3  christos #define	yydef	def_def
    117  1.3  christos #define	yychk	def_chk
    118  1.3  christos #define	yypgo	def_pgo
    119  1.3  christos #define	yyact	def_act
    120  1.1  christos #define	yyexca	def_exca
    121  1.1  christos #define yyerrflag def_errflag
    122  1.1  christos #define yynerrs	def_nerrs
    123  1.1  christos #define	yyps	def_ps
    124  1.1  christos #define	yypv	def_pv
    125  1.1  christos #define	yys	def_s
    126  1.1  christos #define	yy_yys	def_yys
    127  1.1  christos #define	yystate	def_state
    128  1.1  christos #define	yytmp	def_tmp
    129  1.1  christos #define	yyv	def_v
    130  1.1  christos #define	yy_yyv	def_yyv
    131  1.1  christos #define	yyval	def_val
    132  1.1  christos #define	yylloc	def_lloc
    133  1.1  christos #define yyreds	def_reds		/* With YYDEBUG defined.  */
    134  1.1  christos #define yytoks	def_toks		/* With YYDEBUG defined.  */
    135  1.1  christos #define yylhs	def_yylhs
    136  1.1  christos #define yylen	def_yylen
    137  1.1  christos #define yydefred def_yydefred
    138  1.1  christos #define yydgoto	def_yydgoto
    139  1.1  christos #define yysindex def_yysindex
    140  1.1  christos #define yyrindex def_yyrindex
    141  1.1  christos #define yygindex def_yygindex
    142  1.1  christos #define yytable	 def_yytable
    143  1.1  christos #define yycheck	 def_yycheck
    144  1.1  christos 
    145  1.1  christos typedef struct def_pool_str {
    146  1.1  christos   struct def_pool_str *next;
    147  1.1  christos   char data[1];
    148  1.1  christos } def_pool_str;
    149  1.1  christos 
    150  1.1  christos static def_pool_str *pool_strs = NULL;
    151  1.1  christos 
    152  1.1  christos static char *def_pool_alloc (size_t sz);
    153  1.1  christos static char *def_pool_strdup (const char *str);
    154  1.1  christos static void def_pool_free (void);
    155  1.1  christos 
    156  1.1  christos static void def_description (const char *);
    157  1.1  christos static void def_exports (const char *, const char *, int, int, const char *);
    158  1.1  christos static void def_heapsize (int, int);
    159  1.1  christos static void def_import (const char *, const char *, const char *, const char *,
    160  1.1  christos 			int, const char *);
    161  1.3  christos static void def_image_name (const char *, bfd_vma, int);
    162  1.1  christos static void def_section (const char *, int);
    163  1.1  christos static void def_section_alt (const char *, const char *);
    164  1.1  christos static void def_stacksize (int, int);
    165  1.1  christos static void def_version (int, int);
    166  1.1  christos static void def_directive (char *);
    167  1.1  christos static void def_aligncomm (char *str, int align);
    168  1.1  christos static int def_parse (void);
    169  1.1  christos static int def_error (const char *);
    170  1.1  christos static int def_lex (void);
    171  1.1  christos 
    172  1.1  christos static int lex_forced_token = 0;
    173  1.1  christos static const char *lex_parse_string = 0;
    174  1.1  christos static const char *lex_parse_string_end = 0;
    175  1.1  christos 
    176  1.1  christos 
    177  1.3  christos #line 178 "deffilep.c" /* yacc.c:339  */
    178  1.1  christos 
    179  1.3  christos # ifndef YY_NULL
    180  1.3  christos #  if defined __cplusplus && 201103L <= __cplusplus
    181  1.3  christos #   define YY_NULL nullptr
    182  1.3  christos #  else
    183  1.3  christos #   define YY_NULL 0
    184  1.3  christos #  endif
    185  1.3  christos # endif
    186  1.1  christos 
    187  1.1  christos /* Enabling verbose error messages.  */
    188  1.1  christos #ifdef YYERROR_VERBOSE
    189  1.1  christos # undef YYERROR_VERBOSE
    190  1.1  christos # define YYERROR_VERBOSE 1
    191  1.1  christos #else
    192  1.1  christos # define YYERROR_VERBOSE 0
    193  1.1  christos #endif
    194  1.1  christos 
    195  1.3  christos /* In a future release of Bison, this section will be replaced
    196  1.3  christos    by #include "y.tab.h".  */
    197  1.3  christos #ifndef YY_YY_DEFFILEP_H_INCLUDED
    198  1.3  christos # define YY_YY_DEFFILEP_H_INCLUDED
    199  1.3  christos /* Debug traces.  */
    200  1.3  christos #ifndef YYDEBUG
    201  1.3  christos # define YYDEBUG 0
    202  1.3  christos #endif
    203  1.3  christos #if YYDEBUG
    204  1.3  christos extern int yydebug;
    205  1.1  christos #endif
    206  1.1  christos 
    207  1.3  christos /* Token type.  */
    208  1.3  christos #ifndef YYTOKENTYPE
    209  1.3  christos # define YYTOKENTYPE
    210  1.3  christos   enum yytokentype
    211  1.3  christos   {
    212  1.3  christos     NAME = 258,
    213  1.3  christos     LIBRARY = 259,
    214  1.3  christos     DESCRIPTION = 260,
    215  1.3  christos     STACKSIZE_K = 261,
    216  1.3  christos     HEAPSIZE = 262,
    217  1.3  christos     CODE = 263,
    218  1.3  christos     DATAU = 264,
    219  1.3  christos     DATAL = 265,
    220  1.3  christos     SECTIONS = 266,
    221  1.3  christos     EXPORTS = 267,
    222  1.3  christos     IMPORTS = 268,
    223  1.3  christos     VERSIONK = 269,
    224  1.3  christos     BASE = 270,
    225  1.3  christos     CONSTANTU = 271,
    226  1.3  christos     CONSTANTL = 272,
    227  1.3  christos     PRIVATEU = 273,
    228  1.3  christos     PRIVATEL = 274,
    229  1.3  christos     ALIGNCOMM = 275,
    230  1.3  christos     READ = 276,
    231  1.3  christos     WRITE = 277,
    232  1.3  christos     EXECUTE = 278,
    233  1.3  christos     SHARED = 279,
    234  1.3  christos     NONAMEU = 280,
    235  1.3  christos     NONAMEL = 281,
    236  1.3  christos     DIRECTIVE = 282,
    237  1.3  christos     EQUAL = 283,
    238  1.3  christos     ID = 284,
    239  1.3  christos     DIGITS = 285
    240  1.3  christos   };
    241  1.3  christos #endif
    242  1.3  christos /* Tokens.  */
    243  1.3  christos #define NAME 258
    244  1.3  christos #define LIBRARY 259
    245  1.3  christos #define DESCRIPTION 260
    246  1.3  christos #define STACKSIZE_K 261
    247  1.3  christos #define HEAPSIZE 262
    248  1.3  christos #define CODE 263
    249  1.3  christos #define DATAU 264
    250  1.3  christos #define DATAL 265
    251  1.3  christos #define SECTIONS 266
    252  1.3  christos #define EXPORTS 267
    253  1.3  christos #define IMPORTS 268
    254  1.3  christos #define VERSIONK 269
    255  1.3  christos #define BASE 270
    256  1.3  christos #define CONSTANTU 271
    257  1.3  christos #define CONSTANTL 272
    258  1.3  christos #define PRIVATEU 273
    259  1.3  christos #define PRIVATEL 274
    260  1.3  christos #define ALIGNCOMM 275
    261  1.3  christos #define READ 276
    262  1.3  christos #define WRITE 277
    263  1.3  christos #define EXECUTE 278
    264  1.3  christos #define SHARED 279
    265  1.3  christos #define NONAMEU 280
    266  1.3  christos #define NONAMEL 281
    267  1.3  christos #define DIRECTIVE 282
    268  1.3  christos #define EQUAL 283
    269  1.3  christos #define ID 284
    270  1.3  christos #define DIGITS 285
    271  1.3  christos 
    272  1.3  christos /* Value type.  */
    273  1.1  christos #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
    274  1.3  christos typedef union YYSTYPE YYSTYPE;
    275  1.3  christos union YYSTYPE
    276  1.1  christos {
    277  1.3  christos #line 113 "deffilep.y" /* yacc.c:355  */
    278  1.3  christos 
    279  1.1  christos   char *id;
    280  1.1  christos   const char *id_const;
    281  1.1  christos   int number;
    282  1.3  christos   bfd_vma vma;
    283  1.1  christos   char *digits;
    284  1.3  christos 
    285  1.3  christos #line 286 "deffilep.c" /* yacc.c:355  */
    286  1.3  christos };
    287  1.3  christos # define YYSTYPE_IS_TRIVIAL 1
    288  1.1  christos # define YYSTYPE_IS_DECLARED 1
    289  1.1  christos #endif
    290  1.1  christos 
    291  1.1  christos 
    292  1.3  christos extern YYSTYPE yylval;
    293  1.3  christos 
    294  1.3  christos int yyparse (void);
    295  1.3  christos 
    296  1.3  christos #endif /* !YY_YY_DEFFILEP_H_INCLUDED  */
    297  1.1  christos 
    298  1.1  christos /* Copy the second part of user declarations.  */
    299  1.1  christos 
    300  1.3  christos #line 301 "deffilep.c" /* yacc.c:358  */
    301  1.1  christos 
    302  1.1  christos #ifdef short
    303  1.1  christos # undef short
    304  1.1  christos #endif
    305  1.1  christos 
    306  1.1  christos #ifdef YYTYPE_UINT8
    307  1.1  christos typedef YYTYPE_UINT8 yytype_uint8;
    308  1.1  christos #else
    309  1.1  christos typedef unsigned char yytype_uint8;
    310  1.1  christos #endif
    311  1.1  christos 
    312  1.1  christos #ifdef YYTYPE_INT8
    313  1.1  christos typedef YYTYPE_INT8 yytype_int8;
    314  1.3  christos #else
    315  1.1  christos typedef signed char yytype_int8;
    316  1.1  christos #endif
    317  1.1  christos 
    318  1.1  christos #ifdef YYTYPE_UINT16
    319  1.1  christos typedef YYTYPE_UINT16 yytype_uint16;
    320  1.1  christos #else
    321  1.1  christos typedef unsigned short int yytype_uint16;
    322  1.1  christos #endif
    323  1.1  christos 
    324  1.1  christos #ifdef YYTYPE_INT16
    325  1.1  christos typedef YYTYPE_INT16 yytype_int16;
    326  1.1  christos #else
    327  1.1  christos typedef short int yytype_int16;
    328  1.1  christos #endif
    329  1.1  christos 
    330  1.1  christos #ifndef YYSIZE_T
    331  1.1  christos # ifdef __SIZE_TYPE__
    332  1.1  christos #  define YYSIZE_T __SIZE_TYPE__
    333  1.1  christos # elif defined size_t
    334  1.1  christos #  define YYSIZE_T size_t
    335  1.3  christos # elif ! defined YYSIZE_T
    336  1.1  christos #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
    337  1.1  christos #  define YYSIZE_T size_t
    338  1.1  christos # else
    339  1.1  christos #  define YYSIZE_T unsigned int
    340  1.1  christos # endif
    341  1.1  christos #endif
    342  1.1  christos 
    343  1.1  christos #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
    344  1.1  christos 
    345  1.1  christos #ifndef YY_
    346  1.1  christos # if defined YYENABLE_NLS && YYENABLE_NLS
    347  1.1  christos #  if ENABLE_NLS
    348  1.1  christos #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
    349  1.3  christos #   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
    350  1.1  christos #  endif
    351  1.1  christos # endif
    352  1.1  christos # ifndef YY_
    353  1.3  christos #  define YY_(Msgid) Msgid
    354  1.3  christos # endif
    355  1.3  christos #endif
    356  1.3  christos 
    357  1.3  christos #ifndef __attribute__
    358  1.3  christos /* This feature is available in gcc versions 2.5 and later.  */
    359  1.3  christos # if (! defined __GNUC__ || __GNUC__ < 2 \
    360  1.3  christos       || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
    361  1.3  christos #  define __attribute__(Spec) /* empty */
    362  1.1  christos # endif
    363  1.1  christos #endif
    364  1.1  christos 
    365  1.1  christos /* Suppress unused-variable warnings by "using" E.  */
    366  1.1  christos #if ! defined lint || defined __GNUC__
    367  1.3  christos # define YYUSE(E) ((void) (E))
    368  1.1  christos #else
    369  1.3  christos # define YYUSE(E) /* empty */
    370  1.1  christos #endif
    371  1.1  christos 
    372  1.3  christos #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
    373  1.3  christos /* Suppress an incorrect diagnostic about yylval being uninitialized.  */
    374  1.3  christos # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
    375  1.3  christos     _Pragma ("GCC diagnostic push") \
    376  1.3  christos     _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
    377  1.3  christos     _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
    378  1.3  christos # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
    379  1.3  christos     _Pragma ("GCC diagnostic pop")
    380  1.1  christos #else
    381  1.3  christos # define YY_INITIAL_VALUE(Value) Value
    382  1.3  christos #endif
    383  1.3  christos #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
    384  1.3  christos # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
    385  1.3  christos # define YY_IGNORE_MAYBE_UNINITIALIZED_END
    386  1.1  christos #endif
    387  1.3  christos #ifndef YY_INITIAL_VALUE
    388  1.3  christos # define YY_INITIAL_VALUE(Value) /* Nothing. */
    389  1.1  christos #endif
    390  1.1  christos 
    391  1.3  christos 
    392  1.1  christos #if ! defined yyoverflow || YYERROR_VERBOSE
    393  1.1  christos 
    394  1.1  christos /* The parser invokes alloca or malloc; define the necessary symbols.  */
    395  1.1  christos 
    396  1.1  christos # ifdef YYSTACK_USE_ALLOCA
    397  1.1  christos #  if YYSTACK_USE_ALLOCA
    398  1.1  christos #   ifdef __GNUC__
    399  1.1  christos #    define YYSTACK_ALLOC __builtin_alloca
    400  1.1  christos #   elif defined __BUILTIN_VA_ARG_INCR
    401  1.1  christos #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
    402  1.1  christos #   elif defined _AIX
    403  1.1  christos #    define YYSTACK_ALLOC __alloca
    404  1.1  christos #   elif defined _MSC_VER
    405  1.1  christos #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
    406  1.1  christos #    define alloca _alloca
    407  1.1  christos #   else
    408  1.1  christos #    define YYSTACK_ALLOC alloca
    409  1.3  christos #    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
    410  1.1  christos #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
    411  1.3  christos       /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
    412  1.3  christos #     ifndef EXIT_SUCCESS
    413  1.3  christos #      define EXIT_SUCCESS 0
    414  1.1  christos #     endif
    415  1.1  christos #    endif
    416  1.1  christos #   endif
    417  1.1  christos #  endif
    418  1.1  christos # endif
    419  1.1  christos 
    420  1.1  christos # ifdef YYSTACK_ALLOC
    421  1.3  christos    /* Pacify GCC's 'empty if-body' warning.  */
    422  1.3  christos #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
    423  1.1  christos #  ifndef YYSTACK_ALLOC_MAXIMUM
    424  1.1  christos     /* The OS might guarantee only one guard page at the bottom of the stack,
    425  1.1  christos        and a page size can be as small as 4096 bytes.  So we cannot safely
    426  1.1  christos        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
    427  1.1  christos        to allow for a few compiler-allocated temporary stack slots.  */
    428  1.1  christos #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
    429  1.1  christos #  endif
    430  1.1  christos # else
    431  1.1  christos #  define YYSTACK_ALLOC YYMALLOC
    432  1.1  christos #  define YYSTACK_FREE YYFREE
    433  1.1  christos #  ifndef YYSTACK_ALLOC_MAXIMUM
    434  1.1  christos #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
    435  1.1  christos #  endif
    436  1.3  christos #  if (defined __cplusplus && ! defined EXIT_SUCCESS \
    437  1.1  christos        && ! ((defined YYMALLOC || defined malloc) \
    438  1.3  christos              && (defined YYFREE || defined free)))
    439  1.1  christos #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
    440  1.3  christos #   ifndef EXIT_SUCCESS
    441  1.3  christos #    define EXIT_SUCCESS 0
    442  1.1  christos #   endif
    443  1.1  christos #  endif
    444  1.1  christos #  ifndef YYMALLOC
    445  1.1  christos #   define YYMALLOC malloc
    446  1.3  christos #   if ! defined malloc && ! defined EXIT_SUCCESS
    447  1.1  christos void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
    448  1.1  christos #   endif
    449  1.1  christos #  endif
    450  1.1  christos #  ifndef YYFREE
    451  1.1  christos #   define YYFREE free
    452  1.3  christos #   if ! defined free && ! defined EXIT_SUCCESS
    453  1.1  christos void free (void *); /* INFRINGES ON USER NAME SPACE */
    454  1.1  christos #   endif
    455  1.1  christos #  endif
    456  1.1  christos # endif
    457  1.1  christos #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
    458  1.1  christos 
    459  1.1  christos 
    460  1.1  christos #if (! defined yyoverflow \
    461  1.1  christos      && (! defined __cplusplus \
    462  1.3  christos          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
    463  1.1  christos 
    464  1.1  christos /* A type that is properly aligned for any stack member.  */
    465  1.1  christos union yyalloc
    466  1.1  christos {
    467  1.3  christos   yytype_int16 yyss_alloc;
    468  1.3  christos   YYSTYPE yyvs_alloc;
    469  1.3  christos };
    470  1.1  christos 
    471  1.1  christos /* The size of the maximum gap between one aligned stack and the next.  */
    472  1.1  christos # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
    473  1.1  christos 
    474  1.1  christos /* The size of an array large to enough to hold all stacks, each with
    475  1.1  christos    N elements.  */
    476  1.1  christos # define YYSTACK_BYTES(N) \
    477  1.1  christos      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
    478  1.1  christos       + YYSTACK_GAP_MAXIMUM)
    479  1.1  christos 
    480  1.3  christos # define YYCOPY_NEEDED 1
    481  1.1  christos 
    482  1.1  christos /* Relocate STACK from its old location to the new one.  The
    483  1.1  christos    local variables YYSIZE and YYSTACKSIZE give the old and new number of
    484  1.1  christos    elements in the stack, and YYPTR gives the new location of the
    485  1.1  christos    stack.  Advance YYPTR to a properly aligned location for the next
    486  1.1  christos    stack.  */
    487  1.3  christos # define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
    488  1.3  christos     do                                                                  \
    489  1.3  christos       {                                                                 \
    490  1.3  christos         YYSIZE_T yynewbytes;                                            \
    491  1.3  christos         YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
    492  1.3  christos         Stack = &yyptr->Stack_alloc;                                    \
    493  1.3  christos         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
    494  1.3  christos         yyptr += yynewbytes / sizeof (*yyptr);                          \
    495  1.3  christos       }                                                                 \
    496  1.3  christos     while (0)
    497  1.1  christos 
    498  1.1  christos #endif
    499  1.1  christos 
    500  1.3  christos #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
    501  1.3  christos /* Copy COUNT objects from SRC to DST.  The source and destination do
    502  1.3  christos    not overlap.  */
    503  1.3  christos # ifndef YYCOPY
    504  1.3  christos #  if defined __GNUC__ && 1 < __GNUC__
    505  1.3  christos #   define YYCOPY(Dst, Src, Count) \
    506  1.3  christos       __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
    507  1.3  christos #  else
    508  1.3  christos #   define YYCOPY(Dst, Src, Count)              \
    509  1.3  christos       do                                        \
    510  1.3  christos         {                                       \
    511  1.3  christos           YYSIZE_T yyi;                         \
    512  1.3  christos           for (yyi = 0; yyi < (Count); yyi++)   \
    513  1.3  christos             (Dst)[yyi] = (Src)[yyi];            \
    514  1.3  christos         }                                       \
    515  1.3  christos       while (0)
    516  1.3  christos #  endif
    517  1.3  christos # endif
    518  1.3  christos #endif /* !YYCOPY_NEEDED */
    519  1.3  christos 
    520  1.1  christos /* YYFINAL -- State number of the termination state.  */
    521  1.1  christos #define YYFINAL  69
    522  1.1  christos /* YYLAST -- Last index in YYTABLE.  */
    523  1.3  christos #define YYLAST   149
    524  1.1  christos 
    525  1.1  christos /* YYNTOKENS -- Number of terminals.  */
    526  1.1  christos #define YYNTOKENS  35
    527  1.1  christos /* YYNNTS -- Number of nonterminals.  */
    528  1.3  christos #define YYNNTS  27
    529  1.1  christos /* YYNRULES -- Number of rules.  */
    530  1.3  christos #define YYNRULES  99
    531  1.3  christos /* YYNSTATES -- Number of states.  */
    532  1.3  christos #define YYNSTATES  146
    533  1.1  christos 
    534  1.3  christos /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
    535  1.3  christos    by yylex, with out-of-bounds checking.  */
    536  1.1  christos #define YYUNDEFTOK  2
    537  1.1  christos #define YYMAXUTOK   285
    538  1.1  christos 
    539  1.3  christos #define YYTRANSLATE(YYX)                                                \
    540  1.1  christos   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
    541  1.1  christos 
    542  1.3  christos /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
    543  1.3  christos    as returned by yylex, without out-of-bounds checking.  */
    544  1.1  christos static const yytype_uint8 yytranslate[] =
    545  1.1  christos {
    546  1.1  christos        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    547  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    548  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    549  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    550  1.1  christos        2,     2,     2,     2,    32,     2,    31,     2,     2,     2,
    551  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    552  1.1  christos        2,    33,     2,     2,    34,     2,     2,     2,     2,     2,
    553  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    554  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    555  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    556  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    557  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    558  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    559  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    560  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    561  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    562  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    563  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    564  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    565  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    566  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    567  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    568  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    569  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    570  1.1  christos        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    571  1.1  christos        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
    572  1.1  christos        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
    573  1.1  christos       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
    574  1.1  christos       25,    26,    27,    28,    29,    30
    575  1.1  christos };
    576  1.1  christos 
    577  1.1  christos #if YYDEBUG
    578  1.3  christos   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
    579  1.1  christos static const yytype_uint16 yyrline[] =
    580  1.1  christos {
    581  1.3  christos        0,   138,   138,   139,   143,   144,   145,   146,   147,   148,
    582  1.3  christos      149,   150,   151,   152,   153,   154,   155,   156,   160,   162,
    583  1.3  christos      163,   170,   177,   178,   181,   182,   183,   184,   185,   186,
    584  1.3  christos      187,   188,   191,   192,   196,   198,   200,   202,   204,   206,
    585  1.3  christos      211,   212,   216,   217,   221,   222,   226,   227,   229,   230,
    586  1.3  christos      234,   235,   236,   237,   241,   242,   243,   244,   245,   246,
    587  1.3  christos      247,   248,   249,   250,   251,   252,   259,   260,   261,   262,
    588  1.3  christos      263,   264,   265,   266,   267,   268,   271,   272,   278,   284,
    589  1.3  christos      290,   298,   299,   302,   303,   307,   308,   312,   313,   316,
    590  1.3  christos      317,   320,   321,   327,   335,   336,   339,   340,   343,   345
    591  1.1  christos };
    592  1.1  christos #endif
    593  1.1  christos 
    594  1.3  christos #if YYDEBUG || YYERROR_VERBOSE || 0
    595  1.1  christos /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
    596  1.1  christos    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
    597  1.1  christos static const char *const yytname[] =
    598  1.1  christos {
    599  1.1  christos   "$end", "error", "$undefined", "NAME", "LIBRARY", "DESCRIPTION",
    600  1.1  christos   "STACKSIZE_K", "HEAPSIZE", "CODE", "DATAU", "DATAL", "SECTIONS",
    601  1.1  christos   "EXPORTS", "IMPORTS", "VERSIONK", "BASE", "CONSTANTU", "CONSTANTL",
    602  1.1  christos   "PRIVATEU", "PRIVATEL", "ALIGNCOMM", "READ", "WRITE", "EXECUTE",
    603  1.1  christos   "SHARED", "NONAMEU", "NONAMEL", "DIRECTIVE", "EQUAL", "ID", "DIGITS",
    604  1.1  christos   "'.'", "','", "'='", "'@'", "$accept", "start", "command", "explist",
    605  1.1  christos   "expline", "exp_opt_list", "exp_opt", "implist", "impline", "seclist",
    606  1.1  christos   "secline", "attr_list", "opt_comma", "opt_number", "attr",
    607  1.1  christos   "keyword_as_name", "opt_name2", "opt_name", "opt_equalequal_name",
    608  1.1  christos   "opt_ordinal", "opt_equal_name", "opt_base", "anylang_id", "opt_digits",
    609  1.3  christos   "opt_id", "NUMBER", "VMA", YY_NULL
    610  1.1  christos };
    611  1.1  christos #endif
    612  1.1  christos 
    613  1.1  christos # ifdef YYPRINT
    614  1.3  christos /* YYTOKNUM[NUM] -- (External) token number corresponding to the
    615  1.3  christos    (internal) symbol number NUM (which must be that of a token).  */
    616  1.1  christos static const yytype_uint16 yytoknum[] =
    617  1.1  christos {
    618  1.1  christos        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
    619  1.1  christos      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
    620  1.1  christos      275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
    621  1.1  christos      285,    46,    44,    61,    64
    622  1.1  christos };
    623  1.1  christos # endif
    624  1.1  christos 
    625  1.3  christos #define YYPACT_NINF -82
    626  1.3  christos 
    627  1.3  christos #define yypact_value_is_default(Yystate) \
    628  1.3  christos   (!!((Yystate) == (-82)))
    629  1.3  christos 
    630  1.3  christos #define YYTABLE_NINF -48
    631  1.3  christos 
    632  1.3  christos #define yytable_value_is_error(Yytable_value) \
    633  1.3  christos   0
    634  1.1  christos 
    635  1.3  christos   /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
    636  1.3  christos      STATE-NUM.  */
    637  1.3  christos static const yytype_int8 yypact[] =
    638  1.1  christos {
    639  1.3  christos      122,    11,    11,   -25,     9,     9,    53,    53,   -17,    11,
    640  1.3  christos       14,     9,   -18,    20,    95,   -82,   -82,   -82,   -82,   -82,
    641  1.3  christos      -82,   -82,   -82,   -82,   -82,   -82,   -82,   -82,   -82,   -82,
    642  1.3  christos      -82,   -82,   -82,   -82,   -82,   -82,   -82,   -82,    29,    11,
    643  1.3  christos       47,   -82,    67,    67,   -82,   -82,    54,    54,   -82,   -82,
    644  1.3  christos      -82,   -82,    48,   -82,    48,   -14,   -17,   -82,    11,   -82,
    645  1.3  christos       58,    50,    14,   -82,    61,   -82,    64,    33,   -82,   -82,
    646  1.3  christos      -82,    11,    47,   -82,    11,    63,   -82,   -82,     9,   -82,
    647  1.3  christos      -82,   -82,    53,   -82,    48,   -82,   -82,    11,    60,    76,
    648  1.3  christos       81,   -82,     9,   -82,    83,     9,   -82,   -82,    84,   -82,
    649  1.3  christos      -82,   -82,     9,    79,   -26,    85,   -82,   -82,    88,   -82,
    650  1.3  christos      -82,   -82,   -82,    36,    89,    90,   -82,    55,   -82,   -82,
    651  1.3  christos      -82,   -82,   -82,   -82,   -82,   -82,   -82,   -82,    79,    79,
    652  1.3  christos      -82,    92,    13,    92,    92,    36,   -82,    59,   -82,   -82,
    653  1.3  christos      -82,   -82,    92,    92,   -82,   -82
    654  1.1  christos };
    655  1.1  christos 
    656  1.3  christos   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
    657  1.3  christos      Performed when YYTABLE does not specify something else to do.  Zero
    658  1.3  christos      means the default is an error.  */
    659  1.1  christos static const yytype_uint8 yydefact[] =
    660  1.1  christos {
    661  1.1  christos        0,    82,    82,     0,     0,     0,     0,     0,     0,    18,
    662  1.1  christos        0,     0,     0,     0,     0,     3,    66,    60,    73,    64,
    663  1.1  christos       55,    58,    59,    63,    65,    74,    54,    56,    57,    69,
    664  1.1  christos       70,    71,    75,    62,    72,    67,    68,    61,    76,     0,
    665  1.1  christos        0,    81,    90,    90,     6,    98,    49,    49,    50,    51,
    666  1.1  christos       52,    53,     9,    45,    10,     0,    11,    41,    12,    19,
    667  1.1  christos       88,     0,    13,    33,    14,    91,     0,     0,    16,     1,
    668  1.1  christos        2,     0,    77,    78,     0,     0,     4,     5,     0,     7,
    669  1.1  christos        8,    46,     0,    43,    42,    40,    20,     0,    86,     0,
    670  1.1  christos        0,    32,     0,    92,    95,     0,    80,    79,     0,    48,
    671  1.1  christos       44,    87,     0,    47,    84,     0,    15,    94,    97,    17,
    672  1.3  christos       99,    89,    85,    23,     0,     0,    39,     0,    96,    93,
    673  1.3  christos       28,    29,    26,    27,    30,    31,    24,    25,    47,    47,
    674  1.3  christos       83,    84,    84,    84,    84,    23,    38,     0,    36,    37,
    675  1.3  christos       21,    22,    84,    84,    34,    35
    676  1.1  christos };
    677  1.1  christos 
    678  1.3  christos   /* YYPGOTO[NTERM-NUM].  */
    679  1.3  christos static const yytype_int16 yypgoto[] =
    680  1.1  christos {
    681  1.3  christos      -82,   -82,   107,   -82,    65,   -11,   -82,   -82,    75,   -82,
    682  1.3  christos       82,    -4,   -81,    93,    57,   102,    -8,   141,   -75,   -82,
    683  1.3  christos      -82,   101,   -82,   -82,   -82,    -5,   -82
    684  1.1  christos };
    685  1.1  christos 
    686  1.3  christos   /* YYDEFGOTO[NTERM-NUM].  */
    687  1.3  christos static const yytype_int16 yydefgoto[] =
    688  1.1  christos {
    689  1.3  christos       -1,    14,    15,    58,    59,   128,   129,    62,    63,    56,
    690  1.3  christos       57,    52,    82,    79,    53,    40,    41,    42,   116,   103,
    691  1.3  christos       88,    76,    67,   108,   119,    46,   111
    692  1.1  christos };
    693  1.1  christos 
    694  1.3  christos   /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
    695  1.3  christos      positive, shift that token.  If negative, reduce the rule whose
    696  1.3  christos      number is the opposite.  If YYTABLE_NINF, syntax error.  */
    697  1.1  christos static const yytype_int16 yytable[] =
    698  1.1  christos {
    699  1.3  christos       47,    60,   114,    54,    44,   115,    64,    48,    49,    50,
    700  1.1  christos       51,    65,    55,    66,    16,    83,    17,    18,    19,    20,
    701  1.3  christos       21,    22,   113,    23,    24,    25,    26,    27,    28,    29,
    702  1.1  christos       30,    73,    31,    32,    33,    34,    35,    36,    37,    45,
    703  1.3  christos       38,   114,    39,    61,   137,   120,   121,   134,   135,    68,
    704  1.3  christos       60,    84,   122,   123,   124,   125,   136,   138,   139,   140,
    705  1.3  christos       71,   126,   127,    96,    94,    95,    97,   144,   145,   -47,
    706  1.3  christos      -47,   -47,   -47,    99,    48,    49,    50,    51,    74,   101,
    707  1.3  christos       81,    89,    75,    90,   132,    45,    78,   106,   142,    45,
    708  1.3  christos      109,    87,    92,    93,   102,    69,    98,   112,     1,     2,
    709  1.3  christos        3,     4,     5,     6,     7,   104,     8,     9,    10,    11,
    710  1.3  christos      105,    81,   133,   107,   110,    12,   117,   118,   130,   131,
    711  1.3  christos      114,    70,    13,    86,   141,     1,     2,     3,     4,     5,
    712  1.3  christos        6,     7,   143,     8,     9,    10,    11,    91,    85,   100,
    713  1.3  christos       80,    72,    12,    43,    77,     0,     0,     0,     0,    13
    714  1.1  christos };
    715  1.1  christos 
    716  1.1  christos static const yytype_int16 yycheck[] =
    717  1.1  christos {
    718  1.1  christos        5,     9,    28,     7,    29,    31,    11,    21,    22,    23,
    719  1.1  christos       24,    29,    29,    31,     3,    29,     5,     6,     7,     8,
    720  1.1  christos        9,    10,   103,    12,    13,    14,    15,    16,    17,    18,
    721  1.1  christos       19,    39,    21,    22,    23,    24,    25,    26,    27,    30,
    722  1.3  christos       29,    28,    31,    29,    31,     9,    10,   128,   129,    29,
    723  1.3  christos       58,    55,    16,    17,    18,    19,   131,   132,   133,   134,
    724  1.3  christos       31,    25,    26,    71,    31,    32,    74,   142,   143,    21,
    725  1.3  christos       22,    23,    24,    78,    21,    22,    23,    24,    31,    87,
    726  1.3  christos       32,    31,    15,    33,    29,    30,    32,    92,    29,    30,
    727  1.3  christos       95,    33,    31,    29,    34,     0,    33,   102,     3,     4,
    728  1.3  christos        5,     6,     7,     8,     9,    29,    11,    12,    13,    14,
    729  1.3  christos       29,    32,   117,    30,    30,    20,    31,    29,    29,    29,
    730  1.3  christos       28,    14,    27,    58,   135,     3,     4,     5,     6,     7,
    731  1.3  christos        8,     9,   137,    11,    12,    13,    14,    62,    56,    82,
    732  1.3  christos       47,    39,    20,     2,    43,    -1,    -1,    -1,    -1,    27
    733  1.1  christos };
    734  1.1  christos 
    735  1.3  christos   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
    736  1.3  christos      symbol of state STATE-NUM.  */
    737  1.1  christos static const yytype_uint8 yystos[] =
    738  1.1  christos {
    739  1.1  christos        0,     3,     4,     5,     6,     7,     8,     9,    11,    12,
    740  1.1  christos       13,    14,    20,    27,    36,    37,     3,     5,     6,     7,
    741  1.1  christos        8,     9,    10,    12,    13,    14,    15,    16,    17,    18,
    742  1.1  christos       19,    21,    22,    23,    24,    25,    26,    27,    29,    31,
    743  1.1  christos       50,    51,    52,    52,    29,    30,    60,    60,    21,    22,
    744  1.1  christos       23,    24,    46,    49,    46,    29,    44,    45,    38,    39,
    745  1.1  christos       51,    29,    42,    43,    60,    29,    31,    57,    29,     0,
    746  1.1  christos       37,    31,    50,    51,    31,    15,    56,    56,    32,    48,
    747  1.1  christos       48,    32,    47,    29,    46,    45,    39,    33,    55,    31,
    748  1.1  christos       33,    43,    31,    29,    31,    32,    51,    51,    33,    60,
    749  1.1  christos       49,    51,    34,    54,    29,    29,    60,    30,    58,    60,
    750  1.3  christos       30,    61,    60,    47,    28,    31,    53,    31,    29,    59,
    751  1.3  christos        9,    10,    16,    17,    18,    19,    25,    26,    40,    41,
    752  1.3  christos       29,    29,    29,    60,    47,    47,    53,    31,    53,    53,
    753  1.3  christos       53,    40,    29,    60,    53,    53
    754  1.1  christos };
    755  1.1  christos 
    756  1.3  christos   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
    757  1.3  christos static const yytype_uint8 yyr1[] =
    758  1.3  christos {
    759  1.3  christos        0,    35,    36,    36,    37,    37,    37,    37,    37,    37,
    760  1.3  christos       37,    37,    37,    37,    37,    37,    37,    37,    38,    38,
    761  1.3  christos       38,    39,    40,    40,    41,    41,    41,    41,    41,    41,
    762  1.3  christos       41,    41,    42,    42,    43,    43,    43,    43,    43,    43,
    763  1.3  christos       44,    44,    45,    45,    46,    46,    47,    47,    48,    48,
    764  1.3  christos       49,    49,    49,    49,    50,    50,    50,    50,    50,    50,
    765  1.3  christos       50,    50,    50,    50,    50,    50,    50,    50,    50,    50,
    766  1.3  christos       50,    50,    50,    50,    50,    50,    51,    51,    51,    51,
    767  1.3  christos       51,    52,    52,    53,    53,    54,    54,    55,    55,    56,
    768  1.3  christos       56,    57,    57,    57,    58,    58,    59,    59,    60,    61
    769  1.3  christos };
    770  1.1  christos 
    771  1.3  christos   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
    772  1.3  christos static const yytype_uint8 yyr2[] =
    773  1.3  christos {
    774  1.3  christos        0,     2,     2,     1,     3,     3,     2,     3,     3,     2,
    775  1.3  christos        2,     2,     2,     2,     2,     4,     2,     4,     0,     1,
    776  1.3  christos        2,     7,     3,     0,     1,     1,     1,     1,     1,     1,
    777  1.3  christos        1,     1,     2,     1,     8,     8,     6,     6,     6,     4,
    778  1.3  christos        2,     1,     2,     2,     3,     1,     1,     0,     2,     0,
    779  1.3  christos        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
    780  1.3  christos        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
    781  1.3  christos        1,     1,     1,     1,     1,     1,     1,     2,     2,     3,
    782  1.3  christos        3,     1,     0,     2,     0,     2,     0,     2,     0,     3,
    783  1.3  christos        0,     1,     2,     4,     1,     0,     1,     0,     1,     1
    784  1.3  christos };
    785  1.1  christos 
    786  1.1  christos 
    787  1.3  christos #define yyerrok         (yyerrstatus = 0)
    788  1.3  christos #define yyclearin       (yychar = YYEMPTY)
    789  1.3  christos #define YYEMPTY         (-2)
    790  1.3  christos #define YYEOF           0
    791  1.3  christos 
    792  1.3  christos #define YYACCEPT        goto yyacceptlab
    793  1.3  christos #define YYABORT         goto yyabortlab
    794  1.3  christos #define YYERROR         goto yyerrorlab
    795  1.1  christos 
    796  1.1  christos 
    797  1.1  christos #define YYRECOVERING()  (!!yyerrstatus)
    798  1.1  christos 
    799  1.3  christos #define YYBACKUP(Token, Value)                                  \
    800  1.3  christos do                                                              \
    801  1.3  christos   if (yychar == YYEMPTY)                                        \
    802  1.3  christos     {                                                           \
    803  1.3  christos       yychar = (Token);                                         \
    804  1.3  christos       yylval = (Value);                                         \
    805  1.3  christos       YYPOPSTACK (yylen);                                       \
    806  1.3  christos       yystate = *yyssp;                                         \
    807  1.3  christos       goto yybackup;                                            \
    808  1.3  christos     }                                                           \
    809  1.3  christos   else                                                          \
    810  1.3  christos     {                                                           \
    811  1.1  christos       yyerror (YY_("syntax error: cannot back up")); \
    812  1.3  christos       YYERROR;                                                  \
    813  1.3  christos     }                                                           \
    814  1.3  christos while (0)
    815  1.3  christos 
    816  1.3  christos /* Error token number */
    817  1.3  christos #define YYTERROR        1
    818  1.3  christos #define YYERRCODE       256
    819  1.1  christos 
    820  1.1  christos 
    821  1.1  christos 
    822  1.1  christos /* Enable debugging if requested.  */
    823  1.1  christos #if YYDEBUG
    824  1.1  christos 
    825  1.1  christos # ifndef YYFPRINTF
    826  1.1  christos #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
    827  1.1  christos #  define YYFPRINTF fprintf
    828  1.1  christos # endif
    829  1.1  christos 
    830  1.3  christos # define YYDPRINTF(Args)                        \
    831  1.3  christos do {                                            \
    832  1.3  christos   if (yydebug)                                  \
    833  1.3  christos     YYFPRINTF Args;                             \
    834  1.3  christos } while (0)
    835  1.3  christos 
    836  1.3  christos /* This macro is provided for backward compatibility. */
    837  1.3  christos #ifndef YY_LOCATION_PRINT
    838  1.3  christos # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
    839  1.3  christos #endif
    840  1.3  christos 
    841  1.3  christos 
    842  1.3  christos # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
    843  1.3  christos do {                                                                      \
    844  1.3  christos   if (yydebug)                                                            \
    845  1.3  christos     {                                                                     \
    846  1.3  christos       YYFPRINTF (stderr, "%s ", Title);                                   \
    847  1.3  christos       yy_symbol_print (stderr,                                            \
    848  1.3  christos                   Type, Value); \
    849  1.3  christos       YYFPRINTF (stderr, "\n");                                           \
    850  1.3  christos     }                                                                     \
    851  1.3  christos } while (0)
    852  1.1  christos 
    853  1.1  christos 
    854  1.3  christos /*----------------------------------------.
    855  1.3  christos | Print this symbol's value on YYOUTPUT.  |
    856  1.3  christos `----------------------------------------*/
    857  1.1  christos 
    858  1.1  christos static void
    859  1.1  christos yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
    860  1.1  christos {
    861  1.3  christos   FILE *yyo = yyoutput;
    862  1.3  christos   YYUSE (yyo);
    863  1.1  christos   if (!yyvaluep)
    864  1.1  christos     return;
    865  1.1  christos # ifdef YYPRINT
    866  1.1  christos   if (yytype < YYNTOKENS)
    867  1.1  christos     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
    868  1.1  christos # endif
    869  1.3  christos   YYUSE (yytype);
    870  1.1  christos }
    871  1.1  christos 
    872  1.1  christos 
    873  1.1  christos /*--------------------------------.
    874  1.1  christos | Print this symbol on YYOUTPUT.  |
    875  1.1  christos `--------------------------------*/
    876  1.1  christos 
    877  1.1  christos static void
    878  1.1  christos yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
    879  1.1  christos {
    880  1.3  christos   YYFPRINTF (yyoutput, "%s %s (",
    881  1.3  christos              yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
    882  1.1  christos 
    883  1.1  christos   yy_symbol_value_print (yyoutput, yytype, yyvaluep);
    884  1.1  christos   YYFPRINTF (yyoutput, ")");
    885  1.1  christos }
    886  1.1  christos 
    887  1.1  christos /*------------------------------------------------------------------.
    888  1.1  christos | yy_stack_print -- Print the state stack from its BOTTOM up to its |
    889  1.1  christos | TOP (included).                                                   |
    890  1.1  christos `------------------------------------------------------------------*/
    891  1.1  christos 
    892  1.1  christos static void
    893  1.3  christos yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
    894  1.1  christos {
    895  1.1  christos   YYFPRINTF (stderr, "Stack now");
    896  1.3  christos   for (; yybottom <= yytop; yybottom++)
    897  1.3  christos     {
    898  1.3  christos       int yybot = *yybottom;
    899  1.3  christos       YYFPRINTF (stderr, " %d", yybot);
    900  1.3  christos     }
    901  1.1  christos   YYFPRINTF (stderr, "\n");
    902  1.1  christos }
    903  1.1  christos 
    904  1.3  christos # define YY_STACK_PRINT(Bottom, Top)                            \
    905  1.3  christos do {                                                            \
    906  1.3  christos   if (yydebug)                                                  \
    907  1.3  christos     yy_stack_print ((Bottom), (Top));                           \
    908  1.3  christos } while (0)
    909  1.1  christos 
    910  1.1  christos 
    911  1.1  christos /*------------------------------------------------.
    912  1.1  christos | Report that the YYRULE is going to be reduced.  |
    913  1.1  christos `------------------------------------------------*/
    914  1.1  christos 
    915  1.1  christos static void
    916  1.3  christos yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
    917  1.1  christos {
    918  1.3  christos   unsigned long int yylno = yyrline[yyrule];
    919  1.1  christos   int yynrhs = yyr2[yyrule];
    920  1.1  christos   int yyi;
    921  1.1  christos   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
    922  1.3  christos              yyrule - 1, yylno);
    923  1.1  christos   /* The symbols being reduced.  */
    924  1.1  christos   for (yyi = 0; yyi < yynrhs; yyi++)
    925  1.1  christos     {
    926  1.3  christos       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
    927  1.3  christos       yy_symbol_print (stderr,
    928  1.3  christos                        yystos[yyssp[yyi + 1 - yynrhs]],
    929  1.3  christos                        &(yyvsp[(yyi + 1) - (yynrhs)])
    930  1.3  christos                                               );
    931  1.3  christos       YYFPRINTF (stderr, "\n");
    932  1.1  christos     }
    933  1.1  christos }
    934  1.1  christos 
    935  1.3  christos # define YY_REDUCE_PRINT(Rule)          \
    936  1.3  christos do {                                    \
    937  1.3  christos   if (yydebug)                          \
    938  1.3  christos     yy_reduce_print (yyssp, yyvsp, Rule); \
    939  1.3  christos } while (0)
    940  1.1  christos 
    941  1.1  christos /* Nonzero means print parse trace.  It is left uninitialized so that
    942  1.1  christos    multiple parsers can coexist.  */
    943  1.1  christos int yydebug;
    944  1.1  christos #else /* !YYDEBUG */
    945  1.1  christos # define YYDPRINTF(Args)
    946  1.1  christos # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
    947  1.1  christos # define YY_STACK_PRINT(Bottom, Top)
    948  1.1  christos # define YY_REDUCE_PRINT(Rule)
    949  1.1  christos #endif /* !YYDEBUG */
    950  1.1  christos 
    951  1.1  christos 
    952  1.1  christos /* YYINITDEPTH -- initial size of the parser's stacks.  */
    953  1.3  christos #ifndef YYINITDEPTH
    954  1.1  christos # define YYINITDEPTH 200
    955  1.1  christos #endif
    956  1.1  christos 
    957  1.1  christos /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
    958  1.1  christos    if the built-in stack extension method is used).
    959  1.1  christos 
    960  1.1  christos    Do not make this value too large; the results are undefined if
    961  1.1  christos    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
    962  1.1  christos    evaluated with infinite-precision integer arithmetic.  */
    963  1.1  christos 
    964  1.1  christos #ifndef YYMAXDEPTH
    965  1.1  christos # define YYMAXDEPTH 10000
    966  1.1  christos #endif
    967  1.1  christos 
    968  1.1  christos 
    969  1.1  christos #if YYERROR_VERBOSE
    970  1.1  christos 
    971  1.1  christos # ifndef yystrlen
    972  1.1  christos #  if defined __GLIBC__ && defined _STRING_H
    973  1.1  christos #   define yystrlen strlen
    974  1.1  christos #  else
    975  1.1  christos /* Return the length of YYSTR.  */
    976  1.1  christos static YYSIZE_T
    977  1.1  christos yystrlen (const char *yystr)
    978  1.1  christos {
    979  1.1  christos   YYSIZE_T yylen;
    980  1.1  christos   for (yylen = 0; yystr[yylen]; yylen++)
    981  1.1  christos     continue;
    982  1.1  christos   return yylen;
    983  1.1  christos }
    984  1.1  christos #  endif
    985  1.1  christos # endif
    986  1.1  christos 
    987  1.1  christos # ifndef yystpcpy
    988  1.1  christos #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
    989  1.1  christos #   define yystpcpy stpcpy
    990  1.1  christos #  else
    991  1.1  christos /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
    992  1.1  christos    YYDEST.  */
    993  1.1  christos static char *
    994  1.1  christos yystpcpy (char *yydest, const char *yysrc)
    995  1.1  christos {
    996  1.1  christos   char *yyd = yydest;
    997  1.1  christos   const char *yys = yysrc;
    998  1.1  christos 
    999  1.1  christos   while ((*yyd++ = *yys++) != '\0')
   1000  1.1  christos     continue;
   1001  1.1  christos 
   1002  1.1  christos   return yyd - 1;
   1003  1.1  christos }
   1004  1.1  christos #  endif
   1005  1.1  christos # endif
   1006  1.1  christos 
   1007  1.1  christos # ifndef yytnamerr
   1008  1.1  christos /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
   1009  1.1  christos    quotes and backslashes, so that it's suitable for yyerror.  The
   1010  1.1  christos    heuristic is that double-quoting is unnecessary unless the string
   1011  1.1  christos    contains an apostrophe, a comma, or backslash (other than
   1012  1.1  christos    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
   1013  1.1  christos    null, do not copy; instead, return the length of what the result
   1014  1.1  christos    would have been.  */
   1015  1.1  christos static YYSIZE_T
   1016  1.1  christos yytnamerr (char *yyres, const char *yystr)
   1017  1.1  christos {
   1018  1.1  christos   if (*yystr == '"')
   1019  1.1  christos     {
   1020  1.1  christos       YYSIZE_T yyn = 0;
   1021  1.1  christos       char const *yyp = yystr;
   1022  1.1  christos 
   1023  1.1  christos       for (;;)
   1024  1.3  christos         switch (*++yyp)
   1025  1.3  christos           {
   1026  1.3  christos           case '\'':
   1027  1.3  christos           case ',':
   1028  1.3  christos             goto do_not_strip_quotes;
   1029  1.3  christos 
   1030  1.3  christos           case '\\':
   1031  1.3  christos             if (*++yyp != '\\')
   1032  1.3  christos               goto do_not_strip_quotes;
   1033  1.3  christos             /* Fall through.  */
   1034  1.3  christos           default:
   1035  1.3  christos             if (yyres)
   1036  1.3  christos               yyres[yyn] = *yyp;
   1037  1.3  christos             yyn++;
   1038  1.3  christos             break;
   1039  1.3  christos 
   1040  1.3  christos           case '"':
   1041  1.3  christos             if (yyres)
   1042  1.3  christos               yyres[yyn] = '\0';
   1043  1.3  christos             return yyn;
   1044  1.3  christos           }
   1045  1.1  christos     do_not_strip_quotes: ;
   1046  1.1  christos     }
   1047  1.1  christos 
   1048  1.1  christos   if (! yyres)
   1049  1.1  christos     return yystrlen (yystr);
   1050  1.1  christos 
   1051  1.1  christos   return yystpcpy (yyres, yystr) - yyres;
   1052  1.1  christos }
   1053  1.1  christos # endif
   1054  1.1  christos 
   1055  1.3  christos /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
   1056  1.3  christos    about the unexpected token YYTOKEN for the state stack whose top is
   1057  1.3  christos    YYSSP.
   1058  1.3  christos 
   1059  1.3  christos    Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
   1060  1.3  christos    not large enough to hold the message.  In that case, also set
   1061  1.3  christos    *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
   1062  1.3  christos    required number of bytes is too large to store.  */
   1063  1.3  christos static int
   1064  1.3  christos yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
   1065  1.3  christos                 yytype_int16 *yyssp, int yytoken)
   1066  1.1  christos {
   1067  1.3  christos   YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
   1068  1.3  christos   YYSIZE_T yysize = yysize0;
   1069  1.3  christos   enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
   1070  1.3  christos   /* Internationalized format string. */
   1071  1.3  christos   const char *yyformat = YY_NULL;
   1072  1.3  christos   /* Arguments of yyformat. */
   1073  1.3  christos   char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
   1074  1.3  christos   /* Number of reported tokens (one for the "unexpected", one per
   1075  1.3  christos      "expected"). */
   1076  1.3  christos   int yycount = 0;
   1077  1.3  christos 
   1078  1.3  christos   /* There are many possibilities here to consider:
   1079  1.3  christos      - If this state is a consistent state with a default action, then
   1080  1.3  christos        the only way this function was invoked is if the default action
   1081  1.3  christos        is an error action.  In that case, don't check for expected
   1082  1.3  christos        tokens because there are none.
   1083  1.3  christos      - The only way there can be no lookahead present (in yychar) is if
   1084  1.3  christos        this state is a consistent state with a default action.  Thus,
   1085  1.3  christos        detecting the absence of a lookahead is sufficient to determine
   1086  1.3  christos        that there is no unexpected or expected token to report.  In that
   1087  1.3  christos        case, just report a simple "syntax error".
   1088  1.3  christos      - Don't assume there isn't a lookahead just because this state is a
   1089  1.3  christos        consistent state with a default action.  There might have been a
   1090  1.3  christos        previous inconsistent state, consistent state with a non-default
   1091  1.3  christos        action, or user semantic action that manipulated yychar.
   1092  1.3  christos      - Of course, the expected token list depends on states to have
   1093  1.3  christos        correct lookahead information, and it depends on the parser not
   1094  1.3  christos        to perform extra reductions after fetching a lookahead from the
   1095  1.3  christos        scanner and before detecting a syntax error.  Thus, state merging
   1096  1.3  christos        (from LALR or IELR) and default reductions corrupt the expected
   1097  1.3  christos        token list.  However, the list is correct for canonical LR with
   1098  1.3  christos        one exception: it will still contain any token that will not be
   1099  1.3  christos        accepted due to an error action in a later state.
   1100  1.3  christos   */
   1101  1.3  christos   if (yytoken != YYEMPTY)
   1102  1.3  christos     {
   1103  1.3  christos       int yyn = yypact[*yyssp];
   1104  1.3  christos       yyarg[yycount++] = yytname[yytoken];
   1105  1.3  christos       if (!yypact_value_is_default (yyn))
   1106  1.3  christos         {
   1107  1.3  christos           /* Start YYX at -YYN if negative to avoid negative indexes in
   1108  1.3  christos              YYCHECK.  In other words, skip the first -YYN actions for
   1109  1.3  christos              this state because they are default actions.  */
   1110  1.3  christos           int yyxbegin = yyn < 0 ? -yyn : 0;
   1111  1.3  christos           /* Stay within bounds of both yycheck and yytname.  */
   1112  1.3  christos           int yychecklim = YYLAST - yyn + 1;
   1113  1.3  christos           int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
   1114  1.3  christos           int yyx;
   1115  1.3  christos 
   1116  1.3  christos           for (yyx = yyxbegin; yyx < yyxend; ++yyx)
   1117  1.3  christos             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
   1118  1.3  christos                 && !yytable_value_is_error (yytable[yyx + yyn]))
   1119  1.3  christos               {
   1120  1.3  christos                 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
   1121  1.3  christos                   {
   1122  1.3  christos                     yycount = 1;
   1123  1.3  christos                     yysize = yysize0;
   1124  1.3  christos                     break;
   1125  1.3  christos                   }
   1126  1.3  christos                 yyarg[yycount++] = yytname[yyx];
   1127  1.3  christos                 {
   1128  1.3  christos                   YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
   1129  1.3  christos                   if (! (yysize <= yysize1
   1130  1.3  christos                          && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
   1131  1.3  christos                     return 2;
   1132  1.3  christos                   yysize = yysize1;
   1133  1.3  christos                 }
   1134  1.3  christos               }
   1135  1.3  christos         }
   1136  1.3  christos     }
   1137  1.1  christos 
   1138  1.3  christos   switch (yycount)
   1139  1.1  christos     {
   1140  1.3  christos # define YYCASE_(N, S)                      \
   1141  1.3  christos       case N:                               \
   1142  1.3  christos         yyformat = S;                       \
   1143  1.3  christos       break
   1144  1.3  christos       YYCASE_(0, YY_("syntax error"));
   1145  1.3  christos       YYCASE_(1, YY_("syntax error, unexpected %s"));
   1146  1.3  christos       YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
   1147  1.3  christos       YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
   1148  1.3  christos       YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
   1149  1.3  christos       YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
   1150  1.3  christos # undef YYCASE_
   1151  1.3  christos     }
   1152  1.1  christos 
   1153  1.3  christos   {
   1154  1.3  christos     YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
   1155  1.3  christos     if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
   1156  1.3  christos       return 2;
   1157  1.3  christos     yysize = yysize1;
   1158  1.3  christos   }
   1159  1.3  christos 
   1160  1.3  christos   if (*yymsg_alloc < yysize)
   1161  1.3  christos     {
   1162  1.3  christos       *yymsg_alloc = 2 * yysize;
   1163  1.3  christos       if (! (yysize <= *yymsg_alloc
   1164  1.3  christos              && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
   1165  1.3  christos         *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
   1166  1.3  christos       return 1;
   1167  1.3  christos     }
   1168  1.3  christos 
   1169  1.3  christos   /* Avoid sprintf, as that infringes on the user's name space.
   1170  1.3  christos      Don't have undefined behavior even if the translation
   1171  1.3  christos      produced a string with the wrong number of "%s"s.  */
   1172  1.3  christos   {
   1173  1.3  christos     char *yyp = *yymsg;
   1174  1.3  christos     int yyi = 0;
   1175  1.3  christos     while ((*yyp = *yyformat) != '\0')
   1176  1.3  christos       if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
   1177  1.3  christos         {
   1178  1.3  christos           yyp += yytnamerr (yyp, yyarg[yyi++]);
   1179  1.3  christos           yyformat += 2;
   1180  1.3  christos         }
   1181  1.3  christos       else
   1182  1.3  christos         {
   1183  1.3  christos           yyp++;
   1184  1.3  christos           yyformat++;
   1185  1.3  christos         }
   1186  1.3  christos   }
   1187  1.3  christos   return 0;
   1188  1.1  christos }
   1189  1.1  christos #endif /* YYERROR_VERBOSE */
   1190  1.1  christos 
   1191  1.1  christos /*-----------------------------------------------.
   1192  1.1  christos | Release the memory associated to this symbol.  |
   1193  1.1  christos `-----------------------------------------------*/
   1194  1.1  christos 
   1195  1.1  christos static void
   1196  1.1  christos yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
   1197  1.1  christos {
   1198  1.1  christos   YYUSE (yyvaluep);
   1199  1.1  christos   if (!yymsg)
   1200  1.1  christos     yymsg = "Deleting";
   1201  1.1  christos   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
   1202  1.1  christos 
   1203  1.3  christos   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
   1204  1.3  christos   YYUSE (yytype);
   1205  1.3  christos   YY_IGNORE_MAYBE_UNINITIALIZED_END
   1206  1.1  christos }
   1207  1.1  christos 
   1208  1.1  christos 
   1209  1.1  christos 
   1210  1.1  christos 
   1211  1.3  christos /* The lookahead symbol.  */
   1212  1.1  christos int yychar;
   1213  1.1  christos 
   1214  1.3  christos /* The semantic value of the lookahead symbol.  */
   1215  1.1  christos YYSTYPE yylval;
   1216  1.1  christos /* Number of syntax errors so far.  */
   1217  1.1  christos int yynerrs;
   1218  1.1  christos 
   1219  1.1  christos 
   1220  1.1  christos /*----------.
   1221  1.1  christos | yyparse.  |
   1222  1.1  christos `----------*/
   1223  1.1  christos 
   1224  1.1  christos int
   1225  1.1  christos yyparse (void)
   1226  1.3  christos {
   1227  1.3  christos     int yystate;
   1228  1.3  christos     /* Number of tokens to shift before error messages enabled.  */
   1229  1.3  christos     int yyerrstatus;
   1230  1.3  christos 
   1231  1.3  christos     /* The stacks and their tools:
   1232  1.3  christos        'yyss': related to states.
   1233  1.3  christos        'yyvs': related to semantic values.
   1234  1.3  christos 
   1235  1.3  christos        Refer to the stacks through separate pointers, to allow yyoverflow
   1236  1.3  christos        to reallocate them elsewhere.  */
   1237  1.3  christos 
   1238  1.3  christos     /* The state stack.  */
   1239  1.3  christos     yytype_int16 yyssa[YYINITDEPTH];
   1240  1.3  christos     yytype_int16 *yyss;
   1241  1.3  christos     yytype_int16 *yyssp;
   1242  1.3  christos 
   1243  1.3  christos     /* The semantic value stack.  */
   1244  1.3  christos     YYSTYPE yyvsa[YYINITDEPTH];
   1245  1.3  christos     YYSTYPE *yyvs;
   1246  1.3  christos     YYSTYPE *yyvsp;
   1247  1.3  christos 
   1248  1.3  christos     YYSIZE_T yystacksize;
   1249  1.1  christos 
   1250  1.1  christos   int yyn;
   1251  1.1  christos   int yyresult;
   1252  1.3  christos   /* Lookahead token as an internal (translated) token number.  */
   1253  1.1  christos   int yytoken = 0;
   1254  1.3  christos   /* The variables used to return semantic value and location from the
   1255  1.3  christos      action routines.  */
   1256  1.3  christos   YYSTYPE yyval;
   1257  1.3  christos 
   1258  1.1  christos #if YYERROR_VERBOSE
   1259  1.1  christos   /* Buffer for error messages, and its allocated size.  */
   1260  1.1  christos   char yymsgbuf[128];
   1261  1.1  christos   char *yymsg = yymsgbuf;
   1262  1.1  christos   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
   1263  1.1  christos #endif
   1264  1.1  christos 
   1265  1.1  christos #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
   1266  1.1  christos 
   1267  1.1  christos   /* The number of symbols on the RHS of the reduced rule.
   1268  1.1  christos      Keep to zero when no symbol should be popped.  */
   1269  1.1  christos   int yylen = 0;
   1270  1.1  christos 
   1271  1.3  christos   yyssp = yyss = yyssa;
   1272  1.3  christos   yyvsp = yyvs = yyvsa;
   1273  1.3  christos   yystacksize = YYINITDEPTH;
   1274  1.3  christos 
   1275  1.1  christos   YYDPRINTF ((stderr, "Starting parse\n"));
   1276  1.1  christos 
   1277  1.1  christos   yystate = 0;
   1278  1.1  christos   yyerrstatus = 0;
   1279  1.1  christos   yynerrs = 0;
   1280  1.3  christos   yychar = YYEMPTY; /* Cause a token to be read.  */
   1281  1.1  christos   goto yysetstate;
   1282  1.1  christos 
   1283  1.1  christos /*------------------------------------------------------------.
   1284  1.1  christos | yynewstate -- Push a new state, which is found in yystate.  |
   1285  1.1  christos `------------------------------------------------------------*/
   1286  1.1  christos  yynewstate:
   1287  1.1  christos   /* In all cases, when you get here, the value and location stacks
   1288  1.1  christos      have just been pushed.  So pushing a state here evens the stacks.  */
   1289  1.1  christos   yyssp++;
   1290  1.1  christos 
   1291  1.1  christos  yysetstate:
   1292  1.1  christos   *yyssp = yystate;
   1293  1.1  christos 
   1294  1.1  christos   if (yyss + yystacksize - 1 <= yyssp)
   1295  1.1  christos     {
   1296  1.1  christos       /* Get the current used size of the three stacks, in elements.  */
   1297  1.1  christos       YYSIZE_T yysize = yyssp - yyss + 1;
   1298  1.1  christos 
   1299  1.1  christos #ifdef yyoverflow
   1300  1.1  christos       {
   1301  1.3  christos         /* Give user a chance to reallocate the stack.  Use copies of
   1302  1.3  christos            these so that the &'s don't force the real ones into
   1303  1.3  christos            memory.  */
   1304  1.3  christos         YYSTYPE *yyvs1 = yyvs;
   1305  1.3  christos         yytype_int16 *yyss1 = yyss;
   1306  1.3  christos 
   1307  1.3  christos         /* Each stack pointer address is followed by the size of the
   1308  1.3  christos            data in use in that stack, in bytes.  This used to be a
   1309  1.3  christos            conditional around just the two extra args, but that might
   1310  1.3  christos            be undefined if yyoverflow is a macro.  */
   1311  1.3  christos         yyoverflow (YY_("memory exhausted"),
   1312  1.3  christos                     &yyss1, yysize * sizeof (*yyssp),
   1313  1.3  christos                     &yyvs1, yysize * sizeof (*yyvsp),
   1314  1.3  christos                     &yystacksize);
   1315  1.1  christos 
   1316  1.3  christos         yyss = yyss1;
   1317  1.3  christos         yyvs = yyvs1;
   1318  1.1  christos       }
   1319  1.1  christos #else /* no yyoverflow */
   1320  1.1  christos # ifndef YYSTACK_RELOCATE
   1321  1.1  christos       goto yyexhaustedlab;
   1322  1.1  christos # else
   1323  1.1  christos       /* Extend the stack our own way.  */
   1324  1.1  christos       if (YYMAXDEPTH <= yystacksize)
   1325  1.3  christos         goto yyexhaustedlab;
   1326  1.1  christos       yystacksize *= 2;
   1327  1.1  christos       if (YYMAXDEPTH < yystacksize)
   1328  1.3  christos         yystacksize = YYMAXDEPTH;
   1329  1.1  christos 
   1330  1.1  christos       {
   1331  1.3  christos         yytype_int16 *yyss1 = yyss;
   1332  1.3  christos         union yyalloc *yyptr =
   1333  1.3  christos           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
   1334  1.3  christos         if (! yyptr)
   1335  1.3  christos           goto yyexhaustedlab;
   1336  1.3  christos         YYSTACK_RELOCATE (yyss_alloc, yyss);
   1337  1.3  christos         YYSTACK_RELOCATE (yyvs_alloc, yyvs);
   1338  1.1  christos #  undef YYSTACK_RELOCATE
   1339  1.3  christos         if (yyss1 != yyssa)
   1340  1.3  christos           YYSTACK_FREE (yyss1);
   1341  1.1  christos       }
   1342  1.1  christos # endif
   1343  1.1  christos #endif /* no yyoverflow */
   1344  1.1  christos 
   1345  1.1  christos       yyssp = yyss + yysize - 1;
   1346  1.1  christos       yyvsp = yyvs + yysize - 1;
   1347  1.1  christos 
   1348  1.1  christos       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
   1349  1.3  christos                   (unsigned long int) yystacksize));
   1350  1.1  christos 
   1351  1.1  christos       if (yyss + yystacksize - 1 <= yyssp)
   1352  1.3  christos         YYABORT;
   1353  1.1  christos     }
   1354  1.1  christos 
   1355  1.1  christos   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
   1356  1.1  christos 
   1357  1.3  christos   if (yystate == YYFINAL)
   1358  1.3  christos     YYACCEPT;
   1359  1.3  christos 
   1360  1.1  christos   goto yybackup;
   1361  1.1  christos 
   1362  1.1  christos /*-----------.
   1363  1.1  christos | yybackup.  |
   1364  1.1  christos `-----------*/
   1365  1.1  christos yybackup:
   1366  1.1  christos 
   1367  1.1  christos   /* Do appropriate processing given the current state.  Read a
   1368  1.3  christos      lookahead token if we need one and don't already have one.  */
   1369  1.1  christos 
   1370  1.3  christos   /* First try to decide what to do without reference to lookahead token.  */
   1371  1.1  christos   yyn = yypact[yystate];
   1372  1.3  christos   if (yypact_value_is_default (yyn))
   1373  1.1  christos     goto yydefault;
   1374  1.1  christos 
   1375  1.3  christos   /* Not known => get a lookahead token if don't already have one.  */
   1376  1.1  christos 
   1377  1.3  christos   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
   1378  1.1  christos   if (yychar == YYEMPTY)
   1379  1.1  christos     {
   1380  1.1  christos       YYDPRINTF ((stderr, "Reading a token: "));
   1381  1.3  christos       yychar = yylex ();
   1382  1.1  christos     }
   1383  1.1  christos 
   1384  1.1  christos   if (yychar <= YYEOF)
   1385  1.1  christos     {
   1386  1.1  christos       yychar = yytoken = YYEOF;
   1387  1.1  christos       YYDPRINTF ((stderr, "Now at end of input.\n"));
   1388  1.1  christos     }
   1389  1.1  christos   else
   1390  1.1  christos     {
   1391  1.1  christos       yytoken = YYTRANSLATE (yychar);
   1392  1.1  christos       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
   1393  1.1  christos     }
   1394  1.1  christos 
   1395  1.1  christos   /* If the proper action on seeing token YYTOKEN is to reduce or to
   1396  1.1  christos      detect an error, take that action.  */
   1397  1.1  christos   yyn += yytoken;
   1398  1.1  christos   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
   1399  1.1  christos     goto yydefault;
   1400  1.1  christos   yyn = yytable[yyn];
   1401  1.1  christos   if (yyn <= 0)
   1402  1.1  christos     {
   1403  1.3  christos       if (yytable_value_is_error (yyn))
   1404  1.3  christos         goto yyerrlab;
   1405  1.1  christos       yyn = -yyn;
   1406  1.1  christos       goto yyreduce;
   1407  1.1  christos     }
   1408  1.1  christos 
   1409  1.1  christos   /* Count tokens shifted since error; after three, turn off error
   1410  1.1  christos      status.  */
   1411  1.1  christos   if (yyerrstatus)
   1412  1.1  christos     yyerrstatus--;
   1413  1.1  christos 
   1414  1.3  christos   /* Shift the lookahead token.  */
   1415  1.1  christos   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
   1416  1.1  christos 
   1417  1.3  christos   /* Discard the shifted token.  */
   1418  1.3  christos   yychar = YYEMPTY;
   1419  1.1  christos 
   1420  1.1  christos   yystate = yyn;
   1421  1.3  christos   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
   1422  1.1  christos   *++yyvsp = yylval;
   1423  1.3  christos   YY_IGNORE_MAYBE_UNINITIALIZED_END
   1424  1.1  christos 
   1425  1.1  christos   goto yynewstate;
   1426  1.1  christos 
   1427  1.1  christos 
   1428  1.1  christos /*-----------------------------------------------------------.
   1429  1.1  christos | yydefault -- do the default action for the current state.  |
   1430  1.1  christos `-----------------------------------------------------------*/
   1431  1.1  christos yydefault:
   1432  1.1  christos   yyn = yydefact[yystate];
   1433  1.1  christos   if (yyn == 0)
   1434  1.1  christos     goto yyerrlab;
   1435  1.1  christos   goto yyreduce;
   1436  1.1  christos 
   1437  1.1  christos 
   1438  1.1  christos /*-----------------------------.
   1439  1.1  christos | yyreduce -- Do a reduction.  |
   1440  1.1  christos `-----------------------------*/
   1441  1.1  christos yyreduce:
   1442  1.1  christos   /* yyn is the number of a rule to reduce with.  */
   1443  1.1  christos   yylen = yyr2[yyn];
   1444  1.1  christos 
   1445  1.1  christos   /* If YYLEN is nonzero, implement the default value of the action:
   1446  1.3  christos      '$$ = $1'.
   1447  1.1  christos 
   1448  1.1  christos      Otherwise, the following line sets YYVAL to garbage.
   1449  1.1  christos      This behavior is undocumented and Bison
   1450  1.1  christos      users should not rely upon it.  Assigning to YYVAL
   1451  1.1  christos      unconditionally makes the parser a bit smaller, and it avoids a
   1452  1.1  christos      GCC warning that YYVAL may be used uninitialized.  */
   1453  1.1  christos   yyval = yyvsp[1-yylen];
   1454  1.1  christos 
   1455  1.1  christos 
   1456  1.1  christos   YY_REDUCE_PRINT (yyn);
   1457  1.1  christos   switch (yyn)
   1458  1.1  christos     {
   1459  1.1  christos         case 4:
   1460  1.3  christos #line 143 "deffilep.y" /* yacc.c:1661  */
   1461  1.3  christos     { def_image_name ((yyvsp[-1].id), (yyvsp[0].vma), 0); }
   1462  1.3  christos #line 1463 "deffilep.c" /* yacc.c:1661  */
   1463  1.1  christos     break;
   1464  1.1  christos 
   1465  1.1  christos   case 5:
   1466  1.3  christos #line 144 "deffilep.y" /* yacc.c:1661  */
   1467  1.3  christos     { def_image_name ((yyvsp[-1].id), (yyvsp[0].vma), 1); }
   1468  1.3  christos #line 1469 "deffilep.c" /* yacc.c:1661  */
   1469  1.1  christos     break;
   1470  1.1  christos 
   1471  1.1  christos   case 6:
   1472  1.3  christos #line 145 "deffilep.y" /* yacc.c:1661  */
   1473  1.3  christos     { def_description ((yyvsp[0].id));}
   1474  1.3  christos #line 1475 "deffilep.c" /* yacc.c:1661  */
   1475  1.1  christos     break;
   1476  1.1  christos 
   1477  1.1  christos   case 7:
   1478  1.3  christos #line 146 "deffilep.y" /* yacc.c:1661  */
   1479  1.3  christos     { def_stacksize ((yyvsp[-1].number), (yyvsp[0].number));}
   1480  1.3  christos #line 1481 "deffilep.c" /* yacc.c:1661  */
   1481  1.1  christos     break;
   1482  1.1  christos 
   1483  1.1  christos   case 8:
   1484  1.3  christos #line 147 "deffilep.y" /* yacc.c:1661  */
   1485  1.3  christos     { def_heapsize ((yyvsp[-1].number), (yyvsp[0].number));}
   1486  1.3  christos #line 1487 "deffilep.c" /* yacc.c:1661  */
   1487  1.1  christos     break;
   1488  1.1  christos 
   1489  1.1  christos   case 9:
   1490  1.3  christos #line 148 "deffilep.y" /* yacc.c:1661  */
   1491  1.3  christos     { def_section ("CODE", (yyvsp[0].number));}
   1492  1.3  christos #line 1493 "deffilep.c" /* yacc.c:1661  */
   1493  1.1  christos     break;
   1494  1.1  christos 
   1495  1.1  christos   case 10:
   1496  1.3  christos #line 149 "deffilep.y" /* yacc.c:1661  */
   1497  1.3  christos     { def_section ("DATA", (yyvsp[0].number));}
   1498  1.3  christos #line 1499 "deffilep.c" /* yacc.c:1661  */
   1499  1.1  christos     break;
   1500  1.1  christos 
   1501  1.1  christos   case 14:
   1502  1.3  christos #line 153 "deffilep.y" /* yacc.c:1661  */
   1503  1.3  christos     { def_version ((yyvsp[0].number), 0);}
   1504  1.3  christos #line 1505 "deffilep.c" /* yacc.c:1661  */
   1505  1.1  christos     break;
   1506  1.1  christos 
   1507  1.1  christos   case 15:
   1508  1.3  christos #line 154 "deffilep.y" /* yacc.c:1661  */
   1509  1.3  christos     { def_version ((yyvsp[-2].number), (yyvsp[0].number));}
   1510  1.3  christos #line 1511 "deffilep.c" /* yacc.c:1661  */
   1511  1.1  christos     break;
   1512  1.1  christos 
   1513  1.1  christos   case 16:
   1514  1.3  christos #line 155 "deffilep.y" /* yacc.c:1661  */
   1515  1.3  christos     { def_directive ((yyvsp[0].id));}
   1516  1.3  christos #line 1517 "deffilep.c" /* yacc.c:1661  */
   1517  1.1  christos     break;
   1518  1.1  christos 
   1519  1.1  christos   case 17:
   1520  1.3  christos #line 156 "deffilep.y" /* yacc.c:1661  */
   1521  1.3  christos     { def_aligncomm ((yyvsp[-2].id), (yyvsp[0].number));}
   1522  1.3  christos #line 1523 "deffilep.c" /* yacc.c:1661  */
   1523  1.1  christos     break;
   1524  1.1  christos 
   1525  1.1  christos   case 21:
   1526  1.3  christos #line 171 "deffilep.y" /* yacc.c:1661  */
   1527  1.3  christos     { def_exports ((yyvsp[-6].id), (yyvsp[-5].id), (yyvsp[-4].number), (yyvsp[-2].number), (yyvsp[0].id)); }
   1528  1.3  christos #line 1529 "deffilep.c" /* yacc.c:1661  */
   1529  1.1  christos     break;
   1530  1.1  christos 
   1531  1.1  christos   case 22:
   1532  1.3  christos #line 177 "deffilep.y" /* yacc.c:1661  */
   1533  1.3  christos     { (yyval.number) = (yyvsp[-2].number) | (yyvsp[0].number); }
   1534  1.3  christos #line 1535 "deffilep.c" /* yacc.c:1661  */
   1535  1.1  christos     break;
   1536  1.1  christos 
   1537  1.1  christos   case 23:
   1538  1.3  christos #line 178 "deffilep.y" /* yacc.c:1661  */
   1539  1.1  christos     { (yyval.number) = 0; }
   1540  1.3  christos #line 1541 "deffilep.c" /* yacc.c:1661  */
   1541  1.1  christos     break;
   1542  1.1  christos 
   1543  1.1  christos   case 24:
   1544  1.3  christos #line 181 "deffilep.y" /* yacc.c:1661  */
   1545  1.1  christos     { (yyval.number) = 1; }
   1546  1.3  christos #line 1547 "deffilep.c" /* yacc.c:1661  */
   1547  1.1  christos     break;
   1548  1.1  christos 
   1549  1.1  christos   case 25:
   1550  1.3  christos #line 182 "deffilep.y" /* yacc.c:1661  */
   1551  1.1  christos     { (yyval.number) = 1; }
   1552  1.3  christos #line 1553 "deffilep.c" /* yacc.c:1661  */
   1553  1.1  christos     break;
   1554  1.1  christos 
   1555  1.1  christos   case 26:
   1556  1.3  christos #line 183 "deffilep.y" /* yacc.c:1661  */
   1557  1.1  christos     { (yyval.number) = 2; }
   1558  1.3  christos #line 1559 "deffilep.c" /* yacc.c:1661  */
   1559  1.1  christos     break;
   1560  1.1  christos 
   1561  1.1  christos   case 27:
   1562  1.3  christos #line 184 "deffilep.y" /* yacc.c:1661  */
   1563  1.1  christos     { (yyval.number) = 2; }
   1564  1.3  christos #line 1565 "deffilep.c" /* yacc.c:1661  */
   1565  1.1  christos     break;
   1566  1.1  christos 
   1567  1.1  christos   case 28:
   1568  1.3  christos #line 185 "deffilep.y" /* yacc.c:1661  */
   1569  1.1  christos     { (yyval.number) = 4; }
   1570  1.3  christos #line 1571 "deffilep.c" /* yacc.c:1661  */
   1571  1.1  christos     break;
   1572  1.1  christos 
   1573  1.1  christos   case 29:
   1574  1.3  christos #line 186 "deffilep.y" /* yacc.c:1661  */
   1575  1.1  christos     { (yyval.number) = 4; }
   1576  1.3  christos #line 1577 "deffilep.c" /* yacc.c:1661  */
   1577  1.1  christos     break;
   1578  1.1  christos 
   1579  1.1  christos   case 30:
   1580  1.3  christos #line 187 "deffilep.y" /* yacc.c:1661  */
   1581  1.1  christos     { (yyval.number) = 8; }
   1582  1.3  christos #line 1583 "deffilep.c" /* yacc.c:1661  */
   1583  1.1  christos     break;
   1584  1.1  christos 
   1585  1.1  christos   case 31:
   1586  1.3  christos #line 188 "deffilep.y" /* yacc.c:1661  */
   1587  1.1  christos     { (yyval.number) = 8; }
   1588  1.3  christos #line 1589 "deffilep.c" /* yacc.c:1661  */
   1589  1.1  christos     break;
   1590  1.1  christos 
   1591  1.1  christos   case 34:
   1592  1.3  christos #line 197 "deffilep.y" /* yacc.c:1661  */
   1593  1.3  christos     { def_import ((yyvsp[-7].id), (yyvsp[-5].id), (yyvsp[-3].id), (yyvsp[-1].id), -1, (yyvsp[0].id)); }
   1594  1.3  christos #line 1595 "deffilep.c" /* yacc.c:1661  */
   1595  1.1  christos     break;
   1596  1.1  christos 
   1597  1.1  christos   case 35:
   1598  1.3  christos #line 199 "deffilep.y" /* yacc.c:1661  */
   1599  1.3  christos     { def_import ((yyvsp[-7].id), (yyvsp[-5].id), (yyvsp[-3].id),  0, (yyvsp[-1].number), (yyvsp[0].id)); }
   1600  1.3  christos #line 1601 "deffilep.c" /* yacc.c:1661  */
   1601  1.1  christos     break;
   1602  1.1  christos 
   1603  1.1  christos   case 36:
   1604  1.3  christos #line 201 "deffilep.y" /* yacc.c:1661  */
   1605  1.3  christos     { def_import ((yyvsp[-5].id), (yyvsp[-3].id),  0, (yyvsp[-1].id), -1, (yyvsp[0].id)); }
   1606  1.3  christos #line 1607 "deffilep.c" /* yacc.c:1661  */
   1607  1.1  christos     break;
   1608  1.1  christos 
   1609  1.1  christos   case 37:
   1610  1.3  christos #line 203 "deffilep.y" /* yacc.c:1661  */
   1611  1.3  christos     { def_import ((yyvsp[-5].id), (yyvsp[-3].id),  0,  0, (yyvsp[-1].number), (yyvsp[0].id)); }
   1612  1.3  christos #line 1613 "deffilep.c" /* yacc.c:1661  */
   1613  1.1  christos     break;
   1614  1.1  christos 
   1615  1.1  christos   case 38:
   1616  1.3  christos #line 205 "deffilep.y" /* yacc.c:1661  */
   1617  1.3  christos     { def_import( 0, (yyvsp[-5].id), (yyvsp[-3].id), (yyvsp[-1].id), -1, (yyvsp[0].id)); }
   1618  1.3  christos #line 1619 "deffilep.c" /* yacc.c:1661  */
   1619  1.1  christos     break;
   1620  1.1  christos 
   1621  1.1  christos   case 39:
   1622  1.3  christos #line 207 "deffilep.y" /* yacc.c:1661  */
   1623  1.3  christos     { def_import ( 0, (yyvsp[-3].id),  0, (yyvsp[-1].id), -1, (yyvsp[0].id)); }
   1624  1.3  christos #line 1625 "deffilep.c" /* yacc.c:1661  */
   1625  1.1  christos     break;
   1626  1.1  christos 
   1627  1.1  christos   case 42:
   1628  1.3  christos #line 216 "deffilep.y" /* yacc.c:1661  */
   1629  1.3  christos     { def_section ((yyvsp[-1].id), (yyvsp[0].number));}
   1630  1.3  christos #line 1631 "deffilep.c" /* yacc.c:1661  */
   1631  1.1  christos     break;
   1632  1.1  christos 
   1633  1.1  christos   case 43:
   1634  1.3  christos #line 217 "deffilep.y" /* yacc.c:1661  */
   1635  1.3  christos     { def_section_alt ((yyvsp[-1].id), (yyvsp[0].id));}
   1636  1.3  christos #line 1637 "deffilep.c" /* yacc.c:1661  */
   1637  1.1  christos     break;
   1638  1.1  christos 
   1639  1.1  christos   case 44:
   1640  1.3  christos #line 221 "deffilep.y" /* yacc.c:1661  */
   1641  1.3  christos     { (yyval.number) = (yyvsp[-2].number) | (yyvsp[0].number); }
   1642  1.3  christos #line 1643 "deffilep.c" /* yacc.c:1661  */
   1643  1.1  christos     break;
   1644  1.1  christos 
   1645  1.1  christos   case 45:
   1646  1.3  christos #line 222 "deffilep.y" /* yacc.c:1661  */
   1647  1.3  christos     { (yyval.number) = (yyvsp[0].number); }
   1648  1.3  christos #line 1649 "deffilep.c" /* yacc.c:1661  */
   1649  1.1  christos     break;
   1650  1.1  christos 
   1651  1.1  christos   case 48:
   1652  1.3  christos #line 229 "deffilep.y" /* yacc.c:1661  */
   1653  1.3  christos     { (yyval.number)=(yyvsp[0].number);}
   1654  1.3  christos #line 1655 "deffilep.c" /* yacc.c:1661  */
   1655  1.1  christos     break;
   1656  1.1  christos 
   1657  1.1  christos   case 49:
   1658  1.3  christos #line 230 "deffilep.y" /* yacc.c:1661  */
   1659  1.1  christos     { (yyval.number)=-1;}
   1660  1.3  christos #line 1661 "deffilep.c" /* yacc.c:1661  */
   1661  1.1  christos     break;
   1662  1.1  christos 
   1663  1.1  christos   case 50:
   1664  1.3  christos #line 234 "deffilep.y" /* yacc.c:1661  */
   1665  1.1  christos     { (yyval.number) = 1;}
   1666  1.3  christos #line 1667 "deffilep.c" /* yacc.c:1661  */
   1667  1.1  christos     break;
   1668  1.1  christos 
   1669  1.1  christos   case 51:
   1670  1.3  christos #line 235 "deffilep.y" /* yacc.c:1661  */
   1671  1.1  christos     { (yyval.number) = 2;}
   1672  1.3  christos #line 1673 "deffilep.c" /* yacc.c:1661  */
   1673  1.1  christos     break;
   1674  1.1  christos 
   1675  1.1  christos   case 52:
   1676  1.3  christos #line 236 "deffilep.y" /* yacc.c:1661  */
   1677  1.1  christos     { (yyval.number)=4;}
   1678  1.3  christos #line 1679 "deffilep.c" /* yacc.c:1661  */
   1679  1.1  christos     break;
   1680  1.1  christos 
   1681  1.1  christos   case 53:
   1682  1.3  christos #line 237 "deffilep.y" /* yacc.c:1661  */
   1683  1.1  christos     { (yyval.number)=8;}
   1684  1.3  christos #line 1685 "deffilep.c" /* yacc.c:1661  */
   1685  1.1  christos     break;
   1686  1.1  christos 
   1687  1.1  christos   case 54:
   1688  1.3  christos #line 241 "deffilep.y" /* yacc.c:1661  */
   1689  1.1  christos     { (yyval.id_const) = "BASE"; }
   1690  1.3  christos #line 1691 "deffilep.c" /* yacc.c:1661  */
   1691  1.1  christos     break;
   1692  1.1  christos 
   1693  1.1  christos   case 55:
   1694  1.3  christos #line 242 "deffilep.y" /* yacc.c:1661  */
   1695  1.1  christos     { (yyval.id_const) = "CODE"; }
   1696  1.3  christos #line 1697 "deffilep.c" /* yacc.c:1661  */
   1697  1.1  christos     break;
   1698  1.1  christos 
   1699  1.1  christos   case 56:
   1700  1.3  christos #line 243 "deffilep.y" /* yacc.c:1661  */
   1701  1.1  christos     { (yyval.id_const) = "CONSTANT"; }
   1702  1.3  christos #line 1703 "deffilep.c" /* yacc.c:1661  */
   1703  1.1  christos     break;
   1704  1.1  christos 
   1705  1.1  christos   case 57:
   1706  1.3  christos #line 244 "deffilep.y" /* yacc.c:1661  */
   1707  1.1  christos     { (yyval.id_const) = "constant"; }
   1708  1.3  christos #line 1709 "deffilep.c" /* yacc.c:1661  */
   1709  1.1  christos     break;
   1710  1.1  christos 
   1711  1.1  christos   case 58:
   1712  1.3  christos #line 245 "deffilep.y" /* yacc.c:1661  */
   1713  1.1  christos     { (yyval.id_const) = "DATA"; }
   1714  1.3  christos #line 1715 "deffilep.c" /* yacc.c:1661  */
   1715  1.1  christos     break;
   1716  1.1  christos 
   1717  1.1  christos   case 59:
   1718  1.3  christos #line 246 "deffilep.y" /* yacc.c:1661  */
   1719  1.1  christos     { (yyval.id_const) = "data"; }
   1720  1.3  christos #line 1721 "deffilep.c" /* yacc.c:1661  */
   1721  1.1  christos     break;
   1722  1.1  christos 
   1723  1.1  christos   case 60:
   1724  1.3  christos #line 247 "deffilep.y" /* yacc.c:1661  */
   1725  1.1  christos     { (yyval.id_const) = "DESCRIPTION"; }
   1726  1.3  christos #line 1727 "deffilep.c" /* yacc.c:1661  */
   1727  1.1  christos     break;
   1728  1.1  christos 
   1729  1.1  christos   case 61:
   1730  1.3  christos #line 248 "deffilep.y" /* yacc.c:1661  */
   1731  1.1  christos     { (yyval.id_const) = "DIRECTIVE"; }
   1732  1.3  christos #line 1733 "deffilep.c" /* yacc.c:1661  */
   1733  1.1  christos     break;
   1734  1.1  christos 
   1735  1.1  christos   case 62:
   1736  1.3  christos #line 249 "deffilep.y" /* yacc.c:1661  */
   1737  1.1  christos     { (yyval.id_const) = "EXECUTE"; }
   1738  1.3  christos #line 1739 "deffilep.c" /* yacc.c:1661  */
   1739  1.1  christos     break;
   1740  1.1  christos 
   1741  1.1  christos   case 63:
   1742  1.3  christos #line 250 "deffilep.y" /* yacc.c:1661  */
   1743  1.1  christos     { (yyval.id_const) = "EXPORTS"; }
   1744  1.3  christos #line 1745 "deffilep.c" /* yacc.c:1661  */
   1745  1.1  christos     break;
   1746  1.1  christos 
   1747  1.1  christos   case 64:
   1748  1.3  christos #line 251 "deffilep.y" /* yacc.c:1661  */
   1749  1.1  christos     { (yyval.id_const) = "HEAPSIZE"; }
   1750  1.3  christos #line 1751 "deffilep.c" /* yacc.c:1661  */
   1751  1.1  christos     break;
   1752  1.1  christos 
   1753  1.1  christos   case 65:
   1754  1.3  christos #line 252 "deffilep.y" /* yacc.c:1661  */
   1755  1.1  christos     { (yyval.id_const) = "IMPORTS"; }
   1756  1.3  christos #line 1757 "deffilep.c" /* yacc.c:1661  */
   1757  1.1  christos     break;
   1758  1.1  christos 
   1759  1.1  christos   case 66:
   1760  1.3  christos #line 259 "deffilep.y" /* yacc.c:1661  */
   1761  1.1  christos     { (yyval.id_const) = "NAME"; }
   1762  1.3  christos #line 1763 "deffilep.c" /* yacc.c:1661  */
   1763  1.1  christos     break;
   1764  1.1  christos 
   1765  1.1  christos   case 67:
   1766  1.3  christos #line 260 "deffilep.y" /* yacc.c:1661  */
   1767  1.1  christos     { (yyval.id_const) = "NONAME"; }
   1768  1.3  christos #line 1769 "deffilep.c" /* yacc.c:1661  */
   1769  1.1  christos     break;
   1770  1.1  christos 
   1771  1.1  christos   case 68:
   1772  1.3  christos #line 261 "deffilep.y" /* yacc.c:1661  */
   1773  1.1  christos     { (yyval.id_const) = "noname"; }
   1774  1.3  christos #line 1775 "deffilep.c" /* yacc.c:1661  */
   1775  1.1  christos     break;
   1776  1.1  christos 
   1777  1.1  christos   case 69:
   1778  1.3  christos #line 262 "deffilep.y" /* yacc.c:1661  */
   1779  1.1  christos     { (yyval.id_const) = "PRIVATE"; }
   1780  1.3  christos #line 1781 "deffilep.c" /* yacc.c:1661  */
   1781  1.1  christos     break;
   1782  1.1  christos 
   1783  1.1  christos   case 70:
   1784  1.3  christos #line 263 "deffilep.y" /* yacc.c:1661  */
   1785  1.1  christos     { (yyval.id_const) = "private"; }
   1786  1.3  christos #line 1787 "deffilep.c" /* yacc.c:1661  */
   1787  1.1  christos     break;
   1788  1.1  christos 
   1789  1.1  christos   case 71:
   1790  1.3  christos #line 264 "deffilep.y" /* yacc.c:1661  */
   1791  1.1  christos     { (yyval.id_const) = "READ"; }
   1792  1.3  christos #line 1793 "deffilep.c" /* yacc.c:1661  */
   1793  1.1  christos     break;
   1794  1.1  christos 
   1795  1.1  christos   case 72:
   1796  1.3  christos #line 265 "deffilep.y" /* yacc.c:1661  */
   1797  1.1  christos     { (yyval.id_const) = "SHARED"; }
   1798  1.3  christos #line 1799 "deffilep.c" /* yacc.c:1661  */
   1799  1.1  christos     break;
   1800  1.1  christos 
   1801  1.1  christos   case 73:
   1802  1.3  christos #line 266 "deffilep.y" /* yacc.c:1661  */
   1803  1.1  christos     { (yyval.id_const) = "STACKSIZE"; }
   1804  1.3  christos #line 1805 "deffilep.c" /* yacc.c:1661  */
   1805  1.1  christos     break;
   1806  1.1  christos 
   1807  1.1  christos   case 74:
   1808  1.3  christos #line 267 "deffilep.y" /* yacc.c:1661  */
   1809  1.1  christos     { (yyval.id_const) = "VERSION"; }
   1810  1.3  christos #line 1811 "deffilep.c" /* yacc.c:1661  */
   1811  1.1  christos     break;
   1812  1.1  christos 
   1813  1.1  christos   case 75:
   1814  1.3  christos #line 268 "deffilep.y" /* yacc.c:1661  */
   1815  1.1  christos     { (yyval.id_const) = "WRITE"; }
   1816  1.3  christos #line 1817 "deffilep.c" /* yacc.c:1661  */
   1817  1.1  christos     break;
   1818  1.1  christos 
   1819  1.1  christos   case 76:
   1820  1.3  christos #line 271 "deffilep.y" /* yacc.c:1661  */
   1821  1.3  christos     { (yyval.id) = (yyvsp[0].id); }
   1822  1.3  christos #line 1823 "deffilep.c" /* yacc.c:1661  */
   1823  1.1  christos     break;
   1824  1.1  christos 
   1825  1.1  christos   case 77:
   1826  1.3  christos #line 273 "deffilep.y" /* yacc.c:1661  */
   1827  1.1  christos     {
   1828  1.3  christos 	    char *name = xmalloc (strlen ((yyvsp[0].id_const)) + 2);
   1829  1.3  christos 	    sprintf (name, ".%s", (yyvsp[0].id_const));
   1830  1.1  christos 	    (yyval.id) = name;
   1831  1.1  christos 	  }
   1832  1.3  christos #line 1833 "deffilep.c" /* yacc.c:1661  */
   1833  1.1  christos     break;
   1834  1.1  christos 
   1835  1.1  christos   case 78:
   1836  1.3  christos #line 279 "deffilep.y" /* yacc.c:1661  */
   1837  1.3  christos     {
   1838  1.3  christos 	    char *name = def_pool_alloc (strlen ((yyvsp[0].id)) + 2);
   1839  1.3  christos 	    sprintf (name, ".%s", (yyvsp[0].id));
   1840  1.1  christos 	    (yyval.id) = name;
   1841  1.1  christos 	  }
   1842  1.3  christos #line 1843 "deffilep.c" /* yacc.c:1661  */
   1843  1.1  christos     break;
   1844  1.1  christos 
   1845  1.1  christos   case 79:
   1846  1.3  christos #line 285 "deffilep.y" /* yacc.c:1661  */
   1847  1.3  christos     {
   1848  1.3  christos 	    char *name = def_pool_alloc (strlen ((yyvsp[-2].id_const)) + 1 + strlen ((yyvsp[0].id)) + 1);
   1849  1.3  christos 	    sprintf (name, "%s.%s", (yyvsp[-2].id_const), (yyvsp[0].id));
   1850  1.1  christos 	    (yyval.id) = name;
   1851  1.1  christos 	  }
   1852  1.3  christos #line 1853 "deffilep.c" /* yacc.c:1661  */
   1853  1.1  christos     break;
   1854  1.1  christos 
   1855  1.1  christos   case 80:
   1856  1.3  christos #line 291 "deffilep.y" /* yacc.c:1661  */
   1857  1.3  christos     {
   1858  1.3  christos 	    char *name = def_pool_alloc (strlen ((yyvsp[-2].id)) + 1 + strlen ((yyvsp[0].id)) + 1);
   1859  1.3  christos 	    sprintf (name, "%s.%s", (yyvsp[-2].id), (yyvsp[0].id));
   1860  1.1  christos 	    (yyval.id) = name;
   1861  1.1  christos 	  }
   1862  1.3  christos #line 1863 "deffilep.c" /* yacc.c:1661  */
   1863  1.1  christos     break;
   1864  1.1  christos 
   1865  1.1  christos   case 81:
   1866  1.3  christos #line 298 "deffilep.y" /* yacc.c:1661  */
   1867  1.3  christos     { (yyval.id) = (yyvsp[0].id); }
   1868  1.3  christos #line 1869 "deffilep.c" /* yacc.c:1661  */
   1869  1.1  christos     break;
   1870  1.1  christos 
   1871  1.1  christos   case 82:
   1872  1.3  christos #line 299 "deffilep.y" /* yacc.c:1661  */
   1873  1.1  christos     { (yyval.id) = ""; }
   1874  1.3  christos #line 1875 "deffilep.c" /* yacc.c:1661  */
   1875  1.1  christos     break;
   1876  1.1  christos 
   1877  1.1  christos   case 83:
   1878  1.3  christos #line 302 "deffilep.y" /* yacc.c:1661  */
   1879  1.3  christos     { (yyval.id) = (yyvsp[0].id); }
   1880  1.3  christos #line 1881 "deffilep.c" /* yacc.c:1661  */
   1881  1.1  christos     break;
   1882  1.1  christos 
   1883  1.1  christos   case 84:
   1884  1.3  christos #line 303 "deffilep.y" /* yacc.c:1661  */
   1885  1.1  christos     { (yyval.id) = 0; }
   1886  1.3  christos #line 1887 "deffilep.c" /* yacc.c:1661  */
   1887  1.1  christos     break;
   1888  1.1  christos 
   1889  1.1  christos   case 85:
   1890  1.3  christos #line 307 "deffilep.y" /* yacc.c:1661  */
   1891  1.3  christos     { (yyval.number) = (yyvsp[0].number);}
   1892  1.3  christos #line 1893 "deffilep.c" /* yacc.c:1661  */
   1893  1.1  christos     break;
   1894  1.1  christos 
   1895  1.1  christos   case 86:
   1896  1.3  christos #line 308 "deffilep.y" /* yacc.c:1661  */
   1897  1.1  christos     { (yyval.number) = -1;}
   1898  1.3  christos #line 1899 "deffilep.c" /* yacc.c:1661  */
   1899  1.1  christos     break;
   1900  1.1  christos 
   1901  1.1  christos   case 87:
   1902  1.3  christos #line 312 "deffilep.y" /* yacc.c:1661  */
   1903  1.3  christos     { (yyval.id) = (yyvsp[0].id); }
   1904  1.3  christos #line 1905 "deffilep.c" /* yacc.c:1661  */
   1905  1.1  christos     break;
   1906  1.1  christos 
   1907  1.1  christos   case 88:
   1908  1.3  christos #line 313 "deffilep.y" /* yacc.c:1661  */
   1909  1.1  christos     { (yyval.id) =  0; }
   1910  1.3  christos #line 1911 "deffilep.c" /* yacc.c:1661  */
   1911  1.1  christos     break;
   1912  1.1  christos 
   1913  1.1  christos   case 89:
   1914  1.3  christos #line 316 "deffilep.y" /* yacc.c:1661  */
   1915  1.3  christos     { (yyval.vma) = (yyvsp[0].vma);}
   1916  1.3  christos #line 1917 "deffilep.c" /* yacc.c:1661  */
   1917  1.1  christos     break;
   1918  1.1  christos 
   1919  1.1  christos   case 90:
   1920  1.3  christos #line 317 "deffilep.y" /* yacc.c:1661  */
   1921  1.3  christos     { (yyval.vma) = (bfd_vma) -1;}
   1922  1.3  christos #line 1923 "deffilep.c" /* yacc.c:1661  */
   1923  1.1  christos     break;
   1924  1.1  christos 
   1925  1.1  christos   case 91:
   1926  1.3  christos #line 320 "deffilep.y" /* yacc.c:1661  */
   1927  1.3  christos     { (yyval.id) = (yyvsp[0].id); }
   1928  1.3  christos #line 1929 "deffilep.c" /* yacc.c:1661  */
   1929  1.1  christos     break;
   1930  1.1  christos 
   1931  1.1  christos   case 92:
   1932  1.3  christos #line 322 "deffilep.y" /* yacc.c:1661  */
   1933  1.1  christos     {
   1934  1.3  christos 	    char *id = def_pool_alloc (strlen ((yyvsp[0].id)) + 2);
   1935  1.3  christos 	    sprintf (id, ".%s", (yyvsp[0].id));
   1936  1.1  christos 	    (yyval.id) = id;
   1937  1.1  christos 	  }
   1938  1.3  christos #line 1939 "deffilep.c" /* yacc.c:1661  */
   1939  1.1  christos     break;
   1940  1.1  christos 
   1941  1.1  christos   case 93:
   1942  1.3  christos #line 328 "deffilep.y" /* yacc.c:1661  */
   1943  1.1  christos     {
   1944  1.3  christos 	    char *id = def_pool_alloc (strlen ((yyvsp[-3].id)) + 1 + strlen ((yyvsp[-1].digits)) + strlen ((yyvsp[0].id)) + 1);
   1945  1.3  christos 	    sprintf (id, "%s.%s%s", (yyvsp[-3].id), (yyvsp[-1].digits), (yyvsp[0].id));
   1946  1.1  christos 	    (yyval.id) = id;
   1947  1.1  christos 	  }
   1948  1.3  christos #line 1949 "deffilep.c" /* yacc.c:1661  */
   1949  1.1  christos     break;
   1950  1.1  christos 
   1951  1.1  christos   case 94:
   1952  1.3  christos #line 335 "deffilep.y" /* yacc.c:1661  */
   1953  1.3  christos     { (yyval.digits) = (yyvsp[0].digits); }
   1954  1.3  christos #line 1955 "deffilep.c" /* yacc.c:1661  */
   1955  1.1  christos     break;
   1956  1.1  christos 
   1957  1.1  christos   case 95:
   1958  1.3  christos #line 336 "deffilep.y" /* yacc.c:1661  */
   1959  1.1  christos     { (yyval.digits) = ""; }
   1960  1.3  christos #line 1961 "deffilep.c" /* yacc.c:1661  */
   1961  1.1  christos     break;
   1962  1.1  christos 
   1963  1.1  christos   case 96:
   1964  1.3  christos #line 339 "deffilep.y" /* yacc.c:1661  */
   1965  1.3  christos     { (yyval.id) = (yyvsp[0].id); }
   1966  1.3  christos #line 1967 "deffilep.c" /* yacc.c:1661  */
   1967  1.1  christos     break;
   1968  1.1  christos 
   1969  1.1  christos   case 97:
   1970  1.3  christos #line 340 "deffilep.y" /* yacc.c:1661  */
   1971  1.1  christos     { (yyval.id) = ""; }
   1972  1.3  christos #line 1973 "deffilep.c" /* yacc.c:1661  */
   1973  1.1  christos     break;
   1974  1.1  christos 
   1975  1.1  christos   case 98:
   1976  1.3  christos #line 343 "deffilep.y" /* yacc.c:1661  */
   1977  1.3  christos     { (yyval.number) = strtoul ((yyvsp[0].digits), 0, 0); }
   1978  1.3  christos #line 1979 "deffilep.c" /* yacc.c:1661  */
   1979  1.3  christos     break;
   1980  1.3  christos 
   1981  1.3  christos   case 99:
   1982  1.3  christos #line 345 "deffilep.y" /* yacc.c:1661  */
   1983  1.3  christos     { (yyval.vma) = (bfd_vma) strtoull ((yyvsp[0].digits), 0, 0); }
   1984  1.3  christos #line 1985 "deffilep.c" /* yacc.c:1661  */
   1985  1.1  christos     break;
   1986  1.1  christos 
   1987  1.1  christos 
   1988  1.3  christos #line 1989 "deffilep.c" /* yacc.c:1661  */
   1989  1.1  christos       default: break;
   1990  1.1  christos     }
   1991  1.3  christos   /* User semantic actions sometimes alter yychar, and that requires
   1992  1.3  christos      that yytoken be updated with the new translation.  We take the
   1993  1.3  christos      approach of translating immediately before every use of yytoken.
   1994  1.3  christos      One alternative is translating here after every semantic action,
   1995  1.3  christos      but that translation would be missed if the semantic action invokes
   1996  1.3  christos      YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
   1997  1.3  christos      if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
   1998  1.3  christos      incorrect destructor might then be invoked immediately.  In the
   1999  1.3  christos      case of YYERROR or YYBACKUP, subsequent parser actions might lead
   2000  1.3  christos      to an incorrect destructor call or verbose syntax error message
   2001  1.3  christos      before the lookahead is translated.  */
   2002  1.1  christos   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
   2003  1.1  christos 
   2004  1.1  christos   YYPOPSTACK (yylen);
   2005  1.1  christos   yylen = 0;
   2006  1.1  christos   YY_STACK_PRINT (yyss, yyssp);
   2007  1.1  christos 
   2008  1.1  christos   *++yyvsp = yyval;
   2009  1.1  christos 
   2010  1.3  christos   /* Now 'shift' the result of the reduction.  Determine what state
   2011  1.1  christos      that goes to, based on the state we popped back to and the rule
   2012  1.1  christos      number reduced by.  */
   2013  1.1  christos 
   2014  1.1  christos   yyn = yyr1[yyn];
   2015  1.1  christos 
   2016  1.1  christos   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
   2017  1.1  christos   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
   2018  1.1  christos     yystate = yytable[yystate];
   2019  1.1  christos   else
   2020  1.1  christos     yystate = yydefgoto[yyn - YYNTOKENS];
   2021  1.1  christos 
   2022  1.1  christos   goto yynewstate;
   2023  1.1  christos 
   2024  1.1  christos 
   2025  1.3  christos /*--------------------------------------.
   2026  1.3  christos | yyerrlab -- here on detecting error.  |
   2027  1.3  christos `--------------------------------------*/
   2028  1.1  christos yyerrlab:
   2029  1.3  christos   /* Make sure we have latest lookahead translation.  See comments at
   2030  1.3  christos      user semantic actions for why this is necessary.  */
   2031  1.3  christos   yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
   2032  1.3  christos 
   2033  1.1  christos   /* If not already recovering from an error, report this error.  */
   2034  1.1  christos   if (!yyerrstatus)
   2035  1.1  christos     {
   2036  1.1  christos       ++yynerrs;
   2037  1.1  christos #if ! YYERROR_VERBOSE
   2038  1.1  christos       yyerror (YY_("syntax error"));
   2039  1.1  christos #else
   2040  1.3  christos # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
   2041  1.3  christos                                         yyssp, yytoken)
   2042  1.1  christos       {
   2043  1.3  christos         char const *yymsgp = YY_("syntax error");
   2044  1.3  christos         int yysyntax_error_status;
   2045  1.3  christos         yysyntax_error_status = YYSYNTAX_ERROR;
   2046  1.3  christos         if (yysyntax_error_status == 0)
   2047  1.3  christos           yymsgp = yymsg;
   2048  1.3  christos         else if (yysyntax_error_status == 1)
   2049  1.3  christos           {
   2050  1.3  christos             if (yymsg != yymsgbuf)
   2051  1.3  christos               YYSTACK_FREE (yymsg);
   2052  1.3  christos             yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
   2053  1.3  christos             if (!yymsg)
   2054  1.3  christos               {
   2055  1.3  christos                 yymsg = yymsgbuf;
   2056  1.3  christos                 yymsg_alloc = sizeof yymsgbuf;
   2057  1.3  christos                 yysyntax_error_status = 2;
   2058  1.3  christos               }
   2059  1.3  christos             else
   2060  1.3  christos               {
   2061  1.3  christos                 yysyntax_error_status = YYSYNTAX_ERROR;
   2062  1.3  christos                 yymsgp = yymsg;
   2063  1.3  christos               }
   2064  1.3  christos           }
   2065  1.3  christos         yyerror (yymsgp);
   2066  1.3  christos         if (yysyntax_error_status == 2)
   2067  1.3  christos           goto yyexhaustedlab;
   2068  1.1  christos       }
   2069  1.3  christos # undef YYSYNTAX_ERROR
   2070  1.1  christos #endif
   2071  1.1  christos     }
   2072  1.1  christos 
   2073  1.1  christos 
   2074  1.1  christos 
   2075  1.1  christos   if (yyerrstatus == 3)
   2076  1.1  christos     {
   2077  1.3  christos       /* If just tried and failed to reuse lookahead token after an
   2078  1.3  christos          error, discard it.  */
   2079  1.1  christos 
   2080  1.1  christos       if (yychar <= YYEOF)
   2081  1.3  christos         {
   2082  1.3  christos           /* Return failure if at end of input.  */
   2083  1.3  christos           if (yychar == YYEOF)
   2084  1.3  christos             YYABORT;
   2085  1.3  christos         }
   2086  1.1  christos       else
   2087  1.3  christos         {
   2088  1.3  christos           yydestruct ("Error: discarding",
   2089  1.3  christos                       yytoken, &yylval);
   2090  1.3  christos           yychar = YYEMPTY;
   2091  1.3  christos         }
   2092  1.1  christos     }
   2093  1.1  christos 
   2094  1.3  christos   /* Else will try to reuse lookahead token after shifting the error
   2095  1.1  christos      token.  */
   2096  1.1  christos   goto yyerrlab1;
   2097  1.1  christos 
   2098  1.1  christos 
   2099  1.1  christos /*---------------------------------------------------.
   2100  1.1  christos | yyerrorlab -- error raised explicitly by YYERROR.  |
   2101  1.1  christos `---------------------------------------------------*/
   2102  1.1  christos yyerrorlab:
   2103  1.1  christos 
   2104  1.1  christos   /* Pacify compilers like GCC when the user code never invokes
   2105  1.1  christos      YYERROR and the label yyerrorlab therefore never appears in user
   2106  1.1  christos      code.  */
   2107  1.1  christos   if (/*CONSTCOND*/ 0)
   2108  1.1  christos      goto yyerrorlab;
   2109  1.1  christos 
   2110  1.3  christos   /* Do not reclaim the symbols of the rule whose action triggered
   2111  1.1  christos      this YYERROR.  */
   2112  1.1  christos   YYPOPSTACK (yylen);
   2113  1.1  christos   yylen = 0;
   2114  1.1  christos   YY_STACK_PRINT (yyss, yyssp);
   2115  1.1  christos   yystate = *yyssp;
   2116  1.1  christos   goto yyerrlab1;
   2117  1.1  christos 
   2118  1.1  christos 
   2119  1.1  christos /*-------------------------------------------------------------.
   2120  1.1  christos | yyerrlab1 -- common code for both syntax error and YYERROR.  |
   2121  1.1  christos `-------------------------------------------------------------*/
   2122  1.1  christos yyerrlab1:
   2123  1.3  christos   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
   2124  1.1  christos 
   2125  1.1  christos   for (;;)
   2126  1.1  christos     {
   2127  1.1  christos       yyn = yypact[yystate];
   2128  1.3  christos       if (!yypact_value_is_default (yyn))
   2129  1.3  christos         {
   2130  1.3  christos           yyn += YYTERROR;
   2131  1.3  christos           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
   2132  1.3  christos             {
   2133  1.3  christos               yyn = yytable[yyn];
   2134  1.3  christos               if (0 < yyn)
   2135  1.3  christos                 break;
   2136  1.3  christos             }
   2137  1.3  christos         }
   2138  1.1  christos 
   2139  1.1  christos       /* Pop the current state because it cannot handle the error token.  */
   2140  1.1  christos       if (yyssp == yyss)
   2141  1.3  christos         YYABORT;
   2142  1.1  christos 
   2143  1.1  christos 
   2144  1.1  christos       yydestruct ("Error: popping",
   2145  1.3  christos                   yystos[yystate], yyvsp);
   2146  1.1  christos       YYPOPSTACK (1);
   2147  1.1  christos       yystate = *yyssp;
   2148  1.1  christos       YY_STACK_PRINT (yyss, yyssp);
   2149  1.1  christos     }
   2150  1.1  christos 
   2151  1.3  christos   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
   2152  1.1  christos   *++yyvsp = yylval;
   2153  1.3  christos   YY_IGNORE_MAYBE_UNINITIALIZED_END
   2154  1.1  christos 
   2155  1.1  christos 
   2156  1.1  christos   /* Shift the error token.  */
   2157  1.1  christos   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
   2158  1.1  christos 
   2159  1.1  christos   yystate = yyn;
   2160  1.1  christos   goto yynewstate;
   2161  1.1  christos 
   2162  1.1  christos 
   2163  1.1  christos /*-------------------------------------.
   2164  1.1  christos | yyacceptlab -- YYACCEPT comes here.  |
   2165  1.1  christos `-------------------------------------*/
   2166  1.1  christos yyacceptlab:
   2167  1.1  christos   yyresult = 0;
   2168  1.1  christos   goto yyreturn;
   2169  1.1  christos 
   2170  1.1  christos /*-----------------------------------.
   2171  1.1  christos | yyabortlab -- YYABORT comes here.  |
   2172  1.1  christos `-----------------------------------*/
   2173  1.1  christos yyabortlab:
   2174  1.1  christos   yyresult = 1;
   2175  1.1  christos   goto yyreturn;
   2176  1.1  christos 
   2177  1.3  christos #if !defined yyoverflow || YYERROR_VERBOSE
   2178  1.1  christos /*-------------------------------------------------.
   2179  1.1  christos | yyexhaustedlab -- memory exhaustion comes here.  |
   2180  1.1  christos `-------------------------------------------------*/
   2181  1.1  christos yyexhaustedlab:
   2182  1.1  christos   yyerror (YY_("memory exhausted"));
   2183  1.1  christos   yyresult = 2;
   2184  1.1  christos   /* Fall through.  */
   2185  1.1  christos #endif
   2186  1.1  christos 
   2187  1.1  christos yyreturn:
   2188  1.3  christos   if (yychar != YYEMPTY)
   2189  1.3  christos     {
   2190  1.3  christos       /* Make sure we have latest lookahead translation.  See comments at
   2191  1.3  christos          user semantic actions for why this is necessary.  */
   2192  1.3  christos       yytoken = YYTRANSLATE (yychar);
   2193  1.3  christos       yydestruct ("Cleanup: discarding lookahead",
   2194  1.3  christos                   yytoken, &yylval);
   2195  1.3  christos     }
   2196  1.3  christos   /* Do not reclaim the symbols of the rule whose action triggered
   2197  1.1  christos      this YYABORT or YYACCEPT.  */
   2198  1.1  christos   YYPOPSTACK (yylen);
   2199  1.1  christos   YY_STACK_PRINT (yyss, yyssp);
   2200  1.1  christos   while (yyssp != yyss)
   2201  1.1  christos     {
   2202  1.1  christos       yydestruct ("Cleanup: popping",
   2203  1.3  christos                   yystos[*yyssp], yyvsp);
   2204  1.1  christos       YYPOPSTACK (1);
   2205  1.1  christos     }
   2206  1.1  christos #ifndef yyoverflow
   2207  1.1  christos   if (yyss != yyssa)
   2208  1.1  christos     YYSTACK_FREE (yyss);
   2209  1.1  christos #endif
   2210  1.1  christos #if YYERROR_VERBOSE
   2211  1.1  christos   if (yymsg != yymsgbuf)
   2212  1.1  christos     YYSTACK_FREE (yymsg);
   2213  1.1  christos #endif
   2214  1.3  christos   return yyresult;
   2215  1.1  christos }
   2216  1.3  christos #line 347 "deffilep.y" /* yacc.c:1906  */
   2217  1.1  christos 
   2218  1.1  christos 
   2219  1.1  christos /*****************************************************************************
   2220  1.1  christos  API
   2221  1.1  christos  *****************************************************************************/
   2222  1.1  christos 
   2223  1.1  christos static FILE *the_file;
   2224  1.1  christos static const char *def_filename;
   2225  1.1  christos static int linenumber;
   2226  1.1  christos static def_file *def;
   2227  1.1  christos static int saw_newline;
   2228  1.1  christos 
   2229  1.1  christos struct directive
   2230  1.1  christos   {
   2231  1.1  christos     struct directive *next;
   2232  1.1  christos     char *name;
   2233  1.1  christos     int len;
   2234  1.1  christos   };
   2235  1.1  christos 
   2236  1.1  christos static struct directive *directives = 0;
   2237  1.1  christos 
   2238  1.1  christos def_file *
   2239  1.1  christos def_file_empty (void)
   2240  1.1  christos {
   2241  1.1  christos   def_file *rv = xmalloc (sizeof (def_file));
   2242  1.1  christos   memset (rv, 0, sizeof (def_file));
   2243  1.1  christos   rv->is_dll = -1;
   2244  1.1  christos   rv->base_address = (bfd_vma) -1;
   2245  1.1  christos   rv->stack_reserve = rv->stack_commit = -1;
   2246  1.1  christos   rv->heap_reserve = rv->heap_commit = -1;
   2247  1.1  christos   rv->version_major = rv->version_minor = -1;
   2248  1.1  christos   return rv;
   2249  1.1  christos }
   2250  1.1  christos 
   2251  1.1  christos def_file *
   2252  1.1  christos def_file_parse (const char *filename, def_file *add_to)
   2253  1.1  christos {
   2254  1.1  christos   struct directive *d;
   2255  1.1  christos 
   2256  1.1  christos   the_file = fopen (filename, "r");
   2257  1.1  christos   def_filename = filename;
   2258  1.1  christos   linenumber = 1;
   2259  1.1  christos   if (!the_file)
   2260  1.1  christos     {
   2261  1.1  christos       perror (filename);
   2262  1.1  christos       return 0;
   2263  1.1  christos     }
   2264  1.1  christos   if (add_to)
   2265  1.1  christos     {
   2266  1.1  christos       def = add_to;
   2267  1.1  christos     }
   2268  1.1  christos   else
   2269  1.1  christos     {
   2270  1.1  christos       def = def_file_empty ();
   2271  1.1  christos     }
   2272  1.1  christos 
   2273  1.1  christos   saw_newline = 1;
   2274  1.1  christos   if (def_parse ())
   2275  1.1  christos     {
   2276  1.1  christos       def_file_free (def);
   2277  1.1  christos       fclose (the_file);
   2278  1.1  christos       def_pool_free ();
   2279  1.1  christos       return 0;
   2280  1.1  christos     }
   2281  1.1  christos 
   2282  1.1  christos   fclose (the_file);
   2283  1.1  christos 
   2284  1.1  christos   while ((d = directives) != NULL)
   2285  1.1  christos     {
   2286  1.1  christos #if TRACE
   2287  1.1  christos       printf ("Adding directive %08x `%s'\n", d->name, d->name);
   2288  1.1  christos #endif
   2289  1.1  christos       def_file_add_directive (def, d->name, d->len);
   2290  1.1  christos       directives = d->next;
   2291  1.1  christos       free (d->name);
   2292  1.1  christos       free (d);
   2293  1.1  christos     }
   2294  1.1  christos   def_pool_free ();
   2295  1.1  christos 
   2296  1.1  christos   return def;
   2297  1.1  christos }
   2298  1.1  christos 
   2299  1.1  christos void
   2300  1.1  christos def_file_free (def_file *fdef)
   2301  1.1  christos {
   2302  1.1  christos   int i;
   2303  1.1  christos 
   2304  1.1  christos   if (!fdef)
   2305  1.1  christos     return;
   2306  1.1  christos   if (fdef->name)
   2307  1.1  christos     free (fdef->name);
   2308  1.1  christos   if (fdef->description)
   2309  1.1  christos     free (fdef->description);
   2310  1.1  christos 
   2311  1.1  christos   if (fdef->section_defs)
   2312  1.1  christos     {
   2313  1.1  christos       for (i = 0; i < fdef->num_section_defs; i++)
   2314  1.1  christos 	{
   2315  1.1  christos 	  if (fdef->section_defs[i].name)
   2316  1.1  christos 	    free (fdef->section_defs[i].name);
   2317  1.1  christos 	  if (fdef->section_defs[i].class)
   2318  1.1  christos 	    free (fdef->section_defs[i].class);
   2319  1.1  christos 	}
   2320  1.1  christos       free (fdef->section_defs);
   2321  1.1  christos     }
   2322  1.1  christos 
   2323  1.1  christos   if (fdef->exports)
   2324  1.1  christos     {
   2325  1.1  christos       for (i = 0; i < fdef->num_exports; i++)
   2326  1.1  christos 	{
   2327  1.1  christos 	  if (fdef->exports[i].internal_name
   2328  1.1  christos 	      && fdef->exports[i].internal_name != fdef->exports[i].name)
   2329  1.1  christos 	    free (fdef->exports[i].internal_name);
   2330  1.1  christos 	  if (fdef->exports[i].name)
   2331  1.1  christos 	    free (fdef->exports[i].name);
   2332  1.1  christos 	  if (fdef->exports[i].its_name)
   2333  1.1  christos 	    free (fdef->exports[i].its_name);
   2334  1.1  christos 	}
   2335  1.1  christos       free (fdef->exports);
   2336  1.1  christos     }
   2337  1.1  christos 
   2338  1.1  christos   if (fdef->imports)
   2339  1.1  christos     {
   2340  1.1  christos       for (i = 0; i < fdef->num_imports; i++)
   2341  1.1  christos 	{
   2342  1.1  christos 	  if (fdef->imports[i].internal_name
   2343  1.1  christos 	      && fdef->imports[i].internal_name != fdef->imports[i].name)
   2344  1.1  christos 	    free (fdef->imports[i].internal_name);
   2345  1.1  christos 	  if (fdef->imports[i].name)
   2346  1.1  christos 	    free (fdef->imports[i].name);
   2347  1.1  christos 	  if (fdef->imports[i].its_name)
   2348  1.1  christos 	    free (fdef->imports[i].its_name);
   2349  1.1  christos 	}
   2350  1.1  christos       free (fdef->imports);
   2351  1.1  christos     }
   2352  1.1  christos 
   2353  1.1  christos   while (fdef->modules)
   2354  1.1  christos     {
   2355  1.1  christos       def_file_module *m = fdef->modules;
   2356  1.1  christos 
   2357  1.1  christos       fdef->modules = fdef->modules->next;
   2358  1.1  christos       free (m);
   2359  1.1  christos     }
   2360  1.1  christos 
   2361  1.1  christos   while (fdef->aligncomms)
   2362  1.1  christos     {
   2363  1.1  christos       def_file_aligncomm *c = fdef->aligncomms;
   2364  1.1  christos 
   2365  1.1  christos       fdef->aligncomms = fdef->aligncomms->next;
   2366  1.1  christos       free (c->symbol_name);
   2367  1.1  christos       free (c);
   2368  1.1  christos     }
   2369  1.1  christos 
   2370  1.1  christos   free (fdef);
   2371  1.1  christos }
   2372  1.1  christos 
   2373  1.1  christos #ifdef DEF_FILE_PRINT
   2374  1.1  christos void
   2375  1.1  christos def_file_print (FILE *file, def_file *fdef)
   2376  1.1  christos {
   2377  1.1  christos   int i;
   2378  1.1  christos 
   2379  1.1  christos   fprintf (file, ">>>> def_file at 0x%08x\n", fdef);
   2380  1.1  christos   if (fdef->name)
   2381  1.1  christos     fprintf (file, "  name: %s\n", fdef->name ? fdef->name : "(unspecified)");
   2382  1.1  christos   if (fdef->is_dll != -1)
   2383  1.1  christos     fprintf (file, "  is dll: %s\n", fdef->is_dll ? "yes" : "no");
   2384  1.1  christos   if (fdef->base_address != (bfd_vma) -1)
   2385  1.3  christos     {
   2386  1.3  christos       fprintf (file, "  base address: 0x");
   2387  1.3  christos       fprintf_vma (file, fdef->base_address);
   2388  1.3  christos       fprintf (file, "\n");
   2389  1.3  christos     }
   2390  1.1  christos   if (fdef->description)
   2391  1.1  christos     fprintf (file, "  description: `%s'\n", fdef->description);
   2392  1.1  christos   if (fdef->stack_reserve != -1)
   2393  1.1  christos     fprintf (file, "  stack reserve: 0x%08x\n", fdef->stack_reserve);
   2394  1.1  christos   if (fdef->stack_commit != -1)
   2395  1.1  christos     fprintf (file, "  stack commit: 0x%08x\n", fdef->stack_commit);
   2396  1.1  christos   if (fdef->heap_reserve != -1)
   2397  1.1  christos     fprintf (file, "  heap reserve: 0x%08x\n", fdef->heap_reserve);
   2398  1.1  christos   if (fdef->heap_commit != -1)
   2399  1.1  christos     fprintf (file, "  heap commit: 0x%08x\n", fdef->heap_commit);
   2400  1.1  christos 
   2401  1.1  christos   if (fdef->num_section_defs > 0)
   2402  1.1  christos     {
   2403  1.1  christos       fprintf (file, "  section defs:\n");
   2404  1.1  christos 
   2405  1.1  christos       for (i = 0; i < fdef->num_section_defs; i++)
   2406  1.1  christos 	{
   2407  1.1  christos 	  fprintf (file, "    name: `%s', class: `%s', flags:",
   2408  1.1  christos 		   fdef->section_defs[i].name, fdef->section_defs[i].class);
   2409  1.1  christos 	  if (fdef->section_defs[i].flag_read)
   2410  1.1  christos 	    fprintf (file, " R");
   2411  1.1  christos 	  if (fdef->section_defs[i].flag_write)
   2412  1.1  christos 	    fprintf (file, " W");
   2413  1.1  christos 	  if (fdef->section_defs[i].flag_execute)
   2414  1.1  christos 	    fprintf (file, " X");
   2415  1.1  christos 	  if (fdef->section_defs[i].flag_shared)
   2416  1.1  christos 	    fprintf (file, " S");
   2417  1.1  christos 	  fprintf (file, "\n");
   2418  1.1  christos 	}
   2419  1.1  christos     }
   2420  1.1  christos 
   2421  1.1  christos   if (fdef->num_exports > 0)
   2422  1.1  christos     {
   2423  1.1  christos       fprintf (file, "  exports:\n");
   2424  1.1  christos 
   2425  1.1  christos       for (i = 0; i < fdef->num_exports; i++)
   2426  1.1  christos 	{
   2427  1.1  christos 	  fprintf (file, "    name: `%s', int: `%s', ordinal: %d, flags:",
   2428  1.1  christos 		   fdef->exports[i].name, fdef->exports[i].internal_name,
   2429  1.1  christos 		   fdef->exports[i].ordinal);
   2430  1.1  christos 	  if (fdef->exports[i].flag_private)
   2431  1.1  christos 	    fprintf (file, " P");
   2432  1.1  christos 	  if (fdef->exports[i].flag_constant)
   2433  1.1  christos 	    fprintf (file, " C");
   2434  1.1  christos 	  if (fdef->exports[i].flag_noname)
   2435  1.1  christos 	    fprintf (file, " N");
   2436  1.1  christos 	  if (fdef->exports[i].flag_data)
   2437  1.1  christos 	    fprintf (file, " D");
   2438  1.1  christos 	  fprintf (file, "\n");
   2439  1.1  christos 	}
   2440  1.1  christos     }
   2441  1.1  christos 
   2442  1.1  christos   if (fdef->num_imports > 0)
   2443  1.1  christos     {
   2444  1.1  christos       fprintf (file, "  imports:\n");
   2445  1.1  christos 
   2446  1.1  christos       for (i = 0; i < fdef->num_imports; i++)
   2447  1.1  christos 	{
   2448  1.1  christos 	  fprintf (file, "    int: %s, from: `%s', name: `%s', ordinal: %d\n",
   2449  1.1  christos 		   fdef->imports[i].internal_name,
   2450  1.1  christos 		   fdef->imports[i].module,
   2451  1.1  christos 		   fdef->imports[i].name,
   2452  1.1  christos 		   fdef->imports[i].ordinal);
   2453  1.1  christos 	}
   2454  1.1  christos     }
   2455  1.1  christos 
   2456  1.1  christos   if (fdef->version_major != -1)
   2457  1.1  christos     fprintf (file, "  version: %d.%d\n", fdef->version_major, fdef->version_minor);
   2458  1.1  christos 
   2459  1.1  christos   fprintf (file, "<<<< def_file at 0x%08x\n", fdef);
   2460  1.1  christos }
   2461  1.1  christos #endif
   2462  1.1  christos 
   2463  1.1  christos /* Helper routine to check for identity of string pointers,
   2464  1.1  christos    which might be NULL.  */
   2465  1.1  christos 
   2466  1.1  christos static int
   2467  1.1  christos are_names_equal (const char *s1, const char *s2)
   2468  1.1  christos {
   2469  1.1  christos   if (!s1 && !s2)
   2470  1.1  christos     return 0;
   2471  1.1  christos   if (!s1 || !s2)
   2472  1.1  christos     return (!s1 ? -1 : 1);
   2473  1.1  christos   return strcmp (s1, s2);
   2474  1.1  christos }
   2475  1.1  christos 
   2476  1.1  christos static int
   2477  1.1  christos cmp_export_elem (const def_file_export *e, const char *ex_name,
   2478  1.1  christos 		 const char *in_name, const char *its_name,
   2479  1.1  christos 		 int ord)
   2480  1.1  christos {
   2481  1.1  christos   int r;
   2482  1.1  christos 
   2483  1.1  christos   if ((r = are_names_equal (ex_name, e->name)) != 0)
   2484  1.1  christos     return r;
   2485  1.1  christos   if ((r = are_names_equal (in_name, e->internal_name)) != 0)
   2486  1.1  christos     return r;
   2487  1.1  christos   if ((r = are_names_equal (its_name, e->its_name)) != 0)
   2488  1.1  christos     return r;
   2489  1.1  christos   return (ord - e->ordinal);
   2490  1.1  christos }
   2491  1.1  christos 
   2492  1.1  christos /* Search the position of the identical element, or returns the position
   2493  1.1  christos    of the next higher element. If last valid element is smaller, then MAX
   2494  1.1  christos    is returned.  */
   2495  1.1  christos 
   2496  1.1  christos static int
   2497  1.1  christos find_export_in_list (def_file_export *b, int max,
   2498  1.1  christos 		     const char *ex_name, const char *in_name,
   2499  1.1  christos 		     const char *its_name, int ord, int *is_ident)
   2500  1.1  christos {
   2501  1.1  christos   int e, l, r, p;
   2502  1.1  christos 
   2503  1.1  christos   *is_ident = 0;
   2504  1.1  christos   if (!max)
   2505  1.1  christos     return 0;
   2506  1.1  christos   if ((e = cmp_export_elem (b, ex_name, in_name, its_name, ord)) <= 0)
   2507  1.1  christos     {
   2508  1.1  christos       if (!e)
   2509  1.1  christos         *is_ident = 1;
   2510  1.1  christos       return 0;
   2511  1.1  christos     }
   2512  1.1  christos   if (max == 1)
   2513  1.1  christos     return 1;
   2514  1.1  christos   if ((e = cmp_export_elem (b + (max - 1), ex_name, in_name, its_name, ord)) > 0)
   2515  1.1  christos     return max;
   2516  1.1  christos   else if (!e || max == 2)
   2517  1.1  christos     {
   2518  1.1  christos       if (!e)
   2519  1.1  christos 	*is_ident = 1;
   2520  1.1  christos       return max - 1;
   2521  1.1  christos     }
   2522  1.1  christos   l = 0; r = max - 1;
   2523  1.1  christos   while (l < r)
   2524  1.1  christos     {
   2525  1.1  christos       p = (l + r) / 2;
   2526  1.1  christos       e = cmp_export_elem (b + p, ex_name, in_name, its_name, ord);
   2527  1.1  christos       if (!e)
   2528  1.1  christos         {
   2529  1.1  christos           *is_ident = 1;
   2530  1.1  christos           return p;
   2531  1.1  christos         }
   2532  1.1  christos       else if (e < 0)
   2533  1.1  christos         r = p - 1;
   2534  1.1  christos       else if (e > 0)
   2535  1.1  christos         l = p + 1;
   2536  1.1  christos     }
   2537  1.1  christos   if ((e = cmp_export_elem (b + l, ex_name, in_name, its_name, ord)) > 0)
   2538  1.1  christos     ++l;
   2539  1.1  christos   else if (!e)
   2540  1.1  christos     *is_ident = 1;
   2541  1.1  christos   return l;
   2542  1.1  christos }
   2543  1.1  christos 
   2544  1.1  christos def_file_export *
   2545  1.1  christos def_file_add_export (def_file *fdef,
   2546  1.1  christos 		     const char *external_name,
   2547  1.1  christos 		     const char *internal_name,
   2548  1.1  christos 		     int ordinal,
   2549  1.1  christos 		     const char *its_name,
   2550  1.1  christos 		     int *is_dup)
   2551  1.1  christos {
   2552  1.1  christos   def_file_export *e;
   2553  1.1  christos   int pos;
   2554  1.1  christos   int max_exports = ROUND_UP(fdef->num_exports, 32);
   2555  1.1  christos 
   2556  1.1  christos   if (internal_name && !external_name)
   2557  1.1  christos     external_name = internal_name;
   2558  1.1  christos   if (external_name && !internal_name)
   2559  1.1  christos     internal_name = external_name;
   2560  1.1  christos 
   2561  1.1  christos   /* We need to avoid duplicates.  */
   2562  1.1  christos   *is_dup = 0;
   2563  1.1  christos   pos = find_export_in_list (fdef->exports, fdef->num_exports,
   2564  1.1  christos 		     external_name, internal_name,
   2565  1.1  christos 		     its_name, ordinal, is_dup);
   2566  1.1  christos 
   2567  1.1  christos   if (*is_dup != 0)
   2568  1.1  christos     return (fdef->exports + pos);
   2569  1.1  christos 
   2570  1.1  christos   if (fdef->num_exports >= max_exports)
   2571  1.1  christos     {
   2572  1.1  christos       max_exports = ROUND_UP(fdef->num_exports + 1, 32);
   2573  1.1  christos       if (fdef->exports)
   2574  1.1  christos 	fdef->exports = xrealloc (fdef->exports,
   2575  1.1  christos 				 max_exports * sizeof (def_file_export));
   2576  1.1  christos       else
   2577  1.1  christos 	fdef->exports = xmalloc (max_exports * sizeof (def_file_export));
   2578  1.1  christos     }
   2579  1.1  christos 
   2580  1.1  christos   e = fdef->exports + pos;
   2581  1.1  christos   if (pos != fdef->num_exports)
   2582  1.1  christos     memmove (&e[1], e, (sizeof (def_file_export) * (fdef->num_exports - pos)));
   2583  1.1  christos   memset (e, 0, sizeof (def_file_export));
   2584  1.1  christos   e->name = xstrdup (external_name);
   2585  1.1  christos   e->internal_name = xstrdup (internal_name);
   2586  1.1  christos   e->its_name = (its_name ? xstrdup (its_name) : NULL);
   2587  1.1  christos   e->ordinal = ordinal;
   2588  1.1  christos   fdef->num_exports++;
   2589  1.1  christos   return e;
   2590  1.1  christos }
   2591  1.1  christos 
   2592  1.1  christos def_file_module *
   2593  1.1  christos def_get_module (def_file *fdef, const char *name)
   2594  1.1  christos {
   2595  1.1  christos   def_file_module *s;
   2596  1.1  christos 
   2597  1.1  christos   for (s = fdef->modules; s; s = s->next)
   2598  1.1  christos     if (strcmp (s->name, name) == 0)
   2599  1.1  christos       return s;
   2600  1.1  christos 
   2601  1.1  christos   return NULL;
   2602  1.1  christos }
   2603  1.1  christos 
   2604  1.1  christos static def_file_module *
   2605  1.1  christos def_stash_module (def_file *fdef, const char *name)
   2606  1.1  christos {
   2607  1.1  christos   def_file_module *s;
   2608  1.1  christos 
   2609  1.1  christos   if ((s = def_get_module (fdef, name)) != NULL)
   2610  1.1  christos       return s;
   2611  1.1  christos   s = xmalloc (sizeof (def_file_module) + strlen (name));
   2612  1.1  christos   s->next = fdef->modules;
   2613  1.1  christos   fdef->modules = s;
   2614  1.1  christos   s->user_data = 0;
   2615  1.1  christos   strcpy (s->name, name);
   2616  1.1  christos   return s;
   2617  1.1  christos }
   2618  1.1  christos 
   2619  1.1  christos static int
   2620  1.1  christos cmp_import_elem (const def_file_import *e, const char *ex_name,
   2621  1.1  christos 		 const char *in_name, const char *module,
   2622  1.1  christos 		 int ord)
   2623  1.1  christos {
   2624  1.1  christos   int r;
   2625  1.1  christos 
   2626  1.1  christos   if ((r = are_names_equal (module, (e->module ? e->module->name : NULL))))
   2627  1.1  christos     return r;
   2628  1.1  christos   if ((r = are_names_equal (ex_name, e->name)) != 0)
   2629  1.1  christos     return r;
   2630  1.1  christos   if ((r = are_names_equal (in_name, e->internal_name)) != 0)
   2631  1.1  christos     return r;
   2632  1.1  christos   if (ord != e->ordinal)
   2633  1.1  christos     return (ord < e->ordinal ? -1 : 1);
   2634  1.1  christos   return 0;
   2635  1.1  christos }
   2636  1.1  christos 
   2637  1.1  christos /* Search the position of the identical element, or returns the position
   2638  1.1  christos    of the next higher element. If last valid element is smaller, then MAX
   2639  1.1  christos    is returned.  */
   2640  1.1  christos 
   2641  1.1  christos static int
   2642  1.1  christos find_import_in_list (def_file_import *b, int max,
   2643  1.1  christos 		     const char *ex_name, const char *in_name,
   2644  1.1  christos 		     const char *module, int ord, int *is_ident)
   2645  1.1  christos {
   2646  1.1  christos   int e, l, r, p;
   2647  1.1  christos 
   2648  1.1  christos   *is_ident = 0;
   2649  1.1  christos   if (!max)
   2650  1.1  christos     return 0;
   2651  1.1  christos   if ((e = cmp_import_elem (b, ex_name, in_name, module, ord)) <= 0)
   2652  1.1  christos     {
   2653  1.1  christos       if (!e)
   2654  1.1  christos         *is_ident = 1;
   2655  1.1  christos       return 0;
   2656  1.1  christos     }
   2657  1.1  christos   if (max == 1)
   2658  1.1  christos     return 1;
   2659  1.1  christos   if ((e = cmp_import_elem (b + (max - 1), ex_name, in_name, module, ord)) > 0)
   2660  1.1  christos     return max;
   2661  1.1  christos   else if (!e || max == 2)
   2662  1.1  christos     {
   2663  1.1  christos       if (!e)
   2664  1.1  christos         *is_ident = 1;
   2665  1.1  christos       return max - 1;
   2666  1.1  christos     }
   2667  1.1  christos   l = 0; r = max - 1;
   2668  1.1  christos   while (l < r)
   2669  1.1  christos     {
   2670  1.1  christos       p = (l + r) / 2;
   2671  1.1  christos       e = cmp_import_elem (b + p, ex_name, in_name, module, ord);
   2672  1.1  christos       if (!e)
   2673  1.1  christos         {
   2674  1.1  christos           *is_ident = 1;
   2675  1.1  christos           return p;
   2676  1.1  christos         }
   2677  1.1  christos       else if (e < 0)
   2678  1.1  christos         r = p - 1;
   2679  1.1  christos       else if (e > 0)
   2680  1.1  christos         l = p + 1;
   2681  1.1  christos     }
   2682  1.1  christos   if ((e = cmp_import_elem (b + l, ex_name, in_name, module, ord)) > 0)
   2683  1.1  christos     ++l;
   2684  1.1  christos   else if (!e)
   2685  1.1  christos     *is_ident = 1;
   2686  1.1  christos   return l;
   2687  1.1  christos }
   2688  1.1  christos 
   2689  1.1  christos def_file_import *
   2690  1.1  christos def_file_add_import (def_file *fdef,
   2691  1.1  christos 		     const char *name,
   2692  1.1  christos 		     const char *module,
   2693  1.1  christos 		     int ordinal,
   2694  1.1  christos 		     const char *internal_name,
   2695  1.1  christos 		     const char *its_name,
   2696  1.1  christos 		     int *is_dup)
   2697  1.1  christos {
   2698  1.1  christos   def_file_import *i;
   2699  1.1  christos   int pos;
   2700  1.1  christos   int max_imports = ROUND_UP (fdef->num_imports, 16);
   2701  1.1  christos 
   2702  1.1  christos   /* We need to avoid here duplicates.  */
   2703  1.1  christos   *is_dup = 0;
   2704  1.1  christos   pos = find_import_in_list (fdef->imports, fdef->num_imports,
   2705  1.1  christos 			     name,
   2706  1.1  christos 			     (!internal_name ? name : internal_name),
   2707  1.1  christos 			     module, ordinal, is_dup);
   2708  1.1  christos   if (*is_dup != 0)
   2709  1.1  christos     return fdef->imports + pos;
   2710  1.1  christos 
   2711  1.1  christos   if (fdef->num_imports >= max_imports)
   2712  1.1  christos     {
   2713  1.1  christos       max_imports = ROUND_UP (fdef->num_imports+1, 16);
   2714  1.1  christos 
   2715  1.1  christos       if (fdef->imports)
   2716  1.1  christos 	fdef->imports = xrealloc (fdef->imports,
   2717  1.1  christos 				 max_imports * sizeof (def_file_import));
   2718  1.1  christos       else
   2719  1.1  christos 	fdef->imports = xmalloc (max_imports * sizeof (def_file_import));
   2720  1.1  christos     }
   2721  1.1  christos   i = fdef->imports + pos;
   2722  1.1  christos   if (pos != fdef->num_imports)
   2723  1.1  christos     memmove (&i[1], i, (sizeof (def_file_import) * (fdef->num_imports - pos)));
   2724  1.1  christos   memset (i, 0, sizeof (def_file_import));
   2725  1.1  christos   if (name)
   2726  1.1  christos     i->name = xstrdup (name);
   2727  1.1  christos   if (module)
   2728  1.1  christos     i->module = def_stash_module (fdef, module);
   2729  1.1  christos   i->ordinal = ordinal;
   2730  1.1  christos   if (internal_name)
   2731  1.1  christos     i->internal_name = xstrdup (internal_name);
   2732  1.1  christos   else
   2733  1.1  christos     i->internal_name = i->name;
   2734  1.1  christos   i->its_name = (its_name ? xstrdup (its_name) : NULL);
   2735  1.1  christos   fdef->num_imports++;
   2736  1.1  christos 
   2737  1.1  christos   return i;
   2738  1.1  christos }
   2739  1.1  christos 
   2740  1.1  christos struct
   2741  1.1  christos {
   2742  1.1  christos   char *param;
   2743  1.1  christos   int token;
   2744  1.1  christos }
   2745  1.1  christos diropts[] =
   2746  1.1  christos {
   2747  1.1  christos   { "-heap", HEAPSIZE },
   2748  1.1  christos   { "-stack", STACKSIZE_K },
   2749  1.1  christos   { "-attr", SECTIONS },
   2750  1.1  christos   { "-export", EXPORTS },
   2751  1.1  christos   { "-aligncomm", ALIGNCOMM },
   2752  1.1  christos   { 0, 0 }
   2753  1.1  christos };
   2754  1.1  christos 
   2755  1.1  christos void
   2756  1.1  christos def_file_add_directive (def_file *my_def, const char *param, int len)
   2757  1.1  christos {
   2758  1.1  christos   def_file *save_def = def;
   2759  1.1  christos   const char *pend = param + len;
   2760  1.1  christos   char * tend = (char *) param;
   2761  1.1  christos   int i;
   2762  1.1  christos 
   2763  1.1  christos   def = my_def;
   2764  1.1  christos 
   2765  1.1  christos   while (param < pend)
   2766  1.1  christos     {
   2767  1.1  christos       while (param < pend
   2768  1.1  christos 	     && (ISSPACE (*param) || *param == '\n' || *param == 0))
   2769  1.1  christos 	param++;
   2770  1.1  christos 
   2771  1.1  christos       if (param == pend)
   2772  1.1  christos 	break;
   2773  1.1  christos 
   2774  1.1  christos       /* Scan forward until we encounter any of:
   2775  1.1  christos           - the end of the buffer
   2776  1.1  christos 	  - the start of a new option
   2777  1.1  christos 	  - a newline seperating options
   2778  1.1  christos           - a NUL seperating options.  */
   2779  1.1  christos       for (tend = (char *) (param + 1);
   2780  1.1  christos 	   (tend < pend
   2781  1.1  christos 	    && !(ISSPACE (tend[-1]) && *tend == '-')
   2782  1.1  christos 	    && *tend != '\n' && *tend != 0);
   2783  1.1  christos 	   tend++)
   2784  1.1  christos 	;
   2785  1.1  christos 
   2786  1.1  christos       for (i = 0; diropts[i].param; i++)
   2787  1.1  christos 	{
   2788  1.1  christos 	  len = strlen (diropts[i].param);
   2789  1.1  christos 
   2790  1.1  christos 	  if (tend - param >= len
   2791  1.1  christos 	      && strncmp (param, diropts[i].param, len) == 0
   2792  1.1  christos 	      && (param[len] == ':' || param[len] == ' '))
   2793  1.1  christos 	    {
   2794  1.1  christos 	      lex_parse_string_end = tend;
   2795  1.1  christos 	      lex_parse_string = param + len + 1;
   2796  1.1  christos 	      lex_forced_token = diropts[i].token;
   2797  1.1  christos 	      saw_newline = 0;
   2798  1.1  christos 	      if (def_parse ())
   2799  1.1  christos 		continue;
   2800  1.1  christos 	      break;
   2801  1.1  christos 	    }
   2802  1.1  christos 	}
   2803  1.1  christos 
   2804  1.1  christos       if (!diropts[i].param)
   2805  1.1  christos 	{
   2806  1.3  christos 	  if (tend < pend)
   2807  1.3  christos 	    {
   2808  1.3  christos 	      char saved;
   2809  1.1  christos 
   2810  1.3  christos 	      saved = * tend;
   2811  1.3  christos 	      * tend = 0;
   2812  1.3  christos 	      /* xgettext:c-format */
   2813  1.3  christos 	      einfo (_("Warning: .drectve `%s' unrecognized\n"), param);
   2814  1.3  christos 	      * tend = saved;
   2815  1.3  christos 	    }
   2816  1.3  christos 	  else
   2817  1.3  christos 	    {
   2818  1.3  christos 	      einfo (_("Warning: corrupt .drectve at end of def file\n"));
   2819  1.3  christos 	    }
   2820  1.1  christos 	}
   2821  1.1  christos 
   2822  1.1  christos       lex_parse_string = 0;
   2823  1.1  christos       param = tend;
   2824  1.1  christos     }
   2825  1.1  christos 
   2826  1.1  christos   def = save_def;
   2827  1.1  christos   def_pool_free ();
   2828  1.1  christos }
   2829  1.1  christos 
   2830  1.1  christos /* Parser Callbacks.  */
   2831  1.1  christos 
   2832  1.1  christos static void
   2833  1.3  christos def_image_name (const char *name, bfd_vma base, int is_dll)
   2834  1.1  christos {
   2835  1.1  christos   /* If a LIBRARY or NAME statement is specified without a name, there is nothing
   2836  1.1  christos      to do here.  We retain the output filename specified on command line.  */
   2837  1.1  christos   if (*name)
   2838  1.1  christos     {
   2839  1.1  christos       const char* image_name = lbasename (name);
   2840  1.1  christos 
   2841  1.1  christos       if (image_name != name)
   2842  1.1  christos 	einfo ("%s:%d: Warning: path components stripped from %s, '%s'\n",
   2843  1.1  christos 	       def_filename, linenumber, is_dll ? "LIBRARY" : "NAME",
   2844  1.1  christos 	       name);
   2845  1.1  christos       if (def->name)
   2846  1.1  christos 	free (def->name);
   2847  1.3  christos       /* Append the default suffix, if none specified.  */
   2848  1.1  christos       if (strchr (image_name, '.') == 0)
   2849  1.1  christos 	{
   2850  1.1  christos 	  const char * suffix = is_dll ? ".dll" : ".exe";
   2851  1.1  christos 
   2852  1.1  christos 	  def->name = xmalloc (strlen (image_name) + strlen (suffix) + 1);
   2853  1.1  christos 	  sprintf (def->name, "%s%s", image_name, suffix);
   2854  1.1  christos         }
   2855  1.1  christos       else
   2856  1.1  christos 	def->name = xstrdup (image_name);
   2857  1.1  christos     }
   2858  1.1  christos 
   2859  1.1  christos   /* Honor a BASE address statement, even if LIBRARY string is empty.  */
   2860  1.1  christos   def->base_address = base;
   2861  1.1  christos   def->is_dll = is_dll;
   2862  1.1  christos }
   2863  1.1  christos 
   2864  1.1  christos static void
   2865  1.1  christos def_description (const char *text)
   2866  1.1  christos {
   2867  1.1  christos   int len = def->description ? strlen (def->description) : 0;
   2868  1.1  christos 
   2869  1.1  christos   len += strlen (text) + 1;
   2870  1.1  christos   if (def->description)
   2871  1.1  christos     {
   2872  1.1  christos       def->description = xrealloc (def->description, len);
   2873  1.1  christos       strcat (def->description, text);
   2874  1.1  christos     }
   2875  1.1  christos   else
   2876  1.1  christos     {
   2877  1.1  christos       def->description = xmalloc (len);
   2878  1.1  christos       strcpy (def->description, text);
   2879  1.1  christos     }
   2880  1.1  christos }
   2881  1.1  christos 
   2882  1.1  christos static void
   2883  1.1  christos def_stacksize (int reserve, int commit)
   2884  1.1  christos {
   2885  1.1  christos   def->stack_reserve = reserve;
   2886  1.1  christos   def->stack_commit = commit;
   2887  1.1  christos }
   2888  1.1  christos 
   2889  1.1  christos static void
   2890  1.1  christos def_heapsize (int reserve, int commit)
   2891  1.1  christos {
   2892  1.1  christos   def->heap_reserve = reserve;
   2893  1.1  christos   def->heap_commit = commit;
   2894  1.1  christos }
   2895  1.1  christos 
   2896  1.1  christos static void
   2897  1.1  christos def_section (const char *name, int attr)
   2898  1.1  christos {
   2899  1.1  christos   def_file_section *s;
   2900  1.1  christos   int max_sections = ROUND_UP (def->num_section_defs, 4);
   2901  1.1  christos 
   2902  1.1  christos   if (def->num_section_defs >= max_sections)
   2903  1.1  christos     {
   2904  1.1  christos       max_sections = ROUND_UP (def->num_section_defs+1, 4);
   2905  1.1  christos 
   2906  1.1  christos       if (def->section_defs)
   2907  1.1  christos 	def->section_defs = xrealloc (def->section_defs,
   2908  1.1  christos 				      max_sections * sizeof (def_file_import));
   2909  1.1  christos       else
   2910  1.1  christos 	def->section_defs = xmalloc (max_sections * sizeof (def_file_import));
   2911  1.1  christos     }
   2912  1.1  christos   s = def->section_defs + def->num_section_defs;
   2913  1.1  christos   memset (s, 0, sizeof (def_file_section));
   2914  1.1  christos   s->name = xstrdup (name);
   2915  1.1  christos   if (attr & 1)
   2916  1.1  christos     s->flag_read = 1;
   2917  1.1  christos   if (attr & 2)
   2918  1.1  christos     s->flag_write = 1;
   2919  1.1  christos   if (attr & 4)
   2920  1.1  christos     s->flag_execute = 1;
   2921  1.1  christos   if (attr & 8)
   2922  1.1  christos     s->flag_shared = 1;
   2923  1.1  christos 
   2924  1.1  christos   def->num_section_defs++;
   2925  1.1  christos }
   2926  1.1  christos 
   2927  1.1  christos static void
   2928  1.1  christos def_section_alt (const char *name, const char *attr)
   2929  1.1  christos {
   2930  1.1  christos   int aval = 0;
   2931  1.1  christos 
   2932  1.1  christos   for (; *attr; attr++)
   2933  1.1  christos     {
   2934  1.1  christos       switch (*attr)
   2935  1.1  christos 	{
   2936  1.1  christos 	case 'R':
   2937  1.1  christos 	case 'r':
   2938  1.1  christos 	  aval |= 1;
   2939  1.1  christos 	  break;
   2940  1.1  christos 	case 'W':
   2941  1.1  christos 	case 'w':
   2942  1.1  christos 	  aval |= 2;
   2943  1.1  christos 	  break;
   2944  1.1  christos 	case 'X':
   2945  1.1  christos 	case 'x':
   2946  1.1  christos 	  aval |= 4;
   2947  1.1  christos 	  break;
   2948  1.1  christos 	case 'S':
   2949  1.1  christos 	case 's':
   2950  1.1  christos 	  aval |= 8;
   2951  1.1  christos 	  break;
   2952  1.1  christos 	}
   2953  1.1  christos     }
   2954  1.1  christos   def_section (name, aval);
   2955  1.1  christos }
   2956  1.1  christos 
   2957  1.1  christos static void
   2958  1.1  christos def_exports (const char *external_name,
   2959  1.1  christos 	     const char *internal_name,
   2960  1.1  christos 	     int ordinal,
   2961  1.1  christos 	     int flags,
   2962  1.1  christos 	     const char *its_name)
   2963  1.1  christos {
   2964  1.1  christos   def_file_export *dfe;
   2965  1.1  christos   int is_dup = 0;
   2966  1.1  christos 
   2967  1.1  christos   if (!internal_name && external_name)
   2968  1.1  christos     internal_name = external_name;
   2969  1.1  christos #if TRACE
   2970  1.1  christos   printf ("def_exports, ext=%s int=%s\n", external_name, internal_name);
   2971  1.1  christos #endif
   2972  1.1  christos 
   2973  1.1  christos   dfe = def_file_add_export (def, external_name, internal_name, ordinal,
   2974  1.1  christos 			     its_name, &is_dup);
   2975  1.1  christos 
   2976  1.1  christos   /* We might check here for flag redefinition and warn.  For now we
   2977  1.1  christos      ignore duplicates silently.  */
   2978  1.1  christos   if (is_dup)
   2979  1.1  christos     return;
   2980  1.1  christos 
   2981  1.1  christos   if (flags & 1)
   2982  1.1  christos     dfe->flag_noname = 1;
   2983  1.1  christos   if (flags & 2)
   2984  1.1  christos     dfe->flag_constant = 1;
   2985  1.1  christos   if (flags & 4)
   2986  1.1  christos     dfe->flag_data = 1;
   2987  1.1  christos   if (flags & 8)
   2988  1.1  christos     dfe->flag_private = 1;
   2989  1.1  christos }
   2990  1.1  christos 
   2991  1.1  christos static void
   2992  1.1  christos def_import (const char *internal_name,
   2993  1.1  christos 	    const char *module,
   2994  1.1  christos 	    const char *dllext,
   2995  1.1  christos 	    const char *name,
   2996  1.1  christos 	    int ordinal,
   2997  1.1  christos 	    const char *its_name)
   2998  1.1  christos {
   2999  1.1  christos   char *buf = 0;
   3000  1.1  christos   const char *ext = dllext ? dllext : "dll";
   3001  1.1  christos   int is_dup = 0;
   3002  1.3  christos 
   3003  1.1  christos   buf = xmalloc (strlen (module) + strlen (ext) + 2);
   3004  1.1  christos   sprintf (buf, "%s.%s", module, ext);
   3005  1.1  christos   module = buf;
   3006  1.1  christos 
   3007  1.1  christos   def_file_add_import (def, name, module, ordinal, internal_name, its_name,
   3008  1.1  christos 		       &is_dup);
   3009  1.1  christos   free (buf);
   3010  1.1  christos }
   3011  1.1  christos 
   3012  1.1  christos static void
   3013  1.1  christos def_version (int major, int minor)
   3014  1.1  christos {
   3015  1.1  christos   def->version_major = major;
   3016  1.1  christos   def->version_minor = minor;
   3017  1.1  christos }
   3018  1.1  christos 
   3019  1.1  christos static void
   3020  1.1  christos def_directive (char *str)
   3021  1.1  christos {
   3022  1.1  christos   struct directive *d = xmalloc (sizeof (struct directive));
   3023  1.1  christos 
   3024  1.1  christos   d->next = directives;
   3025  1.1  christos   directives = d;
   3026  1.1  christos   d->name = xstrdup (str);
   3027  1.1  christos   d->len = strlen (str);
   3028  1.1  christos }
   3029  1.1  christos 
   3030  1.1  christos static void
   3031  1.1  christos def_aligncomm (char *str, int align)
   3032  1.1  christos {
   3033  1.1  christos   def_file_aligncomm *c, *p;
   3034  1.3  christos 
   3035  1.1  christos   p = NULL;
   3036  1.1  christos   c = def->aligncomms;
   3037  1.1  christos   while (c != NULL)
   3038  1.1  christos     {
   3039  1.1  christos       int e = strcmp (c->symbol_name, str);
   3040  1.1  christos       if (!e)
   3041  1.1  christos 	{
   3042  1.1  christos 	  /* Not sure if we want to allow here duplicates with
   3043  1.1  christos 	     different alignments, but for now we keep them.  */
   3044  1.1  christos 	  e = (int) c->alignment - align;
   3045  1.1  christos 	  if (!e)
   3046  1.1  christos 	    return;
   3047  1.1  christos 	}
   3048  1.1  christos       if (e > 0)
   3049  1.1  christos         break;
   3050  1.1  christos       c = (p = c)->next;
   3051  1.1  christos     }
   3052  1.1  christos 
   3053  1.1  christos   c = xmalloc (sizeof (def_file_aligncomm));
   3054  1.1  christos   c->symbol_name = xstrdup (str);
   3055  1.1  christos   c->alignment = (unsigned int) align;
   3056  1.1  christos   if (!p)
   3057  1.1  christos     {
   3058  1.1  christos       c->next = def->aligncomms;
   3059  1.1  christos       def->aligncomms = c;
   3060  1.1  christos     }
   3061  1.1  christos   else
   3062  1.1  christos     {
   3063  1.1  christos       c->next = p->next;
   3064  1.1  christos       p->next = c;
   3065  1.1  christos     }
   3066  1.1  christos }
   3067  1.1  christos 
   3068  1.1  christos static int
   3069  1.1  christos def_error (const char *err)
   3070  1.1  christos {
   3071  1.1  christos   einfo ("%P: %s:%d: %s\n",
   3072  1.1  christos 	 def_filename ? def_filename : "<unknown-file>", linenumber, err);
   3073  1.1  christos   return 0;
   3074  1.1  christos }
   3075  1.1  christos 
   3076  1.1  christos 
   3077  1.1  christos /* Lexical Scanner.  */
   3078  1.1  christos 
   3079  1.1  christos #undef TRACE
   3080  1.1  christos #define TRACE 0
   3081  1.1  christos 
   3082  1.1  christos /* Never freed, but always reused as needed, so no real leak.  */
   3083  1.1  christos static char *buffer = 0;
   3084  1.1  christos static int buflen = 0;
   3085  1.1  christos static int bufptr = 0;
   3086  1.1  christos 
   3087  1.1  christos static void
   3088  1.1  christos put_buf (char c)
   3089  1.1  christos {
   3090  1.1  christos   if (bufptr == buflen)
   3091  1.1  christos     {
   3092  1.1  christos       buflen += 50;		/* overly reasonable, eh?  */
   3093  1.1  christos       if (buffer)
   3094  1.1  christos 	buffer = xrealloc (buffer, buflen + 1);
   3095  1.1  christos       else
   3096  1.1  christos 	buffer = xmalloc (buflen + 1);
   3097  1.1  christos     }
   3098  1.1  christos   buffer[bufptr++] = c;
   3099  1.1  christos   buffer[bufptr] = 0;		/* not optimal, but very convenient.  */
   3100  1.1  christos }
   3101  1.1  christos 
   3102  1.1  christos static struct
   3103  1.1  christos {
   3104  1.1  christos   char *name;
   3105  1.1  christos   int token;
   3106  1.1  christos }
   3107  1.1  christos tokens[] =
   3108  1.1  christos {
   3109  1.1  christos   { "BASE", BASE },
   3110  1.1  christos   { "CODE", CODE },
   3111  1.1  christos   { "CONSTANT", CONSTANTU },
   3112  1.1  christos   { "constant", CONSTANTL },
   3113  1.1  christos   { "DATA", DATAU },
   3114  1.1  christos   { "data", DATAL },
   3115  1.1  christos   { "DESCRIPTION", DESCRIPTION },
   3116  1.1  christos   { "DIRECTIVE", DIRECTIVE },
   3117  1.1  christos   { "EXECUTE", EXECUTE },
   3118  1.1  christos   { "EXPORTS", EXPORTS },
   3119  1.1  christos   { "HEAPSIZE", HEAPSIZE },
   3120  1.1  christos   { "IMPORTS", IMPORTS },
   3121  1.1  christos   { "LIBRARY", LIBRARY },
   3122  1.1  christos   { "NAME", NAME },
   3123  1.1  christos   { "NONAME", NONAMEU },
   3124  1.1  christos   { "noname", NONAMEL },
   3125  1.1  christos   { "PRIVATE", PRIVATEU },
   3126  1.1  christos   { "private", PRIVATEL },
   3127  1.1  christos   { "READ", READ },
   3128  1.1  christos   { "SECTIONS", SECTIONS },
   3129  1.1  christos   { "SEGMENTS", SECTIONS },
   3130  1.1  christos   { "SHARED", SHARED },
   3131  1.1  christos   { "STACKSIZE", STACKSIZE_K },
   3132  1.1  christos   { "VERSION", VERSIONK },
   3133  1.1  christos   { "WRITE", WRITE },
   3134  1.1  christos   { 0, 0 }
   3135  1.1  christos };
   3136  1.1  christos 
   3137  1.1  christos static int
   3138  1.1  christos def_getc (void)
   3139  1.1  christos {
   3140  1.1  christos   int rv;
   3141  1.1  christos 
   3142  1.1  christos   if (lex_parse_string)
   3143  1.1  christos     {
   3144  1.1  christos       if (lex_parse_string >= lex_parse_string_end)
   3145  1.1  christos 	rv = EOF;
   3146  1.1  christos       else
   3147  1.1  christos 	rv = *lex_parse_string++;
   3148  1.1  christos     }
   3149  1.1  christos   else
   3150  1.1  christos     {
   3151  1.1  christos       rv = fgetc (the_file);
   3152  1.1  christos     }
   3153  1.1  christos   if (rv == '\n')
   3154  1.1  christos     saw_newline = 1;
   3155  1.1  christos   return rv;
   3156  1.1  christos }
   3157  1.1  christos 
   3158  1.1  christos static int
   3159  1.1  christos def_ungetc (int c)
   3160  1.1  christos {
   3161  1.1  christos   if (lex_parse_string)
   3162  1.1  christos     {
   3163  1.1  christos       lex_parse_string--;
   3164  1.1  christos       return c;
   3165  1.1  christos     }
   3166  1.1  christos   else
   3167  1.1  christos     return ungetc (c, the_file);
   3168  1.1  christos }
   3169  1.1  christos 
   3170  1.1  christos static int
   3171  1.1  christos def_lex (void)
   3172  1.1  christos {
   3173  1.1  christos   int c, i, q;
   3174  1.1  christos 
   3175  1.1  christos   if (lex_forced_token)
   3176  1.1  christos     {
   3177  1.1  christos       i = lex_forced_token;
   3178  1.1  christos       lex_forced_token = 0;
   3179  1.1  christos #if TRACE
   3180  1.1  christos       printf ("lex: forcing token %d\n", i);
   3181  1.1  christos #endif
   3182  1.1  christos       return i;
   3183  1.1  christos     }
   3184  1.1  christos 
   3185  1.1  christos   c = def_getc ();
   3186  1.1  christos 
   3187  1.1  christos   /* Trim leading whitespace.  */
   3188  1.1  christos   while (c != EOF && (c == ' ' || c == '\t') && saw_newline)
   3189  1.1  christos     c = def_getc ();
   3190  1.1  christos 
   3191  1.1  christos   if (c == EOF)
   3192  1.1  christos     {
   3193  1.1  christos #if TRACE
   3194  1.1  christos       printf ("lex: EOF\n");
   3195  1.1  christos #endif
   3196  1.1  christos       return 0;
   3197  1.1  christos     }
   3198  1.1  christos 
   3199  1.1  christos   if (saw_newline && c == ';')
   3200  1.1  christos     {
   3201  1.1  christos       do
   3202  1.1  christos 	{
   3203  1.1  christos 	  c = def_getc ();
   3204  1.1  christos 	}
   3205  1.1  christos       while (c != EOF && c != '\n');
   3206  1.1  christos       if (c == '\n')
   3207  1.1  christos 	return def_lex ();
   3208  1.1  christos       return 0;
   3209  1.1  christos     }
   3210  1.1  christos 
   3211  1.1  christos   /* Must be something else.  */
   3212  1.1  christos   saw_newline = 0;
   3213  1.1  christos 
   3214  1.1  christos   if (ISDIGIT (c))
   3215  1.1  christos     {
   3216  1.1  christos       bufptr = 0;
   3217  1.1  christos       while (c != EOF && (ISXDIGIT (c) || (c == 'x')))
   3218  1.1  christos 	{
   3219  1.1  christos 	  put_buf (c);
   3220  1.1  christos 	  c = def_getc ();
   3221  1.1  christos 	}
   3222  1.1  christos       if (c != EOF)
   3223  1.1  christos 	def_ungetc (c);
   3224  1.1  christos       yylval.digits = def_pool_strdup (buffer);
   3225  1.1  christos #if TRACE
   3226  1.1  christos       printf ("lex: `%s' returns DIGITS\n", buffer);
   3227  1.1  christos #endif
   3228  1.1  christos       return DIGITS;
   3229  1.1  christos     }
   3230  1.1  christos 
   3231  1.1  christos   if (ISALPHA (c) || strchr ("$:-_?@", c))
   3232  1.1  christos     {
   3233  1.1  christos       bufptr = 0;
   3234  1.1  christos       q = c;
   3235  1.1  christos       put_buf (c);
   3236  1.1  christos       c = def_getc ();
   3237  1.1  christos 
   3238  1.1  christos       if (q == '@')
   3239  1.1  christos 	{
   3240  1.1  christos           if (ISBLANK (c) ) /* '@' followed by whitespace.  */
   3241  1.1  christos 	    return (q);
   3242  1.1  christos           else if (ISDIGIT (c)) /* '@' followed by digit.  */
   3243  1.1  christos             {
   3244  1.1  christos 	      def_ungetc (c);
   3245  1.1  christos               return (q);
   3246  1.1  christos 	    }
   3247  1.1  christos #if TRACE
   3248  1.1  christos 	  printf ("lex: @ returns itself\n");
   3249  1.1  christos #endif
   3250  1.1  christos 	}
   3251  1.1  christos 
   3252  1.1  christos       while (c != EOF && (ISALNUM (c) || strchr ("$:-_?/@<>", c)))
   3253  1.1  christos 	{
   3254  1.1  christos 	  put_buf (c);
   3255  1.1  christos 	  c = def_getc ();
   3256  1.1  christos 	}
   3257  1.1  christos       if (c != EOF)
   3258  1.1  christos 	def_ungetc (c);
   3259  1.1  christos       if (ISALPHA (q)) /* Check for tokens.  */
   3260  1.1  christos 	{
   3261  1.1  christos           for (i = 0; tokens[i].name; i++)
   3262  1.1  christos 	    if (strcmp (tokens[i].name, buffer) == 0)
   3263  1.1  christos 	      {
   3264  1.1  christos #if TRACE
   3265  1.1  christos 	        printf ("lex: `%s' is a string token\n", buffer);
   3266  1.1  christos #endif
   3267  1.1  christos 	        return tokens[i].token;
   3268  1.1  christos 	      }
   3269  1.1  christos 	}
   3270  1.1  christos #if TRACE
   3271  1.1  christos       printf ("lex: `%s' returns ID\n", buffer);
   3272  1.1  christos #endif
   3273  1.1  christos       yylval.id = def_pool_strdup (buffer);
   3274  1.1  christos       return ID;
   3275  1.1  christos     }
   3276  1.1  christos 
   3277  1.1  christos   if (c == '\'' || c == '"')
   3278  1.1  christos     {
   3279  1.1  christos       q = c;
   3280  1.1  christos       c = def_getc ();
   3281  1.1  christos       bufptr = 0;
   3282  1.1  christos 
   3283  1.1  christos       while (c != EOF && c != q)
   3284  1.1  christos 	{
   3285  1.1  christos 	  put_buf (c);
   3286  1.1  christos 	  c = def_getc ();
   3287  1.1  christos 	}
   3288  1.1  christos       yylval.id = def_pool_strdup (buffer);
   3289  1.1  christos #if TRACE
   3290  1.1  christos       printf ("lex: `%s' returns ID\n", buffer);
   3291  1.1  christos #endif
   3292  1.1  christos       return ID;
   3293  1.1  christos     }
   3294  1.1  christos 
   3295  1.1  christos   if ( c == '=')
   3296  1.1  christos     {
   3297  1.1  christos       c = def_getc ();
   3298  1.1  christos       if (c == '=')
   3299  1.1  christos         {
   3300  1.1  christos #if TRACE
   3301  1.1  christos           printf ("lex: `==' returns EQUAL\n");
   3302  1.1  christos #endif
   3303  1.1  christos 		  return EQUAL;
   3304  1.1  christos         }
   3305  1.1  christos       def_ungetc (c);
   3306  1.1  christos #if TRACE
   3307  1.1  christos       printf ("lex: `=' returns itself\n");
   3308  1.1  christos #endif
   3309  1.1  christos       return '=';
   3310  1.1  christos     }
   3311  1.1  christos   if (c == '.' || c == ',')
   3312  1.1  christos     {
   3313  1.1  christos #if TRACE
   3314  1.1  christos       printf ("lex: `%c' returns itself\n", c);
   3315  1.1  christos #endif
   3316  1.1  christos       return c;
   3317  1.1  christos     }
   3318  1.1  christos 
   3319  1.1  christos   if (c == '\n')
   3320  1.1  christos     {
   3321  1.1  christos       linenumber++;
   3322  1.1  christos       saw_newline = 1;
   3323  1.1  christos     }
   3324  1.1  christos 
   3325  1.1  christos   /*printf ("lex: 0x%02x ignored\n", c); */
   3326  1.1  christos   return def_lex ();
   3327  1.1  christos }
   3328  1.1  christos 
   3329  1.1  christos static char *
   3330  1.1  christos def_pool_alloc (size_t sz)
   3331  1.1  christos {
   3332  1.1  christos   def_pool_str *e;
   3333  1.1  christos 
   3334  1.1  christos   e = (def_pool_str *) xmalloc (sizeof (def_pool_str) + sz);
   3335  1.1  christos   e->next = pool_strs;
   3336  1.1  christos   pool_strs = e;
   3337  1.1  christos   return e->data;
   3338  1.1  christos }
   3339  1.1  christos 
   3340  1.1  christos static char *
   3341  1.1  christos def_pool_strdup (const char *str)
   3342  1.1  christos {
   3343  1.1  christos   char *s;
   3344  1.1  christos   size_t len;
   3345  1.1  christos   if (!str)
   3346  1.1  christos     return NULL;
   3347  1.1  christos   len = strlen (str) + 1;
   3348  1.1  christos   s = def_pool_alloc (len);
   3349  1.1  christos   memcpy (s, str, len);
   3350  1.1  christos   return s;
   3351  1.1  christos }
   3352  1.1  christos 
   3353  1.1  christos static void
   3354  1.1  christos def_pool_free (void)
   3355  1.1  christos {
   3356  1.1  christos   def_pool_str *p;
   3357  1.1  christos   while ((p = pool_strs) != NULL)
   3358  1.1  christos     {
   3359  1.1  christos       pool_strs = p->next;
   3360  1.1  christos       free (p);
   3361  1.1  christos     }
   3362  1.1  christos }
   3363