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