Coverage Report

Created: 2026-02-09 07:07

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