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