Coverage Report

Created: 2026-07-25 06:39

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