Coverage Report

Created: 2026-06-02 06:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/php-src/ext/json/json_parser.tab.c
Line
Count
Source
1
/* A Bison parser, made by GNU Bison 3.5.1.  */
2
3
/* Bison implementation for Yacc-like parsers in C
4
5
   Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
6
   Inc.
7
8
   This program is free software: you can redistribute it and/or modify
9
   it under the terms of the GNU General Public License as published by
10
   the Free Software Foundation, either version 3 of the License, or
11
   (at your option) any later version.
12
13
   This program is distributed in the hope that it will be useful,
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
   GNU General Public License for more details.
17
18
   You should have received a copy of the GNU General Public License
19
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20
21
/* As a special exception, you may create a larger work that contains
22
   part or all of the Bison parser skeleton and distribute that work
23
   under terms of your choice, so long as that work isn't itself a
24
   parser generator using the skeleton or a modified version thereof
25
   as a parser skeleton.  Alternatively, if you modify or redistribute
26
   the parser skeleton itself, you may (at your option) remove this
27
   special exception, which will cause the skeleton and the resulting
28
   Bison output files to be licensed under the GNU General Public
29
   License without this special exception.
30
31
   This special exception was added by the Free Software Foundation in
32
   version 2.2 of Bison.  */
33
34
/* C LALR(1) parser skeleton written by Richard Stallman, by
35
   simplifying the original so-called "semantic" parser.  */
36
37
/* All symbols defined below should begin with yy or YY, to avoid
38
   infringing on user name space.  This should be done even for local
39
   variables, as they might otherwise be expanded by user macros.
40
   There are some unavoidable exceptions within include files to
41
   define necessary library symbols; they are noted "INFRINGES ON
42
   USER NAME SPACE" below.  */
43
44
/* Undocumented macros, especially those whose name start with YY_,
45
   are private implementation details.  Do not rely on them.  */
46
47
/* Identify Bison output.  */
48
#define YYBISON 1
49
50
/* Bison version.  */
51
#define YYBISON_VERSION "3.5.1"
52
53
/* Skeleton name.  */
54
#define YYSKELETON_NAME "yacc.c"
55
56
/* Pure parsers.  */
57
#define YYPURE 2
58
59
/* Push parsers.  */
60
#define YYPUSH 0
61
62
/* Pull parsers.  */
63
#define YYPULL 1
64
65
/* "%code top" blocks.  */
66
67
/*
68
  +----------------------------------------------------------------------+
69
  | Copyright © The PHP Group and Contributors.                          |
70
  +----------------------------------------------------------------------+
71
  | This source file is subject to the Modified BSD License that is      |
72
  | bundled with this package in the file LICENSE, and is available      |
73
  | through the World Wide Web at <https://www.php.net/license/>.        |
74
  |                                                                      |
75
  | SPDX-License-Identifier: BSD-3-Clause                                |
76
  +----------------------------------------------------------------------+
77
  | Author: Jakub Zelenka <bukka@php.net>                                |
78
  +----------------------------------------------------------------------+
79
*/
80
81
#include "php.h"
82
#include "php_json.h"
83
#include "php_json_parser.h"
84
85
#define YYDEBUG 0
86
87
#if YYDEBUG
88
int json_yydebug = 1;
89
#endif
90
91
#ifdef _MSC_VER
92
#define YYMALLOC malloc
93
#define YYFREE free
94
#endif
95
96
18
#define PHP_JSON_DEPTH_DEC --parser->depth
97
#define PHP_JSON_DEPTH_INC \
98
18
  if (parser->max_depth && parser->depth >= parser->max_depth) { \
99
0
    parser->scanner.errcode = PHP_JSON_ERROR_DEPTH; \
100
0
    YYERROR; \
101
0
  } \
102
18
  ++parser->depth
