Subversion Repositories Kolibri OS

Rev

Rev 5221 | Blame | Compare with Previous | Last modification | View Log | RSS feed

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