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