103
104
105
/* Substitute the type names.  */
106
90
#define YYSTYPE         PHP_JSON_YYSTYPE
107
108
#define YYLTYPE         PHP_JSON_YYLTYPE
108
/* Substitute the variable and function names.  */
109
#define yyparse         php_json_yyparse
110
132
#define yylex           php_json_yylex
111
0
#define yyerror         php_json_yyerror
112
#define yydebug         php_json_yydebug
113
18
#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
312
#   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
18
#  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
0
#  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
0
# 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
36
# 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
312
#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
312
#define YYFINAL  16
530
/* YYLAST -- Last index in YYTABLE.  */
531
378
#define YYLAST   26
532
533
/* YYNTOKENS -- Number of terminals.  */
534
162
#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
150
#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
150
  (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
312
#define YYPACT_NINF (-16)
619
620
#define yypact_value_is_default(Yyn) \
621
312
  ((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
318
#define YYEMPTY         (-2)
710
150
#define YYEOF           0
711
712
18
#define YYACCEPT        goto yyacceptlab
713
0
#define YYABORT         goto yyabortlab
714
0
#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
0
#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
180
    do                                                                  \
748
180
      if (N)                                                            \
749
180
        {                                                               \
750
162
          (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
751
162
          (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
752
162
          (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
753
162
          (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
754
162
        }                                                               \
755
180
      else                                                              \
756
180
        {                                                               \
757
18
          (Current).first_line   = (Current).last_line   =              \
758
18
            YYRHSLOC (Rhs, 0).last_line;                                \
759
18
          (Current).first_column = (Current).last_column =              \
760
18
            YYRHSLOC (Rhs, 0).last_column;                              \
761
18
        }                                                               \
762
180
    while (0)
763
#endif
764
765
684
#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
18
# 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
0
{
1199
0
  YYUSE (yyvaluep);
1200
0
  YYUSE (yylocationp);
1201
0
  YYUSE (parser);
1202
0
  if (!yymsg)
1203
0
    yymsg = "Deleting";
1204
0
  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1205
1206
0
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1207
0
  switch (yytype)
1208
0
    {
1209
0
    case 3: /* PHP_JSON_T_NUL  */
1210
0
            { zval_ptr_dtor_nogc(&((*yyvaluep).value)); }
1211
0
        break;
1212
1213
0
    case 4: /* PHP_JSON_T_TRUE  */
1214
0
            { zval_ptr_dtor_nogc(&((*yyvaluep).value)); }
1215
0
        break;
1216
1217
0
    case 5: /* PHP_JSON_T_FALSE  */
1218
0
            { zval_ptr_dtor_nogc(&((*yyvaluep).value)); }
1219
0
        break;
1220
1221
0
    case 6: /* PHP_JSON_T_INT  */
1222
0
            { zval_ptr_dtor_nogc(&((*yyvaluep).value)); }
1223
0
        break;
1224
1225
0
    case 7: /* PHP_JSON_T_DOUBLE  */
1226
0
            { zval_ptr_dtor_nogc(&((*yyvaluep).value)); }
1227
0
        break;
1228
1229
0
    case 8: /* PHP_JSON_T_STRING  */
1230
0
            { zval_ptr_dtor_nogc(&((*yyvaluep).value)); }
1231
0
        break;
1232
1233
0
    case 9: /* PHP_JSON_T_ESTRING  */
1234
0
            { zval_ptr_dtor_nogc(&((*yyvaluep).value)); }
1235
0
        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
0
    case 23: /* members  */
1246
0
            { zval_ptr_dtor_nogc(&((*yyvaluep).value)); }
1247
0
        break;
1248
1249
0
    case 24: /* member  */
1250
0
            { zval_ptr_dtor_nogc(&((*yyvaluep).value)); }
1251
0
        break;
1252
1253
0
    case 25: /* array  */
1254
0
            { zval_ptr_dtor_nogc(&((*yyvaluep).value)); }
1255
0
        break;
1256
1257
0
    case 28: /* elements  */
1258
0
            { zval_ptr_dtor_nogc(&((*yyvaluep).value)); }
1259
0
        break;
1260
1261
0
    case 29: /* element  */
1262
0
            { zval_ptr_dtor_nogc(&((*yyvaluep).value)); }
1263
0
        break;
1264
1265
0
    case 30: /* key  */
1266
0
            { zval_ptr_dtor_nogc(&((*yyvaluep).value)); }
1267
0
        break;
1268
1269
0
    case 31: /* value  */
1270
0
            { zval_ptr_dtor_nogc(&((*yyvaluep).value)); }
1271
0
        break;
1272
1273
0
      default:
1274
0
        break;
1275
0
    }
1276
0
  YY_IGNORE_MAYBE_UNINITIALIZED_END
1277
0
}
1278
1279
1280
1281
1282
/*----------.
1283
| yyparse.  |
1284
`----------*/
1285
1286
int
1287
yyparse (php_json_parser *parser)
1288
18
{
1289
/* The lookahead symbol.  */
1290
18
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
18
YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1297
18
YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1298
1299
/* Location data for the lookahead symbol.  */
1300
18
static YYLTYPE yyloc_default
1301
18
# if defined PHP_JSON_YYLTYPE_IS_TRIVIAL && PHP_JSON_YYLTYPE_IS_TRIVIAL
1302
18
  = { 1, 1, 1, 1 }
1303
18
# endif
1304
18
;
1305
18
YYLTYPE yylloc = yyloc_default;
1306
1307
    /* Number of syntax errors so far.  */
1308
18
    int yynerrs;
1309
1310
18
    yy_state_fast_t yystate;
1311
    /* Number of tokens to shift before error messages enabled.  */
1312
18
    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
18
    yy_state_t yyssa[YYINITDEPTH];
1324
18
    yy_state_t *yyss;
1325
18
    yy_state_t *yyssp;
1326
1327
    /* The semantic value stack.  */
1328
18
    YYSTYPE yyvsa[YYINITDEPTH];
1329
18
    YYSTYPE *yyvs;
1330
18
    YYSTYPE *yyvsp;
1331
1332
    /* The location stack.  */
1333
18
    YYLTYPE yylsa[YYINITDEPTH];
1334
18
    YYLTYPE *yyls;
1335
18
    YYLTYPE *yylsp;
1336
1337
    /* The locations where the error started and ended.  */
1338
18
    YYLTYPE yyerror_range[3];
1339
1340
18
    YYPTRDIFF_T yystacksize;
1341
1342
18
  int yyn;
1343
18
  int yyresult;
1344
  /* Lookahead token as an internal (translated) token number.  */
1345
18
  int yytoken = 0;
1346
  /* The variables used to return semantic value and location from the
1347
     action routines.  */
1348
18
  YYSTYPE yyval;
1349
18
  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
180
#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
18
  int yylen = 0;
1363
1364
18
  yyssp = yyss = yyssa;
1365
18
  yyvsp = yyvs = yyvsa;
1366
18
  yylsp = yyls = yylsa;
1367
18
  yystacksize = YYINITDEPTH;
1368
1369
18
  YYDPRINTF ((stderr, "Starting parse\n"));
1370
1371
18
  yystate = 0;
1372
18
  yyerrstatus = 0;
1373
18
  yynerrs = 0;
1374
18
  yychar = YYEMPTY; /* Cause a token to be read.  */
1375
18
  yylsp[0] = yylloc;
1376
18
  goto yysetstate;
1377
1378
1379
/*------------------------------------------------------------.
1380
| yynewstate -- push a new state, which is found in yystate.  |
1381
`------------------------------------------------------------*/
1382
294
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
294
  yyssp++;
1386
1387
1388
/*--------------------------------------------------------------------.
1389
| yysetstate -- set current state (the top of the stack) to yystate.  |
1390
`--------------------------------------------------------------------*/
1391
312
yysetstate:
1392
312
  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1393
312
  YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1394
312
  YY_IGNORE_USELESS_CAST_BEGIN
1395
312
  *yyssp = YY_CAST (yy_state_t, yystate);
1396
312
  YY_IGNORE_USELESS_CAST_END
1397
1398
312
  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
312
#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1465
1466
312
  if (yystate == YYFINAL)
1467
0
    YYACCEPT;
1468
1469
312
  goto yybackup;
1470
1471
1472
/*-----------.
1473
| yybackup.  |
1474
`-----------*/
1475
312
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
312
  yyn = yypact[yystate];
1481
312
  if (yypact_value_is_default (yyn))
1482
162
    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
150
  if (yychar == YYEMPTY)
1488
132
    {
1489
132
      YYDPRINTF ((stderr, "Reading a token: "));
1490
132
      yychar = yylex (&yylval, &yylloc, parser);
1491
132
    }
1492
1493
150
  if (yychar <= YYEOF)
1494
0
    {
1495
0
      yychar = yytoken = YYEOF;
1496
0
      YYDPRINTF ((stderr, "Now at end of input.\n"));
1497
0
    }
1498
150
  else
1499
150
    {
1500
150
      yytoken = YYTRANSLATE (yychar);
1501
150
      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1502
150
    }
1503
1504
  /* If the proper action on seeing token YYTOKEN is to reduce or to
1505
     detect an error, take that action.  */
1506
150
  yyn += yytoken;
1507
150
  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1508
18
    goto yydefault;
1509
132
  yyn = yytable[yyn];
1510
132
  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
132
  if (yyerrstatus)
1521
0
    yyerrstatus--;
1522
1523
  /* Shift the lookahead token.  */
1524
132
  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1525
132
  yystate = yyn;
1526
132
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1527
132
  *++yyvsp = yylval;
1528
132
  YY_IGNORE_MAYBE_UNINITIALIZED_END
1529
132
  *++yylsp = yylloc;
1530
1531
  /* Discard the shifted token.  */
1532
132
  yychar = YYEMPTY;
1533
132
  goto yynewstate;
1534
1535
1536
/*-----------------------------------------------------------.
1537
| yydefault -- do the default action for the current state.  |
1538
`-----------------------------------------------------------*/
1539
180
yydefault:
1540
180
  yyn = yydefact[yystate];
1541
180
  if (yyn == 0)
1542
0
    goto yyerrlab;
1543
180
  goto yyreduce;
1544
1545
1546
/*-----------------------------.
1547
| yyreduce -- do a reduction.  |
1548
`-----------------------------*/
1549
180
yyreduce:
1550
  /* yyn is the number of a rule to reduce with.  */
1551
180
  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
180
  yyval = yyvsp[1-yylen];
1562
1563
  /* Default location. */
1564
180
  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1565
180
  yyerror_range[1] = yyloc;
1566
180
  YY_REDUCE_PRINT (yyn);
1567
180
  switch (yyn)
1568
180
    {
1569
18
  case 2:
1570
18
                        {
1571
18
        ZVAL_COPY_VALUE(&(yyval.value), &(yyvsp[-1].value));
1572
18
        ZVAL_COPY_VALUE(parser->return_value, &(yyvsp[-1].value));
1573
18
        (void) php_json_yynerrs;
1574
18
        YYACCEPT;
1575
0
      }
1576
0
    break;
1577
1578
18
  case 3:
1579
18
                        {
1580
18
        PHP_JSON_DEPTH_INC;
1581
18
        if (parser->methods.object_start && FAILURE == parser->methods.object_start(parser)) {
1582
0
          YYERROR;
1583
0
        }
1584
18
      }
1585
18
    break;
1586
1587
18
  case 4:
1588
18
                        {
1589
18
        ZVAL_COPY_VALUE(&(yyval.value), &(yyvsp[-1].value));
1590
18
        PHP_JSON_DEPTH_DEC;
1591
18
        if (parser->methods.object_end && FAILURE == parser->methods.object_end(parser, &(yyval.value))) {
1592
0
          YYERROR;
1593
0
        }
1594
18
      }
1595
18
    break;
1596
1597
18
  case 6:
1598
0
                        {
1599
0
        parser->scanner.errcode = PHP_JSON_ERROR_STATE_MISMATCH;
1600
0
        YYERROR;
1601
18
      }
1602
0
    break;
1603
1604
0
  case 7:
1605
0
                        {
1606
0
        if ((parser->scanner.options & PHP_JSON_OBJECT_AS_ARRAY) && parser->methods.object_create == php_json_parser_object_create) {
1607
0
          ZVAL_EMPTY_ARRAY(&(yyval.value));
1608
0
        } else {
1609
0
          parser->methods.object_create(parser, &(yyval.value));
1610
0
        }
1611
0
      }
1612
0
    break;
1613
1614
18
  case 9:
1615
18
                        {
1616
18
        parser->methods.object_create(parser, &(yyval.value));
1617
18
        if (parser->methods.object_update(parser, &(yyval.value), Z_STR((yyvsp[-2].value)), &(yyvsp[0].value)) == FAILURE) {
1618
0
          YYERROR;
1619
0
        }
1620
18
      }
1621
18
    break;
1622
1623
18
  case 10:
1624
6
                        {
1625
6
        if (parser->methods.object_update(parser, &(yyvsp[-4].value), Z_STR((yyvsp[-2].value)), &(yyvsp[0].value)) == FAILURE) {
1626
0
          YYERROR;
1627
0
        }
1628
6
        ZVAL_COPY_VALUE(&(yyval.value), &(yyvsp[-4].value));
1629
6
      }
1630
0
    break;
1631
1632
0
  case 11:
1633
0
                        {
1634
0
        PHP_JSON_DEPTH_INC;
1635
0
        if (parser->methods.array_start && FAILURE == parser->methods.array_start(parser)) {
1636
0
          YYERROR;
1637
0
        }
1638
0
      }
1639
0
    break;
1640
1641
0
  case 12:
1642
0
                        {
1643
0
        ZVAL_COPY_VALUE(&(yyval.value), &(yyvsp[-1].value));
1644
0
        PHP_JSON_DEPTH_DEC;
1645
0
        if (parser->methods.array_end && FAILURE == parser->methods.array_end(parser, &(yyval.value))) {
1646
0
          YYERROR;
1647
0
        }
1648
0
      }
1649
0
    break;
1650
1651
0
  case 14:
1652
0
                        {
1653
0
        parser->scanner.errcode = PHP_JSON_ERROR_STATE_MISMATCH;
1654
0
        YYERROR;
1655
0
      }
1656
0
    break;
1657
1658
0
  case 15:
1659
0
                        {
1660
0
        if (parser->methods.array_create == php_json_parser_array_create) {
1661
0
          ZVAL_EMPTY_ARRAY(&(yyval.value));
1662
0
        } else {
1663
0
          parser->methods.array_create(parser, &(yyval.value));
1664
0
        }
1665
0
      }
1666
0
    break;
1667
1668
0
  case 17:
1669
0
                        {
1670
0
        parser->methods.array_create(parser, &(yyval.value));
1671
0
        parser->methods.array_append(parser, &(yyval.value), &(yyvsp[0].value));
1672
0
      }
1673
0
    break;
1674
1675
0
  case 18:
1676
0
                        {
1677
0
        parser->methods.array_append(parser, &(yyvsp[-2].value), &(yyvsp[0].value));
1678
0
        ZVAL_COPY_VALUE(&(yyval.value), &(yyvsp[-2].value));
1679
0
      }
1680
0
    break;
1681
1682
1683
1684
102
      default: break;
1685
180
    }
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
162
  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1698
1699
162
  YYPOPSTACK (yylen);
1700
162
  yylen = 0;
1701
162
  YY_STACK_PRINT (yyss, yyssp);
1702
1703
162
  *++yyvsp = yyval;
1704
162
  *++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
162
  {
1710
162
    const int yylhs = yyr1[yyn] - YYNTOKENS;
1711
162
    const int yyi = yypgoto[yylhs] + *yyssp;
1712
162
    yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1713
162
               ? yytable[yyi]
1714
162
               : yydefgoto[yylhs]);
1715
162
  }
1716
1717
162
  goto yynewstate;
1718
1719
1720
/*--------------------------------------.
1721
| yyerrlab -- here on detecting error.  |
1722
`--------------------------------------*/
1723
0
yyerrlab:
1724
  /* Make sure we have latest lookahead translation.  See comments at
1725
     user semantic actions for why this is necessary.  */
1726
0
  yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1727
1728
  /* If not already recovering from an error, report this error.  */
1729
0
  if (!yyerrstatus)
1730
0
    {
1731
0
      ++yynerrs;
1732
0
#if ! YYERROR_VERBOSE
1733
0
      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
0
    }
1767
1768
0
  yyerror_range[1] = yylloc;
1769
1770
0
  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
0
  goto yyerrlab1;
1792
1793
1794
/*---------------------------------------------------.
1795
| yyerrorlab -- error raised explicitly by YYERROR.  |
1796
`---------------------------------------------------*/
1797
0
yyerrorlab:
1798
  /* Pacify compilers when the user code never invokes YYERROR and the
1799
     label yyerrorlab therefore never appears in user code.  */
1800
0
  if (0)
1801
0
    YYERROR;
1802
1803
  /* Do not reclaim the symbols of the rule whose action triggered
1804
     this YYERROR.  */
1805
0
  YYPOPSTACK (yylen);
1806
0
  yylen = 0;
1807
0
  YY_STACK_PRINT (yyss, yyssp);
1808
0
  yystate = *yyssp;
1809
0
  goto yyerrlab1;
1810
1811
1812
/*-------------------------------------------------------------.
1813
| yyerrlab1 -- common code for both syntax error and YYERROR.  |
1814
`-------------------------------------------------------------*/
1815
0
yyerrlab1:
1816
0
  yyerrstatus = 3;      /* Each real token shifted decrements this.  */
1817
1818
0
  for (;;)
1819
0
    {
1820
0
      yyn = yypact[yystate];
1821
0
      if (!yypact_value_is_default (yyn))
1822
0
        {
1823
0
          yyn += YYTERROR;
1824
0
          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
0
        }
1831
1832
      /* Pop the current state because it cannot handle the error token.  */
1833
0
      if (yyssp == yyss)
1834
0
        YYABORT;
1835
1836
0
      yyerror_range[1] = *yylsp;
1837
0
      yydestruct ("Error: popping",
1838
0
                  yystos[yystate], yyvsp, yylsp, parser);
1839
0
      YYPOPSTACK (1);
1840
0
      yystate = *yyssp;
1841
0
      YY_STACK_PRINT (yyss, yyssp);
1842
0
    }
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
18
yyacceptlab:
1865
18
  yyresult = 0;
1866
18
  goto yyreturn;
1867
1868
1869
/*-----------------------------------.
1870
| yyabortlab -- YYABORT comes here.  |
1871
`-----------------------------------*/
1872
0
yyabortlab:
1873
0
  yyresult = 1;
1874
0
  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
18
yyreturn:
1892
18
  if (yychar != YYEMPTY)
1893
0
    {
1894
      /* Make sure we have latest lookahead translation.  See comments at
1895
         user semantic actions for why this is necessary.  */
1896
0
      yytoken = YYTRANSLATE (yychar);
1897
0
      yydestruct ("Cleanup: discarding lookahead",
1898
0
                  yytoken, &yylval, &yylloc, parser);
1899
0
    }
1900
  /* Do not reclaim the symbols of the rule whose action triggered
1901
     this YYABORT or YYACCEPT.  */
1902
18
  YYPOPSTACK (yylen);
1903
18
  YY_STACK_PRINT (yyss, yyssp);
1904
18
  while (yyssp != yyss)
1905
0
    {
1906
0
      yydestruct ("Cleanup: popping",
1907
0
                  yystos[+*yyssp], yyvsp, yylsp, parser);
1908
0
      YYPOPSTACK (1);
1909
0
    }
1910
18
#ifndef yyoverflow
1911
18
  if (yyss != yyssa)
1912
0
    YYSTACK_FREE (yyss);
1913
18
#endif
1914
#if YYERROR_VERBOSE
1915
  if (yymsg != yymsgbuf)
1916
    YYSTACK_FREE (yymsg);
1917
#endif
1918
18
  return yyresult;
1919
0
}
1920
 /* Functions */
1921
1922
static int php_json_parser_array_create(php_json_parser *parser, zval *array)
1923
0
{
1924
0
  array_init(array);
1925
0
  return SUCCESS;
1926
0
}
1927
1928
static int php_json_parser_array_append(php_json_parser *parser, zval *array, zval *zvalue)
1929
0
{
1930
0
  zend_hash_next_index_insert(Z_ARRVAL_P(array), zvalue);
1931
0
  return SUCCESS;
1932
0
}
1933
1934
static int php_json_parser_object_create(php_json_parser *parser, zval *object)
1935
18
{
1936
18
  if (parser->scanner.options & PHP_JSON_OBJECT_AS_ARRAY) {
1937
0
    array_init(object);
1938
18
  } else {
1939
18
    object_init(object);
1940
18
  }
1941
18
  return SUCCESS;
1942
18
}
1943
1944
static int php_json_parser_object_update(php_json_parser *parser, zval *object, zend_string *key, zval *zvalue)
1945
24
{
1946
  /* if JSON_OBJECT_AS_ARRAY is set */
1947
24
  if (Z_TYPE_P(object) == IS_ARRAY) {
1948
0
    zend_symtable_update(Z_ARRVAL_P(object), key, zvalue);
1949
24
  } else {
1950
24
    if (ZSTR_LEN(key) > 0 && ZSTR_VAL(key)[0] == '\0') {
1951
0
      parser->scanner.errcode = PHP_JSON_ERROR_INVALID_PROPERTY_NAME;
1952
0
      zend_string_release_ex(key, 0);
1953
0
      zval_ptr_dtor_nogc(zvalue);
1954
0
      zval_ptr_dtor_nogc(object);
1955
0
      return FAILURE;
1956
0
    }
1957
24
    zend_std_write_property(Z_OBJ_P(object), key, zvalue, NULL);
1958
24
    Z_TRY_DELREF_P(zvalue);
1959
24
  }
1960
24
  zend_string_release_ex(key, 0);
1961
1962
24
  return SUCCESS;
1963
24
}
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
132
{
1989
132
  int token = php_json_scan(&parser->scanner);
1990
1991
132
  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
132
  if (validate) {
1997
0
    zval_ptr_dtor_str(&(parser->scanner.value));
1998
0
    ZVAL_UNDEF(&value->value);
1999
132
  } else {
2000
132
    value->value = parser->scanner.value;
2001
132
  }
2002
2003
132
  location->first_column = PHP_JSON_SCANNER_LOCATION(parser->scanner, first_column);
2004
132
  location->first_line = PHP_JSON_SCANNER_LOCATION(parser->scanner, first_line);
2005
132
  location->last_column = PHP_JSON_SCANNER_LOCATION(parser->scanner, last_column);
2006
132
  location->last_line = PHP_JSON_SCANNER_LOCATION(parser->scanner, last_line);
2007
2008
132
  return token;
2009
132
}
2010
2011
static void php_json_yyerror(YYLTYPE *location, php_json_parser *parser, char const *msg)
2012
0
{
2013
0
  if (!parser->scanner.errcode) {
2014
0
    parser->scanner.errcode = PHP_JSON_ERROR_SYNTAX;
2015
0
  }
2016
0
}
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
18
{
2065
18
  memset(parser, 0, sizeof(php_json_parser));
2066
18
  php_json_scanner_init(&parser->scanner, str, str_len, options);
2067
18
  parser->depth = 1;
2068
18
  parser->max_depth = max_depth;
2069
18
  parser->return_value = return_value;
2070
18
  memcpy(&parser->methods, parser_methods, sizeof(php_json_parser_methods));
2071
18
}
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
18
{
2080
18
  php_json_parser_init_ex(
2081
18
      parser,
2082
18
      return_value,
2083
18
      str,
2084
18
      str_len,
2085
18
      options,
2086
18
      max_depth,
2087
18
      &default_parser_methods);
2088
18
}
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
}