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