Annotation of embedaddon/strongswan/src/libstrongswan/settings/settings_parser.c, revision 1.1.1.2
1.1 misho 1: /* A Bison parser, made by GNU Bison 3.0.4. */
2:
3: /* Bison implementation for Yacc-like parsers in C
4:
5: Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
6:
7: This program is free software: you can redistribute it and/or modify
8: it under the terms of the GNU General Public License as published by
9: the Free Software Foundation, either version 3 of the License, or
10: (at your option) any later version.
11:
12: This program is distributed in the hope that it will be useful,
13: but WITHOUT ANY WARRANTY; without even the implied warranty of
14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: GNU General Public License for more details.
16:
17: You should have received a copy of the GNU General Public License
18: along with this program. If not, see <http://www.gnu.org/licenses/>. */
19:
20: /* As a special exception, you may create a larger work that contains
21: part or all of the Bison parser skeleton and distribute that work
22: under terms of your choice, so long as that work isn't itself a
23: parser generator using the skeleton or a modified version thereof
24: as a parser skeleton. Alternatively, if you modify or redistribute
25: the parser skeleton itself, you may (at your option) remove this
26: special exception, which will cause the skeleton and the resulting
27: Bison output files to be licensed under the GNU General Public
28: License without this special exception.
29:
30: This special exception was added by the Free Software Foundation in
31: version 2.2 of Bison. */
32:
33: /* C LALR(1) parser skeleton written by Richard Stallman, by
34: simplifying the original so-called "semantic" parser. */
35:
36: /* All symbols defined below should begin with yy or YY, to avoid
37: infringing on user name space. This should be done even for local
38: variables, as they might otherwise be expanded by user macros.
39: There are some unavoidable exceptions within include files to
40: define necessary library symbols; they are noted "INFRINGES ON
41: USER NAME SPACE" below. */
42:
43: /* Identify Bison output. */
44: #define YYBISON 1
45:
46: /* Bison version. */
47: #define YYBISON_VERSION "3.0.4"
48:
49: /* Skeleton name. */
50: #define YYSKELETON_NAME "yacc.c"
51:
52: /* Pure parsers. */
53: #define YYPURE 1
54:
55: /* Push parsers. */
56: #define YYPUSH 0
57:
58: /* Pull parsers. */
59: #define YYPULL 1
60:
1.1.1.2 ! misho 61: /* Substitute the type names. */
! 62: #define YYSTYPE SETTINGS_PARSER_STYPE
1.1 misho 63: /* Substitute the variable and function names. */
64: #define yyparse settings_parser_parse
65: #define yylex settings_parser_lex
66: #define yyerror settings_parser_error
67: #define yydebug settings_parser_debug
68: #define yynerrs settings_parser_nerrs
69:
70:
71: /* Copy the first part of user declarations. */
72: #line 1 "settings/settings_parser.y" /* yacc.c:339 */
73:
74: /*
75: * Copyright (C) 2014-2018 Tobias Brunner
76: * HSR Hochschule fuer Technik Rapperswil
77: *
78: * This program is free software; you can redistribute it and/or modify it
79: * under the terms of the GNU General Public License as published by the
80: * Free Software Foundation; either version 2 of the License, or (at your
81: * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
82: *
83: * This program is distributed in the hope that it will be useful, but
84: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
85: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
86: * for more details.
87: */
88:
89: #define _GNU_SOURCE /* for asprintf() */
90: #include <stdio.h>
91:
92: #include <library.h>
93: #include <collections/array.h>
94: #include <settings/settings_types.h>
95: #include <utils/parser_helper.h>
96:
97: #include "settings_parser.h"
98:
99: #define YYDEBUG 1
100:
101: /**
102: * Defined by the lexer
103: */
104: int settings_parser_lex(YYSTYPE *lvalp, void *scanner);
105: int settings_parser_lex_init_extra(parser_helper_t *extra, void *scanner);
106: int settings_parser_lex_destroy(void *scanner);
107: int settings_parser_set_in(FILE *in, void *scanner);
108: void settings_parser_set_debug(int debug, void *scanner);
109: char *settings_parser_get_text(void *scanner);
110: int settings_parser_get_leng(void *scanner);
111: int settings_parser_get_lineno(void *scanner);
112: /* Custom functions in lexer */
113: bool settings_parser_open_next_file(parser_helper_t *ctx);
114: bool settings_parser_load_string(parser_helper_t *ctx, const char *content);
115:
116: /**
117: * Forward declarations
118: */
119: static void settings_parser_error(parser_helper_t *ctx, const char *s);
120: static section_t *push_section(parser_helper_t *ctx, char *name);
121: static section_t *pop_section(parser_helper_t *ctx);
122: static void add_section(parser_helper_t *ctx, section_t *section);
123: static void add_setting(parser_helper_t *ctx, kv_t *kv);
124: static void add_references(parser_helper_t *ctx, array_t *references);
125:
126: /**
127: * Make sure to call lexer with the proper context
128: */
129: #undef yylex
1.1.1.2 ! misho 130: static int yylex(SETTINGS_PARSER_STYPE *yylval, parser_helper_t *ctx)
1.1 misho 131: {
1.1.1.2 ! misho 132: return settings_parser_lex(yylval, ctx->scanner);
1.1 misho 133: }
134:
135:
1.1.1.2 ! misho 136: #line 137 "settings/settings_parser.c" /* yacc.c:339 */
1.1 misho 137:
138: # ifndef YY_NULLPTR
139: # if defined __cplusplus && 201103L <= __cplusplus
140: # define YY_NULLPTR nullptr
141: # else
142: # define YY_NULLPTR 0
143: # endif
144: # endif
145:
146: /* Enabling verbose error messages. */
147: #ifdef YYERROR_VERBOSE
148: # undef YYERROR_VERBOSE
149: # define YYERROR_VERBOSE 1
150: #else
151: # define YYERROR_VERBOSE 1
152: #endif
153:
154: /* In a future release of Bison, this section will be replaced
155: by #include "y.tab.h". */
156: #ifndef YY_SETTINGS_PARSER_SETTINGS_SETTINGS_PARSER_H_INCLUDED
157: # define YY_SETTINGS_PARSER_SETTINGS_SETTINGS_PARSER_H_INCLUDED
158: /* Debug traces. */
1.1.1.2 ! misho 159: #ifndef SETTINGS_PARSER_DEBUG
! 160: # if defined YYDEBUG
1.1 misho 161: #if YYDEBUG
1.1.1.2 ! misho 162: # define SETTINGS_PARSER_DEBUG 1
! 163: # else
! 164: # define SETTINGS_PARSER_DEBUG 0
! 165: # endif
! 166: # else /* ! defined YYDEBUG */
! 167: # define SETTINGS_PARSER_DEBUG 1
! 168: # endif /* ! defined YYDEBUG */
! 169: #endif /* ! defined SETTINGS_PARSER_DEBUG */
! 170: #if SETTINGS_PARSER_DEBUG
1.1 misho 171: extern int settings_parser_debug;
172: #endif
173:
174: /* Token type. */
1.1.1.2 ! misho 175: #ifndef SETTINGS_PARSER_TOKENTYPE
! 176: # define SETTINGS_PARSER_TOKENTYPE
! 177: enum settings_parser_tokentype
1.1 misho 178: {
179: NAME = 258,
180: STRING = 259,
181: DOT = 260,
182: COMMA = 261,
183: COLON = 262,
184: NEWLINE = 263,
185: STRING_ERROR = 264
186: };
187: #endif
188: /* Tokens. */
189: #define NAME 258
190: #define STRING 259
191: #define DOT 260
192: #define COMMA 261
193: #define COLON 262
194: #define NEWLINE 263
195: #define STRING_ERROR 264
196:
197: /* Value type. */
1.1.1.2 ! misho 198: #if ! defined SETTINGS_PARSER_STYPE && ! defined SETTINGS_PARSER_STYPE_IS_DECLARED
1.1 misho 199:
1.1.1.2 ! misho 200: union SETTINGS_PARSER_STYPE
1.1 misho 201: {
1.1.1.2 ! misho 202: #line 85 "settings/settings_parser.y" /* yacc.c:355 */
1.1 misho 203:
204: char *s;
205: struct section_t *sec;
206: struct kv_t *kv;
207: array_t *refs;
208:
1.1.1.2 ! misho 209: #line 210 "settings/settings_parser.c" /* yacc.c:355 */
1.1 misho 210: };
211:
1.1.1.2 ! misho 212: typedef union SETTINGS_PARSER_STYPE SETTINGS_PARSER_STYPE;
! 213: # define SETTINGS_PARSER_STYPE_IS_TRIVIAL 1
! 214: # define SETTINGS_PARSER_STYPE_IS_DECLARED 1
1.1 misho 215: #endif
216:
217:
218:
219: int settings_parser_parse (parser_helper_t *ctx);
1.1.1.2 ! misho 220: /* "%code provides" blocks. */
! 221: #line 74 "settings/settings_parser.y" /* yacc.c:355 */
! 222:
! 223: #define YY_DECL \
! 224: int settings_parser_lex(SETTINGS_PARSER_STYPE *yylval, void *yyscanner)
! 225: YY_DECL;
! 226:
! 227: #line 228 "settings/settings_parser.c" /* yacc.c:355 */
1.1 misho 228:
229: #endif /* !YY_SETTINGS_PARSER_SETTINGS_SETTINGS_PARSER_H_INCLUDED */
230:
231: /* Copy the second part of user declarations. */
232:
1.1.1.2 ! misho 233: #line 234 "settings/settings_parser.c" /* yacc.c:358 */
1.1 misho 234:
235: #ifdef short
236: # undef short
237: #endif
238:
239: #ifdef YYTYPE_UINT8
240: typedef YYTYPE_UINT8 yytype_uint8;
241: #else
242: typedef unsigned char yytype_uint8;
243: #endif
244:
245: #ifdef YYTYPE_INT8
246: typedef YYTYPE_INT8 yytype_int8;
247: #else
248: typedef signed char yytype_int8;
249: #endif
250:
251: #ifdef YYTYPE_UINT16
252: typedef YYTYPE_UINT16 yytype_uint16;
253: #else
254: typedef unsigned short int yytype_uint16;
255: #endif
256:
257: #ifdef YYTYPE_INT16
258: typedef YYTYPE_INT16 yytype_int16;
259: #else
260: typedef short int yytype_int16;
261: #endif
262:
263: #ifndef YYSIZE_T
264: # ifdef __SIZE_TYPE__
265: # define YYSIZE_T __SIZE_TYPE__
266: # elif defined size_t
267: # define YYSIZE_T size_t
268: # elif ! defined YYSIZE_T
269: # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
270: # define YYSIZE_T size_t
271: # else
272: # define YYSIZE_T unsigned int
273: # endif
274: #endif
275:
276: #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
277:
278: #ifndef YY_
279: # if defined YYENABLE_NLS && YYENABLE_NLS
280: # if ENABLE_NLS
281: # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
282: # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
283: # endif
284: # endif
285: # ifndef YY_
286: # define YY_(Msgid) Msgid
287: # endif
288: #endif
289:
290: #ifndef YY_ATTRIBUTE
291: # if (defined __GNUC__ \
292: && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
293: || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
294: # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
295: # else
296: # define YY_ATTRIBUTE(Spec) /* empty */
297: # endif
298: #endif
299:
300: #ifndef YY_ATTRIBUTE_PURE
301: # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
302: #endif
303:
304: #ifndef YY_ATTRIBUTE_UNUSED
305: # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
306: #endif
307:
308: #if !defined _Noreturn \
309: && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
310: # if defined _MSC_VER && 1200 <= _MSC_VER
311: # define _Noreturn __declspec (noreturn)
312: # else
313: # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
314: # endif
315: #endif
316:
317: /* Suppress unused-variable warnings by "using" E. */
318: #if ! defined lint || defined __GNUC__
319: # define YYUSE(E) ((void) (E))
320: #else
321: # define YYUSE(E) /* empty */
322: #endif
323:
324: #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
325: /* Suppress an incorrect diagnostic about yylval being uninitialized. */
326: # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
327: _Pragma ("GCC diagnostic push") \
328: _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
329: _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
330: # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
331: _Pragma ("GCC diagnostic pop")
332: #else
333: # define YY_INITIAL_VALUE(Value) Value
334: #endif
335: #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
336: # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
337: # define YY_IGNORE_MAYBE_UNINITIALIZED_END
338: #endif
339: #ifndef YY_INITIAL_VALUE
340: # define YY_INITIAL_VALUE(Value) /* Nothing. */
341: #endif
342:
343:
344: #if ! defined yyoverflow || YYERROR_VERBOSE
345:
346: /* The parser invokes alloca or malloc; define the necessary symbols. */
347:
348: # ifdef YYSTACK_USE_ALLOCA
349: # if YYSTACK_USE_ALLOCA
350: # ifdef __GNUC__
351: # define YYSTACK_ALLOC __builtin_alloca
352: # elif defined __BUILTIN_VA_ARG_INCR
353: # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
354: # elif defined _AIX
355: # define YYSTACK_ALLOC __alloca
356: # elif defined _MSC_VER
357: # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
358: # define alloca _alloca
359: # else
360: # define YYSTACK_ALLOC alloca
361: # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
362: # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
363: /* Use EXIT_SUCCESS as a witness for stdlib.h. */
364: # ifndef EXIT_SUCCESS
365: # define EXIT_SUCCESS 0
366: # endif
367: # endif
368: # endif
369: # endif
370: # endif
371:
372: # ifdef YYSTACK_ALLOC
373: /* Pacify GCC's 'empty if-body' warning. */
374: # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
375: # ifndef YYSTACK_ALLOC_MAXIMUM
376: /* The OS might guarantee only one guard page at the bottom of the stack,
377: and a page size can be as small as 4096 bytes. So we cannot safely
378: invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
379: to allow for a few compiler-allocated temporary stack slots. */
380: # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
381: # endif
382: # else
383: # define YYSTACK_ALLOC YYMALLOC
384: # define YYSTACK_FREE YYFREE
385: # ifndef YYSTACK_ALLOC_MAXIMUM
386: # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
387: # endif
388: # if (defined __cplusplus && ! defined EXIT_SUCCESS \
389: && ! ((defined YYMALLOC || defined malloc) \
390: && (defined YYFREE || defined free)))
391: # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
392: # ifndef EXIT_SUCCESS
393: # define EXIT_SUCCESS 0
394: # endif
395: # endif
396: # ifndef YYMALLOC
397: # define YYMALLOC malloc
398: # if ! defined malloc && ! defined EXIT_SUCCESS
399: void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
400: # endif
401: # endif
402: # ifndef YYFREE
403: # define YYFREE free
404: # if ! defined free && ! defined EXIT_SUCCESS
405: void free (void *); /* INFRINGES ON USER NAME SPACE */
406: # endif
407: # endif
408: # endif
409: #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
410:
411:
412: #if (! defined yyoverflow \
413: && (! defined __cplusplus \
1.1.1.2 ! misho 414: || (defined SETTINGS_PARSER_STYPE_IS_TRIVIAL && SETTINGS_PARSER_STYPE_IS_TRIVIAL)))
1.1 misho 415:
416: /* A type that is properly aligned for any stack member. */
417: union yyalloc
418: {
419: yytype_int16 yyss_alloc;
420: YYSTYPE yyvs_alloc;
421: };
422:
423: /* The size of the maximum gap between one aligned stack and the next. */
424: # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
425:
426: /* The size of an array large to enough to hold all stacks, each with
427: N elements. */
428: # define YYSTACK_BYTES(N) \
429: ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
430: + YYSTACK_GAP_MAXIMUM)
431:
432: # define YYCOPY_NEEDED 1
433:
434: /* Relocate STACK from its old location to the new one. The
435: local variables YYSIZE and YYSTACKSIZE give the old and new number of
436: elements in the stack, and YYPTR gives the new location of the
437: stack. Advance YYPTR to a properly aligned location for the next
438: stack. */
439: # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
440: do \
441: { \
442: YYSIZE_T yynewbytes; \
443: YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
444: Stack = &yyptr->Stack_alloc; \
445: yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
446: yyptr += yynewbytes / sizeof (*yyptr); \
447: } \
448: while (0)
449:
450: #endif
451:
452: #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
453: /* Copy COUNT objects from SRC to DST. The source and destination do
454: not overlap. */
455: # ifndef YYCOPY
456: # if defined __GNUC__ && 1 < __GNUC__
457: # define YYCOPY(Dst, Src, Count) \
458: __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
459: # else
460: # define YYCOPY(Dst, Src, Count) \
461: do \
462: { \
463: YYSIZE_T yyi; \
464: for (yyi = 0; yyi < (Count); yyi++) \
465: (Dst)[yyi] = (Src)[yyi]; \
466: } \
467: while (0)
468: # endif
469: # endif
470: #endif /* !YYCOPY_NEEDED */
471:
472: /* YYFINAL -- State number of the termination state. */
473: #define YYFINAL 2
474: /* YYLAST -- Last index in YYTABLE. */
475: #define YYLAST 19
476:
477: /* YYNTOKENS -- Number of terminals. */
478: #define YYNTOKENS 13
479: /* YYNNTS -- Number of nonterminals. */
480: #define YYNNTS 9
481: /* YYNRULES -- Number of rules. */
482: #define YYNRULES 17
483: /* YYNSTATES -- Number of states. */
484: #define YYNSTATES 24
485:
486: /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
487: by yylex, with out-of-bounds checking. */
488: #define YYUNDEFTOK 2
489: #define YYMAXUTOK 264
490:
491: #define YYTRANSLATE(YYX) \
492: ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
493:
494: /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
495: as returned by yylex, without out-of-bounds checking. */
496: static const yytype_uint8 yytranslate[] =
497: {
498: 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
499: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
500: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
501: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
502: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
503: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
504: 2, 12, 2, 2, 2, 2, 2, 2, 2, 2,
505: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
506: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
507: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
508: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
509: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
510: 2, 2, 2, 11, 2, 10, 2, 2, 2, 2,
511: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
512: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
513: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
514: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
515: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
516: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
517: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
518: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
519: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
520: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
521: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
522: 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
523: 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
524: 5, 6, 7, 8, 9
525: };
526:
1.1.1.2 ! misho 527: #if SETTINGS_PARSER_DEBUG
1.1 misho 528: /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
529: static const yytype_uint8 yyrline[] =
530: {
1.1.1.2 ! misho 531: 0, 119, 119, 121, 122, 126, 130, 137, 145, 150,
! 532: 159, 164, 172, 177, 184, 185, 199, 200
1.1 misho 533: };
534: #endif
535:
1.1.1.2 ! misho 536: #if SETTINGS_PARSER_DEBUG || YYERROR_VERBOSE || 1
1.1 misho 537: /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
538: First, the terminals, then, starting at YYNTOKENS, nonterminals. */
539: static const char *const yytname[] =
540: {
541: "$end", "error", "$undefined", "NAME", "STRING", "\".\"", "\",\"",
542: "\":\"", "NEWLINE", "STRING_ERROR", "'}'", "'{'", "'='", "$accept",
543: "statements", "statement", "section", "section_start", "references",
544: "setting", "value", "valuepart", YY_NULLPTR
545: };
546: #endif
547:
548: # ifdef YYPRINT
549: /* YYTOKNUM[NUM] -- (External) token number corresponding to the
550: (internal) symbol number NUM (which must be that of a token). */
551: static const yytype_uint16 yytoknum[] =
552: {
553: 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
554: 125, 123, 61
555: };
556: # endif
557:
558: #define YYPACT_NINF -7
559:
560: #define yypact_value_is_default(Yystate) \
561: (!!((Yystate) == (-7)))
562:
563: #define YYTABLE_NINF -1
564:
565: #define yytable_value_is_error(Yytable_value) \
566: 0
567:
568: /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
569: STATE-NUM. */
570: static const yytype_int8 yypact[] =
571: {
572: -7, 0, -7, -6, -7, -7, -7, -7, -7, 1,
573: -7, 8, -1, -7, 4, -7, -7, 8, -7, -7,
574: 10, -7, -7, -7
575: };
576:
577: /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
578: Performed when YYTABLE does not specify something else to do. Zero
579: means the default is an error. */
580: static const yytype_uint8 yydefact[] =
581: {
582: 2, 0, 1, 0, 3, 4, 5, 2, 6, 0,
583: 8, 13, 0, 10, 0, 16, 17, 12, 14, 7,
584: 0, 9, 15, 11
585: };
586:
587: /* YYPGOTO[NTERM-NUM]. */
588: static const yytype_int8 yypgoto[] =
589: {
590: -7, 7, -7, -7, -7, -7, -7, -7, 2
591: };
592:
593: /* YYDEFGOTO[NTERM-NUM]. */
594: static const yytype_int8 yydefgoto[] =
595: {
596: -1, 1, 5, 6, 7, 14, 8, 17, 18
597: };
598:
599: /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
600: positive, shift that token. If negative, reduce the rule whose
601: number is the opposite. If YYTABLE_NINF, syntax error. */
602: static const yytype_uint8 yytable[] =
603: {
604: 2, 9, 3, 3, 13, 10, 11, 4, 4, 19,
605: 20, 15, 16, 23, 12, 21, 0, 0, 0, 22
606: };
607:
608: static const yytype_int8 yycheck[] =
609: {
610: 0, 7, 3, 3, 3, 11, 12, 8, 8, 10,
611: 6, 3, 4, 3, 7, 11, -1, -1, -1, 17
612: };
613:
614: /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
615: symbol of state STATE-NUM. */
616: static const yytype_uint8 yystos[] =
617: {
618: 0, 14, 0, 3, 8, 15, 16, 17, 19, 7,
619: 11, 12, 14, 3, 18, 3, 4, 20, 21, 10,
620: 6, 11, 21, 3
621: };
622:
623: /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
624: static const yytype_uint8 yyr1[] =
625: {
626: 0, 13, 14, 14, 14, 15, 15, 16, 17, 17,
627: 18, 18, 19, 19, 20, 20, 21, 21
628: };
629:
630: /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
631: static const yytype_uint8 yyr2[] =
632: {
633: 0, 2, 0, 2, 2, 1, 1, 3, 2, 4,
634: 1, 3, 3, 2, 1, 2, 1, 1
635: };
636:
637:
638: #define yyerrok (yyerrstatus = 0)
639: #define yyclearin (yychar = YYEMPTY)
640: #define YYEMPTY (-2)
641: #define YYEOF 0
642:
643: #define YYACCEPT goto yyacceptlab
644: #define YYABORT goto yyabortlab
645: #define YYERROR goto yyerrorlab
646:
647:
648: #define YYRECOVERING() (!!yyerrstatus)
649:
650: #define YYBACKUP(Token, Value) \
651: do \
652: if (yychar == YYEMPTY) \
653: { \
654: yychar = (Token); \
655: yylval = (Value); \
656: YYPOPSTACK (yylen); \
657: yystate = *yyssp; \
658: goto yybackup; \
659: } \
660: else \
661: { \
662: yyerror (ctx, YY_("syntax error: cannot back up")); \
663: YYERROR; \
664: } \
665: while (0)
666:
667: /* Error token number */
668: #define YYTERROR 1
669: #define YYERRCODE 256
670:
671:
672:
673: /* Enable debugging if requested. */
1.1.1.2 ! misho 674: #if SETTINGS_PARSER_DEBUG
1.1 misho 675:
676: # ifndef YYFPRINTF
677: # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
678: # define YYFPRINTF fprintf
679: # endif
680:
681: # define YYDPRINTF(Args) \
682: do { \
683: if (yydebug) \
684: YYFPRINTF Args; \
685: } while (0)
686:
687: /* This macro is provided for backward compatibility. */
688: #ifndef YY_LOCATION_PRINT
689: # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
690: #endif
691:
692:
693: # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
694: do { \
695: if (yydebug) \
696: { \
697: YYFPRINTF (stderr, "%s ", Title); \
698: yy_symbol_print (stderr, \
699: Type, Value, ctx); \
700: YYFPRINTF (stderr, "\n"); \
701: } \
702: } while (0)
703:
704:
705: /*----------------------------------------.
706: | Print this symbol's value on YYOUTPUT. |
707: `----------------------------------------*/
708:
709: static void
710: yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, parser_helper_t *ctx)
711: {
712: FILE *yyo = yyoutput;
713: YYUSE (yyo);
714: YYUSE (ctx);
715: if (!yyvaluep)
716: return;
717: # ifdef YYPRINT
718: if (yytype < YYNTOKENS)
719: YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
720: # endif
721: YYUSE (yytype);
722: }
723:
724:
725: /*--------------------------------.
726: | Print this symbol on YYOUTPUT. |
727: `--------------------------------*/
728:
729: static void
730: yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, parser_helper_t *ctx)
731: {
732: YYFPRINTF (yyoutput, "%s %s (",
733: yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
734:
735: yy_symbol_value_print (yyoutput, yytype, yyvaluep, ctx);
736: YYFPRINTF (yyoutput, ")");
737: }
738:
739: /*------------------------------------------------------------------.
740: | yy_stack_print -- Print the state stack from its BOTTOM up to its |
741: | TOP (included). |
742: `------------------------------------------------------------------*/
743:
744: static void
745: yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
746: {
747: YYFPRINTF (stderr, "Stack now");
748: for (; yybottom <= yytop; yybottom++)
749: {
750: int yybot = *yybottom;
751: YYFPRINTF (stderr, " %d", yybot);
752: }
753: YYFPRINTF (stderr, "\n");
754: }
755:
756: # define YY_STACK_PRINT(Bottom, Top) \
757: do { \
758: if (yydebug) \
759: yy_stack_print ((Bottom), (Top)); \
760: } while (0)
761:
762:
763: /*------------------------------------------------.
764: | Report that the YYRULE is going to be reduced. |
765: `------------------------------------------------*/
766:
767: static void
768: yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, parser_helper_t *ctx)
769: {
770: unsigned long int yylno = yyrline[yyrule];
771: int yynrhs = yyr2[yyrule];
772: int yyi;
773: YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
774: yyrule - 1, yylno);
775: /* The symbols being reduced. */
776: for (yyi = 0; yyi < yynrhs; yyi++)
777: {
778: YYFPRINTF (stderr, " $%d = ", yyi + 1);
779: yy_symbol_print (stderr,
780: yystos[yyssp[yyi + 1 - yynrhs]],
781: &(yyvsp[(yyi + 1) - (yynrhs)])
782: , ctx);
783: YYFPRINTF (stderr, "\n");
784: }
785: }
786:
787: # define YY_REDUCE_PRINT(Rule) \
788: do { \
789: if (yydebug) \
790: yy_reduce_print (yyssp, yyvsp, Rule, ctx); \
791: } while (0)
792:
793: /* Nonzero means print parse trace. It is left uninitialized so that
794: multiple parsers can coexist. */
795: int yydebug;
1.1.1.2 ! misho 796: #else /* !SETTINGS_PARSER_DEBUG */
1.1 misho 797: # define YYDPRINTF(Args)
798: # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
799: # define YY_STACK_PRINT(Bottom, Top)
800: # define YY_REDUCE_PRINT(Rule)
1.1.1.2 ! misho 801: #endif /* !SETTINGS_PARSER_DEBUG */
1.1 misho 802:
803:
804: /* YYINITDEPTH -- initial size of the parser's stacks. */
805: #ifndef YYINITDEPTH
806: # define YYINITDEPTH 200
807: #endif
808:
809: /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
810: if the built-in stack extension method is used).
811:
812: Do not make this value too large; the results are undefined if
813: YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
814: evaluated with infinite-precision integer arithmetic. */
815:
816: #ifndef YYMAXDEPTH
817: # define YYMAXDEPTH 10000
818: #endif
819:
820:
821: #if YYERROR_VERBOSE
822:
823: # ifndef yystrlen
824: # if defined __GLIBC__ && defined _STRING_H
825: # define yystrlen strlen
826: # else
827: /* Return the length of YYSTR. */
828: static YYSIZE_T
829: yystrlen (const char *yystr)
830: {
831: YYSIZE_T yylen;
832: for (yylen = 0; yystr[yylen]; yylen++)
833: continue;
834: return yylen;
835: }
836: # endif
837: # endif
838:
839: # ifndef yystpcpy
840: # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
841: # define yystpcpy stpcpy
842: # else
843: /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
844: YYDEST. */
845: static char *
846: yystpcpy (char *yydest, const char *yysrc)
847: {
848: char *yyd = yydest;
849: const char *yys = yysrc;
850:
851: while ((*yyd++ = *yys++) != '\0')
852: continue;
853:
854: return yyd - 1;
855: }
856: # endif
857: # endif
858:
859: # ifndef yytnamerr
860: /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
861: quotes and backslashes, so that it's suitable for yyerror. The
862: heuristic is that double-quoting is unnecessary unless the string
863: contains an apostrophe, a comma, or backslash (other than
864: backslash-backslash). YYSTR is taken from yytname. If YYRES is
865: null, do not copy; instead, return the length of what the result
866: would have been. */
867: static YYSIZE_T
868: yytnamerr (char *yyres, const char *yystr)
869: {
870: if (*yystr == '"')
871: {
872: YYSIZE_T yyn = 0;
873: char const *yyp = yystr;
874:
875: for (;;)
876: switch (*++yyp)
877: {
878: case '\'':
879: case ',':
880: goto do_not_strip_quotes;
881:
882: case '\\':
883: if (*++yyp != '\\')
884: goto do_not_strip_quotes;
885: /* Fall through. */
886: default:
887: if (yyres)
888: yyres[yyn] = *yyp;
889: yyn++;
890: break;
891:
892: case '"':
893: if (yyres)
894: yyres[yyn] = '\0';
895: return yyn;
896: }
897: do_not_strip_quotes: ;
898: }
899:
900: if (! yyres)
901: return yystrlen (yystr);
902:
903: return yystpcpy (yyres, yystr) - yyres;
904: }
905: # endif
906:
907: /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
908: about the unexpected token YYTOKEN for the state stack whose top is
909: YYSSP.
910:
911: Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
912: not large enough to hold the message. In that case, also set
913: *YYMSG_ALLOC to the required number of bytes. Return 2 if the
914: required number of bytes is too large to store. */
915: static int
916: yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
917: yytype_int16 *yyssp, int yytoken)
918: {
919: YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
920: YYSIZE_T yysize = yysize0;
921: enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
922: /* Internationalized format string. */
923: const char *yyformat = YY_NULLPTR;
924: /* Arguments of yyformat. */
925: char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
926: /* Number of reported tokens (one for the "unexpected", one per
927: "expected"). */
928: int yycount = 0;
929:
930: /* There are many possibilities here to consider:
931: - If this state is a consistent state with a default action, then
932: the only way this function was invoked is if the default action
933: is an error action. In that case, don't check for expected
934: tokens because there are none.
935: - The only way there can be no lookahead present (in yychar) is if
936: this state is a consistent state with a default action. Thus,
937: detecting the absence of a lookahead is sufficient to determine
938: that there is no unexpected or expected token to report. In that
939: case, just report a simple "syntax error".
940: - Don't assume there isn't a lookahead just because this state is a
941: consistent state with a default action. There might have been a
942: previous inconsistent state, consistent state with a non-default
943: action, or user semantic action that manipulated yychar.
944: - Of course, the expected token list depends on states to have
945: correct lookahead information, and it depends on the parser not
946: to perform extra reductions after fetching a lookahead from the
947: scanner and before detecting a syntax error. Thus, state merging
948: (from LALR or IELR) and default reductions corrupt the expected
949: token list. However, the list is correct for canonical LR with
950: one exception: it will still contain any token that will not be
951: accepted due to an error action in a later state.
952: */
953: if (yytoken != YYEMPTY)
954: {
955: int yyn = yypact[*yyssp];
956: yyarg[yycount++] = yytname[yytoken];
957: if (!yypact_value_is_default (yyn))
958: {
959: /* Start YYX at -YYN if negative to avoid negative indexes in
960: YYCHECK. In other words, skip the first -YYN actions for
961: this state because they are default actions. */
962: int yyxbegin = yyn < 0 ? -yyn : 0;
963: /* Stay within bounds of both yycheck and yytname. */
964: int yychecklim = YYLAST - yyn + 1;
965: int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
966: int yyx;
967:
968: for (yyx = yyxbegin; yyx < yyxend; ++yyx)
969: if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
970: && !yytable_value_is_error (yytable[yyx + yyn]))
971: {
972: if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
973: {
974: yycount = 1;
975: yysize = yysize0;
976: break;
977: }
978: yyarg[yycount++] = yytname[yyx];
979: {
980: YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
981: if (! (yysize <= yysize1
982: && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
983: return 2;
984: yysize = yysize1;
985: }
986: }
987: }
988: }
989:
990: switch (yycount)
991: {
992: # define YYCASE_(N, S) \
993: case N: \
994: yyformat = S; \
995: break
996: YYCASE_(0, YY_("syntax error"));
997: YYCASE_(1, YY_("syntax error, unexpected %s"));
998: YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
999: YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1000: YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1001: YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1002: # undef YYCASE_
1003: }
1004:
1005: {
1006: YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1007: if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1008: return 2;
1009: yysize = yysize1;
1010: }
1011:
1012: if (*yymsg_alloc < yysize)
1013: {
1014: *yymsg_alloc = 2 * yysize;
1015: if (! (yysize <= *yymsg_alloc
1016: && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1017: *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1018: return 1;
1019: }
1020:
1021: /* Avoid sprintf, as that infringes on the user's name space.
1022: Don't have undefined behavior even if the translation
1023: produced a string with the wrong number of "%s"s. */
1024: {
1025: char *yyp = *yymsg;
1026: int yyi = 0;
1027: while ((*yyp = *yyformat) != '\0')
1028: if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1029: {
1030: yyp += yytnamerr (yyp, yyarg[yyi++]);
1031: yyformat += 2;
1032: }
1033: else
1034: {
1035: yyp++;
1036: yyformat++;
1037: }
1038: }
1039: return 0;
1040: }
1041: #endif /* YYERROR_VERBOSE */
1042:
1043: /*-----------------------------------------------.
1044: | Release the memory associated to this symbol. |
1045: `-----------------------------------------------*/
1046:
1047: static void
1048: yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, parser_helper_t *ctx)
1049: {
1050: YYUSE (yyvaluep);
1051: YYUSE (ctx);
1052: if (!yymsg)
1053: yymsg = "Deleting";
1054: YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1055:
1056: YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1057: switch (yytype)
1058: {
1059: case 3: /* NAME */
1.1.1.2 ! misho 1060: #line 104 "settings/settings_parser.y" /* yacc.c:1257 */
1.1 misho 1061: { free(((*yyvaluep).s)); }
1.1.1.2 ! misho 1062: #line 1063 "settings/settings_parser.c" /* yacc.c:1257 */
1.1 misho 1063: break;
1064:
1065: case 4: /* STRING */
1.1.1.2 ! misho 1066: #line 104 "settings/settings_parser.y" /* yacc.c:1257 */
1.1 misho 1067: { free(((*yyvaluep).s)); }
1.1.1.2 ! misho 1068: #line 1069 "settings/settings_parser.c" /* yacc.c:1257 */
1.1 misho 1069: break;
1070:
1071: case 16: /* section */
1.1.1.2 ! misho 1072: #line 106 "settings/settings_parser.y" /* yacc.c:1257 */
1.1 misho 1073: { pop_section(ctx); settings_section_destroy(((*yyvaluep).sec), NULL); }
1.1.1.2 ! misho 1074: #line 1075 "settings/settings_parser.c" /* yacc.c:1257 */
1.1 misho 1075: break;
1076:
1077: case 17: /* section_start */
1.1.1.2 ! misho 1078: #line 106 "settings/settings_parser.y" /* yacc.c:1257 */
1.1 misho 1079: { pop_section(ctx); settings_section_destroy(((*yyvaluep).sec), NULL); }
1.1.1.2 ! misho 1080: #line 1081 "settings/settings_parser.c" /* yacc.c:1257 */
1.1 misho 1081: break;
1082:
1083: case 18: /* references */
1.1.1.2 ! misho 1084: #line 108 "settings/settings_parser.y" /* yacc.c:1257 */
1.1 misho 1085: { array_destroy_function(((*yyvaluep).refs), (void*)free, NULL); }
1.1.1.2 ! misho 1086: #line 1087 "settings/settings_parser.c" /* yacc.c:1257 */
1.1 misho 1087: break;
1088:
1089: case 19: /* setting */
1.1.1.2 ! misho 1090: #line 107 "settings/settings_parser.y" /* yacc.c:1257 */
1.1 misho 1091: { settings_kv_destroy(((*yyvaluep).kv), NULL); }
1.1.1.2 ! misho 1092: #line 1093 "settings/settings_parser.c" /* yacc.c:1257 */
1.1 misho 1093: break;
1094:
1095: case 20: /* value */
1.1.1.2 ! misho 1096: #line 104 "settings/settings_parser.y" /* yacc.c:1257 */
1.1 misho 1097: { free(((*yyvaluep).s)); }
1.1.1.2 ! misho 1098: #line 1099 "settings/settings_parser.c" /* yacc.c:1257 */
1.1 misho 1099: break;
1100:
1101: case 21: /* valuepart */
1.1.1.2 ! misho 1102: #line 104 "settings/settings_parser.y" /* yacc.c:1257 */
1.1 misho 1103: { free(((*yyvaluep).s)); }
1.1.1.2 ! misho 1104: #line 1105 "settings/settings_parser.c" /* yacc.c:1257 */
1.1 misho 1105: break;
1106:
1107:
1108: default:
1109: break;
1110: }
1111: YY_IGNORE_MAYBE_UNINITIALIZED_END
1112: }
1113:
1114:
1115:
1116:
1117: /*----------.
1118: | yyparse. |
1119: `----------*/
1120:
1121: int
1122: yyparse (parser_helper_t *ctx)
1123: {
1124: /* The lookahead symbol. */
1125: int yychar;
1126:
1127:
1128: /* The semantic value of the lookahead symbol. */
1129: /* Default value used for initialization, for pacifying older GCCs
1130: or non-GCC compilers. */
1131: YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1132: YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1133:
1134: /* Number of syntax errors so far. */
1135: int yynerrs;
1136:
1137: int yystate;
1138: /* Number of tokens to shift before error messages enabled. */
1139: int yyerrstatus;
1140:
1141: /* The stacks and their tools:
1142: 'yyss': related to states.
1143: 'yyvs': related to semantic values.
1144:
1145: Refer to the stacks through separate pointers, to allow yyoverflow
1146: to reallocate them elsewhere. */
1147:
1148: /* The state stack. */
1149: yytype_int16 yyssa[YYINITDEPTH];
1150: yytype_int16 *yyss;
1151: yytype_int16 *yyssp;
1152:
1153: /* The semantic value stack. */
1154: YYSTYPE yyvsa[YYINITDEPTH];
1155: YYSTYPE *yyvs;
1156: YYSTYPE *yyvsp;
1157:
1158: YYSIZE_T yystacksize;
1159:
1160: int yyn;
1161: int yyresult;
1162: /* Lookahead token as an internal (translated) token number. */
1163: int yytoken = 0;
1164: /* The variables used to return semantic value and location from the
1165: action routines. */
1166: YYSTYPE yyval;
1167:
1168: #if YYERROR_VERBOSE
1169: /* Buffer for error messages, and its allocated size. */
1170: char yymsgbuf[128];
1171: char *yymsg = yymsgbuf;
1172: YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1173: #endif
1174:
1175: #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1176:
1177: /* The number of symbols on the RHS of the reduced rule.
1178: Keep to zero when no symbol should be popped. */
1179: int yylen = 0;
1180:
1181: yyssp = yyss = yyssa;
1182: yyvsp = yyvs = yyvsa;
1183: yystacksize = YYINITDEPTH;
1184:
1185: YYDPRINTF ((stderr, "Starting parse\n"));
1186:
1187: yystate = 0;
1188: yyerrstatus = 0;
1189: yynerrs = 0;
1190: yychar = YYEMPTY; /* Cause a token to be read. */
1191: goto yysetstate;
1192:
1193: /*------------------------------------------------------------.
1194: | yynewstate -- Push a new state, which is found in yystate. |
1195: `------------------------------------------------------------*/
1196: yynewstate:
1197: /* In all cases, when you get here, the value and location stacks
1198: have just been pushed. So pushing a state here evens the stacks. */
1199: yyssp++;
1200:
1201: yysetstate:
1202: *yyssp = yystate;
1203:
1204: if (yyss + yystacksize - 1 <= yyssp)
1205: {
1206: /* Get the current used size of the three stacks, in elements. */
1207: YYSIZE_T yysize = yyssp - yyss + 1;
1208:
1209: #ifdef yyoverflow
1210: {
1211: /* Give user a chance to reallocate the stack. Use copies of
1212: these so that the &'s don't force the real ones into
1213: memory. */
1214: YYSTYPE *yyvs1 = yyvs;
1215: yytype_int16 *yyss1 = yyss;
1216:
1217: /* Each stack pointer address is followed by the size of the
1218: data in use in that stack, in bytes. This used to be a
1219: conditional around just the two extra args, but that might
1220: be undefined if yyoverflow is a macro. */
1221: yyoverflow (YY_("memory exhausted"),
1222: &yyss1, yysize * sizeof (*yyssp),
1223: &yyvs1, yysize * sizeof (*yyvsp),
1224: &yystacksize);
1225:
1226: yyss = yyss1;
1227: yyvs = yyvs1;
1228: }
1229: #else /* no yyoverflow */
1230: # ifndef YYSTACK_RELOCATE
1231: goto yyexhaustedlab;
1232: # else
1233: /* Extend the stack our own way. */
1234: if (YYMAXDEPTH <= yystacksize)
1235: goto yyexhaustedlab;
1236: yystacksize *= 2;
1237: if (YYMAXDEPTH < yystacksize)
1238: yystacksize = YYMAXDEPTH;
1239:
1240: {
1241: yytype_int16 *yyss1 = yyss;
1242: union yyalloc *yyptr =
1243: (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1244: if (! yyptr)
1245: goto yyexhaustedlab;
1246: YYSTACK_RELOCATE (yyss_alloc, yyss);
1247: YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1248: # undef YYSTACK_RELOCATE
1249: if (yyss1 != yyssa)
1250: YYSTACK_FREE (yyss1);
1251: }
1252: # endif
1253: #endif /* no yyoverflow */
1254:
1255: yyssp = yyss + yysize - 1;
1256: yyvsp = yyvs + yysize - 1;
1257:
1258: YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1259: (unsigned long int) yystacksize));
1260:
1261: if (yyss + yystacksize - 1 <= yyssp)
1262: YYABORT;
1263: }
1264:
1265: YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1266:
1267: if (yystate == YYFINAL)
1268: YYACCEPT;
1269:
1270: goto yybackup;
1271:
1272: /*-----------.
1273: | yybackup. |
1274: `-----------*/
1275: yybackup:
1276:
1277: /* Do appropriate processing given the current state. Read a
1278: lookahead token if we need one and don't already have one. */
1279:
1280: /* First try to decide what to do without reference to lookahead token. */
1281: yyn = yypact[yystate];
1282: if (yypact_value_is_default (yyn))
1283: goto yydefault;
1284:
1285: /* Not known => get a lookahead token if don't already have one. */
1286:
1287: /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1288: if (yychar == YYEMPTY)
1289: {
1290: YYDPRINTF ((stderr, "Reading a token: "));
1291: yychar = yylex (&yylval, ctx);
1292: }
1293:
1294: if (yychar <= YYEOF)
1295: {
1296: yychar = yytoken = YYEOF;
1297: YYDPRINTF ((stderr, "Now at end of input.\n"));
1298: }
1299: else
1300: {
1301: yytoken = YYTRANSLATE (yychar);
1302: YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1303: }
1304:
1305: /* If the proper action on seeing token YYTOKEN is to reduce or to
1306: detect an error, take that action. */
1307: yyn += yytoken;
1308: if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1309: goto yydefault;
1310: yyn = yytable[yyn];
1311: if (yyn <= 0)
1312: {
1313: if (yytable_value_is_error (yyn))
1314: goto yyerrlab;
1315: yyn = -yyn;
1316: goto yyreduce;
1317: }
1318:
1319: /* Count tokens shifted since error; after three, turn off error
1320: status. */
1321: if (yyerrstatus)
1322: yyerrstatus--;
1323:
1324: /* Shift the lookahead token. */
1325: YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1326:
1327: /* Discard the shifted token. */
1328: yychar = YYEMPTY;
1329:
1330: yystate = yyn;
1331: YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1332: *++yyvsp = yylval;
1333: YY_IGNORE_MAYBE_UNINITIALIZED_END
1334:
1335: goto yynewstate;
1336:
1337:
1338: /*-----------------------------------------------------------.
1339: | yydefault -- do the default action for the current state. |
1340: `-----------------------------------------------------------*/
1341: yydefault:
1342: yyn = yydefact[yystate];
1343: if (yyn == 0)
1344: goto yyerrlab;
1345: goto yyreduce;
1346:
1347:
1348: /*-----------------------------.
1349: | yyreduce -- Do a reduction. |
1350: `-----------------------------*/
1351: yyreduce:
1352: /* yyn is the number of a rule to reduce with. */
1353: yylen = yyr2[yyn];
1354:
1355: /* If YYLEN is nonzero, implement the default value of the action:
1356: '$$ = $1'.
1357:
1358: Otherwise, the following line sets YYVAL to garbage.
1359: This behavior is undocumented and Bison
1360: users should not rely upon it. Assigning to YYVAL
1361: unconditionally makes the parser a bit smaller, and it avoids a
1362: GCC warning that YYVAL may be used uninitialized. */
1363: yyval = yyvsp[1-yylen];
1364:
1365:
1366: YY_REDUCE_PRINT (yyn);
1367: switch (yyn)
1368: {
1369: case 5:
1.1.1.2 ! misho 1370: #line 127 "settings/settings_parser.y" /* yacc.c:1646 */
1.1 misho 1371: {
1372: add_section(ctx, (yyvsp[0].sec));
1373: }
1.1.1.2 ! misho 1374: #line 1375 "settings/settings_parser.c" /* yacc.c:1646 */
1.1 misho 1375: break;
1376:
1377: case 6:
1.1.1.2 ! misho 1378: #line 131 "settings/settings_parser.y" /* yacc.c:1646 */
1.1 misho 1379: {
1380: add_setting(ctx, (yyvsp[0].kv));
1381: }
1.1.1.2 ! misho 1382: #line 1383 "settings/settings_parser.c" /* yacc.c:1646 */
1.1 misho 1383: break;
1384:
1385: case 7:
1.1.1.2 ! misho 1386: #line 138 "settings/settings_parser.y" /* yacc.c:1646 */
1.1 misho 1387: {
1388: pop_section(ctx);
1389: (yyval.sec) = (yyvsp[-2].sec);
1390: }
1.1.1.2 ! misho 1391: #line 1392 "settings/settings_parser.c" /* yacc.c:1646 */
1.1 misho 1392: break;
1393:
1394: case 8:
1.1.1.2 ! misho 1395: #line 146 "settings/settings_parser.y" /* yacc.c:1646 */
1.1 misho 1396: {
1397: (yyval.sec) = push_section(ctx, (yyvsp[-1].s));
1398: }
1.1.1.2 ! misho 1399: #line 1400 "settings/settings_parser.c" /* yacc.c:1646 */
1.1 misho 1400: break;
1401:
1402: case 9:
1.1.1.2 ! misho 1403: #line 151 "settings/settings_parser.y" /* yacc.c:1646 */
1.1 misho 1404: {
1405: (yyval.sec) = push_section(ctx, (yyvsp[-3].s));
1406: add_references(ctx, (yyvsp[-1].refs));
1407: array_destroy((yyvsp[-1].refs));
1408: }
1.1.1.2 ! misho 1409: #line 1410 "settings/settings_parser.c" /* yacc.c:1646 */
1.1 misho 1410: break;
1411:
1412: case 10:
1.1.1.2 ! misho 1413: #line 160 "settings/settings_parser.y" /* yacc.c:1646 */
1.1 misho 1414: {
1415: (yyval.refs) = array_create(0, 0);
1416: array_insert((yyval.refs), ARRAY_TAIL, (yyvsp[0].s));
1417: }
1.1.1.2 ! misho 1418: #line 1419 "settings/settings_parser.c" /* yacc.c:1646 */
1.1 misho 1419: break;
1420:
1421: case 11:
1.1.1.2 ! misho 1422: #line 165 "settings/settings_parser.y" /* yacc.c:1646 */
1.1 misho 1423: {
1424: array_insert((yyvsp[-2].refs), ARRAY_TAIL, (yyvsp[0].s));
1425: (yyval.refs) = (yyvsp[-2].refs);
1426: }
1.1.1.2 ! misho 1427: #line 1428 "settings/settings_parser.c" /* yacc.c:1646 */
1.1 misho 1428: break;
1429:
1430: case 12:
1.1.1.2 ! misho 1431: #line 173 "settings/settings_parser.y" /* yacc.c:1646 */
1.1 misho 1432: {
1433: (yyval.kv) = settings_kv_create((yyvsp[-2].s), (yyvsp[0].s));
1434: }
1.1.1.2 ! misho 1435: #line 1436 "settings/settings_parser.c" /* yacc.c:1646 */
1.1 misho 1436: break;
1437:
1438: case 13:
1.1.1.2 ! misho 1439: #line 178 "settings/settings_parser.y" /* yacc.c:1646 */
1.1 misho 1440: {
1441: (yyval.kv) = settings_kv_create((yyvsp[-1].s), NULL);
1442: }
1.1.1.2 ! misho 1443: #line 1444 "settings/settings_parser.c" /* yacc.c:1646 */
1.1 misho 1444: break;
1445:
1446: case 15:
1.1.1.2 ! misho 1447: #line 186 "settings/settings_parser.y" /* yacc.c:1646 */
1.1 misho 1448: { /* just put a single space between them, use strings for more */
1449: if (asprintf(&(yyval.s), "%s %s", (yyvsp[-1].s), (yyvsp[0].s)) < 0)
1450: {
1451: free((yyvsp[-1].s));
1452: free((yyvsp[0].s));
1453: YYERROR;
1454: }
1455: free((yyvsp[-1].s));
1456: free((yyvsp[0].s));
1457: }
1.1.1.2 ! misho 1458: #line 1459 "settings/settings_parser.c" /* yacc.c:1646 */
1.1 misho 1459: break;
1460:
1461:
1.1.1.2 ! misho 1462: #line 1463 "settings/settings_parser.c" /* yacc.c:1646 */
1.1 misho 1463: default: break;
1464: }
1465: /* User semantic actions sometimes alter yychar, and that requires
1466: that yytoken be updated with the new translation. We take the
1467: approach of translating immediately before every use of yytoken.
1468: One alternative is translating here after every semantic action,
1469: but that translation would be missed if the semantic action invokes
1470: YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1471: if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1472: incorrect destructor might then be invoked immediately. In the
1473: case of YYERROR or YYBACKUP, subsequent parser actions might lead
1474: to an incorrect destructor call or verbose syntax error message
1475: before the lookahead is translated. */
1476: YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1477:
1478: YYPOPSTACK (yylen);
1479: yylen = 0;
1480: YY_STACK_PRINT (yyss, yyssp);
1481:
1482: *++yyvsp = yyval;
1483:
1484: /* Now 'shift' the result of the reduction. Determine what state
1485: that goes to, based on the state we popped back to and the rule
1486: number reduced by. */
1487:
1488: yyn = yyr1[yyn];
1489:
1490: yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1491: if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1492: yystate = yytable[yystate];
1493: else
1494: yystate = yydefgoto[yyn - YYNTOKENS];
1495:
1496: goto yynewstate;
1497:
1498:
1499: /*--------------------------------------.
1500: | yyerrlab -- here on detecting error. |
1501: `--------------------------------------*/
1502: yyerrlab:
1503: /* Make sure we have latest lookahead translation. See comments at
1504: user semantic actions for why this is necessary. */
1505: yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1506:
1507: /* If not already recovering from an error, report this error. */
1508: if (!yyerrstatus)
1509: {
1510: ++yynerrs;
1511: #if ! YYERROR_VERBOSE
1512: yyerror (ctx, YY_("syntax error"));
1513: #else
1514: # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1515: yyssp, yytoken)
1516: {
1517: char const *yymsgp = YY_("syntax error");
1518: int yysyntax_error_status;
1519: yysyntax_error_status = YYSYNTAX_ERROR;
1520: if (yysyntax_error_status == 0)
1521: yymsgp = yymsg;
1522: else if (yysyntax_error_status == 1)
1523: {
1524: if (yymsg != yymsgbuf)
1525: YYSTACK_FREE (yymsg);
1526: yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1527: if (!yymsg)
1528: {
1529: yymsg = yymsgbuf;
1530: yymsg_alloc = sizeof yymsgbuf;
1531: yysyntax_error_status = 2;
1532: }
1533: else
1534: {
1535: yysyntax_error_status = YYSYNTAX_ERROR;
1536: yymsgp = yymsg;
1537: }
1538: }
1539: yyerror (ctx, yymsgp);
1540: if (yysyntax_error_status == 2)
1541: goto yyexhaustedlab;
1542: }
1543: # undef YYSYNTAX_ERROR
1544: #endif
1545: }
1546:
1547:
1548:
1549: if (yyerrstatus == 3)
1550: {
1551: /* If just tried and failed to reuse lookahead token after an
1552: error, discard it. */
1553:
1554: if (yychar <= YYEOF)
1555: {
1556: /* Return failure if at end of input. */
1557: if (yychar == YYEOF)
1558: YYABORT;
1559: }
1560: else
1561: {
1562: yydestruct ("Error: discarding",
1563: yytoken, &yylval, ctx);
1564: yychar = YYEMPTY;
1565: }
1566: }
1567:
1568: /* Else will try to reuse lookahead token after shifting the error
1569: token. */
1570: goto yyerrlab1;
1571:
1572:
1573: /*---------------------------------------------------.
1574: | yyerrorlab -- error raised explicitly by YYERROR. |
1575: `---------------------------------------------------*/
1576: yyerrorlab:
1577:
1578: /* Pacify compilers like GCC when the user code never invokes
1579: YYERROR and the label yyerrorlab therefore never appears in user
1580: code. */
1581: if (/*CONSTCOND*/ 0)
1582: goto yyerrorlab;
1583:
1584: /* Do not reclaim the symbols of the rule whose action triggered
1585: this YYERROR. */
1586: YYPOPSTACK (yylen);
1587: yylen = 0;
1588: YY_STACK_PRINT (yyss, yyssp);
1589: yystate = *yyssp;
1590: goto yyerrlab1;
1591:
1592:
1593: /*-------------------------------------------------------------.
1594: | yyerrlab1 -- common code for both syntax error and YYERROR. |
1595: `-------------------------------------------------------------*/
1596: yyerrlab1:
1597: yyerrstatus = 3; /* Each real token shifted decrements this. */
1598:
1599: for (;;)
1600: {
1601: yyn = yypact[yystate];
1602: if (!yypact_value_is_default (yyn))
1603: {
1604: yyn += YYTERROR;
1605: if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1606: {
1607: yyn = yytable[yyn];
1608: if (0 < yyn)
1609: break;
1610: }
1611: }
1612:
1613: /* Pop the current state because it cannot handle the error token. */
1614: if (yyssp == yyss)
1615: YYABORT;
1616:
1617:
1618: yydestruct ("Error: popping",
1619: yystos[yystate], yyvsp, ctx);
1620: YYPOPSTACK (1);
1621: yystate = *yyssp;
1622: YY_STACK_PRINT (yyss, yyssp);
1623: }
1624:
1625: YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1626: *++yyvsp = yylval;
1627: YY_IGNORE_MAYBE_UNINITIALIZED_END
1628:
1629:
1630: /* Shift the error token. */
1631: YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1632:
1633: yystate = yyn;
1634: goto yynewstate;
1635:
1636:
1637: /*-------------------------------------.
1638: | yyacceptlab -- YYACCEPT comes here. |
1639: `-------------------------------------*/
1640: yyacceptlab:
1641: yyresult = 0;
1642: goto yyreturn;
1643:
1644: /*-----------------------------------.
1645: | yyabortlab -- YYABORT comes here. |
1646: `-----------------------------------*/
1647: yyabortlab:
1648: yyresult = 1;
1649: goto yyreturn;
1650:
1651: #if !defined yyoverflow || YYERROR_VERBOSE
1652: /*-------------------------------------------------.
1653: | yyexhaustedlab -- memory exhaustion comes here. |
1654: `-------------------------------------------------*/
1655: yyexhaustedlab:
1656: yyerror (ctx, YY_("memory exhausted"));
1657: yyresult = 2;
1658: /* Fall through. */
1659: #endif
1660:
1661: yyreturn:
1662: if (yychar != YYEMPTY)
1663: {
1664: /* Make sure we have latest lookahead translation. See comments at
1665: user semantic actions for why this is necessary. */
1666: yytoken = YYTRANSLATE (yychar);
1667: yydestruct ("Cleanup: discarding lookahead",
1668: yytoken, &yylval, ctx);
1669: }
1670: /* Do not reclaim the symbols of the rule whose action triggered
1671: this YYABORT or YYACCEPT. */
1672: YYPOPSTACK (yylen);
1673: YY_STACK_PRINT (yyss, yyssp);
1674: while (yyssp != yyss)
1675: {
1676: yydestruct ("Cleanup: popping",
1677: yystos[*yyssp], yyvsp, ctx);
1678: YYPOPSTACK (1);
1679: }
1680: #ifndef yyoverflow
1681: if (yyss != yyssa)
1682: YYSTACK_FREE (yyss);
1683: #endif
1684: #if YYERROR_VERBOSE
1685: if (yymsg != yymsgbuf)
1686: YYSTACK_FREE (yymsg);
1687: #endif
1688: return yyresult;
1689: }
1.1.1.2 ! misho 1690: #line 203 "settings/settings_parser.y" /* yacc.c:1906 */
1.1 misho 1691:
1692:
1693: /**
1694: * Referenced by the generated parser
1695: */
1696: static void settings_parser_error(parser_helper_t *ctx, const char *s)
1697: {
1698: char *text = settings_parser_get_text(ctx->scanner);
1699: int len = settings_parser_get_leng(ctx->scanner);
1700:
1701: if (len && text[len-1] == '\n')
1702: { /* cut off newline at the end to avoid muti-line log messages */
1703: len--;
1704: }
1705: PARSER_DBG1(ctx, "%s [%.*s]", s, len, text);
1706: }
1707:
1708: /**
1709: * Create a section and push it to the stack (the name is adopted), returns
1710: * the created section
1711: */
1712: static section_t *push_section(parser_helper_t *ctx, char *name)
1713: {
1714: array_t *sections = (array_t*)ctx->context;
1715: section_t *section;
1716:
1717: section = settings_section_create(name);
1718: array_insert(sections, ARRAY_TAIL, section);
1719: return section;
1720: }
1721:
1722: /**
1723: * Removes the top section of the stack and returns it
1724: */
1725: static section_t *pop_section(parser_helper_t *ctx)
1726: {
1727: array_t *sections = (array_t*)ctx->context;
1728: section_t *section;
1729:
1730: array_remove(sections, ARRAY_TAIL, §ion);
1731: return section;
1732: }
1733:
1734: /**
1735: * Adds the given section to the section on top of the stack
1736: */
1737: static void add_section(parser_helper_t *ctx, section_t *section)
1738: {
1739: array_t *sections = (array_t*)ctx->context;
1740: section_t *parent;
1741:
1742: array_get(sections, ARRAY_TAIL, &parent);
1743: settings_section_add(parent, section, NULL);
1744: }
1745:
1746: /**
1747: * Adds the given key/value pair to the section on top of the stack
1748: */
1749: static void add_setting(parser_helper_t *ctx, kv_t *kv)
1750: {
1751: array_t *sections = (array_t*)ctx->context;
1752: section_t *section;
1753:
1754: array_get(sections, ARRAY_TAIL, §ion);
1755: settings_kv_add(section, kv, NULL);
1756: }
1757:
1758: /**
1759: * Adds the given references to the section on top of the stack
1760: */
1761: static void add_references(parser_helper_t *ctx, array_t *references)
1762: {
1763: array_t *sections = (array_t*)ctx->context;
1764: section_t *section;
1765: enumerator_t *refs;
1766: char *ref;
1767:
1768: array_get(sections, ARRAY_TAIL, §ion);
1769:
1770: refs = array_create_enumerator(references);
1771: while (refs->enumerate(refs, &ref))
1772: {
1773: settings_reference_add(section, ref, FALSE);
1774: array_remove_at(references, refs);
1775: }
1776: refs->destroy(refs);
1777: }
1778:
1779: /**
1780: * Parse the given file and add all sections and key/value pairs to the
1781: * given section.
1782: */
1783: bool settings_parser_parse_file(section_t *root, char *name)
1784: {
1785: parser_helper_t *helper;
1786: array_t *sections = NULL;
1787: bool success = FALSE;
1788:
1789: array_insert_create(§ions, ARRAY_TAIL, root);
1790: helper = parser_helper_create(sections);
1791: helper->get_lineno = settings_parser_get_lineno;
1792: if (settings_parser_lex_init_extra(helper, &helper->scanner) != 0)
1793: {
1794: helper->destroy(helper);
1795: array_destroy(sections);
1796: return FALSE;
1797: }
1798: helper->file_include(helper, name);
1799: if (!settings_parser_open_next_file(helper))
1800: {
1801: if (lib->conf && streq(name, lib->conf))
1802: {
1803: DBG2(DBG_CFG, "failed to open config file '%s'", name);
1804: }
1805: else
1806: {
1807: DBG1(DBG_CFG, "failed to open config file '%s'", name);
1808: }
1809: }
1810: else
1811: {
1812: if (getenv("DEBUG_SETTINGS_PARSER"))
1813: {
1814: yydebug = 1;
1815: settings_parser_set_debug(1, helper->scanner);
1816: }
1817: success = yyparse(helper) == 0;
1818: if (!success)
1819: {
1820: DBG1(DBG_CFG, "invalid config file '%s'", name);
1821: }
1822: }
1823: array_destroy(sections);
1824: settings_parser_lex_destroy(helper->scanner);
1825: helper->destroy(helper);
1826: return success;
1827: }
1828:
1829: /**
1830: * Parse the given string and add all sections and key/value pairs to the
1831: * given section.
1832: */
1833: bool settings_parser_parse_string(section_t *root, char *settings)
1834: {
1835: parser_helper_t *helper;
1836: array_t *sections = NULL;
1837: bool success = FALSE;
1838:
1839: array_insert_create(§ions, ARRAY_TAIL, root);
1840: helper = parser_helper_create(sections);
1841: helper->get_lineno = settings_parser_get_lineno;
1842: if (settings_parser_lex_init_extra(helper, &helper->scanner) != 0)
1843: {
1844: helper->destroy(helper);
1845: array_destroy(sections);
1846: return FALSE;
1847: }
1848: settings_parser_load_string(helper, settings);
1849: if (getenv("DEBUG_SETTINGS_PARSER"))
1850: {
1851: yydebug = 1;
1852: settings_parser_set_debug(1, helper->scanner);
1853: }
1854: success = yyparse(helper) == 0;
1855: if (!success)
1856: {
1857: DBG1(DBG_CFG, "failed to parse settings '%s'", settings);
1858: }
1859: array_destroy(sections);
1860: settings_parser_lex_destroy(helper->scanner);
1861: helper->destroy(helper);
1862: return success;
1863: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>