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