1 /* A Bison parser, made by GNU Bison 3.8.2.  */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5    Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 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 <https://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 /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38    especially those whose name start with YY_ or yy_.  They are
39    private implementation details that can be changed or removed.  */
40 
41 /* All symbols defined below should begin with yy or YY, to avoid
42    infringing on user name space.  This should be done even for local
43    variables, as they might otherwise be expanded by user macros.
44    There are some unavoidable exceptions within include files to
45    define necessary library symbols; they are noted "INFRINGES ON
46    USER NAME SPACE" below.  */
47 
48 /* Identify Bison output, and Bison version.  */
49 #define YYBISON 30802
50 
51 /* Bison version string.  */
52 #define YYBISON_VERSION "3.8.2"
53 
54 /* Skeleton name.  */
55 #define YYSKELETON_NAME "yacc.c"
56 
57 /* Pure parsers.  */
58 #define YYPURE 0
59 
60 /* Push parsers.  */
61 #define YYPUSH 0
62 
63 /* Pull parsers.  */
64 #define YYPULL 1
65 
66 
67 /* Substitute the variable and function names.  */
68 #define yyparse         confparse
69 #define yylex           conflex
70 #define yyerror         conferror
71 #define yydebug         confdebug
72 #define yynerrs         confnerrs
73 #define yylval          conflval
74 #define yychar          confchar
75 
76 /* First part of user prologue.  */
77 #line 4 "src/conf_yacc.y"
78 
79 
80 /*
81  * AIDE (Advanced Intrusion Detection Environment)
82  *
83  * Copyright (C) 1999-2006, 2010-2013, 2015-2016, 2019-2021 Rami Lehti,
84  *               Pablo Virolainen, Richard van den Berg, Hannes von Haugwitz
85  *
86  * This program is free software; you can redistribute it and/or
87  * modify it under the terms of the GNU General Public License as
88  * published by the Free Software Foundation; either version 2 of the
89  * License, or (at your option) any later version.
90  *
91  * This program is distributed in the hope that it will be useful, but
92  * WITHOUT ANY WARRANTY; without even the implied warranty of
93  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
94  * General Public License for more details.
95  *
96  * You should have received a copy of the GNU General Public License along
97  * with this program; if not, write to the Free Software Foundation, Inc.,
98  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
99  */
100 
101 #include "aide.h"
102 #include "attributes.h"
103 #include <stdio.h>
104 #include <stdlib.h>
105 #include <ctype.h>
106 #include <errno.h>
107 #include <string.h>
108 #include "list.h"
109 #include "conf_lex.h"
110 #include "gen_list.h"
111 #include "db.h"
112 #include "db_config.h"
113 #include "symboltable.h"
114 #include "util.h"
115 #include "commandconf.h"
116 
117 #include "seltree.h"
118 
119 DB_ATTR_TYPE retval=0;
120 
121 #include "conf_ast.h"
122 extern int conflex();
123 void conferror(ast**, const char *);
124 
125 
126 #line 127 "src/conf_yacc.c"
127 
128 # ifndef YY_CAST
129 #  ifdef __cplusplus
130 #   define YY_CAST(Type, Val) static_cast<Type> (Val)
131 #   define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
132 #  else
133 #   define YY_CAST(Type, Val) ((Type) (Val))
134 #   define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
135 #  endif
136 # endif
137 # ifndef YY_NULLPTR
138 #  if defined __cplusplus
139 #   if 201103L <= __cplusplus
140 #    define YY_NULLPTR nullptr
141 #   else
142 #    define YY_NULLPTR 0
143 #   endif
144 #  else
145 #   define YY_NULLPTR ((void*)0)
146 #  endif
147 # endif
148 
149 #include "conf_yacc.h"
150 /* Symbol kind.  */
151 enum yysymbol_kind_t
152 {
153   YYSYMBOL_YYEMPTY = -2,
154   YYSYMBOL_YYEOF = 0,                      /* "end of file"  */
155   YYSYMBOL_YYerror = 1,                    /* error  */
156   YYSYMBOL_YYUNDEF = 2,                    /* "invalid token"  */
157   YYSYMBOL_TDEFINE = 3,                    /* TDEFINE  */
158   YYSYMBOL_TUNDEFINE = 4,                  /* TUNDEFINE  */
159   YYSYMBOL_TIFDEF = 5,                     /* TIFDEF  */
160   YYSYMBOL_TIFNDEF = 6,                    /* TIFNDEF  */
161   YYSYMBOL_TIFNHOST = 7,                   /* TIFNHOST  */
162   YYSYMBOL_TIFHOST = 8,                    /* TIFHOST  */
163   YYSYMBOL_TELSE = 9,                      /* TELSE  */
164   YYSYMBOL_TENDIF = 10,                    /* TENDIF  */
165   YYSYMBOL_TINCLUDE = 11,                  /* TINCLUDE  */
166   YYSYMBOL_TXINCLUDE = 12,                 /* TXINCLUDE  */
167   YYSYMBOL_TSETENV = 13,                   /* TSETENV  */
168   YYSYMBOL_TGROUP = 14,                    /* TGROUP  */
169   YYSYMBOL_TSTRING = 15,                   /* TSTRING  */
170   YYSYMBOL_TEXPR = 16,                     /* TEXPR  */
171   YYSYMBOL_TVARIABLE = 17,                 /* TVARIABLE  */
172   YYSYMBOL_TSPACE = 18,                    /* TSPACE  */
173   YYSYMBOL_TNEWLINE = 19,                  /* TNEWLINE  */
174   YYSYMBOL_TSELRXRULE = 20,                /* TSELRXRULE  */
175   YYSYMBOL_TEQURXRULE = 21,                /* TEQURXRULE  */
176   YYSYMBOL_TNEGRXRULE = 22,                /* TNEGRXRULE  */
177   YYSYMBOL_CONFIGOPTION = 23,              /* CONFIGOPTION  */
178   YYSYMBOL_24_ = 24,                       /* '+'  */
179   YYSYMBOL_25_ = 25,                       /* '-'  */
180   YYSYMBOL_26_ = 26,                       /* ','  */
181   YYSYMBOL_27_ = 27,                       /* '='  */
182   YYSYMBOL_YYACCEPT = 28,                  /* $accept  */
183   YYSYMBOL_config = 29,                    /* config  */
184   YYSYMBOL_statements = 30,                /* statements  */
185   YYSYMBOL_statement = 31,                 /* statement  */
186   YYSYMBOL_attribute_expression = 32,      /* attribute_expression  */
187   YYSYMBOL_restriction_expression = 33,    /* restriction_expression  */
188   YYSYMBOL_define_statement = 34,          /* define_statement  */
189   YYSYMBOL_string_expression = 35,         /* string_expression  */
190   YYSYMBOL_string_fragment = 36,           /* string_fragment  */
191   YYSYMBOL_undefine_statement = 37,        /* undefine_statement  */
192   YYSYMBOL_config_statement = 38,          /* config_statement  */
193   YYSYMBOL_group_statement = 39,           /* group_statement  */
194   YYSYMBOL_include_statement = 40,         /* include_statement  */
195   YYSYMBOL_x_include_setenv_statement = 41, /* x_include_setenv_statement  */
196   YYSYMBOL_if_statement = 42,              /* if_statement  */
197   YYSYMBOL_if_condition = 43,              /* if_condition  */
198   YYSYMBOL_rule_statement = 44             /* rule_statement  */
199 };
200 typedef enum yysymbol_kind_t yysymbol_kind_t;
201 
202 
203 
204 
205 #ifdef short
206 # undef short
207 #endif
208 
209 /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
210    <limits.h> and (if available) <stdint.h> are included
211    so that the code can choose integer types of a good width.  */
212 
213 #ifndef __PTRDIFF_MAX__
214 # include <limits.h> /* INFRINGES ON USER NAME SPACE */
215 # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
216 #  include <stdint.h> /* INFRINGES ON USER NAME SPACE */
217 #  define YY_STDINT_H
218 # endif
219 #endif
220 
221 /* Narrow types that promote to a signed type and that can represent a
222    signed or unsigned integer of at least N bits.  In tables they can
223    save space and decrease cache pressure.  Promoting to a signed type
224    helps avoid bugs in integer arithmetic.  */
225 
226 #ifdef __INT_LEAST8_MAX__
227 typedef __INT_LEAST8_TYPE__ yytype_int8;
228 #elif defined YY_STDINT_H
229 typedef int_least8_t yytype_int8;
230 #else
231 typedef signed char yytype_int8;
232 #endif
233 
234 #ifdef __INT_LEAST16_MAX__
235 typedef __INT_LEAST16_TYPE__ yytype_int16;
236 #elif defined YY_STDINT_H
237 typedef int_least16_t yytype_int16;
238 #else
239 typedef short yytype_int16;
240 #endif
241 
242 /* Work around bug in HP-UX 11.23, which defines these macros
243    incorrectly for preprocessor constants.  This workaround can likely
244    be removed in 2023, as HPE has promised support for HP-UX 11.23
245    (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
246    <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>.  */
247 #ifdef __hpux
248 # undef UINT_LEAST8_MAX
249 # undef UINT_LEAST16_MAX
250 # define UINT_LEAST8_MAX 255
251 # define UINT_LEAST16_MAX 65535
252 #endif
253 
254 #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
255 typedef __UINT_LEAST8_TYPE__ yytype_uint8;
256 #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
257        && UINT_LEAST8_MAX <= INT_MAX)
258 typedef uint_least8_t yytype_uint8;
259 #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
260 typedef unsigned char yytype_uint8;
261 #else
262 typedef short yytype_uint8;
263 #endif
264 
265 #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
266 typedef __UINT_LEAST16_TYPE__ yytype_uint16;
267 #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
268        && UINT_LEAST16_MAX <= INT_MAX)
269 typedef uint_least16_t yytype_uint16;
270 #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
271 typedef unsigned short yytype_uint16;
272 #else
273 typedef int yytype_uint16;
274 #endif
275 
276 #ifndef YYPTRDIFF_T
277 # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
278 #  define YYPTRDIFF_T __PTRDIFF_TYPE__
279 #  define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
280 # elif defined PTRDIFF_MAX
281 #  ifndef ptrdiff_t
282 #   include <stddef.h> /* INFRINGES ON USER NAME SPACE */
283 #  endif
284 #  define YYPTRDIFF_T ptrdiff_t
285 #  define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
286 # else
287 #  define YYPTRDIFF_T long
288 #  define YYPTRDIFF_MAXIMUM LONG_MAX
289 # endif
290 #endif
291 
292 #ifndef YYSIZE_T
293 # ifdef __SIZE_TYPE__
294 #  define YYSIZE_T __SIZE_TYPE__
295 # elif defined size_t
296 #  define YYSIZE_T size_t
297 # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
298 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
299 #  define YYSIZE_T size_t
300 # else
301 #  define YYSIZE_T unsigned
302 # endif
303 #endif
304 
305 #define YYSIZE_MAXIMUM                                  \
306   YY_CAST (YYPTRDIFF_T,                                 \
307            (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1)  \
308             ? YYPTRDIFF_MAXIMUM                         \
309             : YY_CAST (YYSIZE_T, -1)))
310 
311 #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
312 
313 
314 /* Stored state numbers (used for stacks). */
315 typedef yytype_int8 yy_state_t;
316 
317 /* State numbers in computations.  */
318 typedef int yy_state_fast_t;
319 
320 #ifndef YY_
321 # if defined YYENABLE_NLS && YYENABLE_NLS
322 #  if ENABLE_NLS
323 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
324 #   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
325 #  endif
326 # endif
327 # ifndef YY_
328 #  define YY_(Msgid) Msgid
329 # endif
330 #endif
331 
332 
333 #ifndef YY_ATTRIBUTE_PURE
334 # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
335 #  define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
336 # else
337 #  define YY_ATTRIBUTE_PURE
338 # endif
339 #endif
340 
341 #ifndef YY_ATTRIBUTE_UNUSED
342 # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
343 #  define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
344 # else
345 #  define YY_ATTRIBUTE_UNUSED
346 # endif
347 #endif
348 
349 /* Suppress unused-variable warnings by "using" E.  */
350 #if ! defined lint || defined __GNUC__
351 # define YY_USE(E) ((void) (E))
352 #else
353 # define YY_USE(E) /* empty */
354 #endif
355 
356 /* Suppress an incorrect diagnostic about yylval being uninitialized.  */
357 #if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
358 # if __GNUC__ * 100 + __GNUC_MINOR__ < 407
359 #  define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                           \
360     _Pragma ("GCC diagnostic push")                                     \
361     _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
362 # else
363 #  define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                           \
364     _Pragma ("GCC diagnostic push")                                     \
365     _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")              \
366     _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
367 # endif
368 # define YY_IGNORE_MAYBE_UNINITIALIZED_END      \
369     _Pragma ("GCC diagnostic pop")
370 #else
371 # define YY_INITIAL_VALUE(Value) Value
372 #endif
373 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
374 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
375 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
376 #endif
377 #ifndef YY_INITIAL_VALUE
378 # define YY_INITIAL_VALUE(Value) /* Nothing. */
379 #endif
380 
381 #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
382 # define YY_IGNORE_USELESS_CAST_BEGIN                          \
383     _Pragma ("GCC diagnostic push")                            \
384     _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
385 # define YY_IGNORE_USELESS_CAST_END            \
386     _Pragma ("GCC diagnostic pop")
387 #endif
388 #ifndef YY_IGNORE_USELESS_CAST_BEGIN
389 # define YY_IGNORE_USELESS_CAST_BEGIN
390 # define YY_IGNORE_USELESS_CAST_END
391 #endif
392 
393 
394 #define YY_ASSERT(E) ((void) (0 && (E)))
395 
396 #if !defined yyoverflow
397 
398 /* The parser invokes alloca or malloc; define the necessary symbols.  */
399 
400 # ifdef YYSTACK_USE_ALLOCA
401 #  if YYSTACK_USE_ALLOCA
402 #   ifdef __GNUC__
403 #    define YYSTACK_ALLOC __builtin_alloca
404 #   elif defined __BUILTIN_VA_ARG_INCR
405 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
406 #   elif defined _AIX
407 #    define YYSTACK_ALLOC __alloca
408 #   elif defined _MSC_VER
409 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
410 #    define alloca _alloca
411 #   else
412 #    define YYSTACK_ALLOC alloca
413 #    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
414 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
415       /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
416 #     ifndef EXIT_SUCCESS
417 #      define EXIT_SUCCESS 0
418 #     endif
419 #    endif
420 #   endif
421 #  endif
422 # endif
423 
424 # ifdef YYSTACK_ALLOC
425    /* Pacify GCC's 'empty if-body' warning.  */
426 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
427 #  ifndef YYSTACK_ALLOC_MAXIMUM
428     /* The OS might guarantee only one guard page at the bottom of the stack,
429        and a page size can be as small as 4096 bytes.  So we cannot safely
430        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
431        to allow for a few compiler-allocated temporary stack slots.  */
432 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
433 #  endif
434 # else
435 #  define YYSTACK_ALLOC YYMALLOC
436 #  define YYSTACK_FREE YYFREE
437 #  ifndef YYSTACK_ALLOC_MAXIMUM
438 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
439 #  endif
440 #  if (defined __cplusplus && ! defined EXIT_SUCCESS \
441        && ! ((defined YYMALLOC || defined malloc) \
442              && (defined YYFREE || defined free)))
443 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
444 #   ifndef EXIT_SUCCESS
445 #    define EXIT_SUCCESS 0
446 #   endif
447 #  endif
448 #  ifndef YYMALLOC
449 #   define YYMALLOC malloc
450 #   if ! defined malloc && ! defined EXIT_SUCCESS
451 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
452 #   endif
453 #  endif
454 #  ifndef YYFREE
455 #   define YYFREE free
456 #   if ! defined free && ! defined EXIT_SUCCESS
457 void free (void *); /* INFRINGES ON USER NAME SPACE */
458 #   endif
459 #  endif
460 # endif
461 #endif /* !defined yyoverflow */
462 
463 #if (! defined yyoverflow \
464      && (! defined __cplusplus \
465          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
466 
467 /* A type that is properly aligned for any stack member.  */
468 union yyalloc
469 {
470   yy_state_t yyss_alloc;
471   YYSTYPE yyvs_alloc;
472 };
473 
474 /* The size of the maximum gap between one aligned stack and the next.  */
475 # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
476 
477 /* The size of an array large to enough to hold all stacks, each with
478    N elements.  */
479 # define YYSTACK_BYTES(N) \
480      ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
481       + YYSTACK_GAP_MAXIMUM)
482 
483 # define YYCOPY_NEEDED 1
484 
485 /* Relocate STACK from its old location to the new one.  The
486    local variables YYSIZE and YYSTACKSIZE give the old and new number of
487    elements in the stack, and YYPTR gives the new location of the
488    stack.  Advance YYPTR to a properly aligned location for the next
489    stack.  */
490 # define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
491     do                                                                  \
492       {                                                                 \
493         YYPTRDIFF_T yynewbytes;                                         \
494         YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
495         Stack = &yyptr->Stack_alloc;                                    \
496         yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
497         yyptr += yynewbytes / YYSIZEOF (*yyptr);                        \
498       }                                                                 \
499     while (0)
500 
501 #endif
502 
503 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
504 /* Copy COUNT objects from SRC to DST.  The source and destination do
505    not overlap.  */
506 # ifndef YYCOPY
507 #  if defined __GNUC__ && 1 < __GNUC__
508 #   define YYCOPY(Dst, Src, Count) \
509       __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
510 #  else
511 #   define YYCOPY(Dst, Src, Count)              \
512       do                                        \
513         {                                       \
514           YYPTRDIFF_T yyi;                      \
515           for (yyi = 0; yyi < (Count); yyi++)   \
516             (Dst)[yyi] = (Src)[yyi];            \
517         }                                       \
518       while (0)
519 #  endif
520 # endif
521 #endif /* !YYCOPY_NEEDED */
522 
523 /* YYFINAL -- State number of the termination state.  */
524 #define YYFINAL  44
525 /* YYLAST -- Last index in YYTABLE.  */
526 #define YYLAST   74
527 
528 /* YYNTOKENS -- Number of terminals.  */
529 #define YYNTOKENS  28
530 /* YYNNTS -- Number of nonterminals.  */
531 #define YYNNTS  17
532 /* YYNRULES -- Number of rules.  */
533 #define YYNRULES  46
534 /* YYNSTATES -- Number of states.  */
535 #define YYNSTATES  82
536 
537 /* YYMAXUTOK -- Last valid token kind.  */
538 #define YYMAXUTOK   278
539 
540 
541 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
542    as returned by yylex, with out-of-bounds checking.  */
543 #define YYTRANSLATE(YYX)                                \
544   (0 <= (YYX) && (YYX) <= YYMAXUTOK                     \
545    ? YY_CAST (yysymbol_kind_t, yytranslate[YYX])        \
546    : YYSYMBOL_YYUNDEF)
547 
548 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
549    as returned by yylex.  */
550 static const yytype_int8 yytranslate[] =
551 {
552        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
553        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
554        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
555        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
556        2,     2,     2,    24,    26,    25,     2,     2,     2,     2,
557        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
558        2,    27,     2,     2,     2,     2,     2,     2,     2,     2,
559        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
560        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
561        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
562        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
563        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
564        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
565        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
566        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
567        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
568        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
569        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
570        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
571        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
572        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
573        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
574        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
575        2,     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,     1,     2,     3,     4,
578        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
579       15,    16,    17,    18,    19,    20,    21,    22,    23
580 };
581 
582 #if YYDEBUG
583 /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
584 static const yytype_uint8 yyrline[] =
585 {
586        0,   105,   105,   106,   108,   112,   113,   118,   119,   120,
587      121,   122,   122,   123,   124,   126,   127,   128,   130,   131,
588      133,   134,   136,   137,   138,   139,   141,   143,   144,   146,
589      148,   149,   150,   151,   153,   155,   156,   158,   159,   160,
590      161,   163,   164,   165,   166,   167,   168
591 };
592 #endif
593 
594 /** Accessing symbol of state STATE.  */
595 #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
596 
597 #if YYDEBUG || 0
598 /* The user-facing name of the symbol whose (internal) number is
599    YYSYMBOL.  No bounds checking.  */
600 static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
601 
602 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
603    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
604 static const char *const yytname[] =
605 {
606   "\"end of file\"", "error", "\"invalid token\"", "TDEFINE", "TUNDEFINE",
607   "TIFDEF", "TIFNDEF", "TIFNHOST", "TIFHOST", "TELSE", "TENDIF",
608   "TINCLUDE", "TXINCLUDE", "TSETENV", "TGROUP", "TSTRING", "TEXPR",
609   "TVARIABLE", "TSPACE", "TNEWLINE", "TSELRXRULE", "TEQURXRULE",
610   "TNEGRXRULE", "CONFIGOPTION", "'+'", "'-'", "','", "'='", "$accept",
611   "config", "statements", "statement", "attribute_expression",
612   "restriction_expression", "define_statement", "string_expression",
613   "string_fragment", "undefine_statement", "config_statement",
614   "group_statement", "include_statement", "x_include_setenv_statement",
615   "if_statement", "if_condition", "rule_statement", YY_NULLPTR
616 };
617 
618 static const char *
yysymbol_name(yysymbol_kind_t yysymbol)619 yysymbol_name (yysymbol_kind_t yysymbol)
620 {
621   return yytname[yysymbol];
622 }
623 #endif
624 
625 #define YYPACT_NINF (-43)
626 
627 #define yypact_value_is_default(Yyn) \
628   ((Yyn) == YYPACT_NINF)
629 
630 #define YYTABLE_NINF (-20)
631 
632 #define yytable_value_is_error(Yyn) \
633   0
634 
635 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
636    STATE-NUM.  */
637 static const yytype_int8 yypact[] =
638 {
639       37,    -7,     4,     5,     5,     5,     5,    -5,     8,    29,
640       11,     5,     5,     5,    20,    52,   -43,    34,   -43,   -43,
641      -43,   -43,   -43,   -43,   -43,    35,   -43,     5,   -43,   -43,
642      -43,   -43,     5,   -43,   -43,   -43,     5,     5,     5,    39,
643       40,    40,    47,     2,   -43,    37,    37,   -43,   -43,    46,
644       48,   -43,   -43,     0,   -11,     0,   -10,     0,   -10,   -43,
645       41,     0,   -43,   -43,    21,     5,     5,    49,    53,    54,
646        0,     0,    55,   -43,   -43,   -43,   -43,   -43,   -43,    37,
647       58,   -43
648 };
649 
650 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
651    Performed when YYTABLE does not specify something else to do.  Zero
652    means the default is an error.  */
653 static const yytype_int8 yydefact[] =
654 {
655        2,     0,     0,     0,     0,     0,     0,     0,     0,     0,
656        0,     0,     0,     0,     0,     0,     3,     6,    11,    12,
657        7,    13,     8,     9,    10,     0,    14,    20,    26,    24,
658       25,    37,    23,    38,    40,    39,     0,     0,     0,     0,
659        0,     0,    43,     0,     1,     5,     0,    21,    22,    30,
660       32,    34,    17,    29,    17,    41,     0,    42,     0,    19,
661       46,    28,    27,     4,     0,     0,     0,     0,     0,     0,
662       44,    45,     0,    35,    31,    33,    15,    16,    18,     0,
663        0,    36
664 };
665 
666 /* YYPGOTO[NTERM-NUM].  */
667 static const yytype_int8 yypgoto[] =
668 {
669      -43,   -43,   -42,   -43,   -29,    -6,   -43,    -4,   -43,   -43,
670      -43,   -43,   -43,   -43,   -43,   -43,   -43
671 };
672 
673 /* YYDEFGOTO[NTERM-NUM].  */
674 static const yytype_int8 yydefgoto[] =
675 {
676        0,    15,    16,    17,    53,    56,    18,    31,    32,    19,
677       20,    21,    22,    23,    24,    25,    26
678 };
679 
680 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
681    positive, shift that token.  If negative, reduce the rule whose
682    number is the opposite.  If YYTABLE_NINF, syntax error.  */
683 static const yytype_int8 yytable[] =
684 {
685       33,    34,    35,    63,    64,   -19,    52,    40,    41,    42,
686       27,    55,    57,    36,    61,   -19,    69,    29,    52,    30,
687       29,    28,    30,    47,    67,    68,    37,    70,    48,    71,
688       72,    73,    49,    50,    51,    58,    60,    80,    39,    62,
689        1,     2,     3,     4,     5,     6,    38,    43,     7,     8,
690        9,    10,    44,    45,    46,    52,    54,    11,    12,    13,
691       14,    74,    75,    59,    65,    76,    66,    69,    81,    77,
692       78,     0,     0,     0,    79
693 };
694 
695 static const yytype_int8 yycheck[] =
696 {
697        4,     5,     6,    45,    46,    16,    16,    11,    12,    13,
698       17,    40,    41,    18,    43,    26,    26,    15,    16,    17,
699       15,    17,    17,    27,    24,    25,    18,    56,    32,    58,
700        9,    10,    36,    37,    38,    41,    42,    79,    27,    43,
701        3,     4,     5,     6,     7,     8,    17,    27,    11,    12,
702       13,    14,     0,    19,    19,    16,    16,    20,    21,    22,
703       23,    65,    66,    16,    18,    16,    18,    26,    10,    16,
704       16,    -1,    -1,    -1,    19
705 };
706 
707 /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
708    state STATE-NUM.  */
709 static const yytype_int8 yystos[] =
710 {
711        0,     3,     4,     5,     6,     7,     8,    11,    12,    13,
712       14,    20,    21,    22,    23,    29,    30,    31,    34,    37,
713       38,    39,    40,    41,    42,    43,    44,    17,    17,    15,
714       17,    35,    36,    35,    35,    35,    18,    18,    17,    27,
715       35,    35,    35,    27,     0,    19,    19,    35,    35,    35,
716       35,    35,    16,    32,    16,    32,    33,    32,    33,    16,
717       33,    32,    35,    30,    30,    18,    18,    24,    25,    26,
718       32,    32,     9,    10,    35,    35,    16,    16,    16,    19,
719       30,    10
720 };
721 
722 /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM.  */
723 static const yytype_int8 yyr1[] =
724 {
725        0,    28,    29,    29,    30,    30,    30,    31,    31,    31,
726       31,    31,    31,    31,    31,    32,    32,    32,    33,    33,
727       34,    34,    35,    35,    36,    36,    37,    38,    38,    39,
728       40,    40,    40,    40,    41,    42,    42,    43,    43,    43,
729       43,    44,    44,    44,    44,    44,    44
730 };
731 
732 /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM.  */
733 static const yytype_int8 yyr2[] =
734 {
735        0,     2,     0,     1,     3,     2,     1,     1,     1,     1,
736        1,     1,     1,     1,     1,     3,     3,     1,     3,     1,
737        2,     3,     2,     1,     1,     1,     2,     3,     3,     3,
738        3,     5,     3,     5,     3,     4,     7,     2,     2,     2,
739        2,     3,     3,     2,     4,     4,     3
740 };
741 
742 
743 enum { YYENOMEM = -2 };
744 
745 #define yyerrok         (yyerrstatus = 0)
746 #define yyclearin       (yychar = YYEMPTY)
747 
748 #define YYACCEPT        goto yyacceptlab
749 #define YYABORT         goto yyabortlab
750 #define YYERROR         goto yyerrorlab
751 #define YYNOMEM         goto yyexhaustedlab
752 
753 
754 #define YYRECOVERING()  (!!yyerrstatus)
755 
756 #define YYBACKUP(Token, Value)                                    \
757   do                                                              \
758     if (yychar == YYEMPTY)                                        \
759       {                                                           \
760         yychar = (Token);                                         \
761         yylval = (Value);                                         \
762         YYPOPSTACK (yylen);                                       \
763         yystate = *yyssp;                                         \
764         goto yybackup;                                            \
765       }                                                           \
766     else                                                          \
767       {                                                           \
768         yyerror (config_ast, YY_("syntax error: cannot back up")); \
769         YYERROR;                                                  \
770       }                                                           \
771   while (0)
772 
773 /* Backward compatibility with an undocumented macro.
774    Use YYerror or YYUNDEF. */
775 #define YYERRCODE YYUNDEF
776 
777 
778 /* Enable debugging if requested.  */
779 #if YYDEBUG
780 
781 # ifndef YYFPRINTF
782 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
783 #  define YYFPRINTF fprintf
784 # endif
785 
786 # define YYDPRINTF(Args)                        \
787 do {                                            \
788   if (yydebug)                                  \
789     YYFPRINTF Args;                             \
790 } while (0)
791 
792 
793 
794 
795 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)                    \
796 do {                                                                      \
797   if (yydebug)                                                            \
798     {                                                                     \
799       YYFPRINTF (stderr, "%s ", Title);                                   \
800       yy_symbol_print (stderr,                                            \
801                   Kind, Value, config_ast); \
802       YYFPRINTF (stderr, "\n");                                           \
803     }                                                                     \
804 } while (0)
805 
806 
807 /*-----------------------------------.
808 | Print this symbol's value on YYO.  |
809 `-----------------------------------*/
810 
811 static void
yy_symbol_value_print(FILE * yyo,yysymbol_kind_t yykind,YYSTYPE const * const yyvaluep,ast ** config_ast)812 yy_symbol_value_print (FILE *yyo,
813                        yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, ast** config_ast)
814 {
815   FILE *yyoutput = yyo;
816   YY_USE (yyoutput);
817   YY_USE (config_ast);
818   if (!yyvaluep)
819     return;
820   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
821   YY_USE (yykind);
822   YY_IGNORE_MAYBE_UNINITIALIZED_END
823 }
824 
825 
826 /*---------------------------.
827 | Print this symbol on YYO.  |
828 `---------------------------*/
829 
830 static void
yy_symbol_print(FILE * yyo,yysymbol_kind_t yykind,YYSTYPE const * const yyvaluep,ast ** config_ast)831 yy_symbol_print (FILE *yyo,
832                  yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, ast** config_ast)
833 {
834   YYFPRINTF (yyo, "%s %s (",
835              yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
836 
837   yy_symbol_value_print (yyo, yykind, yyvaluep, config_ast);
838   YYFPRINTF (yyo, ")");
839 }
840 
841 /*------------------------------------------------------------------.
842 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
843 | TOP (included).                                                   |
844 `------------------------------------------------------------------*/
845 
846 static void
yy_stack_print(yy_state_t * yybottom,yy_state_t * yytop)847 yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
848 {
849   YYFPRINTF (stderr, "Stack now");
850   for (; yybottom <= yytop; yybottom++)
851     {
852       int yybot = *yybottom;
853       YYFPRINTF (stderr, " %d", yybot);
854     }
855   YYFPRINTF (stderr, "\n");
856 }
857 
858 # define YY_STACK_PRINT(Bottom, Top)                            \
859 do {                                                            \
860   if (yydebug)                                                  \
861     yy_stack_print ((Bottom), (Top));                           \
862 } while (0)
863 
864 
865 /*------------------------------------------------.
866 | Report that the YYRULE is going to be reduced.  |
867 `------------------------------------------------*/
868 
869 static void
yy_reduce_print(yy_state_t * yyssp,YYSTYPE * yyvsp,int yyrule,ast ** config_ast)870 yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
871                  int yyrule, ast** config_ast)
872 {
873   int yylno = yyrline[yyrule];
874   int yynrhs = yyr2[yyrule];
875   int yyi;
876   YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
877              yyrule - 1, yylno);
878   /* The symbols being reduced.  */
879   for (yyi = 0; yyi < yynrhs; yyi++)
880     {
881       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
882       yy_symbol_print (stderr,
883                        YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
884                        &yyvsp[(yyi + 1) - (yynrhs)], config_ast);
885       YYFPRINTF (stderr, "\n");
886     }
887 }
888 
889 # define YY_REDUCE_PRINT(Rule)          \
890 do {                                    \
891   if (yydebug)                          \
892     yy_reduce_print (yyssp, yyvsp, Rule, config_ast); \
893 } while (0)
894 
895 /* Nonzero means print parse trace.  It is left uninitialized so that
896    multiple parsers can coexist.  */
897 int yydebug;
898 #else /* !YYDEBUG */
899 # define YYDPRINTF(Args) ((void) 0)
900 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
901 # define YY_STACK_PRINT(Bottom, Top)
902 # define YY_REDUCE_PRINT(Rule)
903 #endif /* !YYDEBUG */
904 
905 
906 /* YYINITDEPTH -- initial size of the parser's stacks.  */
907 #ifndef YYINITDEPTH
908 # define YYINITDEPTH 200
909 #endif
910 
911 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
912    if the built-in stack extension method is used).
913 
914    Do not make this value too large; the results are undefined if
915    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
916    evaluated with infinite-precision integer arithmetic.  */
917 
918 #ifndef YYMAXDEPTH
919 # define YYMAXDEPTH 10000
920 #endif
921 
922 
923 
924 
925 
926 
927 /*-----------------------------------------------.
928 | Release the memory associated to this symbol.  |
929 `-----------------------------------------------*/
930 
931 static void
yydestruct(const char * yymsg,yysymbol_kind_t yykind,YYSTYPE * yyvaluep,ast ** config_ast)932 yydestruct (const char *yymsg,
933             yysymbol_kind_t yykind, YYSTYPE *yyvaluep, ast** config_ast)
934 {
935   YY_USE (yyvaluep);
936   YY_USE (config_ast);
937   if (!yymsg)
938     yymsg = "Deleting";
939   YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
940 
941   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
942   YY_USE (yykind);
943   YY_IGNORE_MAYBE_UNINITIALIZED_END
944 }
945 
946 
947 /* Lookahead token kind.  */
948 int yychar;
949 
950 /* The semantic value of the lookahead symbol.  */
951 YYSTYPE yylval;
952 /* Number of syntax errors so far.  */
953 int yynerrs;
954 
955 
956 
957 
958 /*----------.
959 | yyparse.  |
960 `----------*/
961 
962 int
yyparse(ast ** config_ast)963 yyparse (ast** config_ast)
964 {
965     yy_state_fast_t yystate = 0;
966     /* Number of tokens to shift before error messages enabled.  */
967     int yyerrstatus = 0;
968 
969     /* Refer to the stacks through separate pointers, to allow yyoverflow
970        to reallocate them elsewhere.  */
971 
972     /* Their size.  */
973     YYPTRDIFF_T yystacksize = YYINITDEPTH;
974 
975     /* The state stack: array, bottom, top.  */
976     yy_state_t yyssa[YYINITDEPTH];
977     yy_state_t *yyss = yyssa;
978     yy_state_t *yyssp = yyss;
979 
980     /* The semantic value stack: array, bottom, top.  */
981     YYSTYPE yyvsa[YYINITDEPTH];
982     YYSTYPE *yyvs = yyvsa;
983     YYSTYPE *yyvsp = yyvs;
984 
985   int yyn;
986   /* The return value of yyparse.  */
987   int yyresult;
988   /* Lookahead symbol kind.  */
989   yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
990   /* The variables used to return semantic value and location from the
991      action routines.  */
992   YYSTYPE yyval;
993 
994 
995 
996 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
997 
998   /* The number of symbols on the RHS of the reduced rule.
999      Keep to zero when no symbol should be popped.  */
1000   int yylen = 0;
1001 
1002   YYDPRINTF ((stderr, "Starting parse\n"));
1003 
1004   yychar = YYEMPTY; /* Cause a token to be read.  */
1005 
1006   goto yysetstate;
1007 
1008 
1009 /*------------------------------------------------------------.
1010 | yynewstate -- push a new state, which is found in yystate.  |
1011 `------------------------------------------------------------*/
1012 yynewstate:
1013   /* In all cases, when you get here, the value and location stacks
1014      have just been pushed.  So pushing a state here evens the stacks.  */
1015   yyssp++;
1016 
1017 
1018 /*--------------------------------------------------------------------.
1019 | yysetstate -- set current state (the top of the stack) to yystate.  |
1020 `--------------------------------------------------------------------*/
1021 yysetstate:
1022   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1023   YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1024   YY_IGNORE_USELESS_CAST_BEGIN
1025   *yyssp = YY_CAST (yy_state_t, yystate);
1026   YY_IGNORE_USELESS_CAST_END
1027   YY_STACK_PRINT (yyss, yyssp);
1028 
1029   if (yyss + yystacksize - 1 <= yyssp)
1030 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1031     YYNOMEM;
1032 #else
1033     {
1034       /* Get the current used size of the three stacks, in elements.  */
1035       YYPTRDIFF_T yysize = yyssp - yyss + 1;
1036 
1037 # if defined yyoverflow
1038       {
1039         /* Give user a chance to reallocate the stack.  Use copies of
1040            these so that the &'s don't force the real ones into
1041            memory.  */
1042         yy_state_t *yyss1 = yyss;
1043         YYSTYPE *yyvs1 = yyvs;
1044 
1045         /* Each stack pointer address is followed by the size of the
1046            data in use in that stack, in bytes.  This used to be a
1047            conditional around just the two extra args, but that might
1048            be undefined if yyoverflow is a macro.  */
1049         yyoverflow (YY_("memory exhausted"),
1050                     &yyss1, yysize * YYSIZEOF (*yyssp),
1051                     &yyvs1, yysize * YYSIZEOF (*yyvsp),
1052                     &yystacksize);
1053         yyss = yyss1;
1054         yyvs = yyvs1;
1055       }
1056 # else /* defined YYSTACK_RELOCATE */
1057       /* Extend the stack our own way.  */
1058       if (YYMAXDEPTH <= yystacksize)
1059         YYNOMEM;
1060       yystacksize *= 2;
1061       if (YYMAXDEPTH < yystacksize)
1062         yystacksize = YYMAXDEPTH;
1063 
1064       {
1065         yy_state_t *yyss1 = yyss;
1066         union yyalloc *yyptr =
1067           YY_CAST (union yyalloc *,
1068                    YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1069         if (! yyptr)
1070           YYNOMEM;
1071         YYSTACK_RELOCATE (yyss_alloc, yyss);
1072         YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1073 #  undef YYSTACK_RELOCATE
1074         if (yyss1 != yyssa)
1075           YYSTACK_FREE (yyss1);
1076       }
1077 # endif
1078 
1079       yyssp = yyss + yysize - 1;
1080       yyvsp = yyvs + yysize - 1;
1081 
1082       YY_IGNORE_USELESS_CAST_BEGIN
1083       YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1084                   YY_CAST (long, yystacksize)));
1085       YY_IGNORE_USELESS_CAST_END
1086 
1087       if (yyss + yystacksize - 1 <= yyssp)
1088         YYABORT;
1089     }
1090 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1091 
1092 
1093   if (yystate == YYFINAL)
1094     YYACCEPT;
1095 
1096   goto yybackup;
1097 
1098 
1099 /*-----------.
1100 | yybackup.  |
1101 `-----------*/
1102 yybackup:
1103   /* Do appropriate processing given the current state.  Read a
1104      lookahead token if we need one and don't already have one.  */
1105 
1106   /* First try to decide what to do without reference to lookahead token.  */
1107   yyn = yypact[yystate];
1108   if (yypact_value_is_default (yyn))
1109     goto yydefault;
1110 
1111   /* Not known => get a lookahead token if don't already have one.  */
1112 
1113   /* YYCHAR is either empty, or end-of-input, or a valid lookahead.  */
1114   if (yychar == YYEMPTY)
1115     {
1116       YYDPRINTF ((stderr, "Reading a token\n"));
1117       yychar = yylex ();
1118     }
1119 
1120   if (yychar <= YYEOF)
1121     {
1122       yychar = YYEOF;
1123       yytoken = YYSYMBOL_YYEOF;
1124       YYDPRINTF ((stderr, "Now at end of input.\n"));
1125     }
1126   else if (yychar == YYerror)
1127     {
1128       /* The scanner already issued an error message, process directly
1129          to error recovery.  But do not keep the error token as
1130          lookahead, it is too special and may lead us to an endless
1131          loop in error recovery. */
1132       yychar = YYUNDEF;
1133       yytoken = YYSYMBOL_YYerror;
1134       goto yyerrlab1;
1135     }
1136   else
1137     {
1138       yytoken = YYTRANSLATE (yychar);
1139       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1140     }
1141 
1142   /* If the proper action on seeing token YYTOKEN is to reduce or to
1143      detect an error, take that action.  */
1144   yyn += yytoken;
1145   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1146     goto yydefault;
1147   yyn = yytable[yyn];
1148   if (yyn <= 0)
1149     {
1150       if (yytable_value_is_error (yyn))
1151         goto yyerrlab;
1152       yyn = -yyn;
1153       goto yyreduce;
1154     }
1155 
1156   /* Count tokens shifted since error; after three, turn off error
1157      status.  */
1158   if (yyerrstatus)
1159     yyerrstatus--;
1160 
1161   /* Shift the lookahead token.  */
1162   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1163   yystate = yyn;
1164   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1165   *++yyvsp = yylval;
1166   YY_IGNORE_MAYBE_UNINITIALIZED_END
1167 
1168   /* Discard the shifted token.  */
1169   yychar = YYEMPTY;
1170   goto yynewstate;
1171 
1172 
1173 /*-----------------------------------------------------------.
1174 | yydefault -- do the default action for the current state.  |
1175 `-----------------------------------------------------------*/
1176 yydefault:
1177   yyn = yydefact[yystate];
1178   if (yyn == 0)
1179     goto yyerrlab;
1180   goto yyreduce;
1181 
1182 
1183 /*-----------------------------.
1184 | yyreduce -- do a reduction.  |
1185 `-----------------------------*/
1186 yyreduce:
1187   /* yyn is the number of a rule to reduce with.  */
1188   yylen = yyr2[yyn];
1189 
1190   /* If YYLEN is nonzero, implement the default value of the action:
1191      '$$ = $1'.
1192 
1193      Otherwise, the following line sets YYVAL to garbage.
1194      This behavior is undocumented and Bison
1195      users should not rely upon it.  Assigning to YYVAL
1196      unconditionally makes the parser a bit smaller, and it avoids a
1197      GCC warning that YYVAL may be used uninitialized.  */
1198   yyval = yyvsp[1-yylen];
1199 
1200 
1201   YY_REDUCE_PRINT (yyn);
1202   switch (yyn)
1203     {
1204   case 3: /* config: statements  */
1205 #line 106 "src/conf_yacc.y"
1206                     { *config_ast = (yyvsp[0].ast); }
1207 #line 1208 "src/conf_yacc.c"
1208     break;
1209 
1210   case 4: /* statements: statement TNEWLINE statements  */
1211 #line 108 "src/conf_yacc.y"
1212                                            {
1213                ast *temp = (yyvsp[-2].ast);
1214                temp->next = (yyvsp[0].ast);
1215                (yyval.ast) = (yyvsp[-2].ast); }
1216 #line 1217 "src/conf_yacc.c"
1217     break;
1218 
1219   case 5: /* statements: statement TNEWLINE  */
1220 #line 112 "src/conf_yacc.y"
1221                                     { (yyval.ast) = (yyvsp[-1].ast); }
1222 #line 1223 "src/conf_yacc.c"
1223     break;
1224 
1225   case 6: /* statements: statement  */
1226 #line 113 "src/conf_yacc.y"
1227                            {
1228                     log_msg(LOG_LEVEL_ERROR, "%s:%d: syntax error: unexpected token or end of file, expected newline (line: '%s')", conf_filename, conf_linenumber, conf_linebuf);
1229                     YYABORT;
1230                }
1231 #line 1232 "src/conf_yacc.c"
1232     break;
1233 
1234   case 15: /* attribute_expression: attribute_expression '+' TEXPR  */
1235 #line 126 "src/conf_yacc.y"
1236                                                      { (yyval.attr_expr) = new_attribute_expression(ATTR_OP_PLUS, (yyvsp[-2].attr_expr), (yyvsp[0].s)); }
1237 #line 1238 "src/conf_yacc.c"
1238     break;
1239 
1240   case 16: /* attribute_expression: attribute_expression '-' TEXPR  */
1241 #line 127 "src/conf_yacc.y"
1242                                                      { (yyval.attr_expr) = new_attribute_expression(ATTR_OP_MINUS, (yyvsp[-2].attr_expr), (yyvsp[0].s)); }
1243 #line 1244 "src/conf_yacc.c"
1244     break;
1245 
1246   case 17: /* attribute_expression: TEXPR  */
1247 #line 128 "src/conf_yacc.y"
1248                             { (yyval.attr_expr) = new_attribute_expression(ATTR_OP_GROUP, NULL, (yyvsp[0].s)); }
1249 #line 1250 "src/conf_yacc.c"
1250     break;
1251 
1252   case 18: /* restriction_expression: restriction_expression ',' TEXPR  */
1253 #line 130 "src/conf_yacc.y"
1254                                                          { (yyval.rs_expr) = new_restriction_expression((yyvsp[-2].rs_expr), (yyvsp[0].s)); }
1255 #line 1256 "src/conf_yacc.c"
1256     break;
1257 
1258   case 19: /* restriction_expression: TEXPR  */
1259 #line 131 "src/conf_yacc.y"
1260                               { (yyval.rs_expr) = new_restriction_expression(NULL, (yyvsp[0].s)); }
1261 #line 1262 "src/conf_yacc.c"
1262     break;
1263 
1264   case 20: /* define_statement: TDEFINE TVARIABLE  */
1265 #line 133 "src/conf_yacc.y"
1266                                     { (yyval.ast) = new_define_statement((yyvsp[0].s), NULL); }
1267 #line 1268 "src/conf_yacc.c"
1268     break;
1269 
1270   case 21: /* define_statement: TDEFINE TVARIABLE string_expression  */
1271 #line 134 "src/conf_yacc.y"
1272                                                       { (yyval.ast) = new_define_statement((yyvsp[-1].s), (yyvsp[0].string_expr)); }
1273 #line 1274 "src/conf_yacc.c"
1274     break;
1275 
1276   case 22: /* string_expression: string_fragment string_expression  */
1277 #line 136 "src/conf_yacc.y"
1278                                                      { (yyval.string_expr) = new_string_concat((yyvsp[-1].string_expr), (yyvsp[0].string_expr)); }
1279 #line 1280 "src/conf_yacc.c"
1280     break;
1281 
1282   case 23: /* string_expression: string_fragment  */
1283 #line 137 "src/conf_yacc.y"
1284                                    { (yyval.string_expr) = (yyvsp[0].string_expr); }
1285 #line 1286 "src/conf_yacc.c"
1286     break;
1287 
1288   case 24: /* string_fragment: TSTRING  */
1289 #line 138 "src/conf_yacc.y"
1290                          { (yyval.string_expr) = new_string((yyvsp[0].s)); }
1291 #line 1292 "src/conf_yacc.c"
1292     break;
1293 
1294   case 25: /* string_fragment: TVARIABLE  */
1295 #line 139 "src/conf_yacc.y"
1296                            { (yyval.string_expr) = new_variable((yyvsp[0].s)); }
1297 #line 1298 "src/conf_yacc.c"
1298     break;
1299 
1300   case 26: /* undefine_statement: TUNDEFINE TVARIABLE  */
1301 #line 141 "src/conf_yacc.y"
1302                                         { (yyval.ast) = new_undefine_statement((yyvsp[0].s)); }
1303 #line 1304 "src/conf_yacc.c"
1304     break;
1305 
1306   case 27: /* config_statement: CONFIGOPTION '=' string_expression  */
1307 #line 143 "src/conf_yacc.y"
1308                                                      { (yyval.ast) = new_string_option_statement((yyvsp[-2].option), (yyvsp[0].string_expr)); }
1309 #line 1310 "src/conf_yacc.c"
1310     break;
1311 
1312   case 28: /* config_statement: CONFIGOPTION '=' attribute_expression  */
1313 #line 144 "src/conf_yacc.y"
1314                                                         { (yyval.ast) = new_attribute_option_statement((yyvsp[-2].option), (yyvsp[0].attr_expr)); }
1315 #line 1316 "src/conf_yacc.c"
1316     break;
1317 
1318   case 29: /* group_statement: TGROUP '=' attribute_expression  */
1319 #line 146 "src/conf_yacc.y"
1320                                                  { (yyval.ast) = new_group_statement((yyvsp[-2].s), (yyvsp[0].attr_expr)); }
1321 #line 1322 "src/conf_yacc.c"
1322     break;
1323 
1324   case 30: /* include_statement: TINCLUDE TSPACE string_expression  */
1325 #line 148 "src/conf_yacc.y"
1326                                                      { (yyval.ast) = new_include_statement((yyvsp[0].string_expr), NULL, false); }
1327 #line 1328 "src/conf_yacc.c"
1328     break;
1329 
1330   case 31: /* include_statement: TINCLUDE TSPACE string_expression TSPACE string_expression  */
1331 #line 149 "src/conf_yacc.y"
1332                                                                               { (yyval.ast) = new_include_statement((yyvsp[-2].string_expr), (yyvsp[0].string_expr), false); }
1333 #line 1334 "src/conf_yacc.c"
1334     break;
1335 
1336   case 32: /* include_statement: TXINCLUDE TSPACE string_expression  */
1337 #line 150 "src/conf_yacc.y"
1338                                                       { (yyval.ast) = new_include_statement((yyvsp[0].string_expr), NULL, true); }
1339 #line 1340 "src/conf_yacc.c"
1340     break;
1341 
1342   case 33: /* include_statement: TXINCLUDE TSPACE string_expression TSPACE string_expression  */
1343 #line 151 "src/conf_yacc.y"
1344                                                                                { (yyval.ast) = new_include_statement((yyvsp[-2].string_expr), (yyvsp[0].string_expr), true); }
1345 #line 1346 "src/conf_yacc.c"
1346     break;
1347 
1348   case 34: /* x_include_setenv_statement: TSETENV TVARIABLE string_expression  */
1349 #line 153 "src/conf_yacc.y"
1350                                                                 { (yyval.ast) = new_x_include_setenv_statement((yyvsp[-1].s), (yyvsp[0].string_expr)); }
1351 #line 1352 "src/conf_yacc.c"
1352     break;
1353 
1354   case 35: /* if_statement: if_condition TNEWLINE statements TENDIF  */
1355 #line 155 "src/conf_yacc.y"
1356                                                       { (yyval.ast) = new_if_statement((yyvsp[-3].if_cond), (yyvsp[-1].ast), NULL); }
1357 #line 1358 "src/conf_yacc.c"
1358     break;
1359 
1360   case 36: /* if_statement: if_condition TNEWLINE statements TELSE TNEWLINE statements TENDIF  */
1361 #line 156 "src/conf_yacc.y"
1362                                                                                 { (yyval.ast) = new_if_statement((yyvsp[-6].if_cond), (yyvsp[-4].ast), (yyvsp[-1].ast)); }
1363 #line 1364 "src/conf_yacc.c"
1364     break;
1365 
1366   case 37: /* if_condition: TIFDEF string_expression  */
1367 #line 158 "src/conf_yacc.y"
1368                                        { (yyval.if_cond)=new_if_condition(new_string_bool_expression(BOOL_OP_DEFINED, (yyvsp[0].string_expr))); }
1369 #line 1370 "src/conf_yacc.c"
1370     break;
1371 
1372   case 38: /* if_condition: TIFNDEF string_expression  */
1373 #line 159 "src/conf_yacc.y"
1374                                         { (yyval.if_cond)=new_if_condition(new_bool_expression(BOOL_OP_NOT, new_string_bool_expression(BOOL_OP_DEFINED, (yyvsp[0].string_expr)), NULL)); }
1375 #line 1376 "src/conf_yacc.c"
1376     break;
1377 
1378   case 39: /* if_condition: TIFHOST string_expression  */
1379 #line 160 "src/conf_yacc.y"
1380                                         { (yyval.if_cond)=new_if_condition(new_string_bool_expression(BOOL_OP_HOSTNAME, (yyvsp[0].string_expr))); }
1381 #line 1382 "src/conf_yacc.c"
1382     break;
1383 
1384   case 40: /* if_condition: TIFNHOST string_expression  */
1385 #line 161 "src/conf_yacc.y"
1386                                          { (yyval.if_cond)=new_if_condition(new_bool_expression(BOOL_OP_NOT, new_string_bool_expression(BOOL_OP_HOSTNAME, (yyvsp[0].string_expr)), NULL)); }
1387 #line 1388 "src/conf_yacc.c"
1388     break;
1389 
1390   case 41: /* rule_statement: TSELRXRULE string_expression attribute_expression  */
1391 #line 163 "src/conf_yacc.y"
1392                                                                   { (yyval.ast) = new_rule_statement(AIDE_SELECTIVE_RULE, (yyvsp[-1].string_expr), NULL, (yyvsp[0].attr_expr)); }
1393 #line 1394 "src/conf_yacc.c"
1394     break;
1395 
1396   case 42: /* rule_statement: TEQURXRULE string_expression attribute_expression  */
1397 #line 164 "src/conf_yacc.y"
1398                                                                   { (yyval.ast) = new_rule_statement(AIDE_EQUAL_RULE, (yyvsp[-1].string_expr), NULL, (yyvsp[0].attr_expr)); }
1399 #line 1400 "src/conf_yacc.c"
1400     break;
1401 
1402   case 43: /* rule_statement: TNEGRXRULE string_expression  */
1403 #line 165 "src/conf_yacc.y"
1404                                              { (yyval.ast) = new_rule_statement(AIDE_NEGATIVE_RULE, (yyvsp[0].string_expr), NULL, NULL); }
1405 #line 1406 "src/conf_yacc.c"
1406     break;
1407 
1408   case 44: /* rule_statement: TSELRXRULE string_expression restriction_expression attribute_expression  */
1409 #line 166 "src/conf_yacc.y"
1410                                                                                          { (yyval.ast) = new_rule_statement(AIDE_SELECTIVE_RULE, (yyvsp[-2].string_expr), (yyvsp[-1].rs_expr), (yyvsp[0].attr_expr)); }
1411 #line 1412 "src/conf_yacc.c"
1412     break;
1413 
1414   case 45: /* rule_statement: TEQURXRULE string_expression restriction_expression attribute_expression  */
1415 #line 167 "src/conf_yacc.y"
1416                                                                                          { (yyval.ast) = new_rule_statement(AIDE_EQUAL_RULE, (yyvsp[-2].string_expr), (yyvsp[-1].rs_expr), (yyvsp[0].attr_expr)); }
1417 #line 1418 "src/conf_yacc.c"
1418     break;
1419 
1420   case 46: /* rule_statement: TNEGRXRULE string_expression restriction_expression  */
1421 #line 168 "src/conf_yacc.y"
1422                                                                     { (yyval.ast) = new_rule_statement(AIDE_NEGATIVE_RULE, (yyvsp[-1].string_expr), (yyvsp[0].rs_expr), NULL); }
1423 #line 1424 "src/conf_yacc.c"
1424     break;
1425 
1426 
1427 #line 1428 "src/conf_yacc.c"
1428 
1429       default: break;
1430     }
1431   /* User semantic actions sometimes alter yychar, and that requires
1432      that yytoken be updated with the new translation.  We take the
1433      approach of translating immediately before every use of yytoken.
1434      One alternative is translating here after every semantic action,
1435      but that translation would be missed if the semantic action invokes
1436      YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1437      if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
1438      incorrect destructor might then be invoked immediately.  In the
1439      case of YYERROR or YYBACKUP, subsequent parser actions might lead
1440      to an incorrect destructor call or verbose syntax error message
1441      before the lookahead is translated.  */
1442   YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1443 
1444   YYPOPSTACK (yylen);
1445   yylen = 0;
1446 
1447   *++yyvsp = yyval;
1448 
1449   /* Now 'shift' the result of the reduction.  Determine what state
1450      that goes to, based on the state we popped back to and the rule
1451      number reduced by.  */
1452   {
1453     const int yylhs = yyr1[yyn] - YYNTOKENS;
1454     const int yyi = yypgoto[yylhs] + *yyssp;
1455     yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1456                ? yytable[yyi]
1457                : yydefgoto[yylhs]);
1458   }
1459 
1460   goto yynewstate;
1461 
1462 
1463 /*--------------------------------------.
1464 | yyerrlab -- here on detecting error.  |
1465 `--------------------------------------*/
1466 yyerrlab:
1467   /* Make sure we have latest lookahead translation.  See comments at
1468      user semantic actions for why this is necessary.  */
1469   yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
1470   /* If not already recovering from an error, report this error.  */
1471   if (!yyerrstatus)
1472     {
1473       ++yynerrs;
1474       yyerror (config_ast, YY_("syntax error"));
1475     }
1476 
1477   if (yyerrstatus == 3)
1478     {
1479       /* If just tried and failed to reuse lookahead token after an
1480          error, discard it.  */
1481 
1482       if (yychar <= YYEOF)
1483         {
1484           /* Return failure if at end of input.  */
1485           if (yychar == YYEOF)
1486             YYABORT;
1487         }
1488       else
1489         {
1490           yydestruct ("Error: discarding",
1491                       yytoken, &yylval, config_ast);
1492           yychar = YYEMPTY;
1493         }
1494     }
1495 
1496   /* Else will try to reuse lookahead token after shifting the error
1497      token.  */
1498   goto yyerrlab1;
1499 
1500 
1501 /*---------------------------------------------------.
1502 | yyerrorlab -- error raised explicitly by YYERROR.  |
1503 `---------------------------------------------------*/
1504 yyerrorlab:
1505   /* Pacify compilers when the user code never invokes YYERROR and the
1506      label yyerrorlab therefore never appears in user code.  */
1507   if (0)
1508     YYERROR;
1509   ++yynerrs;
1510 
1511   /* Do not reclaim the symbols of the rule whose action triggered
1512      this YYERROR.  */
1513   YYPOPSTACK (yylen);
1514   yylen = 0;
1515   YY_STACK_PRINT (yyss, yyssp);
1516   yystate = *yyssp;
1517   goto yyerrlab1;
1518 
1519 
1520 /*-------------------------------------------------------------.
1521 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
1522 `-------------------------------------------------------------*/
1523 yyerrlab1:
1524   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
1525 
1526   /* Pop stack until we find a state that shifts the error token.  */
1527   for (;;)
1528     {
1529       yyn = yypact[yystate];
1530       if (!yypact_value_is_default (yyn))
1531         {
1532           yyn += YYSYMBOL_YYerror;
1533           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
1534             {
1535               yyn = yytable[yyn];
1536               if (0 < yyn)
1537                 break;
1538             }
1539         }
1540 
1541       /* Pop the current state because it cannot handle the error token.  */
1542       if (yyssp == yyss)
1543         YYABORT;
1544 
1545 
1546       yydestruct ("Error: popping",
1547                   YY_ACCESSING_SYMBOL (yystate), yyvsp, config_ast);
1548       YYPOPSTACK (1);
1549       yystate = *yyssp;
1550       YY_STACK_PRINT (yyss, yyssp);
1551     }
1552 
1553   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1554   *++yyvsp = yylval;
1555   YY_IGNORE_MAYBE_UNINITIALIZED_END
1556 
1557 
1558   /* Shift the error token.  */
1559   YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
1560 
1561   yystate = yyn;
1562   goto yynewstate;
1563 
1564 
1565 /*-------------------------------------.
1566 | yyacceptlab -- YYACCEPT comes here.  |
1567 `-------------------------------------*/
1568 yyacceptlab:
1569   yyresult = 0;
1570   goto yyreturnlab;
1571 
1572 
1573 /*-----------------------------------.
1574 | yyabortlab -- YYABORT comes here.  |
1575 `-----------------------------------*/
1576 yyabortlab:
1577   yyresult = 1;
1578   goto yyreturnlab;
1579 
1580 
1581 /*-----------------------------------------------------------.
1582 | yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here.  |
1583 `-----------------------------------------------------------*/
1584 yyexhaustedlab:
1585   yyerror (config_ast, YY_("memory exhausted"));
1586   yyresult = 2;
1587   goto yyreturnlab;
1588 
1589 
1590 /*----------------------------------------------------------.
1591 | yyreturnlab -- parsing is finished, clean up and return.  |
1592 `----------------------------------------------------------*/
1593 yyreturnlab:
1594   if (yychar != YYEMPTY)
1595     {
1596       /* Make sure we have latest lookahead translation.  See comments at
1597          user semantic actions for why this is necessary.  */
1598       yytoken = YYTRANSLATE (yychar);
1599       yydestruct ("Cleanup: discarding lookahead",
1600                   yytoken, &yylval, config_ast);
1601     }
1602   /* Do not reclaim the symbols of the rule whose action triggered
1603      this YYABORT or YYACCEPT.  */
1604   YYPOPSTACK (yylen);
1605   YY_STACK_PRINT (yyss, yyssp);
1606   while (yyssp != yyss)
1607     {
1608       yydestruct ("Cleanup: popping",
1609                   YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, config_ast);
1610       YYPOPSTACK (1);
1611     }
1612 #ifndef yyoverflow
1613   if (yyss != yyssa)
1614     YYSTACK_FREE (yyss);
1615 #endif
1616 
1617   return yyresult;
1618 }
1619 
1620 #line 170 "src/conf_yacc.y"
1621 
1622 
conferror(ast ** config_ast,const char * msg)1623 void conferror(
1624     ast** config_ast  __attribute__((unused)),
1625     const char *msg){
1626   log_msg(LOG_LEVEL_ERROR, "%s:%d: %s (line: '%s')", conf_filename, conf_linenumber, msg, conf_linebuf);
1627 }
1628