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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [binutils-2.20.1/] [ld/] [deffilep.c] - Blame information for rev 297

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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