1 /* A Bison parser, made from zconf.y, by GNU bison 1.75. */
3 /* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
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)
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.
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. */
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. */
26 /* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
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. */
36 /* Identify Bison output. */
42 /* Using locations. */
43 #define YYLSP_NEEDED 0
45 /* If NAME_PREFIX is specified substitute the variables and functions
47 #define yyparse zconfparse
48 #define yylex zconflex
49 #define yyerror zconferror
50 #define yylval zconflval
51 #define yychar zconfchar
52 #define yydebug zconfdebug
53 #define yynerrs zconfnerrs
59 /* Put the tokens into the symbol table, so that GDB and other debuggers
97 #define T_MAINMENU 258
102 #define T_ENDCHOICE 263
103 #define T_COMMENT 264
106 #define T_HELPTEXT 267
109 #define T_DEPENDS 270
110 #define T_REQUIRES 271
111 #define T_OPTIONAL 272
113 #define T_DEFAULT 274
114 #define T_TRISTATE 275
115 #define T_BOOLEAN 276
120 #define T_UNEQUAL 281
123 #define T_CLOSE_PAREN 284
124 #define T_OPEN_PAREN 285
134 /* Copy the first part of user declarations. */
138 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
139 * Released under the terms of the GNU GPL v2.0.
149 #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
151 #define PRINTD 0x0001
152 #define DEBUG_PARSE 0x0002
156 extern int zconflex(void);
157 static void zconfprint(const char *err, ...);
158 static void zconferror(const char *err);
159 static bool zconf_endtoken(int token, int starttoken, int endtoken);
161 struct symbol *symbol_hash[257];
163 #define YYERROR_VERBOSE
166 /* Enabling traces. */
171 /* Enabling verbose error messages. */
172 #ifdef YYERROR_VERBOSE
173 # undef YYERROR_VERBOSE
174 # define YYERROR_VERBOSE 1
176 # define YYERROR_VERBOSE 0
184 struct symbol *symbol;
188 /* Line 193 of /usr/share/bison/yacc.c. */
189 #line 190 "zconf.tab.c"
190 # define YYSTYPE yystype
191 # define YYSTYPE_IS_TRIVIAL 1
195 typedef struct yyltype
202 # define YYLTYPE yyltype
203 # define YYLTYPE_IS_TRIVIAL 1
206 /* Copy the second part of user declarations. */
209 #define LKC_DIRECT_LINK
213 /* Line 213 of /usr/share/bison/yacc.c. */
214 #line 215 "zconf.tab.c"
216 #if !defined(yyoverflow) || YYERROR_VERBOSE
218 /* The parser invokes alloca or malloc; define the necessary symbols. */
220 # if YYSTACK_USE_ALLOCA
221 # define YYSTACK_ALLOC alloca
223 # ifndef YYSTACK_USE_ALLOCA
224 # if defined (alloca) || defined (_ALLOCA_H)
225 # define YYSTACK_ALLOC alloca
228 # define YYSTACK_ALLOC __builtin_alloca
234 # ifdef YYSTACK_ALLOC
235 /* Pacify GCC's `empty if-body' warning. */
236 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
238 # if defined (__STDC__) || defined (__cplusplus)
239 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
240 # define YYSIZE_T size_t
242 # define YYSTACK_ALLOC malloc
243 # define YYSTACK_FREE free
245 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
248 #if (!defined(yyoverflow) \
249 && (! defined (__cplusplus) \
250 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
252 /* A type that is properly aligned for any stack member. */
259 /* The size of the maximum gap between one aligned stack and the next. */
260 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
262 /* The size of an array large to enough to hold all stacks, each with
264 # define YYSTACK_BYTES(N) \
265 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
268 /* Copy COUNT objects from FROM to TO. The source and destination do
272 # define YYCOPY(To, From, Count) \
273 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
275 # define YYCOPY(To, From, Count) \
278 register YYSIZE_T yyi; \
279 for (yyi = 0; yyi < (Count); yyi++) \
280 (To)[yyi] = (From)[yyi]; \
286 /* Relocate STACK from its old location to the new one. The
287 local variables YYSIZE and YYSTACKSIZE give the old and new number of
288 elements in the stack, and YYPTR gives the new location of the
289 stack. Advance YYPTR to a properly aligned location for the next
291 # define YYSTACK_RELOCATE(Stack) \
294 YYSIZE_T yynewbytes; \
295 YYCOPY (&yyptr->Stack, Stack, yysize); \
296 Stack = &yyptr->Stack; \
297 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
298 yyptr += yynewbytes / sizeof (*yyptr); \
304 #if defined(__STDC__) || defined(__cplusplus)
305 typedef signed char yysigned_char;
307 typedef short yysigned_char;
310 /* YYFINAL -- State number of the termination state. */
314 /* YYNTOKENS -- Number of terminals. */
316 /* YYNNTS -- Number of nonterminals. */
318 /* YYNRULES -- Number of rules. */
320 /* YYNRULES -- Number of states. */
321 #define YYNSTATES 145
323 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
325 #define YYMAXUTOK 290
327 #define YYTRANSLATE(X) \
328 ((unsigned)(X) <= YYMAXUTOK ? yytranslate[X] : YYUNDEFTOK)
330 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
331 static const unsigned char yytranslate[] =
333 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
334 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
335 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
336 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
337 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
338 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
339 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
340 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
341 2, 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, 1, 2, 3, 4,
359 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
360 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
361 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
366 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
368 static const unsigned short yyprhs[] =
370 0, 0, 3, 4, 7, 9, 11, 13, 17, 19,
371 21, 23, 26, 28, 30, 32, 34, 36, 39, 43,
372 44, 48, 52, 55, 58, 61, 64, 67, 70, 73,
373 77, 81, 83, 87, 89, 94, 97, 98, 102, 106,
374 109, 112, 116, 118, 121, 122, 125, 128, 130, 136,
375 140, 141, 144, 147, 150, 153, 157, 159, 164, 167,
376 168, 171, 174, 177, 181, 184, 187, 190, 194, 197,
377 200, 201, 205, 208, 212, 215, 218, 219, 221, 225,
378 227, 229, 231, 233, 235, 237, 239, 240, 243, 245,
379 249, 253, 257, 260, 264, 268, 270
382 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
383 static const yysigned_char yyrhs[] =
385 37, 0, -1, -1, 37, 38, -1, 39, -1, 47,
386 -1, 58, -1, 3, 69, 71, -1, 5, -1, 14,
387 -1, 8, -1, 1, 71, -1, 53, -1, 63, -1,
388 41, -1, 61, -1, 71, -1, 10, 24, -1, 40,
389 28, 42, -1, -1, 42, 43, 28, -1, 42, 67,
390 28, -1, 42, 65, -1, 42, 28, -1, 20, 68,
391 -1, 21, 68, -1, 22, 68, -1, 23, 68, -1,
392 25, 68, -1, 18, 69, 72, -1, 19, 74, 72,
393 -1, 7, -1, 44, 28, 48, -1, 70, -1, 45,
394 50, 46, 28, -1, 45, 50, -1, -1, 48, 49,
395 28, -1, 48, 67, 28, -1, 48, 65, -1, 48,
396 28, -1, 18, 69, 72, -1, 17, -1, 19, 74,
397 -1, -1, 50, 39, -1, 13, 73, -1, 70, -1,
398 51, 28, 54, 52, 28, -1, 51, 28, 54, -1,
399 -1, 54, 39, -1, 54, 58, -1, 54, 47, -1,
400 4, 69, -1, 55, 28, 66, -1, 70, -1, 56,
401 59, 57, 28, -1, 56, 59, -1, -1, 59, 39,
402 -1, 59, 58, -1, 59, 47, -1, 59, 1, 28,
403 -1, 6, 69, -1, 60, 28, -1, 9, 69, -1,
404 62, 28, 66, -1, 11, 28, -1, 64, 12, -1,
405 -1, 66, 67, 28, -1, 66, 28, -1, 15, 31,
406 73, -1, 15, 73, -1, 16, 73, -1, -1, 69,
407 -1, 69, 13, 73, -1, 24, -1, 25, -1, 5,
408 -1, 8, -1, 14, -1, 28, -1, 27, -1, -1,
409 13, 73, -1, 74, -1, 74, 34, 74, -1, 74,
410 26, 74, -1, 30, 73, 29, -1, 35, 73, -1,
411 73, 32, 73, -1, 73, 33, 73, -1, 24, -1,
415 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
416 static const unsigned short yyrline[] =
418 0, 88, 88, 89, 92, 93, 94, 95, 96, 97,
419 98, 99, 102, 104, 105, 106, 107, 113, 121, 127,
420 129, 130, 131, 132, 135, 141, 147, 153, 159, 165,
421 171, 179, 188, 194, 202, 204, 210, 212, 213, 214,
422 215, 218, 224, 230, 237, 239, 244, 254, 262, 264,
423 270, 272, 273, 274, 279, 286, 292, 300, 302, 308,
424 310, 311, 312, 313, 316, 322, 329, 336, 343, 349,
425 356, 357, 358, 361, 366, 371, 379, 381, 385, 390,
426 391, 394, 395, 396, 399, 400, 402, 403, 406, 407,
427 408, 409, 410, 411, 412, 415, 416
431 #if YYDEBUG || YYERROR_VERBOSE
432 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
433 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
434 static const char *const yytname[] =
436 "$end", "error", "$undefined", "T_MAINMENU", "T_MENU", "T_ENDMENU",
437 "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG",
438 "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS", "T_REQUIRES",
439 "T_OPTIONAL", "T_PROMPT", "T_DEFAULT", "T_TRISTATE", "T_BOOLEAN",
440 "T_INT", "T_HEX", "T_WORD", "T_STRING", "T_UNEQUAL", "T_EOF", "T_EOL",
441 "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_ON", "T_OR", "T_AND", "T_EQUAL",
442 "T_NOT", "$accept", "input", "block", "common_block",
443 "config_entry_start", "config_stmt", "config_option_list",
444 "config_option", "choice", "choice_entry", "choice_end", "choice_stmt",
445 "choice_option_list", "choice_option", "choice_block", "if", "if_end",
446 "if_stmt", "if_block", "menu", "menu_entry", "menu_end", "menu_stmt",
447 "menu_block", "source", "source_stmt", "comment", "comment_stmt",
448 "help_start", "help", "depends_list", "depends", "prompt_stmt_opt",
449 "prompt", "end", "nl_or_eof", "if_expr", "expr", "symbol", 0
454 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
456 static const unsigned short yytoknum[] =
458 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
459 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
460 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
461 285, 286, 287, 288, 289, 290
465 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
466 static const unsigned char yyr1[] =
468 0, 36, 37, 37, 38, 38, 38, 38, 38, 38,
469 38, 38, 39, 39, 39, 39, 39, 40, 41, 42,
470 42, 42, 42, 42, 43, 43, 43, 43, 43, 43,
471 43, 44, 45, 46, 47, 47, 48, 48, 48, 48,
472 48, 49, 49, 49, 50, 50, 51, 52, 53, 53,
473 54, 54, 54, 54, 55, 56, 57, 58, 58, 59,
474 59, 59, 59, 59, 60, 61, 62, 63, 64, 65,
475 66, 66, 66, 67, 67, 67, 68, 68, 68, 69,
476 69, 70, 70, 70, 71, 71, 72, 72, 73, 73,
477 73, 73, 73, 73, 73, 74, 74
480 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
481 static const unsigned char yyr2[] =
483 0, 2, 0, 2, 1, 1, 1, 3, 1, 1,
484 1, 2, 1, 1, 1, 1, 1, 2, 3, 0,
485 3, 3, 2, 2, 2, 2, 2, 2, 2, 3,
486 3, 1, 3, 1, 4, 2, 0, 3, 3, 2,
487 2, 3, 1, 2, 0, 2, 2, 1, 5, 3,
488 0, 2, 2, 2, 2, 3, 1, 4, 2, 0,
489 2, 2, 2, 3, 2, 2, 2, 3, 2, 2,
490 0, 3, 2, 3, 2, 2, 0, 1, 3, 1,
491 1, 1, 1, 1, 1, 1, 0, 2, 1, 3,
495 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
496 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
497 means the default is an error. */
498 static const unsigned char yydefact[] =
500 2, 0, 1, 0, 0, 0, 8, 0, 31, 10,
501 0, 0, 0, 9, 85, 84, 3, 4, 0, 14,
502 0, 44, 5, 0, 12, 0, 59, 6, 0, 15,
503 0, 13, 16, 11, 79, 80, 0, 54, 64, 66,
504 17, 95, 96, 0, 0, 46, 88, 19, 36, 35,
505 50, 70, 0, 65, 70, 7, 0, 92, 0, 0,
506 0, 0, 18, 32, 81, 82, 83, 45, 0, 33,
507 49, 55, 0, 60, 62, 0, 61, 56, 67, 91,
508 93, 94, 90, 89, 0, 0, 0, 0, 0, 76,
509 76, 76, 76, 76, 23, 0, 0, 22, 0, 42,
510 0, 0, 40, 0, 39, 0, 34, 51, 53, 0,
511 52, 47, 72, 0, 63, 57, 68, 0, 74, 75,
512 86, 86, 24, 77, 25, 26, 27, 28, 20, 69,
513 21, 86, 43, 37, 38, 48, 71, 73, 0, 29,
517 /* YYDEFGOTO[NTERM-NUM]. */
518 static const short yydefgoto[] =
520 -1, 1, 16, 17, 18, 19, 62, 95, 20, 21,
521 68, 22, 63, 103, 49, 23, 109, 24, 70, 25,
522 26, 75, 27, 52, 28, 29, 30, 31, 96, 97,
523 71, 113, 122, 123, 69, 32, 139, 45, 46
526 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
528 #define YYPACT_NINF -120
529 static const short yypact[] =
531 -120, 17, -120, 41, 48, 48, -120, 48, -120, -120,
532 48, -11, 40, -120, -120, -120, -120, -120, 13, -120,
533 23, -120, -120, 66, -120, 72, -120, -120, 77, -120,
534 81, -120, -120, -120, -120, -120, 41, -120, -120, -120,
535 -120, -120, -120, 40, 40, 57, 59, -120, -120, 98,
536 -120, -120, 49, -120, -120, -120, 7, -120, 40, 40,
537 67, 67, 99, 117, -120, -120, -120, -120, 85, -120,
538 74, 18, 88, -120, -120, 95, -120, -120, 18, -120,
539 96, -120, -120, -120, 102, 36, 40, 48, 67, 48,
540 48, 48, 48, 48, -120, 103, 129, -120, 114, -120,
541 48, 67, -120, 115, -120, 116, -120, -120, -120, 118,
542 -120, -120, -120, 119, -120, -120, -120, 40, 57, 57,
543 135, 135, -120, 136, -120, -120, -120, -120, -120, -120,
544 -120, 135, -120, -120, -120, -120, -120, 57, 40, -120,
545 -120, 40, -120, 57, 57
548 /* YYPGOTO[NTERM-NUM]. */
549 static const yysigned_char yypgoto[] =
551 -120, -120, -120, -38, -120, -120, -120, -120, -120, -120,
552 -120, -42, -120, -120, -120, -120, -120, -120, -120, -120,
553 -120, -120, -33, -120, -120, -120, -120, -120, -120, 87,
554 97, 34, 47, -1, -23, 2, -119, -43, -53
557 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
558 positive, shift that token. If negative, reduce the rule which
559 number is the opposite. If zero, do what YYDEFACT says.
560 If YYTABLE_NINF, parse error. */
561 #define YYTABLE_NINF -59
562 static const short yytable[] =
564 56, 57, 140, 36, 37, 33, 38, 82, 83, 39,
565 74, 67, 142, 40, 73, 80, 81, 2, 3, 76,
566 4, 5, 6, 7, 8, 9, 10, 11, 108, 77,
567 12, 13, 107, 85, 86, 121, 79, 110, 55, 58,
568 59, 47, 118, 119, 14, 15, 112, 111, 132, -58,
569 72, 48, -58, 5, 64, 7, 8, 65, 10, 11,
570 41, 42, 12, 66, 41, 42, 43, 117, 14, 15,
571 43, 44, 34, 35, 137, 44, 14, 15, 5, 64,
572 7, 8, 65, 10, 11, 60, 120, 12, 66, 58,
573 59, 41, 42, 61, 50, 143, 98, 105, 144, 131,
574 51, 14, 15, 64, 7, 53, 65, 10, 11, 54,
575 84, 12, 66, 106, 85, 86, 114, 87, 88, 89,
576 90, 91, 92, 115, 93, 14, 15, 94, 84, 59,
577 116, 128, 85, 86, 99, 100, 101, 124, 125, 126,
578 127, 129, 130, 133, 134, 102, 135, 136, 138, 141,
582 static const unsigned char yycheck[] =
584 43, 44, 121, 4, 5, 3, 7, 60, 61, 10,
585 52, 49, 131, 24, 52, 58, 59, 0, 1, 52,
586 3, 4, 5, 6, 7, 8, 9, 10, 70, 52,
587 13, 14, 70, 15, 16, 88, 29, 70, 36, 32,
588 33, 28, 85, 86, 27, 28, 28, 70, 101, 0,
589 1, 28, 3, 4, 5, 6, 7, 8, 9, 10,
590 24, 25, 13, 14, 24, 25, 30, 31, 27, 28,
591 30, 35, 24, 25, 117, 35, 27, 28, 4, 5,
592 6, 7, 8, 9, 10, 26, 87, 13, 14, 32,
593 33, 24, 25, 34, 28, 138, 62, 63, 141, 100,
594 28, 27, 28, 5, 6, 28, 8, 9, 10, 28,
595 11, 13, 14, 28, 15, 16, 28, 18, 19, 20,
596 21, 22, 23, 28, 25, 27, 28, 28, 11, 33,
597 28, 28, 15, 16, 17, 18, 19, 90, 91, 92,
598 93, 12, 28, 28, 28, 28, 28, 28, 13, 13,
602 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
603 symbol of state STATE-NUM. */
604 static const unsigned char yystos[] =
606 0, 37, 0, 1, 3, 4, 5, 6, 7, 8,
607 9, 10, 13, 14, 27, 28, 38, 39, 40, 41,
608 44, 45, 47, 51, 53, 55, 56, 58, 60, 61,
609 62, 63, 71, 71, 24, 25, 69, 69, 69, 69,
610 24, 24, 25, 30, 35, 73, 74, 28, 28, 50,
611 28, 28, 59, 28, 28, 71, 73, 73, 32, 33,
612 26, 34, 42, 48, 5, 8, 14, 39, 46, 70,
613 54, 66, 1, 39, 47, 57, 58, 70, 66, 29,
614 73, 73, 74, 74, 11, 15, 16, 18, 19, 20,
615 21, 22, 23, 25, 28, 43, 64, 65, 67, 17,
616 18, 19, 28, 49, 65, 67, 28, 39, 47, 52,
617 58, 70, 28, 67, 28, 28, 28, 31, 73, 73,
618 69, 74, 68, 69, 68, 68, 68, 68, 28, 12,
619 28, 69, 74, 28, 28, 28, 28, 73, 13, 72,
623 #if !defined(YYSIZE_T) && defined(__SIZE_TYPE__)
624 # define YYSIZE_T __SIZE_TYPE__
626 #if !defined(YYSIZE_T) && defined(size_t)
627 # define YYSIZE_T size_t
629 #if !defined(YYSIZE_T)
630 # if defined (__STDC__) || defined (__cplusplus)
631 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
632 # define YYSIZE_T size_t
635 #if !defined(YYSIZE_T)
636 # define YYSIZE_T unsigned int
639 #define yyerrok (yyerrstatus = 0)
640 #define yyclearin (yychar = YYEMPTY)
644 #define YYACCEPT goto yyacceptlab
645 #define YYABORT goto yyabortlab
646 #define YYERROR goto yyerrlab1
648 /* Like YYERROR except do call yyerror. This remains here temporarily
649 to ease the transition to the new meaning of YYERROR, for GCC.
650 Once GCC version 2 has supplanted version 1, this can go. */
652 #define YYFAIL goto yyerrlab
654 #define YYRECOVERING() (!!yyerrstatus)
656 #define YYBACKUP(Token, Value) \
658 if (yychar == YYEMPTY && yylen == 1) \
662 yychar1 = YYTRANSLATE (yychar); \
668 yyerror ("syntax error: cannot back up"); \
674 #define YYERRCODE 256
676 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
679 #ifndef YYLLOC_DEFAULT
680 # define YYLLOC_DEFAULT(Current, Rhs, N) \
681 Current.first_line = Rhs[1].first_line; \
682 Current.first_column = Rhs[1].first_column; \
683 Current.last_line = Rhs[N].last_line; \
684 Current.last_column = Rhs[N].last_column;
687 /* YYLEX -- calling `yylex' with the right arguments. */
689 #define YYLEX yylex ()
691 /* Enable debugging if requested. */
695 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
696 # define YYFPRINTF fprintf
699 # define YYDPRINTF(Args) \
704 # define YYDSYMPRINT(Args) \
709 /* Nonzero means print parse trace. It is left uninitialized so that
710 multiple parsers can coexist. */
713 # define YYDPRINTF(Args)
714 # define YYDSYMPRINT(Args)
715 #endif /* !YYDEBUG */
717 /* YYINITDEPTH -- initial size of the parser's stacks. */
719 # define YYINITDEPTH 200
722 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
723 if the built-in stack extension method is used).
725 Do not make this value too large; the results are undefined if
726 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
727 evaluated with infinite-precision integer arithmetic. */
734 # define YYMAXDEPTH 10000
742 # if defined (__GLIBC__) && defined (_STRING_H)
743 # define yystrlen strlen
745 /* Return the length of YYSTR. */
747 # if defined (__STDC__) || defined (__cplusplus)
748 yystrlen (const char *yystr)
754 register const char *yys = yystr;
756 while (*yys++ != '\0')
759 return yys - yystr - 1;
765 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
766 # define yystpcpy stpcpy
768 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
771 # if defined (__STDC__) || defined (__cplusplus)
772 yystpcpy (char *yydest, const char *yysrc)
774 yystpcpy (yydest, yysrc)
779 register char *yyd = yydest;
780 register const char *yys = yysrc;
782 while ((*yyd++ = *yys++) != '\0')
790 #endif /* !YYERROR_VERBOSE */
795 /*-----------------------------.
796 | Print this symbol on YYOUT. |
797 `-----------------------------*/
800 #if defined(__STDC__) || defined(__cplusplus)
801 yysymprint (FILE* yyout, int yytype, YYSTYPE yyvalue)
803 yysymprint (yyout, yytype, yyvalue)
809 /* Pacify ``unused variable'' warnings. */
812 if (yytype < YYNTOKENS)
814 YYFPRINTF (yyout, "token %s (", yytname[yytype]);
816 YYPRINT (yyout, yytoknum[yytype], yyvalue);
820 YYFPRINTF (yyout, "nterm %s (", yytname[yytype]);
827 YYFPRINTF (yyout, ")");
829 #endif /* YYDEBUG. */
832 /*-----------------------------------------------.
833 | Release the memory associated to this symbol. |
834 `-----------------------------------------------*/
837 #if defined(__STDC__) || defined(__cplusplus)
838 yydestruct (int yytype, YYSTYPE yyvalue)
840 yydestruct (yytype, yyvalue)
845 /* Pacify ``unused variable'' warnings. */
857 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
858 into yyparse. The argument should have type void *.
859 It should actually point to an object.
860 Grammar actions can access the variable by casting it
861 to the proper pointer type. */
864 # if defined (__STDC__) || defined (__cplusplus)
865 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
866 # define YYPARSE_PARAM_DECL
868 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
869 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
871 #else /* !YYPARSE_PARAM */
872 # define YYPARSE_PARAM_ARG
873 # define YYPARSE_PARAM_DECL
874 #endif /* !YYPARSE_PARAM */
876 /* Prevent warning if -Wstrict-prototypes. */
878 # ifdef YYPARSE_PARAM
879 int yyparse (void *);
886 /* The lookahead symbol. */
889 /* The semantic value of the lookahead symbol. */
892 /* Number of parse errors so far. */
897 yyparse (YYPARSE_PARAM_ARG)
901 register int yystate;
904 /* Number of tokens to shift before error messages enabled. */
906 /* Lookahead token as an internal (translated) token number. */
909 /* Three stacks and their tools:
910 `yyss': related to states,
911 `yyvs': related to semantic values,
912 `yyls': related to locations.
914 Refer to the stacks thru separate pointers, to allow yyoverflow
915 to reallocate them elsewhere. */
917 /* The state stack. */
918 short yyssa[YYINITDEPTH];
920 register short *yyssp;
922 /* The semantic value stack. */
923 YYSTYPE yyvsa[YYINITDEPTH];
924 YYSTYPE *yyvs = yyvsa;
925 register YYSTYPE *yyvsp;
929 #define YYPOPSTACK (yyvsp--, yyssp--)
931 YYSIZE_T yystacksize = YYINITDEPTH;
933 /* The variables used to return semantic value and location from the
938 /* When reducing, the number of symbols on the RHS of the reduced
942 YYDPRINTF ((stderr, "Starting parse\n"));
947 yychar = YYEMPTY; /* Cause a token to be read. */
949 /* Initialize stack pointers.
950 Waste one element of value and location stack
951 so that they stay on the same level as the state stack.
952 The wasted elements are never initialized. */
959 /*------------------------------------------------------------.
960 | yynewstate -- Push a new state, which is found in yystate. |
961 `------------------------------------------------------------*/
963 /* In all cases, when you get here, the value and location stacks
964 have just been pushed. so pushing a state here evens the stacks.
971 if (yyssp >= yyss + yystacksize - 1)
973 /* Get the current used size of the three stacks, in elements. */
974 YYSIZE_T yysize = yyssp - yyss + 1;
978 /* Give user a chance to reallocate the stack. Use copies of
979 these so that the &'s don't force the real ones into
981 YYSTYPE *yyvs1 = yyvs;
985 /* Each stack pointer address is followed by the size of the
986 data in use in that stack, in bytes. This used to be a
987 conditional around just the two extra args, but that might
988 be undefined if yyoverflow is a macro. */
989 yyoverflow ("parser stack overflow",
990 &yyss1, yysize * sizeof (*yyssp),
991 &yyvs1, yysize * sizeof (*yyvsp),
998 #else /* no yyoverflow */
999 # ifndef YYSTACK_RELOCATE
1002 /* Extend the stack our own way. */
1003 if (yystacksize >= YYMAXDEPTH)
1006 if (yystacksize > YYMAXDEPTH)
1007 yystacksize = YYMAXDEPTH;
1010 short *yyss1 = yyss;
1011 union yyalloc *yyptr =
1012 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1015 YYSTACK_RELOCATE (yyss);
1016 YYSTACK_RELOCATE (yyvs);
1018 # undef YYSTACK_RELOCATE
1020 YYSTACK_FREE (yyss1);
1023 #endif /* no yyoverflow */
1025 yyssp = yyss + yysize - 1;
1026 yyvsp = yyvs + yysize - 1;
1029 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1030 (unsigned long int) yystacksize));
1032 if (yyssp >= yyss + yystacksize - 1)
1036 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1045 /* Do appropriate processing given the current state. */
1046 /* Read a lookahead token if we need one and don't already have one. */
1049 /* First try to decide what to do without reference to lookahead token. */
1051 yyn = yypact[yystate];
1052 if (yyn == YYPACT_NINF)
1055 /* Not known => get a lookahead token if don't already have one. */
1057 /* yychar is either YYEMPTY or YYEOF
1058 or a valid token in external form. */
1060 if (yychar == YYEMPTY)
1062 YYDPRINTF ((stderr, "Reading a token: "));
1066 /* Convert token to internal form (in yychar1) for indexing tables with. */
1068 if (yychar <= 0) /* This means end of input. */
1071 yychar = YYEOF; /* Don't call YYLEX any more. */
1073 YYDPRINTF ((stderr, "Now at end of input.\n"));
1077 yychar1 = YYTRANSLATE (yychar);
1079 /* We have to keep this `#if YYDEBUG', since we use variables
1080 which are defined only if `YYDEBUG' is set. */
1081 YYDPRINTF ((stderr, "Next token is "));
1082 YYDSYMPRINT ((stderr, yychar1, yylval));
1083 YYDPRINTF ((stderr, "\n"));
1086 /* If the proper action on seeing token YYCHAR1 is to reduce or to
1087 detect an error, take that action. */
1089 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yychar1)
1094 if (yyn == 0 || yyn == YYTABLE_NINF)
1103 /* Shift the lookahead token. */
1104 YYDPRINTF ((stderr, "Shifting token %d (%s), ",
1105 yychar, yytname[yychar1]));
1107 /* Discard the token being shifted unless it is eof. */
1108 if (yychar != YYEOF)
1114 /* Count tokens shifted since error; after three, turn off error
1123 /*-----------------------------------------------------------.
1124 | yydefault -- do the default action for the current state. |
1125 `-----------------------------------------------------------*/
1127 yyn = yydefact[yystate];
1133 /*-----------------------------.
1134 | yyreduce -- Do a reduction. |
1135 `-----------------------------*/
1137 /* yyn is the number of a rule to reduce with. */
1140 /* If YYLEN is nonzero, implement the default value of the action:
1143 Otherwise, the following line sets YYVAL to garbage.
1144 This behavior is undocumented and Bison
1145 users should not rely upon it. Assigning to YYVAL
1146 unconditionally makes the parser a bit smaller, and it avoids a
1147 GCC warning that YYVAL may be used uninitialized. */
1148 yyval = yyvsp[1-yylen];
1153 /* We have to keep this `#if YYDEBUG', since we use variables which
1154 are defined only if `YYDEBUG' is set. */
1159 YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
1160 yyn - 1, yyrline[yyn]);
1162 /* Print the symbols being reduced, and their result. */
1163 for (yyi = yyprhs[yyn]; yyrhs[yyi] >= 0; yyi++)
1164 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
1165 YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1172 { zconfprint("unexpected 'endmenu' statement"); }
1177 { zconfprint("unexpected 'endif' statement"); }
1182 { zconfprint("unexpected 'endchoice' statement"); }
1187 { zconfprint("syntax error"); yyerrok; }
1193 struct symbol *sym = sym_lookup(yyvsp[0].string, 0);
1194 sym->flags |= SYMBOL_OPTIONAL;
1195 menu_add_entry(sym);
1196 printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), yyvsp[0].string);
1204 printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
1216 menu_set_type(S_TRISTATE);
1217 printd(DEBUG_PARSE, "%s:%d:tristate\n", zconf_curname(), zconf_lineno());
1224 menu_set_type(S_BOOLEAN);
1225 printd(DEBUG_PARSE, "%s:%d:boolean\n", zconf_curname(), zconf_lineno());
1232 menu_set_type(S_INT);
1233 printd(DEBUG_PARSE, "%s:%d:int\n", zconf_curname(), zconf_lineno());
1240 menu_set_type(S_HEX);
1241 printd(DEBUG_PARSE, "%s:%d:hex\n", zconf_curname(), zconf_lineno());
1248 menu_set_type(S_STRING);
1249 printd(DEBUG_PARSE, "%s:%d:string\n", zconf_curname(), zconf_lineno());
1256 menu_add_prop(P_PROMPT, yyvsp[-1].string, NULL, yyvsp[0].expr);
1257 printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
1264 menu_add_prop(P_DEFAULT, NULL, yyvsp[-1].symbol, yyvsp[0].expr);
1265 printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno());
1272 struct symbol *sym = sym_lookup(NULL, 0);
1273 sym->flags |= SYMBOL_CHOICE;
1274 menu_add_entry(sym);
1275 menu_add_prop(P_CHOICE, NULL, NULL, NULL);
1276 printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno());
1291 if (zconf_endtoken(yyvsp[0].token, T_CHOICE, T_ENDCHOICE)) {
1293 printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno());
1301 printf("%s:%d: missing 'endchoice' for this 'choice' statement\n", current_menu->file->name, current_menu->lineno);
1309 menu_add_prop(P_PROMPT, yyvsp[-1].string, NULL, yyvsp[0].expr);
1310 printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
1317 current_entry->sym->flags |= SYMBOL_OPTIONAL;
1318 printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno());
1325 menu_add_prop(P_DEFAULT, NULL, yyvsp[0].symbol, NULL);
1326 //current_choice->prop->def = ;
1327 printd(DEBUG_PARSE, "%s:%d:default\n", zconf_curname(), zconf_lineno());
1334 printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno());
1335 menu_add_entry(NULL);
1336 //current_entry->prompt = menu_add_prop(T_IF, NULL, NULL, );
1337 menu_add_dep(yyvsp[0].expr);
1346 if (zconf_endtoken(yyvsp[0].token, T_IF, T_ENDIF)) {
1348 printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno());
1356 printf("%s:%d: missing 'endif' for this 'if' statement\n", current_menu->file->name, current_menu->lineno);
1364 menu_add_entry(NULL);
1365 menu_add_prop(P_MENU, yyvsp[0].string, NULL, NULL);
1366 printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
1381 if (zconf_endtoken(yyvsp[0].token, T_MENU, T_ENDMENU)) {
1383 printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno());
1391 printf("%s:%d: missing 'endmenu' for this 'menu' statement\n", current_menu->file->name, current_menu->lineno);
1398 { zconfprint("invalid menu option"); yyerrok; }
1404 yyval.string = yyvsp[0].string;
1405 printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), yyvsp[0].string);
1412 zconf_nextfile(yyvsp[-1].string);
1419 menu_add_entry(NULL);
1420 menu_add_prop(P_COMMENT, yyvsp[0].string, NULL, NULL);
1421 printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno());
1435 printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno());
1443 current_entry->sym->help = yyvsp[0].string;
1455 menu_add_dep(yyvsp[0].expr);
1456 printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno());
1463 menu_add_dep(yyvsp[0].expr);
1464 printd(DEBUG_PARSE, "%s:%d:depends\n", zconf_curname(), zconf_lineno());
1471 menu_add_dep(yyvsp[0].expr);
1472 printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), zconf_lineno());
1479 menu_add_prop(P_PROMPT, yyvsp[0].string, NULL, NULL);
1486 menu_add_prop(P_PROMPT, yyvsp[-2].string, NULL, yyvsp[0].expr);
1492 { yyval.token = T_ENDMENU; }
1497 { yyval.token = T_ENDCHOICE; }
1502 { yyval.token = T_ENDIF; }
1507 { yyval.expr = NULL; }
1512 { yyval.expr = yyvsp[0].expr; }
1517 { yyval.expr = expr_alloc_symbol(yyvsp[0].symbol); }
1522 { yyval.expr = expr_alloc_comp(E_EQUAL, yyvsp[-2].symbol, yyvsp[0].symbol); }
1527 { yyval.expr = expr_alloc_comp(E_UNEQUAL, yyvsp[-2].symbol, yyvsp[0].symbol); }
1532 { yyval.expr = yyvsp[-1].expr; }
1537 { yyval.expr = expr_alloc_one(E_NOT, yyvsp[0].expr); }
1542 { yyval.expr = expr_alloc_two(E_OR, yyvsp[-2].expr, yyvsp[0].expr); }
1547 { yyval.expr = expr_alloc_two(E_AND, yyvsp[-2].expr, yyvsp[0].expr); }
1552 { yyval.symbol = sym_lookup(yyvsp[0].string, 0); free(yyvsp[0].string); }
1557 { yyval.symbol = sym_lookup(yyvsp[0].string, 1); free(yyvsp[0].string); }
1563 /* Line 1016 of /usr/share/bison/yacc.c. */
1564 #line 1565 "zconf.tab.c"
1573 short *yyssp1 = yyss - 1;
1574 YYFPRINTF (stderr, "state stack now");
1575 while (yyssp1 != yyssp)
1576 YYFPRINTF (stderr, " %d", *++yyssp1);
1577 YYFPRINTF (stderr, "\n");
1584 /* Now `shift' the result of the reduction. Determine what state
1585 that goes to, based on the state we popped back to and the rule
1586 number reduced by. */
1590 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1591 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1592 yystate = yytable[yystate];
1594 yystate = yydefgoto[yyn - YYNTOKENS];
1599 /*------------------------------------.
1600 | yyerrlab -- here on detecting error |
1601 `------------------------------------*/
1603 /* If not already recovering from an error, report this error. */
1608 yyn = yypact[yystate];
1610 if (YYPACT_NINF < yyn && yyn < YYLAST)
1612 YYSIZE_T yysize = 0;
1613 int yytype = YYTRANSLATE (yychar);
1618 /* Start YYX at -YYN if negative to avoid negative indexes in
1620 for (yyx = yyn < 0 ? -yyn : 0;
1621 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1622 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1623 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1624 yysize += yystrlen ("parse error, unexpected ") + 1;
1625 yysize += yystrlen (yytname[yytype]);
1626 yymsg = (char *) YYSTACK_ALLOC (yysize);
1629 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
1630 yyp = yystpcpy (yyp, yytname[yytype]);
1635 for (yyx = yyn < 0 ? -yyn : 0;
1636 yyx < (int) (sizeof (yytname) / sizeof (char *));
1638 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1640 const char *yyq = ! yycount ? ", expecting " : " or ";
1641 yyp = yystpcpy (yyp, yyq);
1642 yyp = yystpcpy (yyp, yytname[yyx]);
1647 YYSTACK_FREE (yymsg);
1650 yyerror ("parse error; also virtual memory exhausted");
1653 #endif /* YYERROR_VERBOSE */
1654 yyerror ("parse error");
1659 /*----------------------------------------------------.
1660 | yyerrlab1 -- error raised explicitly by an action. |
1661 `----------------------------------------------------*/
1663 if (yyerrstatus == 3)
1665 /* If just tried and failed to reuse lookahead token after an
1666 error, discard it. */
1668 /* Return failure if at end of input. */
1669 if (yychar == YYEOF)
1671 /* Pop the error token. */
1673 /* Pop the rest of the stack. */
1674 while (yyssp > yyss)
1676 YYDPRINTF ((stderr, "Error: popping "));
1677 YYDSYMPRINT ((stderr,
1680 YYDPRINTF ((stderr, "\n"));
1681 yydestruct (yystos[*yyssp], *yyvsp);
1687 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
1688 yychar, yytname[yychar1]));
1689 yydestruct (yychar1, yylval);
1693 /* Else will try to reuse lookahead token after shifting the error
1696 yyerrstatus = 3; /* Each real token shifted decrements this. */
1700 yyn = yypact[yystate];
1701 if (yyn != YYPACT_NINF)
1704 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1712 /* Pop the current state because it cannot handle the error token. */
1716 YYDPRINTF ((stderr, "Error: popping "));
1717 YYDSYMPRINT ((stderr,
1718 yystos[*yyssp], *yyvsp));
1719 YYDPRINTF ((stderr, "\n"));
1721 yydestruct (yystos[yystate], *yyvsp);
1729 short *yyssp1 = yyss - 1;
1730 YYFPRINTF (stderr, "Error: state stack now");
1731 while (yyssp1 != yyssp)
1732 YYFPRINTF (stderr, " %d", *++yyssp1);
1733 YYFPRINTF (stderr, "\n");
1741 YYDPRINTF ((stderr, "Shifting error token, "));
1750 /*-------------------------------------.
1751 | yyacceptlab -- YYACCEPT comes here. |
1752 `-------------------------------------*/
1757 /*-----------------------------------.
1758 | yyabortlab -- YYABORT comes here. |
1759 `-----------------------------------*/
1765 /*----------------------------------------------.
1766 | yyoverflowlab -- parser overflow comes here. |
1767 `----------------------------------------------*/
1769 yyerror ("parser stack overflow");
1777 YYSTACK_FREE (yyss);
1786 void conf_parse(const char *name)
1788 zconf_initscan(name);
1792 rootmenu.prompt = menu_add_prop(P_MENU, "Broadcom Linux Router Configuration", NULL, NULL);
1798 menu_finalize(&rootmenu);
1800 modules_sym = sym_lookup("MODULES", 0);
1802 sym_change_count = 1;
1805 const char *zconf_tokenname(int token)
1808 case T_MENU: return "menu";
1809 case T_ENDMENU: return "endmenu";
1810 case T_CHOICE: return "choice";
1811 case T_ENDCHOICE: return "endchoice";
1812 case T_IF: return "if";
1813 case T_ENDIF: return "endif";
1818 static bool zconf_endtoken(int token, int starttoken, int endtoken)
1820 if (token != endtoken) {
1821 zconfprint("unexpected '%s' within %s block", zconf_tokenname(token), zconf_tokenname(starttoken));
1825 if (current_menu->file != current_file) {
1826 zconfprint("'%s' in different file than '%s'", zconf_tokenname(token), zconf_tokenname(starttoken));
1827 zconfprint("location of the '%s'", zconf_tokenname(starttoken));
1834 static void zconfprint(const char *err, ...)
1838 fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
1840 vfprintf(stderr, err, ap);
1842 fprintf(stderr, "\n");
1845 static void zconferror(const char *err)
1847 fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno(), err);
1850 void print_quoted_string(FILE *out, const char *str)
1856 while ((p = strchr(str, '"'))) {
1859 fprintf(out, "%.*s", len, str);
1867 void print_symbol(FILE *out, struct menu *menu)
1869 struct symbol *sym = menu->sym;
1870 struct property *prop;
1872 //sym->flags |= SYMBOL_PRINTED;
1874 if (sym_is_choice(sym))
1875 fprintf(out, "choice\n");
1877 fprintf(out, "config %s\n", sym->name);
1878 switch (sym->type) {
1880 fputs(" boolean\n", out);
1883 fputs(" tristate\n", out);
1886 fputs(" string\n", out);
1889 fputs(" integer\n", out);
1892 fputs(" hex\n", out);
1895 fputs(" ???\n", out);
1898 for (prop = sym->prop; prop; prop = prop->next) {
1899 if (prop->menu != menu)
1901 switch (prop->type) {
1903 fputs(" prompt ", out);
1904 print_quoted_string(out, prop->text);
1907 if (prop->def->flags & SYMBOL_CONST)
1908 print_quoted_string(out, prop->def->name);
1910 fputs(prop->def->name, out);
1912 if (!expr_is_yes(E_EXPR(prop->visible))) {
1914 expr_fprint(E_EXPR(prop->visible), out);
1919 fputs( " default ", out);
1920 print_quoted_string(out, prop->def->name);
1921 if (!expr_is_yes(E_EXPR(prop->visible))) {
1923 expr_fprint(E_EXPR(prop->visible), out);
1928 fputs(" #choice value\n", out);
1931 fprintf(out, " unknown prop %d!\n", prop->type);
1936 int len = strlen(sym->help);
1937 while (sym->help[--len] == '\n')
1939 fprintf(out, " help\n%s\n", sym->help);
1944 void zconfdump(FILE *out)
1946 //struct file *file;
1947 struct property *prop;
1951 menu = rootmenu.list;
1953 if ((sym = menu->sym))
1954 print_symbol(out, menu);
1955 else if ((prop = menu->prompt)) {
1956 switch (prop->type) {
1958 // fputs("\nmainmenu ", out);
1959 // print_quoted_string(out, prop->text);
1960 // fputs("\n", out);
1963 fputs("\ncomment ", out);
1964 print_quoted_string(out, prop->text);
1968 fputs("\nmenu ", out);
1969 print_quoted_string(out, prop->text);
1973 // fputs("\nsource ", out);
1974 // print_quoted_string(out, prop->text);
1975 // fputs("\n", out);
1978 // fputs("\nif\n", out);
1982 if (!expr_is_yes(E_EXPR(prop->visible))) {
1983 fputs(" depends ", out);
1984 expr_fprint(E_EXPR(prop->visible), out);
1992 else if (menu->next)
1994 else while ((menu = menu->parent)) {
1995 if (menu->prompt && menu->prompt->type == P_MENU)
1996 fputs("\nendmenu\n", out);
2005 #include "lex.zconf.c"
2006 #include "confdata.c"