From 7a48944835713f5b5e0802fa2f8a3187ffd9eca6 Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Tue, 19 Mar 2024 17:40:42 +0800 Subject: [PATCH] HACK: Support using 'endmenuconfig' to quit menuconfig Signed-off-by: Jeffy Chen --- kconf_id.c | 1 + menu.c | 6 + zconf.tab.c_shipped | 802 +++++++++++++++++++++++--------------------- zconf.y | 20 +- 4 files changed, 437 insertions(+), 392 deletions(-) diff --git a/kconf_id.c b/kconf_id.c index 3ea9c5f..7767bea 100644 --- a/kconf_id.c +++ b/kconf_id.c @@ -9,6 +9,7 @@ static struct kconf_id kconf_id_array[] = { { "comment", T_COMMENT, TF_COMMAND }, { "config", T_CONFIG, TF_COMMAND }, { "menuconfig", T_MENUCONFIG, TF_COMMAND }, + { "endmenuconfig", T_ENDMENUCONFIG, TF_COMMAND }, { "help", T_HELP, TF_COMMAND }, { "---help---", T_HELP, TF_COMMAND }, { "if", T_IF, TF_COMMAND|TF_PARAM }, diff --git a/menu.c b/menu.c index 5c5c137..0d9951d 100644 --- a/menu.c +++ b/menu.c @@ -452,6 +452,12 @@ void menu_finalize(struct menu *parent) /* Examine consecutive elements after sym */ last_menu = NULL; for (menu = parent->next; menu; menu = menu->next) { + /* HACK: Use empty entry to quit menuconfig */ + if (parent->prompt && parent->prompt->type == P_MENU) { + if (!menu->prompt && !menu->sym && !menu->dep) + break; + } + dep = menu->prompt ? menu->prompt->visible.expr : menu->dep; if (!expr_contains_symbol(dep, sym)) /* No dependency, quit */ diff --git a/zconf.tab.c_shipped b/zconf.tab.c_shipped index c5a4a5a..571e0a5 100644 --- a/zconf.tab.c_shipped +++ b/zconf.tab.c_shipped @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 3.3.2. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation, + Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -40,11 +41,14 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ +/* Undocumented macros, especially those whose name start with YY_, + are private implementation details. Do not rely on them. */ + /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.0.4" +#define YYBISON_VERSION "3.3.2" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -61,7 +65,7 @@ -/* Copy the first part of user declarations. */ +/* First part of user prologue. */ /* @@ -90,6 +94,7 @@ static void yyerror(const char *err); static void zconfprint(const char *err, ...); static void zconf_error(const char *err, ...); static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken); +static const char *zconf_tokenname(int token); struct symbol *symbol_hash[SYMBOL_HASHSIZE]; @@ -97,12 +102,15 @@ static struct menu *current_menu, *current_entry; - # ifndef YY_NULLPTR -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULLPTR nullptr +# if defined __cplusplus +# if 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif # else -# define YY_NULLPTR 0 +# define YY_NULLPTR ((void*)0) # endif # endif @@ -137,35 +145,36 @@ extern int yydebug; T_COMMENT = 264, T_CONFIG = 265, T_MENUCONFIG = 266, - T_HELP = 267, - T_HELPTEXT = 268, - T_IF = 269, - T_ENDIF = 270, - T_DEPENDS = 271, - T_OPTIONAL = 272, - T_PROMPT = 273, - T_TYPE = 274, - T_DEFAULT = 275, - T_SELECT = 276, - T_IMPLY = 277, - T_RANGE = 278, - T_VISIBLE = 279, - T_OPTION = 280, - T_ON = 281, - T_WORD = 282, - T_WORD_QUOTE = 283, - T_UNEQUAL = 284, - T_LESS = 285, - T_LESS_EQUAL = 286, - T_GREATER = 287, - T_GREATER_EQUAL = 288, - T_CLOSE_PAREN = 289, - T_OPEN_PAREN = 290, - T_EOL = 291, - T_OR = 292, - T_AND = 293, - T_EQUAL = 294, - T_NOT = 295 + T_ENDMENUCONFIG = 267, + T_HELP = 268, + T_HELPTEXT = 269, + T_IF = 270, + T_ENDIF = 271, + T_DEPENDS = 272, + T_OPTIONAL = 273, + T_PROMPT = 274, + T_TYPE = 275, + T_DEFAULT = 276, + T_SELECT = 277, + T_IMPLY = 278, + T_RANGE = 279, + T_VISIBLE = 280, + T_OPTION = 281, + T_ON = 282, + T_WORD = 283, + T_WORD_QUOTE = 284, + T_UNEQUAL = 285, + T_LESS = 286, + T_LESS_EQUAL = 287, + T_GREATER = 288, + T_GREATER_EQUAL = 289, + T_CLOSE_PAREN = 290, + T_OPEN_PAREN = 291, + T_EOL = 292, + T_OR = 293, + T_AND = 294, + T_EQUAL = 295, + T_NOT = 296 }; #endif @@ -198,7 +207,7 @@ int yyparse (void); -/* Copy the second part of user declarations. */ +/* Second part of user prologue. */ /* Include kconf_id.c here so it can see the token constants. */ @@ -225,13 +234,13 @@ typedef signed char yytype_int8; #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else -typedef unsigned short int yytype_uint16; +typedef unsigned short yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else -typedef short int yytype_int16; +typedef short yytype_int16; #endif #ifndef YYSIZE_T @@ -243,7 +252,7 @@ typedef short int yytype_int16; # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else -# define YYSIZE_T unsigned int +# define YYSIZE_T unsigned # endif #endif @@ -279,15 +288,6 @@ typedef short int yytype_int16; # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) #endif -#if !defined _Noreturn \ - && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) -# if defined _MSC_VER && 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) -# else -# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) -# endif -#endif - /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) @@ -295,7 +295,7 @@ typedef short int yytype_int16; # define YYUSE(E) /* empty */ #endif -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ _Pragma ("GCC diagnostic push") \ @@ -446,27 +446,27 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 11 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 325 +#define YYLAST 341 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 41 +#define YYNTOKENS 42 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 52 +#define YYNNTS 54 /* YYNRULES -- Number of rules. */ -#define YYNRULES 126 +#define YYNRULES 129 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 206 +#define YYNSTATES 210 -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 295 +#define YYMAXUTOK 296 +/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, with out-of-bounds checking. */ #define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ + as returned by yylex. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -498,26 +498,26 @@ static const yytype_uint8 yytranslate[] = 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40 + 35, 36, 37, 38, 39, 40, 41 }; #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 110, 110, 110, 112, 112, 116, 124, 134, 136, - 137, 138, 139, 140, 141, 145, 149, 149, 149, 149, - 149, 149, 149, 149, 149, 153, 154, 155, 156, 157, - 158, 162, 163, 169, 176, 181, 188, 197, 199, 200, - 201, 202, 203, 204, 207, 215, 221, 231, 237, 243, - 249, 252, 254, 267, 268, 273, 283, 288, 296, 299, - 301, 302, 303, 304, 305, 308, 314, 325, 331, 341, - 343, 348, 356, 364, 367, 369, 370, 371, 376, 383, - 388, 396, 399, 401, 402, 403, 406, 415, 422, 427, - 433, 451, 453, 454, 455, 458, 466, 468, 469, 472, - 479, 481, 486, 487, 490, 491, 492, 496, 497, 500, - 501, 504, 505, 506, 507, 508, 509, 510, 511, 512, - 513, 514, 518, 520, 521, 524, 525 + 0, 112, 112, 112, 114, 114, 118, 126, 136, 138, + 139, 140, 141, 142, 143, 147, 151, 151, 151, 151, + 151, 151, 151, 151, 151, 155, 156, 157, 158, 159, + 160, 161, 165, 166, 172, 179, 184, 191, 200, 202, + 203, 204, 205, 206, 207, 210, 218, 224, 234, 240, + 246, 252, 255, 257, 270, 271, 276, 289, 294, 304, + 309, 317, 320, 322, 323, 324, 325, 326, 329, 335, + 346, 352, 362, 364, 369, 377, 385, 388, 390, 391, + 392, 397, 404, 409, 417, 420, 422, 423, 424, 427, + 436, 443, 448, 454, 472, 474, 475, 476, 479, 487, + 489, 490, 493, 500, 502, 507, 508, 511, 512, 513, + 517, 518, 521, 522, 525, 526, 527, 528, 529, 530, + 531, 532, 533, 534, 535, 539, 541, 542, 545, 546 }; #endif @@ -528,23 +528,24 @@ static const char *const yytname[] = { "$end", "error", "$undefined", "T_MAINMENU", "T_MENU", "T_ENDMENU", "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG", - "T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS", - "T_OPTIONAL", "T_PROMPT", "T_TYPE", "T_DEFAULT", "T_SELECT", "T_IMPLY", - "T_RANGE", "T_VISIBLE", "T_OPTION", "T_ON", "T_WORD", "T_WORD_QUOTE", - "T_UNEQUAL", "T_LESS", "T_LESS_EQUAL", "T_GREATER", "T_GREATER_EQUAL", - "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_EOL", "T_OR", "T_AND", "T_EQUAL", - "T_NOT", "$accept", "input", "start", "mainmenu_stmt", - "no_mainmenu_stmt", "stmt_list", "option_name", "common_stmt", - "option_error", "config_entry_start", "config_stmt", + "T_MENUCONFIG", "T_ENDMENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", + "T_ENDIF", "T_DEPENDS", "T_OPTIONAL", "T_PROMPT", "T_TYPE", "T_DEFAULT", + "T_SELECT", "T_IMPLY", "T_RANGE", "T_VISIBLE", "T_OPTION", "T_ON", + "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL", "T_LESS", "T_LESS_EQUAL", + "T_GREATER", "T_GREATER_EQUAL", "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_EOL", + "T_OR", "T_AND", "T_EQUAL", "T_NOT", "$accept", "input", "start", + "mainmenu_stmt", "no_mainmenu_stmt", "stmt_list", "option_name", + "common_stmt", "option_error", "config_entry_start", "config_stmt", "menuconfig_entry_start", "menuconfig_stmt", "config_option_list", "config_option", "symbol_option", "symbol_option_list", - "symbol_option_arg", "choice", "choice_entry", "choice_end", - "choice_stmt", "choice_option_list", "choice_option", "choice_block", - "if_entry", "if_end", "if_stmt", "if_block", "menu", "menu_entry", - "menu_end", "menu_stmt", "menu_block", "source_stmt", "comment", - "comment_stmt", "help_start", "help", "depends_list", "depends", - "visibility_list", "visible", "prompt_stmt_opt", "prompt", "end", "nl", - "if_expr", "expr", "nonconst_symbol", "symbol", "word_opt", YY_NULLPTR + "symbol_option_arg", "endmenuconfig", "endmenuconfig_stmt", "choice", + "choice_entry", "choice_end", "choice_stmt", "choice_option_list", + "choice_option", "choice_block", "if_entry", "if_end", "if_stmt", + "if_block", "menu", "menu_entry", "menu_end", "menu_stmt", "menu_block", + "source_stmt", "comment", "comment_stmt", "help_start", "help", + "depends_list", "depends", "visibility_list", "visible", + "prompt_stmt_opt", "prompt", "end", "nl", "if_expr", "expr", + "nonconst_symbol", "symbol", "word_opt", YY_NULLPTR }; #endif @@ -557,16 +558,16 @@ static const yytype_uint16 yytoknum[] = 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295 + 295, 296 }; # endif -#define YYPACT_NINF -92 +#define YYPACT_NINF -93 #define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-92))) + (!!((Yystate) == (-93))) -#define YYTABLE_NINF -89 +#define YYTABLE_NINF -92 #define yytable_value_is_error(Yytable_value) \ 0 @@ -575,27 +576,27 @@ static const yytype_uint16 yytoknum[] = STATE-NUM. */ static const yytype_int16 yypact[] = { - 20, 33, -92, 16, -92, -92, -92, 21, -92, -92, - 29, -92, 152, 186, -92, -92, 40, 67, 33, 71, - 33, 42, 80, 33, 78, 78, 31, 82, -92, -92, - -92, -92, -92, -92, -92, -92, -92, 120, -92, 131, - -92, -92, -92, -92, -92, -92, -92, -92, -92, -92, - -92, -92, -92, -92, -92, -92, -92, -92, 109, -92, - 118, -92, 128, -92, 129, -92, 141, 142, -92, 31, - 31, 74, -92, 69, -92, 144, 145, 28, 119, 248, - 286, 77, 38, 77, 219, -92, -92, -92, -92, -92, - -92, -7, -92, 31, 31, 40, 52, 52, 52, 52, - 52, 52, -92, -92, 146, 147, 158, 33, 33, 31, - 78, 78, 52, -92, 184, -92, -92, -92, -92, 176, - -92, -92, 162, 33, 33, 78, -92, -92, -92, -92, - -92, -92, -92, -92, -92, -92, -92, -92, -92, 197, - -92, 272, -92, -92, -92, -92, -92, -92, -92, -92, - -92, -92, 174, -92, -92, -92, -92, -92, -92, -92, - -92, -92, 31, 197, 178, 197, 59, 197, 197, 52, - 27, 179, -92, -92, 197, 180, 197, 31, -92, 111, - 181, -92, -92, 182, 185, 195, 197, 193, -92, -92, - 208, -92, 209, 113, -92, -92, -92, -92, -92, 211, - 33, -92, -92, -92, -92, -92 + 20, 116, -93, 18, -93, -93, -93, 26, -93, -93, + -33, -93, 146, 189, -93, -93, 19, 34, 116, 47, + 116, 2, 55, 116, 32, 32, 58, 57, 66, -93, + -93, -93, -93, -93, -93, -93, -93, -93, 114, -93, + 147, -93, -93, -93, -93, -93, -93, -93, -93, -93, + -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, + -93, 102, -93, 141, -93, 142, -93, 143, -93, 144, + 145, -93, -93, 57, 57, 104, -93, 74, -93, 148, + 149, 27, 112, 253, 64, 301, 29, 301, 223, -93, + -93, -93, -93, -93, -93, 23, -93, 57, 57, 19, + 131, 131, 131, 131, 131, 131, -93, -93, 150, 154, + 157, 116, 116, 57, 32, 32, 131, -93, 187, -93, + -93, -93, -93, 178, -93, -93, 165, 116, 116, 32, + -93, -93, -93, -93, -93, -93, -93, -93, -93, -93, + -93, -93, -93, 200, -93, 287, -93, -93, -93, -93, + -93, -93, -93, -93, -93, -93, 177, -93, -93, -93, + -93, -93, -93, -93, -93, -93, 57, 200, 181, 200, + 44, 200, 200, 131, -23, 182, -93, -93, 200, 183, + 200, 57, -93, 138, 184, -93, -93, 185, 188, 199, + 200, 197, -93, -93, 212, -93, 213, 134, -93, -93, + -93, -93, -93, 215, 116, -93, -93, -93, -93, -93 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. @@ -603,49 +604,49 @@ static const yytype_int16 yypact[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 7, 0, 107, 0, 3, 8, 8, 7, 102, 103, - 0, 1, 0, 0, 108, 2, 6, 0, 0, 0, - 0, 125, 0, 0, 0, 0, 0, 0, 16, 21, - 17, 18, 23, 19, 20, 22, 24, 0, 25, 0, - 9, 37, 28, 37, 29, 59, 69, 10, 74, 26, - 96, 82, 11, 30, 91, 27, 12, 15, 0, 104, - 0, 126, 0, 105, 0, 122, 0, 0, 124, 0, - 0, 0, 123, 111, 106, 0, 0, 0, 0, 0, - 0, 0, 91, 0, 0, 78, 86, 55, 87, 33, - 35, 0, 119, 0, 0, 71, 0, 0, 0, 0, - 0, 0, 13, 14, 0, 0, 0, 0, 100, 0, - 0, 0, 0, 51, 0, 43, 42, 38, 39, 0, - 41, 40, 0, 0, 100, 0, 63, 64, 60, 62, - 61, 70, 58, 57, 75, 77, 73, 76, 72, 109, - 98, 0, 97, 83, 85, 81, 84, 80, 93, 94, - 92, 118, 120, 121, 117, 112, 113, 114, 115, 116, - 32, 89, 0, 109, 0, 109, 109, 109, 109, 0, - 0, 0, 90, 67, 109, 0, 109, 0, 99, 0, - 0, 44, 101, 0, 0, 0, 109, 53, 50, 31, - 0, 66, 0, 110, 95, 45, 46, 47, 48, 0, - 0, 52, 65, 68, 49, 54 + 7, 0, 110, 0, 3, 8, 8, 7, 105, 106, + 0, 1, 0, 0, 111, 2, 6, 0, 0, 0, + 0, 128, 0, 0, 0, 0, 0, 0, 0, 16, + 21, 17, 18, 23, 19, 20, 22, 24, 0, 25, + 0, 9, 38, 28, 38, 29, 57, 30, 62, 72, + 10, 77, 26, 99, 85, 11, 31, 94, 27, 12, + 15, 0, 107, 0, 129, 0, 108, 0, 125, 0, + 0, 56, 127, 0, 0, 0, 126, 114, 109, 0, + 0, 0, 0, 0, 0, 0, 94, 0, 0, 81, + 89, 58, 90, 34, 36, 0, 122, 0, 0, 74, + 0, 0, 0, 0, 0, 0, 13, 14, 0, 0, + 0, 0, 103, 0, 0, 0, 0, 52, 0, 44, + 43, 39, 40, 0, 42, 41, 0, 0, 103, 0, + 66, 67, 63, 65, 64, 73, 61, 60, 78, 80, + 76, 79, 75, 112, 101, 0, 100, 86, 88, 84, + 87, 83, 96, 97, 95, 121, 123, 124, 120, 115, + 116, 117, 118, 119, 33, 92, 0, 112, 0, 112, + 112, 112, 112, 0, 0, 0, 93, 70, 112, 0, + 112, 0, 102, 0, 0, 45, 104, 0, 0, 0, + 112, 54, 51, 32, 0, 69, 0, 113, 98, 46, + 47, 48, 49, 0, 0, 53, 68, 71, 50, 55 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -92, -92, 241, -92, -92, 244, -92, -13, -66, -92, - -92, -92, -92, 218, -92, -92, -92, -92, -92, -92, - -92, -69, -92, -92, -92, -92, -92, -92, -92, -92, - -92, -92, 12, -92, -92, -92, -92, -92, 172, 170, - -64, -92, -92, 148, -1, 34, 1, 139, -68, -21, - -91, -92 + -93, -93, 246, -93, -93, 249, -93, 3, -68, -93, + -93, -93, -93, 231, -93, -93, -93, -93, -93, -93, + -93, -93, -93, -20, -93, -93, -93, -93, -93, -93, + -93, -93, -93, -93, 4, -93, -93, -93, -93, -93, + 173, 171, -67, -93, -93, 139, -1, 15, -7, 151, + -72, -18, -92, -93 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 3, 4, 5, 6, 12, 39, 40, 116, 41, - 42, 43, 44, 77, 117, 118, 170, 201, 45, 46, - 132, 47, 79, 128, 80, 48, 136, 49, 81, 50, - 51, 145, 52, 83, 53, 54, 55, 119, 120, 84, - 121, 82, 142, 164, 165, 56, 7, 178, 71, 72, - 73, 62 + -1, 3, 4, 5, 6, 12, 40, 41, 120, 42, + 43, 44, 45, 81, 121, 122, 174, 205, 46, 47, + 48, 49, 136, 50, 83, 132, 84, 51, 140, 52, + 85, 53, 54, 149, 55, 87, 56, 57, 58, 123, + 124, 88, 125, 86, 146, 168, 169, 59, 7, 182, + 75, 76, 77, 65 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If @@ -653,121 +654,125 @@ static const yytype_int16 yydefgoto[] = number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_int16 yytable[] = { - 10, 91, 92, 66, 67, 154, 155, 156, 157, 158, - 159, 16, 135, 127, 144, 130, 11, 58, 149, 60, - 150, 169, 64, 1, 1, 152, 153, 151, -34, 104, - 93, 94, -34, -34, -34, -34, -34, -34, -34, -34, - 105, 166, -34, -34, 106, -34, 107, 108, 109, 110, - 111, 112, -34, 113, 187, 114, 2, 14, 65, 68, - 8, 9, 139, 188, 115, 2, 69, 131, 134, 61, - 143, 70, 95, 177, 140, 149, 14, 150, 186, 65, - 68, 18, 19, 20, 21, 22, 23, 24, 25, 167, - 168, 26, 27, 137, 179, 146, 93, 94, 96, 97, - 98, 99, 100, 57, 176, 65, 163, 59, 101, 193, - 2, 93, 94, 38, 133, 138, 63, 147, 74, -36, - 104, 75, 174, -36, -36, -36, -36, -36, -36, -36, - -36, 105, 76, -36, -36, 106, -36, 107, 108, 109, - 110, 111, 112, -36, 113, 85, 114, 194, 93, 94, - 93, 94, -4, 17, 86, 115, 18, 19, 20, 21, - 22, 23, 24, 25, 87, 88, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, 36, 89, 90, 37, - 102, 103, 160, 161, 162, 171, -5, 17, 38, 172, - 18, 19, 20, 21, 22, 23, 24, 25, 173, 205, - 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 177, 94, 37, 181, 189, 191, 195, 196, -88, - 104, 197, 38, -88, -88, -88, -88, -88, -88, -88, - -88, 198, 200, -88, -88, 106, -88, -88, -88, -88, - -88, -88, -88, -88, 202, 203, 114, 204, 15, 104, - 13, 129, 141, -56, -56, 148, -56, -56, -56, -56, - 105, 78, -56, -56, 106, 122, 123, 124, 125, 0, - 0, 0, 175, 104, 0, 114, -79, -79, -79, -79, - -79, -79, -79, -79, 126, 0, -79, -79, 106, 0, - 0, 19, 20, 0, 22, 23, 24, 25, 0, 114, - 26, 27, 180, 0, 182, 183, 184, 185, 148, 0, - 0, 0, 0, 190, 0, 192, 0, 0, 0, 0, - 0, 0, 38, 0, 0, 199 + 10, 95, 96, 16, 2, 191, 69, 70, 158, 159, + 160, 161, 162, 163, 192, 131, 134, 61, 11, 63, + 153, 154, 67, 1, 173, 156, 157, -35, 108, 1, + 64, -35, -35, -35, -35, -35, -35, -35, -35, -35, + 109, 170, -35, -35, 110, -35, 111, 112, 113, 114, + 115, 116, -35, 117, 143, 118, 14, 2, 155, 181, + 68, 97, 98, 14, 119, 139, 144, 148, 99, 19, + 20, 60, 22, 23, 24, 25, 26, 153, 154, 27, + 28, 190, 97, 98, 62, 68, 72, 135, 138, 141, + 147, 150, 66, 73, 183, 71, 171, 172, 74, 137, + 142, 39, 151, 78, 100, 101, 102, 103, 104, 197, + 167, 180, -37, 108, 105, 79, -37, -37, -37, -37, + -37, -37, -37, -37, -37, 109, 178, -37, -37, 110, + -37, 111, 112, 113, 114, 115, 116, -37, 117, 89, + 118, 2, 97, 98, 8, 9, -4, 17, 80, 119, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 68, + 72, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37, 97, 98, 38, 198, 97, 98, 90, 91, + 92, 93, 94, 39, 166, 106, 107, 164, 175, -5, + 17, 165, 176, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 177, 209, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 181, 98, 38, 185, 193, + 195, 199, 200, -91, 108, 201, 39, -91, -91, -91, + -91, -91, -91, -91, -91, -91, 202, 204, -91, -91, + 110, -91, -91, -91, -91, -91, -91, -91, -91, 206, + 207, 118, 208, 15, 108, 13, 133, 145, -59, -59, + 152, -59, -59, -59, -59, -59, 109, 179, -59, -59, + 110, 126, 127, 128, 129, 82, 0, 0, 0, 0, + 0, 118, 0, 0, 0, 0, 0, 0, 108, 0, + 130, -82, -82, -82, -82, -82, -82, -82, -82, -82, + 0, 0, -82, -82, 110, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 0, 118, 27, 28, 184, 0, + 186, 187, 188, 189, 152, 0, 0, 0, 0, 194, + 0, 196, 0, 0, 0, 0, 0, 0, 39, 0, + 0, 203 }; static const yytype_int16 yycheck[] = { - 1, 69, 70, 24, 25, 96, 97, 98, 99, 100, - 101, 10, 81, 79, 83, 79, 0, 18, 84, 20, - 84, 112, 23, 3, 3, 93, 94, 34, 0, 1, - 37, 38, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 109, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 27, 27, 36, 36, 27, 28, - 27, 28, 24, 36, 36, 36, 35, 80, 81, 27, - 83, 40, 71, 14, 36, 141, 36, 141, 169, 27, - 28, 4, 5, 6, 7, 8, 9, 10, 11, 110, - 111, 14, 15, 81, 162, 83, 37, 38, 29, 30, - 31, 32, 33, 36, 125, 27, 107, 36, 39, 177, - 36, 37, 38, 36, 80, 81, 36, 83, 36, 0, - 1, 1, 123, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 1, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 36, 27, 36, 37, 38, - 37, 38, 0, 1, 36, 36, 4, 5, 6, 7, - 8, 9, 10, 11, 36, 36, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 23, 24, 36, 36, 27, - 36, 36, 36, 36, 26, 1, 0, 1, 36, 13, - 4, 5, 6, 7, 8, 9, 10, 11, 36, 200, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 14, 38, 27, 36, 36, 36, 36, 36, 0, - 1, 36, 36, 4, 5, 6, 7, 8, 9, 10, - 11, 36, 39, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 36, 36, 27, 36, 7, 1, - 6, 79, 82, 5, 6, 36, 8, 9, 10, 11, - 12, 43, 14, 15, 16, 17, 18, 19, 20, -1, - -1, -1, 124, 1, -1, 27, 4, 5, 6, 7, - 8, 9, 10, 11, 36, -1, 14, 15, 16, -1, - -1, 5, 6, -1, 8, 9, 10, 11, -1, 27, - 14, 15, 163, -1, 165, 166, 167, 168, 36, -1, - -1, -1, -1, 174, -1, 176, -1, -1, -1, -1, - -1, -1, 36, -1, -1, 186 + 1, 73, 74, 10, 37, 28, 24, 25, 100, 101, + 102, 103, 104, 105, 37, 83, 83, 18, 0, 20, + 88, 88, 23, 3, 116, 97, 98, 0, 1, 3, + 28, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 113, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 25, 28, 37, 37, 35, 15, + 28, 38, 39, 37, 37, 85, 37, 87, 75, 5, + 6, 37, 8, 9, 10, 11, 12, 145, 145, 15, + 16, 173, 38, 39, 37, 28, 29, 84, 85, 85, + 87, 87, 37, 36, 166, 37, 114, 115, 41, 84, + 85, 37, 87, 37, 30, 31, 32, 33, 34, 181, + 111, 129, 0, 1, 40, 1, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 127, 15, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 37, + 28, 37, 38, 39, 28, 29, 0, 1, 1, 37, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 28, + 29, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 38, 39, 28, 37, 38, 39, 37, 37, + 37, 37, 37, 37, 27, 37, 37, 37, 1, 0, + 1, 37, 14, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 37, 204, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 15, 39, 28, 37, 37, + 37, 37, 37, 0, 1, 37, 37, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 37, 40, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 37, + 37, 28, 37, 7, 1, 6, 83, 86, 5, 6, + 37, 8, 9, 10, 11, 12, 13, 128, 15, 16, + 17, 18, 19, 20, 21, 44, -1, -1, -1, -1, + -1, 28, -1, -1, -1, -1, -1, -1, 1, -1, + 37, 4, 5, 6, 7, 8, 9, 10, 11, 12, + -1, -1, 15, 16, 17, 4, 5, 6, 7, 8, + 9, 10, 11, 12, -1, 28, 15, 16, 167, -1, + 169, 170, 171, 172, 37, -1, -1, -1, -1, 178, + -1, 180, -1, -1, -1, -1, -1, -1, 37, -1, + -1, 190 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 3, 36, 42, 43, 44, 45, 87, 27, 28, - 85, 0, 46, 46, 36, 43, 87, 1, 4, 5, - 6, 7, 8, 9, 10, 11, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 23, 24, 27, 36, 47, - 48, 50, 51, 52, 53, 59, 60, 62, 66, 68, - 70, 71, 73, 75, 76, 77, 86, 36, 85, 36, - 85, 27, 92, 36, 85, 27, 90, 90, 28, 35, - 40, 89, 90, 91, 36, 1, 1, 54, 54, 63, - 65, 69, 82, 74, 80, 36, 36, 36, 36, 36, - 36, 89, 89, 37, 38, 87, 29, 30, 31, 32, - 33, 39, 36, 36, 1, 12, 16, 18, 19, 20, - 21, 22, 23, 25, 27, 36, 49, 55, 56, 78, - 79, 81, 17, 18, 19, 20, 36, 49, 64, 79, - 81, 48, 61, 86, 48, 62, 67, 73, 86, 24, - 36, 80, 83, 48, 62, 72, 73, 86, 36, 49, - 81, 34, 89, 89, 91, 91, 91, 91, 91, 91, - 36, 36, 26, 85, 84, 85, 89, 90, 90, 91, - 57, 1, 13, 36, 85, 84, 90, 14, 88, 89, - 88, 36, 88, 88, 88, 88, 91, 27, 36, 36, - 88, 36, 88, 89, 36, 36, 36, 36, 36, 88, - 39, 58, 36, 36, 36, 85 + 0, 3, 37, 43, 44, 45, 46, 90, 28, 29, + 88, 0, 47, 47, 37, 44, 90, 1, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 15, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 28, 37, + 48, 49, 51, 52, 53, 54, 60, 61, 62, 63, + 65, 69, 71, 73, 74, 76, 78, 79, 80, 89, + 37, 88, 37, 88, 28, 95, 37, 88, 28, 93, + 93, 37, 29, 36, 41, 92, 93, 94, 37, 1, + 1, 55, 55, 66, 68, 72, 85, 77, 83, 37, + 37, 37, 37, 37, 37, 92, 92, 38, 39, 90, + 30, 31, 32, 33, 34, 40, 37, 37, 1, 13, + 17, 19, 20, 21, 22, 23, 24, 26, 28, 37, + 50, 56, 57, 81, 82, 84, 18, 19, 20, 21, + 37, 50, 67, 82, 84, 49, 64, 89, 49, 65, + 70, 76, 89, 25, 37, 83, 86, 49, 65, 75, + 76, 89, 37, 50, 84, 35, 92, 92, 94, 94, + 94, 94, 94, 94, 37, 37, 27, 88, 87, 88, + 92, 93, 93, 94, 58, 1, 14, 37, 88, 87, + 93, 15, 91, 92, 91, 37, 91, 91, 91, 91, + 94, 28, 37, 37, 91, 37, 91, 92, 37, 37, + 37, 37, 37, 91, 40, 59, 37, 37, 37, 88 }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 41, 42, 42, 43, 43, 44, 45, 46, 46, - 46, 46, 46, 46, 46, 46, 47, 47, 47, 47, - 47, 47, 47, 47, 47, 48, 48, 48, 48, 48, - 48, 49, 49, 50, 51, 52, 53, 54, 54, 54, - 54, 54, 54, 54, 55, 55, 55, 55, 55, 55, - 56, 57, 57, 58, 58, 59, 60, 61, 62, 63, - 63, 63, 63, 63, 63, 64, 64, 64, 64, 65, - 65, 66, 67, 68, 69, 69, 69, 69, 70, 71, - 72, 73, 74, 74, 74, 74, 75, 76, 77, 78, - 79, 80, 80, 80, 80, 81, 82, 82, 82, 83, - 84, 84, 85, 85, 86, 86, 86, 87, 87, 88, - 88, 89, 89, 89, 89, 89, 89, 89, 89, 89, - 89, 89, 90, 91, 91, 92, 92 + 0, 42, 43, 43, 44, 44, 45, 46, 47, 47, + 47, 47, 47, 47, 47, 47, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 49, 49, 49, 49, 49, + 49, 49, 50, 50, 51, 52, 53, 54, 55, 55, + 55, 55, 55, 55, 55, 56, 56, 56, 56, 56, + 56, 57, 58, 58, 59, 59, 60, 61, 62, 63, + 64, 65, 66, 66, 66, 66, 66, 66, 67, 67, + 67, 67, 68, 68, 69, 70, 71, 72, 72, 72, + 72, 73, 74, 75, 76, 77, 77, 77, 77, 78, + 79, 80, 81, 82, 83, 83, 83, 83, 84, 85, + 85, 85, 86, 87, 87, 88, 88, 89, 89, 89, + 90, 90, 91, 91, 92, 92, 92, 92, 92, 92, + 92, 92, 92, 92, 92, 93, 94, 94, 95, 95 }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ @@ -776,16 +781,16 @@ static const yytype_uint8 yyr2[] = 0, 2, 2, 1, 2, 2, 3, 0, 0, 2, 2, 2, 2, 4, 4, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 3, 2, 3, 2, 3, 2, 0, 2, 2, - 2, 2, 2, 2, 3, 4, 4, 4, 4, 5, - 3, 0, 3, 0, 2, 3, 2, 1, 3, 0, - 2, 2, 2, 2, 2, 4, 3, 2, 4, 0, - 2, 3, 1, 3, 0, 2, 2, 2, 3, 3, - 1, 3, 0, 2, 2, 2, 3, 3, 2, 2, - 2, 0, 2, 2, 2, 4, 0, 2, 2, 2, - 0, 2, 1, 1, 2, 2, 2, 1, 2, 0, - 2, 1, 3, 3, 3, 3, 3, 3, 3, 2, - 3, 3, 1, 1, 1, 0, 1 + 1, 1, 3, 2, 3, 2, 3, 2, 0, 2, + 2, 2, 2, 2, 2, 3, 4, 4, 4, 4, + 5, 3, 0, 3, 0, 2, 2, 1, 3, 2, + 1, 3, 0, 2, 2, 2, 2, 2, 4, 3, + 2, 4, 0, 2, 3, 1, 3, 0, 2, 2, + 2, 3, 3, 1, 3, 0, 2, 2, 2, 3, + 3, 2, 2, 2, 0, 2, 2, 2, 4, 0, + 2, 2, 2, 0, 2, 1, 1, 2, 2, 2, + 1, 2, 0, 2, 1, 3, 3, 3, 3, 3, + 3, 3, 2, 3, 3, 1, 1, 1, 0, 1 }; @@ -801,22 +806,22 @@ static const yytype_uint8 yyr2[] = #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) +#define YYBACKUP(Token, Value) \ + do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ + while (0) /* Error token number */ #define YYTERROR 1 @@ -856,37 +861,37 @@ do { \ } while (0) -/*----------------------------------------. -| Print this symbol's value on YYOUTPUT. | -`----------------------------------------*/ +/*-----------------------------------. +| Print this symbol's value on YYO. | +`-----------------------------------*/ static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) { - FILE *yyo = yyoutput; - YYUSE (yyo); + FILE *yyoutput = yyo; + YYUSE (yyoutput); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); + YYPRINT (yyo, yytoknum[yytype], *yyvaluep); # endif YYUSE (yytype); } -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ +/*---------------------------. +| Print this symbol on YYO. | +`---------------------------*/ static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) { - YYFPRINTF (yyoutput, "%s %s (", + YYFPRINTF (yyo, "%s %s (", yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); - yy_symbol_value_print (yyoutput, yytype, yyvaluep); - YYFPRINTF (yyoutput, ")"); + yy_symbol_value_print (yyo, yytype, yyvaluep); + YYFPRINTF (yyo, ")"); } /*------------------------------------------------------------------. @@ -920,7 +925,7 @@ do { \ static void yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) { - unsigned long int yylno = yyrline[yyrule]; + unsigned long yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", @@ -931,7 +936,7 @@ yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) + &yyvsp[(yyi + 1) - (yynrhs)] ); YYFPRINTF (stderr, "\n"); } @@ -1035,7 +1040,10 @@ yytnamerr (char *yyres, const char *yystr) case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; - /* Fall through. */ + else + goto append; + + append: default: if (yyres) yyres[yyn] = *yyp; @@ -1053,7 +1061,7 @@ yytnamerr (char *yyres, const char *yystr) if (! yyres) return yystrlen (yystr); - return yystpcpy (yyres, yystr) - yyres; + return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres); } # endif @@ -1131,10 +1139,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yyarg[yycount++] = yytname[yyx]; { YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else return 2; - yysize = yysize1; } } } @@ -1146,6 +1154,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, case N: \ yyformat = S; \ break + default: /* Avoid compiler warnings. */ YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); @@ -1157,9 +1166,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, { YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else return 2; - yysize = yysize1; } if (*yymsg_alloc < yysize) @@ -1208,7 +1218,7 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN switch (yytype) { - case 60: /* choice_entry */ + case 63: /* choice_entry */ { fprintf(stderr, "%s:%d: missing end statement for this entry\n", @@ -1219,7 +1229,7 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) break; - case 66: /* if_entry */ + case 69: /* if_entry */ { fprintf(stderr, "%s:%d: missing end statement for this entry\n", @@ -1230,7 +1240,7 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) break; - case 71: /* menu_entry */ + case 74: /* menu_entry */ { fprintf(stderr, "%s:%d: missing end statement for this entry\n", @@ -1241,7 +1251,6 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) break; - default: break; } @@ -1323,23 +1332,31 @@ yyparse (void) yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; + /*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | +| yynewstate -- push a new state, which is found in yystate. | `------------------------------------------------------------*/ - yynewstate: +yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; - yysetstate: - *yyssp = yystate; + +/*--------------------------------------------------------------------. +| yynewstate -- set current state (the top of the stack) to yystate. | +`--------------------------------------------------------------------*/ +yysetstate: + *yyssp = (yytype_int16) yystate; if (yyss + yystacksize - 1 <= yyssp) +#if !defined yyoverflow && !defined YYSTACK_RELOCATE + goto yyexhaustedlab; +#else { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; + YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1); -#ifdef yyoverflow +# if defined yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into @@ -1355,14 +1372,10 @@ yyparse (void) &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); - yyss = yyss1; yyvs = yyvs1; } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else +# else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; @@ -1378,22 +1391,22 @@ yyparse (void) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); -# undef YYSTACK_RELOCATE +# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif -#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } +#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ YYDPRINTF ((stderr, "Entering state %d\n", yystate)); @@ -1402,11 +1415,11 @@ yyparse (void) goto yybackup; + /*-----------. | yybackup. | `-----------*/ yybackup: - /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ @@ -1479,7 +1492,7 @@ yydefault: /*-----------------------------. -| yyreduce -- Do a reduction. | +| yyreduce -- do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -1546,19 +1559,19 @@ yyreduce: break; - case 31: + case 32: { zconf_error("unknown option \"%s\"", (yyvsp[-2].string)); } break; - case 32: + case 33: { zconf_error("invalid option"); } break; - case 33: + case 34: { (yyvsp[-1].symbol)->flags |= SYMBOL_OPTIONAL; @@ -1568,7 +1581,7 @@ yyreduce: break; - case 34: + case 35: { printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); @@ -1576,7 +1589,7 @@ yyreduce: break; - case 35: + case 36: { (yyvsp[-1].symbol)->flags |= SYMBOL_OPTIONAL; @@ -1586,7 +1599,7 @@ yyreduce: break; - case 36: + case 37: { if (current_entry->prompt) @@ -1598,7 +1611,7 @@ yyreduce: break; - case 44: + case 45: { menu_set_type((yyvsp[-2].id)->stype); @@ -1609,7 +1622,7 @@ yyreduce: break; - case 45: + case 46: { menu_add_prompt(P_PROMPT, (yyvsp[-2].string), (yyvsp[-1].expr)); @@ -1618,7 +1631,7 @@ yyreduce: break; - case 46: + case 47: { menu_add_expr(P_DEFAULT, (yyvsp[-2].expr), (yyvsp[-1].expr)); @@ -1631,7 +1644,7 @@ yyreduce: break; - case 47: + case 48: { menu_add_symbol(P_SELECT, (yyvsp[-2].symbol), (yyvsp[-1].expr)); @@ -1640,7 +1653,7 @@ yyreduce: break; - case 48: + case 49: { menu_add_symbol(P_IMPLY, (yyvsp[-2].symbol), (yyvsp[-1].expr)); @@ -1649,7 +1662,7 @@ yyreduce: break; - case 49: + case 50: { menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,(yyvsp[-3].symbol), (yyvsp[-2].symbol)), (yyvsp[-1].expr)); @@ -1658,7 +1671,7 @@ yyreduce: break; - case 52: + case 53: { const struct kconf_id *id = kconf_id_lookup((yyvsp[-1].string), strlen((yyvsp[-1].string))); @@ -1673,19 +1686,35 @@ yyreduce: break; - case 53: + case 54: { (yyval.string) = NULL; } break; - case 54: + case 55: { (yyval.string) = (yyvsp[0].string); } break; - case 55: + case 56: + + { + if ((yyvsp[-1].id)->token != T_ENDMENUCONFIG) { + zconf_error("unexpected '%s' within %s block", + (yyvsp[-1].id)->name, zconf_tokenname(T_MENUCONFIG)); + yynerrs++; + } else { + /* HACK: Use empty entry to quit menuconfig */ + menu_add_entry(NULL); + printd(DEBUG_PARSE, "%s:%d:endmenuconfig\n", zconf_curname(), zconf_lineno()); + } +} + + break; + + case 58: { struct symbol *sym = sym_lookup((yyvsp[-1].string), SYMBOL_CHOICE); @@ -1698,7 +1727,7 @@ yyreduce: break; - case 56: + case 59: { (yyval.menu) = menu_add_menu(); @@ -1706,7 +1735,7 @@ yyreduce: break; - case 57: + case 60: { if (zconf_endtoken((yyvsp[0].id), T_CHOICE, T_ENDCHOICE)) { @@ -1717,7 +1746,7 @@ yyreduce: break; - case 65: + case 68: { menu_add_prompt(P_PROMPT, (yyvsp[-2].string), (yyvsp[-1].expr)); @@ -1726,7 +1755,7 @@ yyreduce: break; - case 66: + case 69: { if ((yyvsp[-2].id)->stype == S_BOOLEAN || (yyvsp[-2].id)->stype == S_TRISTATE) { @@ -1740,7 +1769,7 @@ yyreduce: break; - case 67: + case 70: { current_entry->sym->flags |= SYMBOL_OPTIONAL; @@ -1749,7 +1778,7 @@ yyreduce: break; - case 68: + case 71: { if ((yyvsp[-3].id)->stype == S_UNKNOWN) { @@ -1762,7 +1791,7 @@ yyreduce: break; - case 71: + case 74: { printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); @@ -1773,7 +1802,7 @@ yyreduce: break; - case 72: + case 75: { if (zconf_endtoken((yyvsp[0].id), T_IF, T_ENDIF)) { @@ -1784,7 +1813,7 @@ yyreduce: break; - case 78: + case 81: { menu_add_entry(NULL); @@ -1794,7 +1823,7 @@ yyreduce: break; - case 79: + case 82: { (yyval.menu) = menu_add_menu(); @@ -1802,7 +1831,7 @@ yyreduce: break; - case 80: + case 83: { if (zconf_endtoken((yyvsp[0].id), T_MENU, T_ENDMENU)) { @@ -1813,7 +1842,7 @@ yyreduce: break; - case 86: + case 89: { printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), (yyvsp[-1].string)); @@ -1823,7 +1852,7 @@ yyreduce: break; - case 87: + case 90: { menu_add_entry(NULL); @@ -1833,7 +1862,7 @@ yyreduce: break; - case 89: + case 92: { printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); @@ -1842,7 +1871,7 @@ yyreduce: break; - case 90: + case 93: { if (current_entry->help) { @@ -1861,7 +1890,7 @@ yyreduce: break; - case 95: + case 98: { menu_add_dep((yyvsp[-1].expr)); @@ -1870,7 +1899,7 @@ yyreduce: break; - case 99: + case 102: { menu_add_visibility((yyvsp[0].expr)); @@ -1878,7 +1907,7 @@ yyreduce: break; - case 101: + case 104: { menu_add_prompt(P_PROMPT, (yyvsp[-1].string), (yyvsp[0].expr)); @@ -1886,115 +1915,115 @@ yyreduce: break; - case 104: + case 107: { (yyval.id) = (yyvsp[-1].id); } break; - case 105: + case 108: { (yyval.id) = (yyvsp[-1].id); } break; - case 106: + case 109: { (yyval.id) = (yyvsp[-1].id); } break; - case 109: + case 112: { (yyval.expr) = NULL; } break; - case 110: + case 113: { (yyval.expr) = (yyvsp[0].expr); } break; - case 111: + case 114: { (yyval.expr) = expr_alloc_symbol((yyvsp[0].symbol)); } break; - case 112: + case 115: { (yyval.expr) = expr_alloc_comp(E_LTH, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } break; - case 113: + case 116: { (yyval.expr) = expr_alloc_comp(E_LEQ, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } break; - case 114: + case 117: { (yyval.expr) = expr_alloc_comp(E_GTH, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } break; - case 115: + case 118: { (yyval.expr) = expr_alloc_comp(E_GEQ, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } break; - case 116: + case 119: { (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } break; - case 117: + case 120: { (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[-2].symbol), (yyvsp[0].symbol)); } break; - case 118: + case 121: { (yyval.expr) = (yyvsp[-1].expr); } break; - case 119: + case 122: { (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[0].expr)); } break; - case 120: + case 123: { (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[-2].expr), (yyvsp[0].expr)); } break; - case 121: + case 124: { (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[-2].expr), (yyvsp[0].expr)); } break; - case 122: + case 125: { (yyval.symbol) = sym_lookup((yyvsp[0].string), 0); free((yyvsp[0].string)); } break; - case 124: + case 127: { (yyval.symbol) = sym_lookup((yyvsp[0].string), SYMBOL_CONST); free((yyvsp[0].string)); } break; - case 125: + case 128: { (yyval.string) = NULL; } @@ -2026,14 +2055,13 @@ yyreduce: /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; + { + const int yylhs = yyr1[yyn] - YYNTOKENS; + const int yyi = yypgoto[yylhs] + *yyssp; + yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp + ? yytable[yyi] + : yydefgoto[yylhs]); + } goto yynewstate; @@ -2116,12 +2144,10 @@ yyerrlab: | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; + /* Pacify compilers when the user code never invokes YYERROR and the + label yyerrorlab therefore never appears in user code. */ + if (0) + YYERROR; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -2183,6 +2209,7 @@ yyacceptlab: yyresult = 0; goto yyreturn; + /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ @@ -2190,6 +2217,7 @@ yyabortlab: yyresult = 1; goto yyreturn; + #if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | @@ -2200,6 +2228,10 @@ yyexhaustedlab: /* Fall through. */ #endif + +/*-----------------------------------------------------. +| yyreturn -- parsing is finished, return the result. | +`-----------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { @@ -2273,6 +2305,8 @@ static const char *zconf_tokenname(int token) case T_ENDMENU: return "endmenu"; case T_CHOICE: return "choice"; case T_ENDCHOICE: return "endchoice"; + case T_MENUCONFIG: return "menuconfig"; + case T_ENDMENUCONFIG: return "endmenuconfig"; case T_IF: return "if"; case T_ENDIF: return "endif"; case T_DEPENDS: return "depends"; diff --git a/zconf.y b/zconf.y index b205ace..d0e9d58 100644 --- a/zconf.y +++ b/zconf.y @@ -25,6 +25,7 @@ static void yyerror(const char *err); static void zconfprint(const char *err, ...); static void zconf_error(const char *err, ...); static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken); +static const char *zconf_tokenname(int token); struct symbol *symbol_hash[SYMBOL_HASHSIZE]; @@ -92,7 +93,7 @@ static struct menu *current_menu, *current_entry; %type if_expr %type end %type option_name -%type if_entry menu_entry choice_entry menuconfig_entry_start +%type if_entry menu_entry choice_entry %type symbol_option_arg word_opt %destructor { @@ -100,7 +101,7 @@ static struct menu *current_menu, *current_entry; $$->file->name, $$->lineno); if (current_menu == $$) menu_end_menu(); -} if_entry menu_entry choice_entry menuconfig_entry_start +} if_entry menu_entry choice_entry %{ /* Include kconf_id.c here so it can see the token constants. */ @@ -184,7 +185,6 @@ menuconfig_entry_start: T_MENUCONFIG nonconst_symbol T_EOL { $2->flags |= SYMBOL_OPTIONAL; menu_add_entry($2); - $$ = menu_add_menu(); printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), $2->name); }; @@ -275,9 +275,13 @@ symbol_option_arg: endmenuconfig: T_ENDMENUCONFIG T_EOL { - if (zconf_endtoken($1, T_MENUCONFIG, T_ENDMENUCONFIG)) { - //menu_add_entry(NULL); - menu_end_menu(); + if ($1->token != T_ENDMENUCONFIG) { + zconf_error("unexpected '%s' within %s block", + $1->name, zconf_tokenname(T_MENUCONFIG)); + yynerrs++; + } else { + /* HACK: Use empty entry to quit menuconfig */ + menu_add_entry(NULL); printd(DEBUG_PARSE, "%s:%d:endmenuconfig\n", zconf_curname(), zconf_lineno()); } }; @@ -603,8 +607,8 @@ static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtok return false; } if (current_menu->file != current_file) { - zconf_error("'%s' in different file than '%s' %p %s", - id->name, zconf_tokenname(starttoken), current_menu->file, current_file->name); + zconf_error("'%s' in different file than '%s'", + id->name, zconf_tokenname(starttoken)); fprintf(stderr, "%s:%d: location of the '%s'\n", current_menu->file->name, current_menu->lineno, zconf_tokenname(starttoken)); -- 2.20.1