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