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 "nlmheader.y" /* yacc.c:339  */
66/* nlmheader.y - parse NLM header specification keywords.
67     Copyright (C) 1993-2017 Free Software Foundation, Inc.
68
69     This file is part of GNU Binutils.
70
71     This program is free software; you can redistribute it and/or modify
72     it under the terms of the GNU General Public License as published by
73     the Free Software Foundation; either version 3 of the License, or
74     (at your option) any later version.
75
76     This program is distributed in the hope that it will be useful,
77     but WITHOUT ANY WARRANTY; without even the implied warranty of
78     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
79     GNU General Public License for more details.
80
81     You should have received a copy of the GNU General Public License
82     along with this program; if not, write to the Free Software
83     Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
84     MA 02110-1301, USA.  */
85
86/* Written by Ian Lance Taylor <ian@cygnus.com>.
87
88   This bison file parses the commands recognized by the NetWare NLM
89   linker, except for lists of object files.  It stores the
90   information in global variables.
91
92   This implementation is based on the description in the NetWare Tool
93   Maker Specification manual, edition 1.0.  */
94
95#include "sysdep.h"
96#include "safe-ctype.h"
97#include "bfd.h"
98#include "nlm/common.h"
99#include "nlm/internal.h"
100#include "bucomm.h"
101#include "nlmconv.h"
102
103/* Information is stored in the structures pointed to by these
104   variables.  */
105
106Nlm_Internal_Fixed_Header *fixed_hdr;
107Nlm_Internal_Variable_Header *var_hdr;
108Nlm_Internal_Version_Header *version_hdr;
109Nlm_Internal_Copyright_Header *copyright_hdr;
110Nlm_Internal_Extended_Header *extended_hdr;
111
112/* Procedure named by CHECK.  */
113char *check_procedure;
114/* File named by CUSTOM.  */
115char *custom_file;
116/* Whether to generate debugging information (DEBUG).  */
117bfd_boolean debug_info;
118/* Procedure named by EXIT.  */
119char *exit_procedure;
120/* Exported symbols (EXPORT).  */
121struct string_list *export_symbols;
122/* List of files from INPUT.  */
123struct string_list *input_files;
124/* Map file name (MAP, FULLMAP).  */
125char *map_file;
126/* Whether a full map has been requested (FULLMAP).  */
127bfd_boolean full_map;
128/* File named by HELP.  */
129char *help_file;
130/* Imported symbols (IMPORT).  */
131struct string_list *import_symbols;
132/* File named by MESSAGES.  */
133char *message_file;
134/* Autoload module list (MODULE).  */
135struct string_list *modules;
136/* File named by OUTPUT.  */
137char *output_file;
138/* File named by SHARELIB.  */
139char *sharelib_file;
140/* Start procedure name (START).  */
141char *start_procedure;
142/* VERBOSE.  */
143bfd_boolean verbose;
144/* RPC description file (XDCDATA).  */
145char *rpc_file;
146
147/* The number of serious errors that have occurred.  */
148int parse_errors;
149
150/* The current symbol prefix when reading a list of import or export
151   symbols.  */
152static char *symbol_prefix;
153
154/* Parser error message handler.  */
155#define yyerror(msg) nlmheader_error (msg);
156
157/* Local functions.  */
158static int yylex (void);
159static void nlmlex_file_push (const char *);
160static bfd_boolean nlmlex_file_open (const char *);
161static int nlmlex_buf_init (void);
162static char nlmlex_buf_add (int);
163static long nlmlex_get_number (const char *);
164static void nlmheader_identify (void);
165static void nlmheader_warn (const char *, int);
166static void nlmheader_error (const char *);
167static struct string_list * string_list_cons (char *, struct string_list *);
168static struct string_list * string_list_append (struct string_list *,
169						struct string_list *);
170static struct string_list * string_list_append1 (struct string_list *,
171						 char *);
172static char *xstrdup (const char *);
173
174
175#line 176 "nlmheader.c" /* yacc.c:339  */
176
177# ifndef YY_NULL
178#  if defined __cplusplus && 201103L <= __cplusplus
179#   define YY_NULL nullptr
180#  else
181#   define YY_NULL 0
182#  endif
183# endif
184
185/* Enabling verbose error messages.  */
186#ifdef YYERROR_VERBOSE
187# undef YYERROR_VERBOSE
188# define YYERROR_VERBOSE 1
189#else
190# define YYERROR_VERBOSE 0
191#endif
192
193/* In a future release of Bison, this section will be replaced
194   by #include "y.tab.h".  */
195#ifndef YY_YY_NLMHEADER_H_INCLUDED
196# define YY_YY_NLMHEADER_H_INCLUDED
197/* Debug traces.  */
198#ifndef YYDEBUG
199# define YYDEBUG 0
200#endif
201#if YYDEBUG
202extern int yydebug;
203#endif
204
205/* Token type.  */
206#ifndef YYTOKENTYPE
207# define YYTOKENTYPE
208  enum yytokentype
209  {
210    CHECK = 258,
211    CODESTART = 259,
212    COPYRIGHT = 260,
213    CUSTOM = 261,
214    DATE = 262,
215    DEBUG_K = 263,
216    DESCRIPTION = 264,
217    EXIT = 265,
218    EXPORT = 266,
219    FLAG_ON = 267,
220    FLAG_OFF = 268,
221    FULLMAP = 269,
222    HELP = 270,
223    IMPORT = 271,
224    INPUT = 272,
225    MAP = 273,
226    MESSAGES = 274,
227    MODULE = 275,
228    MULTIPLE = 276,
229    OS_DOMAIN = 277,
230    OUTPUT = 278,
231    PSEUDOPREEMPTION = 279,
232    REENTRANT = 280,
233    SCREENNAME = 281,
234    SHARELIB = 282,
235    STACK = 283,
236    START = 284,
237    SYNCHRONIZE = 285,
238    THREADNAME = 286,
239    TYPE = 287,
240    VERBOSE = 288,
241    VERSIONK = 289,
242    XDCDATA = 290,
243    STRING = 291,
244    QUOTED_STRING = 292
245  };
246#endif
247/* Tokens.  */
248#define CHECK 258
249#define CODESTART 259
250#define COPYRIGHT 260
251#define CUSTOM 261
252#define DATE 262
253#define DEBUG_K 263
254#define DESCRIPTION 264
255#define EXIT 265
256#define EXPORT 266
257#define FLAG_ON 267
258#define FLAG_OFF 268
259#define FULLMAP 269
260#define HELP 270
261#define IMPORT 271
262#define INPUT 272
263#define MAP 273
264#define MESSAGES 274
265#define MODULE 275
266#define MULTIPLE 276
267#define OS_DOMAIN 277
268#define OUTPUT 278
269#define PSEUDOPREEMPTION 279
270#define REENTRANT 280
271#define SCREENNAME 281
272#define SHARELIB 282
273#define STACK 283
274#define START 284
275#define SYNCHRONIZE 285
276#define THREADNAME 286
277#define TYPE 287
278#define VERBOSE 288
279#define VERSIONK 289
280#define XDCDATA 290
281#define STRING 291
282#define QUOTED_STRING 292
283
284/* Value type.  */
285#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
286typedef union YYSTYPE YYSTYPE;
287union YYSTYPE
288{
289#line 112 "nlmheader.y" /* yacc.c:355  */
290
291  char *string;
292  struct string_list *list;
293
294#line 295 "nlmheader.c" /* yacc.c:355  */
295};
296# define YYSTYPE_IS_TRIVIAL 1
297# define YYSTYPE_IS_DECLARED 1
298#endif
299
300
301extern YYSTYPE yylval;
302
303int yyparse (void);
304
305#endif /* !YY_YY_NLMHEADER_H_INCLUDED  */
306
307/* Copy the second part of user declarations.  */
308
309#line 310 "nlmheader.c" /* yacc.c:358  */
310
311#ifdef short
312# undef short
313#endif
314
315#ifdef YYTYPE_UINT8
316typedef YYTYPE_UINT8 yytype_uint8;
317#else
318typedef unsigned char yytype_uint8;
319#endif
320
321#ifdef YYTYPE_INT8
322typedef YYTYPE_INT8 yytype_int8;
323#else
324typedef signed char yytype_int8;
325#endif
326
327#ifdef YYTYPE_UINT16
328typedef YYTYPE_UINT16 yytype_uint16;
329#else
330typedef unsigned short int yytype_uint16;
331#endif
332
333#ifdef YYTYPE_INT16
334typedef YYTYPE_INT16 yytype_int16;
335#else
336typedef short int yytype_int16;
337#endif
338
339#ifndef YYSIZE_T
340# ifdef __SIZE_TYPE__
341#  define YYSIZE_T __SIZE_TYPE__
342# elif defined size_t
343#  define YYSIZE_T size_t
344# elif ! defined YYSIZE_T
345#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
346#  define YYSIZE_T size_t
347# else
348#  define YYSIZE_T unsigned int
349# endif
350#endif
351
352#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
353
354#ifndef YY_
355# if defined YYENABLE_NLS && YYENABLE_NLS
356#  if ENABLE_NLS
357#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
358#   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
359#  endif
360# endif
361# ifndef YY_
362#  define YY_(Msgid) Msgid
363# endif
364#endif
365
366#ifndef __attribute__
367/* This feature is available in gcc versions 2.5 and later.  */
368# if (! defined __GNUC__ || __GNUC__ < 2 \
369      || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
370#  define __attribute__(Spec) /* empty */
371# endif
372#endif
373
374/* Suppress unused-variable warnings by "using" E.  */
375#if ! defined lint || defined __GNUC__
376# define YYUSE(E) ((void) (E))
377#else
378# define YYUSE(E) /* empty */
379#endif
380
381#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
382/* Suppress an incorrect diagnostic about yylval being uninitialized.  */
383# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
384    _Pragma ("GCC diagnostic push") \
385    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
386    _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
387# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
388    _Pragma ("GCC diagnostic pop")
389#else
390# define YY_INITIAL_VALUE(Value) Value
391#endif
392#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
393# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
394# define YY_IGNORE_MAYBE_UNINITIALIZED_END
395#endif
396#ifndef YY_INITIAL_VALUE
397# define YY_INITIAL_VALUE(Value) /* Nothing. */
398#endif
399
400
401#if ! defined yyoverflow || YYERROR_VERBOSE
402
403/* The parser invokes alloca or malloc; define the necessary symbols.  */
404
405# ifdef YYSTACK_USE_ALLOCA
406#  if YYSTACK_USE_ALLOCA
407#   ifdef __GNUC__
408#    define YYSTACK_ALLOC __builtin_alloca
409#   elif defined __BUILTIN_VA_ARG_INCR
410#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
411#   elif defined _AIX
412#    define YYSTACK_ALLOC __alloca
413#   elif defined _MSC_VER
414#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
415#    define alloca _alloca
416#   else
417#    define YYSTACK_ALLOC alloca
418#    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
419#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
420      /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
421#     ifndef EXIT_SUCCESS
422#      define EXIT_SUCCESS 0
423#     endif
424#    endif
425#   endif
426#  endif
427# endif
428
429# ifdef YYSTACK_ALLOC
430   /* Pacify GCC's 'empty if-body' warning.  */
431#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
432#  ifndef YYSTACK_ALLOC_MAXIMUM
433    /* The OS might guarantee only one guard page at the bottom of the stack,
434       and a page size can be as small as 4096 bytes.  So we cannot safely
435       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
436       to allow for a few compiler-allocated temporary stack slots.  */
437#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
438#  endif
439# else
440#  define YYSTACK_ALLOC YYMALLOC
441#  define YYSTACK_FREE YYFREE
442#  ifndef YYSTACK_ALLOC_MAXIMUM
443#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
444#  endif
445#  if (defined __cplusplus && ! defined EXIT_SUCCESS \
446       && ! ((defined YYMALLOC || defined malloc) \
447             && (defined YYFREE || defined free)))
448#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
449#   ifndef EXIT_SUCCESS
450#    define EXIT_SUCCESS 0
451#   endif
452#  endif
453#  ifndef YYMALLOC
454#   define YYMALLOC malloc
455#   if ! defined malloc && ! defined EXIT_SUCCESS
456void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
457#   endif
458#  endif
459#  ifndef YYFREE
460#   define YYFREE free
461#   if ! defined free && ! defined EXIT_SUCCESS
462void free (void *); /* INFRINGES ON USER NAME SPACE */
463#   endif
464#  endif
465# endif
466#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
467
468
469#if (! defined yyoverflow \
470     && (! defined __cplusplus \
471         || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
472
473/* A type that is properly aligned for any stack member.  */
474union yyalloc
475{
476  yytype_int16 yyss_alloc;
477  YYSTYPE yyvs_alloc;
478};
479
480/* The size of the maximum gap between one aligned stack and the next.  */
481# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
482
483/* The size of an array large to enough to hold all stacks, each with
484   N elements.  */
485# define YYSTACK_BYTES(N) \
486     ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
487      + YYSTACK_GAP_MAXIMUM)
488
489# define YYCOPY_NEEDED 1
490
491/* Relocate STACK from its old location to the new one.  The
492   local variables YYSIZE and YYSTACKSIZE give the old and new number of
493   elements in the stack, and YYPTR gives the new location of the
494   stack.  Advance YYPTR to a properly aligned location for the next
495   stack.  */
496# define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
497    do                                                                  \
498      {                                                                 \
499        YYSIZE_T yynewbytes;                                            \
500        YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
501        Stack = &yyptr->Stack_alloc;                                    \
502        yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
503        yyptr += yynewbytes / sizeof (*yyptr);                          \
504      }                                                                 \
505    while (0)
506
507#endif
508
509#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
510/* Copy COUNT objects from SRC to DST.  The source and destination do
511   not overlap.  */
512# ifndef YYCOPY
513#  if defined __GNUC__ && 1 < __GNUC__
514#   define YYCOPY(Dst, Src, Count) \
515      __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
516#  else
517#   define YYCOPY(Dst, Src, Count)              \
518      do                                        \
519        {                                       \
520          YYSIZE_T yyi;                         \
521          for (yyi = 0; yyi < (Count); yyi++)   \
522            (Dst)[yyi] = (Src)[yyi];            \
523        }                                       \
524      while (0)
525#  endif
526# endif
527#endif /* !YYCOPY_NEEDED */
528
529/* YYFINAL -- State number of the termination state.  */
530#define YYFINAL  64
531/* YYLAST -- Last index in YYTABLE.  */
532#define YYLAST   73
533
534/* YYNTOKENS -- Number of terminals.  */
535#define YYNTOKENS  40
536/* YYNNTS -- Number of nonterminals.  */
537#define YYNNTS  11
538/* YYNRULES -- Number of rules.  */
539#define YYNRULES  52
540/* YYNSTATES -- Number of states.  */
541#define YYNSTATES  82
542
543/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
544   by yylex, with out-of-bounds checking.  */
545#define YYUNDEFTOK  2
546#define YYMAXUTOK   292
547
548#define YYTRANSLATE(YYX)                                                \
549  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
550
551/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
552   as returned by yylex, without out-of-bounds checking.  */
553static const yytype_uint8 yytranslate[] =
554{
555       0,     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      38,    39,     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,     2,     2,     2,     2,
572       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
573       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
574       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
575       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
576       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
577       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
578       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
579       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
580       2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
581       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
582      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
583      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
584      35,    36,    37
585};
586
587#if YYDEBUG
588  /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
589static const yytype_uint16 yyrline[] =
590{
591       0,   143,   143,   148,   150,   156,   160,   165,   182,   186,
592     204,   208,   224,   229,   228,   236,   241,   246,   251,   256,
593     261,   260,   268,   272,   276,   280,   284,   288,   292,   296,
594     303,   307,   311,   327,   331,   336,   340,   344,   360,   365,
595     369,   393,   409,   419,   422,   433,   437,   441,   445,   454,
596     465,   482,   485
597};
598#endif
599
600#if YYDEBUG || YYERROR_VERBOSE || 0
601/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
602   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
603static const char *const yytname[] =
604{
605  "$end", "error", "$undefined", "CHECK", "CODESTART", "COPYRIGHT",
606  "CUSTOM", "DATE", "DEBUG_K", "DESCRIPTION", "EXIT", "EXPORT", "FLAG_ON",
607  "FLAG_OFF", "FULLMAP", "HELP", "IMPORT", "INPUT", "MAP", "MESSAGES",
608  "MODULE", "MULTIPLE", "OS_DOMAIN", "OUTPUT", "PSEUDOPREEMPTION",
609  "REENTRANT", "SCREENNAME", "SHARELIB", "STACK", "START", "SYNCHRONIZE",
610  "THREADNAME", "TYPE", "VERBOSE", "VERSIONK", "XDCDATA", "STRING",
611  "QUOTED_STRING", "'('", "')'", "$accept", "file", "commands", "command",
612  "$@1", "$@2", "symbol_list_opt", "symbol_list", "symbol_prefix",
613  "symbol", "string_list", YY_NULL
614};
615#endif
616
617# ifdef YYPRINT
618/* YYTOKNUM[NUM] -- (External) token number corresponding to the
619   (internal) symbol number NUM (which must be that of a token).  */
620static const yytype_uint16 yytoknum[] =
621{
622       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
623     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
624     275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
625     285,   286,   287,   288,   289,   290,   291,   292,    40,    41
626};
627# endif
628
629#define YYPACT_NINF -20
630
631#define yypact_value_is_default(Yystate) \
632  (!!((Yystate) == (-20)))
633
634#define YYTABLE_NINF -1
635
636#define yytable_value_is_error(Yytable_value) \
637  0
638
639  /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
640     STATE-NUM.  */
641static const yytype_int8 yypact[] =
642{
643      -3,    -1,     1,     2,     4,     5,   -20,     6,     8,   -20,
644       9,    10,    11,    12,   -20,    13,    14,    16,    13,   -20,
645     -20,    17,   -20,   -20,    18,    20,    21,    22,   -20,    23,
646      25,   -20,    26,    27,    38,   -20,    -3,   -20,   -20,   -20,
647     -20,    28,   -20,   -20,    -2,   -20,   -20,   -20,   -20,    -2,
648      13,   -20,   -20,   -20,   -20,   -20,   -20,   -20,   -20,   -20,
649     -20,   -20,    30,   -20,   -20,   -20,    31,   -20,    32,   -20,
650      -2,   -20,   -20,   -20,   -20,    33,   -20,     3,   -20,   -20,
651     -20,   -20
652};
653
654  /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
655     Performed when YYTABLE does not specify something else to do.  Zero
656     means the default is an error.  */
657static const yytype_uint8 yydefact[] =
658{
659       3,     0,     0,     0,     0,     0,    10,     0,     0,    13,
660       0,     0,    17,     0,    20,    51,    23,     0,    51,    27,
661      28,     0,    30,    31,     0,     0,     0,     0,    36,     0,
662       0,    39,     0,     0,     0,     2,     3,     5,     6,     7,
663       8,     0,    11,    12,    43,    15,    16,    18,    19,    43,
664      51,    22,    24,    25,    26,    29,    32,    33,    34,    35,
665      37,    38,     0,    42,     1,     4,     0,    50,     0,    14,
666      44,    46,    45,    21,    52,    41,     9,     0,    48,    47,
667      40,    49
668};
669
670  /* YYPGOTO[NTERM-NUM].  */
671static const yytype_int8 yypgoto[] =
672{
673     -20,   -20,    34,   -20,   -20,   -20,    24,   -20,   -19,   -16,
674      15
675};
676
677  /* YYDEFGOTO[NTERM-NUM].  */
678static const yytype_int8 yydefgoto[] =
679{
680      -1,    34,    35,    36,    44,    49,    69,    70,    71,    72,
681      51
682};
683
684  /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
685     positive, shift that token.  If negative, reduce the rule whose
686     number is the opposite.  If YYTABLE_NINF, syntax error.  */
687static const yytype_uint8 yytable[] =
688{
689       1,     2,     3,     4,     5,     6,     7,     8,     9,    10,
690      11,    12,    13,    14,    15,    16,    17,    18,    19,    20,
691      21,    22,    23,    24,    25,    26,    27,    28,    29,    30,
692      31,    32,    33,    54,    67,    37,    68,    38,    64,    39,
693      40,    41,    81,    42,    43,    45,    46,    47,    48,    50,
694      52,    78,    53,    55,    79,    56,    57,    58,    59,     0,
695      60,    61,    62,    63,    66,    74,    75,    76,    77,    80,
696      65,     0,     0,    73
697};
698
699static const yytype_int8 yycheck[] =
700{
701       3,     4,     5,     6,     7,     8,     9,    10,    11,    12,
702      13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
703      23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
704      33,    34,    35,    18,    36,    36,    38,    36,     0,    37,
705      36,    36,    39,    37,    36,    36,    36,    36,    36,    36,
706      36,    70,    36,    36,    70,    37,    36,    36,    36,    -1,
707      37,    36,    36,    36,    36,    50,    36,    36,    36,    36,
708      36,    -1,    -1,    49
709};
710
711  /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
712     symbol of state STATE-NUM.  */
713static const yytype_uint8 yystos[] =
714{
715       0,     3,     4,     5,     6,     7,     8,     9,    10,    11,
716      12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
717      22,    23,    24,    25,    26,    27,    28,    29,    30,    31,
718      32,    33,    34,    35,    41,    42,    43,    36,    36,    37,
719      36,    36,    37,    36,    44,    36,    36,    36,    36,    45,
720      36,    50,    36,    36,    50,    36,    37,    36,    36,    36,
721      37,    36,    36,    36,     0,    42,    36,    36,    38,    46,
722      47,    48,    49,    46,    50,    36,    36,    36,    48,    49,
723      36,    39
724};
725
726  /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
727static const yytype_uint8 yyr1[] =
728{
729       0,    40,    41,    42,    42,    43,    43,    43,    43,    43,
730      43,    43,    43,    44,    43,    43,    43,    43,    43,    43,
731      45,    43,    43,    43,    43,    43,    43,    43,    43,    43,
732      43,    43,    43,    43,    43,    43,    43,    43,    43,    43,
733      43,    43,    43,    46,    46,    47,    47,    47,    47,    48,
734      49,    50,    50
735};
736
737  /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
738static const yytype_uint8 yyr2[] =
739{
740       0,     2,     1,     0,     2,     2,     2,     2,     2,     4,
741       1,     2,     2,     0,     3,     2,     2,     1,     2,     2,
742       0,     3,     2,     1,     2,     2,     2,     1,     1,     2,
743       1,     1,     2,     2,     2,     2,     1,     2,     2,     1,
744       4,     3,     2,     0,     1,     1,     1,     2,     2,     3,
745       1,     0,     2
746};
747
748
749#define yyerrok         (yyerrstatus = 0)
750#define yyclearin       (yychar = YYEMPTY)
751#define YYEMPTY         (-2)
752#define YYEOF           0
753
754#define YYACCEPT        goto yyacceptlab
755#define YYABORT         goto yyabortlab
756#define YYERROR         goto yyerrorlab
757
758
759#define YYRECOVERING()  (!!yyerrstatus)
760
761#define YYBACKUP(Token, Value)                                  \
762do                                                              \
763  if (yychar == YYEMPTY)                                        \
764    {                                                           \
765      yychar = (Token);                                         \
766      yylval = (Value);                                         \
767      YYPOPSTACK (yylen);                                       \
768      yystate = *yyssp;                                         \
769      goto yybackup;                                            \
770    }                                                           \
771  else                                                          \
772    {                                                           \
773      yyerror (YY_("syntax error: cannot back up")); \
774      YYERROR;                                                  \
775    }                                                           \
776while (0)
777
778/* Error token number */
779#define YYTERROR        1
780#define YYERRCODE       256
781
782
783
784/* Enable debugging if requested.  */
785#if YYDEBUG
786
787# ifndef YYFPRINTF
788#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
789#  define YYFPRINTF fprintf
790# endif
791
792# define YYDPRINTF(Args)                        \
793do {                                            \
794  if (yydebug)                                  \
795    YYFPRINTF Args;                             \
796} while (0)
797
798/* This macro is provided for backward compatibility. */
799#ifndef YY_LOCATION_PRINT
800# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
801#endif
802
803
804# define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
805do {                                                                      \
806  if (yydebug)                                                            \
807    {                                                                     \
808      YYFPRINTF (stderr, "%s ", Title);                                   \
809      yy_symbol_print (stderr,                                            \
810                  Type, Value); \
811      YYFPRINTF (stderr, "\n");                                           \
812    }                                                                     \
813} while (0)
814
815
816/*----------------------------------------.
817| Print this symbol's value on YYOUTPUT.  |
818`----------------------------------------*/
819
820static void
821yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
822{
823  FILE *yyo = yyoutput;
824  YYUSE (yyo);
825  if (!yyvaluep)
826    return;
827# ifdef YYPRINT
828  if (yytype < YYNTOKENS)
829    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
830# endif
831  YYUSE (yytype);
832}
833
834
835/*--------------------------------.
836| Print this symbol on YYOUTPUT.  |
837`--------------------------------*/
838
839static void
840yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
841{
842  YYFPRINTF (yyoutput, "%s %s (",
843             yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
844
845  yy_symbol_value_print (yyoutput, yytype, yyvaluep);
846  YYFPRINTF (yyoutput, ")");
847}
848
849/*------------------------------------------------------------------.
850| yy_stack_print -- Print the state stack from its BOTTOM up to its |
851| TOP (included).                                                   |
852`------------------------------------------------------------------*/
853
854static void
855yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
856{
857  YYFPRINTF (stderr, "Stack now");
858  for (; yybottom <= yytop; yybottom++)
859    {
860      int yybot = *yybottom;
861      YYFPRINTF (stderr, " %d", yybot);
862    }
863  YYFPRINTF (stderr, "\n");
864}
865
866# define YY_STACK_PRINT(Bottom, Top)                            \
867do {                                                            \
868  if (yydebug)                                                  \
869    yy_stack_print ((Bottom), (Top));                           \
870} while (0)
871
872
873/*------------------------------------------------.
874| Report that the YYRULE is going to be reduced.  |
875`------------------------------------------------*/
876
877static void
878yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
879{
880  unsigned long int yylno = yyrline[yyrule];
881  int yynrhs = yyr2[yyrule];
882  int yyi;
883  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
884             yyrule - 1, yylno);
885  /* The symbols being reduced.  */
886  for (yyi = 0; yyi < yynrhs; yyi++)
887    {
888      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
889      yy_symbol_print (stderr,
890                       yystos[yyssp[yyi + 1 - yynrhs]],
891                       &(yyvsp[(yyi + 1) - (yynrhs)])
892                                              );
893      YYFPRINTF (stderr, "\n");
894    }
895}
896
897# define YY_REDUCE_PRINT(Rule)          \
898do {                                    \
899  if (yydebug)                          \
900    yy_reduce_print (yyssp, yyvsp, Rule); \
901} while (0)
902
903/* Nonzero means print parse trace.  It is left uninitialized so that
904   multiple parsers can coexist.  */
905int yydebug;
906#else /* !YYDEBUG */
907# define YYDPRINTF(Args)
908# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
909# define YY_STACK_PRINT(Bottom, Top)
910# define YY_REDUCE_PRINT(Rule)
911#endif /* !YYDEBUG */
912
913
914/* YYINITDEPTH -- initial size of the parser's stacks.  */
915#ifndef YYINITDEPTH
916# define YYINITDEPTH 200
917#endif
918
919/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
920   if the built-in stack extension method is used).
921
922   Do not make this value too large; the results are undefined if
923   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
924   evaluated with infinite-precision integer arithmetic.  */
925
926#ifndef YYMAXDEPTH
927# define YYMAXDEPTH 10000
928#endif
929
930
931#if YYERROR_VERBOSE
932
933# ifndef yystrlen
934#  if defined __GLIBC__ && defined _STRING_H
935#   define yystrlen strlen
936#  else
937/* Return the length of YYSTR.  */
938static YYSIZE_T
939yystrlen (const char *yystr)
940{
941  YYSIZE_T yylen;
942  for (yylen = 0; yystr[yylen]; yylen++)
943    continue;
944  return yylen;
945}
946#  endif
947# endif
948
949# ifndef yystpcpy
950#  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
951#   define yystpcpy stpcpy
952#  else
953/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
954   YYDEST.  */
955static char *
956yystpcpy (char *yydest, const char *yysrc)
957{
958  char *yyd = yydest;
959  const char *yys = yysrc;
960
961  while ((*yyd++ = *yys++) != '\0')
962    continue;
963
964  return yyd - 1;
965}
966#  endif
967# endif
968
969# ifndef yytnamerr
970/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
971   quotes and backslashes, so that it's suitable for yyerror.  The
972   heuristic is that double-quoting is unnecessary unless the string
973   contains an apostrophe, a comma, or backslash (other than
974   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
975   null, do not copy; instead, return the length of what the result
976   would have been.  */
977static YYSIZE_T
978yytnamerr (char *yyres, const char *yystr)
979{
980  if (*yystr == '"')
981    {
982      YYSIZE_T yyn = 0;
983      char const *yyp = yystr;
984
985      for (;;)
986        switch (*++yyp)
987          {
988          case '\'':
989          case ',':
990            goto do_not_strip_quotes;
991
992          case '\\':
993            if (*++yyp != '\\')
994              goto do_not_strip_quotes;
995            /* Fall through.  */
996          default:
997            if (yyres)
998              yyres[yyn] = *yyp;
999            yyn++;
1000            break;
1001
1002          case '"':
1003            if (yyres)
1004              yyres[yyn] = '\0';
1005            return yyn;
1006          }
1007    do_not_strip_quotes: ;
1008    }
1009
1010  if (! yyres)
1011    return yystrlen (yystr);
1012
1013  return yystpcpy (yyres, yystr) - yyres;
1014}
1015# endif
1016
1017/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1018   about the unexpected token YYTOKEN for the state stack whose top is
1019   YYSSP.
1020
1021   Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
1022   not large enough to hold the message.  In that case, also set
1023   *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
1024   required number of bytes is too large to store.  */
1025static int
1026yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1027                yytype_int16 *yyssp, int yytoken)
1028{
1029  YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
1030  YYSIZE_T yysize = yysize0;
1031  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1032  /* Internationalized format string. */
1033  const char *yyformat = YY_NULL;
1034  /* Arguments of yyformat. */
1035  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1036  /* Number of reported tokens (one for the "unexpected", one per
1037     "expected"). */
1038  int yycount = 0;
1039
1040  /* There are many possibilities here to consider:
1041     - If this state is a consistent state with a default action, then
1042       the only way this function was invoked is if the default action
1043       is an error action.  In that case, don't check for expected
1044       tokens because there are none.
1045     - The only way there can be no lookahead present (in yychar) is if
1046       this state is a consistent state with a default action.  Thus,
1047       detecting the absence of a lookahead is sufficient to determine
1048       that there is no unexpected or expected token to report.  In that
1049       case, just report a simple "syntax error".
1050     - Don't assume there isn't a lookahead just because this state is a
1051       consistent state with a default action.  There might have been a
1052       previous inconsistent state, consistent state with a non-default
1053       action, or user semantic action that manipulated yychar.
1054     - Of course, the expected token list depends on states to have
1055       correct lookahead information, and it depends on the parser not
1056       to perform extra reductions after fetching a lookahead from the
1057       scanner and before detecting a syntax error.  Thus, state merging
1058       (from LALR or IELR) and default reductions corrupt the expected
1059       token list.  However, the list is correct for canonical LR with
1060       one exception: it will still contain any token that will not be
1061       accepted due to an error action in a later state.
1062  */
1063  if (yytoken != YYEMPTY)
1064    {
1065      int yyn = yypact[*yyssp];
1066      yyarg[yycount++] = yytname[yytoken];
1067      if (!yypact_value_is_default (yyn))
1068        {
1069          /* Start YYX at -YYN if negative to avoid negative indexes in
1070             YYCHECK.  In other words, skip the first -YYN actions for
1071             this state because they are default actions.  */
1072          int yyxbegin = yyn < 0 ? -yyn : 0;
1073          /* Stay within bounds of both yycheck and yytname.  */
1074          int yychecklim = YYLAST - yyn + 1;
1075          int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1076          int yyx;
1077
1078          for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1079            if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1080                && !yytable_value_is_error (yytable[yyx + yyn]))
1081              {
1082                if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1083                  {
1084                    yycount = 1;
1085                    yysize = yysize0;
1086                    break;
1087                  }
1088                yyarg[yycount++] = yytname[yyx];
1089                {
1090                  YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
1091                  if (! (yysize <= yysize1
1092                         && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1093                    return 2;
1094                  yysize = yysize1;
1095                }
1096              }
1097        }
1098    }
1099
1100  switch (yycount)
1101    {
1102# define YYCASE_(N, S)                      \
1103      case N:                               \
1104        yyformat = S;                       \
1105      break
1106      YYCASE_(0, YY_("syntax error"));
1107      YYCASE_(1, YY_("syntax error, unexpected %s"));
1108      YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1109      YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1110      YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1111      YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1112# undef YYCASE_
1113    }
1114
1115  {
1116    YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1117    if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1118      return 2;
1119    yysize = yysize1;
1120  }
1121
1122  if (*yymsg_alloc < yysize)
1123    {
1124      *yymsg_alloc = 2 * yysize;
1125      if (! (yysize <= *yymsg_alloc
1126             && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1127        *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1128      return 1;
1129    }
1130
1131  /* Avoid sprintf, as that infringes on the user's name space.
1132     Don't have undefined behavior even if the translation
1133     produced a string with the wrong number of "%s"s.  */
1134  {
1135    char *yyp = *yymsg;
1136    int yyi = 0;
1137    while ((*yyp = *yyformat) != '\0')
1138      if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1139        {
1140          yyp += yytnamerr (yyp, yyarg[yyi++]);
1141          yyformat += 2;
1142        }
1143      else
1144        {
1145          yyp++;
1146          yyformat++;
1147        }
1148  }
1149  return 0;
1150}
1151#endif /* YYERROR_VERBOSE */
1152
1153/*-----------------------------------------------.
1154| Release the memory associated to this symbol.  |
1155`-----------------------------------------------*/
1156
1157static void
1158yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1159{
1160  YYUSE (yyvaluep);
1161  if (!yymsg)
1162    yymsg = "Deleting";
1163  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1164
1165  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1166  YYUSE (yytype);
1167  YY_IGNORE_MAYBE_UNINITIALIZED_END
1168}
1169
1170
1171
1172
1173/* The lookahead symbol.  */
1174int yychar;
1175
1176/* The semantic value of the lookahead symbol.  */
1177YYSTYPE yylval;
1178/* Number of syntax errors so far.  */
1179int yynerrs;
1180
1181
1182/*----------.
1183| yyparse.  |
1184`----------*/
1185
1186int
1187yyparse (void)
1188{
1189    int yystate;
1190    /* Number of tokens to shift before error messages enabled.  */
1191    int yyerrstatus;
1192
1193    /* The stacks and their tools:
1194       'yyss': related to states.
1195       'yyvs': related to semantic values.
1196
1197       Refer to the stacks through separate pointers, to allow yyoverflow
1198       to reallocate them elsewhere.  */
1199
1200    /* The state stack.  */
1201    yytype_int16 yyssa[YYINITDEPTH];
1202    yytype_int16 *yyss;
1203    yytype_int16 *yyssp;
1204
1205    /* The semantic value stack.  */
1206    YYSTYPE yyvsa[YYINITDEPTH];
1207    YYSTYPE *yyvs;
1208    YYSTYPE *yyvsp;
1209
1210    YYSIZE_T yystacksize;
1211
1212  int yyn;
1213  int yyresult;
1214  /* Lookahead token as an internal (translated) token number.  */
1215  int yytoken = 0;
1216  /* The variables used to return semantic value and location from the
1217     action routines.  */
1218  YYSTYPE yyval;
1219
1220#if YYERROR_VERBOSE
1221  /* Buffer for error messages, and its allocated size.  */
1222  char yymsgbuf[128];
1223  char *yymsg = yymsgbuf;
1224  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1225#endif
1226
1227#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1228
1229  /* The number of symbols on the RHS of the reduced rule.
1230     Keep to zero when no symbol should be popped.  */
1231  int yylen = 0;
1232
1233  yyssp = yyss = yyssa;
1234  yyvsp = yyvs = yyvsa;
1235  yystacksize = YYINITDEPTH;
1236
1237  YYDPRINTF ((stderr, "Starting parse\n"));
1238
1239  yystate = 0;
1240  yyerrstatus = 0;
1241  yynerrs = 0;
1242  yychar = YYEMPTY; /* Cause a token to be read.  */
1243  goto yysetstate;
1244
1245/*------------------------------------------------------------.
1246| yynewstate -- Push a new state, which is found in yystate.  |
1247`------------------------------------------------------------*/
1248 yynewstate:
1249  /* In all cases, when you get here, the value and location stacks
1250     have just been pushed.  So pushing a state here evens the stacks.  */
1251  yyssp++;
1252
1253 yysetstate:
1254  *yyssp = yystate;
1255
1256  if (yyss + yystacksize - 1 <= yyssp)
1257    {
1258      /* Get the current used size of the three stacks, in elements.  */
1259      YYSIZE_T yysize = yyssp - yyss + 1;
1260
1261#ifdef yyoverflow
1262      {
1263        /* Give user a chance to reallocate the stack.  Use copies of
1264           these so that the &'s don't force the real ones into
1265           memory.  */
1266        YYSTYPE *yyvs1 = yyvs;
1267        yytype_int16 *yyss1 = yyss;
1268
1269        /* Each stack pointer address is followed by the size of the
1270           data in use in that stack, in bytes.  This used to be a
1271           conditional around just the two extra args, but that might
1272           be undefined if yyoverflow is a macro.  */
1273        yyoverflow (YY_("memory exhausted"),
1274                    &yyss1, yysize * sizeof (*yyssp),
1275                    &yyvs1, yysize * sizeof (*yyvsp),
1276                    &yystacksize);
1277
1278        yyss = yyss1;
1279        yyvs = yyvs1;
1280      }
1281#else /* no yyoverflow */
1282# ifndef YYSTACK_RELOCATE
1283      goto yyexhaustedlab;
1284# else
1285      /* Extend the stack our own way.  */
1286      if (YYMAXDEPTH <= yystacksize)
1287        goto yyexhaustedlab;
1288      yystacksize *= 2;
1289      if (YYMAXDEPTH < yystacksize)
1290        yystacksize = YYMAXDEPTH;
1291
1292      {
1293        yytype_int16 *yyss1 = yyss;
1294        union yyalloc *yyptr =
1295          (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1296        if (! yyptr)
1297          goto yyexhaustedlab;
1298        YYSTACK_RELOCATE (yyss_alloc, yyss);
1299        YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1300#  undef YYSTACK_RELOCATE
1301        if (yyss1 != yyssa)
1302          YYSTACK_FREE (yyss1);
1303      }
1304# endif
1305#endif /* no yyoverflow */
1306
1307      yyssp = yyss + yysize - 1;
1308      yyvsp = yyvs + yysize - 1;
1309
1310      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1311                  (unsigned long int) yystacksize));
1312
1313      if (yyss + yystacksize - 1 <= yyssp)
1314        YYABORT;
1315    }
1316
1317  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1318
1319  if (yystate == YYFINAL)
1320    YYACCEPT;
1321
1322  goto yybackup;
1323
1324/*-----------.
1325| yybackup.  |
1326`-----------*/
1327yybackup:
1328
1329  /* Do appropriate processing given the current state.  Read a
1330     lookahead token if we need one and don't already have one.  */
1331
1332  /* First try to decide what to do without reference to lookahead token.  */
1333  yyn = yypact[yystate];
1334  if (yypact_value_is_default (yyn))
1335    goto yydefault;
1336
1337  /* Not known => get a lookahead token if don't already have one.  */
1338
1339  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1340  if (yychar == YYEMPTY)
1341    {
1342      YYDPRINTF ((stderr, "Reading a token: "));
1343      yychar = yylex ();
1344    }
1345
1346  if (yychar <= YYEOF)
1347    {
1348      yychar = yytoken = YYEOF;
1349      YYDPRINTF ((stderr, "Now at end of input.\n"));
1350    }
1351  else
1352    {
1353      yytoken = YYTRANSLATE (yychar);
1354      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1355    }
1356
1357  /* If the proper action on seeing token YYTOKEN is to reduce or to
1358     detect an error, take that action.  */
1359  yyn += yytoken;
1360  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1361    goto yydefault;
1362  yyn = yytable[yyn];
1363  if (yyn <= 0)
1364    {
1365      if (yytable_value_is_error (yyn))
1366        goto yyerrlab;
1367      yyn = -yyn;
1368      goto yyreduce;
1369    }
1370
1371  /* Count tokens shifted since error; after three, turn off error
1372     status.  */
1373  if (yyerrstatus)
1374    yyerrstatus--;
1375
1376  /* Shift the lookahead token.  */
1377  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1378
1379  /* Discard the shifted token.  */
1380  yychar = YYEMPTY;
1381
1382  yystate = yyn;
1383  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1384  *++yyvsp = yylval;
1385  YY_IGNORE_MAYBE_UNINITIALIZED_END
1386
1387  goto yynewstate;
1388
1389
1390/*-----------------------------------------------------------.
1391| yydefault -- do the default action for the current state.  |
1392`-----------------------------------------------------------*/
1393yydefault:
1394  yyn = yydefact[yystate];
1395  if (yyn == 0)
1396    goto yyerrlab;
1397  goto yyreduce;
1398
1399
1400/*-----------------------------.
1401| yyreduce -- Do a reduction.  |
1402`-----------------------------*/
1403yyreduce:
1404  /* yyn is the number of a rule to reduce with.  */
1405  yylen = yyr2[yyn];
1406
1407  /* If YYLEN is nonzero, implement the default value of the action:
1408     '$$ = $1'.
1409
1410     Otherwise, the following line sets YYVAL to garbage.
1411     This behavior is undocumented and Bison
1412     users should not rely upon it.  Assigning to YYVAL
1413     unconditionally makes the parser a bit smaller, and it avoids a
1414     GCC warning that YYVAL may be used uninitialized.  */
1415  yyval = yyvsp[1-yylen];
1416
1417
1418  YY_REDUCE_PRINT (yyn);
1419  switch (yyn)
1420    {
1421        case 5:
1422#line 157 "nlmheader.y" /* yacc.c:1661  */
1423    {
1424	    check_procedure = (yyvsp[0].string);
1425	  }
1426#line 1427 "nlmheader.c" /* yacc.c:1661  */
1427    break;
1428
1429  case 6:
1430#line 161 "nlmheader.y" /* yacc.c:1661  */
1431    {
1432	    nlmheader_warn (_("CODESTART is not implemented; sorry"), -1);
1433	    free ((yyvsp[0].string));
1434	  }
1435#line 1436 "nlmheader.c" /* yacc.c:1661  */
1436    break;
1437
1438  case 7:
1439#line 166 "nlmheader.y" /* yacc.c:1661  */
1440    {
1441	    int len;
1442
1443	    strncpy (copyright_hdr->stamp, "CoPyRiGhT=", 10);
1444	    len = strlen ((yyvsp[0].string));
1445	    if (len >= NLM_MAX_COPYRIGHT_MESSAGE_LENGTH)
1446	      {
1447		nlmheader_warn (_("copyright string is too long"),
1448				NLM_MAX_COPYRIGHT_MESSAGE_LENGTH - 1);
1449		len = NLM_MAX_COPYRIGHT_MESSAGE_LENGTH - 1;
1450	      }
1451	    copyright_hdr->copyrightMessageLength = len;
1452	    strncpy (copyright_hdr->copyrightMessage, (yyvsp[0].string), len);
1453	    copyright_hdr->copyrightMessage[len] = '\0';
1454	    free ((yyvsp[0].string));
1455	  }
1456#line 1457 "nlmheader.c" /* yacc.c:1661  */
1457    break;
1458
1459  case 8:
1460#line 183 "nlmheader.y" /* yacc.c:1661  */
1461    {
1462	    custom_file = (yyvsp[0].string);
1463	  }
1464#line 1465 "nlmheader.c" /* yacc.c:1661  */
1465    break;
1466
1467  case 9:
1468#line 187 "nlmheader.y" /* yacc.c:1661  */
1469    {
1470	    /* We don't set the version stamp here, because we use the
1471	       version stamp to detect whether the required VERSION
1472	       keyword was given.  */
1473	    version_hdr->month = nlmlex_get_number ((yyvsp[-2].string));
1474	    version_hdr->day = nlmlex_get_number ((yyvsp[-1].string));
1475	    version_hdr->year = nlmlex_get_number ((yyvsp[0].string));
1476	    free ((yyvsp[-2].string));
1477	    free ((yyvsp[-1].string));
1478	    free ((yyvsp[0].string));
1479	    if (version_hdr->month < 1 || version_hdr->month > 12)
1480	      nlmheader_warn (_("illegal month"), -1);
1481	    if (version_hdr->day < 1 || version_hdr->day > 31)
1482	      nlmheader_warn (_("illegal day"), -1);
1483	    if (version_hdr->year < 1900 || version_hdr->year > 3000)
1484	      nlmheader_warn (_("illegal year"), -1);
1485	  }
1486#line 1487 "nlmheader.c" /* yacc.c:1661  */
1487    break;
1488
1489  case 10:
1490#line 205 "nlmheader.y" /* yacc.c:1661  */
1491    {
1492	    debug_info = TRUE;
1493	  }
1494#line 1495 "nlmheader.c" /* yacc.c:1661  */
1495    break;
1496
1497  case 11:
1498#line 209 "nlmheader.y" /* yacc.c:1661  */
1499    {
1500	    int len;
1501
1502	    len = strlen ((yyvsp[0].string));
1503	    if (len > NLM_MAX_DESCRIPTION_LENGTH)
1504	      {
1505		nlmheader_warn (_("description string is too long"),
1506				NLM_MAX_DESCRIPTION_LENGTH);
1507		len = NLM_MAX_DESCRIPTION_LENGTH;
1508	      }
1509	    var_hdr->descriptionLength = len;
1510	    strncpy (var_hdr->descriptionText, (yyvsp[0].string), len);
1511	    var_hdr->descriptionText[len] = '\0';
1512	    free ((yyvsp[0].string));
1513	  }
1514#line 1515 "nlmheader.c" /* yacc.c:1661  */
1515    break;
1516
1517  case 12:
1518#line 225 "nlmheader.y" /* yacc.c:1661  */
1519    {
1520	    exit_procedure = (yyvsp[0].string);
1521	  }
1522#line 1523 "nlmheader.c" /* yacc.c:1661  */
1523    break;
1524
1525  case 13:
1526#line 229 "nlmheader.y" /* yacc.c:1661  */
1527    {
1528	    symbol_prefix = NULL;
1529	  }
1530#line 1531 "nlmheader.c" /* yacc.c:1661  */
1531    break;
1532
1533  case 14:
1534#line 233 "nlmheader.y" /* yacc.c:1661  */
1535    {
1536	    export_symbols = string_list_append (export_symbols, (yyvsp[0].list));
1537	  }
1538#line 1539 "nlmheader.c" /* yacc.c:1661  */
1539    break;
1540
1541  case 15:
1542#line 237 "nlmheader.y" /* yacc.c:1661  */
1543    {
1544	    fixed_hdr->flags |= nlmlex_get_number ((yyvsp[0].string));
1545	    free ((yyvsp[0].string));
1546	  }
1547#line 1548 "nlmheader.c" /* yacc.c:1661  */
1548    break;
1549
1550  case 16:
1551#line 242 "nlmheader.y" /* yacc.c:1661  */
1552    {
1553	    fixed_hdr->flags &=~ nlmlex_get_number ((yyvsp[0].string));
1554	    free ((yyvsp[0].string));
1555	  }
1556#line 1557 "nlmheader.c" /* yacc.c:1661  */
1557    break;
1558
1559  case 17:
1560#line 247 "nlmheader.y" /* yacc.c:1661  */
1561    {
1562	    map_file = "";
1563	    full_map = TRUE;
1564	  }
1565#line 1566 "nlmheader.c" /* yacc.c:1661  */
1566    break;
1567
1568  case 18:
1569#line 252 "nlmheader.y" /* yacc.c:1661  */
1570    {
1571	    map_file = (yyvsp[0].string);
1572	    full_map = TRUE;
1573	  }
1574#line 1575 "nlmheader.c" /* yacc.c:1661  */
1575    break;
1576
1577  case 19:
1578#line 257 "nlmheader.y" /* yacc.c:1661  */
1579    {
1580	    help_file = (yyvsp[0].string);
1581	  }
1582#line 1583 "nlmheader.c" /* yacc.c:1661  */
1583    break;
1584
1585  case 20:
1586#line 261 "nlmheader.y" /* yacc.c:1661  */
1587    {
1588	    symbol_prefix = NULL;
1589	  }
1590#line 1591 "nlmheader.c" /* yacc.c:1661  */
1591    break;
1592
1593  case 21:
1594#line 265 "nlmheader.y" /* yacc.c:1661  */
1595    {
1596	    import_symbols = string_list_append (import_symbols, (yyvsp[0].list));
1597	  }
1598#line 1599 "nlmheader.c" /* yacc.c:1661  */
1599    break;
1600
1601  case 22:
1602#line 269 "nlmheader.y" /* yacc.c:1661  */
1603    {
1604	    input_files = string_list_append (input_files, (yyvsp[0].list));
1605	  }
1606#line 1607 "nlmheader.c" /* yacc.c:1661  */
1607    break;
1608
1609  case 23:
1610#line 273 "nlmheader.y" /* yacc.c:1661  */
1611    {
1612	    map_file = "";
1613	  }
1614#line 1615 "nlmheader.c" /* yacc.c:1661  */
1615    break;
1616
1617  case 24:
1618#line 277 "nlmheader.y" /* yacc.c:1661  */
1619    {
1620	    map_file = (yyvsp[0].string);
1621	  }
1622#line 1623 "nlmheader.c" /* yacc.c:1661  */
1623    break;
1624
1625  case 25:
1626#line 281 "nlmheader.y" /* yacc.c:1661  */
1627    {
1628	    message_file = (yyvsp[0].string);
1629	  }
1630#line 1631 "nlmheader.c" /* yacc.c:1661  */
1631    break;
1632
1633  case 26:
1634#line 285 "nlmheader.y" /* yacc.c:1661  */
1635    {
1636	    modules = string_list_append (modules, (yyvsp[0].list));
1637	  }
1638#line 1639 "nlmheader.c" /* yacc.c:1661  */
1639    break;
1640
1641  case 27:
1642#line 289 "nlmheader.y" /* yacc.c:1661  */
1643    {
1644	    fixed_hdr->flags |= 0x2;
1645	  }
1646#line 1647 "nlmheader.c" /* yacc.c:1661  */
1647    break;
1648
1649  case 28:
1650#line 293 "nlmheader.y" /* yacc.c:1661  */
1651    {
1652	    fixed_hdr->flags |= 0x10;
1653	  }
1654#line 1655 "nlmheader.c" /* yacc.c:1661  */
1655    break;
1656
1657  case 29:
1658#line 297 "nlmheader.y" /* yacc.c:1661  */
1659    {
1660	    if (output_file == NULL)
1661	      output_file = (yyvsp[0].string);
1662	    else
1663	      nlmheader_warn (_("ignoring duplicate OUTPUT statement"), -1);
1664	  }
1665#line 1666 "nlmheader.c" /* yacc.c:1661  */
1666    break;
1667
1668  case 30:
1669#line 304 "nlmheader.y" /* yacc.c:1661  */
1670    {
1671	    fixed_hdr->flags |= 0x8;
1672	  }
1673#line 1674 "nlmheader.c" /* yacc.c:1661  */
1674    break;
1675
1676  case 31:
1677#line 308 "nlmheader.y" /* yacc.c:1661  */
1678    {
1679	    fixed_hdr->flags |= 0x1;
1680	  }
1681#line 1682 "nlmheader.c" /* yacc.c:1661  */
1682    break;
1683
1684  case 32:
1685#line 312 "nlmheader.y" /* yacc.c:1661  */
1686    {
1687	    int len;
1688
1689	    len = strlen ((yyvsp[0].string));
1690	    if (len >= NLM_MAX_SCREEN_NAME_LENGTH)
1691	      {
1692		nlmheader_warn (_("screen name is too long"),
1693				NLM_MAX_SCREEN_NAME_LENGTH);
1694		len = NLM_MAX_SCREEN_NAME_LENGTH;
1695	      }
1696	    var_hdr->screenNameLength = len;
1697	    strncpy (var_hdr->screenName, (yyvsp[0].string), len);
1698	    var_hdr->screenName[NLM_MAX_SCREEN_NAME_LENGTH] = '\0';
1699	    free ((yyvsp[0].string));
1700	  }
1701#line 1702 "nlmheader.c" /* yacc.c:1661  */
1702    break;
1703
1704  case 33:
1705#line 328 "nlmheader.y" /* yacc.c:1661  */
1706    {
1707	    sharelib_file = (yyvsp[0].string);
1708	  }
1709#line 1710 "nlmheader.c" /* yacc.c:1661  */
1710    break;
1711
1712  case 34:
1713#line 332 "nlmheader.y" /* yacc.c:1661  */
1714    {
1715	    var_hdr->stackSize = nlmlex_get_number ((yyvsp[0].string));
1716	    free ((yyvsp[0].string));
1717	  }
1718#line 1719 "nlmheader.c" /* yacc.c:1661  */
1719    break;
1720
1721  case 35:
1722#line 337 "nlmheader.y" /* yacc.c:1661  */
1723    {
1724	    start_procedure = (yyvsp[0].string);
1725	  }
1726#line 1727 "nlmheader.c" /* yacc.c:1661  */
1727    break;
1728
1729  case 36:
1730#line 341 "nlmheader.y" /* yacc.c:1661  */
1731    {
1732	    fixed_hdr->flags |= 0x4;
1733	  }
1734#line 1735 "nlmheader.c" /* yacc.c:1661  */
1735    break;
1736
1737  case 37:
1738#line 345 "nlmheader.y" /* yacc.c:1661  */
1739    {
1740	    int len;
1741
1742	    len = strlen ((yyvsp[0].string));
1743	    if (len >= NLM_MAX_THREAD_NAME_LENGTH)
1744	      {
1745		nlmheader_warn (_("thread name is too long"),
1746				NLM_MAX_THREAD_NAME_LENGTH);
1747		len = NLM_MAX_THREAD_NAME_LENGTH;
1748	      }
1749	    var_hdr->threadNameLength = len;
1750	    strncpy (var_hdr->threadName, (yyvsp[0].string), len);
1751	    var_hdr->threadName[len] = '\0';
1752	    free ((yyvsp[0].string));
1753	  }
1754#line 1755 "nlmheader.c" /* yacc.c:1661  */
1755    break;
1756
1757  case 38:
1758#line 361 "nlmheader.y" /* yacc.c:1661  */
1759    {
1760	    fixed_hdr->moduleType = nlmlex_get_number ((yyvsp[0].string));
1761	    free ((yyvsp[0].string));
1762	  }
1763#line 1764 "nlmheader.c" /* yacc.c:1661  */
1764    break;
1765
1766  case 39:
1767#line 366 "nlmheader.y" /* yacc.c:1661  */
1768    {
1769	    verbose = TRUE;
1770	  }
1771#line 1772 "nlmheader.c" /* yacc.c:1661  */
1772    break;
1773
1774  case 40:
1775#line 370 "nlmheader.y" /* yacc.c:1661  */
1776    {
1777	    long val;
1778
1779	    strncpy (version_hdr->stamp, "VeRsIoN#", 8);
1780	    version_hdr->majorVersion = nlmlex_get_number ((yyvsp[-2].string));
1781	    val = nlmlex_get_number ((yyvsp[-1].string));
1782	    if (val < 0 || val > 99)
1783	      nlmheader_warn (_("illegal minor version number (must be between 0 and 99)"),
1784			      -1);
1785	    else
1786	      version_hdr->minorVersion = val;
1787	    val = nlmlex_get_number ((yyvsp[0].string));
1788	    if (val < 0)
1789	      nlmheader_warn (_("illegal revision number (must be between 0 and 26)"),
1790			      -1);
1791	    else if (val > 26)
1792	      version_hdr->revision = 0;
1793	    else
1794	      version_hdr->revision = val;
1795	    free ((yyvsp[-2].string));
1796	    free ((yyvsp[-1].string));
1797	    free ((yyvsp[0].string));
1798	  }
1799#line 1800 "nlmheader.c" /* yacc.c:1661  */
1800    break;
1801
1802  case 41:
1803#line 394 "nlmheader.y" /* yacc.c:1661  */
1804    {
1805	    long val;
1806
1807	    strncpy (version_hdr->stamp, "VeRsIoN#", 8);
1808	    version_hdr->majorVersion = nlmlex_get_number ((yyvsp[-1].string));
1809	    val = nlmlex_get_number ((yyvsp[0].string));
1810	    if (val < 0 || val > 99)
1811	      nlmheader_warn (_("illegal minor version number (must be between 0 and 99)"),
1812			      -1);
1813	    else
1814	      version_hdr->minorVersion = val;
1815	    version_hdr->revision = 0;
1816	    free ((yyvsp[-1].string));
1817	    free ((yyvsp[0].string));
1818	  }
1819#line 1820 "nlmheader.c" /* yacc.c:1661  */
1820    break;
1821
1822  case 42:
1823#line 410 "nlmheader.y" /* yacc.c:1661  */
1824    {
1825	    rpc_file = (yyvsp[0].string);
1826	  }
1827#line 1828 "nlmheader.c" /* yacc.c:1661  */
1828    break;
1829
1830  case 43:
1831#line 419 "nlmheader.y" /* yacc.c:1661  */
1832    {
1833	    (yyval.list) = NULL;
1834	  }
1835#line 1836 "nlmheader.c" /* yacc.c:1661  */
1836    break;
1837
1838  case 44:
1839#line 423 "nlmheader.y" /* yacc.c:1661  */
1840    {
1841	    (yyval.list) = (yyvsp[0].list);
1842	  }
1843#line 1844 "nlmheader.c" /* yacc.c:1661  */
1844    break;
1845
1846  case 45:
1847#line 434 "nlmheader.y" /* yacc.c:1661  */
1848    {
1849	    (yyval.list) = string_list_cons ((yyvsp[0].string), NULL);
1850	  }
1851#line 1852 "nlmheader.c" /* yacc.c:1661  */
1852    break;
1853
1854  case 46:
1855#line 438 "nlmheader.y" /* yacc.c:1661  */
1856    {
1857	    (yyval.list) = NULL;
1858	  }
1859#line 1860 "nlmheader.c" /* yacc.c:1661  */
1860    break;
1861
1862  case 47:
1863#line 442 "nlmheader.y" /* yacc.c:1661  */
1864    {
1865	    (yyval.list) = string_list_append1 ((yyvsp[-1].list), (yyvsp[0].string));
1866	  }
1867#line 1868 "nlmheader.c" /* yacc.c:1661  */
1868    break;
1869
1870  case 48:
1871#line 446 "nlmheader.y" /* yacc.c:1661  */
1872    {
1873	    (yyval.list) = (yyvsp[-1].list);
1874	  }
1875#line 1876 "nlmheader.c" /* yacc.c:1661  */
1876    break;
1877
1878  case 49:
1879#line 455 "nlmheader.y" /* yacc.c:1661  */
1880    {
1881	    if (symbol_prefix != NULL)
1882	      free (symbol_prefix);
1883	    symbol_prefix = (yyvsp[-1].string);
1884	  }
1885#line 1886 "nlmheader.c" /* yacc.c:1661  */
1886    break;
1887
1888  case 50:
1889#line 466 "nlmheader.y" /* yacc.c:1661  */
1890    {
1891	    if (symbol_prefix == NULL)
1892	      (yyval.string) = (yyvsp[0].string);
1893	    else
1894	      {
1895		(yyval.string) = xmalloc (strlen (symbol_prefix) + strlen ((yyvsp[0].string)) + 2);
1896		sprintf ((yyval.string), "%s@%s", symbol_prefix, (yyvsp[0].string));
1897		free ((yyvsp[0].string));
1898	      }
1899	  }
1900#line 1901 "nlmheader.c" /* yacc.c:1661  */
1901    break;
1902
1903  case 51:
1904#line 482 "nlmheader.y" /* yacc.c:1661  */
1905    {
1906	    (yyval.list) = NULL;
1907	  }
1908#line 1909 "nlmheader.c" /* yacc.c:1661  */
1909    break;
1910
1911  case 52:
1912#line 486 "nlmheader.y" /* yacc.c:1661  */
1913    {
1914	    (yyval.list) = string_list_cons ((yyvsp[-1].string), (yyvsp[0].list));
1915	  }
1916#line 1917 "nlmheader.c" /* yacc.c:1661  */
1917    break;
1918
1919
1920#line 1921 "nlmheader.c" /* yacc.c:1661  */
1921      default: break;
1922    }
1923  /* User semantic actions sometimes alter yychar, and that requires
1924     that yytoken be updated with the new translation.  We take the
1925     approach of translating immediately before every use of yytoken.
1926     One alternative is translating here after every semantic action,
1927     but that translation would be missed if the semantic action invokes
1928     YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1929     if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
1930     incorrect destructor might then be invoked immediately.  In the
1931     case of YYERROR or YYBACKUP, subsequent parser actions might lead
1932     to an incorrect destructor call or verbose syntax error message
1933     before the lookahead is translated.  */
1934  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1935
1936  YYPOPSTACK (yylen);
1937  yylen = 0;
1938  YY_STACK_PRINT (yyss, yyssp);
1939
1940  *++yyvsp = yyval;
1941
1942  /* Now 'shift' the result of the reduction.  Determine what state
1943     that goes to, based on the state we popped back to and the rule
1944     number reduced by.  */
1945
1946  yyn = yyr1[yyn];
1947
1948  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1949  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1950    yystate = yytable[yystate];
1951  else
1952    yystate = yydefgoto[yyn - YYNTOKENS];
1953
1954  goto yynewstate;
1955
1956
1957/*--------------------------------------.
1958| yyerrlab -- here on detecting error.  |
1959`--------------------------------------*/
1960yyerrlab:
1961  /* Make sure we have latest lookahead translation.  See comments at
1962     user semantic actions for why this is necessary.  */
1963  yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1964
1965  /* If not already recovering from an error, report this error.  */
1966  if (!yyerrstatus)
1967    {
1968      ++yynerrs;
1969#if ! YYERROR_VERBOSE
1970      yyerror (YY_("syntax error"));
1971#else
1972# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1973                                        yyssp, yytoken)
1974      {
1975        char const *yymsgp = YY_("syntax error");
1976        int yysyntax_error_status;
1977        yysyntax_error_status = YYSYNTAX_ERROR;
1978        if (yysyntax_error_status == 0)
1979          yymsgp = yymsg;
1980        else if (yysyntax_error_status == 1)
1981          {
1982            if (yymsg != yymsgbuf)
1983              YYSTACK_FREE (yymsg);
1984            yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1985            if (!yymsg)
1986              {
1987                yymsg = yymsgbuf;
1988                yymsg_alloc = sizeof yymsgbuf;
1989                yysyntax_error_status = 2;
1990              }
1991            else
1992              {
1993                yysyntax_error_status = YYSYNTAX_ERROR;
1994                yymsgp = yymsg;
1995              }
1996          }
1997        yyerror (yymsgp);
1998        if (yysyntax_error_status == 2)
1999          goto yyexhaustedlab;
2000      }
2001# undef YYSYNTAX_ERROR
2002#endif
2003    }
2004
2005
2006
2007  if (yyerrstatus == 3)
2008    {
2009      /* If just tried and failed to reuse lookahead token after an
2010         error, discard it.  */
2011
2012      if (yychar <= YYEOF)
2013        {
2014          /* Return failure if at end of input.  */
2015          if (yychar == YYEOF)
2016            YYABORT;
2017        }
2018      else
2019        {
2020          yydestruct ("Error: discarding",
2021                      yytoken, &yylval);
2022          yychar = YYEMPTY;
2023        }
2024    }
2025
2026  /* Else will try to reuse lookahead token after shifting the error
2027     token.  */
2028  goto yyerrlab1;
2029
2030
2031/*---------------------------------------------------.
2032| yyerrorlab -- error raised explicitly by YYERROR.  |
2033`---------------------------------------------------*/
2034yyerrorlab:
2035
2036  /* Pacify compilers like GCC when the user code never invokes
2037     YYERROR and the label yyerrorlab therefore never appears in user
2038     code.  */
2039  if (/*CONSTCOND*/ 0)
2040     goto yyerrorlab;
2041
2042  /* Do not reclaim the symbols of the rule whose action triggered
2043     this YYERROR.  */
2044  YYPOPSTACK (yylen);
2045  yylen = 0;
2046  YY_STACK_PRINT (yyss, yyssp);
2047  yystate = *yyssp;
2048  goto yyerrlab1;
2049
2050
2051/*-------------------------------------------------------------.
2052| yyerrlab1 -- common code for both syntax error and YYERROR.  |
2053`-------------------------------------------------------------*/
2054yyerrlab1:
2055  yyerrstatus = 3;      /* Each real token shifted decrements this.  */
2056
2057  for (;;)
2058    {
2059      yyn = yypact[yystate];
2060      if (!yypact_value_is_default (yyn))
2061        {
2062          yyn += YYTERROR;
2063          if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2064            {
2065              yyn = yytable[yyn];
2066              if (0 < yyn)
2067                break;
2068            }
2069        }
2070
2071      /* Pop the current state because it cannot handle the error token.  */
2072      if (yyssp == yyss)
2073        YYABORT;
2074
2075
2076      yydestruct ("Error: popping",
2077                  yystos[yystate], yyvsp);
2078      YYPOPSTACK (1);
2079      yystate = *yyssp;
2080      YY_STACK_PRINT (yyss, yyssp);
2081    }
2082
2083  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2084  *++yyvsp = yylval;
2085  YY_IGNORE_MAYBE_UNINITIALIZED_END
2086
2087
2088  /* Shift the error token.  */
2089  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2090
2091  yystate = yyn;
2092  goto yynewstate;
2093
2094
2095/*-------------------------------------.
2096| yyacceptlab -- YYACCEPT comes here.  |
2097`-------------------------------------*/
2098yyacceptlab:
2099  yyresult = 0;
2100  goto yyreturn;
2101
2102/*-----------------------------------.
2103| yyabortlab -- YYABORT comes here.  |
2104`-----------------------------------*/
2105yyabortlab:
2106  yyresult = 1;
2107  goto yyreturn;
2108
2109#if !defined yyoverflow || YYERROR_VERBOSE
2110/*-------------------------------------------------.
2111| yyexhaustedlab -- memory exhaustion comes here.  |
2112`-------------------------------------------------*/
2113yyexhaustedlab:
2114  yyerror (YY_("memory exhausted"));
2115  yyresult = 2;
2116  /* Fall through.  */
2117#endif
2118
2119yyreturn:
2120  if (yychar != YYEMPTY)
2121    {
2122      /* Make sure we have latest lookahead translation.  See comments at
2123         user semantic actions for why this is necessary.  */
2124      yytoken = YYTRANSLATE (yychar);
2125      yydestruct ("Cleanup: discarding lookahead",
2126                  yytoken, &yylval);
2127    }
2128  /* Do not reclaim the symbols of the rule whose action triggered
2129     this YYABORT or YYACCEPT.  */
2130  YYPOPSTACK (yylen);
2131  YY_STACK_PRINT (yyss, yyssp);
2132  while (yyssp != yyss)
2133    {
2134      yydestruct ("Cleanup: popping",
2135                  yystos[*yyssp], yyvsp);
2136      YYPOPSTACK (1);
2137    }
2138#ifndef yyoverflow
2139  if (yyss != yyssa)
2140    YYSTACK_FREE (yyss);
2141#endif
2142#if YYERROR_VERBOSE
2143  if (yymsg != yymsgbuf)
2144    YYSTACK_FREE (yymsg);
2145#endif
2146  return yyresult;
2147}
2148#line 491 "nlmheader.y" /* yacc.c:1906  */
2149
2150
2151/* If strerror is just a macro, we want to use the one from libiberty
2152   since it will handle undefined values.  */
2153#undef strerror
2154extern char *strerror (int);
2155
2156/* The lexer is simple, too simple for flex.  Keywords are only
2157   recognized at the start of lines.  Everything else must be an
2158   argument.  A comma is treated as whitespace.  */
2159
2160/* The states the lexer can be in.  */
2161
2162enum lex_state
2163{
2164  /* At the beginning of a line.  */
2165  BEGINNING_OF_LINE,
2166  /* In the middle of a line.  */
2167  IN_LINE
2168};
2169
2170/* We need to keep a stack of files to handle file inclusion.  */
2171
2172struct input
2173{
2174  /* The file to read from.  */
2175  FILE *file;
2176  /* The name of the file.  */
2177  char *name;
2178  /* The current line number.  */
2179  int lineno;
2180  /* The current state.  */
2181  enum lex_state state;
2182  /* The next file on the stack.  */
2183  struct input *next;
2184};
2185
2186/* The current input file.  */
2187
2188static struct input current;
2189
2190/* The character which introduces comments.  */
2191#define COMMENT_CHAR '#'
2192
2193/* Start the lexer going on the main input file.  */
2194
2195bfd_boolean
2196nlmlex_file (const char *name)
2197{
2198  current.next = NULL;
2199  return nlmlex_file_open (name);
2200}
2201
2202/* Start the lexer going on a subsidiary input file.  */
2203
2204static void
2205nlmlex_file_push (const char *name)
2206{
2207  struct input *push;
2208
2209  push = (struct input *) xmalloc (sizeof (struct input));
2210  *push = current;
2211  if (nlmlex_file_open (name))
2212    current.next = push;
2213  else
2214    {
2215      current = *push;
2216      free (push);
2217    }
2218}
2219
2220/* Start lexing from a file.  */
2221
2222static bfd_boolean
2223nlmlex_file_open (const char *name)
2224{
2225  current.file = fopen (name, "r");
2226  if (current.file == NULL)
2227    {
2228      fprintf (stderr, "%s:%s: %s\n", program_name, name, strerror (errno));
2229      ++parse_errors;
2230      return FALSE;
2231    }
2232  current.name = xstrdup (name);
2233  current.lineno = 1;
2234  current.state = BEGINNING_OF_LINE;
2235  return TRUE;
2236}
2237
2238/* Table used to turn keywords into tokens.  */
2239
2240struct keyword_tokens_struct
2241{
2242  const char *keyword;
2243  int token;
2244};
2245
2246static struct keyword_tokens_struct keyword_tokens[] =
2247{
2248  { "CHECK", CHECK },
2249  { "CODESTART", CODESTART },
2250  { "COPYRIGHT", COPYRIGHT },
2251  { "CUSTOM", CUSTOM },
2252  { "DATE", DATE },
2253  { "DEBUG", DEBUG_K },
2254  { "DESCRIPTION", DESCRIPTION },
2255  { "EXIT", EXIT },
2256  { "EXPORT", EXPORT },
2257  { "FLAG_ON", FLAG_ON },
2258  { "FLAG_OFF", FLAG_OFF },
2259  { "FULLMAP", FULLMAP },
2260  { "HELP", HELP },
2261  { "IMPORT", IMPORT },
2262  { "INPUT", INPUT },
2263  { "MAP", MAP },
2264  { "MESSAGES", MESSAGES },
2265  { "MODULE", MODULE },
2266  { "MULTIPLE", MULTIPLE },
2267  { "OS_DOMAIN", OS_DOMAIN },
2268  { "OUTPUT", OUTPUT },
2269  { "PSEUDOPREEMPTION", PSEUDOPREEMPTION },
2270  { "REENTRANT", REENTRANT },
2271  { "SCREENNAME", SCREENNAME },
2272  { "SHARELIB", SHARELIB },
2273  { "STACK", STACK },
2274  { "STACKSIZE", STACK },
2275  { "START", START },
2276  { "SYNCHRONIZE", SYNCHRONIZE },
2277  { "THREADNAME", THREADNAME },
2278  { "TYPE", TYPE },
2279  { "VERBOSE", VERBOSE },
2280  { "VERSION", VERSIONK },
2281  { "XDCDATA", XDCDATA }
2282};
2283
2284#define KEYWORD_COUNT (sizeof (keyword_tokens) / sizeof (keyword_tokens[0]))
2285
2286/* The lexer accumulates strings in these variables.  */
2287static char *lex_buf;
2288static int lex_size;
2289static int lex_pos;
2290
2291/* Start accumulating strings into the buffer.  */
2292#define BUF_INIT() \
2293  ((void) (lex_buf != NULL ? lex_pos = 0 : nlmlex_buf_init ()))
2294
2295static int
2296nlmlex_buf_init (void)
2297{
2298  lex_size = 10;
2299  lex_buf = xmalloc (lex_size + 1);
2300  lex_pos = 0;
2301  return 0;
2302}
2303
2304/* Finish a string in the buffer.  */
2305#define BUF_FINISH() ((void) (lex_buf[lex_pos] = '\0'))
2306
2307/* Accumulate a character into the buffer.  */
2308#define BUF_ADD(c) \
2309  ((void) (lex_pos < lex_size \
2310	   ? lex_buf[lex_pos++] = (c) \
2311	   : nlmlex_buf_add (c)))
2312
2313static char
2314nlmlex_buf_add (int c)
2315{
2316  if (lex_pos >= lex_size)
2317    {
2318      lex_size *= 2;
2319      lex_buf = xrealloc (lex_buf, lex_size + 1);
2320    }
2321
2322  return lex_buf[lex_pos++] = c;
2323}
2324
2325/* The lexer proper.  This is called by the bison generated parsing
2326   code.  */
2327
2328static int
2329yylex (void)
2330{
2331  int c;
2332
2333tail_recurse:
2334
2335  c = getc (current.file);
2336
2337  /* Commas are treated as whitespace characters.  */
2338  while (ISSPACE (c) || c == ',')
2339    {
2340      current.state = IN_LINE;
2341      if (c == '\n')
2342	{
2343	  ++current.lineno;
2344	  current.state = BEGINNING_OF_LINE;
2345	}
2346      c = getc (current.file);
2347    }
2348
2349  /* At the end of the file we either pop to the previous file or
2350     finish up.  */
2351  if (c == EOF)
2352    {
2353      fclose (current.file);
2354      free (current.name);
2355      if (current.next == NULL)
2356	return 0;
2357      else
2358	{
2359	  struct input *next;
2360
2361	  next = current.next;
2362	  current = *next;
2363	  free (next);
2364	  goto tail_recurse;
2365	}
2366    }
2367
2368  /* A comment character always means to drop everything until the
2369     next newline.  */
2370  if (c == COMMENT_CHAR)
2371    {
2372      do
2373	{
2374	  c = getc (current.file);
2375	}
2376      while (c != '\n');
2377      ++current.lineno;
2378      current.state = BEGINNING_OF_LINE;
2379      goto tail_recurse;
2380    }
2381
2382  /* An '@' introduces an include file.  */
2383  if (c == '@')
2384    {
2385      do
2386	{
2387	  c = getc (current.file);
2388	  if (c == '\n')
2389	    ++current.lineno;
2390	}
2391      while (ISSPACE (c));
2392      BUF_INIT ();
2393      while (! ISSPACE (c) && c != EOF)
2394	{
2395	  BUF_ADD (c);
2396	  c = getc (current.file);
2397	}
2398      BUF_FINISH ();
2399
2400      ungetc (c, current.file);
2401
2402      nlmlex_file_push (lex_buf);
2403      goto tail_recurse;
2404    }
2405
2406  /* A non-space character at the start of a line must be the start of
2407     a keyword.  */
2408  if (current.state == BEGINNING_OF_LINE)
2409    {
2410      BUF_INIT ();
2411      while (ISALNUM (c) || c == '_')
2412	{
2413	  BUF_ADD (TOUPPER (c));
2414	  c = getc (current.file);
2415	}
2416      BUF_FINISH ();
2417
2418      if (c != EOF && ! ISSPACE (c) && c != ',')
2419	{
2420	  nlmheader_identify ();
2421	  fprintf (stderr, _("%s:%d: illegal character in keyword: %c\n"),
2422		   current.name, current.lineno, c);
2423	}
2424      else
2425	{
2426	  unsigned int i;
2427
2428	  for (i = 0; i < KEYWORD_COUNT; i++)
2429	    {
2430	      if (lex_buf[0] == keyword_tokens[i].keyword[0]
2431		  && strcmp (lex_buf, keyword_tokens[i].keyword) == 0)
2432		{
2433		  /* Pushing back the final whitespace avoids worrying
2434		     about \n here.  */
2435		  ungetc (c, current.file);
2436		  current.state = IN_LINE;
2437		  return keyword_tokens[i].token;
2438		}
2439	    }
2440
2441	  nlmheader_identify ();
2442	  fprintf (stderr, _("%s:%d: unrecognized keyword: %s\n"),
2443		   current.name, current.lineno, lex_buf);
2444	}
2445
2446      ++parse_errors;
2447      /* Treat the rest of this line as a comment.  */
2448      ungetc (COMMENT_CHAR, current.file);
2449      goto tail_recurse;
2450    }
2451
2452  /* Parentheses just represent themselves.  */
2453  if (c == '(' || c == ')')
2454    return c;
2455
2456  /* Handle quoted strings.  */
2457  if (c == '"' || c == '\'')
2458    {
2459      int quote;
2460      int start_lineno;
2461
2462      quote = c;
2463      start_lineno = current.lineno;
2464
2465      c = getc (current.file);
2466      BUF_INIT ();
2467      while (c != quote && c != EOF)
2468	{
2469	  BUF_ADD (c);
2470	  if (c == '\n')
2471	    ++current.lineno;
2472	  c = getc (current.file);
2473	}
2474      BUF_FINISH ();
2475
2476      if (c == EOF)
2477	{
2478	  nlmheader_identify ();
2479	  fprintf (stderr, _("%s:%d: end of file in quoted string\n"),
2480		   current.name, start_lineno);
2481	  ++parse_errors;
2482	}
2483
2484      /* FIXME: Possible memory leak.  */
2485      yylval.string = xstrdup (lex_buf);
2486      return QUOTED_STRING;
2487    }
2488
2489  /* Gather a generic argument.  */
2490  BUF_INIT ();
2491  while (! ISSPACE (c)
2492	 && c != ','
2493	 && c != COMMENT_CHAR
2494	 && c != '('
2495	 && c != ')')
2496    {
2497      BUF_ADD (c);
2498      c = getc (current.file);
2499    }
2500  BUF_FINISH ();
2501
2502  ungetc (c, current.file);
2503
2504  /* FIXME: Possible memory leak.  */
2505  yylval.string = xstrdup (lex_buf);
2506  return STRING;
2507}
2508
2509/* Get a number from a string.  */
2510
2511static long
2512nlmlex_get_number (const char *s)
2513{
2514  long ret;
2515  char *send;
2516
2517  ret = strtol (s, &send, 10);
2518  if (*send != '\0')
2519    nlmheader_warn (_("bad number"), -1);
2520  return ret;
2521}
2522
2523/* Prefix the nlmconv warnings with a note as to where they come from.
2524   We don't use program_name on every warning, because then some
2525   versions of the emacs next-error function can't recognize the line
2526   number.  */
2527
2528static void
2529nlmheader_identify (void)
2530{
2531  static int done;
2532
2533  if (! done)
2534    {
2535      fprintf (stderr, _("%s: problems in NLM command language input:\n"),
2536	       program_name);
2537      done = 1;
2538    }
2539}
2540
2541/* Issue a warning.  */
2542
2543static void
2544nlmheader_warn (const char *s, int imax)
2545{
2546  nlmheader_identify ();
2547  fprintf (stderr, "%s:%d: %s", current.name, current.lineno, s);
2548  if (imax != -1)
2549    fprintf (stderr, " (max %d)", imax);
2550  fprintf (stderr, "\n");
2551}
2552
2553/* Report an error.  */
2554
2555static void
2556nlmheader_error (const char *s)
2557{
2558  nlmheader_warn (s, -1);
2559  ++parse_errors;
2560}
2561
2562/* Add a string to a string list.  */
2563
2564static struct string_list *
2565string_list_cons (char *s, struct string_list *l)
2566{
2567  struct string_list *ret;
2568
2569  ret = (struct string_list *) xmalloc (sizeof (struct string_list));
2570  ret->next = l;
2571  ret->string = s;
2572  return ret;
2573}
2574
2575/* Append a string list to another string list.  */
2576
2577static struct string_list *
2578string_list_append (struct string_list *l1, struct string_list *l2)
2579{
2580  register struct string_list **pp;
2581
2582  for (pp = &l1; *pp != NULL; pp = &(*pp)->next)
2583    ;
2584  *pp = l2;
2585  return l1;
2586}
2587
2588/* Append a string to a string list.  */
2589
2590static struct string_list *
2591string_list_append1 (struct string_list *l, char *s)
2592{
2593  struct string_list *n;
2594  register struct string_list **pp;
2595
2596  n = (struct string_list *) xmalloc (sizeof (struct string_list));
2597  n->next = NULL;
2598  n->string = s;
2599  for (pp = &l; *pp != NULL; pp = &(*pp)->next)
2600    ;
2601  *pp = n;
2602  return l;
2603}
2604
2605/* Duplicate a string in memory.  */
2606
2607static char *
2608xstrdup (const char *s)
2609{
2610  unsigned long len;
2611  char *ret;
2612
2613  len = strlen (s);
2614  ret = xmalloc (len + 1);
2615  strcpy (ret, s);
2616  return ret;
2617}
2618