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