PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - ext/json - json_parser.tab.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 246 318 77.4 %
Date: 2019-05-06 Functions: 11 12 91.7 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10

Generated at Mon, 06 May 2019 17:58:16 +0000 (998 days ago)

Copyright © 2005-2022 The PHP Group
All rights reserved.