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