1 /* A Bison parser, made by GNU Bison 2.3. */
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
23 /* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
39 /* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
46 /* Identify Bison output. */
50 #define YYBISON_VERSION "2.3"
53 #define YYSKELETON_NAME "yacc.c"
58 /* Using locations. */
59 #define YYLSP_NEEDED 0
66 /* Put the tokens into the symbol table, so that GDB and other debuggers
90 PSEUDOPREEMPTION = 279,
108 #define CODESTART 259
109 #define COPYRIGHT 260
113 #define DESCRIPTION 264
126 #define OS_DOMAIN 277
128 #define PSEUDOPREEMPTION 279
129 #define REENTRANT 280
130 #define SCREENNAME 281
134 #define SYNCHRONIZE 285
135 #define THREADNAME 286
141 #define QUOTED_STRING 292
146 /* Copy the first part of user declarations. */
147 #line 1 "nlmheader.y"
148 /* nlmheader.y - parse NLM header specification keywords.
149 Copyright (C) 1993-2014 Free Software Foundation, Inc.
151 This file is part of GNU Binutils.
153 This program is free software; you can redistribute it and/or modify
154 it under the terms of the GNU General Public License as published by
155 the Free Software Foundation; either version 3 of the License, or
156 (at your option) any later version.
158 This program is distributed in the hope that it will be useful,
159 but WITHOUT ANY WARRANTY; without even the implied warranty of
160 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
161 GNU General Public License for more details.
163 You should have received a copy of the GNU General Public License
164 along with this program; if not, write to the Free Software
165 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
166 MA 02110-1301, USA. */
168 /* Written by Ian Lance Taylor <ian@cygnus.com>.
170 This bison file parses the commands recognized by the NetWare NLM
171 linker, except for lists of object files. It stores the
172 information in global variables.
174 This implementation is based on the description in the NetWare Tool
175 Maker Specification manual, edition 1.0. */
178 #include "safe-ctype.h"
180 #include "nlm/common.h"
181 #include "nlm/internal.h"
185 /* Information is stored in the structures pointed to by these
188 Nlm_Internal_Fixed_Header *fixed_hdr;
189 Nlm_Internal_Variable_Header *var_hdr;
190 Nlm_Internal_Version_Header *version_hdr;
191 Nlm_Internal_Copyright_Header *copyright_hdr;
192 Nlm_Internal_Extended_Header *extended_hdr;
194 /* Procedure named by CHECK. */
195 char *check_procedure;
196 /* File named by CUSTOM. */
198 /* Whether to generate debugging information (DEBUG). */
199 bfd_boolean debug_info;
200 /* Procedure named by EXIT. */
201 char *exit_procedure;
202 /* Exported symbols (EXPORT). */
203 struct string_list *export_symbols;
204 /* List of files from INPUT. */
205 struct string_list *input_files;
206 /* Map file name (MAP, FULLMAP). */
208 /* Whether a full map has been requested (FULLMAP). */
209 bfd_boolean full_map;
210 /* File named by HELP. */
212 /* Imported symbols (IMPORT). */
213 struct string_list *import_symbols;
214 /* File named by MESSAGES. */
216 /* Autoload module list (MODULE). */
217 struct string_list *modules;
218 /* File named by OUTPUT. */
220 /* File named by SHARELIB. */
222 /* Start procedure name (START). */
223 char *start_procedure;
226 /* RPC description file (XDCDATA). */
229 /* The number of serious errors that have occurred. */
232 /* The current symbol prefix when reading a list of import or export
234 static char *symbol_prefix;
236 /* Parser error message handler. */
237 #define yyerror(msg) nlmheader_error (msg);
239 /* Local functions. */
240 static int yylex (void);
241 static void nlmlex_file_push (const char *);
242 static bfd_boolean nlmlex_file_open (const char *);
243 static int nlmlex_buf_init (void);
244 static char nlmlex_buf_add (int);
245 static long nlmlex_get_number (const char *);
246 static void nlmheader_identify (void);
247 static void nlmheader_warn (const char *, int);
248 static void nlmheader_error (const char *);
249 static struct string_list * string_list_cons (char *, struct string_list *);
250 static struct string_list * string_list_append (struct string_list *,
251 struct string_list *);
252 static struct string_list * string_list_append1 (struct string_list *,
254 static char *xstrdup (const char *);
258 /* Enabling traces. */
263 /* Enabling verbose error messages. */
264 #ifdef YYERROR_VERBOSE
265 # undef YYERROR_VERBOSE
266 # define YYERROR_VERBOSE 1
268 # define YYERROR_VERBOSE 0
271 /* Enabling the token table. */
272 #ifndef YYTOKEN_TABLE
273 # define YYTOKEN_TABLE 0
276 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
277 typedef union YYSTYPE
278 #line 112 "nlmheader.y"
281 struct string_list *list;
283 /* Line 193 of yacc.c. */
284 #line 285 "nlmheader.c"
286 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
287 # define YYSTYPE_IS_DECLARED 1
288 # define YYSTYPE_IS_TRIVIAL 1
293 /* Copy the second part of user declarations. */
296 /* Line 216 of yacc.c. */
297 #line 298 "nlmheader.c"
304 typedef YYTYPE_UINT8 yytype_uint8;
306 typedef unsigned char yytype_uint8;
310 typedef YYTYPE_INT8 yytype_int8;
311 #elif (defined __STDC__ || defined __C99__FUNC__ \
312 || defined __cplusplus || defined _MSC_VER)
313 typedef signed char yytype_int8;
315 typedef short int yytype_int8;
319 typedef YYTYPE_UINT16 yytype_uint16;
321 typedef unsigned short int yytype_uint16;
325 typedef YYTYPE_INT16 yytype_int16;
327 typedef short int yytype_int16;
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 && (defined __STDC__ || defined __C99__FUNC__ \
336 || defined __cplusplus || defined _MSC_VER)
337 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
338 # define YYSIZE_T size_t
340 # define YYSIZE_T unsigned int
344 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
347 # if defined YYENABLE_NLS && YYENABLE_NLS
349 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
350 # define YY_(msgid) dgettext ("bison-runtime", msgid)
354 # define YY_(msgid) msgid
358 /* Suppress unused-variable warnings by "using" E. */
359 #if ! defined lint || defined __GNUC__
360 # define YYUSE(e) ((void) (e))
362 # define YYUSE(e) /* empty */
365 /* Identity function, used to suppress warnings about constant conditions. */
369 #if (defined __STDC__ || defined __C99__FUNC__ \
370 || defined __cplusplus || defined _MSC_VER)
383 #if ! defined yyoverflow || YYERROR_VERBOSE
385 /* The parser invokes alloca or malloc; define the necessary symbols. */
387 # ifdef YYSTACK_USE_ALLOCA
388 # if YYSTACK_USE_ALLOCA
390 # define YYSTACK_ALLOC __builtin_alloca
391 # elif defined __BUILTIN_VA_ARG_INCR
392 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
394 # define YYSTACK_ALLOC __alloca
395 # elif defined _MSC_VER
396 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
397 # define alloca _alloca
399 # define YYSTACK_ALLOC alloca
400 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
401 || defined __cplusplus || defined _MSC_VER)
402 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
411 # ifdef YYSTACK_ALLOC
412 /* Pacify GCC's `empty if-body' warning. */
413 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
414 # ifndef YYSTACK_ALLOC_MAXIMUM
415 /* The OS might guarantee only one guard page at the bottom of the stack,
416 and a page size can be as small as 4096 bytes. So we cannot safely
417 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
418 to allow for a few compiler-allocated temporary stack slots. */
419 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
422 # define YYSTACK_ALLOC YYMALLOC
423 # define YYSTACK_FREE YYFREE
424 # ifndef YYSTACK_ALLOC_MAXIMUM
425 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
427 # if (defined __cplusplus && ! defined _STDLIB_H \
428 && ! ((defined YYMALLOC || defined malloc) \
429 && (defined YYFREE || defined free)))
430 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
436 # define YYMALLOC malloc
437 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
438 || defined __cplusplus || defined _MSC_VER)
439 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
444 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
445 || defined __cplusplus || defined _MSC_VER)
446 void free (void *); /* INFRINGES ON USER NAME SPACE */
450 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
453 #if (! defined yyoverflow \
454 && (! defined __cplusplus \
455 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
457 /* A type that is properly aligned for any stack member. */
464 /* The size of the maximum gap between one aligned stack and the next. */
465 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
467 /* The size of an array large to enough to hold all stacks, each with
469 # define YYSTACK_BYTES(N) \
470 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
471 + YYSTACK_GAP_MAXIMUM)
473 /* Copy COUNT objects from FROM to TO. The source and destination do
476 # if defined __GNUC__ && 1 < __GNUC__
477 # define YYCOPY(To, From, Count) \
478 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
480 # define YYCOPY(To, From, Count) \
484 for (yyi = 0; yyi < (Count); yyi++) \
485 (To)[yyi] = (From)[yyi]; \
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
496 # define YYSTACK_RELOCATE(Stack) \
499 YYSIZE_T yynewbytes; \
500 YYCOPY (&yyptr->Stack, Stack, yysize); \
501 Stack = &yyptr->Stack; \
502 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
503 yyptr += yynewbytes / sizeof (*yyptr); \
509 /* YYFINAL -- State number of the termination state. */
511 /* YYLAST -- Last index in YYTABLE. */
514 /* YYNTOKENS -- Number of terminals. */
516 /* YYNNTS -- Number of nonterminals. */
518 /* YYNRULES -- Number of rules. */
520 /* YYNRULES -- Number of states. */
523 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
525 #define YYMAXUTOK 292
527 #define YYTRANSLATE(YYX) \
528 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
530 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
531 static const yytype_uint8 yytranslate[] =
533 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
534 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
535 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
536 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
537 38, 39, 2, 2, 2, 2, 2, 2, 2, 2,
538 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
539 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
540 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
541 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
542 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
543 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
544 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
545 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
546 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
547 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
548 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
549 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
550 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
551 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
552 2, 2, 2, 2, 2, 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, 1, 2, 3, 4,
559 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
560 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
561 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
566 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
568 static const yytype_uint8 yyprhs[] =
570 0, 0, 3, 5, 6, 9, 12, 15, 18, 21,
571 26, 28, 31, 34, 35, 39, 42, 45, 47, 50,
572 53, 54, 58, 61, 63, 66, 69, 72, 74, 76,
573 79, 81, 83, 86, 89, 92, 95, 97, 100, 103,
574 105, 110, 114, 117, 118, 120, 122, 124, 127, 130,
578 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
579 static const yytype_int8 yyrhs[] =
581 41, 0, -1, 42, -1, -1, 43, 42, -1, 3,
582 36, -1, 4, 36, -1, 5, 37, -1, 6, 36,
583 -1, 7, 36, 36, 36, -1, 8, -1, 9, 37,
584 -1, 10, 36, -1, -1, 11, 44, 46, -1, 12,
585 36, -1, 13, 36, -1, 14, -1, 14, 36, -1,
586 15, 36, -1, -1, 16, 45, 46, -1, 17, 50,
587 -1, 18, -1, 18, 36, -1, 19, 36, -1, 20,
588 50, -1, 21, -1, 22, -1, 23, 36, -1, 24,
589 -1, 25, -1, 26, 37, -1, 27, 36, -1, 28,
590 36, -1, 29, 36, -1, 30, -1, 31, 37, -1,
591 32, 36, -1, 33, -1, 34, 36, 36, 36, -1,
592 34, 36, 36, -1, 35, 36, -1, -1, 47, -1,
593 49, -1, 48, -1, 47, 49, -1, 47, 48, -1,
594 38, 36, 39, -1, 36, -1, -1, 36, 50, -1
597 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
598 static const yytype_uint16 yyrline[] =
600 0, 143, 143, 148, 150, 156, 160, 165, 182, 186,
601 204, 208, 224, 229, 228, 236, 241, 246, 251, 256,
602 261, 260, 268, 272, 276, 280, 284, 288, 292, 296,
603 303, 307, 311, 327, 331, 336, 340, 344, 360, 365,
604 369, 393, 409, 419, 422, 433, 437, 441, 445, 454,
609 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
610 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
611 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
612 static const char *const yytname[] =
614 "$end", "error", "$undefined", "CHECK", "CODESTART", "COPYRIGHT",
615 "CUSTOM", "DATE", "DEBUG_K", "DESCRIPTION", "EXIT", "EXPORT", "FLAG_ON",
616 "FLAG_OFF", "FULLMAP", "HELP", "IMPORT", "INPUT", "MAP", "MESSAGES",
617 "MODULE", "MULTIPLE", "OS_DOMAIN", "OUTPUT", "PSEUDOPREEMPTION",
618 "REENTRANT", "SCREENNAME", "SHARELIB", "STACK", "START", "SYNCHRONIZE",
619 "THREADNAME", "TYPE", "VERBOSE", "VERSIONK", "XDCDATA", "STRING",
620 "QUOTED_STRING", "'('", "')'", "$accept", "file", "commands", "command",
621 "@1", "@2", "symbol_list_opt", "symbol_list", "symbol_prefix", "symbol",
627 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
629 static const yytype_uint16 yytoknum[] =
631 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
632 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
633 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
634 285, 286, 287, 288, 289, 290, 291, 292, 40, 41
638 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
639 static const yytype_uint8 yyr1[] =
641 0, 40, 41, 42, 42, 43, 43, 43, 43, 43,
642 43, 43, 43, 44, 43, 43, 43, 43, 43, 43,
643 45, 43, 43, 43, 43, 43, 43, 43, 43, 43,
644 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
645 43, 43, 43, 46, 46, 47, 47, 47, 47, 48,
649 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
650 static const yytype_uint8 yyr2[] =
652 0, 2, 1, 0, 2, 2, 2, 2, 2, 4,
653 1, 2, 2, 0, 3, 2, 2, 1, 2, 2,
654 0, 3, 2, 1, 2, 2, 2, 1, 1, 2,
655 1, 1, 2, 2, 2, 2, 1, 2, 2, 1,
656 4, 3, 2, 0, 1, 1, 1, 2, 2, 3,
660 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
661 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
662 means the default is an error. */
663 static const yytype_uint8 yydefact[] =
665 3, 0, 0, 0, 0, 0, 10, 0, 0, 13,
666 0, 0, 17, 0, 20, 51, 23, 0, 51, 27,
667 28, 0, 30, 31, 0, 0, 0, 0, 36, 0,
668 0, 39, 0, 0, 0, 2, 3, 5, 6, 7,
669 8, 0, 11, 12, 43, 15, 16, 18, 19, 43,
670 51, 22, 24, 25, 26, 29, 32, 33, 34, 35,
671 37, 38, 0, 42, 1, 4, 0, 50, 0, 14,
672 44, 46, 45, 21, 52, 41, 9, 0, 48, 47,
676 /* YYDEFGOTO[NTERM-NUM]. */
677 static const yytype_int8 yydefgoto[] =
679 -1, 34, 35, 36, 44, 49, 69, 70, 71, 72,
683 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
685 #define YYPACT_NINF -20
686 static const yytype_int8 yypact[] =
688 -3, -1, 1, 2, 4, 5, -20, 6, 8, -20,
689 9, 10, 11, 12, -20, 13, 14, 16, 13, -20,
690 -20, 17, -20, -20, 18, 20, 21, 22, -20, 23,
691 25, -20, 26, 27, 38, -20, -3, -20, -20, -20,
692 -20, 28, -20, -20, -2, -20, -20, -20, -20, -2,
693 13, -20, -20, -20, -20, -20, -20, -20, -20, -20,
694 -20, -20, 30, -20, -20, -20, 31, -20, 32, -20,
695 -2, -20, -20, -20, -20, 33, -20, 3, -20, -20,
699 /* YYPGOTO[NTERM-NUM]. */
700 static const yytype_int8 yypgoto[] =
702 -20, -20, 34, -20, -20, -20, 24, -20, -19, -16,
706 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
707 positive, shift that token. If negative, reduce the rule which
708 number is the opposite. If zero, do what YYDEFACT says.
709 If YYTABLE_NINF, syntax error. */
710 #define YYTABLE_NINF -1
711 static const yytype_uint8 yytable[] =
713 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
714 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
715 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
716 31, 32, 33, 54, 67, 37, 68, 38, 64, 39,
717 40, 41, 81, 42, 43, 45, 46, 47, 48, 50,
718 52, 78, 53, 55, 79, 56, 57, 58, 59, 0,
719 60, 61, 62, 63, 66, 74, 75, 76, 77, 80,
723 static const yytype_int8 yycheck[] =
725 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
726 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
727 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
728 33, 34, 35, 18, 36, 36, 38, 36, 0, 37,
729 36, 36, 39, 37, 36, 36, 36, 36, 36, 36,
730 36, 70, 36, 36, 70, 37, 36, 36, 36, -1,
731 37, 36, 36, 36, 36, 50, 36, 36, 36, 36,
735 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
736 symbol of state STATE-NUM. */
737 static const yytype_uint8 yystos[] =
739 0, 3, 4, 5, 6, 7, 8, 9, 10, 11,
740 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
741 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
742 32, 33, 34, 35, 41, 42, 43, 36, 36, 37,
743 36, 36, 37, 36, 44, 36, 36, 36, 36, 45,
744 36, 50, 36, 36, 50, 36, 37, 36, 36, 36,
745 37, 36, 36, 36, 0, 42, 36, 36, 38, 46,
746 47, 48, 49, 46, 50, 36, 36, 36, 48, 49,
750 #define yyerrok (yyerrstatus = 0)
751 #define yyclearin (yychar = YYEMPTY)
755 #define YYACCEPT goto yyacceptlab
756 #define YYABORT goto yyabortlab
757 #define YYERROR goto yyerrorlab
760 /* Like YYERROR except do call yyerror. This remains here temporarily
761 to ease the transition to the new meaning of YYERROR, for GCC.
762 Once GCC version 2 has supplanted version 1, this can go. */
764 #define YYFAIL goto yyerrlab
766 #define YYRECOVERING() (!!yyerrstatus)
768 #define YYBACKUP(Token, Value) \
770 if (yychar == YYEMPTY && yylen == 1) \
774 yytoken = YYTRANSLATE (yychar); \
780 yyerror (YY_("syntax error: cannot back up")); \
787 #define YYERRCODE 256
790 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
791 If N is 0, then set CURRENT to the empty location which ends
792 the previous symbol: RHS[0] (always defined). */
794 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
795 #ifndef YYLLOC_DEFAULT
796 # define YYLLOC_DEFAULT(Current, Rhs, N) \
800 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
801 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
802 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
803 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
807 (Current).first_line = (Current).last_line = \
808 YYRHSLOC (Rhs, 0).last_line; \
809 (Current).first_column = (Current).last_column = \
810 YYRHSLOC (Rhs, 0).last_column; \
816 /* YY_LOCATION_PRINT -- Print the location on the stream.
817 This macro was not mandated originally: define only if we know
818 we won't break user code: when these are the locations we know. */
820 #ifndef YY_LOCATION_PRINT
821 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
822 # define YY_LOCATION_PRINT(File, Loc) \
823 fprintf (File, "%d.%d-%d.%d", \
824 (Loc).first_line, (Loc).first_column, \
825 (Loc).last_line, (Loc).last_column)
827 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
832 /* YYLEX -- calling `yylex' with the right arguments. */
835 # define YYLEX yylex (YYLEX_PARAM)
837 # define YYLEX yylex ()
840 /* Enable debugging if requested. */
844 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
845 # define YYFPRINTF fprintf
848 # define YYDPRINTF(Args) \
854 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
858 YYFPRINTF (stderr, "%s ", Title); \
859 yy_symbol_print (stderr, \
861 YYFPRINTF (stderr, "\n"); \
866 /*--------------------------------.
867 | Print this symbol on YYOUTPUT. |
868 `--------------------------------*/
871 #if (defined __STDC__ || defined __C99__FUNC__ \
872 || defined __cplusplus || defined _MSC_VER)
874 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
877 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
880 YYSTYPE const * const yyvaluep;
886 if (yytype < YYNTOKENS)
887 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
899 /*--------------------------------.
900 | Print this symbol on YYOUTPUT. |
901 `--------------------------------*/
903 #if (defined __STDC__ || defined __C99__FUNC__ \
904 || defined __cplusplus || defined _MSC_VER)
906 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
909 yy_symbol_print (yyoutput, yytype, yyvaluep)
912 YYSTYPE const * const yyvaluep;
915 if (yytype < YYNTOKENS)
916 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
918 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
920 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
921 YYFPRINTF (yyoutput, ")");
924 /*------------------------------------------------------------------.
925 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
927 `------------------------------------------------------------------*/
929 #if (defined __STDC__ || defined __C99__FUNC__ \
930 || defined __cplusplus || defined _MSC_VER)
932 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
935 yy_stack_print (bottom, top)
936 yytype_int16 *bottom;
940 YYFPRINTF (stderr, "Stack now");
941 for (; bottom <= top; ++bottom)
942 YYFPRINTF (stderr, " %d", *bottom);
943 YYFPRINTF (stderr, "\n");
946 # define YY_STACK_PRINT(Bottom, Top) \
949 yy_stack_print ((Bottom), (Top)); \
953 /*------------------------------------------------.
954 | Report that the YYRULE is going to be reduced. |
955 `------------------------------------------------*/
957 #if (defined __STDC__ || defined __C99__FUNC__ \
958 || defined __cplusplus || defined _MSC_VER)
960 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
963 yy_reduce_print (yyvsp, yyrule)
968 int yynrhs = yyr2[yyrule];
970 unsigned long int yylno = yyrline[yyrule];
971 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
973 /* The symbols being reduced. */
974 for (yyi = 0; yyi < yynrhs; yyi++)
976 fprintf (stderr, " $%d = ", yyi + 1);
977 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
978 &(yyvsp[(yyi + 1) - (yynrhs)])
980 fprintf (stderr, "\n");
984 # define YY_REDUCE_PRINT(Rule) \
987 yy_reduce_print (yyvsp, Rule); \
990 /* Nonzero means print parse trace. It is left uninitialized so that
991 multiple parsers can coexist. */
994 # define YYDPRINTF(Args)
995 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
996 # define YY_STACK_PRINT(Bottom, Top)
997 # define YY_REDUCE_PRINT(Rule)
998 #endif /* !YYDEBUG */
1001 /* YYINITDEPTH -- initial size of the parser's stacks. */
1003 # define YYINITDEPTH 200
1006 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1007 if the built-in stack extension method is used).
1009 Do not make this value too large; the results are undefined if
1010 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1011 evaluated with infinite-precision integer arithmetic. */
1014 # define YYMAXDEPTH 10000
1022 # if defined __GLIBC__ && defined _STRING_H
1023 # define yystrlen strlen
1025 /* Return the length of YYSTR. */
1026 #if (defined __STDC__ || defined __C99__FUNC__ \
1027 || defined __cplusplus || defined _MSC_VER)
1029 yystrlen (const char *yystr)
1037 for (yylen = 0; yystr[yylen]; yylen++)
1045 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1046 # define yystpcpy stpcpy
1048 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1050 #if (defined __STDC__ || defined __C99__FUNC__ \
1051 || defined __cplusplus || defined _MSC_VER)
1053 yystpcpy (char *yydest, const char *yysrc)
1056 yystpcpy (yydest, yysrc)
1062 const char *yys = yysrc;
1064 while ((*yyd++ = *yys++) != '\0')
1073 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1074 quotes and backslashes, so that it's suitable for yyerror. The
1075 heuristic is that double-quoting is unnecessary unless the string
1076 contains an apostrophe, a comma, or backslash (other than
1077 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1078 null, do not copy; instead, return the length of what the result
1081 yytnamerr (char *yyres, const char *yystr)
1086 char const *yyp = yystr;
1093 goto do_not_strip_quotes;
1097 goto do_not_strip_quotes;
1110 do_not_strip_quotes: ;
1114 return yystrlen (yystr);
1116 return yystpcpy (yyres, yystr) - yyres;
1120 /* Copy into YYRESULT an error message about the unexpected token
1121 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1122 including the terminating null byte. If YYRESULT is null, do not
1123 copy anything; just return the number of bytes that would be
1124 copied. As a special case, return 0 if an ordinary "syntax error"
1125 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1126 size calculation. */
1128 yysyntax_error (char *yyresult, int yystate, int yychar)
1130 int yyn = yypact[yystate];
1132 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1136 int yytype = YYTRANSLATE (yychar);
1137 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1138 YYSIZE_T yysize = yysize0;
1140 int yysize_overflow = 0;
1141 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1142 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1146 /* This is so xgettext sees the translatable formats that are
1147 constructed on the fly. */
1148 YY_("syntax error, unexpected %s");
1149 YY_("syntax error, unexpected %s, expecting %s");
1150 YY_("syntax error, unexpected %s, expecting %s or %s");
1151 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1152 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1156 static char const yyunexpected[] = "syntax error, unexpected %s";
1157 static char const yyexpecting[] = ", expecting %s";
1158 static char const yyor[] = " or %s";
1159 char yyformat[sizeof yyunexpected
1160 + sizeof yyexpecting - 1
1161 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1162 * (sizeof yyor - 1))];
1163 char const *yyprefix = yyexpecting;
1165 /* Start YYX at -YYN if negative to avoid negative indexes in
1167 int yyxbegin = yyn < 0 ? -yyn : 0;
1169 /* Stay within bounds of both yycheck and yytname. */
1170 int yychecklim = YYLAST - yyn + 1;
1171 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1174 yyarg[0] = yytname[yytype];
1175 yyfmt = yystpcpy (yyformat, yyunexpected);
1177 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1178 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1180 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1184 yyformat[sizeof yyunexpected - 1] = '\0';
1187 yyarg[yycount++] = yytname[yyx];
1188 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1189 yysize_overflow |= (yysize1 < yysize);
1191 yyfmt = yystpcpy (yyfmt, yyprefix);
1195 yyf = YY_(yyformat);
1196 yysize1 = yysize + yystrlen (yyf);
1197 yysize_overflow |= (yysize1 < yysize);
1200 if (yysize_overflow)
1201 return YYSIZE_MAXIMUM;
1205 /* Avoid sprintf, as that infringes on the user's name space.
1206 Don't have undefined behavior even if the translation
1207 produced a string with the wrong number of "%s"s. */
1208 char *yyp = yyresult;
1210 while ((*yyp = *yyf) != '\0')
1212 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1214 yyp += yytnamerr (yyp, yyarg[yyi++]);
1227 #endif /* YYERROR_VERBOSE */
1230 /*-----------------------------------------------.
1231 | Release the memory associated to this symbol. |
1232 `-----------------------------------------------*/
1235 #if (defined __STDC__ || defined __C99__FUNC__ \
1236 || defined __cplusplus || defined _MSC_VER)
1238 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1241 yydestruct (yymsg, yytype, yyvaluep)
1251 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1262 /* Prevent warnings from -Wmissing-prototypes. */
1264 #ifdef YYPARSE_PARAM
1265 #if defined __STDC__ || defined __cplusplus
1266 int yyparse (void *YYPARSE_PARAM);
1270 #else /* ! YYPARSE_PARAM */
1271 #if defined __STDC__ || defined __cplusplus
1276 #endif /* ! YYPARSE_PARAM */
1280 /* The look-ahead symbol. */
1283 /* The semantic value of the look-ahead symbol. */
1286 /* Number of syntax errors so far. */
1295 #ifdef YYPARSE_PARAM
1296 #if (defined __STDC__ || defined __C99__FUNC__ \
1297 || defined __cplusplus || defined _MSC_VER)
1299 yyparse (void *YYPARSE_PARAM)
1302 yyparse (YYPARSE_PARAM)
1303 void *YYPARSE_PARAM;
1305 #else /* ! YYPARSE_PARAM */
1306 #if (defined __STDC__ || defined __C99__FUNC__ \
1307 || defined __cplusplus || defined _MSC_VER)
1321 /* Number of tokens to shift before error messages enabled. */
1323 /* Look-ahead token as an internal (translated) token number. */
1326 /* Buffer for error messages, and its allocated size. */
1328 char *yymsg = yymsgbuf;
1329 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1332 /* Three stacks and their tools:
1333 `yyss': related to states,
1334 `yyvs': related to semantic values,
1335 `yyls': related to locations.
1337 Refer to the stacks thru separate pointers, to allow yyoverflow
1338 to reallocate them elsewhere. */
1340 /* The state stack. */
1341 yytype_int16 yyssa[YYINITDEPTH];
1342 yytype_int16 *yyss = yyssa;
1343 yytype_int16 *yyssp;
1345 /* The semantic value stack. */
1346 YYSTYPE yyvsa[YYINITDEPTH];
1347 YYSTYPE *yyvs = yyvsa;
1352 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1354 YYSIZE_T yystacksize = YYINITDEPTH;
1356 /* The variables used to return semantic value and location from the
1361 /* The number of symbols on the RHS of the reduced rule.
1362 Keep to zero when no symbol should be popped. */
1365 YYDPRINTF ((stderr, "Starting parse\n"));
1370 yychar = YYEMPTY; /* Cause a token to be read. */
1372 /* Initialize stack pointers.
1373 Waste one element of value and location stack
1374 so that they stay on the same level as the state stack.
1375 The wasted elements are never initialized. */
1382 /*------------------------------------------------------------.
1383 | yynewstate -- Push a new state, which is found in yystate. |
1384 `------------------------------------------------------------*/
1386 /* In all cases, when you get here, the value and location stacks
1387 have just been pushed. So pushing a state here evens the stacks. */
1393 if (yyss + yystacksize - 1 <= yyssp)
1395 /* Get the current used size of the three stacks, in elements. */
1396 YYSIZE_T yysize = yyssp - yyss + 1;
1400 /* Give user a chance to reallocate the stack. Use copies of
1401 these so that the &'s don't force the real ones into
1403 YYSTYPE *yyvs1 = yyvs;
1404 yytype_int16 *yyss1 = yyss;
1407 /* Each stack pointer address is followed by the size of the
1408 data in use in that stack, in bytes. This used to be a
1409 conditional around just the two extra args, but that might
1410 be undefined if yyoverflow is a macro. */
1411 yyoverflow (YY_("memory exhausted"),
1412 &yyss1, yysize * sizeof (*yyssp),
1413 &yyvs1, yysize * sizeof (*yyvsp),
1420 #else /* no yyoverflow */
1421 # ifndef YYSTACK_RELOCATE
1422 goto yyexhaustedlab;
1424 /* Extend the stack our own way. */
1425 if (YYMAXDEPTH <= yystacksize)
1426 goto yyexhaustedlab;
1428 if (YYMAXDEPTH < yystacksize)
1429 yystacksize = YYMAXDEPTH;
1432 yytype_int16 *yyss1 = yyss;
1433 union yyalloc *yyptr =
1434 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1436 goto yyexhaustedlab;
1437 YYSTACK_RELOCATE (yyss);
1438 YYSTACK_RELOCATE (yyvs);
1440 # undef YYSTACK_RELOCATE
1442 YYSTACK_FREE (yyss1);
1445 #endif /* no yyoverflow */
1447 yyssp = yyss + yysize - 1;
1448 yyvsp = yyvs + yysize - 1;
1451 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1452 (unsigned long int) yystacksize));
1454 if (yyss + yystacksize - 1 <= yyssp)
1458 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1467 /* Do appropriate processing given the current state. Read a
1468 look-ahead token if we need one and don't already have one. */
1470 /* First try to decide what to do without reference to look-ahead token. */
1471 yyn = yypact[yystate];
1472 if (yyn == YYPACT_NINF)
1475 /* Not known => get a look-ahead token if don't already have one. */
1477 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1478 if (yychar == YYEMPTY)
1480 YYDPRINTF ((stderr, "Reading a token: "));
1484 if (yychar <= YYEOF)
1486 yychar = yytoken = YYEOF;
1487 YYDPRINTF ((stderr, "Now at end of input.\n"));
1491 yytoken = YYTRANSLATE (yychar);
1492 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1495 /* If the proper action on seeing token YYTOKEN is to reduce or to
1496 detect an error, take that action. */
1498 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1503 if (yyn == 0 || yyn == YYTABLE_NINF)
1512 /* Count tokens shifted since error; after three, turn off error
1517 /* Shift the look-ahead token. */
1518 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1520 /* Discard the shifted token unless it is eof. */
1521 if (yychar != YYEOF)
1530 /*-----------------------------------------------------------.
1531 | yydefault -- do the default action for the current state. |
1532 `-----------------------------------------------------------*/
1534 yyn = yydefact[yystate];
1540 /*-----------------------------.
1541 | yyreduce -- Do a reduction. |
1542 `-----------------------------*/
1544 /* yyn is the number of a rule to reduce with. */
1547 /* If YYLEN is nonzero, implement the default value of the action:
1550 Otherwise, the following line sets YYVAL to garbage.
1551 This behavior is undocumented and Bison
1552 users should not rely upon it. Assigning to YYVAL
1553 unconditionally makes the parser a bit smaller, and it avoids a
1554 GCC warning that YYVAL may be used uninitialized. */
1555 yyval = yyvsp[1-yylen];
1558 YY_REDUCE_PRINT (yyn);
1562 #line 157 "nlmheader.y"
1564 check_procedure = (yyvsp[(2) - (2)].string);
1569 #line 161 "nlmheader.y"
1571 nlmheader_warn (_("CODESTART is not implemented; sorry"), -1);
1572 free ((yyvsp[(2) - (2)].string));
1577 #line 166 "nlmheader.y"
1581 strncpy (copyright_hdr->stamp, "CoPyRiGhT=", 10);
1582 len = strlen ((yyvsp[(2) - (2)].string));
1583 if (len >= NLM_MAX_COPYRIGHT_MESSAGE_LENGTH)
1585 nlmheader_warn (_("copyright string is too long"),
1586 NLM_MAX_COPYRIGHT_MESSAGE_LENGTH - 1);
1587 len = NLM_MAX_COPYRIGHT_MESSAGE_LENGTH - 1;
1589 copyright_hdr->copyrightMessageLength = len;
1590 strncpy (copyright_hdr->copyrightMessage, (yyvsp[(2) - (2)].string), len);
1591 copyright_hdr->copyrightMessage[len] = '\0';
1592 free ((yyvsp[(2) - (2)].string));
1597 #line 183 "nlmheader.y"
1599 custom_file = (yyvsp[(2) - (2)].string);
1604 #line 187 "nlmheader.y"
1606 /* We don't set the version stamp here, because we use the
1607 version stamp to detect whether the required VERSION
1608 keyword was given. */
1609 version_hdr->month = nlmlex_get_number ((yyvsp[(2) - (4)].string));
1610 version_hdr->day = nlmlex_get_number ((yyvsp[(3) - (4)].string));
1611 version_hdr->year = nlmlex_get_number ((yyvsp[(4) - (4)].string));
1612 free ((yyvsp[(2) - (4)].string));
1613 free ((yyvsp[(3) - (4)].string));
1614 free ((yyvsp[(4) - (4)].string));
1615 if (version_hdr->month < 1 || version_hdr->month > 12)
1616 nlmheader_warn (_("illegal month"), -1);
1617 if (version_hdr->day < 1 || version_hdr->day > 31)
1618 nlmheader_warn (_("illegal day"), -1);
1619 if (version_hdr->year < 1900 || version_hdr->year > 3000)
1620 nlmheader_warn (_("illegal year"), -1);
1625 #line 205 "nlmheader.y"
1632 #line 209 "nlmheader.y"
1636 len = strlen ((yyvsp[(2) - (2)].string));
1637 if (len > NLM_MAX_DESCRIPTION_LENGTH)
1639 nlmheader_warn (_("description string is too long"),
1640 NLM_MAX_DESCRIPTION_LENGTH);
1641 len = NLM_MAX_DESCRIPTION_LENGTH;
1643 var_hdr->descriptionLength = len;
1644 strncpy (var_hdr->descriptionText, (yyvsp[(2) - (2)].string), len);
1645 var_hdr->descriptionText[len] = '\0';
1646 free ((yyvsp[(2) - (2)].string));
1651 #line 225 "nlmheader.y"
1653 exit_procedure = (yyvsp[(2) - (2)].string);
1658 #line 229 "nlmheader.y"
1660 symbol_prefix = NULL;
1665 #line 233 "nlmheader.y"
1667 export_symbols = string_list_append (export_symbols, (yyvsp[(3) - (3)].list));
1672 #line 237 "nlmheader.y"
1674 fixed_hdr->flags |= nlmlex_get_number ((yyvsp[(2) - (2)].string));
1675 free ((yyvsp[(2) - (2)].string));
1680 #line 242 "nlmheader.y"
1682 fixed_hdr->flags &=~ nlmlex_get_number ((yyvsp[(2) - (2)].string));
1683 free ((yyvsp[(2) - (2)].string));
1688 #line 247 "nlmheader.y"
1696 #line 252 "nlmheader.y"
1698 map_file = (yyvsp[(2) - (2)].string);
1704 #line 257 "nlmheader.y"
1706 help_file = (yyvsp[(2) - (2)].string);
1711 #line 261 "nlmheader.y"
1713 symbol_prefix = NULL;
1718 #line 265 "nlmheader.y"
1720 import_symbols = string_list_append (import_symbols, (yyvsp[(3) - (3)].list));
1725 #line 269 "nlmheader.y"
1727 input_files = string_list_append (input_files, (yyvsp[(2) - (2)].list));
1732 #line 273 "nlmheader.y"
1739 #line 277 "nlmheader.y"
1741 map_file = (yyvsp[(2) - (2)].string);
1746 #line 281 "nlmheader.y"
1748 message_file = (yyvsp[(2) - (2)].string);
1753 #line 285 "nlmheader.y"
1755 modules = string_list_append (modules, (yyvsp[(2) - (2)].list));
1760 #line 289 "nlmheader.y"
1762 fixed_hdr->flags |= 0x2;
1767 #line 293 "nlmheader.y"
1769 fixed_hdr->flags |= 0x10;
1774 #line 297 "nlmheader.y"
1776 if (output_file == NULL)
1777 output_file = (yyvsp[(2) - (2)].string);
1779 nlmheader_warn (_("ignoring duplicate OUTPUT statement"), -1);
1784 #line 304 "nlmheader.y"
1786 fixed_hdr->flags |= 0x8;
1791 #line 308 "nlmheader.y"
1793 fixed_hdr->flags |= 0x1;
1798 #line 312 "nlmheader.y"
1802 len = strlen ((yyvsp[(2) - (2)].string));
1803 if (len >= NLM_MAX_SCREEN_NAME_LENGTH)
1805 nlmheader_warn (_("screen name is too long"),
1806 NLM_MAX_SCREEN_NAME_LENGTH);
1807 len = NLM_MAX_SCREEN_NAME_LENGTH;
1809 var_hdr->screenNameLength = len;
1810 strncpy (var_hdr->screenName, (yyvsp[(2) - (2)].string), len);
1811 var_hdr->screenName[NLM_MAX_SCREEN_NAME_LENGTH] = '\0';
1812 free ((yyvsp[(2) - (2)].string));
1817 #line 328 "nlmheader.y"
1819 sharelib_file = (yyvsp[(2) - (2)].string);
1824 #line 332 "nlmheader.y"
1826 var_hdr->stackSize = nlmlex_get_number ((yyvsp[(2) - (2)].string));
1827 free ((yyvsp[(2) - (2)].string));
1832 #line 337 "nlmheader.y"
1834 start_procedure = (yyvsp[(2) - (2)].string);
1839 #line 341 "nlmheader.y"
1841 fixed_hdr->flags |= 0x4;
1846 #line 345 "nlmheader.y"
1850 len = strlen ((yyvsp[(2) - (2)].string));
1851 if (len >= NLM_MAX_THREAD_NAME_LENGTH)
1853 nlmheader_warn (_("thread name is too long"),
1854 NLM_MAX_THREAD_NAME_LENGTH);
1855 len = NLM_MAX_THREAD_NAME_LENGTH;
1857 var_hdr->threadNameLength = len;
1858 strncpy (var_hdr->threadName, (yyvsp[(2) - (2)].string), len);
1859 var_hdr->threadName[len] = '\0';
1860 free ((yyvsp[(2) - (2)].string));
1865 #line 361 "nlmheader.y"
1867 fixed_hdr->moduleType = nlmlex_get_number ((yyvsp[(2) - (2)].string));
1868 free ((yyvsp[(2) - (2)].string));
1873 #line 366 "nlmheader.y"
1880 #line 370 "nlmheader.y"
1884 strncpy (version_hdr->stamp, "VeRsIoN#", 8);
1885 version_hdr->majorVersion = nlmlex_get_number ((yyvsp[(2) - (4)].string));
1886 val = nlmlex_get_number ((yyvsp[(3) - (4)].string));
1887 if (val < 0 || val > 99)
1888 nlmheader_warn (_("illegal minor version number (must be between 0 and 99)"),
1891 version_hdr->minorVersion = val;
1892 val = nlmlex_get_number ((yyvsp[(4) - (4)].string));
1894 nlmheader_warn (_("illegal revision number (must be between 0 and 26)"),
1897 version_hdr->revision = 0;
1899 version_hdr->revision = val;
1900 free ((yyvsp[(2) - (4)].string));
1901 free ((yyvsp[(3) - (4)].string));
1902 free ((yyvsp[(4) - (4)].string));
1907 #line 394 "nlmheader.y"
1911 strncpy (version_hdr->stamp, "VeRsIoN#", 8);
1912 version_hdr->majorVersion = nlmlex_get_number ((yyvsp[(2) - (3)].string));
1913 val = nlmlex_get_number ((yyvsp[(3) - (3)].string));
1914 if (val < 0 || val > 99)
1915 nlmheader_warn (_("illegal minor version number (must be between 0 and 99)"),
1918 version_hdr->minorVersion = val;
1919 version_hdr->revision = 0;
1920 free ((yyvsp[(2) - (3)].string));
1921 free ((yyvsp[(3) - (3)].string));
1926 #line 410 "nlmheader.y"
1928 rpc_file = (yyvsp[(2) - (2)].string);
1933 #line 419 "nlmheader.y"
1935 (yyval.list) = NULL;
1940 #line 423 "nlmheader.y"
1942 (yyval.list) = (yyvsp[(1) - (1)].list);
1947 #line 434 "nlmheader.y"
1949 (yyval.list) = string_list_cons ((yyvsp[(1) - (1)].string), NULL);
1954 #line 438 "nlmheader.y"
1956 (yyval.list) = NULL;
1961 #line 442 "nlmheader.y"
1963 (yyval.list) = string_list_append1 ((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].string));
1968 #line 446 "nlmheader.y"
1970 (yyval.list) = (yyvsp[(1) - (2)].list);
1975 #line 455 "nlmheader.y"
1977 if (symbol_prefix != NULL)
1978 free (symbol_prefix);
1979 symbol_prefix = (yyvsp[(2) - (3)].string);
1984 #line 466 "nlmheader.y"
1986 if (symbol_prefix == NULL)
1987 (yyval.string) = (yyvsp[(1) - (1)].string);
1990 (yyval.string) = xmalloc (strlen (symbol_prefix) + strlen ((yyvsp[(1) - (1)].string)) + 2);
1991 sprintf ((yyval.string), "%s@%s", symbol_prefix, (yyvsp[(1) - (1)].string));
1992 free ((yyvsp[(1) - (1)].string));
1998 #line 482 "nlmheader.y"
2000 (yyval.list) = NULL;
2005 #line 486 "nlmheader.y"
2007 (yyval.list) = string_list_cons ((yyvsp[(1) - (2)].string), (yyvsp[(2) - (2)].list));
2012 /* Line 1267 of yacc.c. */
2013 #line 2014 "nlmheader.c"
2016 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2020 YY_STACK_PRINT (yyss, yyssp);
2025 /* Now `shift' the result of the reduction. Determine what state
2026 that goes to, based on the state we popped back to and the rule
2027 number reduced by. */
2031 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2032 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2033 yystate = yytable[yystate];
2035 yystate = yydefgoto[yyn - YYNTOKENS];
2040 /*------------------------------------.
2041 | yyerrlab -- here on detecting error |
2042 `------------------------------------*/
2044 /* If not already recovering from an error, report this error. */
2048 #if ! YYERROR_VERBOSE
2049 yyerror (YY_("syntax error"));
2052 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
2053 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
2055 YYSIZE_T yyalloc = 2 * yysize;
2056 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
2057 yyalloc = YYSTACK_ALLOC_MAXIMUM;
2058 if (yymsg != yymsgbuf)
2059 YYSTACK_FREE (yymsg);
2060 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
2062 yymsg_alloc = yyalloc;
2066 yymsg_alloc = sizeof yymsgbuf;
2070 if (0 < yysize && yysize <= yymsg_alloc)
2072 (void) yysyntax_error (yymsg, yystate, yychar);
2077 yyerror (YY_("syntax error"));
2079 goto yyexhaustedlab;
2087 if (yyerrstatus == 3)
2089 /* If just tried and failed to reuse look-ahead token after an
2090 error, discard it. */
2092 if (yychar <= YYEOF)
2094 /* Return failure if at end of input. */
2095 if (yychar == YYEOF)
2100 yydestruct ("Error: discarding",
2106 /* Else will try to reuse look-ahead token after shifting the error
2111 /*---------------------------------------------------.
2112 | yyerrorlab -- error raised explicitly by YYERROR. |
2113 `---------------------------------------------------*/
2116 /* Pacify compilers like GCC when the user code never invokes
2117 YYERROR and the label yyerrorlab therefore never appears in user
2119 if (/*CONSTCOND*/ 0)
2122 /* Do not reclaim the symbols of the rule which action triggered
2126 YY_STACK_PRINT (yyss, yyssp);
2131 /*-------------------------------------------------------------.
2132 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2133 `-------------------------------------------------------------*/
2135 yyerrstatus = 3; /* Each real token shifted decrements this. */
2139 yyn = yypact[yystate];
2140 if (yyn != YYPACT_NINF)
2143 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2151 /* Pop the current state because it cannot handle the error token. */
2156 yydestruct ("Error: popping",
2157 yystos[yystate], yyvsp);
2160 YY_STACK_PRINT (yyss, yyssp);
2169 /* Shift the error token. */
2170 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2176 /*-------------------------------------.
2177 | yyacceptlab -- YYACCEPT comes here. |
2178 `-------------------------------------*/
2183 /*-----------------------------------.
2184 | yyabortlab -- YYABORT comes here. |
2185 `-----------------------------------*/
2191 /*-------------------------------------------------.
2192 | yyexhaustedlab -- memory exhaustion comes here. |
2193 `-------------------------------------------------*/
2195 yyerror (YY_("memory exhausted"));
2201 if (yychar != YYEOF && yychar != YYEMPTY)
2202 yydestruct ("Cleanup: discarding lookahead",
2204 /* Do not reclaim the symbols of the rule which action triggered
2205 this YYABORT or YYACCEPT. */
2207 YY_STACK_PRINT (yyss, yyssp);
2208 while (yyssp != yyss)
2210 yydestruct ("Cleanup: popping",
2211 yystos[*yyssp], yyvsp);
2216 YYSTACK_FREE (yyss);
2219 if (yymsg != yymsgbuf)
2220 YYSTACK_FREE (yymsg);
2222 /* Make sure YYID is used. */
2223 return YYID (yyresult);
2227 #line 491 "nlmheader.y"
2230 /* If strerror is just a macro, we want to use the one from libiberty
2231 since it will handle undefined values. */
2233 extern char *strerror (int);
2235 /* The lexer is simple, too simple for flex. Keywords are only
2236 recognized at the start of lines. Everything else must be an
2237 argument. A comma is treated as whitespace. */
2239 /* The states the lexer can be in. */
2243 /* At the beginning of a line. */
2245 /* In the middle of a line. */
2249 /* We need to keep a stack of files to handle file inclusion. */
2253 /* The file to read from. */
2255 /* The name of the file. */
2257 /* The current line number. */
2259 /* The current state. */
2260 enum lex_state state;
2261 /* The next file on the stack. */
2265 /* The current input file. */
2267 static struct input current;
2269 /* The character which introduces comments. */
2270 #define COMMENT_CHAR '#'
2272 /* Start the lexer going on the main input file. */
2275 nlmlex_file (const char *name)
2277 current.next = NULL;
2278 return nlmlex_file_open (name);
2281 /* Start the lexer going on a subsidiary input file. */
2284 nlmlex_file_push (const char *name)
2288 push = (struct input *) xmalloc (sizeof (struct input));
2290 if (nlmlex_file_open (name))
2291 current.next = push;
2299 /* Start lexing from a file. */
2302 nlmlex_file_open (const char *name)
2304 current.file = fopen (name, "r");
2305 if (current.file == NULL)
2307 fprintf (stderr, "%s:%s: %s\n", program_name, name, strerror (errno));
2311 current.name = xstrdup (name);
2313 current.state = BEGINNING_OF_LINE;
2317 /* Table used to turn keywords into tokens. */
2319 struct keyword_tokens_struct
2321 const char *keyword;
2325 static struct keyword_tokens_struct keyword_tokens[] =
2328 { "CODESTART", CODESTART },
2329 { "COPYRIGHT", COPYRIGHT },
2330 { "CUSTOM", CUSTOM },
2332 { "DEBUG", DEBUG_K },
2333 { "DESCRIPTION", DESCRIPTION },
2335 { "EXPORT", EXPORT },
2336 { "FLAG_ON", FLAG_ON },
2337 { "FLAG_OFF", FLAG_OFF },
2338 { "FULLMAP", FULLMAP },
2340 { "IMPORT", IMPORT },
2343 { "MESSAGES", MESSAGES },
2344 { "MODULE", MODULE },
2345 { "MULTIPLE", MULTIPLE },
2346 { "OS_DOMAIN", OS_DOMAIN },
2347 { "OUTPUT", OUTPUT },
2348 { "PSEUDOPREEMPTION", PSEUDOPREEMPTION },
2349 { "REENTRANT", REENTRANT },
2350 { "SCREENNAME", SCREENNAME },
2351 { "SHARELIB", SHARELIB },
2353 { "STACKSIZE", STACK },
2355 { "SYNCHRONIZE", SYNCHRONIZE },
2356 { "THREADNAME", THREADNAME },
2358 { "VERBOSE", VERBOSE },
2359 { "VERSION", VERSIONK },
2360 { "XDCDATA", XDCDATA }
2363 #define KEYWORD_COUNT (sizeof (keyword_tokens) / sizeof (keyword_tokens[0]))
2365 /* The lexer accumulates strings in these variables. */
2366 static char *lex_buf;
2367 static int lex_size;
2370 /* Start accumulating strings into the buffer. */
2371 #define BUF_INIT() \
2372 ((void) (lex_buf != NULL ? lex_pos = 0 : nlmlex_buf_init ()))
2375 nlmlex_buf_init (void)
2378 lex_buf = xmalloc (lex_size + 1);
2383 /* Finish a string in the buffer. */
2384 #define BUF_FINISH() ((void) (lex_buf[lex_pos] = '\0'))
2386 /* Accumulate a character into the buffer. */
2387 #define BUF_ADD(c) \
2388 ((void) (lex_pos < lex_size \
2389 ? lex_buf[lex_pos++] = (c) \
2390 : nlmlex_buf_add (c)))
2393 nlmlex_buf_add (int c)
2395 if (lex_pos >= lex_size)
2398 lex_buf = xrealloc (lex_buf, lex_size + 1);
2401 return lex_buf[lex_pos++] = c;
2404 /* The lexer proper. This is called by the bison generated parsing
2414 c = getc (current.file);
2416 /* Commas are treated as whitespace characters. */
2417 while (ISSPACE (c) || c == ',')
2419 current.state = IN_LINE;
2423 current.state = BEGINNING_OF_LINE;
2425 c = getc (current.file);
2428 /* At the end of the file we either pop to the previous file or
2432 fclose (current.file);
2433 free (current.name);
2434 if (current.next == NULL)
2440 next = current.next;
2447 /* A comment character always means to drop everything until the
2449 if (c == COMMENT_CHAR)
2453 c = getc (current.file);
2457 current.state = BEGINNING_OF_LINE;
2461 /* An '@' introduces an include file. */
2466 c = getc (current.file);
2470 while (ISSPACE (c));
2472 while (! ISSPACE (c) && c != EOF)
2475 c = getc (current.file);
2479 ungetc (c, current.file);
2481 nlmlex_file_push (lex_buf);
2485 /* A non-space character at the start of a line must be the start of
2487 if (current.state == BEGINNING_OF_LINE)
2490 while (ISALNUM (c) || c == '_')
2492 BUF_ADD (TOUPPER (c));
2493 c = getc (current.file);
2497 if (c != EOF && ! ISSPACE (c) && c != ',')
2499 nlmheader_identify ();
2500 fprintf (stderr, _("%s:%d: illegal character in keyword: %c\n"),
2501 current.name, current.lineno, c);
2507 for (i = 0; i < KEYWORD_COUNT; i++)
2509 if (lex_buf[0] == keyword_tokens[i].keyword[0]
2510 && strcmp (lex_buf, keyword_tokens[i].keyword) == 0)
2512 /* Pushing back the final whitespace avoids worrying
2514 ungetc (c, current.file);
2515 current.state = IN_LINE;
2516 return keyword_tokens[i].token;
2520 nlmheader_identify ();
2521 fprintf (stderr, _("%s:%d: unrecognized keyword: %s\n"),
2522 current.name, current.lineno, lex_buf);
2526 /* Treat the rest of this line as a comment. */
2527 ungetc (COMMENT_CHAR, current.file);
2531 /* Parentheses just represent themselves. */
2532 if (c == '(' || c == ')')
2535 /* Handle quoted strings. */
2536 if (c == '"' || c == '\'')
2542 start_lineno = current.lineno;
2544 c = getc (current.file);
2546 while (c != quote && c != EOF)
2551 c = getc (current.file);
2557 nlmheader_identify ();
2558 fprintf (stderr, _("%s:%d: end of file in quoted string\n"),
2559 current.name, start_lineno);
2563 /* FIXME: Possible memory leak. */
2564 yylval.string = xstrdup (lex_buf);
2565 return QUOTED_STRING;
2568 /* Gather a generic argument. */
2570 while (! ISSPACE (c)
2572 && c != COMMENT_CHAR
2577 c = getc (current.file);
2581 ungetc (c, current.file);
2583 /* FIXME: Possible memory leak. */
2584 yylval.string = xstrdup (lex_buf);
2588 /* Get a number from a string. */
2591 nlmlex_get_number (const char *s)
2596 ret = strtol (s, &send, 10);
2598 nlmheader_warn (_("bad number"), -1);
2602 /* Prefix the nlmconv warnings with a note as to where they come from.
2603 We don't use program_name on every warning, because then some
2604 versions of the emacs next-error function can't recognize the line
2608 nlmheader_identify (void)
2614 fprintf (stderr, _("%s: problems in NLM command language input:\n"),
2620 /* Issue a warning. */
2623 nlmheader_warn (const char *s, int imax)
2625 nlmheader_identify ();
2626 fprintf (stderr, "%s:%d: %s", current.name, current.lineno, s);
2628 fprintf (stderr, " (max %d)", imax);
2629 fprintf (stderr, "\n");
2632 /* Report an error. */
2635 nlmheader_error (const char *s)
2637 nlmheader_warn (s, -1);
2641 /* Add a string to a string list. */
2643 static struct string_list *
2644 string_list_cons (char *s, struct string_list *l)
2646 struct string_list *ret;
2648 ret = (struct string_list *) xmalloc (sizeof (struct string_list));
2654 /* Append a string list to another string list. */
2656 static struct string_list *
2657 string_list_append (struct string_list *l1, struct string_list *l2)
2659 register struct string_list **pp;
2661 for (pp = &l1; *pp != NULL; pp = &(*pp)->next)
2667 /* Append a string to a string list. */
2669 static struct string_list *
2670 string_list_append1 (struct string_list *l, char *s)
2672 struct string_list *n;
2673 register struct string_list **pp;
2675 n = (struct string_list *) xmalloc (sizeof (struct string_list));
2678 for (pp = &l; *pp != NULL; pp = &(*pp)->next)
2684 /* Duplicate a string in memory. */
2687 xstrdup (const char *s)
2693 ret = xmalloc (len + 1);