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