Coverage Report

Created: 2024-02-29 06:05

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