1 /* A Bison parser, made by GNU Bison 2.1. */
3 /* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
21 /* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
26 /* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
29 /* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
36 /* Identify Bison output. */
40 #define YYBISON_VERSION "2.1"
43 #define YYSKELETON_NAME "yacc.c"
48 /* Using locations. */
49 #define YYLSP_NEEDED 0
56 /* Put the tokens into the symbol table, so that GDB and other debuggers
90 #define DESCRIPTION 260
101 #define CONSTANTU 271
102 #define CONSTANTL 272
111 #define DIRECTIVE 281
118 /* Copy the first part of user declarations. */
120 /* deffilep.y - parser for .def files */
122 /* Copyright 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2007
123 Free Software Foundation, Inc.
125 This file is part of GNU Binutils.
127 This program is free software; you can redistribute it and/or modify
128 it under the terms of the GNU General Public License as published by
129 the Free Software Foundation; either version 3 of the License, or
130 (at your option) any later version.
132 This program is distributed in the hope that it will be useful,
133 but WITHOUT ANY WARRANTY; without even the implied warranty of
134 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
135 GNU General Public License for more details.
137 You should have received a copy of the GNU General Public License
138 along with this program; if not, write to the Free Software
139 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
140 MA 02110-1301, USA. */
143 #include "libiberty.h"
144 #include "safe-ctype.h"
152 #define ROUND_UP(a, b) (((a)+((b)-1))&~((b)-1))
154 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
155 as well as gratuitiously global symbol names, so we can have multiple
156 yacc generated parsers in ld. Note that these are only the variables
157 produced by yacc. If other parser generators (bison, byacc, etc) produce
158 additional global names that conflict at link time, then those parser
159 generators need to be fixed instead of adding those names to this list. */
161 #define yymaxdepth def_maxdepth
162 #define yyparse def_parse
163 #define yylex def_lex
164 #define yyerror def_error
165 #define yylval def_lval
166 #define yychar def_char
167 #define yydebug def_debug
168 #define yypact def_pact
171 #define yydef def_def
172 #define yychk def_chk
173 #define yypgo def_pgo
174 #define yyact def_act
175 #define yyexca def_exca
176 #define yyerrflag def_errflag
177 #define yynerrs def_nerrs
181 #define yy_yys def_yys
182 #define yystate def_state
183 #define yytmp def_tmp
185 #define yy_yyv def_yyv
186 #define yyval def_val
187 #define yylloc def_lloc
188 #define yyreds def_reds /* With YYDEBUG defined. */
189 #define yytoks def_toks /* With YYDEBUG defined. */
190 #define yylhs def_yylhs
191 #define yylen def_yylen
192 #define yydefred def_yydefred
193 #define yydgoto def_yydgoto
194 #define yysindex def_yysindex
195 #define yyrindex def_yyrindex
196 #define yygindex def_yygindex
197 #define yytable def_yytable
198 #define yycheck def_yycheck
200 static void def_description (const char *);
201 static void def_exports (const char *, const char *, int, int);
202 static void def_heapsize (int, int);
203 static void def_import (const char *, const char *, const char *, const char *,
205 static void def_image_name (const char *, int, int);
206 static void def_section (const char *, int);
207 static void def_section_alt (const char *, const char *);
208 static void def_stacksize (int, int);
209 static void def_version (int, int);
210 static void def_directive (char *);
211 static int def_parse (void);
212 static int def_error (const char *);
213 static int def_lex (void);
215 static int lex_forced_token
= 0;
216 static const char *lex_parse_string
= 0;
217 static const char *lex_parse_string_end
= 0;
221 /* Enabling traces. */
226 /* Enabling verbose error messages. */
227 #ifdef YYERROR_VERBOSE
228 # undef YYERROR_VERBOSE
229 # define YYERROR_VERBOSE 1
231 # define YYERROR_VERBOSE 0
234 /* Enabling the token table. */
235 #ifndef YYTOKEN_TABLE
236 # define YYTOKEN_TABLE 0
239 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
240 #line 102 "deffilep.y"
241 typedef union YYSTYPE
{
245 /* Line 196 of yacc.c. */
246 #line 247 "deffilep.c"
247 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
248 # define YYSTYPE_IS_DECLARED 1
249 # define YYSTYPE_IS_TRIVIAL 1
254 /* Copy the second part of user declarations. */
257 /* Line 219 of yacc.c. */
258 #line 259 "deffilep.c"
260 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
261 # define YYSIZE_T __SIZE_TYPE__
263 #if ! defined (YYSIZE_T) && defined (size_t)
264 # define YYSIZE_T size_t
266 #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
267 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
268 # define YYSIZE_T size_t
270 #if ! defined (YYSIZE_T)
271 # define YYSIZE_T unsigned int
277 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
278 # define YY_(msgid) dgettext ("bison-runtime", msgid)
282 # define YY_(msgid) msgid
286 #if ! defined (yyoverflow) || YYERROR_VERBOSE
288 /* The parser invokes alloca or malloc; define the necessary symbols. */
290 # ifdef YYSTACK_USE_ALLOCA
291 # if YYSTACK_USE_ALLOCA
293 # define YYSTACK_ALLOC __builtin_alloca
295 # define YYSTACK_ALLOC alloca
296 # if defined (__STDC__) || defined (__cplusplus)
297 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
298 # define YYINCLUDED_STDLIB_H
304 # ifdef YYSTACK_ALLOC
305 /* Pacify GCC's `empty if-body' warning. */
306 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
307 # ifndef YYSTACK_ALLOC_MAXIMUM
308 /* The OS might guarantee only one guard page at the bottom of the stack,
309 and a page size can be as small as 4096 bytes. So we cannot safely
310 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
311 to allow for a few compiler-allocated temporary stack slots. */
312 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
315 # define YYSTACK_ALLOC YYMALLOC
316 # define YYSTACK_FREE YYFREE
317 # ifndef YYSTACK_ALLOC_MAXIMUM
318 # define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
324 # define YYMALLOC malloc
325 # if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
326 && (defined (__STDC__) || defined (__cplusplus)))
327 void *malloc (YYSIZE_T
); /* INFRINGES ON USER NAME SPACE */
332 # if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
333 && (defined (__STDC__) || defined (__cplusplus)))
334 void free (void *); /* INFRINGES ON USER NAME SPACE */
341 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
344 #if (! defined (yyoverflow) \
345 && (! defined (__cplusplus) \
346 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
348 /* A type that is properly aligned for any stack member. */
355 /* The size of the maximum gap between one aligned stack and the next. */
356 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
358 /* The size of an array large to enough to hold all stacks, each with
360 # define YYSTACK_BYTES(N) \
361 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
362 + YYSTACK_GAP_MAXIMUM)
364 /* Copy COUNT objects from FROM to TO. The source and destination do
367 # if defined (__GNUC__) && 1 < __GNUC__
368 # define YYCOPY(To, From, Count) \
369 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
371 # define YYCOPY(To, From, Count) \
375 for (yyi = 0; yyi < (Count); yyi++) \
376 (To)[yyi] = (From)[yyi]; \
382 /* Relocate STACK from its old location to the new one. The
383 local variables YYSIZE and YYSTACKSIZE give the old and new number of
384 elements in the stack, and YYPTR gives the new location of the
385 stack. Advance YYPTR to a properly aligned location for the next
387 # define YYSTACK_RELOCATE(Stack) \
390 YYSIZE_T yynewbytes; \
391 YYCOPY (&yyptr->Stack, Stack, yysize); \
392 Stack = &yyptr->Stack; \
393 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
394 yyptr += yynewbytes / sizeof (*yyptr); \
400 #if defined (__STDC__) || defined (__cplusplus)
401 typedef signed char yysigned_char
;
403 typedef short int yysigned_char
;
406 /* YYFINAL -- State number of the termination state. */
408 /* YYLAST -- Last index in YYTABLE. */
411 /* YYNTOKENS -- Number of terminals. */
413 /* YYNNTS -- Number of nonterminals. */
415 /* YYNRULES -- Number of rules. */
417 /* YYNRULES -- Number of states. */
420 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
422 #define YYMAXUTOK 283
424 #define YYTRANSLATE(YYX) \
425 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
427 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
428 static const unsigned char yytranslate
[] =
430 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
431 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
432 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
433 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
434 2, 2, 2, 2, 31, 2, 29, 2, 2, 2,
435 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
436 2, 30, 2, 2, 32, 2, 2, 2, 2, 2,
437 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
438 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
439 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
440 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
441 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
442 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
443 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
444 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
445 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
446 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
447 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
448 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
449 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
450 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
451 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
452 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
453 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
454 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
455 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
456 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
457 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
462 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
464 static const unsigned char yyprhs
[] =
466 0, 0, 3, 6, 8, 12, 16, 19, 23, 27,
467 30, 33, 36, 39, 42, 45, 50, 53, 54, 56,
468 59, 65, 69, 70, 72, 74, 76, 78, 80, 82,
469 84, 86, 89, 91, 99, 107, 113, 119, 125, 129,
470 132, 134, 137, 140, 144, 146, 148, 149, 152, 153,
471 155, 157, 159, 161, 163, 167, 168, 171, 172, 175,
475 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
476 static const yysigned_char yyrhs
[] =
478 34, 0, -1, 34, 35, -1, 35, -1, 3, 48,
479 51, -1, 4, 48, 51, -1, 5, 27, -1, 6,
480 28, 46, -1, 7, 28, 46, -1, 8, 44, -1,
481 9, 44, -1, 11, 42, -1, 12, 36, -1, 13,
482 40, -1, 14, 28, -1, 14, 28, 29, 28, -1,
483 26, 27, -1, -1, 37, -1, 36, 37, -1, 52,
484 50, 49, 45, 38, -1, 39, 45, 38, -1, -1,
485 24, -1, 25, -1, 16, -1, 17, -1, 9, -1,
486 10, -1, 18, -1, 19, -1, 40, 41, -1, 41,
487 -1, 27, 30, 27, 29, 27, 29, 27, -1, 27,
488 30, 27, 29, 27, 29, 28, -1, 27, 30, 27,
489 29, 27, -1, 27, 30, 27, 29, 28, -1, 27,
490 29, 27, 29, 27, -1, 27, 29, 27, -1, 42,
491 43, -1, 43, -1, 27, 44, -1, 27, 27, -1,
492 44, 45, 47, -1, 47, -1, 31, -1, -1, 31,
493 28, -1, -1, 20, -1, 21, -1, 22, -1, 23,
494 -1, 27, -1, 27, 29, 27, -1, -1, 32, 28,
495 -1, -1, 30, 52, -1, -1, 15, 30, 28, -1,
496 -1, 27, -1, 52, 29, 27, -1
499 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
500 static const unsigned char yyrline
[] =
502 0, 119, 119, 120, 124, 125, 126, 127, 128, 129,
503 130, 131, 132, 133, 134, 135, 136, 140, 142, 143,
504 150, 157, 158, 161, 162, 163, 164, 165, 166, 167,
505 168, 171, 172, 176, 177, 178, 179, 180, 181, 185,
506 186, 190, 191, 195, 196, 200, 201, 203, 204, 208,
507 209, 210, 211, 214, 215, 221, 225, 226, 230, 231,
512 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
513 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
514 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
515 static const char *const yytname
[] =
517 "$end", "error", "$undefined", "NAME", "LIBRARY", "DESCRIPTION",
518 "STACKSIZE", "HEAPSIZE", "CODE", "DATAU", "DATAL", "SECTIONS", "EXPORTS",
519 "IMPORTS", "VERSIONK", "BASE", "CONSTANTU", "CONSTANTL", "PRIVATEU",
520 "PRIVATEL", "READ", "WRITE", "EXECUTE", "SHARED", "NONAMEU", "NONAMEL",
521 "DIRECTIVE", "ID", "NUMBER", "'.'", "'='", "','", "'@'", "$accept",
522 "start", "command", "explist", "expline", "exp_opt_list", "exp_opt",
523 "implist", "impline", "seclist", "secline", "attr_list", "opt_comma",
524 "opt_number", "attr", "opt_name", "opt_ordinal", "opt_equal_name",
525 "opt_base", "dot_name", 0
530 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
532 static const unsigned short int yytoknum
[] =
534 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
535 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
536 275, 276, 277, 278, 279, 280, 281, 282, 283, 46,
541 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
542 static const unsigned char yyr1
[] =
544 0, 33, 34, 34, 35, 35, 35, 35, 35, 35,
545 35, 35, 35, 35, 35, 35, 35, 36, 36, 36,
546 37, 38, 38, 39, 39, 39, 39, 39, 39, 39,
547 39, 40, 40, 41, 41, 41, 41, 41, 41, 42,
548 42, 43, 43, 44, 44, 45, 45, 46, 46, 47,
549 47, 47, 47, 48, 48, 48, 49, 49, 50, 50,
553 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
554 static const unsigned char yyr2
[] =
556 0, 2, 2, 1, 3, 3, 2, 3, 3, 2,
557 2, 2, 2, 2, 2, 4, 2, 0, 1, 2,
558 5, 3, 0, 1, 1, 1, 1, 1, 1, 1,
559 1, 2, 1, 7, 7, 5, 5, 5, 3, 2,
560 1, 2, 2, 3, 1, 1, 0, 2, 0, 1,
561 1, 1, 1, 1, 3, 0, 2, 0, 2, 0,
565 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
566 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
567 means the default is an error. */
568 static const unsigned char yydefact
[] =
570 0, 55, 55, 0, 0, 0, 0, 0, 0, 17,
571 0, 0, 0, 0, 3, 53, 61, 61, 6, 48,
572 48, 49, 50, 51, 52, 9, 44, 10, 0, 11,
573 40, 62, 12, 18, 59, 0, 13, 32, 14, 16,
574 1, 2, 0, 0, 4, 5, 0, 7, 8, 45,
575 0, 42, 41, 39, 19, 0, 0, 57, 0, 0,
576 31, 0, 54, 0, 47, 43, 63, 58, 0, 46,
577 38, 0, 15, 60, 56, 22, 0, 0, 27, 28,
578 25, 26, 29, 30, 23, 24, 20, 46, 37, 35,
579 36, 22, 0, 21, 33, 34
582 /* YYDEFGOTO[NTERM-NUM]. */
583 static const yysigned_char yydefgoto
[] =
585 -1, 13, 14, 32, 33, 86, 87, 36, 37, 29,
586 30, 25, 50, 47, 26, 16, 69, 57, 44, 34
589 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
591 #define YYPACT_NINF -55
592 static const yysigned_char yypact
[] =
594 16, -9, -9, 5, 22, 29, 41, 41, 31, 32,
595 38, 39, 42, 0, -55, 37, 53, 53, -55, 40,
596 40, -55, -55, -55, -55, 18, -55, 18, 33, 31,
597 -55, -55, 32, -55, -28, -13, 38, -55, 43, -55,
598 -55, -55, 46, 44, -55, -55, 47, -55, -55, -55,
599 41, -55, 18, -55, -55, 49, 32, 45, 51, 52,
600 -55, 54, -55, 55, -55, -55, -55, 56, 58, 50,
601 59, 60, -55, -55, -55, 27, 57, 7, -55, -55,
602 -55, -55, -55, -55, -55, -55, -55, 50, -55, 61,
603 -55, 27, 20, -55, -55, -55
606 /* YYPGOTO[NTERM-NUM]. */
607 static const yysigned_char yypgoto
[] =
609 -55, -55, 67, -55, 62, -21, -55, -55, 63, -55,
610 64, 3, -54, 71, 48, 85, -55, -55, 75, 65
613 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
614 positive, shift that token. If negative, reduce the rule which
615 number is the opposite. If zero, do what YYDEFACT says.
616 If YYTABLE_NINF, syntax error. */
617 #define YYTABLE_NINF -47
618 static const yysigned_char yytable
[] =
620 40, 55, 56, 1, 2, 3, 4, 5, 6, 7,
621 27, 8, 9, 10, 11, 75, 58, 59, 15, 1,
622 2, 3, 4, 5, 6, 7, 12, 8, 9, 10,
623 11, 52, 18, 91, 89, 90, 78, 79, -46, -46,
624 -46, -46, 12, 80, 81, 82, 83, 94, 95, 49,
625 19, 84, 85, 21, 22, 23, 24, 20, 28, 31,
626 51, 21, 22, 23, 24, 35, 42, 38, 43, 39,
627 93, 46, 61, 62, 63, 64, 66, 68, 70, 71,
628 41, 49, 72, 73, 88, 55, 74, 17, 76, 77,
629 92, 48, 45, 53, 54, 0, 0, 0, 65, 60,
630 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
631 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
635 static const yysigned_char yycheck
[] =
637 0, 29, 30, 3, 4, 5, 6, 7, 8, 9,
638 7, 11, 12, 13, 14, 69, 29, 30, 27, 3,
639 4, 5, 6, 7, 8, 9, 26, 11, 12, 13,
640 14, 28, 27, 87, 27, 28, 9, 10, 20, 21,
641 22, 23, 26, 16, 17, 18, 19, 27, 28, 31,
642 28, 24, 25, 20, 21, 22, 23, 28, 27, 27,
643 27, 20, 21, 22, 23, 27, 29, 28, 15, 27,
644 91, 31, 29, 27, 30, 28, 27, 32, 27, 27,
645 13, 31, 28, 28, 27, 29, 28, 2, 29, 29,
646 29, 20, 17, 29, 32, -1, -1, -1, 50, 36,
647 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
648 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
652 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
653 symbol of state STATE-NUM. */
654 static const unsigned char yystos
[] =
656 0, 3, 4, 5, 6, 7, 8, 9, 11, 12,
657 13, 14, 26, 34, 35, 27, 48, 48, 27, 28,
658 28, 20, 21, 22, 23, 44, 47, 44, 27, 42,
659 43, 27, 36, 37, 52, 27, 40, 41, 28, 27,
660 0, 35, 29, 15, 51, 51, 31, 46, 46, 31,
661 45, 27, 44, 43, 37, 29, 30, 50, 29, 30,
662 41, 29, 27, 30, 28, 47, 27, 52, 32, 49,
663 27, 27, 28, 28, 28, 45, 29, 29, 9, 10,
664 16, 17, 18, 19, 24, 25, 38, 39, 27, 27,
665 28, 45, 29, 38, 27, 28
668 #define yyerrok (yyerrstatus = 0)
669 #define yyclearin (yychar = YYEMPTY)
673 #define YYACCEPT goto yyacceptlab
674 #define YYABORT goto yyabortlab
675 #define YYERROR goto yyerrorlab
678 /* Like YYERROR except do call yyerror. This remains here temporarily
679 to ease the transition to the new meaning of YYERROR, for GCC.
680 Once GCC version 2 has supplanted version 1, this can go. */
682 #define YYFAIL goto yyerrlab
684 #define YYRECOVERING() (!!yyerrstatus)
686 #define YYBACKUP(Token, Value) \
688 if (yychar == YYEMPTY && yylen == 1) \
692 yytoken = YYTRANSLATE (yychar); \
698 yyerror (YY_("syntax error: cannot back up")); \
705 #define YYERRCODE 256
708 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
709 If N is 0, then set CURRENT to the empty location which ends
710 the previous symbol: RHS[0] (always defined). */
712 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
713 #ifndef YYLLOC_DEFAULT
714 # define YYLLOC_DEFAULT(Current, Rhs, N) \
718 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
719 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
720 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
721 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
725 (Current).first_line = (Current).last_line = \
726 YYRHSLOC (Rhs, 0).last_line; \
727 (Current).first_column = (Current).last_column = \
728 YYRHSLOC (Rhs, 0).last_column; \
734 /* YY_LOCATION_PRINT -- Print the location on the stream.
735 This macro was not mandated originally: define only if we know
736 we won't break user code: when these are the locations we know. */
738 #ifndef YY_LOCATION_PRINT
739 # if YYLTYPE_IS_TRIVIAL
740 # define YY_LOCATION_PRINT(File, Loc) \
741 fprintf (File, "%d.%d-%d.%d", \
742 (Loc).first_line, (Loc).first_column, \
743 (Loc).last_line, (Loc).last_column)
745 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
750 /* YYLEX -- calling `yylex' with the right arguments. */
753 # define YYLEX yylex (YYLEX_PARAM)
755 # define YYLEX yylex ()
758 /* Enable debugging if requested. */
762 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
763 # define YYFPRINTF fprintf
766 # define YYDPRINTF(Args) \
772 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
776 YYFPRINTF (stderr, "%s ", Title); \
777 yysymprint (stderr, \
779 YYFPRINTF (stderr, "\n"); \
783 /*------------------------------------------------------------------.
784 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
786 `------------------------------------------------------------------*/
788 #if defined (__STDC__) || defined (__cplusplus)
790 yy_stack_print (short int *bottom
, short int *top
)
793 yy_stack_print (bottom
, top
)
798 YYFPRINTF (stderr
, "Stack now");
799 for (/* Nothing. */; bottom
<= top
; ++bottom
)
800 YYFPRINTF (stderr
, " %d", *bottom
);
801 YYFPRINTF (stderr
, "\n");
804 # define YY_STACK_PRINT(Bottom, Top) \
807 yy_stack_print ((Bottom), (Top)); \
811 /*------------------------------------------------.
812 | Report that the YYRULE is going to be reduced. |
813 `------------------------------------------------*/
815 #if defined (__STDC__) || defined (__cplusplus)
817 yy_reduce_print (int yyrule
)
820 yy_reduce_print (yyrule
)
825 unsigned long int yylno
= yyrline
[yyrule
];
826 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu), ",
828 /* Print the symbols being reduced, and their result. */
829 for (yyi
= yyprhs
[yyrule
]; 0 <= yyrhs
[yyi
]; yyi
++)
830 YYFPRINTF (stderr
, "%s ", yytname
[yyrhs
[yyi
]]);
831 YYFPRINTF (stderr
, "-> %s\n", yytname
[yyr1
[yyrule
]]);
834 # define YY_REDUCE_PRINT(Rule) \
837 yy_reduce_print (Rule); \
840 /* Nonzero means print parse trace. It is left uninitialized so that
841 multiple parsers can coexist. */
844 # define YYDPRINTF(Args)
845 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
846 # define YY_STACK_PRINT(Bottom, Top)
847 # define YY_REDUCE_PRINT(Rule)
848 #endif /* !YYDEBUG */
851 /* YYINITDEPTH -- initial size of the parser's stacks. */
853 # define YYINITDEPTH 200
856 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
857 if the built-in stack extension method is used).
859 Do not make this value too large; the results are undefined if
860 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
861 evaluated with infinite-precision integer arithmetic. */
864 # define YYMAXDEPTH 10000
872 # if defined (__GLIBC__) && defined (_STRING_H)
873 # define yystrlen strlen
875 /* Return the length of YYSTR. */
877 # if defined (__STDC__) || defined (__cplusplus)
878 yystrlen (const char *yystr
)
884 const char *yys
= yystr
;
886 while (*yys
++ != '\0')
889 return yys
- yystr
- 1;
895 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
896 # define yystpcpy stpcpy
898 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
901 # if defined (__STDC__) || defined (__cplusplus)
902 yystpcpy (char *yydest
, const char *yysrc
)
904 yystpcpy (yydest
, yysrc
)
910 const char *yys
= yysrc
;
912 while ((*yyd
++ = *yys
++) != '\0')
921 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
922 quotes and backslashes, so that it's suitable for yyerror. The
923 heuristic is that double-quoting is unnecessary unless the string
924 contains an apostrophe, a comma, or backslash (other than
925 backslash-backslash). YYSTR is taken from yytname. If YYRES is
926 null, do not copy; instead, return the length of what the result
929 yytnamerr (char *yyres
, const char *yystr
)
934 char const *yyp
= yystr
;
941 goto do_not_strip_quotes
;
945 goto do_not_strip_quotes
;
958 do_not_strip_quotes
: ;
962 return yystrlen (yystr
);
964 return yystpcpy (yyres
, yystr
) - yyres
;
968 #endif /* YYERROR_VERBOSE */
973 /*--------------------------------.
974 | Print this symbol on YYOUTPUT. |
975 `--------------------------------*/
977 #if defined (__STDC__) || defined (__cplusplus)
979 yysymprint (FILE *yyoutput
, int yytype
, YYSTYPE
*yyvaluep
)
982 yysymprint (yyoutput
, yytype
, yyvaluep
)
988 /* Pacify ``unused variable'' warnings. */
991 if (yytype
< YYNTOKENS
)
992 YYFPRINTF (yyoutput
, "token %s (", yytname
[yytype
]);
994 YYFPRINTF (yyoutput
, "nterm %s (", yytname
[yytype
]);
998 if (yytype
< YYNTOKENS
)
999 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
1006 YYFPRINTF (yyoutput
, ")");
1009 #endif /* ! YYDEBUG */
1010 /*-----------------------------------------------.
1011 | Release the memory associated to this symbol. |
1012 `-----------------------------------------------*/
1014 #if defined (__STDC__) || defined (__cplusplus)
1016 yydestruct (const char *yymsg
, int yytype
, YYSTYPE
*yyvaluep
)
1019 yydestruct (yymsg
, yytype
, yyvaluep
)
1025 /* Pacify ``unused variable'' warnings. */
1030 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
1041 /* Prevent warnings from -Wmissing-prototypes. */
1043 #ifdef YYPARSE_PARAM
1044 # if defined (__STDC__) || defined (__cplusplus)
1045 int yyparse (void *YYPARSE_PARAM
);
1049 #else /* ! YYPARSE_PARAM */
1050 #if defined (__STDC__) || defined (__cplusplus)
1055 #endif /* ! YYPARSE_PARAM */
1059 /* The look-ahead symbol. */
1062 /* The semantic value of the look-ahead symbol. */
1065 /* Number of syntax errors so far. */
1074 #ifdef YYPARSE_PARAM
1075 # if defined (__STDC__) || defined (__cplusplus)
1076 int yyparse (void *YYPARSE_PARAM
)
1078 int yyparse (YYPARSE_PARAM
)
1079 void *YYPARSE_PARAM
;
1081 #else /* ! YYPARSE_PARAM */
1082 #if defined (__STDC__) || defined (__cplusplus)
1096 /* Number of tokens to shift before error messages enabled. */
1098 /* Look-ahead token as an internal (translated) token number. */
1101 /* Three stacks and their tools:
1102 `yyss': related to states,
1103 `yyvs': related to semantic values,
1104 `yyls': related to locations.
1106 Refer to the stacks thru separate pointers, to allow yyoverflow
1107 to reallocate them elsewhere. */
1109 /* The state stack. */
1110 short int yyssa
[YYINITDEPTH
];
1111 short int *yyss
= yyssa
;
1114 /* The semantic value stack. */
1115 YYSTYPE yyvsa
[YYINITDEPTH
];
1116 YYSTYPE
*yyvs
= yyvsa
;
1121 #define YYPOPSTACK (yyvsp--, yyssp--)
1123 YYSIZE_T yystacksize
= YYINITDEPTH
;
1125 /* The variables used to return semantic value and location from the
1130 /* When reducing, the number of symbols on the RHS of the reduced
1134 YYDPRINTF ((stderr
, "Starting parse\n"));
1139 yychar
= YYEMPTY
; /* Cause a token to be read. */
1141 /* Initialize stack pointers.
1142 Waste one element of value and location stack
1143 so that they stay on the same level as the state stack.
1144 The wasted elements are never initialized. */
1151 /*------------------------------------------------------------.
1152 | yynewstate -- Push a new state, which is found in yystate. |
1153 `------------------------------------------------------------*/
1155 /* In all cases, when you get here, the value and location stacks
1156 have just been pushed. so pushing a state here evens the stacks.
1163 if (yyss
+ yystacksize
- 1 <= yyssp
)
1165 /* Get the current used size of the three stacks, in elements. */
1166 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1170 /* Give user a chance to reallocate the stack. Use copies of
1171 these so that the &'s don't force the real ones into
1173 YYSTYPE
*yyvs1
= yyvs
;
1174 short int *yyss1
= yyss
;
1177 /* Each stack pointer address is followed by the size of the
1178 data in use in that stack, in bytes. This used to be a
1179 conditional around just the two extra args, but that might
1180 be undefined if yyoverflow is a macro. */
1181 yyoverflow (YY_("memory exhausted"),
1182 &yyss1
, yysize
* sizeof (*yyssp
),
1183 &yyvs1
, yysize
* sizeof (*yyvsp
),
1190 #else /* no yyoverflow */
1191 # ifndef YYSTACK_RELOCATE
1192 goto yyexhaustedlab
;
1194 /* Extend the stack our own way. */
1195 if (YYMAXDEPTH
<= yystacksize
)
1196 goto yyexhaustedlab
;
1198 if (YYMAXDEPTH
< yystacksize
)
1199 yystacksize
= YYMAXDEPTH
;
1202 short int *yyss1
= yyss
;
1203 union yyalloc
*yyptr
=
1204 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1206 goto yyexhaustedlab
;
1207 YYSTACK_RELOCATE (yyss
);
1208 YYSTACK_RELOCATE (yyvs
);
1210 # undef YYSTACK_RELOCATE
1212 YYSTACK_FREE (yyss1
);
1215 #endif /* no yyoverflow */
1217 yyssp
= yyss
+ yysize
- 1;
1218 yyvsp
= yyvs
+ yysize
- 1;
1221 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1222 (unsigned long int) yystacksize
));
1224 if (yyss
+ yystacksize
- 1 <= yyssp
)
1228 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1237 /* Do appropriate processing given the current state. */
1238 /* Read a look-ahead token if we need one and don't already have one. */
1241 /* First try to decide what to do without reference to look-ahead token. */
1243 yyn
= yypact
[yystate
];
1244 if (yyn
== YYPACT_NINF
)
1247 /* Not known => get a look-ahead token if don't already have one. */
1249 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1250 if (yychar
== YYEMPTY
)
1252 YYDPRINTF ((stderr
, "Reading a token: "));
1256 if (yychar
<= YYEOF
)
1258 yychar
= yytoken
= YYEOF
;
1259 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1263 yytoken
= YYTRANSLATE (yychar
);
1264 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1267 /* If the proper action on seeing token YYTOKEN is to reduce or to
1268 detect an error, take that action. */
1270 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1275 if (yyn
== 0 || yyn
== YYTABLE_NINF
)
1284 /* Shift the look-ahead token. */
1285 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1287 /* Discard the token being shifted unless it is eof. */
1288 if (yychar
!= YYEOF
)
1294 /* Count tokens shifted since error; after three, turn off error
1303 /*-----------------------------------------------------------.
1304 | yydefault -- do the default action for the current state. |
1305 `-----------------------------------------------------------*/
1307 yyn
= yydefact
[yystate
];
1313 /*-----------------------------.
1314 | yyreduce -- Do a reduction. |
1315 `-----------------------------*/
1317 /* yyn is the number of a rule to reduce with. */
1320 /* If YYLEN is nonzero, implement the default value of the action:
1323 Otherwise, the following line sets YYVAL to garbage.
1324 This behavior is undocumented and Bison
1325 users should not rely upon it. Assigning to YYVAL
1326 unconditionally makes the parser a bit smaller, and it avoids a
1327 GCC warning that YYVAL may be used uninitialized. */
1328 yyval
= yyvsp
[1-yylen
];
1331 YY_REDUCE_PRINT (yyn
);
1335 #line 124 "deffilep.y"
1336 { def_image_name ((yyvsp
[-1].id
), (yyvsp
[0].number
), 0); }
1340 #line 125 "deffilep.y"
1341 { def_image_name ((yyvsp
[-1].id
), (yyvsp
[0].number
), 1); }
1345 #line 126 "deffilep.y"
1346 { def_description ((yyvsp
[0].id
));}
1350 #line 127 "deffilep.y"
1351 { def_stacksize ((yyvsp
[-1].number
), (yyvsp
[0].number
));}
1355 #line 128 "deffilep.y"
1356 { def_heapsize ((yyvsp
[-1].number
), (yyvsp
[0].number
));}
1360 #line 129 "deffilep.y"
1361 { def_section ("CODE", (yyvsp
[0].number
));}
1365 #line 130 "deffilep.y"
1366 { def_section ("DATA", (yyvsp
[0].number
));}
1370 #line 134 "deffilep.y"
1371 { def_version ((yyvsp
[0].number
), 0);}
1375 #line 135 "deffilep.y"
1376 { def_version ((yyvsp
[-2].number
), (yyvsp
[0].number
));}
1380 #line 136 "deffilep.y"
1381 { def_directive ((yyvsp
[0].id
));}
1385 #line 151 "deffilep.y"
1386 { def_exports ((yyvsp
[-4].id
), (yyvsp
[-3].id
), (yyvsp
[-2].number
), (yyvsp
[0].number
)); }
1390 #line 157 "deffilep.y"
1391 { (yyval
.number
) = (yyvsp
[-2].number
) | (yyvsp
[0].number
); }
1395 #line 158 "deffilep.y"
1396 { (yyval
.number
) = 0; }
1400 #line 161 "deffilep.y"
1401 { (yyval
.number
) = 1; }
1405 #line 162 "deffilep.y"
1406 { (yyval
.number
) = 1; }
1410 #line 163 "deffilep.y"
1411 { (yyval
.number
) = 2; }
1415 #line 164 "deffilep.y"
1416 { (yyval
.number
) = 2; }
1420 #line 165 "deffilep.y"
1421 { (yyval
.number
) = 4; }
1425 #line 166 "deffilep.y"
1426 { (yyval
.number
) = 4; }
1430 #line 167 "deffilep.y"
1431 { (yyval
.number
) = 8; }
1435 #line 168 "deffilep.y"
1436 { (yyval
.number
) = 8; }
1440 #line 176 "deffilep.y"
1441 { def_import ((yyvsp
[-6].id
), (yyvsp
[-4].id
), (yyvsp
[-2].id
), (yyvsp
[0].id
), -1); }
1445 #line 177 "deffilep.y"
1446 { def_import ((yyvsp
[-6].id
), (yyvsp
[-4].id
), (yyvsp
[-2].id
), 0, (yyvsp
[0].number
)); }
1450 #line 178 "deffilep.y"
1451 { def_import ((yyvsp
[-4].id
), (yyvsp
[-2].id
), 0, (yyvsp
[0].id
), -1); }
1455 #line 179 "deffilep.y"
1456 { def_import ((yyvsp
[-4].id
), (yyvsp
[-2].id
), 0, 0, (yyvsp
[0].number
)); }
1460 #line 180 "deffilep.y"
1461 { def_import ( 0, (yyvsp
[-4].id
), (yyvsp
[-2].id
), (yyvsp
[0].id
), -1); }
1465 #line 181 "deffilep.y"
1466 { def_import ( 0, (yyvsp
[-2].id
), 0, (yyvsp
[0].id
), -1); }
1470 #line 190 "deffilep.y"
1471 { def_section ((yyvsp
[-1].id
), (yyvsp
[0].number
));}
1475 #line 191 "deffilep.y"
1476 { def_section_alt ((yyvsp
[-1].id
), (yyvsp
[0].id
));}
1480 #line 195 "deffilep.y"
1481 { (yyval
.number
) = (yyvsp
[-2].number
) | (yyvsp
[0].number
); }
1485 #line 196 "deffilep.y"
1486 { (yyval
.number
) = (yyvsp
[0].number
); }
1490 #line 203 "deffilep.y"
1491 { (yyval
.number
)=(yyvsp
[0].number
);}
1495 #line 204 "deffilep.y"
1496 { (yyval
.number
)=-1;}
1500 #line 208 "deffilep.y"
1501 { (yyval
.number
) = 1;}
1505 #line 209 "deffilep.y"
1506 { (yyval
.number
) = 2;}
1510 #line 210 "deffilep.y"
1511 { (yyval
.number
)=4;}
1515 #line 211 "deffilep.y"
1516 { (yyval
.number
)=8;}
1520 #line 214 "deffilep.y"
1521 { (yyval
.id
) = (yyvsp
[0].id
); }
1525 #line 216 "deffilep.y"
1527 char *name
= xmalloc (strlen ((yyvsp
[-2].id
)) + 1 + strlen ((yyvsp
[0].id
)) + 1);
1528 sprintf (name
, "%s.%s", (yyvsp
[-2].id
), (yyvsp
[0].id
));
1534 #line 221 "deffilep.y"
1535 { (yyval
.id
) = ""; }
1539 #line 225 "deffilep.y"
1540 { (yyval
.number
) = (yyvsp
[0].number
);}
1544 #line 226 "deffilep.y"
1545 { (yyval
.number
) = -1;}
1549 #line 230 "deffilep.y"
1550 { (yyval
.id
) = (yyvsp
[0].id
); }
1554 #line 231 "deffilep.y"
1559 #line 234 "deffilep.y"
1560 { (yyval
.number
) = (yyvsp
[0].number
);}
1564 #line 235 "deffilep.y"
1565 { (yyval
.number
) = -1;}
1569 #line 238 "deffilep.y"
1570 { (yyval
.id
) = (yyvsp
[0].id
); }
1574 #line 240 "deffilep.y"
1576 char *name
= xmalloc (strlen ((yyvsp
[-2].id
)) + 1 + strlen ((yyvsp
[0].id
)) + 1);
1577 sprintf (name
, "%s.%s", (yyvsp
[-2].id
), (yyvsp
[0].id
));
1586 /* Line 1126 of yacc.c. */
1587 #line 1588 "deffilep.c"
1593 YY_STACK_PRINT (yyss
, yyssp
);
1598 /* Now `shift' the result of the reduction. Determine what state
1599 that goes to, based on the state we popped back to and the rule
1600 number reduced by. */
1604 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
1605 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1606 yystate
= yytable
[yystate
];
1608 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
1613 /*------------------------------------.
1614 | yyerrlab -- here on detecting error |
1615 `------------------------------------*/
1617 /* If not already recovering from an error, report this error. */
1622 yyn
= yypact
[yystate
];
1624 if (YYPACT_NINF
< yyn
&& yyn
< YYLAST
)
1626 int yytype
= YYTRANSLATE (yychar
);
1627 YYSIZE_T yysize0
= yytnamerr (0, yytname
[yytype
]);
1628 YYSIZE_T yysize
= yysize0
;
1630 int yysize_overflow
= 0;
1632 # define YYERROR_VERBOSE_ARGS_MAXIMUM 5
1633 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1637 /* This is so xgettext sees the translatable formats that are
1638 constructed on the fly. */
1639 YY_("syntax error, unexpected %s");
1640 YY_("syntax error, unexpected %s, expecting %s");
1641 YY_("syntax error, unexpected %s, expecting %s or %s");
1642 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1643 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1647 static char const yyunexpected
[] = "syntax error, unexpected %s";
1648 static char const yyexpecting
[] = ", expecting %s";
1649 static char const yyor
[] = " or %s";
1650 char yyformat
[sizeof yyunexpected
1651 + sizeof yyexpecting
- 1
1652 + ((YYERROR_VERBOSE_ARGS_MAXIMUM
- 2)
1653 * (sizeof yyor
- 1))];
1654 char const *yyprefix
= yyexpecting
;
1656 /* Start YYX at -YYN if negative to avoid negative indexes in
1658 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1660 /* Stay within bounds of both yycheck and yytname. */
1661 int yychecklim
= YYLAST
- yyn
;
1662 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1665 yyarg
[0] = yytname
[yytype
];
1666 yyfmt
= yystpcpy (yyformat
, yyunexpected
);
1668 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1669 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1671 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1675 yyformat
[sizeof yyunexpected
- 1] = '\0';
1678 yyarg
[yycount
++] = yytname
[yyx
];
1679 yysize1
= yysize
+ yytnamerr (0, yytname
[yyx
]);
1680 yysize_overflow
|= yysize1
< yysize
;
1682 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
1686 yyf
= YY_(yyformat
);
1687 yysize1
= yysize
+ yystrlen (yyf
);
1688 yysize_overflow
|= yysize1
< yysize
;
1691 if (!yysize_overflow
&& yysize
<= YYSTACK_ALLOC_MAXIMUM
)
1692 yymsg
= (char *) YYSTACK_ALLOC (yysize
);
1695 /* Avoid sprintf, as that infringes on the user's name space.
1696 Don't have undefined behavior even if the translation
1697 produced a string with the wrong number of "%s"s. */
1700 while ((*yyp
= *yyf
))
1702 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
1704 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1714 YYSTACK_FREE (yymsg
);
1718 yyerror (YY_("syntax error"));
1719 goto yyexhaustedlab
;
1723 #endif /* YYERROR_VERBOSE */
1724 yyerror (YY_("syntax error"));
1729 if (yyerrstatus
== 3)
1731 /* If just tried and failed to reuse look-ahead token after an
1732 error, discard it. */
1734 if (yychar
<= YYEOF
)
1736 /* Return failure if at end of input. */
1737 if (yychar
== YYEOF
)
1742 yydestruct ("Error: discarding", yytoken
, &yylval
);
1747 /* Else will try to reuse look-ahead token after shifting the error
1752 /*---------------------------------------------------.
1753 | yyerrorlab -- error raised explicitly by YYERROR. |
1754 `---------------------------------------------------*/
1757 /* Pacify compilers like GCC when the user code never invokes
1758 YYERROR and the label yyerrorlab therefore never appears in user
1769 /*-------------------------------------------------------------.
1770 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1771 `-------------------------------------------------------------*/
1773 yyerrstatus
= 3; /* Each real token shifted decrements this. */
1777 yyn
= yypact
[yystate
];
1778 if (yyn
!= YYPACT_NINF
)
1781 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
1789 /* Pop the current state because it cannot handle the error token. */
1794 yydestruct ("Error: popping", yystos
[yystate
], yyvsp
);
1797 YY_STACK_PRINT (yyss
, yyssp
);
1806 /* Shift the error token. */
1807 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
1813 /*-------------------------------------.
1814 | yyacceptlab -- YYACCEPT comes here. |
1815 `-------------------------------------*/
1820 /*-----------------------------------.
1821 | yyabortlab -- YYABORT comes here. |
1822 `-----------------------------------*/
1828 /*-------------------------------------------------.
1829 | yyexhaustedlab -- memory exhaustion comes here. |
1830 `-------------------------------------------------*/
1832 yyerror (YY_("memory exhausted"));
1838 if (yychar
!= YYEOF
&& yychar
!= YYEMPTY
)
1839 yydestruct ("Cleanup: discarding lookahead",
1841 while (yyssp
!= yyss
)
1843 yydestruct ("Cleanup: popping",
1844 yystos
[*yyssp
], yyvsp
);
1849 YYSTACK_FREE (yyss
);
1855 #line 248 "deffilep.y"
1858 /*****************************************************************************
1860 *****************************************************************************/
1862 static FILE *the_file
;
1863 static const char *def_filename
;
1864 static int linenumber
;
1865 static def_file
*def
;
1866 static int saw_newline
;
1870 struct directive
*next
;
1875 static struct directive
*directives
= 0;
1878 def_file_empty (void)
1880 def_file
*rv
= xmalloc (sizeof (def_file
));
1881 memset (rv
, 0, sizeof (def_file
));
1883 rv
->base_address
= (bfd_vma
) -1;
1884 rv
->stack_reserve
= rv
->stack_commit
= -1;
1885 rv
->heap_reserve
= rv
->heap_commit
= -1;
1886 rv
->version_major
= rv
->version_minor
= -1;
1891 def_file_parse (const char *filename
, def_file
*add_to
)
1893 struct directive
*d
;
1895 the_file
= fopen (filename
, "r");
1896 def_filename
= filename
;
1909 def
= def_file_empty ();
1915 def_file_free (def
);
1922 for (d
= directives
; d
; d
= d
->next
)
1925 printf ("Adding directive %08x `%s'\n", d
->name
, d
->name
);
1927 def_file_add_directive (def
, d
->name
, d
->len
);
1934 def_file_free (def_file
*def
)
1942 if (def
->description
)
1943 free (def
->description
);
1945 if (def
->section_defs
)
1947 for (i
= 0; i
< def
->num_section_defs
; i
++)
1949 if (def
->section_defs
[i
].name
)
1950 free (def
->section_defs
[i
].name
);
1951 if (def
->section_defs
[i
].class)
1952 free (def
->section_defs
[i
].class);
1954 free (def
->section_defs
);
1959 for (i
= 0; i
< def
->num_exports
; i
++)
1961 if (def
->exports
[i
].internal_name
1962 && def
->exports
[i
].internal_name
!= def
->exports
[i
].name
)
1963 free (def
->exports
[i
].internal_name
);
1964 if (def
->exports
[i
].name
)
1965 free (def
->exports
[i
].name
);
1967 free (def
->exports
);
1972 for (i
= 0; i
< def
->num_imports
; i
++)
1974 if (def
->imports
[i
].internal_name
1975 && def
->imports
[i
].internal_name
!= def
->imports
[i
].name
)
1976 free (def
->imports
[i
].internal_name
);
1977 if (def
->imports
[i
].name
)
1978 free (def
->imports
[i
].name
);
1980 free (def
->imports
);
1983 while (def
->modules
)
1985 def_file_module
*m
= def
->modules
;
1986 def
->modules
= def
->modules
->next
;
1993 #ifdef DEF_FILE_PRINT
1995 def_file_print (FILE *file
, def_file
*def
)
1999 fprintf (file
, ">>>> def_file at 0x%08x\n", def
);
2001 fprintf (file
, " name: %s\n", def
->name
? def
->name
: "(unspecified)");
2002 if (def
->is_dll
!= -1)
2003 fprintf (file
, " is dll: %s\n", def
->is_dll
? "yes" : "no");
2004 if (def
->base_address
!= (bfd_vma
) -1)
2005 fprintf (file
, " base address: 0x%08x\n", def
->base_address
);
2006 if (def
->description
)
2007 fprintf (file
, " description: `%s'\n", def
->description
);
2008 if (def
->stack_reserve
!= -1)
2009 fprintf (file
, " stack reserve: 0x%08x\n", def
->stack_reserve
);
2010 if (def
->stack_commit
!= -1)
2011 fprintf (file
, " stack commit: 0x%08x\n", def
->stack_commit
);
2012 if (def
->heap_reserve
!= -1)
2013 fprintf (file
, " heap reserve: 0x%08x\n", def
->heap_reserve
);
2014 if (def
->heap_commit
!= -1)
2015 fprintf (file
, " heap commit: 0x%08x\n", def
->heap_commit
);
2017 if (def
->num_section_defs
> 0)
2019 fprintf (file
, " section defs:\n");
2021 for (i
= 0; i
< def
->num_section_defs
; i
++)
2023 fprintf (file
, " name: `%s', class: `%s', flags:",
2024 def
->section_defs
[i
].name
, def
->section_defs
[i
].class);
2025 if (def
->section_defs
[i
].flag_read
)
2026 fprintf (file
, " R");
2027 if (def
->section_defs
[i
].flag_write
)
2028 fprintf (file
, " W");
2029 if (def
->section_defs
[i
].flag_execute
)
2030 fprintf (file
, " X");
2031 if (def
->section_defs
[i
].flag_shared
)
2032 fprintf (file
, " S");
2033 fprintf (file
, "\n");
2037 if (def
->num_exports
> 0)
2039 fprintf (file
, " exports:\n");
2041 for (i
= 0; i
< def
->num_exports
; i
++)
2043 fprintf (file
, " name: `%s', int: `%s', ordinal: %d, flags:",
2044 def
->exports
[i
].name
, def
->exports
[i
].internal_name
,
2045 def
->exports
[i
].ordinal
);
2046 if (def
->exports
[i
].flag_private
)
2047 fprintf (file
, " P");
2048 if (def
->exports
[i
].flag_constant
)
2049 fprintf (file
, " C");
2050 if (def
->exports
[i
].flag_noname
)
2051 fprintf (file
, " N");
2052 if (def
->exports
[i
].flag_data
)
2053 fprintf (file
, " D");
2054 fprintf (file
, "\n");
2058 if (def
->num_imports
> 0)
2060 fprintf (file
, " imports:\n");
2062 for (i
= 0; i
< def
->num_imports
; i
++)
2064 fprintf (file
, " int: %s, from: `%s', name: `%s', ordinal: %d\n",
2065 def
->imports
[i
].internal_name
,
2066 def
->imports
[i
].module
,
2067 def
->imports
[i
].name
,
2068 def
->imports
[i
].ordinal
);
2072 if (def
->version_major
!= -1)
2073 fprintf (file
, " version: %d.%d\n", def
->version_major
, def
->version_minor
);
2075 fprintf (file
, "<<<< def_file at 0x%08x\n", def
);
2080 def_file_add_export (def_file
*def
,
2081 const char *external_name
,
2082 const char *internal_name
,
2086 int max_exports
= ROUND_UP(def
->num_exports
, 32);
2088 if (def
->num_exports
>= max_exports
)
2090 max_exports
= ROUND_UP(def
->num_exports
+ 1, 32);
2092 def
->exports
= xrealloc (def
->exports
,
2093 max_exports
* sizeof (def_file_export
));
2095 def
->exports
= xmalloc (max_exports
* sizeof (def_file_export
));
2097 e
= def
->exports
+ def
->num_exports
;
2098 memset (e
, 0, sizeof (def_file_export
));
2099 if (internal_name
&& !external_name
)
2100 external_name
= internal_name
;
2101 if (external_name
&& !internal_name
)
2102 internal_name
= external_name
;
2103 e
->name
= xstrdup (external_name
);
2104 e
->internal_name
= xstrdup (internal_name
);
2105 e
->ordinal
= ordinal
;
2111 def_get_module (def_file
*def
, const char *name
)
2115 for (s
= def
->modules
; s
; s
= s
->next
)
2116 if (strcmp (s
->name
, name
) == 0)
2122 static def_file_module
*
2123 def_stash_module (def_file
*def
, const char *name
)
2127 if ((s
= def_get_module (def
, name
)) != NULL
)
2129 s
= xmalloc (sizeof (def_file_module
) + strlen (name
));
2130 s
->next
= def
->modules
;
2133 strcpy (s
->name
, name
);
2138 def_file_add_import (def_file
*def
,
2142 const char *internal_name
)
2145 int max_imports
= ROUND_UP (def
->num_imports
, 16);
2147 if (def
->num_imports
>= max_imports
)
2149 max_imports
= ROUND_UP (def
->num_imports
+1, 16);
2152 def
->imports
= xrealloc (def
->imports
,
2153 max_imports
* sizeof (def_file_import
));
2155 def
->imports
= xmalloc (max_imports
* sizeof (def_file_import
));
2157 i
= def
->imports
+ def
->num_imports
;
2158 memset (i
, 0, sizeof (def_file_import
));
2160 i
->name
= xstrdup (name
);
2162 i
->module
= def_stash_module (def
, module
);
2163 i
->ordinal
= ordinal
;
2165 i
->internal_name
= xstrdup (internal_name
);
2167 i
->internal_name
= i
->name
;
2180 { "-heap", HEAPSIZE
},
2181 { "-stack", STACKSIZE
},
2182 { "-attr", SECTIONS
},
2183 { "-export", EXPORTS
},
2188 def_file_add_directive (def_file
*my_def
, const char *param
, int len
)
2190 def_file
*save_def
= def
;
2191 const char *pend
= param
+ len
;
2192 char * tend
= (char *) param
;
2197 while (param
< pend
)
2200 && (ISSPACE (*param
) || *param
== '\n' || *param
== 0))
2206 /* Scan forward until we encounter any of:
2207 - the end of the buffer
2208 - the start of a new option
2209 - a newline seperating options
2210 - a NUL seperating options. */
2211 for (tend
= (char *) (param
+ 1);
2213 && !(ISSPACE (tend
[-1]) && *tend
== '-')
2214 && *tend
!= '\n' && *tend
!= 0);
2218 for (i
= 0; diropts
[i
].param
; i
++)
2220 int len
= strlen (diropts
[i
].param
);
2222 if (tend
- param
>= len
2223 && strncmp (param
, diropts
[i
].param
, len
) == 0
2224 && (param
[len
] == ':' || param
[len
] == ' '))
2226 lex_parse_string_end
= tend
;
2227 lex_parse_string
= param
+ len
+ 1;
2228 lex_forced_token
= diropts
[i
].token
;
2236 if (!diropts
[i
].param
)
2242 /* xgettext:c-format */
2243 einfo (_("Warning: .drectve `%s' unrecognized\n"), param
);
2247 lex_parse_string
= 0;
2254 /* Parser Callbacks. */
2257 def_image_name (const char *name
, int base
, int is_dll
)
2259 /* If a LIBRARY or NAME statement is specified without a name, there is nothing
2260 to do here. We retain the output filename specified on command line. */
2263 const char* image_name
= lbasename (name
);
2264 if (image_name
!= name
)
2265 einfo ("%s:%d: Warning: path components stripped from %s, '%s'\n",
2266 def_filename
, linenumber
, is_dll
? "LIBRARY" : "NAME",
2270 /* Append the default suffix, if none specified. */
2271 if (strchr (image_name
, '.') == 0)
2273 const char * suffix
= is_dll
? ".dll" : ".exe";
2275 def
->name
= xmalloc (strlen (image_name
) + strlen (suffix
) + 1);
2276 sprintf (def
->name
, "%s%s", image_name
, suffix
);
2279 def
->name
= xstrdup (image_name
);
2282 /* Honor a BASE address statement, even if LIBRARY string is empty. */
2283 def
->base_address
= base
;
2284 def
->is_dll
= is_dll
;
2288 def_description (const char *text
)
2290 int len
= def
->description
? strlen (def
->description
) : 0;
2292 len
+= strlen (text
) + 1;
2293 if (def
->description
)
2295 def
->description
= xrealloc (def
->description
, len
);
2296 strcat (def
->description
, text
);
2300 def
->description
= xmalloc (len
);
2301 strcpy (def
->description
, text
);
2306 def_stacksize (int reserve
, int commit
)
2308 def
->stack_reserve
= reserve
;
2309 def
->stack_commit
= commit
;
2313 def_heapsize (int reserve
, int commit
)
2315 def
->heap_reserve
= reserve
;
2316 def
->heap_commit
= commit
;
2320 def_section (const char *name
, int attr
)
2322 def_file_section
*s
;
2323 int max_sections
= ROUND_UP (def
->num_section_defs
, 4);
2325 if (def
->num_section_defs
>= max_sections
)
2327 max_sections
= ROUND_UP (def
->num_section_defs
+1, 4);
2329 if (def
->section_defs
)
2330 def
->section_defs
= xrealloc (def
->section_defs
,
2331 max_sections
* sizeof (def_file_import
));
2333 def
->section_defs
= xmalloc (max_sections
* sizeof (def_file_import
));
2335 s
= def
->section_defs
+ def
->num_section_defs
;
2336 memset (s
, 0, sizeof (def_file_section
));
2337 s
->name
= xstrdup (name
);
2343 s
->flag_execute
= 1;
2347 def
->num_section_defs
++;
2351 def_section_alt (const char *name
, const char *attr
)
2355 for (; *attr
; attr
++)
2377 def_section (name
, aval
);
2381 def_exports (const char *external_name
,
2382 const char *internal_name
,
2386 def_file_export
*dfe
;
2388 if (!internal_name
&& external_name
)
2389 internal_name
= external_name
;
2391 printf ("def_exports, ext=%s int=%s\n", external_name
, internal_name
);
2394 dfe
= def_file_add_export (def
, external_name
, internal_name
, ordinal
);
2396 dfe
->flag_noname
= 1;
2398 dfe
->flag_constant
= 1;
2402 dfe
->flag_private
= 1;
2406 def_import (const char *internal_name
,
2413 const char *ext
= dllext
? dllext
: "dll";
2415 buf
= xmalloc (strlen (module
) + strlen (ext
) + 2);
2416 sprintf (buf
, "%s.%s", module
, ext
);
2419 def_file_add_import (def
, name
, module
, ordinal
, internal_name
);
2425 def_version (int major
, int minor
)
2427 def
->version_major
= major
;
2428 def
->version_minor
= minor
;
2432 def_directive (char *str
)
2434 struct directive
*d
= xmalloc (sizeof (struct directive
));
2436 d
->next
= directives
;
2438 d
->name
= xstrdup (str
);
2439 d
->len
= strlen (str
);
2443 def_error (const char *err
)
2445 einfo ("%P: %s:%d: %s\n",
2446 def_filename
? def_filename
: "<unknown-file>", linenumber
, err
);
2451 /* Lexical Scanner. */
2456 /* Never freed, but always reused as needed, so no real leak. */
2457 static char *buffer
= 0;
2458 static int buflen
= 0;
2459 static int bufptr
= 0;
2464 if (bufptr
== buflen
)
2466 buflen
+= 50; /* overly reasonable, eh? */
2468 buffer
= xrealloc (buffer
, buflen
+ 1);
2470 buffer
= xmalloc (buflen
+ 1);
2472 buffer
[bufptr
++] = c
;
2473 buffer
[bufptr
] = 0; /* not optimal, but very convenient. */
2485 { "CONSTANT", CONSTANTU
},
2486 { "constant", CONSTANTL
},
2489 { "DESCRIPTION", DESCRIPTION
},
2490 { "DIRECTIVE", DIRECTIVE
},
2491 { "EXECUTE", EXECUTE
},
2492 { "EXPORTS", EXPORTS
},
2493 { "HEAPSIZE", HEAPSIZE
},
2494 { "IMPORTS", IMPORTS
},
2495 { "LIBRARY", LIBRARY
},
2497 { "NONAME", NONAMEU
},
2498 { "noname", NONAMEL
},
2499 { "PRIVATE", PRIVATEU
},
2500 { "private", PRIVATEL
},
2502 { "SECTIONS", SECTIONS
},
2503 { "SEGMENTS", SECTIONS
},
2504 { "SHARED", SHARED
},
2505 { "STACKSIZE", STACKSIZE
},
2506 { "VERSION", VERSIONK
},
2516 if (lex_parse_string
)
2518 if (lex_parse_string
>= lex_parse_string_end
)
2521 rv
= *lex_parse_string
++;
2525 rv
= fgetc (the_file
);
2535 if (lex_parse_string
)
2541 return ungetc (c
, the_file
);
2549 if (lex_forced_token
)
2551 i
= lex_forced_token
;
2552 lex_forced_token
= 0;
2554 printf ("lex: forcing token %d\n", i
);
2561 /* Trim leading whitespace. */
2562 while (c
!= EOF
&& (c
== ' ' || c
== '\t') && saw_newline
)
2568 printf ("lex: EOF\n");
2573 if (saw_newline
&& c
== ';')
2579 while (c
!= EOF
&& c
!= '\n');
2585 /* Must be something else. */
2591 while (c
!= EOF
&& (ISXDIGIT (c
) || (c
== 'x')))
2598 yylval
.number
= strtoul (buffer
, 0, 0);
2600 printf ("lex: `%s' returns NUMBER %d\n", buffer
, yylval
.number
);
2605 if (ISALPHA (c
) || strchr ("$:-_?@", c
))
2614 if (ISBLANK (c
) ) /* '@' followed by whitespace. */
2616 else if (ISDIGIT (c
)) /* '@' followed by digit. */
2622 printf ("lex: @ returns itself\n");
2626 while (c
!= EOF
&& (ISALNUM (c
) || strchr ("$:-_?/@", c
)))
2633 if (ISALPHA (q
)) /* Check for tokens. */
2635 for (i
= 0; tokens
[i
].name
; i
++)
2636 if (strcmp (tokens
[i
].name
, buffer
) == 0)
2639 printf ("lex: `%s' is a string token\n", buffer
);
2641 return tokens
[i
].token
;
2645 printf ("lex: `%s' returns ID\n", buffer
);
2647 yylval
.id
= xstrdup (buffer
);
2651 if (c
== '\'' || c
== '"')
2657 while (c
!= EOF
&& c
!= q
)
2662 yylval
.id
= xstrdup (buffer
);
2664 printf ("lex: `%s' returns ID\n", buffer
);
2669 if (c
== '=' || c
== '.' || c
== ',')
2672 printf ("lex: `%c' returns itself\n", c
);
2683 /*printf ("lex: 0x%02x ignored\n", c); */