Coverage Report

Created: 2026-06-02 06:36

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