1 /* A Bison parser, made by GNU Bison 2.3. */
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
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)
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.
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. */
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.
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
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. */
46 /* Identify Bison output. */
50 #define YYBISON_VERSION "2.3"
53 #define YYSKELETON_NAME "yacc.c"
58 /* Using locations. */
59 #define YYLSP_NEEDED 0
66 /* Put the tokens into the symbol table, so that GDB and other debuggers
102 #define DESCRIPTION 260
103 #define STACKSIZE_K 261
113 #define CONSTANTU 271
114 #define CONSTANTL 272
117 #define ALIGNCOMM 275
124 #define DIRECTIVE 282
132 /* Copy the first part of user declarations. */
134 /* deffilep.y - parser for .def files */
136 /* Copyright (C) 1995-2014 Free Software Foundation, Inc.
138 This file is part of GNU Binutils.
140 This program is free software; you can redistribute it and/or modify
141 it under the terms of the GNU General Public License as published by
142 the Free Software Foundation; either version 3 of the License, or
143 (at your option) any later version.
145 This program is distributed in the hope that it will be useful,
146 but WITHOUT ANY WARRANTY; without even the implied warranty of
147 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
148 GNU General Public License for more details.
150 You should have received a copy of the GNU General Public License
151 along with this program; if not, write to the Free Software
152 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
153 MA 02110-1301, USA. */
156 #include "libiberty.h"
157 #include "safe-ctype.h"
165 #define ROUND_UP(a, b) (((a)+((b)-1))&~((b)-1))
167 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
168 as well as gratuitiously global symbol names, so we can have multiple
169 yacc generated parsers in ld. Note that these are only the variables
170 produced by yacc. If other parser generators (bison, byacc, etc) produce
171 additional global names that conflict at link time, then those parser
172 generators need to be fixed instead of adding those names to this list. */
174 #define yymaxdepth def_maxdepth
175 #define yyparse def_parse
176 #define yylex def_lex
177 #define yyerror def_error
178 #define yylval def_lval
179 #define yychar def_char
180 #define yydebug def_debug
181 #define yypact def_pact
184 #define yydef def_def
185 #define yychk def_chk
186 #define yypgo def_pgo
187 #define yyact def_act
188 #define yyexca def_exca
189 #define yyerrflag def_errflag
190 #define yynerrs def_nerrs
194 #define yy_yys def_yys
195 #define yystate def_state
196 #define yytmp def_tmp
198 #define yy_yyv def_yyv
199 #define yyval def_val
200 #define yylloc def_lloc
201 #define yyreds def_reds /* With YYDEBUG defined. */
202 #define yytoks def_toks /* With YYDEBUG defined. */
203 #define yylhs def_yylhs
204 #define yylen def_yylen
205 #define yydefred def_yydefred
206 #define yydgoto def_yydgoto
207 #define yysindex def_yysindex
208 #define yyrindex def_yyrindex
209 #define yygindex def_yygindex
210 #define yytable def_yytable
211 #define yycheck def_yycheck
213 typedef struct def_pool_str {
214 struct def_pool_str *next;
218 static def_pool_str *pool_strs = NULL;
220 static char *def_pool_alloc (size_t sz);
221 static char *def_pool_strdup (const char *str);
222 static void def_pool_free (void);
224 static void def_description (const char *);
225 static void def_exports (const char *, const char *, int, int, const char *);
226 static void def_heapsize (int, int);
227 static void def_import (const char *, const char *, const char *, const char *,
229 static void def_image_name (const char *, bfd_vma, int);
230 static void def_section (const char *, int);
231 static void def_section_alt (const char *, const char *);
232 static void def_stacksize (int, int);
233 static void def_version (int, int);
234 static void def_directive (char *);
235 static void def_aligncomm (char *str, int align);
236 static int def_parse (void);
237 static int def_error (const char *);
238 static int def_lex (void);
240 static int lex_forced_token = 0;
241 static const char *lex_parse_string = 0;
242 static const char *lex_parse_string_end = 0;
246 /* Enabling traces. */
251 /* Enabling verbose error messages. */
252 #ifdef YYERROR_VERBOSE
253 # undef YYERROR_VERBOSE
254 # define YYERROR_VERBOSE 1
256 # define YYERROR_VERBOSE 0
259 /* Enabling the token table. */
260 #ifndef YYTOKEN_TABLE
261 # define YYTOKEN_TABLE 0
264 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
265 typedef union YYSTYPE
266 #line 113 "deffilep.y"
269 const char *id_const;
274 /* Line 193 of yacc.c. */
275 #line 276 "deffilep.c"
277 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
278 # define YYSTYPE_IS_DECLARED 1
279 # define YYSTYPE_IS_TRIVIAL 1
284 /* Copy the second part of user declarations. */
287 /* Line 216 of yacc.c. */
288 #line 289 "deffilep.c"
295 typedef YYTYPE_UINT8 yytype_uint8;
297 typedef unsigned char yytype_uint8;
301 typedef YYTYPE_INT8 yytype_int8;
302 #elif (defined __STDC__ || defined __C99__FUNC__ \
303 || defined __cplusplus || defined _MSC_VER)
304 typedef signed char yytype_int8;
306 typedef short int yytype_int8;
310 typedef YYTYPE_UINT16 yytype_uint16;
312 typedef unsigned short int yytype_uint16;
316 typedef YYTYPE_INT16 yytype_int16;
318 typedef short int yytype_int16;
322 # ifdef __SIZE_TYPE__
323 # define YYSIZE_T __SIZE_TYPE__
324 # elif defined size_t
325 # define YYSIZE_T size_t
326 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
327 || defined __cplusplus || defined _MSC_VER)
328 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
329 # define YYSIZE_T size_t
331 # define YYSIZE_T unsigned int
335 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
338 # if defined YYENABLE_NLS && YYENABLE_NLS
340 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
341 # define YY_(msgid) dgettext ("bison-runtime", msgid)
345 # define YY_(msgid) msgid
349 /* Suppress unused-variable warnings by "using" E. */
350 #if ! defined lint || defined __GNUC__
351 # define YYUSE(e) ((void) (e))
353 # define YYUSE(e) /* empty */
356 /* Identity function, used to suppress warnings about constant conditions. */
360 #if (defined __STDC__ || defined __C99__FUNC__ \
361 || defined __cplusplus || defined _MSC_VER)
374 #if ! defined yyoverflow || YYERROR_VERBOSE
376 /* The parser invokes alloca or malloc; define the necessary symbols. */
378 # ifdef YYSTACK_USE_ALLOCA
379 # if YYSTACK_USE_ALLOCA
381 # define YYSTACK_ALLOC __builtin_alloca
382 # elif defined __BUILTIN_VA_ARG_INCR
383 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
385 # define YYSTACK_ALLOC __alloca
386 # elif defined _MSC_VER
387 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
388 # define alloca _alloca
390 # define YYSTACK_ALLOC alloca
391 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
392 || defined __cplusplus || defined _MSC_VER)
393 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
402 # ifdef YYSTACK_ALLOC
403 /* Pacify GCC's `empty if-body' warning. */
404 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
405 # ifndef YYSTACK_ALLOC_MAXIMUM
406 /* The OS might guarantee only one guard page at the bottom of the stack,
407 and a page size can be as small as 4096 bytes. So we cannot safely
408 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
409 to allow for a few compiler-allocated temporary stack slots. */
410 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
413 # define YYSTACK_ALLOC YYMALLOC
414 # define YYSTACK_FREE YYFREE
415 # ifndef YYSTACK_ALLOC_MAXIMUM
416 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
418 # if (defined __cplusplus && ! defined _STDLIB_H \
419 && ! ((defined YYMALLOC || defined malloc) \
420 && (defined YYFREE || defined free)))
421 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
427 # define YYMALLOC malloc
428 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
429 || defined __cplusplus || defined _MSC_VER)
430 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
435 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
436 || defined __cplusplus || defined _MSC_VER)
437 void free (void *); /* INFRINGES ON USER NAME SPACE */
441 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
444 #if (! defined yyoverflow \
445 && (! defined __cplusplus \
446 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
448 /* A type that is properly aligned for any stack member. */
455 /* The size of the maximum gap between one aligned stack and the next. */
456 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
458 /* The size of an array large to enough to hold all stacks, each with
460 # define YYSTACK_BYTES(N) \
461 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
462 + YYSTACK_GAP_MAXIMUM)
464 /* Copy COUNT objects from FROM to TO. The source and destination do
467 # if defined __GNUC__ && 1 < __GNUC__
468 # define YYCOPY(To, From, Count) \
469 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
471 # define YYCOPY(To, From, Count) \
475 for (yyi = 0; yyi < (Count); yyi++) \
476 (To)[yyi] = (From)[yyi]; \
482 /* Relocate STACK from its old location to the new one. The
483 local variables YYSIZE and YYSTACKSIZE give the old and new number of
484 elements in the stack, and YYPTR gives the new location of the
485 stack. Advance YYPTR to a properly aligned location for the next
487 # define YYSTACK_RELOCATE(Stack) \
490 YYSIZE_T yynewbytes; \
491 YYCOPY (&yyptr->Stack, Stack, yysize); \
492 Stack = &yyptr->Stack; \
493 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
494 yyptr += yynewbytes / sizeof (*yyptr); \
500 /* YYFINAL -- State number of the termination state. */
502 /* YYLAST -- Last index in YYTABLE. */
505 /* YYNTOKENS -- Number of terminals. */
507 /* YYNNTS -- Number of nonterminals. */
509 /* YYNRULES -- Number of rules. */
511 /* YYNRULES -- Number of states. */
512 #define YYNSTATES 146
514 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
516 #define YYMAXUTOK 285
518 #define YYTRANSLATE(YYX) \
519 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
521 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
522 static const yytype_uint8 yytranslate[] =
524 0, 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, 32, 2, 31, 2, 2, 2,
529 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
530 2, 33, 2, 2, 34, 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, 2, 2, 2, 2,
538 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
539 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
540 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
541 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
542 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
543 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
544 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
545 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
546 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
547 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
548 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
549 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
550 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
551 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
552 25, 26, 27, 28, 29, 30
556 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
558 static const yytype_uint16 yyprhs[] =
560 0, 0, 3, 6, 8, 12, 16, 19, 23, 27,
561 30, 33, 36, 39, 42, 45, 50, 53, 58, 59,
562 61, 64, 72, 76, 77, 79, 81, 83, 85, 87,
563 89, 91, 93, 96, 98, 107, 116, 123, 130, 137,
564 142, 145, 147, 150, 153, 157, 159, 161, 162, 165,
565 166, 168, 170, 172, 174, 176, 178, 180, 182, 184,
566 186, 188, 190, 192, 194, 196, 198, 200, 202, 204,
567 206, 208, 210, 212, 214, 216, 218, 220, 223, 226,
568 230, 234, 236, 237, 240, 241, 244, 245, 248, 249,
569 253, 254, 256, 259, 264, 266, 267, 269, 270, 272
572 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
573 static const yytype_int8 yyrhs[] =
575 36, 0, -1, 36, 37, -1, 37, -1, 3, 52,
576 56, -1, 4, 52, 56, -1, 5, 29, -1, 6,
577 60, 48, -1, 7, 60, 48, -1, 8, 46, -1,
578 9, 46, -1, 11, 44, -1, 12, 38, -1, 13,
579 42, -1, 14, 60, -1, 14, 60, 31, 60, -1,
580 27, 29, -1, 20, 57, 32, 60, -1, -1, 39,
581 -1, 38, 39, -1, 51, 55, 54, 47, 40, 47,
582 53, -1, 41, 47, 40, -1, -1, 25, -1, 26,
583 -1, 16, -1, 17, -1, 9, -1, 10, -1, 18,
584 -1, 19, -1, 42, 43, -1, 43, -1, 29, 33,
585 29, 31, 29, 31, 29, 53, -1, 29, 33, 29,
586 31, 29, 31, 60, 53, -1, 29, 33, 29, 31,
587 29, 53, -1, 29, 33, 29, 31, 60, 53, -1,
588 29, 31, 29, 31, 29, 53, -1, 29, 31, 29,
589 53, -1, 44, 45, -1, 45, -1, 29, 46, -1,
590 29, 29, -1, 46, 47, 49, -1, 49, -1, 32,
591 -1, -1, 32, 60, -1, -1, 21, -1, 22, -1,
592 23, -1, 24, -1, 15, -1, 8, -1, 16, -1,
593 17, -1, 9, -1, 10, -1, 5, -1, 27, -1,
594 23, -1, 12, -1, 7, -1, 13, -1, 3, -1,
595 25, -1, 26, -1, 18, -1, 19, -1, 21, -1,
596 24, -1, 6, -1, 14, -1, 22, -1, 29, -1,
597 31, 50, -1, 31, 51, -1, 50, 31, 51, -1,
598 29, 31, 51, -1, 51, -1, -1, 28, 29, -1,
599 -1, 34, 60, -1, -1, 33, 51, -1, -1, 15,
600 33, 61, -1, -1, 29, -1, 31, 29, -1, 57,
601 31, 58, 59, -1, 30, -1, -1, 29, -1, -1,
605 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
606 static const yytype_uint16 yyrline[] =
608 0, 138, 138, 139, 143, 144, 145, 146, 147, 148,
609 149, 150, 151, 152, 153, 154, 155, 156, 160, 162,
610 163, 170, 177, 178, 181, 182, 183, 184, 185, 186,
611 187, 188, 191, 192, 196, 198, 200, 202, 204, 206,
612 211, 212, 216, 217, 221, 222, 226, 227, 229, 230,
613 234, 235, 236, 237, 241, 242, 243, 244, 245, 246,
614 247, 248, 249, 250, 251, 252, 259, 260, 261, 262,
615 263, 264, 265, 266, 267, 268, 271, 272, 278, 284,
616 290, 298, 299, 302, 303, 307, 308, 312, 313, 316,
617 317, 320, 321, 327, 335, 336, 339, 340, 343, 345
621 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
622 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
623 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
624 static const char *const yytname[] =
626 "$end", "error", "$undefined", "NAME", "LIBRARY", "DESCRIPTION",
627 "STACKSIZE_K", "HEAPSIZE", "CODE", "DATAU", "DATAL", "SECTIONS",
628 "EXPORTS", "IMPORTS", "VERSIONK", "BASE", "CONSTANTU", "CONSTANTL",
629 "PRIVATEU", "PRIVATEL", "ALIGNCOMM", "READ", "WRITE", "EXECUTE",
630 "SHARED", "NONAMEU", "NONAMEL", "DIRECTIVE", "EQUAL", "ID", "DIGITS",
631 "'.'", "','", "'='", "'@'", "$accept", "start", "command", "explist",
632 "expline", "exp_opt_list", "exp_opt", "implist", "impline", "seclist",
633 "secline", "attr_list", "opt_comma", "opt_number", "attr",
634 "keyword_as_name", "opt_name2", "opt_name", "opt_equalequal_name",
635 "opt_ordinal", "opt_equal_name", "opt_base", "anylang_id", "opt_digits",
636 "opt_id", "NUMBER", "VMA", 0
641 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
643 static const yytype_uint16 yytoknum[] =
645 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
646 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
647 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
652 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
653 static const yytype_uint8 yyr1[] =
655 0, 35, 36, 36, 37, 37, 37, 37, 37, 37,
656 37, 37, 37, 37, 37, 37, 37, 37, 38, 38,
657 38, 39, 40, 40, 41, 41, 41, 41, 41, 41,
658 41, 41, 42, 42, 43, 43, 43, 43, 43, 43,
659 44, 44, 45, 45, 46, 46, 47, 47, 48, 48,
660 49, 49, 49, 49, 50, 50, 50, 50, 50, 50,
661 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
662 50, 50, 50, 50, 50, 50, 51, 51, 51, 51,
663 51, 52, 52, 53, 53, 54, 54, 55, 55, 56,
664 56, 57, 57, 57, 58, 58, 59, 59, 60, 61
667 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
668 static const yytype_uint8 yyr2[] =
670 0, 2, 2, 1, 3, 3, 2, 3, 3, 2,
671 2, 2, 2, 2, 2, 4, 2, 4, 0, 1,
672 2, 7, 3, 0, 1, 1, 1, 1, 1, 1,
673 1, 1, 2, 1, 8, 8, 6, 6, 6, 4,
674 2, 1, 2, 2, 3, 1, 1, 0, 2, 0,
675 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
676 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
677 1, 1, 1, 1, 1, 1, 1, 2, 2, 3,
678 3, 1, 0, 2, 0, 2, 0, 2, 0, 3,
679 0, 1, 2, 4, 1, 0, 1, 0, 1, 1
682 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
683 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
684 means the default is an error. */
685 static const yytype_uint8 yydefact[] =
687 0, 82, 82, 0, 0, 0, 0, 0, 0, 18,
688 0, 0, 0, 0, 0, 3, 66, 60, 73, 64,
689 55, 58, 59, 63, 65, 74, 54, 56, 57, 69,
690 70, 71, 75, 62, 72, 67, 68, 61, 76, 0,
691 0, 81, 90, 90, 6, 98, 49, 49, 50, 51,
692 52, 53, 9, 45, 10, 0, 11, 41, 12, 19,
693 88, 0, 13, 33, 14, 91, 0, 0, 16, 1,
694 2, 0, 77, 78, 0, 0, 4, 5, 0, 7,
695 8, 46, 0, 43, 42, 40, 20, 0, 86, 0,
696 0, 32, 0, 92, 95, 0, 80, 79, 0, 48,
697 44, 87, 0, 47, 84, 0, 15, 94, 97, 17,
698 99, 89, 85, 23, 0, 0, 39, 0, 96, 93,
699 28, 29, 26, 27, 30, 31, 24, 25, 47, 47,
700 83, 84, 84, 84, 84, 23, 38, 0, 36, 37,
701 21, 22, 84, 84, 34, 35
704 /* YYDEFGOTO[NTERM-NUM]. */
705 static const yytype_int16 yydefgoto[] =
707 -1, 14, 15, 58, 59, 128, 129, 62, 63, 56,
708 57, 52, 82, 79, 53, 40, 41, 42, 116, 103,
709 88, 76, 67, 108, 119, 46, 111
712 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
714 #define YYPACT_NINF -82
715 static const yytype_int8 yypact[] =
717 122, 11, 11, -25, 9, 9, 53, 53, -17, 11,
718 14, 9, -18, 20, 95, -82, -82, -82, -82, -82,
719 -82, -82, -82, -82, -82, -82, -82, -82, -82, -82,
720 -82, -82, -82, -82, -82, -82, -82, -82, 29, 11,
721 47, -82, 67, 67, -82, -82, 54, 54, -82, -82,
722 -82, -82, 48, -82, 48, -14, -17, -82, 11, -82,
723 58, 50, 14, -82, 61, -82, 64, 33, -82, -82,
724 -82, 11, 47, -82, 11, 63, -82, -82, 9, -82,
725 -82, -82, 53, -82, 48, -82, -82, 11, 60, 76,
726 81, -82, 9, -82, 83, 9, -82, -82, 84, -82,
727 -82, -82, 9, 79, -26, 85, -82, -82, 88, -82,
728 -82, -82, -82, 36, 89, 90, -82, 55, -82, -82,
729 -82, -82, -82, -82, -82, -82, -82, -82, 79, 79,
730 -82, 92, 13, 92, 92, 36, -82, 59, -82, -82,
731 -82, -82, 92, 92, -82, -82
734 /* YYPGOTO[NTERM-NUM]. */
735 static const yytype_int16 yypgoto[] =
737 -82, -82, 107, -82, 65, -11, -82, -82, 75, -82,
738 82, -4, -81, 93, 57, 102, -8, 141, -75, -82,
739 -82, 101, -82, -82, -82, -5, -82
742 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
743 positive, shift that token. If negative, reduce the rule which
744 number is the opposite. If zero, do what YYDEFACT says.
745 If YYTABLE_NINF, syntax error. */
746 #define YYTABLE_NINF -48
747 static const yytype_int16 yytable[] =
749 47, 60, 114, 54, 44, 115, 64, 48, 49, 50,
750 51, 65, 55, 66, 16, 83, 17, 18, 19, 20,
751 21, 22, 113, 23, 24, 25, 26, 27, 28, 29,
752 30, 73, 31, 32, 33, 34, 35, 36, 37, 45,
753 38, 114, 39, 61, 137, 120, 121, 134, 135, 68,
754 60, 84, 122, 123, 124, 125, 136, 138, 139, 140,
755 71, 126, 127, 96, 94, 95, 97, 144, 145, -47,
756 -47, -47, -47, 99, 48, 49, 50, 51, 74, 101,
757 81, 89, 75, 90, 132, 45, 78, 106, 142, 45,
758 109, 87, 92, 93, 102, 69, 98, 112, 1, 2,
759 3, 4, 5, 6, 7, 104, 8, 9, 10, 11,
760 105, 81, 133, 107, 110, 12, 117, 118, 130, 131,
761 114, 70, 13, 86, 141, 1, 2, 3, 4, 5,
762 6, 7, 143, 8, 9, 10, 11, 91, 85, 100,
763 80, 72, 12, 43, 77, 0, 0, 0, 0, 13
766 static const yytype_int16 yycheck[] =
768 5, 9, 28, 7, 29, 31, 11, 21, 22, 23,
769 24, 29, 29, 31, 3, 29, 5, 6, 7, 8,
770 9, 10, 103, 12, 13, 14, 15, 16, 17, 18,
771 19, 39, 21, 22, 23, 24, 25, 26, 27, 30,
772 29, 28, 31, 29, 31, 9, 10, 128, 129, 29,
773 58, 55, 16, 17, 18, 19, 131, 132, 133, 134,
774 31, 25, 26, 71, 31, 32, 74, 142, 143, 21,
775 22, 23, 24, 78, 21, 22, 23, 24, 31, 87,
776 32, 31, 15, 33, 29, 30, 32, 92, 29, 30,
777 95, 33, 31, 29, 34, 0, 33, 102, 3, 4,
778 5, 6, 7, 8, 9, 29, 11, 12, 13, 14,
779 29, 32, 117, 30, 30, 20, 31, 29, 29, 29,
780 28, 14, 27, 58, 135, 3, 4, 5, 6, 7,
781 8, 9, 137, 11, 12, 13, 14, 62, 56, 82,
782 47, 39, 20, 2, 43, -1, -1, -1, -1, 27
785 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
786 symbol of state STATE-NUM. */
787 static const yytype_uint8 yystos[] =
789 0, 3, 4, 5, 6, 7, 8, 9, 11, 12,
790 13, 14, 20, 27, 36, 37, 3, 5, 6, 7,
791 8, 9, 10, 12, 13, 14, 15, 16, 17, 18,
792 19, 21, 22, 23, 24, 25, 26, 27, 29, 31,
793 50, 51, 52, 52, 29, 30, 60, 60, 21, 22,
794 23, 24, 46, 49, 46, 29, 44, 45, 38, 39,
795 51, 29, 42, 43, 60, 29, 31, 57, 29, 0,
796 37, 31, 50, 51, 31, 15, 56, 56, 32, 48,
797 48, 32, 47, 29, 46, 45, 39, 33, 55, 31,
798 33, 43, 31, 29, 31, 32, 51, 51, 33, 60,
799 49, 51, 34, 54, 29, 29, 60, 30, 58, 60,
800 30, 61, 60, 47, 28, 31, 53, 31, 29, 59,
801 9, 10, 16, 17, 18, 19, 25, 26, 40, 41,
802 29, 29, 29, 60, 47, 47, 53, 31, 53, 53,
803 53, 40, 29, 60, 53, 53
806 #define yyerrok (yyerrstatus = 0)
807 #define yyclearin (yychar = YYEMPTY)
811 #define YYACCEPT goto yyacceptlab
812 #define YYABORT goto yyabortlab
813 #define YYERROR goto yyerrorlab
816 /* Like YYERROR except do call yyerror. This remains here temporarily
817 to ease the transition to the new meaning of YYERROR, for GCC.
818 Once GCC version 2 has supplanted version 1, this can go. */
820 #define YYFAIL goto yyerrlab
822 #define YYRECOVERING() (!!yyerrstatus)
824 #define YYBACKUP(Token, Value) \
826 if (yychar == YYEMPTY && yylen == 1) \
830 yytoken = YYTRANSLATE (yychar); \
836 yyerror (YY_("syntax error: cannot back up")); \
843 #define YYERRCODE 256
846 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
847 If N is 0, then set CURRENT to the empty location which ends
848 the previous symbol: RHS[0] (always defined). */
850 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
851 #ifndef YYLLOC_DEFAULT
852 # define YYLLOC_DEFAULT(Current, Rhs, N) \
856 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
857 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
858 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
859 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
863 (Current).first_line = (Current).last_line = \
864 YYRHSLOC (Rhs, 0).last_line; \
865 (Current).first_column = (Current).last_column = \
866 YYRHSLOC (Rhs, 0).last_column; \
872 /* YY_LOCATION_PRINT -- Print the location on the stream.
873 This macro was not mandated originally: define only if we know
874 we won't break user code: when these are the locations we know. */
876 #ifndef YY_LOCATION_PRINT
877 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
878 # define YY_LOCATION_PRINT(File, Loc) \
879 fprintf (File, "%d.%d-%d.%d", \
880 (Loc).first_line, (Loc).first_column, \
881 (Loc).last_line, (Loc).last_column)
883 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
888 /* YYLEX -- calling `yylex' with the right arguments. */
891 # define YYLEX yylex (YYLEX_PARAM)
893 # define YYLEX yylex ()
896 /* Enable debugging if requested. */
900 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
901 # define YYFPRINTF fprintf
904 # define YYDPRINTF(Args) \
910 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
914 YYFPRINTF (stderr, "%s ", Title); \
915 yy_symbol_print (stderr, \
917 YYFPRINTF (stderr, "\n"); \
922 /*--------------------------------.
923 | Print this symbol on YYOUTPUT. |
924 `--------------------------------*/
927 #if (defined __STDC__ || defined __C99__FUNC__ \
928 || defined __cplusplus || defined _MSC_VER)
930 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
933 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
936 YYSTYPE const * const yyvaluep;
942 if (yytype < YYNTOKENS)
943 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
955 /*--------------------------------.
956 | Print this symbol on YYOUTPUT. |
957 `--------------------------------*/
959 #if (defined __STDC__ || defined __C99__FUNC__ \
960 || defined __cplusplus || defined _MSC_VER)
962 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
965 yy_symbol_print (yyoutput, yytype, yyvaluep)
968 YYSTYPE const * const yyvaluep;
971 if (yytype < YYNTOKENS)
972 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
974 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
976 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
977 YYFPRINTF (yyoutput, ")");
980 /*------------------------------------------------------------------.
981 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
983 `------------------------------------------------------------------*/
985 #if (defined __STDC__ || defined __C99__FUNC__ \
986 || defined __cplusplus || defined _MSC_VER)
988 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
991 yy_stack_print (bottom, top)
992 yytype_int16 *bottom;
996 YYFPRINTF (stderr, "Stack now");
997 for (; bottom <= top; ++bottom)
998 YYFPRINTF (stderr, " %d", *bottom);
999 YYFPRINTF (stderr, "\n");
1002 # define YY_STACK_PRINT(Bottom, Top) \
1005 yy_stack_print ((Bottom), (Top)); \
1009 /*------------------------------------------------.
1010 | Report that the YYRULE is going to be reduced. |
1011 `------------------------------------------------*/
1013 #if (defined __STDC__ || defined __C99__FUNC__ \
1014 || defined __cplusplus || defined _MSC_VER)
1016 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
1019 yy_reduce_print (yyvsp, yyrule)
1024 int yynrhs = yyr2[yyrule];
1026 unsigned long int yylno = yyrline[yyrule];
1027 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1029 /* The symbols being reduced. */
1030 for (yyi = 0; yyi < yynrhs; yyi++)
1032 fprintf (stderr, " $%d = ", yyi + 1);
1033 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1034 &(yyvsp[(yyi + 1) - (yynrhs)])
1036 fprintf (stderr, "\n");
1040 # define YY_REDUCE_PRINT(Rule) \
1043 yy_reduce_print (yyvsp, Rule); \
1046 /* Nonzero means print parse trace. It is left uninitialized so that
1047 multiple parsers can coexist. */
1049 #else /* !YYDEBUG */
1050 # define YYDPRINTF(Args)
1051 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1052 # define YY_STACK_PRINT(Bottom, Top)
1053 # define YY_REDUCE_PRINT(Rule)
1054 #endif /* !YYDEBUG */
1057 /* YYINITDEPTH -- initial size of the parser's stacks. */
1059 # define YYINITDEPTH 200
1062 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1063 if the built-in stack extension method is used).
1065 Do not make this value too large; the results are undefined if
1066 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1067 evaluated with infinite-precision integer arithmetic. */
1070 # define YYMAXDEPTH 10000
1078 # if defined __GLIBC__ && defined _STRING_H
1079 # define yystrlen strlen
1081 /* Return the length of YYSTR. */
1082 #if (defined __STDC__ || defined __C99__FUNC__ \
1083 || defined __cplusplus || defined _MSC_VER)
1085 yystrlen (const char *yystr)
1093 for (yylen = 0; yystr[yylen]; yylen++)
1101 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1102 # define yystpcpy stpcpy
1104 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1106 #if (defined __STDC__ || defined __C99__FUNC__ \
1107 || defined __cplusplus || defined _MSC_VER)
1109 yystpcpy (char *yydest, const char *yysrc)
1112 yystpcpy (yydest, yysrc)
1118 const char *yys = yysrc;
1120 while ((*yyd++ = *yys++) != '\0')
1129 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1130 quotes and backslashes, so that it's suitable for yyerror. The
1131 heuristic is that double-quoting is unnecessary unless the string
1132 contains an apostrophe, a comma, or backslash (other than
1133 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1134 null, do not copy; instead, return the length of what the result
1137 yytnamerr (char *yyres, const char *yystr)
1142 char const *yyp = yystr;
1149 goto do_not_strip_quotes;
1153 goto do_not_strip_quotes;
1166 do_not_strip_quotes: ;
1170 return yystrlen (yystr);
1172 return yystpcpy (yyres, yystr) - yyres;
1176 /* Copy into YYRESULT an error message about the unexpected token
1177 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1178 including the terminating null byte. If YYRESULT is null, do not
1179 copy anything; just return the number of bytes that would be
1180 copied. As a special case, return 0 if an ordinary "syntax error"
1181 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1182 size calculation. */
1184 yysyntax_error (char *yyresult, int yystate, int yychar)
1186 int yyn = yypact[yystate];
1188 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1192 int yytype = YYTRANSLATE (yychar);
1193 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1194 YYSIZE_T yysize = yysize0;
1196 int yysize_overflow = 0;
1197 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1198 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1202 /* This is so xgettext sees the translatable formats that are
1203 constructed on the fly. */
1204 YY_("syntax error, unexpected %s");
1205 YY_("syntax error, unexpected %s, expecting %s");
1206 YY_("syntax error, unexpected %s, expecting %s or %s");
1207 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1208 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1212 static char const yyunexpected[] = "syntax error, unexpected %s";
1213 static char const yyexpecting[] = ", expecting %s";
1214 static char const yyor[] = " or %s";
1215 char yyformat[sizeof yyunexpected
1216 + sizeof yyexpecting - 1
1217 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1218 * (sizeof yyor - 1))];
1219 char const *yyprefix = yyexpecting;
1221 /* Start YYX at -YYN if negative to avoid negative indexes in
1223 int yyxbegin = yyn < 0 ? -yyn : 0;
1225 /* Stay within bounds of both yycheck and yytname. */
1226 int yychecklim = YYLAST - yyn + 1;
1227 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1230 yyarg[0] = yytname[yytype];
1231 yyfmt = yystpcpy (yyformat, yyunexpected);
1233 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1234 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1236 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1240 yyformat[sizeof yyunexpected - 1] = '\0';
1243 yyarg[yycount++] = yytname[yyx];
1244 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1245 yysize_overflow |= (yysize1 < yysize);
1247 yyfmt = yystpcpy (yyfmt, yyprefix);
1251 yyf = YY_(yyformat);
1252 yysize1 = yysize + yystrlen (yyf);
1253 yysize_overflow |= (yysize1 < yysize);
1256 if (yysize_overflow)
1257 return YYSIZE_MAXIMUM;
1261 /* Avoid sprintf, as that infringes on the user's name space.
1262 Don't have undefined behavior even if the translation
1263 produced a string with the wrong number of "%s"s. */
1264 char *yyp = yyresult;
1266 while ((*yyp = *yyf) != '\0')
1268 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1270 yyp += yytnamerr (yyp, yyarg[yyi++]);
1283 #endif /* YYERROR_VERBOSE */
1286 /*-----------------------------------------------.
1287 | Release the memory associated to this symbol. |
1288 `-----------------------------------------------*/
1291 #if (defined __STDC__ || defined __C99__FUNC__ \
1292 || defined __cplusplus || defined _MSC_VER)
1294 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1297 yydestruct (yymsg, yytype, yyvaluep)
1307 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1318 /* Prevent warnings from -Wmissing-prototypes. */
1320 #ifdef YYPARSE_PARAM
1321 #if defined __STDC__ || defined __cplusplus
1322 int yyparse (void *YYPARSE_PARAM);
1326 #else /* ! YYPARSE_PARAM */
1327 #if defined __STDC__ || defined __cplusplus
1332 #endif /* ! YYPARSE_PARAM */
1336 /* The look-ahead symbol. */
1339 /* The semantic value of the look-ahead symbol. */
1342 /* Number of syntax errors so far. */
1351 #ifdef YYPARSE_PARAM
1352 #if (defined __STDC__ || defined __C99__FUNC__ \
1353 || defined __cplusplus || defined _MSC_VER)
1355 yyparse (void *YYPARSE_PARAM)
1358 yyparse (YYPARSE_PARAM)
1359 void *YYPARSE_PARAM;
1361 #else /* ! YYPARSE_PARAM */
1362 #if (defined __STDC__ || defined __C99__FUNC__ \
1363 || defined __cplusplus || defined _MSC_VER)
1377 /* Number of tokens to shift before error messages enabled. */
1379 /* Look-ahead token as an internal (translated) token number. */
1382 /* Buffer for error messages, and its allocated size. */
1384 char *yymsg = yymsgbuf;
1385 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1388 /* Three stacks and their tools:
1389 `yyss': related to states,
1390 `yyvs': related to semantic values,
1391 `yyls': related to locations.
1393 Refer to the stacks thru separate pointers, to allow yyoverflow
1394 to reallocate them elsewhere. */
1396 /* The state stack. */
1397 yytype_int16 yyssa[YYINITDEPTH];
1398 yytype_int16 *yyss = yyssa;
1399 yytype_int16 *yyssp;
1401 /* The semantic value stack. */
1402 YYSTYPE yyvsa[YYINITDEPTH];
1403 YYSTYPE *yyvs = yyvsa;
1408 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1410 YYSIZE_T yystacksize = YYINITDEPTH;
1412 /* The variables used to return semantic value and location from the
1417 /* The number of symbols on the RHS of the reduced rule.
1418 Keep to zero when no symbol should be popped. */
1421 YYDPRINTF ((stderr, "Starting parse\n"));
1426 yychar = YYEMPTY; /* Cause a token to be read. */
1428 /* Initialize stack pointers.
1429 Waste one element of value and location stack
1430 so that they stay on the same level as the state stack.
1431 The wasted elements are never initialized. */
1438 /*------------------------------------------------------------.
1439 | yynewstate -- Push a new state, which is found in yystate. |
1440 `------------------------------------------------------------*/
1442 /* In all cases, when you get here, the value and location stacks
1443 have just been pushed. So pushing a state here evens the stacks. */
1449 if (yyss + yystacksize - 1 <= yyssp)
1451 /* Get the current used size of the three stacks, in elements. */
1452 YYSIZE_T yysize = yyssp - yyss + 1;
1456 /* Give user a chance to reallocate the stack. Use copies of
1457 these so that the &'s don't force the real ones into
1459 YYSTYPE *yyvs1 = yyvs;
1460 yytype_int16 *yyss1 = yyss;
1463 /* Each stack pointer address is followed by the size of the
1464 data in use in that stack, in bytes. This used to be a
1465 conditional around just the two extra args, but that might
1466 be undefined if yyoverflow is a macro. */
1467 yyoverflow (YY_("memory exhausted"),
1468 &yyss1, yysize * sizeof (*yyssp),
1469 &yyvs1, yysize * sizeof (*yyvsp),
1476 #else /* no yyoverflow */
1477 # ifndef YYSTACK_RELOCATE
1478 goto yyexhaustedlab;
1480 /* Extend the stack our own way. */
1481 if (YYMAXDEPTH <= yystacksize)
1482 goto yyexhaustedlab;
1484 if (YYMAXDEPTH < yystacksize)
1485 yystacksize = YYMAXDEPTH;
1488 yytype_int16 *yyss1 = yyss;
1489 union yyalloc *yyptr =
1490 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1492 goto yyexhaustedlab;
1493 YYSTACK_RELOCATE (yyss);
1494 YYSTACK_RELOCATE (yyvs);
1496 # undef YYSTACK_RELOCATE
1498 YYSTACK_FREE (yyss1);
1501 #endif /* no yyoverflow */
1503 yyssp = yyss + yysize - 1;
1504 yyvsp = yyvs + yysize - 1;
1507 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1508 (unsigned long int) yystacksize));
1510 if (yyss + yystacksize - 1 <= yyssp)
1514 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1523 /* Do appropriate processing given the current state. Read a
1524 look-ahead token if we need one and don't already have one. */
1526 /* First try to decide what to do without reference to look-ahead token. */
1527 yyn = yypact[yystate];
1528 if (yyn == YYPACT_NINF)
1531 /* Not known => get a look-ahead token if don't already have one. */
1533 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1534 if (yychar == YYEMPTY)
1536 YYDPRINTF ((stderr, "Reading a token: "));
1540 if (yychar <= YYEOF)
1542 yychar = yytoken = YYEOF;
1543 YYDPRINTF ((stderr, "Now at end of input.\n"));
1547 yytoken = YYTRANSLATE (yychar);
1548 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1551 /* If the proper action on seeing token YYTOKEN is to reduce or to
1552 detect an error, take that action. */
1554 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1559 if (yyn == 0 || yyn == YYTABLE_NINF)
1568 /* Count tokens shifted since error; after three, turn off error
1573 /* Shift the look-ahead token. */
1574 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1576 /* Discard the shifted token unless it is eof. */
1577 if (yychar != YYEOF)
1586 /*-----------------------------------------------------------.
1587 | yydefault -- do the default action for the current state. |
1588 `-----------------------------------------------------------*/
1590 yyn = yydefact[yystate];
1596 /*-----------------------------.
1597 | yyreduce -- Do a reduction. |
1598 `-----------------------------*/
1600 /* yyn is the number of a rule to reduce with. */
1603 /* If YYLEN is nonzero, implement the default value of the action:
1606 Otherwise, the following line sets YYVAL to garbage.
1607 This behavior is undocumented and Bison
1608 users should not rely upon it. Assigning to YYVAL
1609 unconditionally makes the parser a bit smaller, and it avoids a
1610 GCC warning that YYVAL may be used uninitialized. */
1611 yyval = yyvsp[1-yylen];
1614 YY_REDUCE_PRINT (yyn);
1618 #line 143 "deffilep.y"
1619 { def_image_name ((yyvsp[(2) - (3)].id), (yyvsp[(3) - (3)].vma), 0); }
1623 #line 144 "deffilep.y"
1624 { def_image_name ((yyvsp[(2) - (3)].id), (yyvsp[(3) - (3)].vma), 1); }
1628 #line 145 "deffilep.y"
1629 { def_description ((yyvsp[(2) - (2)].id));}
1633 #line 146 "deffilep.y"
1634 { def_stacksize ((yyvsp[(2) - (3)].number), (yyvsp[(3) - (3)].number));}
1638 #line 147 "deffilep.y"
1639 { def_heapsize ((yyvsp[(2) - (3)].number), (yyvsp[(3) - (3)].number));}
1643 #line 148 "deffilep.y"
1644 { def_section ("CODE", (yyvsp[(2) - (2)].number));}
1648 #line 149 "deffilep.y"
1649 { def_section ("DATA", (yyvsp[(2) - (2)].number));}
1653 #line 153 "deffilep.y"
1654 { def_version ((yyvsp[(2) - (2)].number), 0);}
1658 #line 154 "deffilep.y"
1659 { def_version ((yyvsp[(2) - (4)].number), (yyvsp[(4) - (4)].number));}
1663 #line 155 "deffilep.y"
1664 { def_directive ((yyvsp[(2) - (2)].id));}
1668 #line 156 "deffilep.y"
1669 { def_aligncomm ((yyvsp[(2) - (4)].id), (yyvsp[(4) - (4)].number));}
1673 #line 171 "deffilep.y"
1674 { def_exports ((yyvsp[(1) - (7)].id), (yyvsp[(2) - (7)].id), (yyvsp[(3) - (7)].number), (yyvsp[(5) - (7)].number), (yyvsp[(7) - (7)].id)); }
1678 #line 177 "deffilep.y"
1679 { (yyval.number) = (yyvsp[(1) - (3)].number) | (yyvsp[(3) - (3)].number); }
1683 #line 178 "deffilep.y"
1684 { (yyval.number) = 0; }
1688 #line 181 "deffilep.y"
1689 { (yyval.number) = 1; }
1693 #line 182 "deffilep.y"
1694 { (yyval.number) = 1; }
1698 #line 183 "deffilep.y"
1699 { (yyval.number) = 2; }
1703 #line 184 "deffilep.y"
1704 { (yyval.number) = 2; }
1708 #line 185 "deffilep.y"
1709 { (yyval.number) = 4; }
1713 #line 186 "deffilep.y"
1714 { (yyval.number) = 4; }
1718 #line 187 "deffilep.y"
1719 { (yyval.number) = 8; }
1723 #line 188 "deffilep.y"
1724 { (yyval.number) = 8; }
1728 #line 197 "deffilep.y"
1729 { def_import ((yyvsp[(1) - (8)].id), (yyvsp[(3) - (8)].id), (yyvsp[(5) - (8)].id), (yyvsp[(7) - (8)].id), -1, (yyvsp[(8) - (8)].id)); }
1733 #line 199 "deffilep.y"
1734 { def_import ((yyvsp[(1) - (8)].id), (yyvsp[(3) - (8)].id), (yyvsp[(5) - (8)].id), 0, (yyvsp[(7) - (8)].number), (yyvsp[(8) - (8)].id)); }
1738 #line 201 "deffilep.y"
1739 { def_import ((yyvsp[(1) - (6)].id), (yyvsp[(3) - (6)].id), 0, (yyvsp[(5) - (6)].id), -1, (yyvsp[(6) - (6)].id)); }
1743 #line 203 "deffilep.y"
1744 { def_import ((yyvsp[(1) - (6)].id), (yyvsp[(3) - (6)].id), 0, 0, (yyvsp[(5) - (6)].number), (yyvsp[(6) - (6)].id)); }
1748 #line 205 "deffilep.y"
1749 { def_import( 0, (yyvsp[(1) - (6)].id), (yyvsp[(3) - (6)].id), (yyvsp[(5) - (6)].id), -1, (yyvsp[(6) - (6)].id)); }
1753 #line 207 "deffilep.y"
1754 { def_import ( 0, (yyvsp[(1) - (4)].id), 0, (yyvsp[(3) - (4)].id), -1, (yyvsp[(4) - (4)].id)); }
1758 #line 216 "deffilep.y"
1759 { def_section ((yyvsp[(1) - (2)].id), (yyvsp[(2) - (2)].number));}
1763 #line 217 "deffilep.y"
1764 { def_section_alt ((yyvsp[(1) - (2)].id), (yyvsp[(2) - (2)].id));}
1768 #line 221 "deffilep.y"
1769 { (yyval.number) = (yyvsp[(1) - (3)].number) | (yyvsp[(3) - (3)].number); }
1773 #line 222 "deffilep.y"
1774 { (yyval.number) = (yyvsp[(1) - (1)].number); }
1778 #line 229 "deffilep.y"
1779 { (yyval.number)=(yyvsp[(2) - (2)].number);}
1783 #line 230 "deffilep.y"
1784 { (yyval.number)=-1;}
1788 #line 234 "deffilep.y"
1789 { (yyval.number) = 1;}
1793 #line 235 "deffilep.y"
1794 { (yyval.number) = 2;}
1798 #line 236 "deffilep.y"
1799 { (yyval.number)=4;}
1803 #line 237 "deffilep.y"
1804 { (yyval.number)=8;}
1808 #line 241 "deffilep.y"
1809 { (yyval.id_const) = "BASE"; }
1813 #line 242 "deffilep.y"
1814 { (yyval.id_const) = "CODE"; }
1818 #line 243 "deffilep.y"
1819 { (yyval.id_const) = "CONSTANT"; }
1823 #line 244 "deffilep.y"
1824 { (yyval.id_const) = "constant"; }
1828 #line 245 "deffilep.y"
1829 { (yyval.id_const) = "DATA"; }
1833 #line 246 "deffilep.y"
1834 { (yyval.id_const) = "data"; }
1838 #line 247 "deffilep.y"
1839 { (yyval.id_const) = "DESCRIPTION"; }
1843 #line 248 "deffilep.y"
1844 { (yyval.id_const) = "DIRECTIVE"; }
1848 #line 249 "deffilep.y"
1849 { (yyval.id_const) = "EXECUTE"; }
1853 #line 250 "deffilep.y"
1854 { (yyval.id_const) = "EXPORTS"; }
1858 #line 251 "deffilep.y"
1859 { (yyval.id_const) = "HEAPSIZE"; }
1863 #line 252 "deffilep.y"
1864 { (yyval.id_const) = "IMPORTS"; }
1868 #line 259 "deffilep.y"
1869 { (yyval.id_const) = "NAME"; }
1873 #line 260 "deffilep.y"
1874 { (yyval.id_const) = "NONAME"; }
1878 #line 261 "deffilep.y"
1879 { (yyval.id_const) = "noname"; }
1883 #line 262 "deffilep.y"
1884 { (yyval.id_const) = "PRIVATE"; }
1888 #line 263 "deffilep.y"
1889 { (yyval.id_const) = "private"; }
1893 #line 264 "deffilep.y"
1894 { (yyval.id_const) = "READ"; }
1898 #line 265 "deffilep.y"
1899 { (yyval.id_const) = "SHARED"; }
1903 #line 266 "deffilep.y"
1904 { (yyval.id_const) = "STACKSIZE"; }
1908 #line 267 "deffilep.y"
1909 { (yyval.id_const) = "VERSION"; }
1913 #line 268 "deffilep.y"
1914 { (yyval.id_const) = "WRITE"; }
1918 #line 271 "deffilep.y"
1919 { (yyval.id) = (yyvsp[(1) - (1)].id); }
1923 #line 273 "deffilep.y"
1925 char *name = xmalloc (strlen ((yyvsp[(2) - (2)].id_const)) + 2);
1926 sprintf (name, ".%s", (yyvsp[(2) - (2)].id_const));
1932 #line 279 "deffilep.y"
1934 char *name = def_pool_alloc (strlen ((yyvsp[(2) - (2)].id)) + 2);
1935 sprintf (name, ".%s", (yyvsp[(2) - (2)].id));
1941 #line 285 "deffilep.y"
1943 char *name = def_pool_alloc (strlen ((yyvsp[(1) - (3)].id_const)) + 1 + strlen ((yyvsp[(3) - (3)].id)) + 1);
1944 sprintf (name, "%s.%s", (yyvsp[(1) - (3)].id_const), (yyvsp[(3) - (3)].id));
1950 #line 291 "deffilep.y"
1952 char *name = def_pool_alloc (strlen ((yyvsp[(1) - (3)].id)) + 1 + strlen ((yyvsp[(3) - (3)].id)) + 1);
1953 sprintf (name, "%s.%s", (yyvsp[(1) - (3)].id), (yyvsp[(3) - (3)].id));
1959 #line 298 "deffilep.y"
1960 { (yyval.id) = (yyvsp[(1) - (1)].id); }
1964 #line 299 "deffilep.y"
1965 { (yyval.id) = ""; }
1969 #line 302 "deffilep.y"
1970 { (yyval.id) = (yyvsp[(2) - (2)].id); }
1974 #line 303 "deffilep.y"
1979 #line 307 "deffilep.y"
1980 { (yyval.number) = (yyvsp[(2) - (2)].number);}
1984 #line 308 "deffilep.y"
1985 { (yyval.number) = -1;}
1989 #line 312 "deffilep.y"
1990 { (yyval.id) = (yyvsp[(2) - (2)].id); }
1994 #line 313 "deffilep.y"
1999 #line 316 "deffilep.y"
2000 { (yyval.vma) = (yyvsp[(3) - (3)].vma);}
2004 #line 317 "deffilep.y"
2005 { (yyval.vma) = (bfd_vma) -1;}
2009 #line 320 "deffilep.y"
2010 { (yyval.id) = (yyvsp[(1) - (1)].id); }
2014 #line 322 "deffilep.y"
2016 char *id = def_pool_alloc (strlen ((yyvsp[(2) - (2)].id)) + 2);
2017 sprintf (id, ".%s", (yyvsp[(2) - (2)].id));
2023 #line 328 "deffilep.y"
2025 char *id = def_pool_alloc (strlen ((yyvsp[(1) - (4)].id)) + 1 + strlen ((yyvsp[(3) - (4)].digits)) + strlen ((yyvsp[(4) - (4)].id)) + 1);
2026 sprintf (id, "%s.%s%s", (yyvsp[(1) - (4)].id), (yyvsp[(3) - (4)].digits), (yyvsp[(4) - (4)].id));
2032 #line 335 "deffilep.y"
2033 { (yyval.digits) = (yyvsp[(1) - (1)].digits); }
2037 #line 336 "deffilep.y"
2038 { (yyval.digits) = ""; }
2042 #line 339 "deffilep.y"
2043 { (yyval.id) = (yyvsp[(1) - (1)].id); }
2047 #line 340 "deffilep.y"
2048 { (yyval.id) = ""; }
2052 #line 343 "deffilep.y"
2053 { (yyval.number) = strtoul ((yyvsp[(1) - (1)].digits), 0, 0); }
2057 #line 345 "deffilep.y"
2058 { (yyval.vma) = (bfd_vma) strtoull ((yyvsp[(1) - (1)].digits), 0, 0); }
2062 /* Line 1267 of yacc.c. */
2063 #line 2064 "deffilep.c"
2066 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2070 YY_STACK_PRINT (yyss, yyssp);
2075 /* Now `shift' the result of the reduction. Determine what state
2076 that goes to, based on the state we popped back to and the rule
2077 number reduced by. */
2081 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2082 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2083 yystate = yytable[yystate];
2085 yystate = yydefgoto[yyn - YYNTOKENS];
2090 /*------------------------------------.
2091 | yyerrlab -- here on detecting error |
2092 `------------------------------------*/
2094 /* If not already recovering from an error, report this error. */
2098 #if ! YYERROR_VERBOSE
2099 yyerror (YY_("syntax error"));
2102 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
2103 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
2105 YYSIZE_T yyalloc = 2 * yysize;
2106 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
2107 yyalloc = YYSTACK_ALLOC_MAXIMUM;
2108 if (yymsg != yymsgbuf)
2109 YYSTACK_FREE (yymsg);
2110 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
2112 yymsg_alloc = yyalloc;
2116 yymsg_alloc = sizeof yymsgbuf;
2120 if (0 < yysize && yysize <= yymsg_alloc)
2122 (void) yysyntax_error (yymsg, yystate, yychar);
2127 yyerror (YY_("syntax error"));
2129 goto yyexhaustedlab;
2137 if (yyerrstatus == 3)
2139 /* If just tried and failed to reuse look-ahead token after an
2140 error, discard it. */
2142 if (yychar <= YYEOF)
2144 /* Return failure if at end of input. */
2145 if (yychar == YYEOF)
2150 yydestruct ("Error: discarding",
2156 /* Else will try to reuse look-ahead token after shifting the error
2161 /*---------------------------------------------------.
2162 | yyerrorlab -- error raised explicitly by YYERROR. |
2163 `---------------------------------------------------*/
2166 /* Pacify compilers like GCC when the user code never invokes
2167 YYERROR and the label yyerrorlab therefore never appears in user
2169 if (/*CONSTCOND*/ 0)
2172 /* Do not reclaim the symbols of the rule which action triggered
2176 YY_STACK_PRINT (yyss, yyssp);
2181 /*-------------------------------------------------------------.
2182 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2183 `-------------------------------------------------------------*/
2185 yyerrstatus = 3; /* Each real token shifted decrements this. */
2189 yyn = yypact[yystate];
2190 if (yyn != YYPACT_NINF)
2193 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2201 /* Pop the current state because it cannot handle the error token. */
2206 yydestruct ("Error: popping",
2207 yystos[yystate], yyvsp);
2210 YY_STACK_PRINT (yyss, yyssp);
2219 /* Shift the error token. */
2220 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2226 /*-------------------------------------.
2227 | yyacceptlab -- YYACCEPT comes here. |
2228 `-------------------------------------*/
2233 /*-----------------------------------.
2234 | yyabortlab -- YYABORT comes here. |
2235 `-----------------------------------*/
2241 /*-------------------------------------------------.
2242 | yyexhaustedlab -- memory exhaustion comes here. |
2243 `-------------------------------------------------*/
2245 yyerror (YY_("memory exhausted"));
2251 if (yychar != YYEOF && yychar != YYEMPTY)
2252 yydestruct ("Cleanup: discarding lookahead",
2254 /* Do not reclaim the symbols of the rule which action triggered
2255 this YYABORT or YYACCEPT. */
2257 YY_STACK_PRINT (yyss, yyssp);
2258 while (yyssp != yyss)
2260 yydestruct ("Cleanup: popping",
2261 yystos[*yyssp], yyvsp);
2266 YYSTACK_FREE (yyss);
2269 if (yymsg != yymsgbuf)
2270 YYSTACK_FREE (yymsg);
2272 /* Make sure YYID is used. */
2273 return YYID (yyresult);
2277 #line 347 "deffilep.y"
2280 /*****************************************************************************
2282 *****************************************************************************/
2284 static FILE *the_file;
2285 static const char *def_filename;
2286 static int linenumber;
2287 static def_file *def;
2288 static int saw_newline;
2292 struct directive *next;
2297 static struct directive *directives = 0;
2300 def_file_empty (void)
2302 def_file *rv = xmalloc (sizeof (def_file));
2303 memset (rv, 0, sizeof (def_file));
2305 rv->base_address = (bfd_vma) -1;
2306 rv->stack_reserve = rv->stack_commit = -1;
2307 rv->heap_reserve = rv->heap_commit = -1;
2308 rv->version_major = rv->version_minor = -1;
2313 def_file_parse (const char *filename, def_file *add_to)
2315 struct directive *d;
2317 the_file = fopen (filename, "r");
2318 def_filename = filename;
2331 def = def_file_empty ();
2337 def_file_free (def);
2345 while ((d = directives) != NULL)
2348 printf ("Adding directive %08x `%s'\n", d->name, d->name);
2350 def_file_add_directive (def, d->name, d->len);
2351 directives = d->next;
2361 def_file_free (def_file *fdef)
2369 if (fdef->description)
2370 free (fdef->description);
2372 if (fdef->section_defs)
2374 for (i = 0; i < fdef->num_section_defs; i++)
2376 if (fdef->section_defs[i].name)
2377 free (fdef->section_defs[i].name);
2378 if (fdef->section_defs[i].class)
2379 free (fdef->section_defs[i].class);
2381 free (fdef->section_defs);
2386 for (i = 0; i < fdef->num_exports; i++)
2388 if (fdef->exports[i].internal_name
2389 && fdef->exports[i].internal_name != fdef->exports[i].name)
2390 free (fdef->exports[i].internal_name);
2391 if (fdef->exports[i].name)
2392 free (fdef->exports[i].name);
2393 if (fdef->exports[i].its_name)
2394 free (fdef->exports[i].its_name);
2396 free (fdef->exports);
2401 for (i = 0; i < fdef->num_imports; i++)
2403 if (fdef->imports[i].internal_name
2404 && fdef->imports[i].internal_name != fdef->imports[i].name)
2405 free (fdef->imports[i].internal_name);
2406 if (fdef->imports[i].name)
2407 free (fdef->imports[i].name);
2408 if (fdef->imports[i].its_name)
2409 free (fdef->imports[i].its_name);
2411 free (fdef->imports);
2414 while (fdef->modules)
2416 def_file_module *m = fdef->modules;
2418 fdef->modules = fdef->modules->next;
2422 while (fdef->aligncomms)
2424 def_file_aligncomm *c = fdef->aligncomms;
2426 fdef->aligncomms = fdef->aligncomms->next;
2427 free (c->symbol_name);
2434 #ifdef DEF_FILE_PRINT
2436 def_file_print (FILE *file, def_file *fdef)
2440 fprintf (file, ">>>> def_file at 0x%08x\n", fdef);
2442 fprintf (file, " name: %s\n", fdef->name ? fdef->name : "(unspecified)");
2443 if (fdef->is_dll != -1)
2444 fprintf (file, " is dll: %s\n", fdef->is_dll ? "yes" : "no");
2445 if (fdef->base_address != (bfd_vma) -1)
2447 fprintf (file, " base address: 0x");
2448 fprintf_vma (file, fdef->base_address);
2449 fprintf (file, "\n");
2451 if (fdef->description)
2452 fprintf (file, " description: `%s'\n", fdef->description);
2453 if (fdef->stack_reserve != -1)
2454 fprintf (file, " stack reserve: 0x%08x\n", fdef->stack_reserve);
2455 if (fdef->stack_commit != -1)
2456 fprintf (file, " stack commit: 0x%08x\n", fdef->stack_commit);
2457 if (fdef->heap_reserve != -1)
2458 fprintf (file, " heap reserve: 0x%08x\n", fdef->heap_reserve);
2459 if (fdef->heap_commit != -1)
2460 fprintf (file, " heap commit: 0x%08x\n", fdef->heap_commit);
2462 if (fdef->num_section_defs > 0)
2464 fprintf (file, " section defs:\n");
2466 for (i = 0; i < fdef->num_section_defs; i++)
2468 fprintf (file, " name: `%s', class: `%s', flags:",
2469 fdef->section_defs[i].name, fdef->section_defs[i].class);
2470 if (fdef->section_defs[i].flag_read)
2471 fprintf (file, " R");
2472 if (fdef->section_defs[i].flag_write)
2473 fprintf (file, " W");
2474 if (fdef->section_defs[i].flag_execute)
2475 fprintf (file, " X");
2476 if (fdef->section_defs[i].flag_shared)
2477 fprintf (file, " S");
2478 fprintf (file, "\n");
2482 if (fdef->num_exports > 0)
2484 fprintf (file, " exports:\n");
2486 for (i = 0; i < fdef->num_exports; i++)
2488 fprintf (file, " name: `%s', int: `%s', ordinal: %d, flags:",
2489 fdef->exports[i].name, fdef->exports[i].internal_name,
2490 fdef->exports[i].ordinal);
2491 if (fdef->exports[i].flag_private)
2492 fprintf (file, " P");
2493 if (fdef->exports[i].flag_constant)
2494 fprintf (file, " C");
2495 if (fdef->exports[i].flag_noname)
2496 fprintf (file, " N");
2497 if (fdef->exports[i].flag_data)
2498 fprintf (file, " D");
2499 fprintf (file, "\n");
2503 if (fdef->num_imports > 0)
2505 fprintf (file, " imports:\n");
2507 for (i = 0; i < fdef->num_imports; i++)
2509 fprintf (file, " int: %s, from: `%s', name: `%s', ordinal: %d\n",
2510 fdef->imports[i].internal_name,
2511 fdef->imports[i].module,
2512 fdef->imports[i].name,
2513 fdef->imports[i].ordinal);
2517 if (fdef->version_major != -1)
2518 fprintf (file, " version: %d.%d\n", fdef->version_major, fdef->version_minor);
2520 fprintf (file, "<<<< def_file at 0x%08x\n", fdef);
2524 /* Helper routine to check for identity of string pointers,
2525 which might be NULL. */
2528 are_names_equal (const char *s1, const char *s2)
2533 return (!s1 ? -1 : 1);
2534 return strcmp (s1, s2);
2538 cmp_export_elem (const def_file_export *e, const char *ex_name,
2539 const char *in_name, const char *its_name,
2544 if ((r = are_names_equal (ex_name, e->name)) != 0)
2546 if ((r = are_names_equal (in_name, e->internal_name)) != 0)
2548 if ((r = are_names_equal (its_name, e->its_name)) != 0)
2550 return (ord - e->ordinal);
2553 /* Search the position of the identical element, or returns the position
2554 of the next higher element. If last valid element is smaller, then MAX
2558 find_export_in_list (def_file_export *b, int max,
2559 const char *ex_name, const char *in_name,
2560 const char *its_name, int ord, int *is_ident)
2567 if ((e = cmp_export_elem (b, ex_name, in_name, its_name, ord)) <= 0)
2575 if ((e = cmp_export_elem (b + (max - 1), ex_name, in_name, its_name, ord)) > 0)
2577 else if (!e || max == 2)
2587 e = cmp_export_elem (b + p, ex_name, in_name, its_name, ord);
2598 if ((e = cmp_export_elem (b + l, ex_name, in_name, its_name, ord)) > 0)
2606 def_file_add_export (def_file *fdef,
2607 const char *external_name,
2608 const char *internal_name,
2610 const char *its_name,
2615 int max_exports = ROUND_UP(fdef->num_exports, 32);
2617 if (internal_name && !external_name)
2618 external_name = internal_name;
2619 if (external_name && !internal_name)
2620 internal_name = external_name;
2622 /* We need to avoid duplicates. */
2624 pos = find_export_in_list (fdef->exports, fdef->num_exports,
2625 external_name, internal_name,
2626 its_name, ordinal, is_dup);
2629 return (fdef->exports + pos);
2631 if (fdef->num_exports >= max_exports)
2633 max_exports = ROUND_UP(fdef->num_exports + 1, 32);
2635 fdef->exports = xrealloc (fdef->exports,
2636 max_exports * sizeof (def_file_export));
2638 fdef->exports = xmalloc (max_exports * sizeof (def_file_export));
2641 e = fdef->exports + pos;
2642 if (pos != fdef->num_exports)
2643 memmove (&e[1], e, (sizeof (def_file_export) * (fdef->num_exports - pos)));
2644 memset (e, 0, sizeof (def_file_export));
2645 e->name = xstrdup (external_name);
2646 e->internal_name = xstrdup (internal_name);
2647 e->its_name = (its_name ? xstrdup (its_name) : NULL);
2648 e->ordinal = ordinal;
2649 fdef->num_exports++;
2654 def_get_module (def_file *fdef, const char *name)
2658 for (s = fdef->modules; s; s = s->next)
2659 if (strcmp (s->name, name) == 0)
2665 static def_file_module *
2666 def_stash_module (def_file *fdef, const char *name)
2670 if ((s = def_get_module (fdef, name)) != NULL)
2672 s = xmalloc (sizeof (def_file_module) + strlen (name));
2673 s->next = fdef->modules;
2676 strcpy (s->name, name);
2681 cmp_import_elem (const def_file_import *e, const char *ex_name,
2682 const char *in_name, const char *module,
2687 if ((r = are_names_equal (module, (e->module ? e->module->name : NULL))))
2689 if ((r = are_names_equal (ex_name, e->name)) != 0)
2691 if ((r = are_names_equal (in_name, e->internal_name)) != 0)
2693 if (ord != e->ordinal)
2694 return (ord < e->ordinal ? -1 : 1);
2698 /* Search the position of the identical element, or returns the position
2699 of the next higher element. If last valid element is smaller, then MAX
2703 find_import_in_list (def_file_import *b, int max,
2704 const char *ex_name, const char *in_name,
2705 const char *module, int ord, int *is_ident)
2712 if ((e = cmp_import_elem (b, ex_name, in_name, module, ord)) <= 0)
2720 if ((e = cmp_import_elem (b + (max - 1), ex_name, in_name, module, ord)) > 0)
2722 else if (!e || max == 2)
2732 e = cmp_import_elem (b + p, ex_name, in_name, module, ord);
2743 if ((e = cmp_import_elem (b + l, ex_name, in_name, module, ord)) > 0)
2751 def_file_add_import (def_file *fdef,
2755 const char *internal_name,
2756 const char *its_name,
2761 int max_imports = ROUND_UP (fdef->num_imports, 16);
2763 /* We need to avoid here duplicates. */
2765 pos = find_import_in_list (fdef->imports, fdef->num_imports,
2767 (!internal_name ? name : internal_name),
2768 module, ordinal, is_dup);
2770 return fdef->imports + pos;
2772 if (fdef->num_imports >= max_imports)
2774 max_imports = ROUND_UP (fdef->num_imports+1, 16);
2777 fdef->imports = xrealloc (fdef->imports,
2778 max_imports * sizeof (def_file_import));
2780 fdef->imports = xmalloc (max_imports * sizeof (def_file_import));
2782 i = fdef->imports + pos;
2783 if (pos != fdef->num_imports)
2784 memmove (&i[1], i, (sizeof (def_file_import) * (fdef->num_imports - pos)));
2785 memset (i, 0, sizeof (def_file_import));
2787 i->name = xstrdup (name);
2789 i->module = def_stash_module (fdef, module);
2790 i->ordinal = ordinal;
2792 i->internal_name = xstrdup (internal_name);
2794 i->internal_name = i->name;
2795 i->its_name = (its_name ? xstrdup (its_name) : NULL);
2796 fdef->num_imports++;
2808 { "-heap", HEAPSIZE },
2809 { "-stack", STACKSIZE_K },
2810 { "-attr", SECTIONS },
2811 { "-export", EXPORTS },
2812 { "-aligncomm", ALIGNCOMM },
2817 def_file_add_directive (def_file *my_def, const char *param, int len)
2819 def_file *save_def = def;
2820 const char *pend = param + len;
2821 char * tend = (char *) param;
2826 while (param < pend)
2829 && (ISSPACE (*param) || *param == '\n' || *param == 0))
2835 /* Scan forward until we encounter any of:
2836 - the end of the buffer
2837 - the start of a new option
2838 - a newline seperating options
2839 - a NUL seperating options. */
2840 for (tend = (char *) (param + 1);
2842 && !(ISSPACE (tend[-1]) && *tend == '-')
2843 && *tend != '\n' && *tend != 0);
2847 for (i = 0; diropts[i].param; i++)
2849 len = strlen (diropts[i].param);
2851 if (tend - param >= len
2852 && strncmp (param, diropts[i].param, len) == 0
2853 && (param[len] == ':' || param[len] == ' '))
2855 lex_parse_string_end = tend;
2856 lex_parse_string = param + len + 1;
2857 lex_forced_token = diropts[i].token;
2865 if (!diropts[i].param)
2873 /* xgettext:c-format */
2874 einfo (_("Warning: .drectve `%s' unrecognized\n"), param);
2879 einfo (_("Warning: corrupt .drectve at end of def file\n"));
2883 lex_parse_string = 0;
2891 /* Parser Callbacks. */
2894 def_image_name (const char *name, bfd_vma base, int is_dll)
2896 /* If a LIBRARY or NAME statement is specified without a name, there is nothing
2897 to do here. We retain the output filename specified on command line. */
2900 const char* image_name = lbasename (name);
2902 if (image_name != name)
2903 einfo ("%s:%d: Warning: path components stripped from %s, '%s'\n",
2904 def_filename, linenumber, is_dll ? "LIBRARY" : "NAME",
2908 /* Append the default suffix, if none specified. */
2909 if (strchr (image_name, '.') == 0)
2911 const char * suffix = is_dll ? ".dll" : ".exe";
2913 def->name = xmalloc (strlen (image_name) + strlen (suffix) + 1);
2914 sprintf (def->name, "%s%s", image_name, suffix);
2917 def->name = xstrdup (image_name);
2920 /* Honor a BASE address statement, even if LIBRARY string is empty. */
2921 def->base_address = base;
2922 def->is_dll = is_dll;
2926 def_description (const char *text)
2928 int len = def->description ? strlen (def->description) : 0;
2930 len += strlen (text) + 1;
2931 if (def->description)
2933 def->description = xrealloc (def->description, len);
2934 strcat (def->description, text);
2938 def->description = xmalloc (len);
2939 strcpy (def->description, text);
2944 def_stacksize (int reserve, int commit)
2946 def->stack_reserve = reserve;
2947 def->stack_commit = commit;
2951 def_heapsize (int reserve, int commit)
2953 def->heap_reserve = reserve;
2954 def->heap_commit = commit;
2958 def_section (const char *name, int attr)
2960 def_file_section *s;
2961 int max_sections = ROUND_UP (def->num_section_defs, 4);
2963 if (def->num_section_defs >= max_sections)
2965 max_sections = ROUND_UP (def->num_section_defs+1, 4);
2967 if (def->section_defs)
2968 def->section_defs = xrealloc (def->section_defs,
2969 max_sections * sizeof (def_file_import));
2971 def->section_defs = xmalloc (max_sections * sizeof (def_file_import));
2973 s = def->section_defs + def->num_section_defs;
2974 memset (s, 0, sizeof (def_file_section));
2975 s->name = xstrdup (name);
2981 s->flag_execute = 1;
2985 def->num_section_defs++;
2989 def_section_alt (const char *name, const char *attr)
2993 for (; *attr; attr++)
3015 def_section (name, aval);
3019 def_exports (const char *external_name,
3020 const char *internal_name,
3023 const char *its_name)
3025 def_file_export *dfe;
3028 if (!internal_name && external_name)
3029 internal_name = external_name;
3031 printf ("def_exports, ext=%s int=%s\n", external_name, internal_name);
3034 dfe = def_file_add_export (def, external_name, internal_name, ordinal,
3037 /* We might check here for flag redefinition and warn. For now we
3038 ignore duplicates silently. */
3043 dfe->flag_noname = 1;
3045 dfe->flag_constant = 1;
3049 dfe->flag_private = 1;
3053 def_import (const char *internal_name,
3058 const char *its_name)
3061 const char *ext = dllext ? dllext : "dll";
3064 buf = xmalloc (strlen (module) + strlen (ext) + 2);
3065 sprintf (buf, "%s.%s", module, ext);
3068 def_file_add_import (def, name, module, ordinal, internal_name, its_name,
3074 def_version (int major, int minor)
3076 def->version_major = major;
3077 def->version_minor = minor;
3081 def_directive (char *str)
3083 struct directive *d = xmalloc (sizeof (struct directive));
3085 d->next = directives;
3087 d->name = xstrdup (str);
3088 d->len = strlen (str);
3092 def_aligncomm (char *str, int align)
3094 def_file_aligncomm *c, *p;
3097 c = def->aligncomms;
3100 int e = strcmp (c->symbol_name, str);
3103 /* Not sure if we want to allow here duplicates with
3104 different alignments, but for now we keep them. */
3105 e = (int) c->alignment - align;
3114 c = xmalloc (sizeof (def_file_aligncomm));
3115 c->symbol_name = xstrdup (str);
3116 c->alignment = (unsigned int) align;
3119 c->next = def->aligncomms;
3120 def->aligncomms = c;
3130 def_error (const char *err)
3132 einfo ("%P: %s:%d: %s\n",
3133 def_filename ? def_filename : "<unknown-file>", linenumber, err);
3138 /* Lexical Scanner. */
3143 /* Never freed, but always reused as needed, so no real leak. */
3144 static char *buffer = 0;
3145 static int buflen = 0;
3146 static int bufptr = 0;
3151 if (bufptr == buflen)
3153 buflen += 50; /* overly reasonable, eh? */
3155 buffer = xrealloc (buffer, buflen + 1);
3157 buffer = xmalloc (buflen + 1);
3159 buffer[bufptr++] = c;
3160 buffer[bufptr] = 0; /* not optimal, but very convenient. */
3172 { "CONSTANT", CONSTANTU },
3173 { "constant", CONSTANTL },
3176 { "DESCRIPTION", DESCRIPTION },
3177 { "DIRECTIVE", DIRECTIVE },
3178 { "EXECUTE", EXECUTE },
3179 { "EXPORTS", EXPORTS },
3180 { "HEAPSIZE", HEAPSIZE },
3181 { "IMPORTS", IMPORTS },
3182 { "LIBRARY", LIBRARY },
3184 { "NONAME", NONAMEU },
3185 { "noname", NONAMEL },
3186 { "PRIVATE", PRIVATEU },
3187 { "private", PRIVATEL },
3189 { "SECTIONS", SECTIONS },
3190 { "SEGMENTS", SECTIONS },
3191 { "SHARED", SHARED },
3192 { "STACKSIZE", STACKSIZE_K },
3193 { "VERSION", VERSIONK },
3203 if (lex_parse_string)
3205 if (lex_parse_string >= lex_parse_string_end)
3208 rv = *lex_parse_string++;
3212 rv = fgetc (the_file);
3222 if (lex_parse_string)
3228 return ungetc (c, the_file);
3236 if (lex_forced_token)
3238 i = lex_forced_token;
3239 lex_forced_token = 0;
3241 printf ("lex: forcing token %d\n", i);
3248 /* Trim leading whitespace. */
3249 while (c != EOF && (c == ' ' || c == '\t') && saw_newline)
3255 printf ("lex: EOF\n");
3260 if (saw_newline && c == ';')
3266 while (c != EOF && c != '\n');
3272 /* Must be something else. */
3278 while (c != EOF && (ISXDIGIT (c) || (c == 'x')))
3285 yylval.digits = def_pool_strdup (buffer);
3287 printf ("lex: `%s' returns DIGITS\n", buffer);
3292 if (ISALPHA (c) || strchr ("$:-_?@", c))
3301 if (ISBLANK (c) ) /* '@' followed by whitespace. */
3303 else if (ISDIGIT (c)) /* '@' followed by digit. */
3309 printf ("lex: @ returns itself\n");
3313 while (c != EOF && (ISALNUM (c) || strchr ("$:-_?/@<>", c)))
3320 if (ISALPHA (q)) /* Check for tokens. */
3322 for (i = 0; tokens[i].name; i++)
3323 if (strcmp (tokens[i].name, buffer) == 0)
3326 printf ("lex: `%s' is a string token\n", buffer);
3328 return tokens[i].token;
3332 printf ("lex: `%s' returns ID\n", buffer);
3334 yylval.id = def_pool_strdup (buffer);
3338 if (c == '\'' || c == '"')
3344 while (c != EOF && c != q)
3349 yylval.id = def_pool_strdup (buffer);
3351 printf ("lex: `%s' returns ID\n", buffer);
3362 printf ("lex: `==' returns EQUAL\n");
3368 printf ("lex: `=' returns itself\n");
3372 if (c == '.' || c == ',')
3375 printf ("lex: `%c' returns itself\n", c);
3386 /*printf ("lex: 0x%02x ignored\n", c); */
3391 def_pool_alloc (size_t sz)
3395 e = (def_pool_str *) xmalloc (sizeof (def_pool_str) + sz);
3396 e->next = pool_strs;
3402 def_pool_strdup (const char *str)
3408 len = strlen (str) + 1;
3409 s = def_pool_alloc (len);
3410 memcpy (s, str, len);
3415 def_pool_free (void)
3418 while ((p = pool_strs) != NULL)
3420 pool_strs = p->next;