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