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
101 #define DESCRIPTION 260
102 #define STACKSIZE_K 261
112 #define CONSTANTU 271
113 #define CONSTANTL 272
116 #define ALIGNCOMM 275
123 #define DIRECTIVE 282
130 /* Copy the first part of user declarations. */
132 /* deffilep.y - parser for .def files */
134 /* Copyright 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006,
135 2007, 2009 Free Software Foundation, Inc.
137 This file is part of GNU Binutils.
139 This program is free software; you can redistribute it and/or modify
140 it under the terms of the GNU General Public License as published by
141 the Free Software Foundation; either version 3 of the License, or
142 (at your option) any later version.
144 This program is distributed in the hope that it will be useful,
145 but WITHOUT ANY WARRANTY; without even the implied warranty of
146 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
147 GNU General Public License for more details.
149 You should have received a copy of the GNU General Public License
150 along with this program; if not, write to the Free Software
151 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
152 MA 02110-1301, USA. */
155 #include "libiberty.h"
156 #include "safe-ctype.h"
164 #define ROUND_UP(a, b) (((a)+((b)-1))&~((b)-1))
166 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
167 as well as gratuitiously global symbol names, so we can have multiple
168 yacc generated parsers in ld. Note that these are only the variables
169 produced by yacc. If other parser generators (bison, byacc, etc) produce
170 additional global names that conflict at link time, then those parser
171 generators need to be fixed instead of adding those names to this list. */
173 #define yymaxdepth def_maxdepth
174 #define yyparse def_parse
175 #define yylex def_lex
176 #define yyerror def_error
177 #define yylval def_lval
178 #define yychar def_char
179 #define yydebug def_debug
180 #define yypact def_pact
183 #define yydef def_def
184 #define yychk def_chk
185 #define yypgo def_pgo
186 #define yyact def_act
187 #define yyexca def_exca
188 #define yyerrflag def_errflag
189 #define yynerrs def_nerrs
193 #define yy_yys def_yys
194 #define yystate def_state
195 #define yytmp def_tmp
197 #define yy_yyv def_yyv
198 #define yyval def_val
199 #define yylloc def_lloc
200 #define yyreds def_reds /* With YYDEBUG defined. */
201 #define yytoks def_toks /* With YYDEBUG defined. */
202 #define yylhs def_yylhs
203 #define yylen def_yylen
204 #define yydefred def_yydefred
205 #define yydgoto def_yydgoto
206 #define yysindex def_yysindex
207 #define yyrindex def_yyrindex
208 #define yygindex def_yygindex
209 #define yytable def_yytable
210 #define yycheck def_yycheck
212 static void def_description (const char *);
213 static void def_exports (const char *, const char *, int, int);
214 static void def_heapsize (int, int);
215 static void def_import (const char *, const char *, const char *, const char *,
217 static void def_image_name (const char *, int, int);
218 static void def_section (const char *, int);
219 static void def_section_alt (const char *, const char *);
220 static void def_stacksize (int, int);
221 static void def_version (int, int);
222 static void def_directive (char *);
223 static void def_aligncomm (char *str
, int align
);
224 static int def_parse (void);
225 static int def_error (const char *);
226 static int def_lex (void);
228 static int lex_forced_token
= 0;
229 static const char *lex_parse_string
= 0;
230 static const char *lex_parse_string_end
= 0;
234 /* Enabling traces. */
239 /* Enabling verbose error messages. */
240 #ifdef YYERROR_VERBOSE
241 # undef YYERROR_VERBOSE
242 # define YYERROR_VERBOSE 1
244 # define YYERROR_VERBOSE 0
247 /* Enabling the token table. */
248 #ifndef YYTOKEN_TABLE
249 # define YYTOKEN_TABLE 0
252 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
253 typedef union YYSTYPE
254 #line 103 "deffilep.y"
260 /* Line 193 of yacc.c. */
261 #line 262 "deffilep.c"
263 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
264 # define YYSTYPE_IS_DECLARED 1
265 # define YYSTYPE_IS_TRIVIAL 1
270 /* Copy the second part of user declarations. */
273 /* Line 216 of yacc.c. */
274 #line 275 "deffilep.c"
281 typedef YYTYPE_UINT8 yytype_uint8
;
283 typedef unsigned char yytype_uint8
;
287 typedef YYTYPE_INT8 yytype_int8
;
288 #elif (defined __STDC__ || defined __C99__FUNC__ \
289 || defined __cplusplus || defined _MSC_VER)
290 typedef signed char yytype_int8
;
292 typedef short int yytype_int8
;
296 typedef YYTYPE_UINT16 yytype_uint16
;
298 typedef unsigned short int yytype_uint16
;
302 typedef YYTYPE_INT16 yytype_int16
;
304 typedef short int yytype_int16
;
308 # ifdef __SIZE_TYPE__
309 # define YYSIZE_T __SIZE_TYPE__
310 # elif defined size_t
311 # define YYSIZE_T size_t
312 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
313 || defined __cplusplus || defined _MSC_VER)
314 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
315 # define YYSIZE_T size_t
317 # define YYSIZE_T unsigned int
321 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
324 # if defined YYENABLE_NLS && YYENABLE_NLS
326 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
327 # define YY_(msgid) dgettext ("bison-runtime", msgid)
331 # define YY_(msgid) msgid
335 /* Suppress unused-variable warnings by "using" E. */
336 #if ! defined lint || defined __GNUC__
337 # define YYUSE(e) ((void) (e))
339 # define YYUSE(e) /* empty */
342 /* Identity function, used to suppress warnings about constant conditions. */
346 #if (defined __STDC__ || defined __C99__FUNC__ \
347 || defined __cplusplus || defined _MSC_VER)
360 #if ! defined yyoverflow || YYERROR_VERBOSE
362 /* The parser invokes alloca or malloc; define the necessary symbols. */
364 # ifdef YYSTACK_USE_ALLOCA
365 # if YYSTACK_USE_ALLOCA
367 # define YYSTACK_ALLOC __builtin_alloca
368 # elif defined __BUILTIN_VA_ARG_INCR
369 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
371 # define YYSTACK_ALLOC __alloca
372 # elif defined _MSC_VER
373 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
374 # define alloca _alloca
376 # define YYSTACK_ALLOC alloca
377 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
378 || defined __cplusplus || defined _MSC_VER)
379 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
388 # ifdef YYSTACK_ALLOC
389 /* Pacify GCC's `empty if-body' warning. */
390 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
391 # ifndef YYSTACK_ALLOC_MAXIMUM
392 /* The OS might guarantee only one guard page at the bottom of the stack,
393 and a page size can be as small as 4096 bytes. So we cannot safely
394 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
395 to allow for a few compiler-allocated temporary stack slots. */
396 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
399 # define YYSTACK_ALLOC YYMALLOC
400 # define YYSTACK_FREE YYFREE
401 # ifndef YYSTACK_ALLOC_MAXIMUM
402 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
404 # if (defined __cplusplus && ! defined _STDLIB_H \
405 && ! ((defined YYMALLOC || defined malloc) \
406 && (defined YYFREE || defined free)))
407 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
413 # define YYMALLOC malloc
414 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
415 || defined __cplusplus || defined _MSC_VER)
416 void *malloc (YYSIZE_T
); /* INFRINGES ON USER NAME SPACE */
421 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
422 || defined __cplusplus || defined _MSC_VER)
423 void free (void *); /* INFRINGES ON USER NAME SPACE */
427 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
430 #if (! defined yyoverflow \
431 && (! defined __cplusplus \
432 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
434 /* A type that is properly aligned for any stack member. */
441 /* The size of the maximum gap between one aligned stack and the next. */
442 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
444 /* The size of an array large to enough to hold all stacks, each with
446 # define YYSTACK_BYTES(N) \
447 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
448 + YYSTACK_GAP_MAXIMUM)
450 /* Copy COUNT objects from FROM to TO. The source and destination do
453 # if defined __GNUC__ && 1 < __GNUC__
454 # define YYCOPY(To, From, Count) \
455 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
457 # define YYCOPY(To, From, Count) \
461 for (yyi = 0; yyi < (Count); yyi++) \
462 (To)[yyi] = (From)[yyi]; \
468 /* Relocate STACK from its old location to the new one. The
469 local variables YYSIZE and YYSTACKSIZE give the old and new number of
470 elements in the stack, and YYPTR gives the new location of the
471 stack. Advance YYPTR to a properly aligned location for the next
473 # define YYSTACK_RELOCATE(Stack) \
476 YYSIZE_T yynewbytes; \
477 YYCOPY (&yyptr->Stack, Stack, yysize); \
478 Stack = &yyptr->Stack; \
479 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
480 yyptr += yynewbytes / sizeof (*yyptr); \
486 /* YYFINAL -- State number of the termination state. */
488 /* YYLAST -- Last index in YYTABLE. */
491 /* YYNTOKENS -- Number of terminals. */
493 /* YYNNTS -- Number of nonterminals. */
495 /* YYNRULES -- Number of rules. */
497 /* YYNRULES -- Number of states. */
498 #define YYNSTATES 107
500 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
502 #define YYMAXUTOK 284
504 #define YYTRANSLATE(YYX) \
505 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
507 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
508 static const yytype_uint8 yytranslate
[] =
510 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
511 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
512 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
513 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
514 2, 2, 2, 2, 31, 2, 30, 2, 2, 2,
515 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
516 2, 32, 2, 2, 33, 2, 2, 2, 2, 2,
517 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
518 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
519 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
520 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
521 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
522 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
523 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
524 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
525 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
526 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
527 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
528 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
529 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
530 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
531 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
532 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
533 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
534 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
535 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
536 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
537 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
542 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
544 static const yytype_uint8 yyprhs
[] =
546 0, 0, 3, 6, 8, 12, 16, 19, 23, 27,
547 30, 33, 36, 39, 42, 45, 50, 53, 58, 59,
548 61, 64, 70, 74, 75, 77, 79, 81, 83, 85,
549 87, 89, 91, 94, 96, 104, 112, 118, 124, 130,
550 134, 137, 139, 142, 145, 149, 151, 153, 154, 157,
551 158, 160, 162, 164, 166, 168, 172, 173, 176, 177,
552 180, 181, 185, 186, 188, 192, 194, 199, 201, 202,
556 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
557 static const yytype_int8 yyrhs
[] =
559 35, 0, -1, 35, 36, -1, 36, -1, 3, 49,
560 52, -1, 4, 49, 52, -1, 5, 28, -1, 6,
561 57, 47, -1, 7, 57, 47, -1, 8, 45, -1,
562 9, 45, -1, 11, 43, -1, 12, 37, -1, 13,
563 41, -1, 14, 57, -1, 14, 57, 30, 57, -1,
564 27, 28, -1, 20, 54, 31, 57, -1, -1, 38,
565 -1, 37, 38, -1, 53, 51, 50, 46, 39, -1,
566 40, 46, 39, -1, -1, 25, -1, 26, -1, 16,
567 -1, 17, -1, 9, -1, 10, -1, 18, -1, 19,
568 -1, 41, 42, -1, 42, -1, 28, 32, 28, 30,
569 28, 30, 28, -1, 28, 32, 28, 30, 28, 30,
570 57, -1, 28, 32, 28, 30, 28, -1, 28, 32,
571 28, 30, 57, -1, 28, 30, 28, 30, 28, -1,
572 28, 30, 28, -1, 43, 44, -1, 44, -1, 28,
573 45, -1, 28, 28, -1, 45, 46, 48, -1, 48,
574 -1, 31, -1, -1, 31, 57, -1, -1, 21, -1,
575 22, -1, 23, -1, 24, -1, 28, -1, 28, 30,
576 28, -1, -1, 33, 57, -1, -1, 32, 53, -1,
577 -1, 15, 32, 57, -1, -1, 28, -1, 53, 30,
578 28, -1, 28, -1, 54, 30, 55, 56, -1, 29,
579 -1, -1, 28, -1, -1, 29, -1
582 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
583 static const yytype_uint16 yyrline
[] =
585 0, 123, 123, 124, 128, 129, 130, 131, 132, 133,
586 134, 135, 136, 137, 138, 139, 140, 141, 145, 147,
587 148, 155, 162, 163, 166, 167, 168, 169, 170, 171,
588 172, 173, 176, 177, 181, 182, 183, 184, 185, 186,
589 190, 191, 195, 196, 200, 201, 205, 206, 208, 209,
590 213, 214, 215, 216, 219, 220, 226, 230, 231, 235,
591 236, 239, 240, 243, 244, 252, 253, 261, 262, 265,
596 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
597 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
598 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
599 static const char *const yytname
[] =
601 "$end", "error", "$undefined", "NAME", "LIBRARY", "DESCRIPTION",
602 "STACKSIZE_K", "HEAPSIZE", "CODE", "DATAU", "DATAL", "SECTIONS",
603 "EXPORTS", "IMPORTS", "VERSIONK", "BASE", "CONSTANTU", "CONSTANTL",
604 "PRIVATEU", "PRIVATEL", "ALIGNCOMM", "READ", "WRITE", "EXECUTE",
605 "SHARED", "NONAMEU", "NONAMEL", "DIRECTIVE", "ID", "DIGITS", "'.'",
606 "','", "'='", "'@'", "$accept", "start", "command", "explist", "expline",
607 "exp_opt_list", "exp_opt", "implist", "impline", "seclist", "secline",
608 "attr_list", "opt_comma", "opt_number", "attr", "opt_name",
609 "opt_ordinal", "opt_equal_name", "opt_base", "dot_name", "anylang_id",
610 "opt_digits", "opt_id", "NUMBER", 0
615 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
617 static const yytype_uint16 yytoknum
[] =
619 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
620 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
621 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
626 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
627 static const yytype_uint8 yyr1
[] =
629 0, 34, 35, 35, 36, 36, 36, 36, 36, 36,
630 36, 36, 36, 36, 36, 36, 36, 36, 37, 37,
631 37, 38, 39, 39, 40, 40, 40, 40, 40, 40,
632 40, 40, 41, 41, 42, 42, 42, 42, 42, 42,
633 43, 43, 44, 44, 45, 45, 46, 46, 47, 47,
634 48, 48, 48, 48, 49, 49, 49, 50, 50, 51,
635 51, 52, 52, 53, 53, 54, 54, 55, 55, 56,
639 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
640 static const yytype_uint8 yyr2
[] =
642 0, 2, 2, 1, 3, 3, 2, 3, 3, 2,
643 2, 2, 2, 2, 2, 4, 2, 4, 0, 1,
644 2, 5, 3, 0, 1, 1, 1, 1, 1, 1,
645 1, 1, 2, 1, 7, 7, 5, 5, 5, 3,
646 2, 1, 2, 2, 3, 1, 1, 0, 2, 0,
647 1, 1, 1, 1, 1, 3, 0, 2, 0, 2,
648 0, 3, 0, 1, 3, 1, 4, 1, 0, 1,
652 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
653 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
654 means the default is an error. */
655 static const yytype_uint8 yydefact
[] =
657 0, 56, 56, 0, 0, 0, 0, 0, 0, 18,
658 0, 0, 0, 0, 0, 3, 54, 62, 62, 6,
659 71, 49, 49, 50, 51, 52, 53, 9, 45, 10,
660 0, 11, 41, 63, 12, 19, 60, 0, 13, 33,
661 14, 65, 0, 16, 1, 2, 0, 0, 4, 5,
662 0, 7, 8, 46, 0, 43, 42, 40, 20, 0,
663 0, 58, 0, 0, 32, 0, 68, 0, 55, 0,
664 48, 44, 64, 59, 0, 47, 39, 0, 15, 67,
665 70, 17, 61, 57, 23, 0, 0, 69, 66, 28,
666 29, 26, 27, 30, 31, 24, 25, 21, 47, 38,
667 36, 37, 23, 0, 22, 34, 35
670 /* YYDEFGOTO[NTERM-NUM]. */
671 static const yytype_int8 yydefgoto
[] =
673 -1, 14, 15, 34, 35, 97, 98, 38, 39, 31,
674 32, 27, 54, 51, 28, 17, 75, 61, 48, 36,
678 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
680 #define YYPACT_NINF -74
681 static const yytype_int8 yypact
[] =
683 29, -27, -27, -23, -15, -15, 30, 30, 2, 11,
684 19, -15, 27, 33, 4, -74, -7, 48, 48, -74,
685 -74, 26, 26, -74, -74, -74, -74, -2, -74, -2,
686 55, 2, -74, -74, 11, -74, 14, 18, 19, -74,
687 50, -74, -3, -74, -74, -74, 54, 52, -74, -74,
688 -15, -74, -74, -74, 30, -74, -2, -74, -74, 57,
689 11, 53, 59, 60, -74, -15, 61, -15, -74, -15,
690 -74, -74, -74, 62, -15, 58, 63, 64, -74, -74,
691 67, -74, -74, -74, 49, 68, 42, -74, -74, -74,
692 -74, -74, -74, -74, -74, -74, -74, -74, 58, -74,
693 69, -74, 49, 44, -74, -74, -74
696 /* YYPGOTO[NTERM-NUM]. */
697 static const yytype_int8 yypgoto
[] =
699 -74, -74, 77, -74, 66, -1, -74, -74, 65, -74,
700 71, -4, -73, 75, 51, 102, -74, -74, 88, 47,
704 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
705 positive, shift that token. If negative, reduce the rule which
706 number is the opposite. If zero, do what YYDEFACT says.
707 If YYTABLE_NINF, syntax error. */
708 #define YYTABLE_NINF -48
709 static const yytype_int8 yytable
[] =
711 22, 16, 84, 29, 44, 19, 40, 1, 2, 3,
712 4, 5, 6, 7, 20, 8, 9, 10, 11, -47,
713 -47, -47, -47, 46, 12, 102, 56, 66, 67, 53,
714 30, 13, 1, 2, 3, 4, 5, 6, 7, 33,
715 8, 9, 10, 11, 59, 70, 60, 37, 62, 12,
716 63, 23, 24, 25, 26, 41, 13, 50, 89, 90,
717 78, 43, 81, 47, 82, 91, 92, 93, 94, 83,
718 100, 20, 105, 20, 95, 96, 23, 24, 25, 26,
719 65, 101, 68, 55, 69, 72, 74, 76, 77, 53,
720 79, 45, 59, 85, 86, 87, 99, 52, 106, 103,
721 58, 104, 57, 64, 18, 71, 49, 73
724 static const yytype_uint8 yycheck
[] =
726 5, 28, 75, 7, 0, 28, 11, 3, 4, 5,
727 6, 7, 8, 9, 29, 11, 12, 13, 14, 21,
728 22, 23, 24, 30, 20, 98, 30, 30, 31, 31,
729 28, 27, 3, 4, 5, 6, 7, 8, 9, 28,
730 11, 12, 13, 14, 30, 50, 32, 28, 30, 20,
731 32, 21, 22, 23, 24, 28, 27, 31, 9, 10,
732 65, 28, 67, 15, 69, 16, 17, 18, 19, 74,
733 28, 29, 28, 29, 25, 26, 21, 22, 23, 24,
734 30, 86, 28, 28, 32, 28, 33, 28, 28, 31,
735 29, 14, 30, 30, 30, 28, 28, 22, 103, 30,
736 34, 102, 31, 38, 2, 54, 18, 60
739 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
740 symbol of state STATE-NUM. */
741 static const yytype_uint8 yystos
[] =
743 0, 3, 4, 5, 6, 7, 8, 9, 11, 12,
744 13, 14, 20, 27, 35, 36, 28, 49, 49, 28,
745 29, 57, 57, 21, 22, 23, 24, 45, 48, 45,
746 28, 43, 44, 28, 37, 38, 53, 28, 41, 42,
747 57, 28, 54, 28, 0, 36, 30, 15, 52, 52,
748 31, 47, 47, 31, 46, 28, 45, 44, 38, 30,
749 32, 51, 30, 32, 42, 30, 30, 31, 28, 32,
750 57, 48, 28, 53, 33, 50, 28, 28, 57, 29,
751 55, 57, 57, 57, 46, 30, 30, 28, 56, 9,
752 10, 16, 17, 18, 19, 25, 26, 39, 40, 28,
753 28, 57, 46, 30, 39, 28, 57
756 #define yyerrok (yyerrstatus = 0)
757 #define yyclearin (yychar = YYEMPTY)
761 #define YYACCEPT goto yyacceptlab
762 #define YYABORT goto yyabortlab
763 #define YYERROR goto yyerrorlab
766 /* Like YYERROR except do call yyerror. This remains here temporarily
767 to ease the transition to the new meaning of YYERROR, for GCC.
768 Once GCC version 2 has supplanted version 1, this can go. */
770 #define YYFAIL goto yyerrlab
772 #define YYRECOVERING() (!!yyerrstatus)
774 #define YYBACKUP(Token, Value) \
776 if (yychar == YYEMPTY && yylen == 1) \
780 yytoken = YYTRANSLATE (yychar); \
786 yyerror (YY_("syntax error: cannot back up")); \
793 #define YYERRCODE 256
796 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
797 If N is 0, then set CURRENT to the empty location which ends
798 the previous symbol: RHS[0] (always defined). */
800 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
801 #ifndef YYLLOC_DEFAULT
802 # define YYLLOC_DEFAULT(Current, Rhs, N) \
806 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
807 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
808 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
809 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
813 (Current).first_line = (Current).last_line = \
814 YYRHSLOC (Rhs, 0).last_line; \
815 (Current).first_column = (Current).last_column = \
816 YYRHSLOC (Rhs, 0).last_column; \
822 /* YY_LOCATION_PRINT -- Print the location on the stream.
823 This macro was not mandated originally: define only if we know
824 we won't break user code: when these are the locations we know. */
826 #ifndef YY_LOCATION_PRINT
827 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
828 # define YY_LOCATION_PRINT(File, Loc) \
829 fprintf (File, "%d.%d-%d.%d", \
830 (Loc).first_line, (Loc).first_column, \
831 (Loc).last_line, (Loc).last_column)
833 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
838 /* YYLEX -- calling `yylex' with the right arguments. */
841 # define YYLEX yylex (YYLEX_PARAM)
843 # define YYLEX yylex ()
846 /* Enable debugging if requested. */
850 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
851 # define YYFPRINTF fprintf
854 # define YYDPRINTF(Args) \
860 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
864 YYFPRINTF (stderr, "%s ", Title); \
865 yy_symbol_print (stderr, \
867 YYFPRINTF (stderr, "\n"); \
872 /*--------------------------------.
873 | Print this symbol on YYOUTPUT. |
874 `--------------------------------*/
877 #if (defined __STDC__ || defined __C99__FUNC__ \
878 || defined __cplusplus || defined _MSC_VER)
880 yy_symbol_value_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
)
883 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
)
886 YYSTYPE
const * const yyvaluep
;
892 if (yytype
< YYNTOKENS
)
893 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
905 /*--------------------------------.
906 | Print this symbol on YYOUTPUT. |
907 `--------------------------------*/
909 #if (defined __STDC__ || defined __C99__FUNC__ \
910 || defined __cplusplus || defined _MSC_VER)
912 yy_symbol_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
)
915 yy_symbol_print (yyoutput
, yytype
, yyvaluep
)
918 YYSTYPE
const * const yyvaluep
;
921 if (yytype
< YYNTOKENS
)
922 YYFPRINTF (yyoutput
, "token %s (", yytname
[yytype
]);
924 YYFPRINTF (yyoutput
, "nterm %s (", yytname
[yytype
]);
926 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
);
927 YYFPRINTF (yyoutput
, ")");
930 /*------------------------------------------------------------------.
931 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
933 `------------------------------------------------------------------*/
935 #if (defined __STDC__ || defined __C99__FUNC__ \
936 || defined __cplusplus || defined _MSC_VER)
938 yy_stack_print (yytype_int16
*bottom
, yytype_int16
*top
)
941 yy_stack_print (bottom
, top
)
942 yytype_int16
*bottom
;
946 YYFPRINTF (stderr
, "Stack now");
947 for (; bottom
<= top
; ++bottom
)
948 YYFPRINTF (stderr
, " %d", *bottom
);
949 YYFPRINTF (stderr
, "\n");
952 # define YY_STACK_PRINT(Bottom, Top) \
955 yy_stack_print ((Bottom), (Top)); \
959 /*------------------------------------------------.
960 | Report that the YYRULE is going to be reduced. |
961 `------------------------------------------------*/
963 #if (defined __STDC__ || defined __C99__FUNC__ \
964 || defined __cplusplus || defined _MSC_VER)
966 yy_reduce_print (YYSTYPE
*yyvsp
, int yyrule
)
969 yy_reduce_print (yyvsp
, yyrule
)
974 int yynrhs
= yyr2
[yyrule
];
976 unsigned long int yylno
= yyrline
[yyrule
];
977 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu):\n",
979 /* The symbols being reduced. */
980 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
982 fprintf (stderr
, " $%d = ", yyi
+ 1);
983 yy_symbol_print (stderr
, yyrhs
[yyprhs
[yyrule
] + yyi
],
984 &(yyvsp
[(yyi
+ 1) - (yynrhs
)])
986 fprintf (stderr
, "\n");
990 # define YY_REDUCE_PRINT(Rule) \
993 yy_reduce_print (yyvsp, Rule); \
996 /* Nonzero means print parse trace. It is left uninitialized so that
997 multiple parsers can coexist. */
1000 # define YYDPRINTF(Args)
1001 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1002 # define YY_STACK_PRINT(Bottom, Top)
1003 # define YY_REDUCE_PRINT(Rule)
1004 #endif /* !YYDEBUG */
1007 /* YYINITDEPTH -- initial size of the parser's stacks. */
1009 # define YYINITDEPTH 200
1012 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1013 if the built-in stack extension method is used).
1015 Do not make this value too large; the results are undefined if
1016 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1017 evaluated with infinite-precision integer arithmetic. */
1020 # define YYMAXDEPTH 10000
1028 # if defined __GLIBC__ && defined _STRING_H
1029 # define yystrlen strlen
1031 /* Return the length of YYSTR. */
1032 #if (defined __STDC__ || defined __C99__FUNC__ \
1033 || defined __cplusplus || defined _MSC_VER)
1035 yystrlen (const char *yystr
)
1043 for (yylen
= 0; yystr
[yylen
]; yylen
++)
1051 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1052 # define yystpcpy stpcpy
1054 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1056 #if (defined __STDC__ || defined __C99__FUNC__ \
1057 || defined __cplusplus || defined _MSC_VER)
1059 yystpcpy (char *yydest
, const char *yysrc
)
1062 yystpcpy (yydest
, yysrc
)
1068 const char *yys
= yysrc
;
1070 while ((*yyd
++ = *yys
++) != '\0')
1079 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1080 quotes and backslashes, so that it's suitable for yyerror. The
1081 heuristic is that double-quoting is unnecessary unless the string
1082 contains an apostrophe, a comma, or backslash (other than
1083 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1084 null, do not copy; instead, return the length of what the result
1087 yytnamerr (char *yyres
, const char *yystr
)
1092 char const *yyp
= yystr
;
1099 goto do_not_strip_quotes
;
1103 goto do_not_strip_quotes
;
1116 do_not_strip_quotes
: ;
1120 return yystrlen (yystr
);
1122 return yystpcpy (yyres
, yystr
) - yyres
;
1126 /* Copy into YYRESULT an error message about the unexpected token
1127 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1128 including the terminating null byte. If YYRESULT is null, do not
1129 copy anything; just return the number of bytes that would be
1130 copied. As a special case, return 0 if an ordinary "syntax error"
1131 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1132 size calculation. */
1134 yysyntax_error (char *yyresult
, int yystate
, int yychar
)
1136 int yyn
= yypact
[yystate
];
1138 if (! (YYPACT_NINF
< yyn
&& yyn
<= YYLAST
))
1142 int yytype
= YYTRANSLATE (yychar
);
1143 YYSIZE_T yysize0
= yytnamerr (0, yytname
[yytype
]);
1144 YYSIZE_T yysize
= yysize0
;
1146 int yysize_overflow
= 0;
1147 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1148 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1152 /* This is so xgettext sees the translatable formats that are
1153 constructed on the fly. */
1154 YY_("syntax error, unexpected %s");
1155 YY_("syntax error, unexpected %s, expecting %s");
1156 YY_("syntax error, unexpected %s, expecting %s or %s");
1157 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1158 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1162 static char const yyunexpected
[] = "syntax error, unexpected %s";
1163 static char const yyexpecting
[] = ", expecting %s";
1164 static char const yyor
[] = " or %s";
1165 char yyformat
[sizeof yyunexpected
1166 + sizeof yyexpecting
- 1
1167 + ((YYERROR_VERBOSE_ARGS_MAXIMUM
- 2)
1168 * (sizeof yyor
- 1))];
1169 char const *yyprefix
= yyexpecting
;
1171 /* Start YYX at -YYN if negative to avoid negative indexes in
1173 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1175 /* Stay within bounds of both yycheck and yytname. */
1176 int yychecklim
= YYLAST
- yyn
+ 1;
1177 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1180 yyarg
[0] = yytname
[yytype
];
1181 yyfmt
= yystpcpy (yyformat
, yyunexpected
);
1183 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1184 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1186 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1190 yyformat
[sizeof yyunexpected
- 1] = '\0';
1193 yyarg
[yycount
++] = yytname
[yyx
];
1194 yysize1
= yysize
+ yytnamerr (0, yytname
[yyx
]);
1195 yysize_overflow
|= (yysize1
< yysize
);
1197 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
1201 yyf
= YY_(yyformat
);
1202 yysize1
= yysize
+ yystrlen (yyf
);
1203 yysize_overflow
|= (yysize1
< yysize
);
1206 if (yysize_overflow
)
1207 return YYSIZE_MAXIMUM
;
1211 /* Avoid sprintf, as that infringes on the user's name space.
1212 Don't have undefined behavior even if the translation
1213 produced a string with the wrong number of "%s"s. */
1214 char *yyp
= yyresult
;
1216 while ((*yyp
= *yyf
) != '\0')
1218 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
1220 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1233 #endif /* YYERROR_VERBOSE */
1236 /*-----------------------------------------------.
1237 | Release the memory associated to this symbol. |
1238 `-----------------------------------------------*/
1241 #if (defined __STDC__ || defined __C99__FUNC__ \
1242 || defined __cplusplus || defined _MSC_VER)
1244 yydestruct (const char *yymsg
, int yytype
, YYSTYPE
*yyvaluep
)
1247 yydestruct (yymsg
, yytype
, yyvaluep
)
1257 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
1268 /* Prevent warnings from -Wmissing-prototypes. */
1270 #ifdef YYPARSE_PARAM
1271 #if defined __STDC__ || defined __cplusplus
1272 int yyparse (void *YYPARSE_PARAM
);
1276 #else /* ! YYPARSE_PARAM */
1277 #if defined __STDC__ || defined __cplusplus
1282 #endif /* ! YYPARSE_PARAM */
1286 /* The look-ahead symbol. */
1289 /* The semantic value of the look-ahead symbol. */
1292 /* Number of syntax errors so far. */
1301 #ifdef YYPARSE_PARAM
1302 #if (defined __STDC__ || defined __C99__FUNC__ \
1303 || defined __cplusplus || defined _MSC_VER)
1305 yyparse (void *YYPARSE_PARAM
)
1308 yyparse (YYPARSE_PARAM
)
1309 void *YYPARSE_PARAM
;
1311 #else /* ! YYPARSE_PARAM */
1312 #if (defined __STDC__ || defined __C99__FUNC__ \
1313 || defined __cplusplus || defined _MSC_VER)
1327 /* Number of tokens to shift before error messages enabled. */
1329 /* Look-ahead token as an internal (translated) token number. */
1332 /* Buffer for error messages, and its allocated size. */
1334 char *yymsg
= yymsgbuf
;
1335 YYSIZE_T yymsg_alloc
= sizeof yymsgbuf
;
1338 /* Three stacks and their tools:
1339 `yyss': related to states,
1340 `yyvs': related to semantic values,
1341 `yyls': related to locations.
1343 Refer to the stacks thru separate pointers, to allow yyoverflow
1344 to reallocate them elsewhere. */
1346 /* The state stack. */
1347 yytype_int16 yyssa
[YYINITDEPTH
];
1348 yytype_int16
*yyss
= yyssa
;
1349 yytype_int16
*yyssp
;
1351 /* The semantic value stack. */
1352 YYSTYPE yyvsa
[YYINITDEPTH
];
1353 YYSTYPE
*yyvs
= yyvsa
;
1358 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1360 YYSIZE_T yystacksize
= YYINITDEPTH
;
1362 /* The variables used to return semantic value and location from the
1367 /* The number of symbols on the RHS of the reduced rule.
1368 Keep to zero when no symbol should be popped. */
1371 YYDPRINTF ((stderr
, "Starting parse\n"));
1376 yychar
= YYEMPTY
; /* Cause a token to be read. */
1378 /* Initialize stack pointers.
1379 Waste one element of value and location stack
1380 so that they stay on the same level as the state stack.
1381 The wasted elements are never initialized. */
1388 /*------------------------------------------------------------.
1389 | yynewstate -- Push a new state, which is found in yystate. |
1390 `------------------------------------------------------------*/
1392 /* In all cases, when you get here, the value and location stacks
1393 have just been pushed. So pushing a state here evens the stacks. */
1399 if (yyss
+ yystacksize
- 1 <= yyssp
)
1401 /* Get the current used size of the three stacks, in elements. */
1402 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1406 /* Give user a chance to reallocate the stack. Use copies of
1407 these so that the &'s don't force the real ones into
1409 YYSTYPE
*yyvs1
= yyvs
;
1410 yytype_int16
*yyss1
= yyss
;
1413 /* Each stack pointer address is followed by the size of the
1414 data in use in that stack, in bytes. This used to be a
1415 conditional around just the two extra args, but that might
1416 be undefined if yyoverflow is a macro. */
1417 yyoverflow (YY_("memory exhausted"),
1418 &yyss1
, yysize
* sizeof (*yyssp
),
1419 &yyvs1
, yysize
* sizeof (*yyvsp
),
1426 #else /* no yyoverflow */
1427 # ifndef YYSTACK_RELOCATE
1428 goto yyexhaustedlab
;
1430 /* Extend the stack our own way. */
1431 if (YYMAXDEPTH
<= yystacksize
)
1432 goto yyexhaustedlab
;
1434 if (YYMAXDEPTH
< yystacksize
)
1435 yystacksize
= YYMAXDEPTH
;
1438 yytype_int16
*yyss1
= yyss
;
1439 union yyalloc
*yyptr
=
1440 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1442 goto yyexhaustedlab
;
1443 YYSTACK_RELOCATE (yyss
);
1444 YYSTACK_RELOCATE (yyvs
);
1446 # undef YYSTACK_RELOCATE
1448 YYSTACK_FREE (yyss1
);
1451 #endif /* no yyoverflow */
1453 yyssp
= yyss
+ yysize
- 1;
1454 yyvsp
= yyvs
+ yysize
- 1;
1457 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1458 (unsigned long int) yystacksize
));
1460 if (yyss
+ yystacksize
- 1 <= yyssp
)
1464 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1473 /* Do appropriate processing given the current state. Read a
1474 look-ahead token if we need one and don't already have one. */
1476 /* First try to decide what to do without reference to look-ahead token. */
1477 yyn
= yypact
[yystate
];
1478 if (yyn
== YYPACT_NINF
)
1481 /* Not known => get a look-ahead token if don't already have one. */
1483 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1484 if (yychar
== YYEMPTY
)
1486 YYDPRINTF ((stderr
, "Reading a token: "));
1490 if (yychar
<= YYEOF
)
1492 yychar
= yytoken
= YYEOF
;
1493 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1497 yytoken
= YYTRANSLATE (yychar
);
1498 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1501 /* If the proper action on seeing token YYTOKEN is to reduce or to
1502 detect an error, take that action. */
1504 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1509 if (yyn
== 0 || yyn
== YYTABLE_NINF
)
1518 /* Count tokens shifted since error; after three, turn off error
1523 /* Shift the look-ahead token. */
1524 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1526 /* Discard the shifted token unless it is eof. */
1527 if (yychar
!= YYEOF
)
1536 /*-----------------------------------------------------------.
1537 | yydefault -- do the default action for the current state. |
1538 `-----------------------------------------------------------*/
1540 yyn
= yydefact
[yystate
];
1546 /*-----------------------------.
1547 | yyreduce -- Do a reduction. |
1548 `-----------------------------*/
1550 /* yyn is the number of a rule to reduce with. */
1553 /* If YYLEN is nonzero, implement the default value of the action:
1556 Otherwise, the following line sets YYVAL to garbage.
1557 This behavior is undocumented and Bison
1558 users should not rely upon it. Assigning to YYVAL
1559 unconditionally makes the parser a bit smaller, and it avoids a
1560 GCC warning that YYVAL may be used uninitialized. */
1561 yyval
= yyvsp
[1-yylen
];
1564 YY_REDUCE_PRINT (yyn
);
1568 #line 128 "deffilep.y"
1569 { def_image_name ((yyvsp
[(2) - (3)].id
), (yyvsp
[(3) - (3)].number
), 0); }
1573 #line 129 "deffilep.y"
1574 { def_image_name ((yyvsp
[(2) - (3)].id
), (yyvsp
[(3) - (3)].number
), 1); }
1578 #line 130 "deffilep.y"
1579 { def_description ((yyvsp
[(2) - (2)].id
));}
1583 #line 131 "deffilep.y"
1584 { def_stacksize ((yyvsp
[(2) - (3)].number
), (yyvsp
[(3) - (3)].number
));}
1588 #line 132 "deffilep.y"
1589 { def_heapsize ((yyvsp
[(2) - (3)].number
), (yyvsp
[(3) - (3)].number
));}
1593 #line 133 "deffilep.y"
1594 { def_section ("CODE", (yyvsp
[(2) - (2)].number
));}
1598 #line 134 "deffilep.y"
1599 { def_section ("DATA", (yyvsp
[(2) - (2)].number
));}
1603 #line 138 "deffilep.y"
1604 { def_version ((yyvsp
[(2) - (2)].number
), 0);}
1608 #line 139 "deffilep.y"
1609 { def_version ((yyvsp
[(2) - (4)].number
), (yyvsp
[(4) - (4)].number
));}
1613 #line 140 "deffilep.y"
1614 { def_directive ((yyvsp
[(2) - (2)].id
));}
1618 #line 141 "deffilep.y"
1619 { def_aligncomm ((yyvsp
[(2) - (4)].id
), (yyvsp
[(4) - (4)].number
));}
1623 #line 156 "deffilep.y"
1624 { def_exports ((yyvsp
[(1) - (5)].id
), (yyvsp
[(2) - (5)].id
), (yyvsp
[(3) - (5)].number
), (yyvsp
[(5) - (5)].number
)); }
1628 #line 162 "deffilep.y"
1629 { (yyval
.number
) = (yyvsp
[(1) - (3)].number
) | (yyvsp
[(3) - (3)].number
); }
1633 #line 163 "deffilep.y"
1634 { (yyval
.number
) = 0; }
1638 #line 166 "deffilep.y"
1639 { (yyval
.number
) = 1; }
1643 #line 167 "deffilep.y"
1644 { (yyval
.number
) = 1; }
1648 #line 168 "deffilep.y"
1649 { (yyval
.number
) = 2; }
1653 #line 169 "deffilep.y"
1654 { (yyval
.number
) = 2; }
1658 #line 170 "deffilep.y"
1659 { (yyval
.number
) = 4; }
1663 #line 171 "deffilep.y"
1664 { (yyval
.number
) = 4; }
1668 #line 172 "deffilep.y"
1669 { (yyval
.number
) = 8; }
1673 #line 173 "deffilep.y"
1674 { (yyval
.number
) = 8; }
1678 #line 181 "deffilep.y"
1679 { def_import ((yyvsp
[(1) - (7)].id
), (yyvsp
[(3) - (7)].id
), (yyvsp
[(5) - (7)].id
), (yyvsp
[(7) - (7)].id
), -1); }
1683 #line 182 "deffilep.y"
1684 { def_import ((yyvsp
[(1) - (7)].id
), (yyvsp
[(3) - (7)].id
), (yyvsp
[(5) - (7)].id
), 0, (yyvsp
[(7) - (7)].number
)); }
1688 #line 183 "deffilep.y"
1689 { def_import ((yyvsp
[(1) - (5)].id
), (yyvsp
[(3) - (5)].id
), 0, (yyvsp
[(5) - (5)].id
), -1); }
1693 #line 184 "deffilep.y"
1694 { def_import ((yyvsp
[(1) - (5)].id
), (yyvsp
[(3) - (5)].id
), 0, 0, (yyvsp
[(5) - (5)].number
)); }
1698 #line 185 "deffilep.y"
1699 { def_import ( 0, (yyvsp
[(1) - (5)].id
), (yyvsp
[(3) - (5)].id
), (yyvsp
[(5) - (5)].id
), -1); }
1703 #line 186 "deffilep.y"
1704 { def_import ( 0, (yyvsp
[(1) - (3)].id
), 0, (yyvsp
[(3) - (3)].id
), -1); }
1708 #line 195 "deffilep.y"
1709 { def_section ((yyvsp
[(1) - (2)].id
), (yyvsp
[(2) - (2)].number
));}
1713 #line 196 "deffilep.y"
1714 { def_section_alt ((yyvsp
[(1) - (2)].id
), (yyvsp
[(2) - (2)].id
));}
1718 #line 200 "deffilep.y"
1719 { (yyval
.number
) = (yyvsp
[(1) - (3)].number
) | (yyvsp
[(3) - (3)].number
); }
1723 #line 201 "deffilep.y"
1724 { (yyval
.number
) = (yyvsp
[(1) - (1)].number
); }
1728 #line 208 "deffilep.y"
1729 { (yyval
.number
)=(yyvsp
[(2) - (2)].number
);}
1733 #line 209 "deffilep.y"
1734 { (yyval
.number
)=-1;}
1738 #line 213 "deffilep.y"
1739 { (yyval
.number
) = 1;}
1743 #line 214 "deffilep.y"
1744 { (yyval
.number
) = 2;}
1748 #line 215 "deffilep.y"
1749 { (yyval
.number
)=4;}
1753 #line 216 "deffilep.y"
1754 { (yyval
.number
)=8;}
1758 #line 219 "deffilep.y"
1759 { (yyval
.id
) = (yyvsp
[(1) - (1)].id
); }
1763 #line 221 "deffilep.y"
1765 char *name
= xmalloc (strlen ((yyvsp
[(1) - (3)].id
)) + 1 + strlen ((yyvsp
[(3) - (3)].id
)) + 1);
1766 sprintf (name
, "%s.%s", (yyvsp
[(1) - (3)].id
), (yyvsp
[(3) - (3)].id
));
1772 #line 226 "deffilep.y"
1773 { (yyval
.id
) = ""; }
1777 #line 230 "deffilep.y"
1778 { (yyval
.number
) = (yyvsp
[(2) - (2)].number
);}
1782 #line 231 "deffilep.y"
1783 { (yyval
.number
) = -1;}
1787 #line 235 "deffilep.y"
1788 { (yyval
.id
) = (yyvsp
[(2) - (2)].id
); }
1792 #line 236 "deffilep.y"
1797 #line 239 "deffilep.y"
1798 { (yyval
.number
) = (yyvsp
[(3) - (3)].number
);}
1802 #line 240 "deffilep.y"
1803 { (yyval
.number
) = -1;}
1807 #line 243 "deffilep.y"
1808 { (yyval
.id
) = (yyvsp
[(1) - (1)].id
); }
1812 #line 245 "deffilep.y"
1814 char *name
= xmalloc (strlen ((yyvsp
[(1) - (3)].id
)) + 1 + strlen ((yyvsp
[(3) - (3)].id
)) + 1);
1815 sprintf (name
, "%s.%s", (yyvsp
[(1) - (3)].id
), (yyvsp
[(3) - (3)].id
));
1821 #line 252 "deffilep.y"
1822 { (yyval
.id
) = (yyvsp
[(1) - (1)].id
); }
1826 #line 254 "deffilep.y"
1828 char *id
= xmalloc (strlen ((yyvsp
[(1) - (4)].id
)) + 1 + strlen ((yyvsp
[(3) - (4)].digits
)) + strlen ((yyvsp
[(4) - (4)].id
)) + 1);
1829 sprintf (id
, "%s.%s%s", (yyvsp
[(1) - (4)].id
), (yyvsp
[(3) - (4)].digits
), (yyvsp
[(4) - (4)].id
));
1835 #line 261 "deffilep.y"
1836 { (yyval
.digits
) = (yyvsp
[(1) - (1)].digits
); }
1840 #line 262 "deffilep.y"
1841 { (yyval
.digits
) = ""; }
1845 #line 265 "deffilep.y"
1846 { (yyval
.id
) = (yyvsp
[(1) - (1)].id
); }
1850 #line 266 "deffilep.y"
1851 { (yyval
.id
) = ""; }
1855 #line 269 "deffilep.y"
1856 { (yyval
.number
) = strtoul ((yyvsp
[(1) - (1)].digits
), 0, 0); }
1860 /* Line 1267 of yacc.c. */
1861 #line 1862 "deffilep.c"
1864 YY_SYMBOL_PRINT ("-> $$ =", yyr1
[yyn
], &yyval
, &yyloc
);
1868 YY_STACK_PRINT (yyss
, yyssp
);
1873 /* Now `shift' the result of the reduction. Determine what state
1874 that goes to, based on the state we popped back to and the rule
1875 number reduced by. */
1879 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
1880 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1881 yystate
= yytable
[yystate
];
1883 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
1888 /*------------------------------------.
1889 | yyerrlab -- here on detecting error |
1890 `------------------------------------*/
1892 /* If not already recovering from an error, report this error. */
1896 #if ! YYERROR_VERBOSE
1897 yyerror (YY_("syntax error"));
1900 YYSIZE_T yysize
= yysyntax_error (0, yystate
, yychar
);
1901 if (yymsg_alloc
< yysize
&& yymsg_alloc
< YYSTACK_ALLOC_MAXIMUM
)
1903 YYSIZE_T yyalloc
= 2 * yysize
;
1904 if (! (yysize
<= yyalloc
&& yyalloc
<= YYSTACK_ALLOC_MAXIMUM
))
1905 yyalloc
= YYSTACK_ALLOC_MAXIMUM
;
1906 if (yymsg
!= yymsgbuf
)
1907 YYSTACK_FREE (yymsg
);
1908 yymsg
= (char *) YYSTACK_ALLOC (yyalloc
);
1910 yymsg_alloc
= yyalloc
;
1914 yymsg_alloc
= sizeof yymsgbuf
;
1918 if (0 < yysize
&& yysize
<= yymsg_alloc
)
1920 (void) yysyntax_error (yymsg
, yystate
, yychar
);
1925 yyerror (YY_("syntax error"));
1927 goto yyexhaustedlab
;
1935 if (yyerrstatus
== 3)
1937 /* If just tried and failed to reuse look-ahead token after an
1938 error, discard it. */
1940 if (yychar
<= YYEOF
)
1942 /* Return failure if at end of input. */
1943 if (yychar
== YYEOF
)
1948 yydestruct ("Error: discarding",
1954 /* Else will try to reuse look-ahead token after shifting the error
1959 /*---------------------------------------------------.
1960 | yyerrorlab -- error raised explicitly by YYERROR. |
1961 `---------------------------------------------------*/
1964 /* Pacify compilers like GCC when the user code never invokes
1965 YYERROR and the label yyerrorlab therefore never appears in user
1967 if (/*CONSTCOND*/ 0)
1970 /* Do not reclaim the symbols of the rule which action triggered
1974 YY_STACK_PRINT (yyss
, yyssp
);
1979 /*-------------------------------------------------------------.
1980 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1981 `-------------------------------------------------------------*/
1983 yyerrstatus
= 3; /* Each real token shifted decrements this. */
1987 yyn
= yypact
[yystate
];
1988 if (yyn
!= YYPACT_NINF
)
1991 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
1999 /* Pop the current state because it cannot handle the error token. */
2004 yydestruct ("Error: popping",
2005 yystos
[yystate
], yyvsp
);
2008 YY_STACK_PRINT (yyss
, yyssp
);
2017 /* Shift the error token. */
2018 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
2024 /*-------------------------------------.
2025 | yyacceptlab -- YYACCEPT comes here. |
2026 `-------------------------------------*/
2031 /*-----------------------------------.
2032 | yyabortlab -- YYABORT comes here. |
2033 `-----------------------------------*/
2039 /*-------------------------------------------------.
2040 | yyexhaustedlab -- memory exhaustion comes here. |
2041 `-------------------------------------------------*/
2043 yyerror (YY_("memory exhausted"));
2049 if (yychar
!= YYEOF
&& yychar
!= YYEMPTY
)
2050 yydestruct ("Cleanup: discarding lookahead",
2052 /* Do not reclaim the symbols of the rule which action triggered
2053 this YYABORT or YYACCEPT. */
2055 YY_STACK_PRINT (yyss
, yyssp
);
2056 while (yyssp
!= yyss
)
2058 yydestruct ("Cleanup: popping",
2059 yystos
[*yyssp
], yyvsp
);
2064 YYSTACK_FREE (yyss
);
2067 if (yymsg
!= yymsgbuf
)
2068 YYSTACK_FREE (yymsg
);
2070 /* Make sure YYID is used. */
2071 return YYID (yyresult
);
2075 #line 271 "deffilep.y"
2078 /*****************************************************************************
2080 *****************************************************************************/
2082 static FILE *the_file
;
2083 static const char *def_filename
;
2084 static int linenumber
;
2085 static def_file
*def
;
2086 static int saw_newline
;
2090 struct directive
*next
;
2095 static struct directive
*directives
= 0;
2098 def_file_empty (void)
2100 def_file
*rv
= xmalloc (sizeof (def_file
));
2101 memset (rv
, 0, sizeof (def_file
));
2103 rv
->base_address
= (bfd_vma
) -1;
2104 rv
->stack_reserve
= rv
->stack_commit
= -1;
2105 rv
->heap_reserve
= rv
->heap_commit
= -1;
2106 rv
->version_major
= rv
->version_minor
= -1;
2111 def_file_parse (const char *filename
, def_file
*add_to
)
2113 struct directive
*d
;
2115 the_file
= fopen (filename
, "r");
2116 def_filename
= filename
;
2129 def
= def_file_empty ();
2135 def_file_free (def
);
2142 for (d
= directives
; d
; d
= d
->next
)
2145 printf ("Adding directive %08x `%s'\n", d
->name
, d
->name
);
2147 def_file_add_directive (def
, d
->name
, d
->len
);
2154 def_file_free (def_file
*def
)
2162 if (def
->description
)
2163 free (def
->description
);
2165 if (def
->section_defs
)
2167 for (i
= 0; i
< def
->num_section_defs
; i
++)
2169 if (def
->section_defs
[i
].name
)
2170 free (def
->section_defs
[i
].name
);
2171 if (def
->section_defs
[i
].class)
2172 free (def
->section_defs
[i
].class);
2174 free (def
->section_defs
);
2179 for (i
= 0; i
< def
->num_exports
; i
++)
2181 if (def
->exports
[i
].internal_name
2182 && def
->exports
[i
].internal_name
!= def
->exports
[i
].name
)
2183 free (def
->exports
[i
].internal_name
);
2184 if (def
->exports
[i
].name
)
2185 free (def
->exports
[i
].name
);
2187 free (def
->exports
);
2192 for (i
= 0; i
< def
->num_imports
; i
++)
2194 if (def
->imports
[i
].internal_name
2195 && def
->imports
[i
].internal_name
!= def
->imports
[i
].name
)
2196 free (def
->imports
[i
].internal_name
);
2197 if (def
->imports
[i
].name
)
2198 free (def
->imports
[i
].name
);
2200 free (def
->imports
);
2203 while (def
->modules
)
2205 def_file_module
*m
= def
->modules
;
2206 def
->modules
= def
->modules
->next
;
2210 while (def
->aligncomms
)
2212 def_file_aligncomm
*c
= def
->aligncomms
;
2213 def
->aligncomms
= def
->aligncomms
->next
;
2214 free (c
->symbol_name
);
2221 #ifdef DEF_FILE_PRINT
2223 def_file_print (FILE *file
, def_file
*def
)
2227 fprintf (file
, ">>>> def_file at 0x%08x\n", def
);
2229 fprintf (file
, " name: %s\n", def
->name
? def
->name
: "(unspecified)");
2230 if (def
->is_dll
!= -1)
2231 fprintf (file
, " is dll: %s\n", def
->is_dll
? "yes" : "no");
2232 if (def
->base_address
!= (bfd_vma
) -1)
2233 fprintf (file
, " base address: 0x%08x\n", def
->base_address
);
2234 if (def
->description
)
2235 fprintf (file
, " description: `%s'\n", def
->description
);
2236 if (def
->stack_reserve
!= -1)
2237 fprintf (file
, " stack reserve: 0x%08x\n", def
->stack_reserve
);
2238 if (def
->stack_commit
!= -1)
2239 fprintf (file
, " stack commit: 0x%08x\n", def
->stack_commit
);
2240 if (def
->heap_reserve
!= -1)
2241 fprintf (file
, " heap reserve: 0x%08x\n", def
->heap_reserve
);
2242 if (def
->heap_commit
!= -1)
2243 fprintf (file
, " heap commit: 0x%08x\n", def
->heap_commit
);
2245 if (def
->num_section_defs
> 0)
2247 fprintf (file
, " section defs:\n");
2249 for (i
= 0; i
< def
->num_section_defs
; i
++)
2251 fprintf (file
, " name: `%s', class: `%s', flags:",
2252 def
->section_defs
[i
].name
, def
->section_defs
[i
].class);
2253 if (def
->section_defs
[i
].flag_read
)
2254 fprintf (file
, " R");
2255 if (def
->section_defs
[i
].flag_write
)
2256 fprintf (file
, " W");
2257 if (def
->section_defs
[i
].flag_execute
)
2258 fprintf (file
, " X");
2259 if (def
->section_defs
[i
].flag_shared
)
2260 fprintf (file
, " S");
2261 fprintf (file
, "\n");
2265 if (def
->num_exports
> 0)
2267 fprintf (file
, " exports:\n");
2269 for (i
= 0; i
< def
->num_exports
; i
++)
2271 fprintf (file
, " name: `%s', int: `%s', ordinal: %d, flags:",
2272 def
->exports
[i
].name
, def
->exports
[i
].internal_name
,
2273 def
->exports
[i
].ordinal
);
2274 if (def
->exports
[i
].flag_private
)
2275 fprintf (file
, " P");
2276 if (def
->exports
[i
].flag_constant
)
2277 fprintf (file
, " C");
2278 if (def
->exports
[i
].flag_noname
)
2279 fprintf (file
, " N");
2280 if (def
->exports
[i
].flag_data
)
2281 fprintf (file
, " D");
2282 fprintf (file
, "\n");
2286 if (def
->num_imports
> 0)
2288 fprintf (file
, " imports:\n");
2290 for (i
= 0; i
< def
->num_imports
; i
++)
2292 fprintf (file
, " int: %s, from: `%s', name: `%s', ordinal: %d\n",
2293 def
->imports
[i
].internal_name
,
2294 def
->imports
[i
].module
,
2295 def
->imports
[i
].name
,
2296 def
->imports
[i
].ordinal
);
2300 if (def
->version_major
!= -1)
2301 fprintf (file
, " version: %d.%d\n", def
->version_major
, def
->version_minor
);
2303 fprintf (file
, "<<<< def_file at 0x%08x\n", def
);
2308 def_file_add_export (def_file
*def
,
2309 const char *external_name
,
2310 const char *internal_name
,
2314 int max_exports
= ROUND_UP(def
->num_exports
, 32);
2316 if (def
->num_exports
>= max_exports
)
2318 max_exports
= ROUND_UP(def
->num_exports
+ 1, 32);
2320 def
->exports
= xrealloc (def
->exports
,
2321 max_exports
* sizeof (def_file_export
));
2323 def
->exports
= xmalloc (max_exports
* sizeof (def_file_export
));
2325 e
= def
->exports
+ def
->num_exports
;
2326 memset (e
, 0, sizeof (def_file_export
));
2327 if (internal_name
&& !external_name
)
2328 external_name
= internal_name
;
2329 if (external_name
&& !internal_name
)
2330 internal_name
= external_name
;
2331 e
->name
= xstrdup (external_name
);
2332 e
->internal_name
= xstrdup (internal_name
);
2333 e
->ordinal
= ordinal
;
2339 def_get_module (def_file
*def
, const char *name
)
2343 for (s
= def
->modules
; s
; s
= s
->next
)
2344 if (strcmp (s
->name
, name
) == 0)
2350 static def_file_module
*
2351 def_stash_module (def_file
*def
, const char *name
)
2355 if ((s
= def_get_module (def
, name
)) != NULL
)
2357 s
= xmalloc (sizeof (def_file_module
) + strlen (name
));
2358 s
->next
= def
->modules
;
2361 strcpy (s
->name
, name
);
2366 def_file_add_import (def_file
*def
,
2370 const char *internal_name
)
2373 int max_imports
= ROUND_UP (def
->num_imports
, 16);
2375 if (def
->num_imports
>= max_imports
)
2377 max_imports
= ROUND_UP (def
->num_imports
+1, 16);
2380 def
->imports
= xrealloc (def
->imports
,
2381 max_imports
* sizeof (def_file_import
));
2383 def
->imports
= xmalloc (max_imports
* sizeof (def_file_import
));
2385 i
= def
->imports
+ def
->num_imports
;
2386 memset (i
, 0, sizeof (def_file_import
));
2388 i
->name
= xstrdup (name
);
2390 i
->module
= def_stash_module (def
, module
);
2391 i
->ordinal
= ordinal
;
2393 i
->internal_name
= xstrdup (internal_name
);
2395 i
->internal_name
= i
->name
;
2408 { "-heap", HEAPSIZE
},
2409 { "-stack", STACKSIZE_K
},
2410 { "-attr", SECTIONS
},
2411 { "-export", EXPORTS
},
2412 { "-aligncomm", ALIGNCOMM
},
2417 def_file_add_directive (def_file
*my_def
, const char *param
, int len
)
2419 def_file
*save_def
= def
;
2420 const char *pend
= param
+ len
;
2421 char * tend
= (char *) param
;
2426 while (param
< pend
)
2429 && (ISSPACE (*param
) || *param
== '\n' || *param
== 0))
2435 /* Scan forward until we encounter any of:
2436 - the end of the buffer
2437 - the start of a new option
2438 - a newline seperating options
2439 - a NUL seperating options. */
2440 for (tend
= (char *) (param
+ 1);
2442 && !(ISSPACE (tend
[-1]) && *tend
== '-')
2443 && *tend
!= '\n' && *tend
!= 0);
2447 for (i
= 0; diropts
[i
].param
; i
++)
2449 int len
= strlen (diropts
[i
].param
);
2451 if (tend
- param
>= len
2452 && strncmp (param
, diropts
[i
].param
, len
) == 0
2453 && (param
[len
] == ':' || param
[len
] == ' '))
2455 lex_parse_string_end
= tend
;
2456 lex_parse_string
= param
+ len
+ 1;
2457 lex_forced_token
= diropts
[i
].token
;
2465 if (!diropts
[i
].param
)
2471 /* xgettext:c-format */
2472 einfo (_("Warning: .drectve `%s' unrecognized\n"), param
);
2476 lex_parse_string
= 0;
2483 /* Parser Callbacks. */
2486 def_image_name (const char *name
, int base
, int is_dll
)
2488 /* If a LIBRARY or NAME statement is specified without a name, there is nothing
2489 to do here. We retain the output filename specified on command line. */
2492 const char* image_name
= lbasename (name
);
2493 if (image_name
!= name
)
2494 einfo ("%s:%d: Warning: path components stripped from %s, '%s'\n",
2495 def_filename
, linenumber
, is_dll
? "LIBRARY" : "NAME",
2499 /* Append the default suffix, if none specified. */
2500 if (strchr (image_name
, '.') == 0)
2502 const char * suffix
= is_dll
? ".dll" : ".exe";
2504 def
->name
= xmalloc (strlen (image_name
) + strlen (suffix
) + 1);
2505 sprintf (def
->name
, "%s%s", image_name
, suffix
);
2508 def
->name
= xstrdup (image_name
);
2511 /* Honor a BASE address statement, even if LIBRARY string is empty. */
2512 def
->base_address
= base
;
2513 def
->is_dll
= is_dll
;
2517 def_description (const char *text
)
2519 int len
= def
->description
? strlen (def
->description
) : 0;
2521 len
+= strlen (text
) + 1;
2522 if (def
->description
)
2524 def
->description
= xrealloc (def
->description
, len
);
2525 strcat (def
->description
, text
);
2529 def
->description
= xmalloc (len
);
2530 strcpy (def
->description
, text
);
2535 def_stacksize (int reserve
, int commit
)
2537 def
->stack_reserve
= reserve
;
2538 def
->stack_commit
= commit
;
2542 def_heapsize (int reserve
, int commit
)
2544 def
->heap_reserve
= reserve
;
2545 def
->heap_commit
= commit
;
2549 def_section (const char *name
, int attr
)
2551 def_file_section
*s
;
2552 int max_sections
= ROUND_UP (def
->num_section_defs
, 4);
2554 if (def
->num_section_defs
>= max_sections
)
2556 max_sections
= ROUND_UP (def
->num_section_defs
+1, 4);
2558 if (def
->section_defs
)
2559 def
->section_defs
= xrealloc (def
->section_defs
,
2560 max_sections
* sizeof (def_file_import
));
2562 def
->section_defs
= xmalloc (max_sections
* sizeof (def_file_import
));
2564 s
= def
->section_defs
+ def
->num_section_defs
;
2565 memset (s
, 0, sizeof (def_file_section
));
2566 s
->name
= xstrdup (name
);
2572 s
->flag_execute
= 1;
2576 def
->num_section_defs
++;
2580 def_section_alt (const char *name
, const char *attr
)
2584 for (; *attr
; attr
++)
2606 def_section (name
, aval
);
2610 def_exports (const char *external_name
,
2611 const char *internal_name
,
2615 def_file_export
*dfe
;
2617 if (!internal_name
&& external_name
)
2618 internal_name
= external_name
;
2620 printf ("def_exports, ext=%s int=%s\n", external_name
, internal_name
);
2623 dfe
= def_file_add_export (def
, external_name
, internal_name
, ordinal
);
2625 dfe
->flag_noname
= 1;
2627 dfe
->flag_constant
= 1;
2631 dfe
->flag_private
= 1;
2635 def_import (const char *internal_name
,
2642 const char *ext
= dllext
? dllext
: "dll";
2644 buf
= xmalloc (strlen (module
) + strlen (ext
) + 2);
2645 sprintf (buf
, "%s.%s", module
, ext
);
2648 def_file_add_import (def
, name
, module
, ordinal
, internal_name
);
2654 def_version (int major
, int minor
)
2656 def
->version_major
= major
;
2657 def
->version_minor
= minor
;
2661 def_directive (char *str
)
2663 struct directive
*d
= xmalloc (sizeof (struct directive
));
2665 d
->next
= directives
;
2667 d
->name
= xstrdup (str
);
2668 d
->len
= strlen (str
);
2672 def_aligncomm (char *str
, int align
)
2674 def_file_aligncomm
*c
= xmalloc (sizeof (def_file_aligncomm
));
2676 c
->symbol_name
= xstrdup (str
);
2677 c
->alignment
= (unsigned int) align
;
2679 c
->next
= def
->aligncomms
;
2680 def
->aligncomms
= c
;
2684 def_error (const char *err
)
2686 einfo ("%P: %s:%d: %s\n",
2687 def_filename
? def_filename
: "<unknown-file>", linenumber
, err
);
2692 /* Lexical Scanner. */
2697 /* Never freed, but always reused as needed, so no real leak. */
2698 static char *buffer
= 0;
2699 static int buflen
= 0;
2700 static int bufptr
= 0;
2705 if (bufptr
== buflen
)
2707 buflen
+= 50; /* overly reasonable, eh? */
2709 buffer
= xrealloc (buffer
, buflen
+ 1);
2711 buffer
= xmalloc (buflen
+ 1);
2713 buffer
[bufptr
++] = c
;
2714 buffer
[bufptr
] = 0; /* not optimal, but very convenient. */
2726 { "CONSTANT", CONSTANTU
},
2727 { "constant", CONSTANTL
},
2730 { "DESCRIPTION", DESCRIPTION
},
2731 { "DIRECTIVE", DIRECTIVE
},
2732 { "EXECUTE", EXECUTE
},
2733 { "EXPORTS", EXPORTS
},
2734 { "HEAPSIZE", HEAPSIZE
},
2735 { "IMPORTS", IMPORTS
},
2736 { "LIBRARY", LIBRARY
},
2738 { "NONAME", NONAMEU
},
2739 { "noname", NONAMEL
},
2740 { "PRIVATE", PRIVATEU
},
2741 { "private", PRIVATEL
},
2743 { "SECTIONS", SECTIONS
},
2744 { "SEGMENTS", SECTIONS
},
2745 { "SHARED", SHARED
},
2746 { "STACKSIZE", STACKSIZE_K
},
2747 { "VERSION", VERSIONK
},
2757 if (lex_parse_string
)
2759 if (lex_parse_string
>= lex_parse_string_end
)
2762 rv
= *lex_parse_string
++;
2766 rv
= fgetc (the_file
);
2776 if (lex_parse_string
)
2782 return ungetc (c
, the_file
);
2790 if (lex_forced_token
)
2792 i
= lex_forced_token
;
2793 lex_forced_token
= 0;
2795 printf ("lex: forcing token %d\n", i
);
2802 /* Trim leading whitespace. */
2803 while (c
!= EOF
&& (c
== ' ' || c
== '\t') && saw_newline
)
2809 printf ("lex: EOF\n");
2814 if (saw_newline
&& c
== ';')
2820 while (c
!= EOF
&& c
!= '\n');
2826 /* Must be something else. */
2832 while (c
!= EOF
&& (ISXDIGIT (c
) || (c
== 'x')))
2839 yylval
.digits
= xstrdup (buffer
);
2841 printf ("lex: `%s' returns DIGITS\n", buffer
);
2846 if (ISALPHA (c
) || strchr ("$:-_?@", c
))
2855 if (ISBLANK (c
) ) /* '@' followed by whitespace. */
2857 else if (ISDIGIT (c
)) /* '@' followed by digit. */
2863 printf ("lex: @ returns itself\n");
2867 while (c
!= EOF
&& (ISALNUM (c
) || strchr ("$:-_?/@", c
)))
2874 if (ISALPHA (q
)) /* Check for tokens. */
2876 for (i
= 0; tokens
[i
].name
; i
++)
2877 if (strcmp (tokens
[i
].name
, buffer
) == 0)
2880 printf ("lex: `%s' is a string token\n", buffer
);
2882 return tokens
[i
].token
;
2886 printf ("lex: `%s' returns ID\n", buffer
);
2888 yylval
.id
= xstrdup (buffer
);
2892 if (c
== '\'' || c
== '"')
2898 while (c
!= EOF
&& c
!= q
)
2903 yylval
.id
= xstrdup (buffer
);
2905 printf ("lex: `%s' returns ID\n", buffer
);
2910 if (c
== '=' || c
== '.' || c
== ',')
2913 printf ("lex: `%c' returns itself\n", c
);
2924 /*printf ("lex: 0x%02x ignored\n", c); */