Root/scripts/config/zconf.tab.c_shipped

1/* A Bison parser, made by GNU Bison 1.875d. */
2
3/* Skeleton parser for Yacc-like parsing with Bison,
4   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   This program is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with this program; if not, write to the Free Software
18   Foundation, Inc., 59 Temple Place - Suite 330,
19   Boston, MA 02111-1307, USA. */
20
21/* As a special exception, when this file is copied by Bison into a
22   Bison output file, you may use that output file without restriction.
23   This special exception was added by the Free Software Foundation
24   in version 1.24 of Bison. */
25
26/* Written by Richard Stallman by simplifying the original so called
27   ``semantic'' parser. */
28
29/* All symbols defined below should begin with yy or YY, to avoid
30   infringing on user name space. This should be done even for local
31   variables, as they might otherwise be expanded by user macros.
32   There are some unavoidable exceptions within include files to
33   define necessary library symbols; they are noted "INFRINGES ON
34   USER NAME SPACE" below. */
35
36/* Identify Bison output. */
37#define YYBISON 1
38
39/* Skeleton name. */
40#define YYSKELETON_NAME "yacc.c"
41
42/* Pure parsers. */
43#define YYPURE 0
44
45/* Using locations. */
46#define YYLSP_NEEDED 0
47
48/* If NAME_PREFIX is specified substitute the variables and functions
49   names. */
50#define yyparse zconfparse
51#define yylex zconflex
52#define yyerror zconferror
53#define yylval zconflval
54#define yychar zconfchar
55#define yydebug zconfdebug
56#define yynerrs zconfnerrs
57
58
59/* Tokens. */
60#ifndef YYTOKENTYPE
61# define YYTOKENTYPE
62   /* Put the tokens into the symbol table, so that GDB and other debuggers
63      know about them. */
64   enum yytokentype {
65     T_MAINMENU = 258,
66     T_MENU = 259,
67     T_ENDMENU = 260,
68     T_SOURCE = 261,
69     T_CHOICE = 262,
70     T_ENDCHOICE = 263,
71     T_COMMENT = 264,
72     T_CONFIG = 265,
73     T_MENUCONFIG = 266,
74     T_HELP = 267,
75     T_HELPTEXT = 268,
76     T_IF = 269,
77     T_ENDIF = 270,
78     T_DEPENDS = 271,
79     T_REQUIRES = 272,
80     T_OPTIONAL = 273,
81     T_PROMPT = 274,
82     T_TYPE = 275,
83     T_DEFAULT = 276,
84     T_DESELECT = 277,
85     T_SELECT = 278,
86     T_RANGE = 279,
87     T_ON = 280,
88     T_RESET = 281,
89     T_WORD = 282,
90     T_WORD_QUOTE = 283,
91     T_UNEQUAL = 284,
92     T_CLOSE_PAREN = 285,
93     T_OPEN_PAREN = 286,
94     T_EOL = 287,
95     T_OR = 288,
96     T_AND = 289,
97     T_EQUAL = 290,
98     T_NOT = 291
99   };
100#endif
101#define T_MAINMENU 258
102#define T_MENU 259
103#define T_ENDMENU 260
104#define T_SOURCE 261
105#define T_CHOICE 262
106#define T_ENDCHOICE 263
107#define T_COMMENT 264
108#define T_CONFIG 265
109#define T_MENUCONFIG 266
110#define T_HELP 267
111#define T_HELPTEXT 268
112#define T_IF 269
113#define T_ENDIF 270
114#define T_DEPENDS 271
115#define T_REQUIRES 272
116#define T_OPTIONAL 273
117#define T_PROMPT 274
118#define T_TYPE 275
119#define T_DEFAULT 276
120#define T_DESELECT 277
121#define T_SELECT 278
122#define T_RANGE 279
123#define T_ON 280
124#define T_RESET 281
125#define T_WORD 282
126#define T_WORD_QUOTE 283
127#define T_UNEQUAL 284
128#define T_CLOSE_PAREN 285
129#define T_OPEN_PAREN 286
130#define T_EOL 287
131#define T_OR 288
132#define T_AND 289
133#define T_EQUAL 290
134#define T_NOT 291
135
136
137
138
139/* Copy the first part of user declarations. */
140
141
142/*
143 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
144 * Released under the terms of the GNU GPL v2.0.
145 */
146
147#include <ctype.h>
148#include <stdarg.h>
149#include <stdio.h>
150#include <stdlib.h>
151#include <string.h>
152#include <stdbool.h>
153
154#define LKC_DIRECT_LINK
155#include "lkc.h"
156
157#include "zconf.hash.c"
158
159#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
160
161#define PRINTD 0x0001
162#define DEBUG_PARSE 0x0002
163
164int cdebug = PRINTD;
165
166extern int zconflex(void);
167static void zconfprint(const char *err, ...);
168static void zconf_error(const char *err, ...);
169static void zconferror(const char *err);
170static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken);
171
172struct symbol *symbol_hash[SYMBOL_HASHSIZE];
173
174static struct menu *current_menu, *current_entry;
175
176#define YYDEBUG 0
177#if YYDEBUG
178#define YYERROR_VERBOSE
179#endif
180
181
182/* Enabling traces. */
183#ifndef YYDEBUG
184# define YYDEBUG 0
185#endif
186
187/* Enabling verbose error messages. */
188#ifdef YYERROR_VERBOSE
189# undef YYERROR_VERBOSE
190# define YYERROR_VERBOSE 1
191#else
192# define YYERROR_VERBOSE 0
193#endif
194
195#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
196
197typedef union YYSTYPE {
198    char *string;
199    struct file *file;
200    struct symbol *symbol;
201    struct expr *expr;
202    struct menu *menu;
203    struct kconf_id *id;
204} YYSTYPE;
205/* Line 191 of yacc.c. */
206
207# define yystype YYSTYPE /* obsolescent; will be withdrawn */
208# define YYSTYPE_IS_DECLARED 1
209# define YYSTYPE_IS_TRIVIAL 1
210#endif
211
212
213
214/* Copy the second part of user declarations. */
215
216
217/* Line 214 of yacc.c. */
218
219
220#if ! defined (yyoverflow) || YYERROR_VERBOSE
221
222# ifndef YYFREE
223# define YYFREE free
224# endif
225# ifndef YYMALLOC
226# define YYMALLOC malloc
227# endif
228
229/* The parser invokes alloca or malloc; define the necessary symbols. */
230
231# ifdef YYSTACK_USE_ALLOCA
232# if YYSTACK_USE_ALLOCA
233# define YYSTACK_ALLOC alloca
234# endif
235# else
236# if defined (alloca) || defined (_ALLOCA_H)
237# define YYSTACK_ALLOC alloca
238# else
239# ifdef __GNUC__
240# define YYSTACK_ALLOC __builtin_alloca
241# endif
242# endif
243# endif
244
245# ifdef YYSTACK_ALLOC
246   /* Pacify GCC's `empty if-body' warning. */
247# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
248# else
249# if defined (__STDC__) || defined (__cplusplus)
250# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
251# define YYSIZE_T size_t
252# endif
253# define YYSTACK_ALLOC YYMALLOC
254# define YYSTACK_FREE YYFREE
255# endif
256#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
257
258
259#if (! defined (yyoverflow) \
260     && (! defined (__cplusplus) \
261     || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
262
263/* A type that is properly aligned for any stack member. */
264union yyalloc
265{
266  short int yyss;
267  YYSTYPE yyvs;
268  };
269
270/* The size of the maximum gap between one aligned stack and the next. */
271# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
272
273/* The size of an array large to enough to hold all stacks, each with
274   N elements. */
275# define YYSTACK_BYTES(N) \
276     ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
277      + YYSTACK_GAP_MAXIMUM)
278
279/* Copy COUNT objects from FROM to TO. The source and destination do
280   not overlap. */
281# ifndef YYCOPY
282# if defined (__GNUC__) && 1 < __GNUC__
283# define YYCOPY(To, From, Count) \
284      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
285# else
286# define YYCOPY(To, From, Count) \
287      do \
288    { \
289      register YYSIZE_T yyi; \
290      for (yyi = 0; yyi < (Count); yyi++) \
291        (To)[yyi] = (From)[yyi]; \
292    } \
293      while (0)
294# endif
295# endif
296
297/* Relocate STACK from its old location to the new one. The
298   local variables YYSIZE and YYSTACKSIZE give the old and new number of
299   elements in the stack, and YYPTR gives the new location of the
300   stack. Advance YYPTR to a properly aligned location for the next
301   stack. */
302# define YYSTACK_RELOCATE(Stack) \
303    do \
304      { \
305    YYSIZE_T yynewbytes; \
306    YYCOPY (&yyptr->Stack, Stack, yysize); \
307    Stack = &yyptr->Stack; \
308    yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
309    yyptr += yynewbytes / sizeof (*yyptr); \
310      } \
311    while (0)
312
313#endif
314
315#if defined (__STDC__) || defined (__cplusplus)
316   typedef signed char yysigned_char;
317#else
318   typedef short int yysigned_char;
319#endif
320
321/* YYFINAL -- State number of the termination state. */
322#define YYFINAL 3
323/* YYLAST -- Last index in YYTABLE. */
324#define YYLAST 285
325
326/* YYNTOKENS -- Number of terminals. */
327#define YYNTOKENS 37
328/* YYNNTS -- Number of nonterminals. */
329#define YYNNTS 42
330/* YYNRULES -- Number of rules. */
331#define YYNRULES 108
332/* YYNRULES -- Number of states. */
333#define YYNSTATES 184
334
335/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
336#define YYUNDEFTOK 2
337#define YYMAXUTOK 291
338
339#define YYTRANSLATE(YYX) \
340  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
341
342/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
343static const unsigned char yytranslate[] =
344{
345       0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
346       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
347       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
348       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
349       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
350       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
351       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
352       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
353       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
354       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
355       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
356       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
357       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
358       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
359       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
360       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
361       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
362       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
363       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
364       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
365       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
366       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
367       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
368       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
369       2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
370       2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
371       5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
372      15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
373      25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
374      35, 36
375};
376
377#if YYDEBUG
378/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
379   YYRHS. */
380static const unsigned short int yyprhs[] =
381{
382       0, 0, 3, 5, 6, 9, 12, 15, 20, 23,
383      28, 33, 37, 39, 41, 43, 45, 47, 49, 51,
384      53, 55, 57, 59, 61, 63, 65, 67, 71, 74,
385      78, 81, 85, 88, 89, 92, 95, 98, 101, 104,
386     108, 113, 118, 123, 128, 134, 137, 140, 142, 146,
387     147, 150, 153, 156, 159, 162, 167, 171, 174, 178,
388     183, 184, 187, 191, 193, 197, 198, 201, 204, 207,
389     211, 214, 216, 220, 221, 224, 227, 230, 234, 238,
390     241, 244, 247, 248, 251, 254, 257, 262, 266, 270,
391     271, 274, 276, 278, 281, 284, 287, 289, 292, 293,
392     296, 298, 302, 306, 310, 313, 317, 321, 323
393};
394
395/* YYRHS -- A `-1'-separated list of the rules' RHS. */
396static const yysigned_char yyrhs[] =
397{
398      38, 0, -1, 39, -1, -1, 39, 41, -1, 39,
399      52, -1, 39, 63, -1, 39, 3, 73, 75, -1,
400      39, 74, -1, 39, 27, 1, 32, -1, 39, 40,
401       1, 32, -1, 39, 1, 32, -1, 16, -1, 19,
402      -1, 20, -1, 22, -1, 23, -1, 18, -1, 24,
403      -1, 21, -1, 26, -1, 32, -1, 58, -1, 67,
404      -1, 44, -1, 46, -1, 65, -1, 27, 1, 32,
405      -1, 1, 32, -1, 10, 27, 32, -1, 43, 47,
406      -1, 11, 27, 32, -1, 45, 47, -1, -1, 47,
407      48, -1, 47, 71, -1, 47, 69, -1, 47, 42,
408      -1, 47, 32, -1, 20, 72, 32, -1, 19, 73,
409      76, 32, -1, 21, 77, 76, 32, -1, 22, 27,
410      76, 32, -1, 23, 27, 76, 32, -1, 24, 78,
411      78, 76, 32, -1, 7, 32, -1, 49, 53, -1,
412      74, -1, 50, 55, 51, -1, -1, 53, 54, -1,
413      53, 71, -1, 53, 69, -1, 53, 32, -1, 53,
414      42, -1, 19, 73, 76, 32, -1, 20, 72, 32,
415      -1, 18, 32, -1, 26, 76, 32, -1, 21, 27,
416      76, 32, -1, -1, 55, 41, -1, 14, 77, 75,
417      -1, 74, -1, 56, 59, 57, -1, -1, 59, 41,
418      -1, 59, 63, -1, 59, 52, -1, 4, 73, 32,
419      -1, 60, 70, -1, 74, -1, 61, 64, 62, -1,
420      -1, 64, 41, -1, 64, 63, -1, 64, 52, -1,
421       6, 73, 32, -1, 9, 73, 32, -1, 66, 70,
422      -1, 12, 32, -1, 68, 13, -1, -1, 70, 71,
423      -1, 70, 32, -1, 70, 42, -1, 16, 25, 77,
424      32, -1, 16, 77, 32, -1, 17, 77, 32, -1,
425      -1, 73, 76, -1, 27, -1, 28, -1, 5, 32,
426      -1, 8, 32, -1, 15, 32, -1, 32, -1, 75,
427      32, -1, -1, 14, 77, -1, 78, -1, 78, 35,
428      78, -1, 78, 29, 78, -1, 31, 77, 30, -1,
429      36, 77, -1, 77, 33, 77, -1, 77, 34, 77,
430      -1, 27, -1, 28, -1
431};
432
433/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
434static const unsigned short int yyrline[] =
435{
436       0, 105, 105, 107, 109, 110, 111, 112, 113, 114,
437     115, 119, 123, 123, 123, 123, 123, 123, 123, 123,
438     123, 127, 128, 129, 130, 131, 132, 136, 137, 143,
439     151, 157, 165, 175, 177, 178, 179, 180, 181, 184,
440     192, 198, 208, 214, 220, 228, 237, 242, 250, 253,
441     255, 256, 257, 258, 259, 262, 268, 279, 285, 290,
442     300, 302, 307, 315, 323, 326, 328, 329, 330, 335,
443     342, 347, 355, 358, 360, 361, 362, 365, 373, 380,
444     387, 393, 400, 402, 403, 404, 407, 412, 417, 425,
445     427, 432, 433, 436, 437, 438, 442, 443, 446, 447,
446     450, 451, 452, 453, 454, 455, 456, 459, 460
447};
448#endif
449
450#if YYDEBUG || YYERROR_VERBOSE
451/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
452   First, the terminals, then, starting at YYNTOKENS, nonterminals. */
453static const char *const yytname[] =
454{
455  "$end", "error", "$undefined", "T_MAINMENU", "T_MENU", "T_ENDMENU",
456  "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG",
457  "T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS",
458  "T_REQUIRES", "T_OPTIONAL", "T_PROMPT", "T_TYPE", "T_DEFAULT",
459  "T_DESELECT", "T_SELECT", "T_RANGE", "T_ON", "T_RESET", "T_WORD",
460  "T_WORD_QUOTE", "T_UNEQUAL", "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_EOL",
461  "T_OR", "T_AND", "T_EQUAL", "T_NOT", "$accept", "input", "stmt_list",
462  "option_name", "common_stmt", "option_error", "config_entry_start",
463  "config_stmt", "menuconfig_entry_start", "menuconfig_stmt",
464  "config_option_list", "config_option", "choice", "choice_entry",
465  "choice_end", "choice_stmt", "choice_option_list", "choice_option",
466  "choice_block", "if_entry", "if_end", "if_stmt", "if_block", "menu",
467  "menu_entry", "menu_end", "menu_stmt", "menu_block", "source_stmt",
468  "comment", "comment_stmt", "help_start", "help", "depends_list",
469  "depends", "prompt_stmt_opt", "prompt", "end", "nl", "if_expr", "expr",
470  "symbol", 0
471};
472#endif
473
474# ifdef YYPRINT
475/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
476   token YYLEX-NUM. */
477static const unsigned short int yytoknum[] =
478{
479       0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
480     265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
481     275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
482     285, 286, 287, 288, 289, 290, 291
483};
484# endif
485
486/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
487static const unsigned char yyr1[] =
488{
489       0, 37, 38, 39, 39, 39, 39, 39, 39, 39,
490      39, 39, 40, 40, 40, 40, 40, 40, 40, 40,
491      40, 41, 41, 41, 41, 41, 41, 42, 42, 43,
492      44, 45, 46, 47, 47, 47, 47, 47, 47, 48,
493      48, 48, 48, 48, 48, 49, 50, 51, 52, 53,
494      53, 53, 53, 53, 53, 54, 54, 54, 54, 54,
495      55, 55, 56, 57, 58, 59, 59, 59, 59, 60,
496      61, 62, 63, 64, 64, 64, 64, 65, 66, 67,
497      68, 69, 70, 70, 70, 70, 71, 71, 71, 72,
498      72, 73, 73, 74, 74, 74, 75, 75, 76, 76,
499      77, 77, 77, 77, 77, 77, 77, 78, 78
500};
501
502/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
503static const unsigned char yyr2[] =
504{
505       0, 2, 1, 0, 2, 2, 2, 4, 2, 4,
506       4, 3, 1, 1, 1, 1, 1, 1, 1, 1,
507       1, 1, 1, 1, 1, 1, 1, 3, 2, 3,
508       2, 3, 2, 0, 2, 2, 2, 2, 2, 3,
509       4, 4, 4, 4, 5, 2, 2, 1, 3, 0,
510       2, 2, 2, 2, 2, 4, 3, 2, 3, 4,
511       0, 2, 3, 1, 3, 0, 2, 2, 2, 3,
512       2, 1, 3, 0, 2, 2, 2, 3, 3, 2,
513       2, 2, 0, 2, 2, 2, 4, 3, 3, 0,
514       2, 1, 1, 2, 2, 2, 1, 2, 0, 2,
515       1, 3, 3, 3, 2, 3, 3, 1, 1
516};
517
518/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
519   STATE-NUM when YYTABLE doesn't specify something else to do. Zero
520   means the default is an error. */
521static const unsigned char yydefact[] =
522{
523       3, 0, 0, 1, 0, 0, 0, 0, 0, 0,
524       0, 0, 0, 0, 0, 0, 12, 17, 13, 14,
525      19, 15, 16, 18, 20, 0, 21, 0, 4, 33,
526      24, 33, 25, 49, 60, 5, 65, 22, 82, 73,
527       6, 26, 82, 23, 8, 11, 91, 92, 0, 0,
528      93, 0, 45, 94, 0, 0, 0, 107, 108, 0,
529       0, 0, 100, 95, 0, 0, 0, 0, 0, 0,
530       0, 0, 0, 0, 96, 7, 69, 77, 78, 29,
531      31, 0, 104, 0, 0, 62, 0, 0, 9, 10,
532       0, 0, 0, 0, 0, 89, 0, 0, 0, 0,
533       0, 38, 37, 34, 0, 36, 35, 0, 0, 89,
534       0, 98, 53, 54, 50, 52, 51, 61, 48, 47,
535      66, 68, 64, 67, 63, 84, 85, 83, 74, 76,
536      72, 75, 71, 97, 103, 105, 106, 102, 101, 28,
537      80, 0, 0, 0, 98, 0, 98, 98, 98, 98,
538       0, 0, 81, 57, 98, 0, 98, 0, 0, 0,
539      87, 88, 0, 39, 90, 0, 0, 0, 98, 27,
540       0, 56, 0, 99, 58, 86, 40, 41, 42, 43,
541       0, 55, 59, 44
542};
543
544/* YYDEFGOTO[NTERM-NUM]. */
545static const short int yydefgoto[] =
546{
547      -1, 1, 2, 27, 28, 102, 29, 30, 31, 32,
548      66, 103, 33, 34, 118, 35, 68, 114, 69, 36,
549     122, 37, 70, 38, 39, 130, 40, 72, 41, 42,
550      43, 104, 105, 71, 106, 145, 146, 44, 75, 158,
551      61, 62
552};
553
554/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
555   STATE-NUM. */
556#define YYPACT_NINF -80
557static const short int yypact[] =
558{
559     -80, 2, 164, -80, -22, 105, 105, -6, 105, 0,
560       7, 105, 17, 28, 70, 35, -80, -80, -80, -80,
561     -80, -80, -80, -80, -80, 69, -80, 78, -80, -80,
562     -80, -80, -80, -80, -80, -80, -80, -80, -80, -80,
563     -80, -80, -80, -80, -80, -80, -80, -80, 62, 68,
564     -80, 85, -80, -80, 97, 127, 144, -80, -80, 70,
565      70, 188, -8, -80, 149, 163, 42, 104, 192, 67,
566     221, 8, 221, 134, -80, 167, -80, -80, -80, -80,
567     -80, 50, -80, 70, 70, 167, 119, 119, -80, -80,
568     173, 184, 60, 70, 105, 105, 70, 65, 150, 119,
569     232, -80, -80, -80, 210, -80, -80, 202, 105, 105,
570     231, 224, -80, -80, -80, -80, -80, -80, -80, -80,
571     -80, -80, -80, -80, -80, -80, -80, -80, -80, -80,
572     -80, -80, -80, -80, -80, 226, -80, -80, -80, -80,
573     -80, 70, 211, 218, 224, 230, 224, -3, 224, 224,
574     119, 233, -80, -80, 224, 234, 224, 70, 235, 222,
575     -80, -80, 236, -80, -80, 237, 238, 239, 224, -80,
576     240, -80, 241, 129, -80, -80, -80, -80, -80, -80,
577     242, -80, -80, -80
578};
579
580/* YYPGOTO[NTERM-NUM]. */
581static const short int yypgoto[] =
582{
583     -80, -80, -80, -80, -36, 22, -80, -80, -80, -80,
584     244, -80, -80, -80, -80, 176, -80, -80, -80, -80,
585     -80, -80, -80, -80, -80, -80, 187, -80, -80, -80,
586     -80, -80, 195, 243, 121, 155, -5, 145, 215, 93,
587     -55, -79
588};
589
590/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
591   positive, shift that token. If negative, reduce the rule which
592   number is the opposite. If zero, do what YYDEFACT says.
593   If YYTABLE_NINF, syntax error. */
594#define YYTABLE_NINF -80
595static const short int yytable[] =
596{
597      48, 49, 3, 51, 81, 82, 54, 137, 138, 90,
598      45, 157, -70, -70, -70, -70, -70, -70, -70, -70,
599     150, 86, -70, -70, 92, 93, 50, 87, 135, 136,
600      83, 84, 52, 117, 120, 100, 128, 142, 143, 53,
601     125, 147, -30, 90, 55, -30, -30, -30, -30, -30,
602     -30, -30, -30, -30, 91, 56, -30, -30, 92, 93,
603     -30, 94, 95, 96, 97, 98, 99, 63, -30, 100,
604      64, 168, 7, 8, 101, 10, 11, 12, 13, 65,
605     134, 14, 15, 83, 84, 141, 159, 57, 58, 144,
606     113, 59, 148, 126, 74, 126, 60, 57, 58, 26,
607      76, 59, 173, 154, -32, 90, 60, -32, -32, -32,
608     -32, -32, -32, -32, -32, -32, 91, 77, -32, -32,
609      92, 93, -32, 94, 95, 96, 97, 98, 99, 78,
610     -32, 100, 46, 47, -79, 90, 101, -79, -79, -79,
611     -79, -79, -79, -79, -79, -79, 57, 58, -79, -79,
612      92, 93, -79, -79, -79, -79, -79, -79, -79, 79,
613     -79, 100, 83, 84, -2, 4, 125, 5, 6, 7,
614       8, 9, 10, 11, 12, 13, 80, 149, 14, 15,
615      16, 88, 17, 18, 19, 20, 21, 22, 23, 116,
616      24, 25, 127, 90, 127, 89, 26, -46, -46, 133,
617     -46, -46, -46, -46, 91, 139, -46, -46, 92, 93,
618     107, 108, 109, 110, 119, 124, 140, 132, 111, 100,
619      74, 83, 84, 152, 112, 6, 7, 8, 9, 10,
620      11, 12, 13, 151, 153, 14, 15, 162, 157, 164,
621     165, 166, 167, 160, 83, 84, 121, 170, 129, 172,
622     161, 83, 84, 26, 175, 83, 84, 123, 156, 131,
623      84, 180, 163, 115, 155, 169, 171, 174, 176, 177,
624     178, 179, 181, 182, 183, 67, 85, 0, 0, 0,
625       0, 0, 0, 0, 0, 73
626};
627
628static const short int yycheck[] =
629{
630       5, 6, 0, 8, 59, 60, 11, 86, 87, 1,
631      32, 14, 4, 5, 6, 7, 8, 9, 10, 11,
632      99, 29, 14, 15, 16, 17, 32, 35, 83, 84,
633      33, 34, 32, 69, 70, 27, 72, 92, 93, 32,
634      32, 96, 0, 1, 27, 3, 4, 5, 6, 7,
635       8, 9, 10, 11, 12, 27, 14, 15, 16, 17,
636      18, 19, 20, 21, 22, 23, 24, 32, 26, 27,
637       1, 150, 5, 6, 32, 8, 9, 10, 11, 1,
638      30, 14, 15, 33, 34, 25, 141, 27, 28, 94,
639      68, 31, 27, 71, 32, 73, 36, 27, 28, 32,
640      32, 31, 157, 108, 0, 1, 36, 3, 4, 5,
641       6, 7, 8, 9, 10, 11, 12, 32, 14, 15,
642      16, 17, 18, 19, 20, 21, 22, 23, 24, 32,
643      26, 27, 27, 28, 0, 1, 32, 3, 4, 5,
644       6, 7, 8, 9, 10, 11, 27, 28, 14, 15,
645      16, 17, 18, 19, 20, 21, 22, 23, 24, 32,
646      26, 27, 33, 34, 0, 1, 32, 3, 4, 5,
647       6, 7, 8, 9, 10, 11, 32, 27, 14, 15,
648      16, 32, 18, 19, 20, 21, 22, 23, 24, 68,
649      26, 27, 71, 1, 73, 32, 32, 5, 6, 32,
650       8, 9, 10, 11, 12, 32, 14, 15, 16, 17,
651      18, 19, 20, 21, 69, 70, 32, 72, 26, 27,
652      32, 33, 34, 13, 32, 4, 5, 6, 7, 8,
653       9, 10, 11, 1, 32, 14, 15, 144, 14, 146,
654     147, 148, 149, 32, 33, 34, 70, 154, 72, 156,
655      32, 33, 34, 32, 32, 33, 34, 70, 27, 72,
656      34, 168, 32, 68, 109, 32, 32, 32, 32, 32,
657      32, 32, 32, 32, 32, 31, 61, -1, -1, -1,
658      -1, -1, -1, -1, -1, 42
659};
660
661/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
662   symbol of state STATE-NUM. */
663static const unsigned char yystos[] =
664{
665       0, 38, 39, 0, 1, 3, 4, 5, 6, 7,
666       8, 9, 10, 11, 14, 15, 16, 18, 19, 20,
667      21, 22, 23, 24, 26, 27, 32, 40, 41, 43,
668      44, 45, 46, 49, 50, 52, 56, 58, 60, 61,
669      63, 65, 66, 67, 74, 32, 27, 28, 73, 73,
670      32, 73, 32, 32, 73, 27, 27, 27, 28, 31,
671      36, 77, 78, 32, 1, 1, 47, 47, 53, 55,
672      59, 70, 64, 70, 32, 75, 32, 32, 32, 32,
673      32, 77, 77, 33, 34, 75, 29, 35, 32, 32,
674       1, 12, 16, 17, 19, 20, 21, 22, 23, 24,
675      27, 32, 42, 48, 68, 69, 71, 18, 19, 20,
676      21, 26, 32, 42, 54, 69, 71, 41, 51, 74,
677      41, 52, 57, 63, 74, 32, 42, 71, 41, 52,
678      62, 63, 74, 32, 30, 77, 77, 78, 78, 32,
679      32, 25, 77, 77, 73, 72, 73, 77, 27, 27,
680      78, 1, 13, 32, 73, 72, 27, 14, 76, 77,
681      32, 32, 76, 32, 76, 76, 76, 76, 78, 32,
682      76, 32, 76, 77, 32, 32, 32, 32, 32, 32,
683      76, 32, 32, 32
684};
685
686#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
687# define YYSIZE_T __SIZE_TYPE__
688#endif
689#if ! defined (YYSIZE_T) && defined (size_t)
690# define YYSIZE_T size_t
691#endif
692#if ! defined (YYSIZE_T)
693# if defined (__STDC__) || defined (__cplusplus)
694# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
695# define YYSIZE_T size_t
696# endif
697#endif
698#if ! defined (YYSIZE_T)
699# define YYSIZE_T unsigned int
700#endif
701
702#define yyerrok (yyerrstatus = 0)
703#define yyclearin (yychar = YYEMPTY)
704#define YYEMPTY (-2)
705#define YYEOF 0
706
707#define YYACCEPT goto yyacceptlab
708#define YYABORT goto yyabortlab
709#define YYERROR goto yyerrorlab
710
711
712/* Like YYERROR except do call yyerror. This remains here temporarily
713   to ease the transition to the new meaning of YYERROR, for GCC.
714   Once GCC version 2 has supplanted version 1, this can go. */
715
716#define YYFAIL goto yyerrlab
717
718#define YYRECOVERING() (!!yyerrstatus)
719
720#define YYBACKUP(Token, Value) \
721do \
722  if (yychar == YYEMPTY && yylen == 1) \
723    { \
724      yychar = (Token); \
725      yylval = (Value); \
726      yytoken = YYTRANSLATE (yychar); \
727      YYPOPSTACK; \
728      goto yybackup; \
729    } \
730  else \
731    { \
732      yyerror ("syntax error: cannot back up");\
733      YYERROR; \
734    } \
735while (0)
736
737#define YYTERROR 1
738#define YYERRCODE 256
739
740/* YYLLOC_DEFAULT -- Compute the default location (before the actions
741   are run). */
742
743#ifndef YYLLOC_DEFAULT
744# define YYLLOC_DEFAULT(Current, Rhs, N) \
745   ((Current).first_line = (Rhs)[1].first_line, \
746    (Current).first_column = (Rhs)[1].first_column, \
747    (Current).last_line = (Rhs)[N].last_line, \
748    (Current).last_column = (Rhs)[N].last_column)
749#endif
750
751/* YYLEX -- calling `yylex' with the right arguments. */
752
753#ifdef YYLEX_PARAM
754# define YYLEX yylex (YYLEX_PARAM)
755#else
756# define YYLEX yylex ()
757#endif
758
759/* Enable debugging if requested. */
760#if YYDEBUG
761
762# ifndef YYFPRINTF
763# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
764# define YYFPRINTF fprintf
765# endif
766
767# define YYDPRINTF(Args) \
768do { \
769  if (yydebug) \
770    YYFPRINTF Args; \
771} while (0)
772
773# define YYDSYMPRINT(Args) \
774do { \
775  if (yydebug) \
776    yysymprint Args; \
777} while (0)
778
779# define YYDSYMPRINTF(Title, Token, Value, Location) \
780do { \
781  if (yydebug) \
782    { \
783      YYFPRINTF (stderr, "%s ", Title); \
784      yysymprint (stderr, \
785                  Token, Value); \
786      YYFPRINTF (stderr, "\n"); \
787    } \
788} while (0)
789
790/*------------------------------------------------------------------.
791| yy_stack_print -- Print the state stack from its BOTTOM up to its |
792| TOP (included). |
793`------------------------------------------------------------------*/
794
795#if defined (__STDC__) || defined (__cplusplus)
796static void
797yy_stack_print (short int *bottom, short int *top)
798#else
799static void
800yy_stack_print (bottom, top)
801    short int *bottom;
802    short int *top;
803#endif
804{
805  YYFPRINTF (stderr, "Stack now");
806  for (/* Nothing. */; bottom <= top; ++bottom)
807    YYFPRINTF (stderr, " %d", *bottom);
808  YYFPRINTF (stderr, "\n");
809}
810
811# define YY_STACK_PRINT(Bottom, Top) \
812do { \
813  if (yydebug) \
814    yy_stack_print ((Bottom), (Top)); \
815} while (0)
816
817
818/*------------------------------------------------.
819| Report that the YYRULE is going to be reduced. |
820`------------------------------------------------*/
821
822#if defined (__STDC__) || defined (__cplusplus)
823static void
824yy_reduce_print (int yyrule)
825#else
826static void
827yy_reduce_print (yyrule)
828    int yyrule;
829#endif
830{
831  int yyi;
832  unsigned int yylno = yyrline[yyrule];
833  YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
834             yyrule - 1, yylno);
835  /* Print the symbols being reduced, and their result. */
836  for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
837    YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
838  YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
839}
840
841# define YY_REDUCE_PRINT(Rule) \
842do { \
843  if (yydebug) \
844    yy_reduce_print (Rule); \
845} while (0)
846
847/* Nonzero means print parse trace. It is left uninitialized so that
848   multiple parsers can coexist. */
849int yydebug;
850#else /* !YYDEBUG */
851# define YYDPRINTF(Args)
852# define YYDSYMPRINT(Args)
853# define YYDSYMPRINTF(Title, Token, Value, Location)
854# define YY_STACK_PRINT(Bottom, Top)
855# define YY_REDUCE_PRINT(Rule)
856#endif /* !YYDEBUG */
857
858
859/* YYINITDEPTH -- initial size of the parser's stacks. */
860#ifndef YYINITDEPTH
861# define YYINITDEPTH 200
862#endif
863
864/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
865   if the built-in stack extension method is used).
866
867   Do not make this value too large; the results are undefined if
868   SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
869   evaluated with infinite-precision integer arithmetic. */
870
871#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0
872# undef YYMAXDEPTH
873#endif
874
875#ifndef YYMAXDEPTH
876# define YYMAXDEPTH 10000
877#endif
878
879
880
881#if YYERROR_VERBOSE
882
883# ifndef yystrlen
884# if defined (__GLIBC__) && defined (_STRING_H)
885# define yystrlen strlen
886# else
887/* Return the length of YYSTR. */
888static YYSIZE_T
889# if defined (__STDC__) || defined (__cplusplus)
890yystrlen (const char *yystr)
891# else
892yystrlen (yystr)
893     const char *yystr;
894# endif
895{
896  register const char *yys = yystr;
897
898  while (*yys++ != '\0')
899    continue;
900
901  return yys - yystr - 1;
902}
903# endif
904# endif
905
906# ifndef yystpcpy
907# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
908# define yystpcpy stpcpy
909# else
910/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
911   YYDEST. */
912static char *
913# if defined (__STDC__) || defined (__cplusplus)
914yystpcpy (char *yydest, const char *yysrc)
915# else
916yystpcpy (yydest, yysrc)
917     char *yydest;
918     const char *yysrc;
919# endif
920{
921  register char *yyd = yydest;
922  register const char *yys = yysrc;
923
924  while ((*yyd++ = *yys++) != '\0')
925    continue;
926
927  return yyd - 1;
928}
929# endif
930# endif
931
932#endif /* !YYERROR_VERBOSE */
933
934
935
936#if YYDEBUG
937/*--------------------------------.
938| Print this symbol on YYOUTPUT. |
939`--------------------------------*/
940
941#if defined (__STDC__) || defined (__cplusplus)
942static void
943yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
944#else
945static void
946yysymprint (yyoutput, yytype, yyvaluep)
947    FILE *yyoutput;
948    int yytype;
949    YYSTYPE *yyvaluep;
950#endif
951{
952  /* Pacify ``unused variable'' warnings. */
953  (void) yyvaluep;
954
955  if (yytype < YYNTOKENS)
956    {
957      YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
958# ifdef YYPRINT
959      YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
960# endif
961    }
962  else
963    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
964
965  switch (yytype)
966    {
967      default:
968        break;
969    }
970  YYFPRINTF (yyoutput, ")");
971}
972
973#endif /* ! YYDEBUG */
974/*-----------------------------------------------.
975| Release the memory associated to this symbol. |
976`-----------------------------------------------*/
977
978#if defined (__STDC__) || defined (__cplusplus)
979static void
980yydestruct (int yytype, YYSTYPE *yyvaluep)
981#else
982static void
983yydestruct (yytype, yyvaluep)
984    int yytype;
985    YYSTYPE *yyvaluep;
986#endif
987{
988  /* Pacify ``unused variable'' warnings. */
989  (void) yyvaluep;
990
991  switch (yytype)
992    {
993      case 50: /* choice_entry */
994
995        {
996    fprintf(stderr, "%s:%d: missing end statement for this entry\n",
997        yyvaluep->menu->file->name, yyvaluep->menu->lineno);
998    if (current_menu == yyvaluep->menu)
999        menu_end_menu();
1000};
1001
1002        break;
1003      case 56: /* if_entry */
1004
1005        {
1006    fprintf(stderr, "%s:%d: missing end statement for this entry\n",
1007        yyvaluep->menu->file->name, yyvaluep->menu->lineno);
1008    if (current_menu == yyvaluep->menu)
1009        menu_end_menu();
1010};
1011
1012        break;
1013      case 61: /* menu_entry */
1014
1015        {
1016    fprintf(stderr, "%s:%d: missing end statement for this entry\n",
1017        yyvaluep->menu->file->name, yyvaluep->menu->lineno);
1018    if (current_menu == yyvaluep->menu)
1019        menu_end_menu();
1020};
1021
1022        break;
1023
1024      default:
1025        break;
1026    }
1027}
1028
1029
1030/* Prevent warnings from -Wmissing-prototypes. */
1031
1032#ifdef YYPARSE_PARAM
1033# if defined (__STDC__) || defined (__cplusplus)
1034int yyparse (void *YYPARSE_PARAM);
1035# else
1036int yyparse ();
1037# endif
1038#else /* ! YYPARSE_PARAM */
1039#if defined (__STDC__) || defined (__cplusplus)
1040int yyparse (void);
1041#else
1042int yyparse ();
1043#endif
1044#endif /* ! YYPARSE_PARAM */
1045
1046
1047
1048/* The lookahead symbol. */
1049int yychar;
1050
1051/* The semantic value of the lookahead symbol. */
1052YYSTYPE yylval;
1053
1054/* Number of syntax errors so far. */
1055int yynerrs;
1056
1057
1058
1059/*----------.
1060| yyparse. |
1061`----------*/
1062
1063#ifdef YYPARSE_PARAM
1064# if defined (__STDC__) || defined (__cplusplus)
1065int yyparse (void *YYPARSE_PARAM)
1066# else
1067int yyparse (YYPARSE_PARAM)
1068  void *YYPARSE_PARAM;
1069# endif
1070#else /* ! YYPARSE_PARAM */
1071#if defined (__STDC__) || defined (__cplusplus)
1072int
1073yyparse (void)
1074#else
1075int
1076yyparse ()
1077
1078#endif
1079#endif
1080{
1081  
1082  register int yystate;
1083  register int yyn;
1084  int yyresult;
1085  /* Number of tokens to shift before error messages enabled. */
1086  int yyerrstatus;
1087  /* Lookahead token as an internal (translated) token number. */
1088  int yytoken = 0;
1089
1090  /* Three stacks and their tools:
1091     `yyss': related to states,
1092     `yyvs': related to semantic values,
1093     `yyls': related to locations.
1094
1095     Refer to the stacks thru separate pointers, to allow yyoverflow
1096     to reallocate them elsewhere. */
1097
1098  /* The state stack. */
1099  short int yyssa[YYINITDEPTH];
1100  short int *yyss = yyssa;
1101  register short int *yyssp;
1102
1103  /* The semantic value stack. */
1104  YYSTYPE yyvsa[YYINITDEPTH];
1105  YYSTYPE *yyvs = yyvsa;
1106  register YYSTYPE *yyvsp;
1107
1108
1109
1110#define YYPOPSTACK (yyvsp--, yyssp--)
1111
1112  YYSIZE_T yystacksize = YYINITDEPTH;
1113
1114  /* The variables used to return semantic value and location from the
1115     action routines. */
1116  YYSTYPE yyval;
1117
1118
1119  /* When reducing, the number of symbols on the RHS of the reduced
1120     rule. */
1121  int yylen;
1122
1123  YYDPRINTF ((stderr, "Starting parse\n"));
1124
1125  yystate = 0;
1126  yyerrstatus = 0;
1127  yynerrs = 0;
1128  yychar = YYEMPTY; /* Cause a token to be read. */
1129
1130  /* Initialize stack pointers.
1131     Waste one element of value and location stack
1132     so that they stay on the same level as the state stack.
1133     The wasted elements are never initialized. */
1134
1135  yyssp = yyss;
1136  yyvsp = yyvs;
1137
1138
1139  goto yysetstate;
1140
1141/*------------------------------------------------------------.
1142| yynewstate -- Push a new state, which is found in yystate. |
1143`------------------------------------------------------------*/
1144 yynewstate:
1145  /* In all cases, when you get here, the value and location stacks
1146     have just been pushed. so pushing a state here evens the stacks.
1147     */
1148  yyssp++;
1149
1150 yysetstate:
1151  *yyssp = yystate;
1152
1153  if (yyss + yystacksize - 1 <= yyssp)
1154    {
1155      /* Get the current used size of the three stacks, in elements. */
1156      YYSIZE_T yysize = yyssp - yyss + 1;
1157
1158#ifdef yyoverflow
1159      {
1160    /* Give user a chance to reallocate the stack. Use copies of
1161       these so that the &'s don't force the real ones into
1162       memory. */
1163    YYSTYPE *yyvs1 = yyvs;
1164    short int *yyss1 = yyss;
1165
1166
1167    /* Each stack pointer address is followed by the size of the
1168       data in use in that stack, in bytes. This used to be a
1169       conditional around just the two extra args, but that might
1170       be undefined if yyoverflow is a macro. */
1171    yyoverflow ("parser stack overflow",
1172            &yyss1, yysize * sizeof (*yyssp),
1173            &yyvs1, yysize * sizeof (*yyvsp),
1174
1175            &yystacksize);
1176
1177    yyss = yyss1;
1178    yyvs = yyvs1;
1179      }
1180#else /* no yyoverflow */
1181# ifndef YYSTACK_RELOCATE
1182      goto yyoverflowlab;
1183# else
1184      /* Extend the stack our own way. */
1185      if (YYMAXDEPTH <= yystacksize)
1186    goto yyoverflowlab;
1187      yystacksize *= 2;
1188      if (YYMAXDEPTH < yystacksize)
1189    yystacksize = YYMAXDEPTH;
1190
1191      {
1192    short int *yyss1 = yyss;
1193    union yyalloc *yyptr =
1194      (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1195    if (! yyptr)
1196      goto yyoverflowlab;
1197    YYSTACK_RELOCATE (yyss);
1198    YYSTACK_RELOCATE (yyvs);
1199
1200# undef YYSTACK_RELOCATE
1201    if (yyss1 != yyssa)
1202      YYSTACK_FREE (yyss1);
1203      }
1204# endif
1205#endif /* no yyoverflow */
1206
1207      yyssp = yyss + yysize - 1;
1208      yyvsp = yyvs + yysize - 1;
1209
1210
1211      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1212          (unsigned long int) yystacksize));
1213
1214      if (yyss + yystacksize - 1 <= yyssp)
1215    YYABORT;
1216    }
1217
1218  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1219
1220  goto yybackup;
1221
1222/*-----------.
1223| yybackup. |
1224`-----------*/
1225yybackup:
1226
1227/* Do appropriate processing given the current state. */
1228/* Read a lookahead token if we need one and don't already have one. */
1229/* yyresume: */
1230
1231  /* First try to decide what to do without reference to lookahead token. */
1232
1233  yyn = yypact[yystate];
1234  if (yyn == YYPACT_NINF)
1235    goto yydefault;
1236
1237  /* Not known => get a lookahead token if don't already have one. */
1238
1239  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1240  if (yychar == YYEMPTY)
1241    {
1242      YYDPRINTF ((stderr, "Reading a token: "));
1243      yychar = YYLEX;
1244    }
1245
1246  if (yychar <= YYEOF)
1247    {
1248      yychar = yytoken = YYEOF;
1249      YYDPRINTF ((stderr, "Now at end of input.\n"));
1250    }
1251  else
1252    {
1253      yytoken = YYTRANSLATE (yychar);
1254      YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
1255    }
1256
1257  /* If the proper action on seeing token YYTOKEN is to reduce or to
1258     detect an error, take that action. */
1259  yyn += yytoken;
1260  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1261    goto yydefault;
1262  yyn = yytable[yyn];
1263  if (yyn <= 0)
1264    {
1265      if (yyn == 0 || yyn == YYTABLE_NINF)
1266    goto yyerrlab;
1267      yyn = -yyn;
1268      goto yyreduce;
1269    }
1270
1271  if (yyn == YYFINAL)
1272    YYACCEPT;
1273
1274  /* Shift the lookahead token. */
1275  YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
1276
1277  /* Discard the token being shifted unless it is eof. */
1278  if (yychar != YYEOF)
1279    yychar = YYEMPTY;
1280
1281  *++yyvsp = yylval;
1282
1283
1284  /* Count tokens shifted since error; after three, turn off error
1285     status. */
1286  if (yyerrstatus)
1287    yyerrstatus--;
1288
1289  yystate = yyn;
1290  goto yynewstate;
1291
1292
1293/*-----------------------------------------------------------.
1294| yydefault -- do the default action for the current state. |
1295`-----------------------------------------------------------*/
1296yydefault:
1297  yyn = yydefact[yystate];
1298  if (yyn == 0)
1299    goto yyerrlab;
1300  goto yyreduce;
1301
1302
1303/*-----------------------------.
1304| yyreduce -- Do a reduction. |
1305`-----------------------------*/
1306yyreduce:
1307  /* yyn is the number of a rule to reduce with. */
1308  yylen = yyr2[yyn];
1309
1310  /* If YYLEN is nonzero, implement the default value of the action:
1311     `$$ = $1'.
1312
1313     Otherwise, the following line sets YYVAL to garbage.
1314     This behavior is undocumented and Bison
1315     users should not rely upon it. Assigning to YYVAL
1316     unconditionally makes the parser a bit smaller, and it avoids a
1317     GCC warning that YYVAL may be used uninitialized. */
1318  yyval = yyvsp[1-yylen];
1319
1320
1321  YY_REDUCE_PRINT (yyn);
1322  switch (yyn)
1323    {
1324        case 8:
1325
1326    { zconf_error("unexpected end statement"); ;}
1327    break;
1328
1329  case 9:
1330
1331    { zconf_error("unknown statement \"%s\"", yyvsp[-2].string); ;}
1332    break;
1333
1334  case 10:
1335
1336    {
1337    zconf_error("unexpected option \"%s\"", kconf_id_strings + yyvsp[-2].id->name);
1338;}
1339    break;
1340
1341  case 11:
1342
1343    { zconf_error("invalid statement"); ;}
1344    break;
1345
1346  case 27:
1347
1348    { zconf_error("unknown option \"%s\"", yyvsp[-2].string); ;}
1349    break;
1350
1351  case 28:
1352
1353    { zconf_error("invalid option"); ;}
1354    break;
1355
1356  case 29:
1357
1358    {
1359    struct symbol *sym = sym_lookup(yyvsp[-1].string, 0);
1360    sym->flags |= SYMBOL_OPTIONAL;
1361    menu_add_entry(sym);
1362    printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string);
1363;}
1364    break;
1365
1366  case 30:
1367
1368    {
1369    menu_end_entry();
1370    printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
1371;}
1372    break;
1373
1374  case 31:
1375
1376    {
1377    struct symbol *sym = sym_lookup(yyvsp[-1].string, 0);
1378    sym->flags |= SYMBOL_OPTIONAL;
1379    menu_add_entry(sym);
1380    printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string);
1381;}
1382    break;
1383
1384  case 32:
1385
1386    {
1387    if (current_entry->prompt)
1388        current_entry->prompt->type = P_MENU;
1389    else
1390        zconfprint("warning: menuconfig statement without prompt");
1391    menu_end_entry();
1392    printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
1393;}
1394    break;
1395
1396  case 39:
1397
1398    {
1399    menu_set_type(yyvsp[-2].id->stype);
1400    printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
1401        zconf_curname(), zconf_lineno(),
1402        yyvsp[-2].id->stype);
1403;}
1404    break;
1405
1406  case 40:
1407
1408    {
1409    menu_add_prompt(P_PROMPT, yyvsp[-2].string, yyvsp[-1].expr);
1410    printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
1411;}
1412    break;
1413
1414  case 41:
1415
1416    {
1417    menu_add_expr(P_DEFAULT, yyvsp[-2].expr, yyvsp[-1].expr);
1418    if (yyvsp[-3].id->stype != S_UNKNOWN)
1419        menu_set_type(yyvsp[-3].id->stype);
1420    printd(DEBUG_PARSE, "%s:%d:default(%u)\n",
1421        zconf_curname(), zconf_lineno(),
1422        yyvsp[-3].id->stype);
1423;}
1424    break;
1425
1426  case 42:
1427
1428    {
1429    menu_add_symbol(P_DESELECT, sym_lookup(yyvsp[-2].string, 0), yyvsp[-1].expr);
1430    printd(DEBUG_PARSE, "%s:%d:deselect\n", zconf_curname(), zconf_lineno());
1431;}
1432    break;
1433
1434  case 43:
1435
1436    {
1437    menu_add_symbol(P_SELECT, sym_lookup(yyvsp[-2].string, 0), yyvsp[-1].expr);
1438    printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno());
1439;}
1440    break;
1441
1442  case 44:
1443
1444    {
1445    menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,yyvsp[-3].symbol, yyvsp[-2].symbol), yyvsp[-1].expr);
1446    printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno());
1447;}
1448    break;
1449
1450  case 45:
1451
1452    {
1453    struct symbol *sym = sym_lookup(NULL, 0);
1454    sym->flags |= SYMBOL_CHOICE;
1455    menu_add_entry(sym);
1456    menu_add_expr(P_CHOICE, NULL, NULL);
1457    printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno());
1458;}
1459    break;
1460
1461  case 46:
1462
1463    {
1464    yyval.menu = menu_add_menu();
1465;}
1466    break;
1467
1468  case 47:
1469
1470    {
1471    if (zconf_endtoken(yyvsp[0].id, T_CHOICE, T_ENDCHOICE)) {
1472        menu_end_menu();
1473        printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno());
1474    }
1475;}
1476    break;
1477
1478  case 55:
1479
1480    {
1481    menu_add_prompt(P_PROMPT, yyvsp[-2].string, yyvsp[-1].expr);
1482    printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
1483;}
1484    break;
1485
1486  case 56:
1487
1488    {
1489    if (yyvsp[-2].id->stype == S_BOOLEAN || yyvsp[-2].id->stype == S_TRISTATE) {
1490        menu_set_type(yyvsp[-2].id->stype);
1491        printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
1492            zconf_curname(), zconf_lineno(),
1493            yyvsp[-2].id->stype);
1494    } else
1495        YYERROR;
1496;}
1497    break;
1498
1499  case 57:
1500
1501    {
1502    current_entry->sym->flags |= SYMBOL_OPTIONAL;
1503    printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno());
1504;}
1505    break;
1506
1507  case 58:
1508
1509    {
1510    menu_add_prop(P_RESET, NULL, NULL, yyvsp[-1].expr);
1511;}
1512    break;
1513
1514  case 59:
1515
1516    {
1517    if (yyvsp[-3].id->stype == S_UNKNOWN) {
1518        menu_add_symbol(P_DEFAULT, sym_lookup(yyvsp[-2].string, 0), yyvsp[-1].expr);
1519        printd(DEBUG_PARSE, "%s:%d:default\n",
1520            zconf_curname(), zconf_lineno());
1521    } else
1522        YYERROR;
1523;}
1524    break;
1525
1526  case 62:
1527
1528    {
1529    printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
1530    menu_add_entry(NULL);
1531    menu_add_dep(yyvsp[-1].expr);
1532    yyval.menu = menu_add_menu();
1533;}
1534    break;
1535
1536  case 63:
1537
1538    {
1539    if (zconf_endtoken(yyvsp[0].id, T_IF, T_ENDIF)) {
1540        menu_end_menu();
1541        printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno());
1542    }
1543;}
1544    break;
1545
1546  case 69:
1547
1548    {
1549    menu_add_entry(NULL);
1550    menu_add_prompt(P_MENU, yyvsp[-1].string, NULL);
1551    printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
1552;}
1553    break;
1554
1555  case 70:
1556
1557    {
1558    yyval.menu = menu_add_menu();
1559;}
1560    break;
1561
1562  case 71:
1563
1564    {
1565    if (zconf_endtoken(yyvsp[0].id, T_MENU, T_ENDMENU)) {
1566        menu_end_menu();
1567        printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno());
1568    }
1569;}
1570    break;
1571
1572  case 77:
1573
1574    {
1575    printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), yyvsp[-1].string);
1576    zconf_nextfile(yyvsp[-1].string);
1577;}
1578    break;
1579
1580  case 78:
1581
1582    {
1583    menu_add_entry(NULL);
1584    menu_add_prompt(P_COMMENT, yyvsp[-1].string, NULL);
1585    printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno());
1586;}
1587    break;
1588
1589  case 79:
1590
1591    {
1592    menu_end_entry();
1593;}
1594    break;
1595
1596  case 80:
1597
1598    {
1599    printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno());
1600    zconf_starthelp();
1601;}
1602    break;
1603
1604  case 81:
1605
1606    {
1607    current_entry->sym->help = yyvsp[0].string;
1608;}
1609    break;
1610
1611  case 86:
1612
1613    {
1614    menu_add_dep(yyvsp[-1].expr);
1615    printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno());
1616;}
1617    break;
1618
1619  case 87:
1620
1621    {
1622    menu_add_dep(yyvsp[-1].expr);
1623    printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno());
1624;}
1625    break;
1626
1627  case 88:
1628
1629    {
1630    menu_add_dep(yyvsp[-1].expr);
1631    printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno());
1632;}
1633    break;
1634
1635  case 90:
1636
1637    {
1638    menu_add_prompt(P_PROMPT, yyvsp[-1].string, yyvsp[0].expr);
1639;}
1640    break;
1641
1642  case 93:
1643
1644    { yyval.id = yyvsp[-1].id; ;}
1645    break;
1646
1647  case 94:
1648
1649    { yyval.id = yyvsp[-1].id; ;}
1650    break;
1651
1652  case 95:
1653
1654    { yyval.id = yyvsp[-1].id; ;}
1655    break;
1656
1657  case 98:
1658
1659    { yyval.expr = NULL; ;}
1660    break;
1661
1662  case 99:
1663
1664    { yyval.expr = yyvsp[0].expr; ;}
1665    break;
1666
1667  case 100:
1668
1669    { yyval.expr = expr_alloc_symbol(yyvsp[0].symbol); ;}
1670    break;
1671
1672  case 101:
1673
1674    { yyval.expr = expr_alloc_comp(E_EQUAL, yyvsp[-2].symbol, yyvsp[0].symbol); ;}
1675    break;
1676
1677  case 102:
1678
1679    { yyval.expr = expr_alloc_comp(E_UNEQUAL, yyvsp[-2].symbol, yyvsp[0].symbol); ;}
1680    break;
1681
1682  case 103:
1683
1684    { yyval.expr = yyvsp[-1].expr; ;}
1685    break;
1686
1687  case 104:
1688
1689    { yyval.expr = expr_alloc_one(E_NOT, yyvsp[0].expr); ;}
1690    break;
1691
1692  case 105:
1693
1694    { yyval.expr = expr_alloc_two(E_OR, yyvsp[-2].expr, yyvsp[0].expr); ;}
1695    break;
1696
1697  case 106:
1698
1699    { yyval.expr = expr_alloc_two(E_AND, yyvsp[-2].expr, yyvsp[0].expr); ;}
1700    break;
1701
1702  case 107:
1703
1704    { yyval.symbol = sym_lookup(yyvsp[0].string, 0); free(yyvsp[0].string); ;}
1705    break;
1706
1707  case 108:
1708
1709    { yyval.symbol = sym_lookup(yyvsp[0].string, 1); free(yyvsp[0].string); ;}
1710    break;
1711
1712
1713    }
1714
1715/* Line 1010 of yacc.c. */
1716
1717
1718  yyvsp -= yylen;
1719  yyssp -= yylen;
1720
1721
1722  YY_STACK_PRINT (yyss, yyssp);
1723
1724  *++yyvsp = yyval;
1725
1726
1727  /* Now `shift' the result of the reduction. Determine what state
1728     that goes to, based on the state we popped back to and the rule
1729     number reduced by. */
1730
1731  yyn = yyr1[yyn];
1732
1733  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1734  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1735    yystate = yytable[yystate];
1736  else
1737    yystate = yydefgoto[yyn - YYNTOKENS];
1738
1739  goto yynewstate;
1740
1741
1742/*------------------------------------.
1743| yyerrlab -- here on detecting error |
1744`------------------------------------*/
1745yyerrlab:
1746  /* If not already recovering from an error, report this error. */
1747  if (!yyerrstatus)
1748    {
1749      ++yynerrs;
1750#if YYERROR_VERBOSE
1751      yyn = yypact[yystate];
1752
1753      if (YYPACT_NINF < yyn && yyn < YYLAST)
1754    {
1755      YYSIZE_T yysize = 0;
1756      int yytype = YYTRANSLATE (yychar);
1757      const char* yyprefix;
1758      char *yymsg;
1759      int yyx;
1760
1761      /* Start YYX at -YYN if negative to avoid negative indexes in
1762         YYCHECK. */
1763      int yyxbegin = yyn < 0 ? -yyn : 0;
1764
1765      /* Stay within bounds of both yycheck and yytname. */
1766      int yychecklim = YYLAST - yyn;
1767      int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1768      int yycount = 0;
1769
1770      yyprefix = ", expecting ";
1771      for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1772        if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1773          {
1774        yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
1775        yycount += 1;
1776        if (yycount == 5)
1777          {
1778            yysize = 0;
1779            break;
1780          }
1781          }
1782      yysize += (sizeof ("syntax error, unexpected ")
1783             + yystrlen (yytname[yytype]));
1784      yymsg = (char *) YYSTACK_ALLOC (yysize);
1785      if (yymsg != 0)
1786        {
1787          char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
1788          yyp = yystpcpy (yyp, yytname[yytype]);
1789
1790          if (yycount < 5)
1791        {
1792          yyprefix = ", expecting ";
1793          for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1794            if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1795              {
1796            yyp = yystpcpy (yyp, yyprefix);
1797            yyp = yystpcpy (yyp, yytname[yyx]);
1798            yyprefix = " or ";
1799              }
1800        }
1801          yyerror (yymsg);
1802          YYSTACK_FREE (yymsg);
1803        }
1804      else
1805        yyerror ("syntax error; also virtual memory exhausted");
1806    }
1807      else
1808#endif /* YYERROR_VERBOSE */
1809    yyerror ("syntax error");
1810    }
1811
1812
1813
1814  if (yyerrstatus == 3)
1815    {
1816      /* If just tried and failed to reuse lookahead token after an
1817     error, discard it. */
1818
1819      if (yychar <= YYEOF)
1820        {
1821          /* If at end of input, pop the error token,
1822         then the rest of the stack, then return failure. */
1823      if (yychar == YYEOF)
1824         for (;;)
1825           {
1826         YYPOPSTACK;
1827         if (yyssp == yyss)
1828           YYABORT;
1829         YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1830         yydestruct (yystos[*yyssp], yyvsp);
1831           }
1832        }
1833      else
1834    {
1835      YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
1836      yydestruct (yytoken, &yylval);
1837      yychar = YYEMPTY;
1838
1839    }
1840    }
1841
1842  /* Else will try to reuse lookahead token after shifting the error
1843     token. */
1844  goto yyerrlab1;
1845
1846
1847/*---------------------------------------------------.
1848| yyerrorlab -- error raised explicitly by YYERROR. |
1849`---------------------------------------------------*/
1850yyerrorlab:
1851
1852#ifdef __GNUC__
1853  /* Pacify GCC when the user code never invokes YYERROR and the label
1854     yyerrorlab therefore never appears in user code. */
1855  if (0)
1856     goto yyerrorlab;
1857#endif
1858
1859  yyvsp -= yylen;
1860  yyssp -= yylen;
1861  yystate = *yyssp;
1862  goto yyerrlab1;
1863
1864
1865/*-------------------------------------------------------------.
1866| yyerrlab1 -- common code for both syntax error and YYERROR. |
1867`-------------------------------------------------------------*/
1868yyerrlab1:
1869  yyerrstatus = 3; /* Each real token shifted decrements this. */
1870
1871  for (;;)
1872    {
1873      yyn = yypact[yystate];
1874      if (yyn != YYPACT_NINF)
1875    {
1876      yyn += YYTERROR;
1877      if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1878        {
1879          yyn = yytable[yyn];
1880          if (0 < yyn)
1881        break;
1882        }
1883    }
1884
1885      /* Pop the current state because it cannot handle the error token. */
1886      if (yyssp == yyss)
1887    YYABORT;
1888
1889      YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1890      yydestruct (yystos[yystate], yyvsp);
1891      YYPOPSTACK;
1892      yystate = *yyssp;
1893      YY_STACK_PRINT (yyss, yyssp);
1894    }
1895
1896  if (yyn == YYFINAL)
1897    YYACCEPT;
1898
1899  YYDPRINTF ((stderr, "Shifting error token, "));
1900
1901  *++yyvsp = yylval;
1902
1903
1904  yystate = yyn;
1905  goto yynewstate;
1906
1907
1908/*-------------------------------------.
1909| yyacceptlab -- YYACCEPT comes here. |
1910`-------------------------------------*/
1911yyacceptlab:
1912  yyresult = 0;
1913  goto yyreturn;
1914
1915/*-----------------------------------.
1916| yyabortlab -- YYABORT comes here. |
1917`-----------------------------------*/
1918yyabortlab:
1919  yyresult = 1;
1920  goto yyreturn;
1921
1922#ifndef yyoverflow
1923/*----------------------------------------------.
1924| yyoverflowlab -- parser overflow comes here. |
1925`----------------------------------------------*/
1926yyoverflowlab:
1927  yyerror ("parser stack overflow");
1928  yyresult = 2;
1929  /* Fall through. */
1930#endif
1931
1932yyreturn:
1933#ifndef yyoverflow
1934  if (yyss != yyssa)
1935    YYSTACK_FREE (yyss);
1936#endif
1937  return yyresult;
1938}
1939
1940
1941
1942
1943
1944void conf_parse(const char *name)
1945{
1946    struct symbol *sym;
1947    int i;
1948
1949    zconf_initscan(name);
1950
1951    sym_init();
1952    menu_init();
1953    modules_sym = sym_lookup("MODULES", 0);
1954    rootmenu.prompt = menu_add_prompt(P_MENU, "OpenWrt Configuration", NULL);
1955
1956#if YYDEBUG
1957    if (getenv("ZCONF_DEBUG"))
1958        zconfdebug = 1;
1959#endif
1960    zconfparse();
1961    if (zconfnerrs)
1962        exit(1);
1963    menu_finalize(&rootmenu);
1964    for_all_symbols(i, sym) {
1965        sym_check_deps(sym);
1966        }
1967
1968    sym_change_count = 1;
1969}
1970
1971const char *zconf_tokenname(int token)
1972{
1973    switch (token) {
1974    case T_MENU: return "menu";
1975    case T_ENDMENU: return "endmenu";
1976    case T_CHOICE: return "choice";
1977    case T_ENDCHOICE: return "endchoice";
1978    case T_IF: return "if";
1979    case T_ENDIF: return "endif";
1980    case T_DEPENDS: return "depends";
1981    }
1982    return "<token>";
1983}
1984
1985static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken)
1986{
1987    if (id->token != endtoken) {
1988        zconf_error("unexpected '%s' within %s block",
1989            kconf_id_strings + id->name, zconf_tokenname(starttoken));
1990        zconfnerrs++;
1991        return false;
1992    }
1993    if (current_menu->file != current_file) {
1994        zconf_error("'%s' in different file than '%s'",
1995            kconf_id_strings + id->name, zconf_tokenname(starttoken));
1996        fprintf(stderr, "%s:%d: location of the '%s'\n",
1997            current_menu->file->name, current_menu->lineno,
1998            zconf_tokenname(starttoken));
1999        zconfnerrs++;
2000        return false;
2001    }
2002    return true;
2003}
2004
2005static void zconfprint(const char *err, ...)
2006{
2007    va_list ap;
2008
2009    fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
2010    va_start(ap, err);
2011    vfprintf(stderr, err, ap);
2012    va_end(ap);
2013    fprintf(stderr, "\n");
2014}
2015
2016static void zconf_error(const char *err, ...)
2017{
2018    va_list ap;
2019
2020    zconfnerrs++;
2021    fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
2022    va_start(ap, err);
2023    vfprintf(stderr, err, ap);
2024    va_end(ap);
2025    fprintf(stderr, "\n");
2026}
2027
2028static void zconferror(const char *err)
2029{
2030#if YYDEBUG
2031    fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
2032#endif
2033}
2034
2035void print_quoted_string(FILE *out, const char *str)
2036{
2037    const char *p;
2038    int len;
2039
2040    putc('"', out);
2041    while ((p = strchr(str, '"'))) {
2042        len = p - str;
2043        if (len)
2044            fprintf(out, "%.*s", len, str);
2045        fputs("\\\"", out);
2046        str = p + 1;
2047    }
2048    fputs(str, out);
2049    putc('"', out);
2050}
2051
2052void print_symbol(FILE *out, struct menu *menu)
2053{
2054    struct symbol *sym = menu->sym;
2055    struct property *prop;
2056
2057    if (sym_is_choice(sym))
2058        fprintf(out, "choice\n");
2059    else
2060        fprintf(out, "config %s\n", sym->name);
2061    switch (sym->type) {
2062    case S_BOOLEAN:
2063        fputs(" boolean\n", out);
2064        break;
2065    case S_TRISTATE:
2066        fputs(" tristate\n", out);
2067        break;
2068    case S_STRING:
2069        fputs(" string\n", out);
2070        break;
2071    case S_INT:
2072        fputs(" integer\n", out);
2073        break;
2074    case S_HEX:
2075        fputs(" hex\n", out);
2076        break;
2077    default:
2078        fputs(" ???\n", out);
2079        break;
2080    }
2081    for (prop = sym->prop; prop; prop = prop->next) {
2082        if (prop->menu != menu)
2083            continue;
2084        switch (prop->type) {
2085        case P_PROMPT:
2086            fputs(" prompt ", out);
2087            print_quoted_string(out, prop->text);
2088            if (!expr_is_yes(prop->visible.expr)) {
2089                fputs(" if ", out);
2090                expr_fprint(prop->visible.expr, out);
2091            }
2092            fputc('\n', out);
2093            break;
2094        case P_DEFAULT:
2095            fputs( " default ", out);
2096            expr_fprint(prop->expr, out);
2097            if (!expr_is_yes(prop->visible.expr)) {
2098                fputs(" if ", out);
2099                expr_fprint(prop->visible.expr, out);
2100            }
2101            fputc('\n', out);
2102            break;
2103        case P_CHOICE:
2104            fputs(" #choice value\n", out);
2105            break;
2106        default:
2107            fprintf(out, " unknown prop %d!\n", prop->type);
2108            break;
2109        }
2110    }
2111    if (sym->help) {
2112        int len = strlen(sym->help);
2113        while (sym->help[--len] == '\n')
2114            sym->help[len] = 0;
2115        fprintf(out, " help\n%s\n", sym->help);
2116    }
2117    fputc('\n', out);
2118}
2119
2120void zconfdump(FILE *out)
2121{
2122    struct property *prop;
2123    struct symbol *sym;
2124    struct menu *menu;
2125
2126    menu = rootmenu.list;
2127    while (menu) {
2128        if ((sym = menu->sym))
2129            print_symbol(out, menu);
2130        else if ((prop = menu->prompt)) {
2131            switch (prop->type) {
2132            case P_COMMENT:
2133                fputs("\ncomment ", out);
2134                print_quoted_string(out, prop->text);
2135                fputs("\n", out);
2136                break;
2137            case P_MENU:
2138                fputs("\nmenu ", out);
2139                print_quoted_string(out, prop->text);
2140                fputs("\n", out);
2141                break;
2142            default:
2143                ;
2144            }
2145            if (!expr_is_yes(prop->visible.expr)) {
2146                fputs(" depends ", out);
2147                expr_fprint(prop->visible.expr, out);
2148                fputc('\n', out);
2149            }
2150            fputs("\n", out);
2151        }
2152
2153        if (menu->list)
2154            menu = menu->list;
2155        else if (menu->next)
2156            menu = menu->next;
2157        else while ((menu = menu->parent)) {
2158            if (menu->prompt && menu->prompt->type == P_MENU)
2159                fputs("\nendmenu\n", out);
2160            if (menu->next) {
2161                menu = menu->next;
2162                break;
2163            }
2164        }
2165    }
2166}
2167
2168#include "lex.zconf.c"
2169#include "util.c"
2170#include "confdata.c"
2171#include "expr.c"
2172#include "symbol.c"
2173#include "menu.c"
2174
2175
2176

Archive Download this file



interactive