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