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