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 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006,
137 2007, 2009 Free Software Foundation, Inc.
139 This file is part of GNU Binutils.
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.
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.
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. */
157 #include "libiberty.h"
158 #include "safe-ctype.h"
166 #define ROUND_UP(a, b) (((a)+((b)-1))&~((b)-1))
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. */
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
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
195 #define yy_yys def_yys
196 #define yystate def_state
197 #define yytmp def_tmp
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
214 typedef struct def_pool_str {
215 struct def_pool_str *next;
219 static def_pool_str *pool_strs = NULL;
221 static char *def_pool_alloc (size_t sz);
222 static char *def_pool_strdup (const char *str);
223 static void def_pool_free (void);
225 static void def_description (const char *);
226 static void def_exports (const char *, const char *, int, int, const char *);
227 static void def_heapsize (int, int);
228 static void def_import (const char *, const char *, const char *, const char *,
230 static void def_image_name (const char *, int, int);
231 static void def_section (const char *, int);
232 static void def_section_alt (const char *, const char *);
233 static void def_stacksize (int, int);
234 static void def_version (int, int);
235 static void def_directive (char *);
236 static void def_aligncomm (char *str, int align);
237 static int def_parse (void);
238 static int def_error (const char *);
239 static int def_lex (void);
241 static int lex_forced_token = 0;
242 static const char *lex_parse_string = 0;
243 static const char *lex_parse_string_end = 0;
247 /* Enabling traces. */
252 /* Enabling verbose error messages. */
253 #ifdef YYERROR_VERBOSE
254 # undef YYERROR_VERBOSE
255 # define YYERROR_VERBOSE 1
257 # define YYERROR_VERBOSE 0
260 /* Enabling the token table. */
261 #ifndef YYTOKEN_TABLE
262 # define YYTOKEN_TABLE 0
265 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
266 typedef union YYSTYPE
267 #line 114 "deffilep.y"
273 /* Line 193 of yacc.c. */
274 #line 275 "deffilep.c"
276 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
277 # define YYSTYPE_IS_DECLARED 1
278 # define YYSTYPE_IS_TRIVIAL 1
283 /* Copy the second part of user declarations. */
286 /* Line 216 of yacc.c. */
287 #line 288 "deffilep.c"
294 typedef YYTYPE_UINT8 yytype_uint8;
296 typedef unsigned char yytype_uint8;
300 typedef YYTYPE_INT8 yytype_int8;
301 #elif (defined __STDC__ || defined __C99__FUNC__ \
302 || defined __cplusplus || defined _MSC_VER)
303 typedef signed char yytype_int8;
305 typedef short int yytype_int8;
309 typedef YYTYPE_UINT16 yytype_uint16;
311 typedef unsigned short int yytype_uint16;
315 typedef YYTYPE_INT16 yytype_int16;
317 typedef short int yytype_int16;
321 # ifdef __SIZE_TYPE__
322 # define YYSIZE_T __SIZE_TYPE__
323 # elif defined size_t
324 # define YYSIZE_T size_t
325 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
326 || defined __cplusplus || defined _MSC_VER)
327 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
328 # define YYSIZE_T size_t
330 # define YYSIZE_T unsigned int
334 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
337 # if defined YYENABLE_NLS && YYENABLE_NLS
339 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
340 # define YY_(msgid) dgettext ("bison-runtime", msgid)
344 # define YY_(msgid) msgid
348 /* Suppress unused-variable warnings by "using" E. */
349 #if ! defined lint || defined __GNUC__
350 # define YYUSE(e) ((void) (e))
352 # define YYUSE(e) /* empty */
355 /* Identity function, used to suppress warnings about constant conditions. */
359 #if (defined __STDC__ || defined __C99__FUNC__ \
360 || defined __cplusplus || defined _MSC_VER)
373 #if ! defined yyoverflow || YYERROR_VERBOSE
375 /* The parser invokes alloca or malloc; define the necessary symbols. */
377 # ifdef YYSTACK_USE_ALLOCA
378 # if YYSTACK_USE_ALLOCA
380 # define YYSTACK_ALLOC __builtin_alloca
381 # elif defined __BUILTIN_VA_ARG_INCR
382 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
384 # define YYSTACK_ALLOC __alloca
385 # elif defined _MSC_VER
386 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
387 # define alloca _alloca
389 # define YYSTACK_ALLOC alloca
390 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
391 || defined __cplusplus || defined _MSC_VER)
392 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
401 # ifdef YYSTACK_ALLOC
402 /* Pacify GCC's `empty if-body' warning. */
403 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
404 # ifndef YYSTACK_ALLOC_MAXIMUM
405 /* The OS might guarantee only one guard page at the bottom of the stack,
406 and a page size can be as small as 4096 bytes. So we cannot safely
407 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
408 to allow for a few compiler-allocated temporary stack slots. */
409 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
412 # define YYSTACK_ALLOC YYMALLOC
413 # define YYSTACK_FREE YYFREE
414 # ifndef YYSTACK_ALLOC_MAXIMUM
415 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
417 # if (defined __cplusplus && ! defined _STDLIB_H \
418 && ! ((defined YYMALLOC || defined malloc) \
419 && (defined YYFREE || defined free)))
420 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
426 # define YYMALLOC malloc
427 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
428 || defined __cplusplus || defined _MSC_VER)
429 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
434 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
435 || defined __cplusplus || defined _MSC_VER)
436 void free (void *); /* INFRINGES ON USER NAME SPACE */
440 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
443 #if (! defined yyoverflow \
444 && (! defined __cplusplus \
445 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
447 /* A type that is properly aligned for any stack member. */
454 /* The size of the maximum gap between one aligned stack and the next. */
455 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
457 /* The size of an array large to enough to hold all stacks, each with
459 # define YYSTACK_BYTES(N) \
460 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
461 + YYSTACK_GAP_MAXIMUM)
463 /* Copy COUNT objects from FROM to TO. The source and destination do
466 # if defined __GNUC__ && 1 < __GNUC__
467 # define YYCOPY(To, From, Count) \
468 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
470 # define YYCOPY(To, From, Count) \
474 for (yyi = 0; yyi < (Count); yyi++) \
475 (To)[yyi] = (From)[yyi]; \
481 /* Relocate STACK from its old location to the new one. The
482 local variables YYSIZE and YYSTACKSIZE give the old and new number of
483 elements in the stack, and YYPTR gives the new location of the
484 stack. Advance YYPTR to a properly aligned location for the next
486 # define YYSTACK_RELOCATE(Stack) \
489 YYSIZE_T yynewbytes; \
490 YYCOPY (&yyptr->Stack, Stack, yysize); \
491 Stack = &yyptr->Stack; \
492 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
493 yyptr += yynewbytes / sizeof (*yyptr); \
499 /* YYFINAL -- State number of the termination state. */
501 /* YYLAST -- Last index in YYTABLE. */
504 /* YYNTOKENS -- Number of terminals. */
506 /* YYNNTS -- Number of nonterminals. */
508 /* YYNRULES -- Number of rules. */
510 /* YYNRULES -- Number of states. */
511 #define YYNSTATES 123
513 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
515 #define YYMAXUTOK 285
517 #define YYTRANSLATE(YYX) \
518 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
520 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
521 static const yytype_uint8 yytranslate[] =
523 0, 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, 32, 2, 31, 2, 2, 2,
528 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
529 2, 33, 2, 2, 34, 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, 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, 1, 2, 3, 4,
549 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
550 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
551 25, 26, 27, 28, 29, 30
555 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
557 static const yytype_uint8 yyprhs[] =
559 0, 0, 3, 6, 8, 12, 16, 19, 23, 27,
560 30, 33, 36, 39, 42, 45, 50, 53, 58, 59,
561 61, 64, 72, 76, 77, 79, 81, 83, 85, 87,
562 89, 91, 93, 96, 98, 107, 116, 123, 130, 137,
563 142, 145, 147, 150, 153, 157, 159, 161, 162, 165,
564 166, 168, 170, 172, 174, 176, 179, 183, 184, 187,
565 188, 191, 192, 195, 196, 200, 201, 203, 206, 210,
566 212, 215, 220, 222, 223, 225, 226
569 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
570 static const yytype_int8 yyrhs[] =
572 36, 0, -1, 36, 37, -1, 37, -1, 3, 50,
573 54, -1, 4, 50, 54, -1, 5, 29, -1, 6,
574 59, 48, -1, 7, 59, 48, -1, 8, 46, -1,
575 9, 46, -1, 11, 44, -1, 12, 38, -1, 13,
576 42, -1, 14, 59, -1, 14, 59, 31, 59, -1,
577 27, 29, -1, 20, 56, 32, 59, -1, -1, 39,
578 -1, 38, 39, -1, 55, 53, 52, 47, 40, 47,
579 51, -1, 41, 47, 40, -1, -1, 25, -1, 26,
580 -1, 16, -1, 17, -1, 9, -1, 10, -1, 18,
581 -1, 19, -1, 42, 43, -1, 43, -1, 29, 33,
582 29, 31, 29, 31, 29, 51, -1, 29, 33, 29,
583 31, 29, 31, 59, 51, -1, 29, 33, 29, 31,
584 29, 51, -1, 29, 33, 29, 31, 59, 51, -1,
585 29, 31, 29, 31, 29, 51, -1, 29, 31, 29,
586 51, -1, 44, 45, -1, 45, -1, 29, 46, -1,
587 29, 29, -1, 46, 47, 49, -1, 49, -1, 32,
588 -1, -1, 32, 59, -1, -1, 21, -1, 22, -1,
589 23, -1, 24, -1, 29, -1, 31, 29, -1, 29,
590 31, 29, -1, -1, 28, 29, -1, -1, 34, 59,
591 -1, -1, 33, 55, -1, -1, 15, 33, 59, -1,
592 -1, 29, -1, 31, 29, -1, 55, 31, 29, -1,
593 29, -1, 31, 29, -1, 56, 31, 57, 58, -1,
594 30, -1, -1, 29, -1, -1, 30, -1
597 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
598 static const yytype_uint16 yyrline[] =
600 0, 135, 135, 136, 140, 141, 142, 143, 144, 145,
601 146, 147, 148, 149, 150, 151, 152, 153, 157, 159,
602 160, 167, 174, 175, 178, 179, 180, 181, 182, 183,
603 184, 185, 188, 189, 193, 195, 197, 199, 201, 203,
604 208, 209, 213, 214, 218, 219, 223, 224, 226, 227,
605 231, 232, 233, 234, 237, 238, 244, 250, 253, 254,
606 258, 259, 263, 264, 267, 268, 271, 272, 278, 286,
607 287, 293, 301, 302, 305, 306, 309
611 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
612 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
613 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
614 static const char *const yytname[] =
616 "$end", "error", "$undefined", "NAME", "LIBRARY", "DESCRIPTION",
617 "STACKSIZE_K", "HEAPSIZE", "CODE", "DATAU", "DATAL", "SECTIONS",
618 "EXPORTS", "IMPORTS", "VERSIONK", "BASE", "CONSTANTU", "CONSTANTL",
619 "PRIVATEU", "PRIVATEL", "ALIGNCOMM", "READ", "WRITE", "EXECUTE",
620 "SHARED", "NONAMEU", "NONAMEL", "DIRECTIVE", "EQUAL", "ID", "DIGITS",
621 "'.'", "','", "'='", "'@'", "$accept", "start", "command", "explist",
622 "expline", "exp_opt_list", "exp_opt", "implist", "impline", "seclist",
623 "secline", "attr_list", "opt_comma", "opt_number", "attr", "opt_name",
624 "opt_equalequal_name", "opt_ordinal", "opt_equal_name", "opt_base",
625 "dot_name", "anylang_id", "opt_digits", "opt_id", "NUMBER", 0
630 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
632 static const yytype_uint16 yytoknum[] =
634 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
635 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
636 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
641 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
642 static const yytype_uint8 yyr1[] =
644 0, 35, 36, 36, 37, 37, 37, 37, 37, 37,
645 37, 37, 37, 37, 37, 37, 37, 37, 38, 38,
646 38, 39, 40, 40, 41, 41, 41, 41, 41, 41,
647 41, 41, 42, 42, 43, 43, 43, 43, 43, 43,
648 44, 44, 45, 45, 46, 46, 47, 47, 48, 48,
649 49, 49, 49, 49, 50, 50, 50, 50, 51, 51,
650 52, 52, 53, 53, 54, 54, 55, 55, 55, 56,
651 56, 56, 57, 57, 58, 58, 59
654 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
655 static const yytype_uint8 yyr2[] =
657 0, 2, 2, 1, 3, 3, 2, 3, 3, 2,
658 2, 2, 2, 2, 2, 4, 2, 4, 0, 1,
659 2, 7, 3, 0, 1, 1, 1, 1, 1, 1,
660 1, 1, 2, 1, 8, 8, 6, 6, 6, 4,
661 2, 1, 2, 2, 3, 1, 1, 0, 2, 0,
662 1, 1, 1, 1, 1, 2, 3, 0, 2, 0,
663 2, 0, 2, 0, 3, 0, 1, 2, 3, 1,
667 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
668 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
669 means the default is an error. */
670 static const yytype_uint8 yydefact[] =
672 0, 57, 57, 0, 0, 0, 0, 0, 0, 18,
673 0, 0, 0, 0, 0, 3, 54, 0, 65, 65,
674 6, 76, 49, 49, 50, 51, 52, 53, 9, 45,
675 10, 0, 11, 41, 66, 0, 12, 19, 63, 0,
676 13, 33, 14, 69, 0, 0, 16, 1, 2, 0,
677 55, 0, 4, 5, 0, 7, 8, 46, 0, 43,
678 42, 40, 67, 20, 0, 0, 61, 0, 0, 32,
679 0, 70, 73, 0, 56, 0, 48, 44, 68, 62,
680 0, 47, 59, 0, 15, 72, 75, 17, 64, 60,
681 23, 0, 0, 39, 0, 74, 71, 28, 29, 26,
682 27, 30, 31, 24, 25, 47, 47, 58, 59, 59,
683 59, 59, 23, 38, 0, 36, 37, 21, 22, 59,
687 /* YYDEFGOTO[NTERM-NUM]. */
688 static const yytype_int8 yydefgoto[] =
690 -1, 14, 15, 36, 37, 105, 106, 40, 41, 32,
691 33, 28, 58, 55, 29, 18, 93, 81, 66, 52,
695 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
697 #define YYPACT_NINF -81
698 static const yytype_int8 yypact[] =
700 30, 27, 27, -15, -7, -7, 64, 64, -1, 35,
701 11, -7, 38, 22, 4, -81, 28, 31, 48, 48,
702 -81, -81, 66, 66, -81, -81, -81, -81, -2, -81,
703 -2, 55, -1, -81, -81, 67, 35, -81, 59, 60,
704 11, -81, 68, -81, 71, 16, -81, -81, -81, 72,
705 -81, 69, -81, -81, -7, -81, -81, -81, 64, -81,
706 -2, -81, -81, -81, 74, 35, 63, 75, 76, -81,
707 -7, -81, 77, -7, -81, -7, -81, -81, -81, 79,
708 -7, 80, -26, 82, -81, -81, 85, -81, -81, -81,
709 36, 86, 87, -81, 51, -81, -81, -81, -81, -81,
710 -81, -81, -81, -81, -81, 80, 80, -81, 78, 1,
711 78, 78, 36, -81, 65, -81, -81, -81, -81, 78,
715 /* YYPGOTO[NTERM-NUM]. */
716 static const yytype_int8 yypgoto[] =
718 -81, -81, 94, -81, 81, 6, -81, -81, 83, -81,
719 88, -4, -80, 96, 53, 119, -37, -81, -81, 103,
720 61, -81, -81, -81, -5
723 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
724 positive, shift that token. If negative, reduce the rule which
725 number is the opposite. If zero, do what YYDEFACT says.
726 If YYTABLE_NINF, syntax error. */
727 #define YYTABLE_NINF -48
728 static const yytype_int8 yytable[] =
730 23, 90, 91, 30, 47, 92, 42, 1, 2, 3,
731 4, 5, 6, 7, 20, 8, 9, 10, 11, -47,
732 -47, -47, -47, 21, 12, 111, 112, 60, 31, 91,
733 57, 13, 114, 1, 2, 3, 4, 5, 6, 7,
734 39, 8, 9, 10, 11, 97, 98, 72, 73, 76,
735 12, 46, 99, 100, 101, 102, 16, 13, 17, 49,
736 50, 103, 104, 51, 34, 84, 35, 43, 87, 44,
737 88, 113, 115, 116, 117, 89, 24, 25, 26, 27,
738 109, 21, 121, 122, 59, 24, 25, 26, 27, 110,
739 64, 67, 65, 68, 119, 21, 62, 80, 54, 70,
740 71, 74, 75, 78, 82, 83, 91, 85, 48, 120,
741 64, 77, 57, 94, 95, 107, 108, 63, 118, 56,
742 61, 19, 53, 69, 0, 0, 79
745 static const yytype_int8 yycheck[] =
747 5, 81, 28, 7, 0, 31, 11, 3, 4, 5,
748 6, 7, 8, 9, 29, 11, 12, 13, 14, 21,
749 22, 23, 24, 30, 20, 105, 106, 31, 29, 28,
750 32, 27, 31, 3, 4, 5, 6, 7, 8, 9,
751 29, 11, 12, 13, 14, 9, 10, 31, 32, 54,
752 20, 29, 16, 17, 18, 19, 29, 27, 31, 31,
753 29, 25, 26, 15, 29, 70, 31, 29, 73, 31,
754 75, 108, 109, 110, 111, 80, 21, 22, 23, 24,
755 29, 30, 119, 120, 29, 21, 22, 23, 24, 94,
756 31, 31, 33, 33, 29, 30, 29, 34, 32, 31,
757 29, 29, 33, 29, 29, 29, 28, 30, 14, 114,
758 31, 58, 32, 31, 29, 29, 29, 36, 112, 23,
759 32, 2, 19, 40, -1, -1, 65
762 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
763 symbol of state STATE-NUM. */
764 static const yytype_uint8 yystos[] =
766 0, 3, 4, 5, 6, 7, 8, 9, 11, 12,
767 13, 14, 20, 27, 36, 37, 29, 31, 50, 50,
768 29, 30, 59, 59, 21, 22, 23, 24, 46, 49,
769 46, 29, 44, 45, 29, 31, 38, 39, 55, 29,
770 42, 43, 59, 29, 31, 56, 29, 0, 37, 31,
771 29, 15, 54, 54, 32, 48, 48, 32, 47, 29,
772 46, 45, 29, 39, 31, 33, 53, 31, 33, 43,
773 31, 29, 31, 32, 29, 33, 59, 49, 29, 55,
774 34, 52, 29, 29, 59, 30, 57, 59, 59, 59,
775 47, 28, 31, 51, 31, 29, 58, 9, 10, 16,
776 17, 18, 19, 25, 26, 40, 41, 29, 29, 29,
777 59, 47, 47, 51, 31, 51, 51, 51, 40, 29,
781 #define yyerrok (yyerrstatus = 0)
782 #define yyclearin (yychar = YYEMPTY)
786 #define YYACCEPT goto yyacceptlab
787 #define YYABORT goto yyabortlab
788 #define YYERROR goto yyerrorlab
791 /* Like YYERROR except do call yyerror. This remains here temporarily
792 to ease the transition to the new meaning of YYERROR, for GCC.
793 Once GCC version 2 has supplanted version 1, this can go. */
795 #define YYFAIL goto yyerrlab
797 #define YYRECOVERING() (!!yyerrstatus)
799 #define YYBACKUP(Token, Value) \
801 if (yychar == YYEMPTY && yylen == 1) \
805 yytoken = YYTRANSLATE (yychar); \
811 yyerror (YY_("syntax error: cannot back up")); \
818 #define YYERRCODE 256
821 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
822 If N is 0, then set CURRENT to the empty location which ends
823 the previous symbol: RHS[0] (always defined). */
825 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
826 #ifndef YYLLOC_DEFAULT
827 # define YYLLOC_DEFAULT(Current, Rhs, N) \
831 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
832 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
833 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
834 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
838 (Current).first_line = (Current).last_line = \
839 YYRHSLOC (Rhs, 0).last_line; \
840 (Current).first_column = (Current).last_column = \
841 YYRHSLOC (Rhs, 0).last_column; \
847 /* YY_LOCATION_PRINT -- Print the location on the stream.
848 This macro was not mandated originally: define only if we know
849 we won't break user code: when these are the locations we know. */
851 #ifndef YY_LOCATION_PRINT
852 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
853 # define YY_LOCATION_PRINT(File, Loc) \
854 fprintf (File, "%d.%d-%d.%d", \
855 (Loc).first_line, (Loc).first_column, \
856 (Loc).last_line, (Loc).last_column)
858 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
863 /* YYLEX -- calling `yylex' with the right arguments. */
866 # define YYLEX yylex (YYLEX_PARAM)
868 # define YYLEX yylex ()
871 /* Enable debugging if requested. */
875 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
876 # define YYFPRINTF fprintf
879 # define YYDPRINTF(Args) \
885 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
889 YYFPRINTF (stderr, "%s ", Title); \
890 yy_symbol_print (stderr, \
892 YYFPRINTF (stderr, "\n"); \
897 /*--------------------------------.
898 | Print this symbol on YYOUTPUT. |
899 `--------------------------------*/
902 #if (defined __STDC__ || defined __C99__FUNC__ \
903 || defined __cplusplus || defined _MSC_VER)
905 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
908 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
911 YYSTYPE const * const yyvaluep;
917 if (yytype < YYNTOKENS)
918 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
930 /*--------------------------------.
931 | Print this symbol on YYOUTPUT. |
932 `--------------------------------*/
934 #if (defined __STDC__ || defined __C99__FUNC__ \
935 || defined __cplusplus || defined _MSC_VER)
937 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
940 yy_symbol_print (yyoutput, yytype, yyvaluep)
943 YYSTYPE const * const yyvaluep;
946 if (yytype < YYNTOKENS)
947 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
949 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
951 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
952 YYFPRINTF (yyoutput, ")");
955 /*------------------------------------------------------------------.
956 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
958 `------------------------------------------------------------------*/
960 #if (defined __STDC__ || defined __C99__FUNC__ \
961 || defined __cplusplus || defined _MSC_VER)
963 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
966 yy_stack_print (bottom, top)
967 yytype_int16 *bottom;
971 YYFPRINTF (stderr, "Stack now");
972 for (; bottom <= top; ++bottom)
973 YYFPRINTF (stderr, " %d", *bottom);
974 YYFPRINTF (stderr, "\n");
977 # define YY_STACK_PRINT(Bottom, Top) \
980 yy_stack_print ((Bottom), (Top)); \
984 /*------------------------------------------------.
985 | Report that the YYRULE is going to be reduced. |
986 `------------------------------------------------*/
988 #if (defined __STDC__ || defined __C99__FUNC__ \
989 || defined __cplusplus || defined _MSC_VER)
991 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
994 yy_reduce_print (yyvsp, yyrule)
999 int yynrhs = yyr2[yyrule];
1001 unsigned long int yylno = yyrline[yyrule];
1002 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1004 /* The symbols being reduced. */
1005 for (yyi = 0; yyi < yynrhs; yyi++)
1007 fprintf (stderr, " $%d = ", yyi + 1);
1008 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1009 &(yyvsp[(yyi + 1) - (yynrhs)])
1011 fprintf (stderr, "\n");
1015 # define YY_REDUCE_PRINT(Rule) \
1018 yy_reduce_print (yyvsp, Rule); \
1021 /* Nonzero means print parse trace. It is left uninitialized so that
1022 multiple parsers can coexist. */
1024 #else /* !YYDEBUG */
1025 # define YYDPRINTF(Args)
1026 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1027 # define YY_STACK_PRINT(Bottom, Top)
1028 # define YY_REDUCE_PRINT(Rule)
1029 #endif /* !YYDEBUG */
1032 /* YYINITDEPTH -- initial size of the parser's stacks. */
1034 # define YYINITDEPTH 200
1037 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1038 if the built-in stack extension method is used).
1040 Do not make this value too large; the results are undefined if
1041 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1042 evaluated with infinite-precision integer arithmetic. */
1045 # define YYMAXDEPTH 10000
1053 # if defined __GLIBC__ && defined _STRING_H
1054 # define yystrlen strlen
1056 /* Return the length of YYSTR. */
1057 #if (defined __STDC__ || defined __C99__FUNC__ \
1058 || defined __cplusplus || defined _MSC_VER)
1060 yystrlen (const char *yystr)
1068 for (yylen = 0; yystr[yylen]; yylen++)
1076 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1077 # define yystpcpy stpcpy
1079 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1081 #if (defined __STDC__ || defined __C99__FUNC__ \
1082 || defined __cplusplus || defined _MSC_VER)
1084 yystpcpy (char *yydest, const char *yysrc)
1087 yystpcpy (yydest, yysrc)
1093 const char *yys = yysrc;
1095 while ((*yyd++ = *yys++) != '\0')
1104 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1105 quotes and backslashes, so that it's suitable for yyerror. The
1106 heuristic is that double-quoting is unnecessary unless the string
1107 contains an apostrophe, a comma, or backslash (other than
1108 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1109 null, do not copy; instead, return the length of what the result
1112 yytnamerr (char *yyres, const char *yystr)
1117 char const *yyp = yystr;
1124 goto do_not_strip_quotes;
1128 goto do_not_strip_quotes;
1141 do_not_strip_quotes: ;
1145 return yystrlen (yystr);
1147 return yystpcpy (yyres, yystr) - yyres;
1151 /* Copy into YYRESULT an error message about the unexpected token
1152 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1153 including the terminating null byte. If YYRESULT is null, do not
1154 copy anything; just return the number of bytes that would be
1155 copied. As a special case, return 0 if an ordinary "syntax error"
1156 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1157 size calculation. */
1159 yysyntax_error (char *yyresult, int yystate, int yychar)
1161 int yyn = yypact[yystate];
1163 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1167 int yytype = YYTRANSLATE (yychar);
1168 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1169 YYSIZE_T yysize = yysize0;
1171 int yysize_overflow = 0;
1172 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1173 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1177 /* This is so xgettext sees the translatable formats that are
1178 constructed on the fly. */
1179 YY_("syntax error, unexpected %s");
1180 YY_("syntax error, unexpected %s, expecting %s");
1181 YY_("syntax error, unexpected %s, expecting %s or %s");
1182 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1183 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1187 static char const yyunexpected[] = "syntax error, unexpected %s";
1188 static char const yyexpecting[] = ", expecting %s";
1189 static char const yyor[] = " or %s";
1190 char yyformat[sizeof yyunexpected
1191 + sizeof yyexpecting - 1
1192 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1193 * (sizeof yyor - 1))];
1194 char const *yyprefix = yyexpecting;
1196 /* Start YYX at -YYN if negative to avoid negative indexes in
1198 int yyxbegin = yyn < 0 ? -yyn : 0;
1200 /* Stay within bounds of both yycheck and yytname. */
1201 int yychecklim = YYLAST - yyn + 1;
1202 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1205 yyarg[0] = yytname[yytype];
1206 yyfmt = yystpcpy (yyformat, yyunexpected);
1208 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1209 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1211 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1215 yyformat[sizeof yyunexpected - 1] = '\0';
1218 yyarg[yycount++] = yytname[yyx];
1219 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1220 yysize_overflow |= (yysize1 < yysize);
1222 yyfmt = yystpcpy (yyfmt, yyprefix);
1226 yyf = YY_(yyformat);
1227 yysize1 = yysize + yystrlen (yyf);
1228 yysize_overflow |= (yysize1 < yysize);
1231 if (yysize_overflow)
1232 return YYSIZE_MAXIMUM;
1236 /* Avoid sprintf, as that infringes on the user's name space.
1237 Don't have undefined behavior even if the translation
1238 produced a string with the wrong number of "%s"s. */
1239 char *yyp = yyresult;
1241 while ((*yyp = *yyf) != '\0')
1243 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1245 yyp += yytnamerr (yyp, yyarg[yyi++]);
1258 #endif /* YYERROR_VERBOSE */
1261 /*-----------------------------------------------.
1262 | Release the memory associated to this symbol. |
1263 `-----------------------------------------------*/
1266 #if (defined __STDC__ || defined __C99__FUNC__ \
1267 || defined __cplusplus || defined _MSC_VER)
1269 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1272 yydestruct (yymsg, yytype, yyvaluep)
1282 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1293 /* Prevent warnings from -Wmissing-prototypes. */
1295 #ifdef YYPARSE_PARAM
1296 #if defined __STDC__ || defined __cplusplus
1297 int yyparse (void *YYPARSE_PARAM);
1301 #else /* ! YYPARSE_PARAM */
1302 #if defined __STDC__ || defined __cplusplus
1307 #endif /* ! YYPARSE_PARAM */
1311 /* The look-ahead symbol. */
1314 /* The semantic value of the look-ahead symbol. */
1317 /* Number of syntax errors so far. */
1326 #ifdef YYPARSE_PARAM
1327 #if (defined __STDC__ || defined __C99__FUNC__ \
1328 || defined __cplusplus || defined _MSC_VER)
1330 yyparse (void *YYPARSE_PARAM)
1333 yyparse (YYPARSE_PARAM)
1334 void *YYPARSE_PARAM;
1336 #else /* ! YYPARSE_PARAM */
1337 #if (defined __STDC__ || defined __C99__FUNC__ \
1338 || defined __cplusplus || defined _MSC_VER)
1352 /* Number of tokens to shift before error messages enabled. */
1354 /* Look-ahead token as an internal (translated) token number. */
1357 /* Buffer for error messages, and its allocated size. */
1359 char *yymsg = yymsgbuf;
1360 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1363 /* Three stacks and their tools:
1364 `yyss': related to states,
1365 `yyvs': related to semantic values,
1366 `yyls': related to locations.
1368 Refer to the stacks thru separate pointers, to allow yyoverflow
1369 to reallocate them elsewhere. */
1371 /* The state stack. */
1372 yytype_int16 yyssa[YYINITDEPTH];
1373 yytype_int16 *yyss = yyssa;
1374 yytype_int16 *yyssp;
1376 /* The semantic value stack. */
1377 YYSTYPE yyvsa[YYINITDEPTH];
1378 YYSTYPE *yyvs = yyvsa;
1383 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1385 YYSIZE_T yystacksize = YYINITDEPTH;
1387 /* The variables used to return semantic value and location from the
1392 /* The number of symbols on the RHS of the reduced rule.
1393 Keep to zero when no symbol should be popped. */
1396 YYDPRINTF ((stderr, "Starting parse\n"));
1401 yychar = YYEMPTY; /* Cause a token to be read. */
1403 /* Initialize stack pointers.
1404 Waste one element of value and location stack
1405 so that they stay on the same level as the state stack.
1406 The wasted elements are never initialized. */
1413 /*------------------------------------------------------------.
1414 | yynewstate -- Push a new state, which is found in yystate. |
1415 `------------------------------------------------------------*/
1417 /* In all cases, when you get here, the value and location stacks
1418 have just been pushed. So pushing a state here evens the stacks. */
1424 if (yyss + yystacksize - 1 <= yyssp)
1426 /* Get the current used size of the three stacks, in elements. */
1427 YYSIZE_T yysize = yyssp - yyss + 1;
1431 /* Give user a chance to reallocate the stack. Use copies of
1432 these so that the &'s don't force the real ones into
1434 YYSTYPE *yyvs1 = yyvs;
1435 yytype_int16 *yyss1 = yyss;
1438 /* Each stack pointer address is followed by the size of the
1439 data in use in that stack, in bytes. This used to be a
1440 conditional around just the two extra args, but that might
1441 be undefined if yyoverflow is a macro. */
1442 yyoverflow (YY_("memory exhausted"),
1443 &yyss1, yysize * sizeof (*yyssp),
1444 &yyvs1, yysize * sizeof (*yyvsp),
1451 #else /* no yyoverflow */
1452 # ifndef YYSTACK_RELOCATE
1453 goto yyexhaustedlab;
1455 /* Extend the stack our own way. */
1456 if (YYMAXDEPTH <= yystacksize)
1457 goto yyexhaustedlab;
1459 if (YYMAXDEPTH < yystacksize)
1460 yystacksize = YYMAXDEPTH;
1463 yytype_int16 *yyss1 = yyss;
1464 union yyalloc *yyptr =
1465 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1467 goto yyexhaustedlab;
1468 YYSTACK_RELOCATE (yyss);
1469 YYSTACK_RELOCATE (yyvs);
1471 # undef YYSTACK_RELOCATE
1473 YYSTACK_FREE (yyss1);
1476 #endif /* no yyoverflow */
1478 yyssp = yyss + yysize - 1;
1479 yyvsp = yyvs + yysize - 1;
1482 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1483 (unsigned long int) yystacksize));
1485 if (yyss + yystacksize - 1 <= yyssp)
1489 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1498 /* Do appropriate processing given the current state. Read a
1499 look-ahead token if we need one and don't already have one. */
1501 /* First try to decide what to do without reference to look-ahead token. */
1502 yyn = yypact[yystate];
1503 if (yyn == YYPACT_NINF)
1506 /* Not known => get a look-ahead token if don't already have one. */
1508 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1509 if (yychar == YYEMPTY)
1511 YYDPRINTF ((stderr, "Reading a token: "));
1515 if (yychar <= YYEOF)
1517 yychar = yytoken = YYEOF;
1518 YYDPRINTF ((stderr, "Now at end of input.\n"));
1522 yytoken = YYTRANSLATE (yychar);
1523 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1526 /* If the proper action on seeing token YYTOKEN is to reduce or to
1527 detect an error, take that action. */
1529 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1534 if (yyn == 0 || yyn == YYTABLE_NINF)
1543 /* Count tokens shifted since error; after three, turn off error
1548 /* Shift the look-ahead token. */
1549 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1551 /* Discard the shifted token unless it is eof. */
1552 if (yychar != YYEOF)
1561 /*-----------------------------------------------------------.
1562 | yydefault -- do the default action for the current state. |
1563 `-----------------------------------------------------------*/
1565 yyn = yydefact[yystate];
1571 /*-----------------------------.
1572 | yyreduce -- Do a reduction. |
1573 `-----------------------------*/
1575 /* yyn is the number of a rule to reduce with. */
1578 /* If YYLEN is nonzero, implement the default value of the action:
1581 Otherwise, the following line sets YYVAL to garbage.
1582 This behavior is undocumented and Bison
1583 users should not rely upon it. Assigning to YYVAL
1584 unconditionally makes the parser a bit smaller, and it avoids a
1585 GCC warning that YYVAL may be used uninitialized. */
1586 yyval = yyvsp[1-yylen];
1589 YY_REDUCE_PRINT (yyn);
1593 #line 140 "deffilep.y"
1594 { def_image_name ((yyvsp[(2) - (3)].id), (yyvsp[(3) - (3)].number), 0); }
1598 #line 141 "deffilep.y"
1599 { def_image_name ((yyvsp[(2) - (3)].id), (yyvsp[(3) - (3)].number), 1); }
1603 #line 142 "deffilep.y"
1604 { def_description ((yyvsp[(2) - (2)].id));}
1608 #line 143 "deffilep.y"
1609 { def_stacksize ((yyvsp[(2) - (3)].number), (yyvsp[(3) - (3)].number));}
1613 #line 144 "deffilep.y"
1614 { def_heapsize ((yyvsp[(2) - (3)].number), (yyvsp[(3) - (3)].number));}
1618 #line 145 "deffilep.y"
1619 { def_section ("CODE", (yyvsp[(2) - (2)].number));}
1623 #line 146 "deffilep.y"
1624 { def_section ("DATA", (yyvsp[(2) - (2)].number));}
1628 #line 150 "deffilep.y"
1629 { def_version ((yyvsp[(2) - (2)].number), 0);}
1633 #line 151 "deffilep.y"
1634 { def_version ((yyvsp[(2) - (4)].number), (yyvsp[(4) - (4)].number));}
1638 #line 152 "deffilep.y"
1639 { def_directive ((yyvsp[(2) - (2)].id));}
1643 #line 153 "deffilep.y"
1644 { def_aligncomm ((yyvsp[(2) - (4)].id), (yyvsp[(4) - (4)].number));}
1648 #line 168 "deffilep.y"
1649 { def_exports ((yyvsp[(1) - (7)].id), (yyvsp[(2) - (7)].id), (yyvsp[(3) - (7)].number), (yyvsp[(5) - (7)].number), (yyvsp[(7) - (7)].id)); }
1653 #line 174 "deffilep.y"
1654 { (yyval.number) = (yyvsp[(1) - (3)].number) | (yyvsp[(3) - (3)].number); }
1658 #line 175 "deffilep.y"
1659 { (yyval.number) = 0; }
1663 #line 178 "deffilep.y"
1664 { (yyval.number) = 1; }
1668 #line 179 "deffilep.y"
1669 { (yyval.number) = 1; }
1673 #line 180 "deffilep.y"
1674 { (yyval.number) = 2; }
1678 #line 181 "deffilep.y"
1679 { (yyval.number) = 2; }
1683 #line 182 "deffilep.y"
1684 { (yyval.number) = 4; }
1688 #line 183 "deffilep.y"
1689 { (yyval.number) = 4; }
1693 #line 184 "deffilep.y"
1694 { (yyval.number) = 8; }
1698 #line 185 "deffilep.y"
1699 { (yyval.number) = 8; }
1703 #line 194 "deffilep.y"
1704 { def_import ((yyvsp[(1) - (8)].id), (yyvsp[(3) - (8)].id), (yyvsp[(5) - (8)].id), (yyvsp[(7) - (8)].id), -1, (yyvsp[(8) - (8)].id)); }
1708 #line 196 "deffilep.y"
1709 { def_import ((yyvsp[(1) - (8)].id), (yyvsp[(3) - (8)].id), (yyvsp[(5) - (8)].id), 0, (yyvsp[(7) - (8)].number), (yyvsp[(8) - (8)].id)); }
1713 #line 198 "deffilep.y"
1714 { def_import ((yyvsp[(1) - (6)].id), (yyvsp[(3) - (6)].id), 0, (yyvsp[(5) - (6)].id), -1, (yyvsp[(6) - (6)].id)); }
1718 #line 200 "deffilep.y"
1719 { def_import ((yyvsp[(1) - (6)].id), (yyvsp[(3) - (6)].id), 0, 0, (yyvsp[(5) - (6)].number), (yyvsp[(6) - (6)].id)); }
1723 #line 202 "deffilep.y"
1724 { def_import( 0, (yyvsp[(1) - (6)].id), (yyvsp[(3) - (6)].id), (yyvsp[(5) - (6)].id), -1, (yyvsp[(6) - (6)].id)); }
1728 #line 204 "deffilep.y"
1729 { def_import ( 0, (yyvsp[(1) - (4)].id), 0, (yyvsp[(3) - (4)].id), -1, (yyvsp[(4) - (4)].id)); }
1733 #line 213 "deffilep.y"
1734 { def_section ((yyvsp[(1) - (2)].id), (yyvsp[(2) - (2)].number));}
1738 #line 214 "deffilep.y"
1739 { def_section_alt ((yyvsp[(1) - (2)].id), (yyvsp[(2) - (2)].id));}
1743 #line 218 "deffilep.y"
1744 { (yyval.number) = (yyvsp[(1) - (3)].number) | (yyvsp[(3) - (3)].number); }
1748 #line 219 "deffilep.y"
1749 { (yyval.number) = (yyvsp[(1) - (1)].number); }
1753 #line 226 "deffilep.y"
1754 { (yyval.number)=(yyvsp[(2) - (2)].number);}
1758 #line 227 "deffilep.y"
1759 { (yyval.number)=-1;}
1763 #line 231 "deffilep.y"
1764 { (yyval.number) = 1;}
1768 #line 232 "deffilep.y"
1769 { (yyval.number) = 2;}
1773 #line 233 "deffilep.y"
1774 { (yyval.number)=4;}
1778 #line 234 "deffilep.y"
1779 { (yyval.number)=8;}
1783 #line 237 "deffilep.y"
1784 { (yyval.id) = (yyvsp[(1) - (1)].id); }
1788 #line 239 "deffilep.y"
1790 char *name = def_pool_alloc (strlen ((yyvsp[(2) - (2)].id)) + 2);
1791 sprintf (name, ".%s", (yyvsp[(2) - (2)].id));
1797 #line 245 "deffilep.y"
1799 char *name = def_pool_alloc (strlen ((yyvsp[(1) - (3)].id)) + 1 + strlen ((yyvsp[(3) - (3)].id)) + 1);
1800 sprintf (name, "%s.%s", (yyvsp[(1) - (3)].id), (yyvsp[(3) - (3)].id));
1806 #line 250 "deffilep.y"
1807 { (yyval.id) = ""; }
1811 #line 253 "deffilep.y"
1812 { (yyval.id) = (yyvsp[(2) - (2)].id); }
1816 #line 254 "deffilep.y"
1821 #line 258 "deffilep.y"
1822 { (yyval.number) = (yyvsp[(2) - (2)].number);}
1826 #line 259 "deffilep.y"
1827 { (yyval.number) = -1;}
1831 #line 263 "deffilep.y"
1832 { (yyval.id) = (yyvsp[(2) - (2)].id); }
1836 #line 264 "deffilep.y"
1841 #line 267 "deffilep.y"
1842 { (yyval.number) = (yyvsp[(3) - (3)].number);}
1846 #line 268 "deffilep.y"
1847 { (yyval.number) = -1;}
1851 #line 271 "deffilep.y"
1852 { (yyval.id) = (yyvsp[(1) - (1)].id); }
1856 #line 273 "deffilep.y"
1858 char *name = def_pool_alloc (strlen ((yyvsp[(2) - (2)].id)) + 2);
1859 sprintf (name, ".%s", (yyvsp[(2) - (2)].id));
1865 #line 279 "deffilep.y"
1867 char *name = def_pool_alloc (strlen ((yyvsp[(1) - (3)].id)) + 1 + strlen ((yyvsp[(3) - (3)].id)) + 1);
1868 sprintf (name, "%s.%s", (yyvsp[(1) - (3)].id), (yyvsp[(3) - (3)].id));
1874 #line 286 "deffilep.y"
1875 { (yyval.id) = (yyvsp[(1) - (1)].id); }
1879 #line 288 "deffilep.y"
1881 char *id = def_pool_alloc (strlen ((yyvsp[(2) - (2)].id)) + 2);
1882 sprintf (id, ".%s", (yyvsp[(2) - (2)].id));
1888 #line 294 "deffilep.y"
1890 char *id = def_pool_alloc (strlen ((yyvsp[(1) - (4)].id)) + 1 + strlen ((yyvsp[(3) - (4)].digits)) + strlen ((yyvsp[(4) - (4)].id)) + 1);
1891 sprintf (id, "%s.%s%s", (yyvsp[(1) - (4)].id), (yyvsp[(3) - (4)].digits), (yyvsp[(4) - (4)].id));
1897 #line 301 "deffilep.y"
1898 { (yyval.digits) = (yyvsp[(1) - (1)].digits); }
1902 #line 302 "deffilep.y"
1903 { (yyval.digits) = ""; }
1907 #line 305 "deffilep.y"
1908 { (yyval.id) = (yyvsp[(1) - (1)].id); }
1912 #line 306 "deffilep.y"
1913 { (yyval.id) = ""; }
1917 #line 309 "deffilep.y"
1918 { (yyval.number) = strtoul ((yyvsp[(1) - (1)].digits), 0, 0); }
1922 /* Line 1267 of yacc.c. */
1923 #line 1924 "deffilep.c"
1926 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1930 YY_STACK_PRINT (yyss, yyssp);
1935 /* Now `shift' the result of the reduction. Determine what state
1936 that goes to, based on the state we popped back to and the rule
1937 number reduced by. */
1941 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1942 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1943 yystate = yytable[yystate];
1945 yystate = yydefgoto[yyn - YYNTOKENS];
1950 /*------------------------------------.
1951 | yyerrlab -- here on detecting error |
1952 `------------------------------------*/
1954 /* If not already recovering from an error, report this error. */
1958 #if ! YYERROR_VERBOSE
1959 yyerror (YY_("syntax error"));
1962 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1963 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1965 YYSIZE_T yyalloc = 2 * yysize;
1966 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1967 yyalloc = YYSTACK_ALLOC_MAXIMUM;
1968 if (yymsg != yymsgbuf)
1969 YYSTACK_FREE (yymsg);
1970 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1972 yymsg_alloc = yyalloc;
1976 yymsg_alloc = sizeof yymsgbuf;
1980 if (0 < yysize && yysize <= yymsg_alloc)
1982 (void) yysyntax_error (yymsg, yystate, yychar);
1987 yyerror (YY_("syntax error"));
1989 goto yyexhaustedlab;
1997 if (yyerrstatus == 3)
1999 /* If just tried and failed to reuse look-ahead token after an
2000 error, discard it. */
2002 if (yychar <= YYEOF)
2004 /* Return failure if at end of input. */
2005 if (yychar == YYEOF)
2010 yydestruct ("Error: discarding",
2016 /* Else will try to reuse look-ahead token after shifting the error
2021 /*---------------------------------------------------.
2022 | yyerrorlab -- error raised explicitly by YYERROR. |
2023 `---------------------------------------------------*/
2026 /* Pacify compilers like GCC when the user code never invokes
2027 YYERROR and the label yyerrorlab therefore never appears in user
2029 if (/*CONSTCOND*/ 0)
2032 /* Do not reclaim the symbols of the rule which action triggered
2036 YY_STACK_PRINT (yyss, yyssp);
2041 /*-------------------------------------------------------------.
2042 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2043 `-------------------------------------------------------------*/
2045 yyerrstatus = 3; /* Each real token shifted decrements this. */
2049 yyn = yypact[yystate];
2050 if (yyn != YYPACT_NINF)
2053 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2061 /* Pop the current state because it cannot handle the error token. */
2066 yydestruct ("Error: popping",
2067 yystos[yystate], yyvsp);
2070 YY_STACK_PRINT (yyss, yyssp);
2079 /* Shift the error token. */
2080 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2086 /*-------------------------------------.
2087 | yyacceptlab -- YYACCEPT comes here. |
2088 `-------------------------------------*/
2093 /*-----------------------------------.
2094 | yyabortlab -- YYABORT comes here. |
2095 `-----------------------------------*/
2101 /*-------------------------------------------------.
2102 | yyexhaustedlab -- memory exhaustion comes here. |
2103 `-------------------------------------------------*/
2105 yyerror (YY_("memory exhausted"));
2111 if (yychar != YYEOF && yychar != YYEMPTY)
2112 yydestruct ("Cleanup: discarding lookahead",
2114 /* Do not reclaim the symbols of the rule which action triggered
2115 this YYABORT or YYACCEPT. */
2117 YY_STACK_PRINT (yyss, yyssp);
2118 while (yyssp != yyss)
2120 yydestruct ("Cleanup: popping",
2121 yystos[*yyssp], yyvsp);
2126 YYSTACK_FREE (yyss);
2129 if (yymsg != yymsgbuf)
2130 YYSTACK_FREE (yymsg);
2132 /* Make sure YYID is used. */
2133 return YYID (yyresult);
2137 #line 311 "deffilep.y"
2140 /*****************************************************************************
2142 *****************************************************************************/
2144 static FILE *the_file;
2145 static const char *def_filename;
2146 static int linenumber;
2147 static def_file *def;
2148 static int saw_newline;
2152 struct directive *next;
2157 static struct directive *directives = 0;
2160 def_file_empty (void)
2162 def_file *rv = xmalloc (sizeof (def_file));
2163 memset (rv, 0, sizeof (def_file));
2165 rv->base_address = (bfd_vma) -1;
2166 rv->stack_reserve = rv->stack_commit = -1;
2167 rv->heap_reserve = rv->heap_commit = -1;
2168 rv->version_major = rv->version_minor = -1;
2173 def_file_parse (const char *filename, def_file *add_to)
2175 struct directive *d;
2177 the_file = fopen (filename, "r");
2178 def_filename = filename;
2191 def = def_file_empty ();
2197 def_file_free (def);
2205 while ((d = directives) != NULL)
2208 printf ("Adding directive %08x `%s'\n", d->name, d->name);
2210 def_file_add_directive (def, d->name, d->len);
2211 directives = d->next;
2221 def_file_free (def_file *fdef)
2229 if (fdef->description)
2230 free (fdef->description);
2232 if (fdef->section_defs)
2234 for (i = 0; i < fdef->num_section_defs; i++)
2236 if (fdef->section_defs[i].name)
2237 free (fdef->section_defs[i].name);
2238 if (fdef->section_defs[i].class)
2239 free (fdef->section_defs[i].class);
2241 free (fdef->section_defs);
2246 for (i = 0; i < fdef->num_exports; i++)
2248 if (fdef->exports[i].internal_name
2249 && fdef->exports[i].internal_name != fdef->exports[i].name)
2250 free (fdef->exports[i].internal_name);
2251 if (fdef->exports[i].name)
2252 free (fdef->exports[i].name);
2253 if (fdef->exports[i].its_name)
2254 free (fdef->exports[i].its_name);
2256 free (fdef->exports);
2261 for (i = 0; i < fdef->num_imports; i++)
2263 if (fdef->imports[i].internal_name
2264 && fdef->imports[i].internal_name != fdef->imports[i].name)
2265 free (fdef->imports[i].internal_name);
2266 if (fdef->imports[i].name)
2267 free (fdef->imports[i].name);
2268 if (fdef->imports[i].its_name)
2269 free (fdef->imports[i].its_name);
2271 free (fdef->imports);
2274 while (fdef->modules)
2276 def_file_module *m = fdef->modules;
2278 fdef->modules = fdef->modules->next;
2282 while (fdef->aligncomms)
2284 def_file_aligncomm *c = fdef->aligncomms;
2286 fdef->aligncomms = fdef->aligncomms->next;
2287 free (c->symbol_name);
2294 #ifdef DEF_FILE_PRINT
2296 def_file_print (FILE *file, def_file *fdef)
2300 fprintf (file, ">>>> def_file at 0x%08x\n", fdef);
2302 fprintf (file, " name: %s\n", fdef->name ? fdef->name : "(unspecified)");
2303 if (fdef->is_dll != -1)
2304 fprintf (file, " is dll: %s\n", fdef->is_dll ? "yes" : "no");
2305 if (fdef->base_address != (bfd_vma) -1)
2306 fprintf (file, " base address: 0x%08x\n", fdef->base_address);
2307 if (fdef->description)
2308 fprintf (file, " description: `%s'\n", fdef->description);
2309 if (fdef->stack_reserve != -1)
2310 fprintf (file, " stack reserve: 0x%08x\n", fdef->stack_reserve);
2311 if (fdef->stack_commit != -1)
2312 fprintf (file, " stack commit: 0x%08x\n", fdef->stack_commit);
2313 if (fdef->heap_reserve != -1)
2314 fprintf (file, " heap reserve: 0x%08x\n", fdef->heap_reserve);
2315 if (fdef->heap_commit != -1)
2316 fprintf (file, " heap commit: 0x%08x\n", fdef->heap_commit);
2318 if (fdef->num_section_defs > 0)
2320 fprintf (file, " section defs:\n");
2322 for (i = 0; i < fdef->num_section_defs; i++)
2324 fprintf (file, " name: `%s', class: `%s', flags:",
2325 fdef->section_defs[i].name, fdef->section_defs[i].class);
2326 if (fdef->section_defs[i].flag_read)
2327 fprintf (file, " R");
2328 if (fdef->section_defs[i].flag_write)
2329 fprintf (file, " W");
2330 if (fdef->section_defs[i].flag_execute)
2331 fprintf (file, " X");
2332 if (fdef->section_defs[i].flag_shared)
2333 fprintf (file, " S");
2334 fprintf (file, "\n");
2338 if (fdef->num_exports > 0)
2340 fprintf (file, " exports:\n");
2342 for (i = 0; i < fdef->num_exports; i++)
2344 fprintf (file, " name: `%s', int: `%s', ordinal: %d, flags:",
2345 fdef->exports[i].name, fdef->exports[i].internal_name,
2346 fdef->exports[i].ordinal);
2347 if (fdef->exports[i].flag_private)
2348 fprintf (file, " P");
2349 if (fdef->exports[i].flag_constant)
2350 fprintf (file, " C");
2351 if (fdef->exports[i].flag_noname)
2352 fprintf (file, " N");
2353 if (fdef->exports[i].flag_data)
2354 fprintf (file, " D");
2355 fprintf (file, "\n");
2359 if (fdef->num_imports > 0)
2361 fprintf (file, " imports:\n");
2363 for (i = 0; i < fdef->num_imports; i++)
2365 fprintf (file, " int: %s, from: `%s', name: `%s', ordinal: %d\n",
2366 fdef->imports[i].internal_name,
2367 fdef->imports[i].module,
2368 fdef->imports[i].name,
2369 fdef->imports[i].ordinal);
2373 if (fdef->version_major != -1)
2374 fprintf (file, " version: %d.%d\n", fdef->version_major, fdef->version_minor);
2376 fprintf (file, "<<<< def_file at 0x%08x\n", fdef);
2380 /* Helper routine to check for identity of string pointers,
2381 which might be NULL. */
2384 are_names_equal (const char *s1, const char *s2)
2389 return (!s1 ? -1 : 1);
2390 return strcmp (s1, s2);
2394 cmp_export_elem (const def_file_export *e, const char *ex_name,
2395 const char *in_name, const char *its_name,
2400 if ((r = are_names_equal (ex_name, e->name)) != 0)
2402 if ((r = are_names_equal (in_name, e->internal_name)) != 0)
2404 if ((r = are_names_equal (its_name, e->its_name)) != 0)
2406 return (ord - e->ordinal);
2409 /* Search the position of the identical element, or returns the position
2410 of the next higher element. If last valid element is smaller, then MAX
2414 find_export_in_list (def_file_export *b, int max,
2415 const char *ex_name, const char *in_name,
2416 const char *its_name, int ord, int *is_ident)
2423 if ((e = cmp_export_elem (b, ex_name, in_name, its_name, ord)) <= 0)
2427 if ((e = cmp_export_elem (b + (max - 1), ex_name, in_name, its_name, ord)) > 0)
2429 else if (!e || max == 2)
2435 e = cmp_export_elem (b + p, ex_name, in_name, its_name, ord);
2446 if ((e = cmp_export_elem (b + l, ex_name, in_name, its_name, ord)) > 0)
2454 def_file_add_export (def_file *fdef,
2455 const char *external_name,
2456 const char *internal_name,
2458 const char *its_name,
2463 int max_exports = ROUND_UP(fdef->num_exports, 32);
2465 if (internal_name && !external_name)
2466 external_name = internal_name;
2467 if (external_name && !internal_name)
2468 internal_name = external_name;
2470 /* We need to avoid duplicates. */
2472 pos = find_export_in_list (fdef->exports, fdef->num_exports,
2473 external_name, internal_name,
2474 its_name, ordinal, is_dup);
2477 return (fdef->exports + pos);
2479 if (fdef->num_exports >= max_exports)
2481 max_exports = ROUND_UP(fdef->num_exports + 1, 32);
2483 fdef->exports = xrealloc (fdef->exports,
2484 max_exports * sizeof (def_file_export));
2486 fdef->exports = xmalloc (max_exports * sizeof (def_file_export));
2489 e = fdef->exports + pos;
2490 if (pos != fdef->num_exports)
2491 memmove (&e[1], e, (sizeof (def_file_export) * (fdef->num_exports - pos)));
2492 memset (e, 0, sizeof (def_file_export));
2493 e->name = xstrdup (external_name);
2494 e->internal_name = xstrdup (internal_name);
2495 e->its_name = (its_name ? xstrdup (its_name) : NULL);
2496 e->ordinal = ordinal;
2497 fdef->num_exports++;
2502 def_get_module (def_file *fdef, const char *name)
2506 for (s = fdef->modules; s; s = s->next)
2507 if (strcmp (s->name, name) == 0)
2513 static def_file_module *
2514 def_stash_module (def_file *fdef, const char *name)
2518 if ((s = def_get_module (fdef, name)) != NULL)
2520 s = xmalloc (sizeof (def_file_module) + strlen (name));
2521 s->next = fdef->modules;
2524 strcpy (s->name, name);
2529 cmp_import_elem (const def_file_import *e, const char *ex_name,
2530 const char *in_name, const char *module,
2535 if ((r = are_names_equal (ex_name, e->name)) != 0)
2537 if ((r = are_names_equal (in_name, e->internal_name)) != 0)
2539 if (ord != e->ordinal)
2540 return (ord < e->ordinal ? -1 : 1);
2541 return are_names_equal (module, (e->module ? e->module->name : NULL));
2544 /* Search the position of the identical element, or returns the position
2545 of the next higher element. If last valid element is smaller, then MAX
2549 find_import_in_list (def_file_import *b, int max,
2550 const char *ex_name, const char *in_name,
2551 const char *module, int ord, int *is_ident)
2558 if ((e = cmp_import_elem (b, ex_name, in_name, module, ord)) <= 0)
2562 if ((e = cmp_import_elem (b + (max - 1), ex_name, in_name, module, ord)) > 0)
2564 else if (!e || max == 2)
2570 e = cmp_import_elem (b + p, ex_name, in_name, module, ord);
2581 if ((e = cmp_import_elem (b + l, ex_name, in_name, module, ord)) > 0)
2589 def_file_add_import (def_file *fdef,
2593 const char *internal_name,
2594 const char *its_name,
2599 int max_imports = ROUND_UP (fdef->num_imports, 16);
2601 /* We need to avoid here duplicates. */
2603 pos = find_import_in_list (fdef->imports, fdef->num_imports,
2605 (!internal_name ? name : internal_name),
2606 module, ordinal, is_dup);
2608 return fdef->imports + pos;
2610 if (fdef->num_imports >= max_imports)
2612 max_imports = ROUND_UP (fdef->num_imports+1, 16);
2615 fdef->imports = xrealloc (fdef->imports,
2616 max_imports * sizeof (def_file_import));
2618 fdef->imports = xmalloc (max_imports * sizeof (def_file_import));
2620 i = fdef->imports + pos;
2621 if (pos != fdef->num_imports)
2622 memmove (&i[1], i, (sizeof (def_file_import) * (fdef->num_imports - pos)));
2623 memset (i, 0, sizeof (def_file_import));
2625 i->name = xstrdup (name);
2627 i->module = def_stash_module (fdef, module);
2628 i->ordinal = ordinal;
2630 i->internal_name = xstrdup (internal_name);
2632 i->internal_name = i->name;
2633 i->its_name = (its_name ? xstrdup (its_name) : NULL);
2634 fdef->num_imports++;
2646 { "-heap", HEAPSIZE },
2647 { "-stack", STACKSIZE_K },
2648 { "-attr", SECTIONS },
2649 { "-export", EXPORTS },
2650 { "-aligncomm", ALIGNCOMM },
2655 def_file_add_directive (def_file *my_def, const char *param, int len)
2657 def_file *save_def = def;
2658 const char *pend = param + len;
2659 char * tend = (char *) param;
2664 while (param < pend)
2667 && (ISSPACE (*param) || *param == '\n' || *param == 0))
2673 /* Scan forward until we encounter any of:
2674 - the end of the buffer
2675 - the start of a new option
2676 - a newline seperating options
2677 - a NUL seperating options. */
2678 for (tend = (char *) (param + 1);
2680 && !(ISSPACE (tend[-1]) && *tend == '-')
2681 && *tend != '\n' && *tend != 0);
2685 for (i = 0; diropts[i].param; i++)
2687 len = strlen (diropts[i].param);
2689 if (tend - param >= len
2690 && strncmp (param, diropts[i].param, len) == 0
2691 && (param[len] == ':' || param[len] == ' '))
2693 lex_parse_string_end = tend;
2694 lex_parse_string = param + len + 1;
2695 lex_forced_token = diropts[i].token;
2703 if (!diropts[i].param)
2709 /* xgettext:c-format */
2710 einfo (_("Warning: .drectve `%s' unrecognized\n"), param);
2714 lex_parse_string = 0;
2722 /* Parser Callbacks. */
2725 def_image_name (const char *name, int base, int is_dll)
2727 /* If a LIBRARY or NAME statement is specified without a name, there is nothing
2728 to do here. We retain the output filename specified on command line. */
2731 const char* image_name = lbasename (name);
2733 if (image_name != name)
2734 einfo ("%s:%d: Warning: path components stripped from %s, '%s'\n",
2735 def_filename, linenumber, is_dll ? "LIBRARY" : "NAME",
2739 /* Append the default suffix, if none specified. */
2740 if (strchr (image_name, '.') == 0)
2742 const char * suffix = is_dll ? ".dll" : ".exe";
2744 def->name = xmalloc (strlen (image_name) + strlen (suffix) + 1);
2745 sprintf (def->name, "%s%s", image_name, suffix);
2748 def->name = xstrdup (image_name);
2751 /* Honor a BASE address statement, even if LIBRARY string is empty. */
2752 def->base_address = base;
2753 def->is_dll = is_dll;
2757 def_description (const char *text)
2759 int len = def->description ? strlen (def->description) : 0;
2761 len += strlen (text) + 1;
2762 if (def->description)
2764 def->description = xrealloc (def->description, len);
2765 strcat (def->description, text);
2769 def->description = xmalloc (len);
2770 strcpy (def->description, text);
2775 def_stacksize (int reserve, int commit)
2777 def->stack_reserve = reserve;
2778 def->stack_commit = commit;
2782 def_heapsize (int reserve, int commit)
2784 def->heap_reserve = reserve;
2785 def->heap_commit = commit;
2789 def_section (const char *name, int attr)
2791 def_file_section *s;
2792 int max_sections = ROUND_UP (def->num_section_defs, 4);
2794 if (def->num_section_defs >= max_sections)
2796 max_sections = ROUND_UP (def->num_section_defs+1, 4);
2798 if (def->section_defs)
2799 def->section_defs = xrealloc (def->section_defs,
2800 max_sections * sizeof (def_file_import));
2802 def->section_defs = xmalloc (max_sections * sizeof (def_file_import));
2804 s = def->section_defs + def->num_section_defs;
2805 memset (s, 0, sizeof (def_file_section));
2806 s->name = xstrdup (name);
2812 s->flag_execute = 1;
2816 def->num_section_defs++;
2820 def_section_alt (const char *name, const char *attr)
2824 for (; *attr; attr++)
2846 def_section (name, aval);
2850 def_exports (const char *external_name,
2851 const char *internal_name,
2854 const char *its_name)
2856 def_file_export *dfe;
2859 if (!internal_name && external_name)
2860 internal_name = external_name;
2862 printf ("def_exports, ext=%s int=%s\n", external_name, internal_name);
2865 dfe = def_file_add_export (def, external_name, internal_name, ordinal,
2868 /* We might check here for flag redefinition and warn. For now we
2869 ignore duplicates silently. */
2874 dfe->flag_noname = 1;
2876 dfe->flag_constant = 1;
2880 dfe->flag_private = 1;
2884 def_import (const char *internal_name,
2889 const char *its_name)
2892 const char *ext = dllext ? dllext : "dll";
2895 buf = xmalloc (strlen (module) + strlen (ext) + 2);
2896 sprintf (buf, "%s.%s", module, ext);
2899 def_file_add_import (def, name, module, ordinal, internal_name, its_name,
2905 def_version (int major, int minor)
2907 def->version_major = major;
2908 def->version_minor = minor;
2912 def_directive (char *str)
2914 struct directive *d = xmalloc (sizeof (struct directive));
2916 d->next = directives;
2918 d->name = xstrdup (str);
2919 d->len = strlen (str);
2923 def_aligncomm (char *str, int align)
2925 def_file_aligncomm *c, *p;
2928 c = def->aligncomms;
2931 int e = strcmp (c->symbol_name, str);
2934 /* Not sure if we want to allow here duplicates with
2935 different alignments, but for now we keep them. */
2936 e = (int) c->alignment - align;
2945 c = xmalloc (sizeof (def_file_aligncomm));
2946 c->symbol_name = xstrdup (str);
2947 c->alignment = (unsigned int) align;
2950 c->next = def->aligncomms;
2951 def->aligncomms = c;
2961 def_error (const char *err)
2963 einfo ("%P: %s:%d: %s\n",
2964 def_filename ? def_filename : "<unknown-file>", linenumber, err);
2969 /* Lexical Scanner. */
2974 /* Never freed, but always reused as needed, so no real leak. */
2975 static char *buffer = 0;
2976 static int buflen = 0;
2977 static int bufptr = 0;
2982 if (bufptr == buflen)
2984 buflen += 50; /* overly reasonable, eh? */
2986 buffer = xrealloc (buffer, buflen + 1);
2988 buffer = xmalloc (buflen + 1);
2990 buffer[bufptr++] = c;
2991 buffer[bufptr] = 0; /* not optimal, but very convenient. */
3003 { "CONSTANT", CONSTANTU },
3004 { "constant", CONSTANTL },
3007 { "DESCRIPTION", DESCRIPTION },
3008 { "DIRECTIVE", DIRECTIVE },
3009 { "EXECUTE", EXECUTE },
3010 { "EXPORTS", EXPORTS },
3011 { "HEAPSIZE", HEAPSIZE },
3012 { "IMPORTS", IMPORTS },
3013 { "LIBRARY", LIBRARY },
3015 { "NONAME", NONAMEU },
3016 { "noname", NONAMEL },
3017 { "PRIVATE", PRIVATEU },
3018 { "private", PRIVATEL },
3020 { "SECTIONS", SECTIONS },
3021 { "SEGMENTS", SECTIONS },
3022 { "SHARED", SHARED },
3023 { "STACKSIZE", STACKSIZE_K },
3024 { "VERSION", VERSIONK },
3034 if (lex_parse_string)
3036 if (lex_parse_string >= lex_parse_string_end)
3039 rv = *lex_parse_string++;
3043 rv = fgetc (the_file);
3053 if (lex_parse_string)
3059 return ungetc (c, the_file);
3067 if (lex_forced_token)
3069 i = lex_forced_token;
3070 lex_forced_token = 0;
3072 printf ("lex: forcing token %d\n", i);
3079 /* Trim leading whitespace. */
3080 while (c != EOF && (c == ' ' || c == '\t') && saw_newline)
3086 printf ("lex: EOF\n");
3091 if (saw_newline && c == ';')
3097 while (c != EOF && c != '\n');
3103 /* Must be something else. */
3109 while (c != EOF && (ISXDIGIT (c) || (c == 'x')))
3116 yylval.digits = def_pool_strdup (buffer);
3118 printf ("lex: `%s' returns DIGITS\n", buffer);
3123 if (ISALPHA (c) || strchr ("$:-_?@", c))
3132 if (ISBLANK (c) ) /* '@' followed by whitespace. */
3134 else if (ISDIGIT (c)) /* '@' followed by digit. */
3140 printf ("lex: @ returns itself\n");
3144 while (c != EOF && (ISALNUM (c) || strchr ("$:-_?/@<>", c)))
3151 if (ISALPHA (q)) /* Check for tokens. */
3153 for (i = 0; tokens[i].name; i++)
3154 if (strcmp (tokens[i].name, buffer) == 0)
3157 printf ("lex: `%s' is a string token\n", buffer);
3159 return tokens[i].token;
3163 printf ("lex: `%s' returns ID\n", buffer);
3165 yylval.id = def_pool_strdup (buffer);
3169 if (c == '\'' || c == '"')
3175 while (c != EOF && c != q)
3180 yylval.id = def_pool_strdup (buffer);
3182 printf ("lex: `%s' returns ID\n", buffer);
3193 printf ("lex: `==' returns EQUAL\n");
3199 printf ("lex: `=' returns itself\n");
3203 if (c == '.' || c == ',')
3206 printf ("lex: `%c' returns itself\n", c);
3217 /*printf ("lex: 0x%02x ignored\n", c); */
3222 def_pool_alloc (size_t sz)
3226 e = (def_pool_str *) xmalloc (sizeof (def_pool_str) + sz);
3227 e->next = pool_strs;
3233 def_pool_strdup (const char *str)
3239 len = strlen (str) + 1;
3240 s = def_pool_alloc (len);
3241 memcpy (s, str, len);
3246 def_pool_free (void)
3249 while ((p = pool_strs) != NULL)
3251 pool_strs = p->next;