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