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