xref: /xnu-10002.1.13/iokit/System/OSUnserializeXMLSharedImplementation.h (revision 1031c584a5e37aff177559b9f69dbd3c8c3fd30a)
1*1031c584SApple OSS Distributions /*
2*1031c584SApple OSS Distributions  * Copyright (c) 1999-2019 Apple Inc. All rights reserved.
3*1031c584SApple OSS Distributions  *
4*1031c584SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*1031c584SApple OSS Distributions  *
6*1031c584SApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*1031c584SApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*1031c584SApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*1031c584SApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*1031c584SApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*1031c584SApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*1031c584SApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*1031c584SApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*1031c584SApple OSS Distributions  *
15*1031c584SApple OSS Distributions  * Please obtain a copy of the License at
16*1031c584SApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*1031c584SApple OSS Distributions  *
18*1031c584SApple OSS Distributions  * The Original Code and all software distributed under the License are
19*1031c584SApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*1031c584SApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*1031c584SApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*1031c584SApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*1031c584SApple OSS Distributions  * Please see the License for the specific language governing rights and
24*1031c584SApple OSS Distributions  * limitations under the License.
25*1031c584SApple OSS Distributions  *
26*1031c584SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*1031c584SApple OSS Distributions  */
28*1031c584SApple OSS Distributions 
29*1031c584SApple OSS Distributions /*
30*1031c584SApple OSS Distributions  * HISTORY
31*1031c584SApple OSS Distributions  *
32*1031c584SApple OSS Distributions  * OSUnserializeXML.y created by rsulack on Tue Oct 12 1999
33*1031c584SApple OSS Distributions  */
34*1031c584SApple OSS Distributions 
35*1031c584SApple OSS Distributions // parser for unserializing OSContainer objects serialized to XML
36*1031c584SApple OSS Distributions //
37*1031c584SApple OSS Distributions // to build :
38*1031c584SApple OSS Distributions //	bison -p OSUnserializeXML OSUnserializeXML.y
39*1031c584SApple OSS Distributions //	head -50 OSUnserializeXML.y > ../libkern/c++/OSUnserializeXMLSharedImplementation.h
40*1031c584SApple OSS Distributions //	sed -e "s/#include <stdio.h>//" < OSUnserializeXML.tab.c >> ../libkern/c++/OSUnserializeXMLSharedImplementation.h
41*1031c584SApple OSS Distributions //
42*1031c584SApple OSS Distributions //	when changing code check in both OSUnserializeXML.y and OSUnserializeXMLSharedImplementation.h
43*1031c584SApple OSS Distributions //
44*1031c584SApple OSS Distributions //
45*1031c584SApple OSS Distributions //
46*1031c584SApple OSS Distributions //
47*1031c584SApple OSS Distributions //
48*1031c584SApple OSS Distributions //		 DO NOT EDIT OSUnserializeXMLSharedImplementation.h!
49*1031c584SApple OSS Distributions //
50*1031c584SApple OSS Distributions //			this means you!
51*1031c584SApple OSS Distributions /* A Bison parser, made by GNU Bison 2.3.  */
52*1031c584SApple OSS Distributions 
53*1031c584SApple OSS Distributions /* Skeleton implementation for Bison's Yacc-like parsers in C
54*1031c584SApple OSS Distributions  *
55*1031c584SApple OSS Distributions  *  Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
56*1031c584SApple OSS Distributions  *  Free Software Foundation, Inc.
57*1031c584SApple OSS Distributions  *
58*1031c584SApple OSS Distributions  *  This program is free software; you can redistribute it and/or modify
59*1031c584SApple OSS Distributions  *  it under the terms of the GNU General Public License as published by
60*1031c584SApple OSS Distributions  *  the Free Software Foundation; either version 2, or (at your option)
61*1031c584SApple OSS Distributions  *  any later version.
62*1031c584SApple OSS Distributions  *
63*1031c584SApple OSS Distributions  *  This program is distributed in the hope that it will be useful,
64*1031c584SApple OSS Distributions  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
65*1031c584SApple OSS Distributions  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
66*1031c584SApple OSS Distributions  *  GNU General Public License for more details.
67*1031c584SApple OSS Distributions  *
68*1031c584SApple OSS Distributions  *  You should have received a copy of the GNU General Public License
69*1031c584SApple OSS Distributions  *  along with this program; if not, write to the Free Software
70*1031c584SApple OSS Distributions  *  Foundation, Inc., 51 Franklin Street, Fifth Floor,
71*1031c584SApple OSS Distributions  *  Boston, MA 02110-1301, USA.  */
72*1031c584SApple OSS Distributions 
73*1031c584SApple OSS Distributions /* As a special exception, you may create a larger work that contains
74*1031c584SApple OSS Distributions  *  part or all of the Bison parser skeleton and distribute that work
75*1031c584SApple OSS Distributions  *  under terms of your choice, so long as that work isn't itself a
76*1031c584SApple OSS Distributions  *  parser generator using the skeleton or a modified version thereof
77*1031c584SApple OSS Distributions  *  as a parser skeleton.  Alternatively, if you modify or redistribute
78*1031c584SApple OSS Distributions  *  the parser skeleton itself, you may (at your option) remove this
79*1031c584SApple OSS Distributions  *  special exception, which will cause the skeleton and the resulting
80*1031c584SApple OSS Distributions  *  Bison output files to be licensed under the GNU General Public
81*1031c584SApple OSS Distributions  *  License without this special exception.
82*1031c584SApple OSS Distributions  *
83*1031c584SApple OSS Distributions  *  This special exception was added by the Free Software Foundation in
84*1031c584SApple OSS Distributions  *  version 2.2 of Bison.  */
85*1031c584SApple OSS Distributions 
86*1031c584SApple OSS Distributions /* C LALR(1) parser skeleton written by Richard Stallman, by
87*1031c584SApple OSS Distributions *  simplifying the original so-called "semantic" parser.  */
88*1031c584SApple OSS Distributions 
89*1031c584SApple OSS Distributions /* All symbols defined below should begin with yy or YY, to avoid
90*1031c584SApple OSS Distributions  *  infringing on user name space.  This should be done even for local
91*1031c584SApple OSS Distributions  *  variables, as they might otherwise be expanded by user macros.
92*1031c584SApple OSS Distributions  *  There are some unavoidable exceptions within include files to
93*1031c584SApple OSS Distributions  *  define necessary library symbols; they are noted "INFRINGES ON
94*1031c584SApple OSS Distributions  *  USER NAME SPACE" below.  */
95*1031c584SApple OSS Distributions 
96*1031c584SApple OSS Distributions /* Identify Bison output.  */
97*1031c584SApple OSS Distributions #define YYBISON 1
98*1031c584SApple OSS Distributions 
99*1031c584SApple OSS Distributions /* Bison version.  */
100*1031c584SApple OSS Distributions #define YYBISON_VERSION "2.3"
101*1031c584SApple OSS Distributions 
102*1031c584SApple OSS Distributions /* Skeleton name.  */
103*1031c584SApple OSS Distributions #define YYSKELETON_NAME "yacc.c"
104*1031c584SApple OSS Distributions 
105*1031c584SApple OSS Distributions /* Pure parsers.  */
106*1031c584SApple OSS Distributions #define YYPURE 1
107*1031c584SApple OSS Distributions 
108*1031c584SApple OSS Distributions /* Using locations.  */
109*1031c584SApple OSS Distributions #define YYLSP_NEEDED 0
110*1031c584SApple OSS Distributions 
111*1031c584SApple OSS Distributions /* Substitute the variable and function names.  */
112*1031c584SApple OSS Distributions #define yyparse OSUnserializeXMLparse
113*1031c584SApple OSS Distributions #define yylex   OSUnserializeXMLlex
114*1031c584SApple OSS Distributions #define yyerror OSUnserializeXMLerror
115*1031c584SApple OSS Distributions #define yylval  OSUnserializeXMLlval
116*1031c584SApple OSS Distributions #define yychar  OSUnserializeXMLchar
117*1031c584SApple OSS Distributions #define yydebug OSUnserializeXMLdebug
118*1031c584SApple OSS Distributions #define yynerrs OSUnserializeXMLnerrs
119*1031c584SApple OSS Distributions 
120*1031c584SApple OSS Distributions 
121*1031c584SApple OSS Distributions /* Tokens.  */
122*1031c584SApple OSS Distributions #ifndef YYTOKENTYPE
123*1031c584SApple OSS Distributions # define YYTOKENTYPE
124*1031c584SApple OSS Distributions /* Put the tokens into the symbol table, so that GDB and other debuggers
125*1031c584SApple OSS Distributions  *  know about them.  */
126*1031c584SApple OSS Distributions enum yytokentype {
127*1031c584SApple OSS Distributions 	ARRAY = 258,
128*1031c584SApple OSS Distributions 	BOOLEAN = 259,
129*1031c584SApple OSS Distributions 	DATA = 260,
130*1031c584SApple OSS Distributions 	DICTIONARY = 261,
131*1031c584SApple OSS Distributions 	IDREF = 262,
132*1031c584SApple OSS Distributions 	KEY = 263,
133*1031c584SApple OSS Distributions 	NUMBER = 264,
134*1031c584SApple OSS Distributions 	SET = 265,
135*1031c584SApple OSS Distributions 	STRING = 266,
136*1031c584SApple OSS Distributions 	SYNTAX_ERROR = 267
137*1031c584SApple OSS Distributions };
138*1031c584SApple OSS Distributions #endif
139*1031c584SApple OSS Distributions /* Tokens.  */
140*1031c584SApple OSS Distributions #define ARRAY 258
141*1031c584SApple OSS Distributions #define BOOLEAN 259
142*1031c584SApple OSS Distributions #define DATA 260
143*1031c584SApple OSS Distributions #define DICTIONARY 261
144*1031c584SApple OSS Distributions #define IDREF 262
145*1031c584SApple OSS Distributions #define KEY 263
146*1031c584SApple OSS Distributions #define NUMBER 264
147*1031c584SApple OSS Distributions #define SET 265
148*1031c584SApple OSS Distributions #define STRING 266
149*1031c584SApple OSS Distributions #define SYNTAX_ERROR 267
150*1031c584SApple OSS Distributions 
151*1031c584SApple OSS Distributions 
152*1031c584SApple OSS Distributions 
153*1031c584SApple OSS Distributions 
154*1031c584SApple OSS Distributions /* Copy the first part of user declarations.  */
155*1031c584SApple OSS Distributions #line 61 "OSUnserializeXML.y"
156*1031c584SApple OSS Distributions 
157*1031c584SApple OSS Distributions #include <string.h>
158*1031c584SApple OSS Distributions #if KERNEL
159*1031c584SApple OSS Distributions #include <libkern/c++/OSMetaClass.h>
160*1031c584SApple OSS Distributions #include <libkern/c++/OSContainers.h>
161*1031c584SApple OSS Distributions #include <libkern/c++/OSLib.h>
162*1031c584SApple OSS Distributions #else /* !KERNEL */
163*1031c584SApple OSS Distributions #include <DriverKit/DriverKit.h>
164*1031c584SApple OSS Distributions #endif /* KERNEL */
165*1031c584SApple OSS Distributions 
166*1031c584SApple OSS Distributions 
167*1031c584SApple OSS Distributions #define MAX_OBJECTS              131071
168*1031c584SApple OSS Distributions #define MAX_REFED_OBJECTS        65535
169*1031c584SApple OSS Distributions 
170*1031c584SApple OSS Distributions #define YYSTYPE object_t *
171*1031c584SApple OSS Distributions #define YYPARSE_PARAM   state
172*1031c584SApple OSS Distributions #define YYLEX_PARAM     (parser_state_t *)state
173*1031c584SApple OSS Distributions 
174*1031c584SApple OSS Distributions // this is the internal struct used to hold objects on parser stack
175*1031c584SApple OSS Distributions // it represents objects both before and after they have been created
176*1031c584SApple OSS Distributions typedef struct object {
177*1031c584SApple OSS Distributions 	struct object   *next;
178*1031c584SApple OSS Distributions 	struct object   *free;
179*1031c584SApple OSS Distributions 	struct object   *elements;
180*1031c584SApple OSS Distributions 	OSObject        *object;
181*1031c584SApple OSS Distributions 	OSSymbol        *key;                   // for dictionary
182*1031c584SApple OSS Distributions 	int             size;
183*1031c584SApple OSS Distributions 	void            *data;                  // for data
184*1031c584SApple OSS Distributions 	char            *string;                // for string & symbol
185*1031c584SApple OSS Distributions 	int             string_alloc_length;
186*1031c584SApple OSS Distributions 	long long       number;                 // for number
187*1031c584SApple OSS Distributions 	int             idref;
188*1031c584SApple OSS Distributions } object_t;
189*1031c584SApple OSS Distributions 
190*1031c584SApple OSS Distributions // this code is reentrant, this structure contains all
191*1031c584SApple OSS Distributions // state information for the parsing of a single buffer
192*1031c584SApple OSS Distributions typedef struct parser_state {
193*1031c584SApple OSS Distributions 	const char      *parseBuffer;           // start of text to be parsed
194*1031c584SApple OSS Distributions 	int             parseBufferIndex;       // current index into text
195*1031c584SApple OSS Distributions 	int             lineNumber;             // current line number
196*1031c584SApple OSS Distributions 	object_t        *objects;               // internal objects in use
197*1031c584SApple OSS Distributions 	object_t        *freeObjects;           // internal objects that are free
198*1031c584SApple OSS Distributions 	OSDictionary    *tags;                  // used to remember "ID" tags
199*1031c584SApple OSS Distributions 	OSString        **errorString;          // parse error with line
200*1031c584SApple OSS Distributions 	OSObject        *parsedObject;          // resultant object of parsed text
201*1031c584SApple OSS Distributions 	int             parsedObjectCount;
202*1031c584SApple OSS Distributions 	int             retrievedObjectCount;
203*1031c584SApple OSS Distributions } parser_state_t;
204*1031c584SApple OSS Distributions 
205*1031c584SApple OSS Distributions #define STATE           ((parser_state_t *)state)
206*1031c584SApple OSS Distributions 
207*1031c584SApple OSS Distributions #undef yyerror
208*1031c584SApple OSS Distributions #define yyerror(s)      OSUnserializeerror(STATE, (s))
209*1031c584SApple OSS Distributions static int              OSUnserializeerror(parser_state_t *state, const char *s);
210*1031c584SApple OSS Distributions 
211*1031c584SApple OSS Distributions static int              yylex(YYSTYPE *lvalp, parser_state_t *state);
212*1031c584SApple OSS Distributions 
213*1031c584SApple OSS Distributions static object_t         *newObject(parser_state_t *state);
214*1031c584SApple OSS Distributions static void             freeObject(parser_state_t *state, object_t *o);
215*1031c584SApple OSS Distributions static void             rememberObject(parser_state_t *state, int tag, OSObject *o);
216*1031c584SApple OSS Distributions static object_t         *retrieveObject(parser_state_t *state, int tag);
217*1031c584SApple OSS Distributions static void             cleanupObjects(parser_state_t *state);
218*1031c584SApple OSS Distributions 
219*1031c584SApple OSS Distributions static object_t         *buildDictionary(parser_state_t *state, object_t *o);
220*1031c584SApple OSS Distributions static object_t         *buildArray(parser_state_t *state, object_t *o);
221*1031c584SApple OSS Distributions static object_t         *buildSet(parser_state_t *state, object_t *o);
222*1031c584SApple OSS Distributions static object_t         *buildString(parser_state_t *state, object_t *o);
223*1031c584SApple OSS Distributions static object_t         *buildSymbol(parser_state_t *state, object_t *o);
224*1031c584SApple OSS Distributions static object_t         *buildData(parser_state_t *state, object_t *o);
225*1031c584SApple OSS Distributions static object_t         *buildNumber(parser_state_t *state, object_t *o);
226*1031c584SApple OSS Distributions static object_t         *buildBoolean(parser_state_t *state, object_t *o);
227*1031c584SApple OSS Distributions 
228*1031c584SApple OSS Distributions #if KERNEL
229*1031c584SApple OSS Distributions __BEGIN_DECLS
230*1031c584SApple OSS Distributions #include <kern/kalloc.h>
231*1031c584SApple OSS Distributions __END_DECLS
232*1031c584SApple OSS Distributions 
233*1031c584SApple OSS Distributions #define malloc(size)         malloc_impl(size)
234*1031c584SApple OSS Distributions #define malloc_type(type)    kalloc_type(type, Z_SET_NOTSHARED)
235*1031c584SApple OSS Distributions static inline void *
malloc_impl(size_t size)236*1031c584SApple OSS Distributions malloc_impl(size_t size)
237*1031c584SApple OSS Distributions {
238*1031c584SApple OSS Distributions 	if (size == 0) {
239*1031c584SApple OSS Distributions 		return NULL;
240*1031c584SApple OSS Distributions 	}
241*1031c584SApple OSS Distributions 	return kalloc_data(size,
242*1031c584SApple OSS Distributions 	           Z_VM_TAG_BT(Z_WAITOK_ZERO, VM_KERN_MEMORY_LIBKERN));
243*1031c584SApple OSS Distributions }
244*1031c584SApple OSS Distributions 
245*1031c584SApple OSS Distributions #define free(addr)             free_impl(addr)
246*1031c584SApple OSS Distributions #define free_type(type, addr)  kfree_type(type, addr)
247*1031c584SApple OSS Distributions static inline void
free_impl(void * addr)248*1031c584SApple OSS Distributions free_impl(void *addr)
249*1031c584SApple OSS Distributions {
250*1031c584SApple OSS Distributions 	kfree_data_addr(addr);
251*1031c584SApple OSS Distributions }
252*1031c584SApple OSS Distributions static inline void
safe_free(void * addr,size_t size)253*1031c584SApple OSS Distributions safe_free(void *addr, size_t size)
254*1031c584SApple OSS Distributions {
255*1031c584SApple OSS Distributions 	kfree_data(addr, size);
256*1031c584SApple OSS Distributions }
257*1031c584SApple OSS Distributions 
258*1031c584SApple OSS Distributions #define realloc(addr, osize, nsize) realloc_impl(addr, osize, nsize)
259*1031c584SApple OSS Distributions static inline void *
realloc_impl(void * addr,size_t osize,size_t nsize)260*1031c584SApple OSS Distributions realloc_impl(void *addr, size_t osize, size_t nsize)
261*1031c584SApple OSS Distributions {
262*1031c584SApple OSS Distributions 	return krealloc_data(addr, osize, nsize,
263*1031c584SApple OSS Distributions 	           Z_VM_TAG_BT(Z_WAITOK_ZERO, VM_KERN_MEMORY_LIBKERN));
264*1031c584SApple OSS Distributions }
265*1031c584SApple OSS Distributions #else /* !KERNEL */
266*1031c584SApple OSS Distributions #define malloc(size)      malloc_impl(size)
267*1031c584SApple OSS Distributions #define malloc_type(type) (type *) calloc(1, sizeof(type))
268*1031c584SApple OSS Distributions static inline void *
malloc_impl(size_t size)269*1031c584SApple OSS Distributions malloc_impl(size_t size)
270*1031c584SApple OSS Distributions {
271*1031c584SApple OSS Distributions 	if (size == 0) {
272*1031c584SApple OSS Distributions 		return NULL;
273*1031c584SApple OSS Distributions 	}
274*1031c584SApple OSS Distributions 	return calloc(1, size);
275*1031c584SApple OSS Distributions }
276*1031c584SApple OSS Distributions #define safe_free(addr, size)       free(addr)
277*1031c584SApple OSS Distributions #define free_type(type, addr)       safe_free(addr, sizeof(type))
278*1031c584SApple OSS Distributions #define realloc(addr, osize, nsize) realloc_impl(addr, osize, nsize)
279*1031c584SApple OSS Distributions static inline void *
realloc_impl(void * addr,size_t osize,size_t nsize)280*1031c584SApple OSS Distributions realloc_impl(void *addr, size_t osize, size_t nsize)
281*1031c584SApple OSS Distributions {
282*1031c584SApple OSS Distributions 	void * nmem;
283*1031c584SApple OSS Distributions 
284*1031c584SApple OSS Distributions 	if (!addr) {
285*1031c584SApple OSS Distributions 		return malloc(nsize);
286*1031c584SApple OSS Distributions 	}
287*1031c584SApple OSS Distributions 	if (nsize == osize) {
288*1031c584SApple OSS Distributions 		return addr;
289*1031c584SApple OSS Distributions 	}
290*1031c584SApple OSS Distributions 	nmem = (realloc)(addr, nsize);
291*1031c584SApple OSS Distributions 	if (nmem && nsize > osize) {
292*1031c584SApple OSS Distributions 		bzero((uint8_t *)nmem + osize, nsize - osize);
293*1031c584SApple OSS Distributions 	}
294*1031c584SApple OSS Distributions 
295*1031c584SApple OSS Distributions 	return nmem;
296*1031c584SApple OSS Distributions }
297*1031c584SApple OSS Distributions #endif /* KERNEL */
298*1031c584SApple OSS Distributions 
299*1031c584SApple OSS Distributions 
300*1031c584SApple OSS Distributions 
301*1031c584SApple OSS Distributions /* Enabling traces.  */
302*1031c584SApple OSS Distributions #ifndef YYDEBUG
303*1031c584SApple OSS Distributions # define YYDEBUG 0
304*1031c584SApple OSS Distributions #endif
305*1031c584SApple OSS Distributions 
306*1031c584SApple OSS Distributions /* Enabling verbose error messages.  */
307*1031c584SApple OSS Distributions #ifdef YYERROR_VERBOSE
308*1031c584SApple OSS Distributions # undef YYERROR_VERBOSE
309*1031c584SApple OSS Distributions # define YYERROR_VERBOSE 1
310*1031c584SApple OSS Distributions #else
311*1031c584SApple OSS Distributions # define YYERROR_VERBOSE 0
312*1031c584SApple OSS Distributions #endif
313*1031c584SApple OSS Distributions 
314*1031c584SApple OSS Distributions /* Enabling the token table.  */
315*1031c584SApple OSS Distributions #ifndef YYTOKEN_TABLE
316*1031c584SApple OSS Distributions # define YYTOKEN_TABLE 0
317*1031c584SApple OSS Distributions #endif
318*1031c584SApple OSS Distributions 
319*1031c584SApple OSS Distributions #if !defined YYSTYPE && !defined YYSTYPE_IS_DECLARED
320*1031c584SApple OSS Distributions typedef int YYSTYPE;
321*1031c584SApple OSS Distributions # define yystype YYSTYPE /* obsolescent; will be withdrawn */
322*1031c584SApple OSS Distributions # define YYSTYPE_IS_DECLARED 1
323*1031c584SApple OSS Distributions # define YYSTYPE_IS_TRIVIAL 1
324*1031c584SApple OSS Distributions #endif
325*1031c584SApple OSS Distributions 
326*1031c584SApple OSS Distributions 
327*1031c584SApple OSS Distributions 
328*1031c584SApple OSS Distributions /* Copy the second part of user declarations.  */
329*1031c584SApple OSS Distributions 
330*1031c584SApple OSS Distributions 
331*1031c584SApple OSS Distributions /* Line 216 of yacc.c.  */
332*1031c584SApple OSS Distributions #line 283 "OSUnserializeXML.tab.c"
333*1031c584SApple OSS Distributions 
334*1031c584SApple OSS Distributions #ifdef short
335*1031c584SApple OSS Distributions # undef short
336*1031c584SApple OSS Distributions #endif
337*1031c584SApple OSS Distributions 
338*1031c584SApple OSS Distributions #ifdef YYTYPE_UINT8
339*1031c584SApple OSS Distributions typedef YYTYPE_UINT8 yytype_uint8;
340*1031c584SApple OSS Distributions #else
341*1031c584SApple OSS Distributions typedef unsigned char yytype_uint8;
342*1031c584SApple OSS Distributions #endif
343*1031c584SApple OSS Distributions 
344*1031c584SApple OSS Distributions #ifdef YYTYPE_INT8
345*1031c584SApple OSS Distributions typedef YYTYPE_INT8 yytype_int8;
346*1031c584SApple OSS Distributions #elif (defined __STDC__ || defined __C99__FUNC__ \
347*1031c584SApple OSS Distributions         || defined __cplusplus || defined _MSC_VER)
348*1031c584SApple OSS Distributions typedef signed char yytype_int8;
349*1031c584SApple OSS Distributions #else
350*1031c584SApple OSS Distributions typedef short int yytype_int8;
351*1031c584SApple OSS Distributions #endif
352*1031c584SApple OSS Distributions 
353*1031c584SApple OSS Distributions #ifdef YYTYPE_UINT16
354*1031c584SApple OSS Distributions typedef YYTYPE_UINT16 yytype_uint16;
355*1031c584SApple OSS Distributions #else
356*1031c584SApple OSS Distributions typedef unsigned short int yytype_uint16;
357*1031c584SApple OSS Distributions #endif
358*1031c584SApple OSS Distributions 
359*1031c584SApple OSS Distributions #ifdef YYTYPE_INT16
360*1031c584SApple OSS Distributions typedef YYTYPE_INT16 yytype_int16;
361*1031c584SApple OSS Distributions #else
362*1031c584SApple OSS Distributions typedef short int yytype_int16;
363*1031c584SApple OSS Distributions #endif
364*1031c584SApple OSS Distributions 
365*1031c584SApple OSS Distributions #ifndef YYSIZE_T
366*1031c584SApple OSS Distributions # ifdef __SIZE_TYPE__
367*1031c584SApple OSS Distributions #  define YYSIZE_T __SIZE_TYPE__
368*1031c584SApple OSS Distributions # elif defined size_t
369*1031c584SApple OSS Distributions #  define YYSIZE_T size_t
370*1031c584SApple OSS Distributions # elif !defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
371*1031c584SApple OSS Distributions         || defined __cplusplus || defined _MSC_VER)
372*1031c584SApple OSS Distributions #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
373*1031c584SApple OSS Distributions #  define YYSIZE_T size_t
374*1031c584SApple OSS Distributions # else
375*1031c584SApple OSS Distributions #  define YYSIZE_T unsigned int
376*1031c584SApple OSS Distributions # endif
377*1031c584SApple OSS Distributions #endif
378*1031c584SApple OSS Distributions 
379*1031c584SApple OSS Distributions #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
380*1031c584SApple OSS Distributions 
381*1031c584SApple OSS Distributions #ifndef YY_
382*1031c584SApple OSS Distributions # if defined YYENABLE_NLS && YYENABLE_NLS
383*1031c584SApple OSS Distributions #  if ENABLE_NLS
384*1031c584SApple OSS Distributions #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
385*1031c584SApple OSS Distributions #   define YY_(msgid) dgettext ("bison-runtime", msgid)
386*1031c584SApple OSS Distributions #  endif
387*1031c584SApple OSS Distributions # endif
388*1031c584SApple OSS Distributions # ifndef YY_
389*1031c584SApple OSS Distributions #  define YY_(msgid) msgid
390*1031c584SApple OSS Distributions # endif
391*1031c584SApple OSS Distributions #endif
392*1031c584SApple OSS Distributions 
393*1031c584SApple OSS Distributions /* Suppress unused-variable warnings by "using" E.  */
394*1031c584SApple OSS Distributions #if !defined lint || defined __GNUC__
395*1031c584SApple OSS Distributions # define YYUSE(e) ((void) (e))
396*1031c584SApple OSS Distributions #else
397*1031c584SApple OSS Distributions # define YYUSE(e) /* empty */
398*1031c584SApple OSS Distributions #endif
399*1031c584SApple OSS Distributions 
400*1031c584SApple OSS Distributions /* Identity function, used to suppress warnings about constant conditions.  */
401*1031c584SApple OSS Distributions #ifndef lint
402*1031c584SApple OSS Distributions # define YYID(n) (n)
403*1031c584SApple OSS Distributions #else
404*1031c584SApple OSS Distributions #if (defined __STDC__ || defined __C99__FUNC__ \
405*1031c584SApple OSS Distributions         || defined __cplusplus || defined _MSC_VER)
406*1031c584SApple OSS Distributions static int
YYID(int i)407*1031c584SApple OSS Distributions YYID(int i)
408*1031c584SApple OSS Distributions #else
409*1031c584SApple OSS Distributions static int
410*1031c584SApple OSS Distributions     YYID(i)
411*1031c584SApple OSS Distributions int i;
412*1031c584SApple OSS Distributions #endif
413*1031c584SApple OSS Distributions {
414*1031c584SApple OSS Distributions 	return i;
415*1031c584SApple OSS Distributions }
416*1031c584SApple OSS Distributions #endif
417*1031c584SApple OSS Distributions 
418*1031c584SApple OSS Distributions #if !defined yyoverflow || YYERROR_VERBOSE
419*1031c584SApple OSS Distributions 
420*1031c584SApple OSS Distributions /* The parser invokes alloca or malloc; define the necessary symbols.  */
421*1031c584SApple OSS Distributions 
422*1031c584SApple OSS Distributions # ifdef YYSTACK_USE_ALLOCA
423*1031c584SApple OSS Distributions #  if YYSTACK_USE_ALLOCA
424*1031c584SApple OSS Distributions #   ifdef __GNUC__
425*1031c584SApple OSS Distributions #    define YYSTACK_ALLOC __builtin_alloca
426*1031c584SApple OSS Distributions #   elif defined __BUILTIN_VA_ARG_INCR
427*1031c584SApple OSS Distributions #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
428*1031c584SApple OSS Distributions #   elif defined _AIX
429*1031c584SApple OSS Distributions #    define YYSTACK_ALLOC __alloca
430*1031c584SApple OSS Distributions #   elif defined _MSC_VER
431*1031c584SApple OSS Distributions #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
432*1031c584SApple OSS Distributions #    define alloca _alloca
433*1031c584SApple OSS Distributions #   else
434*1031c584SApple OSS Distributions #    define YYSTACK_ALLOC alloca
435*1031c584SApple OSS Distributions #    if !defined _ALLOCA_H && !defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
436*1031c584SApple OSS Distributions         || defined __cplusplus || defined _MSC_VER)
437*1031c584SApple OSS Distributions #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
438*1031c584SApple OSS Distributions #     ifndef _STDLIB_H
439*1031c584SApple OSS Distributions #      define _STDLIB_H 1
440*1031c584SApple OSS Distributions #     endif
441*1031c584SApple OSS Distributions #    endif
442*1031c584SApple OSS Distributions #   endif
443*1031c584SApple OSS Distributions #  endif
444*1031c584SApple OSS Distributions # endif
445*1031c584SApple OSS Distributions 
446*1031c584SApple OSS Distributions # ifdef YYSTACK_ALLOC
447*1031c584SApple OSS Distributions /* Pacify GCC's `empty if-body' warning.  */
448*1031c584SApple OSS Distributions #  define YYSTACK_FREE(Ptr) do { /* empty */ ; } while (YYID (0))
449*1031c584SApple OSS Distributions #  ifndef YYSTACK_ALLOC_MAXIMUM
450*1031c584SApple OSS Distributions /* The OS might guarantee only one guard page at the bottom of the stack,
451*1031c584SApple OSS Distributions  *  and a page size can be as small as 4096 bytes.  So we cannot safely
452*1031c584SApple OSS Distributions  *  invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
453*1031c584SApple OSS Distributions  *  to allow for a few compiler-allocated temporary stack slots.  */
454*1031c584SApple OSS Distributions #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
455*1031c584SApple OSS Distributions #  endif
456*1031c584SApple OSS Distributions # else
457*1031c584SApple OSS Distributions #  define YYSTACK_ALLOC YYMALLOC
458*1031c584SApple OSS Distributions #  define YYSTACK_FREE YYFREE
459*1031c584SApple OSS Distributions #  ifndef YYSTACK_ALLOC_MAXIMUM
460*1031c584SApple OSS Distributions #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
461*1031c584SApple OSS Distributions #  endif
462*1031c584SApple OSS Distributions #  if (defined __cplusplus && !defined _STDLIB_H \
463*1031c584SApple OSS Distributions         && !((defined YYMALLOC || defined malloc) \
464*1031c584SApple OSS Distributions         && (defined YYFREE || defined free)))
465*1031c584SApple OSS Distributions #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
466*1031c584SApple OSS Distributions #   ifndef _STDLIB_H
467*1031c584SApple OSS Distributions #    define _STDLIB_H 1
468*1031c584SApple OSS Distributions #   endif
469*1031c584SApple OSS Distributions #  endif
470*1031c584SApple OSS Distributions #  ifndef YYMALLOC
471*1031c584SApple OSS Distributions #   define YYMALLOC malloc
472*1031c584SApple OSS Distributions #   if !defined malloc && !defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
473*1031c584SApple OSS Distributions         || defined __cplusplus || defined _MSC_VER)
474*1031c584SApple OSS Distributions void *malloc(YYSIZE_T);  /* INFRINGES ON USER NAME SPACE */
475*1031c584SApple OSS Distributions #   endif
476*1031c584SApple OSS Distributions #  endif
477*1031c584SApple OSS Distributions #  ifndef YYFREE
478*1031c584SApple OSS Distributions #   define YYFREE free
479*1031c584SApple OSS Distributions #   if !defined free && !defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
480*1031c584SApple OSS Distributions         || defined __cplusplus || defined _MSC_VER)
481*1031c584SApple OSS Distributions void free(void *);  /* INFRINGES ON USER NAME SPACE */
482*1031c584SApple OSS Distributions #   endif
483*1031c584SApple OSS Distributions #  endif
484*1031c584SApple OSS Distributions # endif
485*1031c584SApple OSS Distributions #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
486*1031c584SApple OSS Distributions 
487*1031c584SApple OSS Distributions 
488*1031c584SApple OSS Distributions #if (!defined yyoverflow \
489*1031c584SApple OSS Distributions         && (!defined __cplusplus \
490*1031c584SApple OSS Distributions         || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
491*1031c584SApple OSS Distributions 
492*1031c584SApple OSS Distributions /* A type that is properly aligned for any stack member.  */
493*1031c584SApple OSS Distributions union yyalloc {
494*1031c584SApple OSS Distributions 	yytype_int16 yyss;
495*1031c584SApple OSS Distributions 	YYSTYPE yyvs;
496*1031c584SApple OSS Distributions };
497*1031c584SApple OSS Distributions 
498*1031c584SApple OSS Distributions /* The size of the maximum gap between one aligned stack and the next.  */
499*1031c584SApple OSS Distributions # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
500*1031c584SApple OSS Distributions 
501*1031c584SApple OSS Distributions /* The size of an array large to enough to hold all stacks, each with
502*1031c584SApple OSS Distributions  *  N elements.  */
503*1031c584SApple OSS Distributions # define YYSTACK_BYTES(N) \
504*1031c584SApple OSS Distributions      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
505*1031c584SApple OSS Distributions       + YYSTACK_GAP_MAXIMUM)
506*1031c584SApple OSS Distributions 
507*1031c584SApple OSS Distributions /* Copy COUNT objects from FROM to TO.  The source and destination do
508*1031c584SApple OSS Distributions  *  not overlap.  */
509*1031c584SApple OSS Distributions # ifndef YYCOPY
510*1031c584SApple OSS Distributions #  if defined __GNUC__ && 1 < __GNUC__
511*1031c584SApple OSS Distributions #   define YYCOPY(To, From, Count) \
512*1031c584SApple OSS Distributions       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
513*1031c584SApple OSS Distributions #  else
514*1031c584SApple OSS Distributions #   define YYCOPY(To, From, Count)              \
515*1031c584SApple OSS Distributions       do                                        \
516*1031c584SApple OSS Distributions 	{                                       \
517*1031c584SApple OSS Distributions 	  YYSIZE_T yyi;                         \
518*1031c584SApple OSS Distributions 	  for (yyi = 0; yyi < (Count); yyi++)   \
519*1031c584SApple OSS Distributions 	    (To)[yyi] = (From)[yyi];            \
520*1031c584SApple OSS Distributions 	}                                       \
521*1031c584SApple OSS Distributions       while (YYID (0))
522*1031c584SApple OSS Distributions #  endif
523*1031c584SApple OSS Distributions # endif
524*1031c584SApple OSS Distributions 
525*1031c584SApple OSS Distributions /* Relocate STACK from its old location to the new one.  The
526*1031c584SApple OSS Distributions  *  local variables YYSIZE and YYSTACKSIZE give the old and new number of
527*1031c584SApple OSS Distributions  *  elements in the stack, and YYPTR gives the new location of the
528*1031c584SApple OSS Distributions  *  stack.  Advance YYPTR to a properly aligned location for the next
529*1031c584SApple OSS Distributions  *  stack.  */
530*1031c584SApple OSS Distributions # define YYSTACK_RELOCATE(Stack)                                        \
531*1031c584SApple OSS Distributions     do                                                                  \
532*1031c584SApple OSS Distributions       {                                                                 \
533*1031c584SApple OSS Distributions 	YYSIZE_T yynewbytes;                                            \
534*1031c584SApple OSS Distributions 	YYCOPY (&yyptr->Stack, Stack, yysize);                          \
535*1031c584SApple OSS Distributions 	Stack = &yyptr->Stack;                                          \
536*1031c584SApple OSS Distributions 	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
537*1031c584SApple OSS Distributions 	yyptr += yynewbytes / sizeof (*yyptr);                          \
538*1031c584SApple OSS Distributions       }                                                                 \
539*1031c584SApple OSS Distributions     while (YYID (0))
540*1031c584SApple OSS Distributions 
541*1031c584SApple OSS Distributions #endif
542*1031c584SApple OSS Distributions 
543*1031c584SApple OSS Distributions /* YYFINAL -- State number of the termination state.  */
544*1031c584SApple OSS Distributions #define YYFINAL  33
545*1031c584SApple OSS Distributions /* YYLAST -- Last index in YYTABLE.  */
546*1031c584SApple OSS Distributions #define YYLAST   108
547*1031c584SApple OSS Distributions 
548*1031c584SApple OSS Distributions /* YYNTOKENS -- Number of terminals.  */
549*1031c584SApple OSS Distributions #define YYNTOKENS  19
550*1031c584SApple OSS Distributions /* YYNNTS -- Number of nonterminals.  */
551*1031c584SApple OSS Distributions #define YYNNTS  15
552*1031c584SApple OSS Distributions /* YYNRULES -- Number of rules.  */
553*1031c584SApple OSS Distributions #define YYNRULES  32
554*1031c584SApple OSS Distributions /* YYNRULES -- Number of states.  */
555*1031c584SApple OSS Distributions #define YYNSTATES  40
556*1031c584SApple OSS Distributions 
557*1031c584SApple OSS Distributions /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
558*1031c584SApple OSS Distributions #define YYUNDEFTOK  2
559*1031c584SApple OSS Distributions #define YYMAXUTOK   267
560*1031c584SApple OSS Distributions 
561*1031c584SApple OSS Distributions #define YYTRANSLATE(YYX)                                                \
562*1031c584SApple OSS Distributions   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
563*1031c584SApple OSS Distributions 
564*1031c584SApple OSS Distributions /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
565*1031c584SApple OSS Distributions static const yytype_uint8 yytranslate[] =
566*1031c584SApple OSS Distributions {
567*1031c584SApple OSS Distributions 	0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
568*1031c584SApple OSS Distributions 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
569*1031c584SApple OSS Distributions 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
570*1031c584SApple OSS Distributions 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
571*1031c584SApple OSS Distributions 	15, 16, 2, 2, 2, 2, 2, 2, 2, 2,
572*1031c584SApple OSS Distributions 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
573*1031c584SApple OSS Distributions 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
574*1031c584SApple OSS Distributions 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
575*1031c584SApple OSS Distributions 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
576*1031c584SApple OSS Distributions 	2, 17, 2, 18, 2, 2, 2, 2, 2, 2,
577*1031c584SApple OSS Distributions 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
578*1031c584SApple OSS Distributions 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
579*1031c584SApple OSS Distributions 	2, 2, 2, 13, 2, 14, 2, 2, 2, 2,
580*1031c584SApple OSS Distributions 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
581*1031c584SApple OSS Distributions 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
582*1031c584SApple OSS Distributions 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
583*1031c584SApple OSS Distributions 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
584*1031c584SApple OSS Distributions 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
585*1031c584SApple OSS Distributions 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
586*1031c584SApple OSS Distributions 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
587*1031c584SApple OSS Distributions 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
588*1031c584SApple OSS Distributions 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
589*1031c584SApple OSS Distributions 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
590*1031c584SApple OSS Distributions 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
591*1031c584SApple OSS Distributions 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
592*1031c584SApple OSS Distributions 	2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
593*1031c584SApple OSS Distributions 	5, 6, 7, 8, 9, 10, 11, 12
594*1031c584SApple OSS Distributions };
595*1031c584SApple OSS Distributions 
596*1031c584SApple OSS Distributions #if YYDEBUG
597*1031c584SApple OSS Distributions /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
598*1031c584SApple OSS Distributions  *  YYRHS.  */
599*1031c584SApple OSS Distributions static const yytype_uint8 yyprhs[] =
600*1031c584SApple OSS Distributions {
601*1031c584SApple OSS Distributions 	0, 0, 3, 4, 6, 8, 10, 12, 14, 16,
602*1031c584SApple OSS Distributions 	18, 20, 22, 24, 27, 31, 33, 35, 38, 41,
603*1031c584SApple OSS Distributions 	43, 46, 50, 52, 55, 59, 61, 63, 66, 68,
604*1031c584SApple OSS Distributions 	70, 72, 74
605*1031c584SApple OSS Distributions };
606*1031c584SApple OSS Distributions 
607*1031c584SApple OSS Distributions /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
608*1031c584SApple OSS Distributions static const yytype_int8 yyrhs[] =
609*1031c584SApple OSS Distributions {
610*1031c584SApple OSS Distributions 	20, 0, -1, -1, 21, -1, 12, -1, 22, -1,
611*1031c584SApple OSS Distributions 	26, -1, 27, -1, 33, -1, 30, -1, 32, -1,
612*1031c584SApple OSS Distributions 	29, -1, 31, -1, 13, 14, -1, 13, 23, 14,
613*1031c584SApple OSS Distributions 	-1, 6, -1, 24, -1, 23, 24, -1, 25, 21,
614*1031c584SApple OSS Distributions 	-1, 8, -1, 15, 16, -1, 15, 28, 16, -1,
615*1031c584SApple OSS Distributions 	3, -1, 17, 18, -1, 17, 28, 18, -1, 10,
616*1031c584SApple OSS Distributions 	-1, 21, -1, 28, 21, -1, 4, -1, 5, -1,
617*1031c584SApple OSS Distributions 	7, -1, 9, -1, 11, -1
618*1031c584SApple OSS Distributions };
619*1031c584SApple OSS Distributions 
620*1031c584SApple OSS Distributions /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
621*1031c584SApple OSS Distributions static const yytype_uint16 yyrline[] =
622*1031c584SApple OSS Distributions {
623*1031c584SApple OSS Distributions 	0, 217, 217, 220, 225, 230, 242, 254, 266, 278,
624*1031c584SApple OSS Distributions 	290, 302, 314, 338, 341, 344, 347, 348, 363, 372,
625*1031c584SApple OSS Distributions 	384, 387, 390, 393, 396, 399, 402, 405, 412, 415,
626*1031c584SApple OSS Distributions 	418, 421, 424
627*1031c584SApple OSS Distributions };
628*1031c584SApple OSS Distributions #endif
629*1031c584SApple OSS Distributions 
630*1031c584SApple OSS Distributions #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
631*1031c584SApple OSS Distributions /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
632*1031c584SApple OSS Distributions  *  First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
633*1031c584SApple OSS Distributions static const char *const yytname[] =
634*1031c584SApple OSS Distributions {
635*1031c584SApple OSS Distributions 	"$end", "error", "$undefined", "ARRAY", "BOOLEAN", "DATA", "DICTIONARY",
636*1031c584SApple OSS Distributions 	"IDREF", "KEY", "NUMBER", "SET", "STRING", "SYNTAX_ERROR", "'{'", "'}'",
637*1031c584SApple OSS Distributions 	"'('", "')'", "'['", "']'", "$accept", "input", "object", "dict",
638*1031c584SApple OSS Distributions 	"pairs", "pair", "key", "array", "set", "elements", "boolean", "data",
639*1031c584SApple OSS Distributions 	"idref", "number", "string", 0
640*1031c584SApple OSS Distributions };
641*1031c584SApple OSS Distributions #endif
642*1031c584SApple OSS Distributions 
643*1031c584SApple OSS Distributions # ifdef YYPRINT
644*1031c584SApple OSS Distributions /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
645*1031c584SApple OSS Distributions  *  token YYLEX-NUM.  */
646*1031c584SApple OSS Distributions static const yytype_uint16 yytoknum[] =
647*1031c584SApple OSS Distributions {
648*1031c584SApple OSS Distributions 	0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
649*1031c584SApple OSS Distributions 	265, 266, 267, 123, 125, 40, 41, 91, 93
650*1031c584SApple OSS Distributions };
651*1031c584SApple OSS Distributions # endif
652*1031c584SApple OSS Distributions 
653*1031c584SApple OSS Distributions /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
654*1031c584SApple OSS Distributions static const yytype_uint8 yyr1[] =
655*1031c584SApple OSS Distributions {
656*1031c584SApple OSS Distributions 	0, 19, 20, 20, 20, 21, 21, 21, 21, 21,
657*1031c584SApple OSS Distributions 	21, 21, 21, 22, 22, 22, 23, 23, 24, 25,
658*1031c584SApple OSS Distributions 	26, 26, 26, 27, 27, 27, 28, 28, 29, 30,
659*1031c584SApple OSS Distributions 	31, 32, 33
660*1031c584SApple OSS Distributions };
661*1031c584SApple OSS Distributions 
662*1031c584SApple OSS Distributions /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
663*1031c584SApple OSS Distributions static const yytype_uint8 yyr2[] =
664*1031c584SApple OSS Distributions {
665*1031c584SApple OSS Distributions 	0, 2, 0, 1, 1, 1, 1, 1, 1, 1,
666*1031c584SApple OSS Distributions 	1, 1, 1, 2, 3, 1, 1, 2, 2, 1,
667*1031c584SApple OSS Distributions 	2, 3, 1, 2, 3, 1, 1, 2, 1, 1,
668*1031c584SApple OSS Distributions 	1, 1, 1
669*1031c584SApple OSS Distributions };
670*1031c584SApple OSS Distributions 
671*1031c584SApple OSS Distributions /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
672*1031c584SApple OSS Distributions  *  STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
673*1031c584SApple OSS Distributions  *  means the default is an error.  */
674*1031c584SApple OSS Distributions static const yytype_uint8 yydefact[] =
675*1031c584SApple OSS Distributions {
676*1031c584SApple OSS Distributions 	2, 22, 28, 29, 15, 30, 31, 25, 32, 4,
677*1031c584SApple OSS Distributions 	0, 0, 0, 0, 3, 5, 6, 7, 11, 9,
678*1031c584SApple OSS Distributions 	12, 10, 8, 19, 13, 0, 16, 0, 20, 26,
679*1031c584SApple OSS Distributions 	0, 23, 0, 1, 14, 17, 18, 21, 27, 24
680*1031c584SApple OSS Distributions };
681*1031c584SApple OSS Distributions 
682*1031c584SApple OSS Distributions /* YYDEFGOTO[NTERM-NUM].  */
683*1031c584SApple OSS Distributions static const yytype_int8 yydefgoto[] =
684*1031c584SApple OSS Distributions {
685*1031c584SApple OSS Distributions 	-1, 13, 29, 15, 25, 26, 27, 16, 17, 30,
686*1031c584SApple OSS Distributions 	18, 19, 20, 21, 22
687*1031c584SApple OSS Distributions };
688*1031c584SApple OSS Distributions 
689*1031c584SApple OSS Distributions /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
690*1031c584SApple OSS Distributions  *  STATE-NUM.  */
691*1031c584SApple OSS Distributions #define YYPACT_NINF -20
692*1031c584SApple OSS Distributions static const yytype_int8 yypact[] =
693*1031c584SApple OSS Distributions {
694*1031c584SApple OSS Distributions 	46, -20, -20, -20, -20, -20, -20, -20, -20, -20,
695*1031c584SApple OSS Distributions 	4, 61, -2, 10, -20, -20, -20, -20, -20, -20,
696*1031c584SApple OSS Distributions 	-20, -20, -20, -20, -20, 6, -20, 91, -20, -20,
697*1031c584SApple OSS Distributions 	76, -20, 30, -20, -20, -20, -20, -20, -20, -20
698*1031c584SApple OSS Distributions };
699*1031c584SApple OSS Distributions 
700*1031c584SApple OSS Distributions /* YYPGOTO[NTERM-NUM].  */
701*1031c584SApple OSS Distributions static const yytype_int8 yypgoto[] =
702*1031c584SApple OSS Distributions {
703*1031c584SApple OSS Distributions 	-20, -20, 0, -20, -20, -19, -20, -20, -20, 5,
704*1031c584SApple OSS Distributions 	-20, -20, -20, -20, -20
705*1031c584SApple OSS Distributions };
706*1031c584SApple OSS Distributions 
707*1031c584SApple OSS Distributions /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
708*1031c584SApple OSS Distributions  *  positive, shift that token.  If negative, reduce the rule which
709*1031c584SApple OSS Distributions  *  number is the opposite.  If zero, do what YYDEFACT says.
710*1031c584SApple OSS Distributions  *  If YYTABLE_NINF, syntax error.  */
711*1031c584SApple OSS Distributions #define YYTABLE_NINF -1
712*1031c584SApple OSS Distributions static const yytype_uint8 yytable[] =
713*1031c584SApple OSS Distributions {
714*1031c584SApple OSS Distributions 	14, 1, 2, 3, 4, 5, 35, 6, 7, 8,
715*1031c584SApple OSS Distributions 	33, 10, 23, 11, 23, 12, 31, 32, 24, 0,
716*1031c584SApple OSS Distributions 	34, 0, 0, 0, 0, 0, 0, 36, 0, 0,
717*1031c584SApple OSS Distributions 	38, 0, 38, 1, 2, 3, 4, 5, 0, 6,
718*1031c584SApple OSS Distributions 	7, 8, 0, 10, 0, 11, 0, 12, 39, 1,
719*1031c584SApple OSS Distributions 	2, 3, 4, 5, 0, 6, 7, 8, 9, 10,
720*1031c584SApple OSS Distributions 	0, 11, 0, 12, 1, 2, 3, 4, 5, 0,
721*1031c584SApple OSS Distributions 	6, 7, 8, 0, 10, 0, 11, 28, 12, 1,
722*1031c584SApple OSS Distributions 	2, 3, 4, 5, 0, 6, 7, 8, 0, 10,
723*1031c584SApple OSS Distributions 	0, 11, 37, 12, 1, 2, 3, 4, 5, 0,
724*1031c584SApple OSS Distributions 	6, 7, 8, 0, 10, 0, 11, 0, 12
725*1031c584SApple OSS Distributions };
726*1031c584SApple OSS Distributions 
727*1031c584SApple OSS Distributions static const yytype_int8 yycheck[] =
728*1031c584SApple OSS Distributions {
729*1031c584SApple OSS Distributions 	0, 3, 4, 5, 6, 7, 25, 9, 10, 11,
730*1031c584SApple OSS Distributions 	0, 13, 8, 15, 8, 17, 18, 12, 14, -1,
731*1031c584SApple OSS Distributions 	14, -1, -1, -1, -1, -1, -1, 27, -1, -1,
732*1031c584SApple OSS Distributions 	30, -1, 32, 3, 4, 5, 6, 7, -1, 9,
733*1031c584SApple OSS Distributions 	10, 11, -1, 13, -1, 15, -1, 17, 18, 3,
734*1031c584SApple OSS Distributions 	4, 5, 6, 7, -1, 9, 10, 11, 12, 13,
735*1031c584SApple OSS Distributions 	-1, 15, -1, 17, 3, 4, 5, 6, 7, -1,
736*1031c584SApple OSS Distributions 	9, 10, 11, -1, 13, -1, 15, 16, 17, 3,
737*1031c584SApple OSS Distributions 	4, 5, 6, 7, -1, 9, 10, 11, -1, 13,
738*1031c584SApple OSS Distributions 	-1, 15, 16, 17, 3, 4, 5, 6, 7, -1,
739*1031c584SApple OSS Distributions 	9, 10, 11, -1, 13, -1, 15, -1, 17
740*1031c584SApple OSS Distributions };
741*1031c584SApple OSS Distributions 
742*1031c584SApple OSS Distributions /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
743*1031c584SApple OSS Distributions  *  symbol of state STATE-NUM.  */
744*1031c584SApple OSS Distributions static const yytype_uint8 yystos[] =
745*1031c584SApple OSS Distributions {
746*1031c584SApple OSS Distributions 	0, 3, 4, 5, 6, 7, 9, 10, 11, 12,
747*1031c584SApple OSS Distributions 	13, 15, 17, 20, 21, 22, 26, 27, 29, 30,
748*1031c584SApple OSS Distributions 	31, 32, 33, 8, 14, 23, 24, 25, 16, 21,
749*1031c584SApple OSS Distributions 	28, 18, 28, 0, 14, 24, 21, 16, 21, 18
750*1031c584SApple OSS Distributions };
751*1031c584SApple OSS Distributions 
752*1031c584SApple OSS Distributions #define yyerrok         (yyerrstatus = 0)
753*1031c584SApple OSS Distributions #define yyclearin       (yychar = YYEMPTY)
754*1031c584SApple OSS Distributions #define YYEMPTY         (-2)
755*1031c584SApple OSS Distributions #define YYEOF           0
756*1031c584SApple OSS Distributions 
757*1031c584SApple OSS Distributions #define YYACCEPT        goto yyacceptlab
758*1031c584SApple OSS Distributions #define YYABORT         goto yyabortlab
759*1031c584SApple OSS Distributions #define YYERROR         goto yyerrorlab
760*1031c584SApple OSS Distributions 
761*1031c584SApple OSS Distributions 
762*1031c584SApple OSS Distributions /* Like YYERROR except do call yyerror.  This remains here temporarily
763*1031c584SApple OSS Distributions  *  to ease the transition to the new meaning of YYERROR, for GCC.
764*1031c584SApple OSS Distributions  *  Once GCC version 2 has supplanted version 1, this can go.  */
765*1031c584SApple OSS Distributions 
766*1031c584SApple OSS Distributions #define YYFAIL          goto yyerrlab
767*1031c584SApple OSS Distributions 
768*1031c584SApple OSS Distributions #define YYRECOVERING()  (!!yyerrstatus)
769*1031c584SApple OSS Distributions 
770*1031c584SApple OSS Distributions #define YYBACKUP(Token, Value)                                  \
771*1031c584SApple OSS Distributions do                                                              \
772*1031c584SApple OSS Distributions   if (yychar == YYEMPTY && yylen == 1)                          \
773*1031c584SApple OSS Distributions     {                                                           \
774*1031c584SApple OSS Distributions       yychar = (Token);                                         \
775*1031c584SApple OSS Distributions       yylval = (Value);                                         \
776*1031c584SApple OSS Distributions       yytoken = YYTRANSLATE (yychar);                           \
777*1031c584SApple OSS Distributions       YYPOPSTACK (1);                                           \
778*1031c584SApple OSS Distributions       goto yybackup;                                            \
779*1031c584SApple OSS Distributions     }                                                           \
780*1031c584SApple OSS Distributions   else                                                          \
781*1031c584SApple OSS Distributions     {                                                           \
782*1031c584SApple OSS Distributions       yyerror (YY_("syntax error: cannot back up")); \
783*1031c584SApple OSS Distributions       YYERROR;                                                  \
784*1031c584SApple OSS Distributions     }                                                           \
785*1031c584SApple OSS Distributions while (YYID (0))
786*1031c584SApple OSS Distributions 
787*1031c584SApple OSS Distributions 
788*1031c584SApple OSS Distributions #define YYTERROR        1
789*1031c584SApple OSS Distributions #define YYERRCODE       256
790*1031c584SApple OSS Distributions 
791*1031c584SApple OSS Distributions 
792*1031c584SApple OSS Distributions /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
793*1031c584SApple OSS Distributions  *  If N is 0, then set CURRENT to the empty location which ends
794*1031c584SApple OSS Distributions  *  the previous symbol: RHS[0] (always defined).  */
795*1031c584SApple OSS Distributions 
796*1031c584SApple OSS Distributions #define YYRHSLOC(Rhs, K) ((Rhs)[K])
797*1031c584SApple OSS Distributions #ifndef YYLLOC_DEFAULT
798*1031c584SApple OSS Distributions # define YYLLOC_DEFAULT(Current, Rhs, N)                                \
799*1031c584SApple OSS Distributions     do                                                                  \
800*1031c584SApple OSS Distributions       if (YYID (N))                                                    \
801*1031c584SApple OSS Distributions 	{                                                               \
802*1031c584SApple OSS Distributions 	  (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
803*1031c584SApple OSS Distributions 	  (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
804*1031c584SApple OSS Distributions 	  (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
805*1031c584SApple OSS Distributions 	  (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
806*1031c584SApple OSS Distributions 	}                                                               \
807*1031c584SApple OSS Distributions       else                                                              \
808*1031c584SApple OSS Distributions 	{                                                               \
809*1031c584SApple OSS Distributions 	  (Current).first_line   = (Current).last_line   =              \
810*1031c584SApple OSS Distributions 	    YYRHSLOC (Rhs, 0).last_line;                                \
811*1031c584SApple OSS Distributions 	  (Current).first_column = (Current).last_column =              \
812*1031c584SApple OSS Distributions 	    YYRHSLOC (Rhs, 0).last_column;                              \
813*1031c584SApple OSS Distributions 	}                                                               \
814*1031c584SApple OSS Distributions     while (YYID (0))
815*1031c584SApple OSS Distributions #endif
816*1031c584SApple OSS Distributions 
817*1031c584SApple OSS Distributions 
818*1031c584SApple OSS Distributions /* YY_LOCATION_PRINT -- Print the location on the stream.
819*1031c584SApple OSS Distributions  *  This macro was not mandated originally: define only if we know
820*1031c584SApple OSS Distributions  *  we won't break user code: when these are the locations we know.  */
821*1031c584SApple OSS Distributions 
822*1031c584SApple OSS Distributions #ifndef YY_LOCATION_PRINT
823*1031c584SApple OSS Distributions # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
824*1031c584SApple OSS Distributions #  define YY_LOCATION_PRINT(File, Loc)                  \
825*1031c584SApple OSS Distributions      fprintf (File, "%d.%d-%d.%d",                      \
826*1031c584SApple OSS Distributions 	      (Loc).first_line, (Loc).first_column,     \
827*1031c584SApple OSS Distributions 	      (Loc).last_line,  (Loc).last_column)
828*1031c584SApple OSS Distributions # else
829*1031c584SApple OSS Distributions #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
830*1031c584SApple OSS Distributions # endif
831*1031c584SApple OSS Distributions #endif
832*1031c584SApple OSS Distributions 
833*1031c584SApple OSS Distributions 
834*1031c584SApple OSS Distributions /* YYLEX -- calling `yylex' with the right arguments.  */
835*1031c584SApple OSS Distributions 
836*1031c584SApple OSS Distributions #ifdef YYLEX_PARAM
837*1031c584SApple OSS Distributions # define YYLEX yylex (&yylval, YYLEX_PARAM)
838*1031c584SApple OSS Distributions #else
839*1031c584SApple OSS Distributions # define YYLEX yylex (&yylval)
840*1031c584SApple OSS Distributions #endif
841*1031c584SApple OSS Distributions 
842*1031c584SApple OSS Distributions /* Enable debugging if requested.  */
843*1031c584SApple OSS Distributions #if YYDEBUG
844*1031c584SApple OSS Distributions 
845*1031c584SApple OSS Distributions # ifndef YYFPRINTF
846*1031c584SApple OSS Distributions #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
847*1031c584SApple OSS Distributions #  define YYFPRINTF fprintf
848*1031c584SApple OSS Distributions # endif
849*1031c584SApple OSS Distributions 
850*1031c584SApple OSS Distributions # define YYDPRINTF(Args)                        \
851*1031c584SApple OSS Distributions do {                                            \
852*1031c584SApple OSS Distributions   if (yydebug)                                  \
853*1031c584SApple OSS Distributions     YYFPRINTF Args;                             \
854*1031c584SApple OSS Distributions } while (YYID (0))
855*1031c584SApple OSS Distributions 
856*1031c584SApple OSS Distributions # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
857*1031c584SApple OSS Distributions do {                                                                      \
858*1031c584SApple OSS Distributions   if (yydebug)                                                            \
859*1031c584SApple OSS Distributions     {                                                                     \
860*1031c584SApple OSS Distributions       YYFPRINTF (stderr, "%s ", Title);                                   \
861*1031c584SApple OSS Distributions       yy_symbol_print (stderr,                                            \
862*1031c584SApple OSS Distributions 	          Type, Value); \
863*1031c584SApple OSS Distributions       YYFPRINTF (stderr, "\n");                                           \
864*1031c584SApple OSS Distributions     }                                                                     \
865*1031c584SApple OSS Distributions } while (YYID (0))
866*1031c584SApple OSS Distributions 
867*1031c584SApple OSS Distributions 
868*1031c584SApple OSS Distributions /*--------------------------------.
869*1031c584SApple OSS Distributions  | Print this symbol on YYOUTPUT.  |
870*1031c584SApple OSS Distributions  |   `--------------------------------*/
871*1031c584SApple OSS Distributions 
872*1031c584SApple OSS Distributions /*ARGSUSED*/
873*1031c584SApple OSS Distributions #if (defined __STDC__ || defined __C99__FUNC__ \
874*1031c584SApple OSS Distributions         || defined __cplusplus || defined _MSC_VER)
875*1031c584SApple OSS Distributions static void
yy_symbol_value_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep)876*1031c584SApple OSS Distributions yy_symbol_value_print(FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
877*1031c584SApple OSS Distributions #else
878*1031c584SApple OSS Distributions static void
879*1031c584SApple OSS Distributions     yy_symbol_value_print(yyoutput, yytype, yyvaluep)
880*1031c584SApple OSS Distributions FILE *yyoutput;
881*1031c584SApple OSS Distributions int yytype;
882*1031c584SApple OSS Distributions YYSTYPE const * const yyvaluep;
883*1031c584SApple OSS Distributions #endif
884*1031c584SApple OSS Distributions {
885*1031c584SApple OSS Distributions 	if (!yyvaluep) {
886*1031c584SApple OSS Distributions 		return;
887*1031c584SApple OSS Distributions 	}
888*1031c584SApple OSS Distributions # ifdef YYPRINT
889*1031c584SApple OSS Distributions 	if (yytype < YYNTOKENS) {
890*1031c584SApple OSS Distributions 		YYPRINT(yyoutput, yytoknum[yytype], *yyvaluep);
891*1031c584SApple OSS Distributions 	}
892*1031c584SApple OSS Distributions # else
893*1031c584SApple OSS Distributions 	YYUSE(yyoutput);
894*1031c584SApple OSS Distributions # endif
895*1031c584SApple OSS Distributions 	switch (yytype) {
896*1031c584SApple OSS Distributions 	default:
897*1031c584SApple OSS Distributions 		break;
898*1031c584SApple OSS Distributions 	}
899*1031c584SApple OSS Distributions }
900*1031c584SApple OSS Distributions 
901*1031c584SApple OSS Distributions 
902*1031c584SApple OSS Distributions /*--------------------------------.
903*1031c584SApple OSS Distributions  | Print this symbol on YYOUTPUT.  |
904*1031c584SApple OSS Distributions  |   `--------------------------------*/
905*1031c584SApple OSS Distributions 
906*1031c584SApple OSS Distributions #if (defined __STDC__ || defined __C99__FUNC__ \
907*1031c584SApple OSS Distributions         || defined __cplusplus || defined _MSC_VER)
908*1031c584SApple OSS Distributions static void
yy_symbol_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep)909*1031c584SApple OSS Distributions yy_symbol_print(FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
910*1031c584SApple OSS Distributions #else
911*1031c584SApple OSS Distributions static void
912*1031c584SApple OSS Distributions     yy_symbol_print(yyoutput, yytype, yyvaluep)
913*1031c584SApple OSS Distributions FILE *yyoutput;
914*1031c584SApple OSS Distributions int yytype;
915*1031c584SApple OSS Distributions YYSTYPE const * const yyvaluep;
916*1031c584SApple OSS Distributions #endif
917*1031c584SApple OSS Distributions {
918*1031c584SApple OSS Distributions 	if (yytype < YYNTOKENS) {
919*1031c584SApple OSS Distributions 		YYFPRINTF(yyoutput, "token %s (", yytname[yytype]);
920*1031c584SApple OSS Distributions 	} else {
921*1031c584SApple OSS Distributions 		YYFPRINTF(yyoutput, "nterm %s (", yytname[yytype]);
922*1031c584SApple OSS Distributions 	}
923*1031c584SApple OSS Distributions 
924*1031c584SApple OSS Distributions 	yy_symbol_value_print(yyoutput, yytype, yyvaluep);
925*1031c584SApple OSS Distributions 	YYFPRINTF(yyoutput, ")");
926*1031c584SApple OSS Distributions }
927*1031c584SApple OSS Distributions 
928*1031c584SApple OSS Distributions /*------------------------------------------------------------------.
929*1031c584SApple OSS Distributions  | yy_stack_print -- Print the state stack from its BOTTOM up to its |
930*1031c584SApple OSS Distributions  | TOP (included).                                                   |
931*1031c584SApple OSS Distributions  |   `------------------------------------------------------------------*/
932*1031c584SApple OSS Distributions 
933*1031c584SApple OSS Distributions #if (defined __STDC__ || defined __C99__FUNC__ \
934*1031c584SApple OSS Distributions         || defined __cplusplus || defined _MSC_VER)
935*1031c584SApple OSS Distributions static void
yy_stack_print(yytype_int16 * bottom,yytype_int16 * top)936*1031c584SApple OSS Distributions yy_stack_print(yytype_int16 *bottom, yytype_int16 *top)
937*1031c584SApple OSS Distributions #else
938*1031c584SApple OSS Distributions static void
939*1031c584SApple OSS Distributions     yy_stack_print(bottom, top)
940*1031c584SApple OSS Distributions yytype_int16 *bottom;
941*1031c584SApple OSS Distributions yytype_int16 *top;
942*1031c584SApple OSS Distributions #endif
943*1031c584SApple OSS Distributions {
944*1031c584SApple OSS Distributions 	YYFPRINTF(stderr, "Stack now");
945*1031c584SApple OSS Distributions 	for (; bottom <= top; ++bottom) {
946*1031c584SApple OSS Distributions 		YYFPRINTF(stderr, " %d", *bottom);
947*1031c584SApple OSS Distributions 	}
948*1031c584SApple OSS Distributions 	YYFPRINTF(stderr, "\n");
949*1031c584SApple OSS Distributions }
950*1031c584SApple OSS Distributions 
951*1031c584SApple OSS Distributions # define YY_STACK_PRINT(Bottom, Top)                            \
952*1031c584SApple OSS Distributions do {                                                            \
953*1031c584SApple OSS Distributions   if (yydebug)                                                  \
954*1031c584SApple OSS Distributions     yy_stack_print ((Bottom), (Top));                           \
955*1031c584SApple OSS Distributions } while (YYID (0))
956*1031c584SApple OSS Distributions 
957*1031c584SApple OSS Distributions 
958*1031c584SApple OSS Distributions /*------------------------------------------------.
959*1031c584SApple OSS Distributions  | Report that the YYRULE is going to be reduced.  |
960*1031c584SApple OSS Distributions  |   `------------------------------------------------*/
961*1031c584SApple OSS Distributions 
962*1031c584SApple OSS Distributions #if (defined __STDC__ || defined __C99__FUNC__ \
963*1031c584SApple OSS Distributions         || defined __cplusplus || defined _MSC_VER)
964*1031c584SApple OSS Distributions static void
yy_reduce_print(YYSTYPE * yyvsp,int yyrule)965*1031c584SApple OSS Distributions yy_reduce_print(YYSTYPE *yyvsp, int yyrule)
966*1031c584SApple OSS Distributions #else
967*1031c584SApple OSS Distributions static void
968*1031c584SApple OSS Distributions     yy_reduce_print(yyvsp, yyrule)
969*1031c584SApple OSS Distributions YYSTYPE *yyvsp;
970*1031c584SApple OSS Distributions int yyrule;
971*1031c584SApple OSS Distributions #endif
972*1031c584SApple OSS Distributions {
973*1031c584SApple OSS Distributions 	int yynrhs = yyr2[yyrule];
974*1031c584SApple OSS Distributions 	int yyi;
975*1031c584SApple OSS Distributions 	unsigned long int yylno = yyrline[yyrule];
976*1031c584SApple OSS Distributions 	YYFPRINTF(stderr, "Reducing stack by rule %d (line %lu):\n",
977*1031c584SApple OSS Distributions 	    yyrule - 1, yylno);
978*1031c584SApple OSS Distributions 	/* The symbols being reduced.  */
979*1031c584SApple OSS Distributions 	for (yyi = 0; yyi < yynrhs; yyi++) {
980*1031c584SApple OSS Distributions 		fprintf(stderr, "   $%d = ", yyi + 1);
981*1031c584SApple OSS Distributions 		yy_symbol_print(stderr, yyrhs[yyprhs[yyrule] + yyi],
982*1031c584SApple OSS Distributions 		    &(yyvsp[(yyi + 1) - (yynrhs)])
983*1031c584SApple OSS Distributions 		    );
984*1031c584SApple OSS Distributions 		fprintf(stderr, "\n");
985*1031c584SApple OSS Distributions 	}
986*1031c584SApple OSS Distributions }
987*1031c584SApple OSS Distributions 
988*1031c584SApple OSS Distributions # define YY_REDUCE_PRINT(Rule)          \
989*1031c584SApple OSS Distributions do {                                    \
990*1031c584SApple OSS Distributions   if (yydebug)                          \
991*1031c584SApple OSS Distributions     yy_reduce_print (yyvsp, Rule); \
992*1031c584SApple OSS Distributions } while (YYID (0))
993*1031c584SApple OSS Distributions 
994*1031c584SApple OSS Distributions /* Nonzero means print parse trace.  It is left uninitialized so that
995*1031c584SApple OSS Distributions  *  multiple parsers can coexist.  */
996*1031c584SApple OSS Distributions int yydebug;
997*1031c584SApple OSS Distributions #else /* !YYDEBUG */
998*1031c584SApple OSS Distributions # define YYDPRINTF(Args)
999*1031c584SApple OSS Distributions # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1000*1031c584SApple OSS Distributions # define YY_STACK_PRINT(Bottom, Top)
1001*1031c584SApple OSS Distributions # define YY_REDUCE_PRINT(Rule)
1002*1031c584SApple OSS Distributions #endif /* !YYDEBUG */
1003*1031c584SApple OSS Distributions 
1004*1031c584SApple OSS Distributions 
1005*1031c584SApple OSS Distributions /* YYINITDEPTH -- initial size of the parser's stacks.  */
1006*1031c584SApple OSS Distributions #ifndef YYINITDEPTH
1007*1031c584SApple OSS Distributions # define YYINITDEPTH 200
1008*1031c584SApple OSS Distributions #endif
1009*1031c584SApple OSS Distributions 
1010*1031c584SApple OSS Distributions /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1011*1031c584SApple OSS Distributions  *  if the built-in stack extension method is used).
1012*1031c584SApple OSS Distributions  *
1013*1031c584SApple OSS Distributions  *  Do not make this value too large; the results are undefined if
1014*1031c584SApple OSS Distributions  *  YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1015*1031c584SApple OSS Distributions  *  evaluated with infinite-precision integer arithmetic.  */
1016*1031c584SApple OSS Distributions 
1017*1031c584SApple OSS Distributions #ifndef YYMAXDEPTH
1018*1031c584SApple OSS Distributions # define YYMAXDEPTH 10000
1019*1031c584SApple OSS Distributions #endif
1020*1031c584SApple OSS Distributions 
1021*1031c584SApple OSS Distributions 
1022*1031c584SApple OSS Distributions 
1023*1031c584SApple OSS Distributions #if YYERROR_VERBOSE
1024*1031c584SApple OSS Distributions 
1025*1031c584SApple OSS Distributions # ifndef yystrlen
1026*1031c584SApple OSS Distributions #  if defined __GLIBC__ && defined _STRING_H
1027*1031c584SApple OSS Distributions #   define yystrlen strlen
1028*1031c584SApple OSS Distributions #  else
1029*1031c584SApple OSS Distributions /* Return the length of YYSTR.  */
1030*1031c584SApple OSS Distributions #if (defined __STDC__ || defined __C99__FUNC__ \
1031*1031c584SApple OSS Distributions         || defined __cplusplus || defined _MSC_VER)
1032*1031c584SApple OSS Distributions static YYSIZE_T
yystrlen(const char * yystr)1033*1031c584SApple OSS Distributions yystrlen(const char *yystr)
1034*1031c584SApple OSS Distributions #else
1035*1031c584SApple OSS Distributions static YYSIZE_T
1036*1031c584SApple OSS Distributions     yystrlen(yystr)
1037*1031c584SApple OSS Distributions const char *yystr;
1038*1031c584SApple OSS Distributions #endif
1039*1031c584SApple OSS Distributions {
1040*1031c584SApple OSS Distributions 	YYSIZE_T yylen;
1041*1031c584SApple OSS Distributions 	for (yylen = 0; yystr[yylen]; yylen++) {
1042*1031c584SApple OSS Distributions 		continue;
1043*1031c584SApple OSS Distributions 	}
1044*1031c584SApple OSS Distributions 	return yylen;
1045*1031c584SApple OSS Distributions }
1046*1031c584SApple OSS Distributions #  endif
1047*1031c584SApple OSS Distributions # endif
1048*1031c584SApple OSS Distributions 
1049*1031c584SApple OSS Distributions # ifndef yystpcpy
1050*1031c584SApple OSS Distributions #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1051*1031c584SApple OSS Distributions #   define yystpcpy stpcpy
1052*1031c584SApple OSS Distributions #  else
1053*1031c584SApple OSS Distributions /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1054*1031c584SApple OSS Distributions  *  YYDEST.  */
1055*1031c584SApple OSS Distributions #if (defined __STDC__ || defined __C99__FUNC__ \
1056*1031c584SApple OSS Distributions         || defined __cplusplus || defined _MSC_VER)
1057*1031c584SApple OSS Distributions static char *
yystpcpy(char * yydest,const char * yysrc)1058*1031c584SApple OSS Distributions yystpcpy(char *yydest, const char *yysrc)
1059*1031c584SApple OSS Distributions #else
1060*1031c584SApple OSS Distributions static char *
1061*1031c584SApple OSS Distributions yystpcpy(yydest, yysrc)
1062*1031c584SApple OSS Distributions char *yydest;
1063*1031c584SApple OSS Distributions const char *yysrc;
1064*1031c584SApple OSS Distributions #endif
1065*1031c584SApple OSS Distributions {
1066*1031c584SApple OSS Distributions 	char *yyd = yydest;
1067*1031c584SApple OSS Distributions 	const char *yys = yysrc;
1068*1031c584SApple OSS Distributions 
1069*1031c584SApple OSS Distributions 	while ((*yyd++ = *yys++) != '\0') {
1070*1031c584SApple OSS Distributions 		continue;
1071*1031c584SApple OSS Distributions 	}
1072*1031c584SApple OSS Distributions 
1073*1031c584SApple OSS Distributions 	return yyd - 1;
1074*1031c584SApple OSS Distributions }
1075*1031c584SApple OSS Distributions #  endif
1076*1031c584SApple OSS Distributions # endif
1077*1031c584SApple OSS Distributions 
1078*1031c584SApple OSS Distributions # ifndef yytnamerr
1079*1031c584SApple OSS Distributions /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1080*1031c584SApple OSS Distributions  *  quotes and backslashes, so that it's suitable for yyerror.  The
1081*1031c584SApple OSS Distributions  *  heuristic is that double-quoting is unnecessary unless the string
1082*1031c584SApple OSS Distributions  *  contains an apostrophe, a comma, or backslash (other than
1083*1031c584SApple OSS Distributions  *  backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
1084*1031c584SApple OSS Distributions  *  null, do not copy; instead, return the length of what the result
1085*1031c584SApple OSS Distributions  *  would have been.  */
1086*1031c584SApple OSS Distributions static YYSIZE_T
yytnamerr(char * yyres,const char * yystr)1087*1031c584SApple OSS Distributions yytnamerr(char *yyres, const char *yystr)
1088*1031c584SApple OSS Distributions {
1089*1031c584SApple OSS Distributions 	if (*yystr == '"') {
1090*1031c584SApple OSS Distributions 		YYSIZE_T yyn = 0;
1091*1031c584SApple OSS Distributions 		char const *yyp = yystr;
1092*1031c584SApple OSS Distributions 
1093*1031c584SApple OSS Distributions 		for (;;) {
1094*1031c584SApple OSS Distributions 			switch (*++yyp) {
1095*1031c584SApple OSS Distributions 			case '\'':
1096*1031c584SApple OSS Distributions 			case ',':
1097*1031c584SApple OSS Distributions 				goto do_not_strip_quotes;
1098*1031c584SApple OSS Distributions 
1099*1031c584SApple OSS Distributions 			case '\\':
1100*1031c584SApple OSS Distributions 				if (*++yyp != '\\') {
1101*1031c584SApple OSS Distributions 					goto do_not_strip_quotes;
1102*1031c584SApple OSS Distributions 				}
1103*1031c584SApple OSS Distributions 			/* Fall through.  */
1104*1031c584SApple OSS Distributions 			default:
1105*1031c584SApple OSS Distributions 				if (yyres) {
1106*1031c584SApple OSS Distributions 					yyres[yyn] = *yyp;
1107*1031c584SApple OSS Distributions 				}
1108*1031c584SApple OSS Distributions 				yyn++;
1109*1031c584SApple OSS Distributions 				break;
1110*1031c584SApple OSS Distributions 
1111*1031c584SApple OSS Distributions 			case '"':
1112*1031c584SApple OSS Distributions 				if (yyres) {
1113*1031c584SApple OSS Distributions 					yyres[yyn] = '\0';
1114*1031c584SApple OSS Distributions 				}
1115*1031c584SApple OSS Distributions 				return yyn;
1116*1031c584SApple OSS Distributions 			}
1117*1031c584SApple OSS Distributions 		}
1118*1031c584SApple OSS Distributions do_not_strip_quotes:;
1119*1031c584SApple OSS Distributions 	}
1120*1031c584SApple OSS Distributions 
1121*1031c584SApple OSS Distributions 	if (!yyres) {
1122*1031c584SApple OSS Distributions 		return yystrlen(yystr);
1123*1031c584SApple OSS Distributions 	}
1124*1031c584SApple OSS Distributions 
1125*1031c584SApple OSS Distributions 	return yystpcpy(yyres, yystr) - yyres;
1126*1031c584SApple OSS Distributions }
1127*1031c584SApple OSS Distributions # endif
1128*1031c584SApple OSS Distributions 
1129*1031c584SApple OSS Distributions /* Copy into YYRESULT an error message about the unexpected token
1130*1031c584SApple OSS Distributions  *  YYCHAR while in state YYSTATE.  Return the number of bytes copied,
1131*1031c584SApple OSS Distributions  *  including the terminating null byte.  If YYRESULT is null, do not
1132*1031c584SApple OSS Distributions  *  copy anything; just return the number of bytes that would be
1133*1031c584SApple OSS Distributions  *  copied.  As a special case, return 0 if an ordinary "syntax error"
1134*1031c584SApple OSS Distributions  *  message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
1135*1031c584SApple OSS Distributions  *  size calculation.  */
1136*1031c584SApple OSS Distributions static YYSIZE_T
yysyntax_error(char * yyresult,int yystate,int yychar)1137*1031c584SApple OSS Distributions yysyntax_error(char *yyresult, int yystate, int yychar)
1138*1031c584SApple OSS Distributions {
1139*1031c584SApple OSS Distributions 	int yyn = yypact[yystate];
1140*1031c584SApple OSS Distributions 
1141*1031c584SApple OSS Distributions 	if (!(YYPACT_NINF < yyn && yyn <= YYLAST)) {
1142*1031c584SApple OSS Distributions 		return 0;
1143*1031c584SApple OSS Distributions 	} else {
1144*1031c584SApple OSS Distributions 		int yytype = YYTRANSLATE(yychar);
1145*1031c584SApple OSS Distributions 		YYSIZE_T yysize0 = yytnamerr(0, yytname[yytype]);
1146*1031c584SApple OSS Distributions 		YYSIZE_T yysize = yysize0;
1147*1031c584SApple OSS Distributions 		YYSIZE_T yysize1;
1148*1031c584SApple OSS Distributions 		int yysize_overflow = 0;
1149*1031c584SApple OSS Distributions 		enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1150*1031c584SApple OSS Distributions 		char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1151*1031c584SApple OSS Distributions 		int yyx;
1152*1031c584SApple OSS Distributions 
1153*1031c584SApple OSS Distributions # if 0
1154*1031c584SApple OSS Distributions 		/* This is so xgettext sees the translatable formats that are
1155*1031c584SApple OSS Distributions 		 *  constructed on the fly.  */
1156*1031c584SApple OSS Distributions 		YY_("syntax error, unexpected %s");
1157*1031c584SApple OSS Distributions 		YY_("syntax error, unexpected %s, expecting %s");
1158*1031c584SApple OSS Distributions 		YY_("syntax error, unexpected %s, expecting %s or %s");
1159*1031c584SApple OSS Distributions 		YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1160*1031c584SApple OSS Distributions 		YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1161*1031c584SApple OSS Distributions # endif
1162*1031c584SApple OSS Distributions 		char *yyfmt;
1163*1031c584SApple OSS Distributions 		char const *yyf;
1164*1031c584SApple OSS Distributions 		static char const yyunexpected[] = "syntax error, unexpected %s";
1165*1031c584SApple OSS Distributions 		static char const yyexpecting[] = ", expecting %s";
1166*1031c584SApple OSS Distributions 		static char const yyor[] = " or %s";
1167*1031c584SApple OSS Distributions 		char yyformat[sizeof yyunexpected
1168*1031c584SApple OSS Distributions 		+ sizeof yyexpecting - 1
1169*1031c584SApple OSS Distributions 		+ ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1170*1031c584SApple OSS Distributions 		* (sizeof yyor - 1))];
1171*1031c584SApple OSS Distributions 		char const *yyprefix = yyexpecting;
1172*1031c584SApple OSS Distributions 
1173*1031c584SApple OSS Distributions 		/* Start YYX at -YYN if negative to avoid negative indexes in
1174*1031c584SApple OSS Distributions 		 *  YYCHECK.  */
1175*1031c584SApple OSS Distributions 		int yyxbegin = yyn < 0 ? -yyn : 0;
1176*1031c584SApple OSS Distributions 
1177*1031c584SApple OSS Distributions 		/* Stay within bounds of both yycheck and yytname.  */
1178*1031c584SApple OSS Distributions 		int yychecklim = YYLAST - yyn + 1;
1179*1031c584SApple OSS Distributions 		int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1180*1031c584SApple OSS Distributions 		int yycount = 1;
1181*1031c584SApple OSS Distributions 
1182*1031c584SApple OSS Distributions 		yyarg[0] = yytname[yytype];
1183*1031c584SApple OSS Distributions 		yyfmt = yystpcpy(yyformat, yyunexpected);
1184*1031c584SApple OSS Distributions 
1185*1031c584SApple OSS Distributions 		for (yyx = yyxbegin; yyx < yyxend; ++yyx) {
1186*1031c584SApple OSS Distributions 			if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) {
1187*1031c584SApple OSS Distributions 				if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) {
1188*1031c584SApple OSS Distributions 					yycount = 1;
1189*1031c584SApple OSS Distributions 					yysize = yysize0;
1190*1031c584SApple OSS Distributions 					yyformat[sizeof yyunexpected - 1] = '\0';
1191*1031c584SApple OSS Distributions 					break;
1192*1031c584SApple OSS Distributions 				}
1193*1031c584SApple OSS Distributions 				yyarg[yycount++] = yytname[yyx];
1194*1031c584SApple OSS Distributions 				yysize1 = yysize + yytnamerr(0, yytname[yyx]);
1195*1031c584SApple OSS Distributions 				yysize_overflow |= (yysize1 < yysize);
1196*1031c584SApple OSS Distributions 				yysize = yysize1;
1197*1031c584SApple OSS Distributions 				yyfmt = yystpcpy(yyfmt, yyprefix);
1198*1031c584SApple OSS Distributions 				yyprefix = yyor;
1199*1031c584SApple OSS Distributions 			}
1200*1031c584SApple OSS Distributions 		}
1201*1031c584SApple OSS Distributions 
1202*1031c584SApple OSS Distributions 		yyf = YY_(yyformat);
1203*1031c584SApple OSS Distributions 		yysize1 = yysize + yystrlen(yyf);
1204*1031c584SApple OSS Distributions 		yysize_overflow |= (yysize1 < yysize);
1205*1031c584SApple OSS Distributions 		yysize = yysize1;
1206*1031c584SApple OSS Distributions 
1207*1031c584SApple OSS Distributions 		if (yysize_overflow) {
1208*1031c584SApple OSS Distributions 			return YYSIZE_MAXIMUM;
1209*1031c584SApple OSS Distributions 		}
1210*1031c584SApple OSS Distributions 
1211*1031c584SApple OSS Distributions 		if (yyresult) {
1212*1031c584SApple OSS Distributions 			/* Avoid sprintf, as that infringes on the user's name space.
1213*1031c584SApple OSS Distributions 			 *  Don't have undefined behavior even if the translation
1214*1031c584SApple OSS Distributions 			 *  produced a string with the wrong number of "%s"s.  */
1215*1031c584SApple OSS Distributions 			char *yyp = yyresult;
1216*1031c584SApple OSS Distributions 			int yyi = 0;
1217*1031c584SApple OSS Distributions 			while ((*yyp = *yyf) != '\0') {
1218*1031c584SApple OSS Distributions 				if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) {
1219*1031c584SApple OSS Distributions 					yyp += yytnamerr(yyp, yyarg[yyi++]);
1220*1031c584SApple OSS Distributions 					yyf += 2;
1221*1031c584SApple OSS Distributions 				} else {
1222*1031c584SApple OSS Distributions 					yyp++;
1223*1031c584SApple OSS Distributions 					yyf++;
1224*1031c584SApple OSS Distributions 				}
1225*1031c584SApple OSS Distributions 			}
1226*1031c584SApple OSS Distributions 		}
1227*1031c584SApple OSS Distributions 		return yysize;
1228*1031c584SApple OSS Distributions 	}
1229*1031c584SApple OSS Distributions }
1230*1031c584SApple OSS Distributions #endif /* YYERROR_VERBOSE */
1231*1031c584SApple OSS Distributions 
1232*1031c584SApple OSS Distributions 
1233*1031c584SApple OSS Distributions /*-----------------------------------------------.
1234*1031c584SApple OSS Distributions  | Release the memory associated to this symbol.  |
1235*1031c584SApple OSS Distributions  |   `-----------------------------------------------*/
1236*1031c584SApple OSS Distributions 
1237*1031c584SApple OSS Distributions /*ARGSUSED*/
1238*1031c584SApple OSS Distributions #if (defined __STDC__ || defined __C99__FUNC__ \
1239*1031c584SApple OSS Distributions         || defined __cplusplus || defined _MSC_VER)
1240*1031c584SApple OSS Distributions static void
yydestruct(const char * yymsg,int yytype,YYSTYPE * yyvaluep)1241*1031c584SApple OSS Distributions yydestruct(const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1242*1031c584SApple OSS Distributions #else
1243*1031c584SApple OSS Distributions static void
1244*1031c584SApple OSS Distributions     yydestruct(yymsg, yytype, yyvaluep)
1245*1031c584SApple OSS Distributions const char *yymsg;
1246*1031c584SApple OSS Distributions int yytype;
1247*1031c584SApple OSS Distributions YYSTYPE *yyvaluep;
1248*1031c584SApple OSS Distributions #endif
1249*1031c584SApple OSS Distributions {
1250*1031c584SApple OSS Distributions 	YYUSE(yyvaluep);
1251*1031c584SApple OSS Distributions 
1252*1031c584SApple OSS Distributions 	if (!yymsg) {
1253*1031c584SApple OSS Distributions 		yymsg = "Deleting";
1254*1031c584SApple OSS Distributions 	}
1255*1031c584SApple OSS Distributions 	YY_SYMBOL_PRINT(yymsg, yytype, yyvaluep, yylocationp);
1256*1031c584SApple OSS Distributions 
1257*1031c584SApple OSS Distributions 	switch (yytype) {
1258*1031c584SApple OSS Distributions 	default:
1259*1031c584SApple OSS Distributions 		break;
1260*1031c584SApple OSS Distributions 	}
1261*1031c584SApple OSS Distributions }
1262*1031c584SApple OSS Distributions 
1263*1031c584SApple OSS Distributions 
1264*1031c584SApple OSS Distributions /* Prevent warnings from -Wmissing-prototypes.  */
1265*1031c584SApple OSS Distributions 
1266*1031c584SApple OSS Distributions #ifdef YYPARSE_PARAM
1267*1031c584SApple OSS Distributions #if defined __STDC__ || defined __cplusplus
1268*1031c584SApple OSS Distributions int yyparse(void *YYPARSE_PARAM);
1269*1031c584SApple OSS Distributions #else
1270*1031c584SApple OSS Distributions int yyparse();
1271*1031c584SApple OSS Distributions #endif
1272*1031c584SApple OSS Distributions #else /* ! YYPARSE_PARAM */
1273*1031c584SApple OSS Distributions #if defined __STDC__ || defined __cplusplus
1274*1031c584SApple OSS Distributions int yyparse(void);
1275*1031c584SApple OSS Distributions #else
1276*1031c584SApple OSS Distributions int yyparse();
1277*1031c584SApple OSS Distributions #endif
1278*1031c584SApple OSS Distributions #endif /* ! YYPARSE_PARAM */
1279*1031c584SApple OSS Distributions 
1280*1031c584SApple OSS Distributions 
1281*1031c584SApple OSS Distributions 
1282*1031c584SApple OSS Distributions 
1283*1031c584SApple OSS Distributions 
1284*1031c584SApple OSS Distributions 
1285*1031c584SApple OSS Distributions /*----------.
1286*1031c584SApple OSS Distributions  | yyparse.  |
1287*1031c584SApple OSS Distributions  |   `----------*/
1288*1031c584SApple OSS Distributions 
1289*1031c584SApple OSS Distributions #ifdef YYPARSE_PARAM
1290*1031c584SApple OSS Distributions #if (defined __STDC__ || defined __C99__FUNC__ \
1291*1031c584SApple OSS Distributions         || defined __cplusplus || defined _MSC_VER)
1292*1031c584SApple OSS Distributions int
yyparse(void * YYPARSE_PARAM)1293*1031c584SApple OSS Distributions yyparse(void *YYPARSE_PARAM)
1294*1031c584SApple OSS Distributions #else
1295*1031c584SApple OSS Distributions int
1296*1031c584SApple OSS Distributions     yyparse(YYPARSE_PARAM)
1297*1031c584SApple OSS Distributions void *YYPARSE_PARAM;
1298*1031c584SApple OSS Distributions #endif
1299*1031c584SApple OSS Distributions #else /* ! YYPARSE_PARAM */
1300*1031c584SApple OSS Distributions #if (defined __STDC__ || defined __C99__FUNC__ \
1301*1031c584SApple OSS Distributions         || defined __cplusplus || defined _MSC_VER)
1302*1031c584SApple OSS Distributions int
1303*1031c584SApple OSS Distributions yyparse(void)
1304*1031c584SApple OSS Distributions #else
1305*1031c584SApple OSS Distributions int
1306*1031c584SApple OSS Distributions yyparse()
1307*1031c584SApple OSS Distributions 
1308*1031c584SApple OSS Distributions #endif
1309*1031c584SApple OSS Distributions #endif
1310*1031c584SApple OSS Distributions {
1311*1031c584SApple OSS Distributions 	/* The look-ahead symbol.  */
1312*1031c584SApple OSS Distributions 	int yychar;
1313*1031c584SApple OSS Distributions 
1314*1031c584SApple OSS Distributions /* The semantic value of the look-ahead symbol.  */
1315*1031c584SApple OSS Distributions 	YYSTYPE yylval;
1316*1031c584SApple OSS Distributions 
1317*1031c584SApple OSS Distributions /* Number of syntax errors so far.  */
1318*1031c584SApple OSS Distributions 	int yynerrs;
1319*1031c584SApple OSS Distributions 
1320*1031c584SApple OSS Distributions 	int yystate;
1321*1031c584SApple OSS Distributions 	int yyn;
1322*1031c584SApple OSS Distributions 	int yyresult;
1323*1031c584SApple OSS Distributions 	/* Number of tokens to shift before error messages enabled.  */
1324*1031c584SApple OSS Distributions 	int yyerrstatus;
1325*1031c584SApple OSS Distributions 	/* Look-ahead token as an internal (translated) token number.  */
1326*1031c584SApple OSS Distributions 	int yytoken = 0;
1327*1031c584SApple OSS Distributions #if YYERROR_VERBOSE
1328*1031c584SApple OSS Distributions 	/* Buffer for error messages, and its allocated size.  */
1329*1031c584SApple OSS Distributions 	char yymsgbuf[128];
1330*1031c584SApple OSS Distributions 	char *yymsg = yymsgbuf;
1331*1031c584SApple OSS Distributions 	YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1332*1031c584SApple OSS Distributions #endif
1333*1031c584SApple OSS Distributions 
1334*1031c584SApple OSS Distributions 	/* Three stacks and their tools:
1335*1031c584SApple OSS Distributions 	 *  `yyss': related to states,
1336*1031c584SApple OSS Distributions 	 *  `yyvs': related to semantic values,
1337*1031c584SApple OSS Distributions 	 *  `yyls': related to locations.
1338*1031c584SApple OSS Distributions 	 *
1339*1031c584SApple OSS Distributions 	 *  Refer to the stacks thru separate pointers, to allow yyoverflow
1340*1031c584SApple OSS Distributions 	 *  to reallocate them elsewhere.  */
1341*1031c584SApple OSS Distributions 
1342*1031c584SApple OSS Distributions 	/* The state stack.  */
1343*1031c584SApple OSS Distributions 	yytype_int16 yyssa[YYINITDEPTH];
1344*1031c584SApple OSS Distributions 	yytype_int16 *yyss = yyssa;
1345*1031c584SApple OSS Distributions 	yytype_int16 *yyssp;
1346*1031c584SApple OSS Distributions 
1347*1031c584SApple OSS Distributions 	/* The semantic value stack.  */
1348*1031c584SApple OSS Distributions 	YYSTYPE yyvsa[YYINITDEPTH];
1349*1031c584SApple OSS Distributions 	YYSTYPE *yyvs = yyvsa;
1350*1031c584SApple OSS Distributions 	YYSTYPE *yyvsp;
1351*1031c584SApple OSS Distributions 
1352*1031c584SApple OSS Distributions 
1353*1031c584SApple OSS Distributions 
1354*1031c584SApple OSS Distributions #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1355*1031c584SApple OSS Distributions 
1356*1031c584SApple OSS Distributions 	YYSIZE_T yystacksize = YYINITDEPTH;
1357*1031c584SApple OSS Distributions 
1358*1031c584SApple OSS Distributions 	/* The variables used to return semantic value and location from the
1359*1031c584SApple OSS Distributions 	 *  action routines.  */
1360*1031c584SApple OSS Distributions 	YYSTYPE yyval;
1361*1031c584SApple OSS Distributions 
1362*1031c584SApple OSS Distributions 
1363*1031c584SApple OSS Distributions 	/* The number of symbols on the RHS of the reduced rule.
1364*1031c584SApple OSS Distributions 	 *  Keep to zero when no symbol should be popped.  */
1365*1031c584SApple OSS Distributions 	int yylen = 0;
1366*1031c584SApple OSS Distributions 
1367*1031c584SApple OSS Distributions 	YYDPRINTF((stderr, "Starting parse\n"));
1368*1031c584SApple OSS Distributions 
1369*1031c584SApple OSS Distributions 	yystate = 0;
1370*1031c584SApple OSS Distributions 	yyerrstatus = 0;
1371*1031c584SApple OSS Distributions 	yynerrs = 0;
1372*1031c584SApple OSS Distributions 	yychar = YYEMPTY;       /* Cause a token to be read.  */
1373*1031c584SApple OSS Distributions 
1374*1031c584SApple OSS Distributions 	/* Initialize stack pointers.
1375*1031c584SApple OSS Distributions 	 *  Waste one element of value and location stack
1376*1031c584SApple OSS Distributions 	 *  so that they stay on the same level as the state stack.
1377*1031c584SApple OSS Distributions 	 *  The wasted elements are never initialized.  */
1378*1031c584SApple OSS Distributions 
1379*1031c584SApple OSS Distributions 	yyssp = yyss;
1380*1031c584SApple OSS Distributions 	yyvsp = yyvs;
1381*1031c584SApple OSS Distributions 
1382*1031c584SApple OSS Distributions 	goto yysetstate;
1383*1031c584SApple OSS Distributions 
1384*1031c584SApple OSS Distributions /*------------------------------------------------------------.
1385*1031c584SApple OSS Distributions  | yynewstate -- Push a new state, which is found in yystate.  |
1386*1031c584SApple OSS Distributions  |   `------------------------------------------------------------*/
1387*1031c584SApple OSS Distributions yynewstate:
1388*1031c584SApple OSS Distributions 	/* In all cases, when you get here, the value and location stacks
1389*1031c584SApple OSS Distributions 	 *  have just been pushed.  So pushing a state here evens the stacks.  */
1390*1031c584SApple OSS Distributions 	yyssp++;
1391*1031c584SApple OSS Distributions 
1392*1031c584SApple OSS Distributions yysetstate:
1393*1031c584SApple OSS Distributions 	*yyssp = yystate;
1394*1031c584SApple OSS Distributions 
1395*1031c584SApple OSS Distributions 	if (yyss + yystacksize - 1 <= yyssp) {
1396*1031c584SApple OSS Distributions 		/* Get the current used size of the three stacks, in elements.  */
1397*1031c584SApple OSS Distributions 		YYSIZE_T yysize = yyssp - yyss + 1;
1398*1031c584SApple OSS Distributions 
1399*1031c584SApple OSS Distributions #ifdef yyoverflow
1400*1031c584SApple OSS Distributions 		{
1401*1031c584SApple OSS Distributions 			/* Give user a chance to reallocate the stack.  Use copies of
1402*1031c584SApple OSS Distributions 			 *  these so that the &'s don't force the real ones into
1403*1031c584SApple OSS Distributions 			 *  memory.  */
1404*1031c584SApple OSS Distributions 			YYSTYPE *yyvs1 = yyvs;
1405*1031c584SApple OSS Distributions 			yytype_int16 *yyss1 = yyss;
1406*1031c584SApple OSS Distributions 
1407*1031c584SApple OSS Distributions 
1408*1031c584SApple OSS Distributions 			/* Each stack pointer address is followed by the size of the
1409*1031c584SApple OSS Distributions 			 *  data in use in that stack, in bytes.  This used to be a
1410*1031c584SApple OSS Distributions 			 *  conditional around just the two extra args, but that might
1411*1031c584SApple OSS Distributions 			 *  be undefined if yyoverflow is a macro.  */
1412*1031c584SApple OSS Distributions 			yyoverflow(YY_("memory exhausted"),
1413*1031c584SApple OSS Distributions 			    &yyss1, yysize * sizeof(*yyssp),
1414*1031c584SApple OSS Distributions 			    &yyvs1, yysize * sizeof(*yyvsp),
1415*1031c584SApple OSS Distributions 
1416*1031c584SApple OSS Distributions 			    &yystacksize);
1417*1031c584SApple OSS Distributions 
1418*1031c584SApple OSS Distributions 			yyss = yyss1;
1419*1031c584SApple OSS Distributions 			yyvs = yyvs1;
1420*1031c584SApple OSS Distributions 		}
1421*1031c584SApple OSS Distributions #else /* no yyoverflow */
1422*1031c584SApple OSS Distributions # ifndef YYSTACK_RELOCATE
1423*1031c584SApple OSS Distributions 		goto yyexhaustedlab;
1424*1031c584SApple OSS Distributions # else
1425*1031c584SApple OSS Distributions 		/* Extend the stack our own way.  */
1426*1031c584SApple OSS Distributions 		if (YYMAXDEPTH <= yystacksize) {
1427*1031c584SApple OSS Distributions 			goto yyexhaustedlab;
1428*1031c584SApple OSS Distributions 		}
1429*1031c584SApple OSS Distributions 		yystacksize *= 2;
1430*1031c584SApple OSS Distributions 		if (YYMAXDEPTH < yystacksize) {
1431*1031c584SApple OSS Distributions 			yystacksize = YYMAXDEPTH;
1432*1031c584SApple OSS Distributions 		}
1433*1031c584SApple OSS Distributions 
1434*1031c584SApple OSS Distributions 		{
1435*1031c584SApple OSS Distributions 			yytype_int16 *yyss1 = yyss;
1436*1031c584SApple OSS Distributions 			union yyalloc *yyptr =
1437*1031c584SApple OSS Distributions 			    (union yyalloc *) YYSTACK_ALLOC(YYSTACK_BYTES(yystacksize));
1438*1031c584SApple OSS Distributions 			if (!yyptr) {
1439*1031c584SApple OSS Distributions 				goto yyexhaustedlab;
1440*1031c584SApple OSS Distributions 			}
1441*1031c584SApple OSS Distributions 			YYSTACK_RELOCATE(yyss);
1442*1031c584SApple OSS Distributions 			YYSTACK_RELOCATE(yyvs);
1443*1031c584SApple OSS Distributions 
1444*1031c584SApple OSS Distributions #  undef YYSTACK_RELOCATE
1445*1031c584SApple OSS Distributions 			if (yyss1 != yyssa) {
1446*1031c584SApple OSS Distributions 				YYSTACK_FREE(yyss1);
1447*1031c584SApple OSS Distributions 			}
1448*1031c584SApple OSS Distributions 		}
1449*1031c584SApple OSS Distributions # endif
1450*1031c584SApple OSS Distributions #endif /* no yyoverflow */
1451*1031c584SApple OSS Distributions 
1452*1031c584SApple OSS Distributions 		yyssp = yyss + yysize - 1;
1453*1031c584SApple OSS Distributions 		yyvsp = yyvs + yysize - 1;
1454*1031c584SApple OSS Distributions 
1455*1031c584SApple OSS Distributions 
1456*1031c584SApple OSS Distributions 		YYDPRINTF((stderr, "Stack size increased to %lu\n",
1457*1031c584SApple OSS Distributions 		    (unsigned long int) yystacksize));
1458*1031c584SApple OSS Distributions 
1459*1031c584SApple OSS Distributions 		if (yyss + yystacksize - 1 <= yyssp) {
1460*1031c584SApple OSS Distributions 			YYABORT;
1461*1031c584SApple OSS Distributions 		}
1462*1031c584SApple OSS Distributions 	}
1463*1031c584SApple OSS Distributions 
1464*1031c584SApple OSS Distributions 	YYDPRINTF((stderr, "Entering state %d\n", yystate));
1465*1031c584SApple OSS Distributions 
1466*1031c584SApple OSS Distributions 	goto yybackup;
1467*1031c584SApple OSS Distributions 
1468*1031c584SApple OSS Distributions /*-----------.
1469*1031c584SApple OSS Distributions  | yybackup.  |
1470*1031c584SApple OSS Distributions  |   `-----------*/
1471*1031c584SApple OSS Distributions yybackup:
1472*1031c584SApple OSS Distributions 
1473*1031c584SApple OSS Distributions 	/* Do appropriate processing given the current state.  Read a
1474*1031c584SApple OSS Distributions 	 *  look-ahead token if we need one and don't already have one.  */
1475*1031c584SApple OSS Distributions 
1476*1031c584SApple OSS Distributions 	/* First try to decide what to do without reference to look-ahead token.  */
1477*1031c584SApple OSS Distributions 	yyn = yypact[yystate];
1478*1031c584SApple OSS Distributions 	if (yyn == YYPACT_NINF) {
1479*1031c584SApple OSS Distributions 		goto yydefault;
1480*1031c584SApple OSS Distributions 	}
1481*1031c584SApple OSS Distributions 
1482*1031c584SApple OSS Distributions 	/* Not known => get a look-ahead token if don't already have one.  */
1483*1031c584SApple OSS Distributions 
1484*1031c584SApple OSS Distributions 	/* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol.  */
1485*1031c584SApple OSS Distributions 	if (yychar == YYEMPTY) {
1486*1031c584SApple OSS Distributions 		YYDPRINTF((stderr, "Reading a token: "));
1487*1031c584SApple OSS Distributions 		yychar = YYLEX;
1488*1031c584SApple OSS Distributions 	}
1489*1031c584SApple OSS Distributions 
1490*1031c584SApple OSS Distributions 	if (yychar <= YYEOF) {
1491*1031c584SApple OSS Distributions 		yychar = yytoken = YYEOF;
1492*1031c584SApple OSS Distributions 		YYDPRINTF((stderr, "Now at end of input.\n"));
1493*1031c584SApple OSS Distributions 	} else {
1494*1031c584SApple OSS Distributions 		yytoken = YYTRANSLATE(yychar);
1495*1031c584SApple OSS Distributions 		YY_SYMBOL_PRINT("Next token is", yytoken, &yylval, &yylloc);
1496*1031c584SApple OSS Distributions 	}
1497*1031c584SApple OSS Distributions 
1498*1031c584SApple OSS Distributions 	/* If the proper action on seeing token YYTOKEN is to reduce or to
1499*1031c584SApple OSS Distributions 	 *  detect an error, take that action.  */
1500*1031c584SApple OSS Distributions 	yyn += yytoken;
1501*1031c584SApple OSS Distributions 	if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) {
1502*1031c584SApple OSS Distributions 		goto yydefault;
1503*1031c584SApple OSS Distributions 	}
1504*1031c584SApple OSS Distributions 	yyn = yytable[yyn];
1505*1031c584SApple OSS Distributions 	if (yyn <= 0) {
1506*1031c584SApple OSS Distributions 		if (yyn == 0 || yyn == YYTABLE_NINF) {
1507*1031c584SApple OSS Distributions 			goto yyerrlab;
1508*1031c584SApple OSS Distributions 		}
1509*1031c584SApple OSS Distributions 		yyn = -yyn;
1510*1031c584SApple OSS Distributions 		goto yyreduce;
1511*1031c584SApple OSS Distributions 	}
1512*1031c584SApple OSS Distributions 
1513*1031c584SApple OSS Distributions 	if (yyn == YYFINAL) {
1514*1031c584SApple OSS Distributions 		YYACCEPT;
1515*1031c584SApple OSS Distributions 	}
1516*1031c584SApple OSS Distributions 
1517*1031c584SApple OSS Distributions 	/* Count tokens shifted since error; after three, turn off error
1518*1031c584SApple OSS Distributions 	 *  status.  */
1519*1031c584SApple OSS Distributions 	if (yyerrstatus) {
1520*1031c584SApple OSS Distributions 		yyerrstatus--;
1521*1031c584SApple OSS Distributions 	}
1522*1031c584SApple OSS Distributions 
1523*1031c584SApple OSS Distributions 	/* Shift the look-ahead token.  */
1524*1031c584SApple OSS Distributions 	YY_SYMBOL_PRINT("Shifting", yytoken, &yylval, &yylloc);
1525*1031c584SApple OSS Distributions 
1526*1031c584SApple OSS Distributions 	/* Discard the shifted token unless it is eof.  */
1527*1031c584SApple OSS Distributions 	if (yychar != YYEOF) {
1528*1031c584SApple OSS Distributions 		yychar = YYEMPTY;
1529*1031c584SApple OSS Distributions 	}
1530*1031c584SApple OSS Distributions 
1531*1031c584SApple OSS Distributions 	yystate = yyn;
1532*1031c584SApple OSS Distributions 	*++yyvsp = yylval;
1533*1031c584SApple OSS Distributions 
1534*1031c584SApple OSS Distributions 	goto yynewstate;
1535*1031c584SApple OSS Distributions 
1536*1031c584SApple OSS Distributions 
1537*1031c584SApple OSS Distributions /*-----------------------------------------------------------.
1538*1031c584SApple OSS Distributions  | yydefault -- do the default action for the current state.  |
1539*1031c584SApple OSS Distributions  |   `-----------------------------------------------------------*/
1540*1031c584SApple OSS Distributions yydefault:
1541*1031c584SApple OSS Distributions 	yyn = yydefact[yystate];
1542*1031c584SApple OSS Distributions 	if (yyn == 0) {
1543*1031c584SApple OSS Distributions 		goto yyerrlab;
1544*1031c584SApple OSS Distributions 	}
1545*1031c584SApple OSS Distributions 	goto yyreduce;
1546*1031c584SApple OSS Distributions 
1547*1031c584SApple OSS Distributions 
1548*1031c584SApple OSS Distributions /*-----------------------------.
1549*1031c584SApple OSS Distributions  | yyreduce -- Do a reduction.  |
1550*1031c584SApple OSS Distributions  |   `-----------------------------*/
1551*1031c584SApple OSS Distributions yyreduce:
1552*1031c584SApple OSS Distributions 	/* yyn is the number of a rule to reduce with.  */
1553*1031c584SApple OSS Distributions 	yylen = yyr2[yyn];
1554*1031c584SApple OSS Distributions 
1555*1031c584SApple OSS Distributions 	/* If YYLEN is nonzero, implement the default value of the action:
1556*1031c584SApple OSS Distributions 	 *  `$$ = $1'.
1557*1031c584SApple OSS Distributions 	 *
1558*1031c584SApple OSS Distributions 	 *  Otherwise, the following line sets YYVAL to garbage.
1559*1031c584SApple OSS Distributions 	 *  This behavior is undocumented and Bison
1560*1031c584SApple OSS Distributions 	 *  users should not rely upon it.  Assigning to YYVAL
1561*1031c584SApple OSS Distributions 	 *  unconditionally makes the parser a bit smaller, and it avoids a
1562*1031c584SApple OSS Distributions 	 *  GCC warning that YYVAL may be used uninitialized.  */
1563*1031c584SApple OSS Distributions 	yyval = yyvsp[1 - yylen];
1564*1031c584SApple OSS Distributions 
1565*1031c584SApple OSS Distributions 
1566*1031c584SApple OSS Distributions 	YY_REDUCE_PRINT(yyn);
1567*1031c584SApple OSS Distributions 	switch (yyn) {
1568*1031c584SApple OSS Distributions 	case 2:
1569*1031c584SApple OSS Distributions #line 217 "OSUnserializeXML.y"
1570*1031c584SApple OSS Distributions 		{ yyerror("unexpected end of buffer");
1571*1031c584SApple OSS Distributions 		  YYERROR;
1572*1031c584SApple OSS Distributions 		  ;}
1573*1031c584SApple OSS Distributions 		break;
1574*1031c584SApple OSS Distributions 
1575*1031c584SApple OSS Distributions 	case 3:
1576*1031c584SApple OSS Distributions #line 220 "OSUnserializeXML.y"
1577*1031c584SApple OSS Distributions 		{ STATE->parsedObject = (yyvsp[(1) - (1)])->object;
1578*1031c584SApple OSS Distributions 		  (yyvsp[(1) - (1)])->object = 0;
1579*1031c584SApple OSS Distributions 		  freeObject(STATE, (yyvsp[(1) - (1)]));
1580*1031c584SApple OSS Distributions 		  YYACCEPT;
1581*1031c584SApple OSS Distributions 		  ;}
1582*1031c584SApple OSS Distributions 		break;
1583*1031c584SApple OSS Distributions 
1584*1031c584SApple OSS Distributions 	case 4:
1585*1031c584SApple OSS Distributions #line 225 "OSUnserializeXML.y"
1586*1031c584SApple OSS Distributions 		{ yyerror("syntax error");
1587*1031c584SApple OSS Distributions 		  YYERROR;
1588*1031c584SApple OSS Distributions 		  ;}
1589*1031c584SApple OSS Distributions 		break;
1590*1031c584SApple OSS Distributions 
1591*1031c584SApple OSS Distributions 	case 5:
1592*1031c584SApple OSS Distributions #line 230 "OSUnserializeXML.y"
1593*1031c584SApple OSS Distributions 		{ (yyval) = buildDictionary(STATE, (yyvsp[(1) - (1)]));
1594*1031c584SApple OSS Distributions 
1595*1031c584SApple OSS Distributions 		  if (!yyval->object) {
1596*1031c584SApple OSS Distributions 			  yyerror("buildDictionary");
1597*1031c584SApple OSS Distributions 			  YYERROR;
1598*1031c584SApple OSS Distributions 		  }
1599*1031c584SApple OSS Distributions 		  STATE->parsedObjectCount++;
1600*1031c584SApple OSS Distributions 		  if (STATE->parsedObjectCount > MAX_OBJECTS) {
1601*1031c584SApple OSS Distributions 			  yyerror("maximum object count");
1602*1031c584SApple OSS Distributions 			  YYERROR;
1603*1031c584SApple OSS Distributions 		  }
1604*1031c584SApple OSS Distributions 		  ;}
1605*1031c584SApple OSS Distributions 		break;
1606*1031c584SApple OSS Distributions 
1607*1031c584SApple OSS Distributions 	case 6:
1608*1031c584SApple OSS Distributions #line 242 "OSUnserializeXML.y"
1609*1031c584SApple OSS Distributions 		{ (yyval) = buildArray(STATE, (yyvsp[(1) - (1)]));
1610*1031c584SApple OSS Distributions 
1611*1031c584SApple OSS Distributions 		  if (!yyval->object) {
1612*1031c584SApple OSS Distributions 			  yyerror("buildArray");
1613*1031c584SApple OSS Distributions 			  YYERROR;
1614*1031c584SApple OSS Distributions 		  }
1615*1031c584SApple OSS Distributions 		  STATE->parsedObjectCount++;
1616*1031c584SApple OSS Distributions 		  if (STATE->parsedObjectCount > MAX_OBJECTS) {
1617*1031c584SApple OSS Distributions 			  yyerror("maximum object count");
1618*1031c584SApple OSS Distributions 			  YYERROR;
1619*1031c584SApple OSS Distributions 		  }
1620*1031c584SApple OSS Distributions 		  ;}
1621*1031c584SApple OSS Distributions 		break;
1622*1031c584SApple OSS Distributions 
1623*1031c584SApple OSS Distributions 	case 7:
1624*1031c584SApple OSS Distributions #line 254 "OSUnserializeXML.y"
1625*1031c584SApple OSS Distributions 		{ (yyval) = buildSet(STATE, (yyvsp[(1) - (1)]));
1626*1031c584SApple OSS Distributions 
1627*1031c584SApple OSS Distributions 		  if (!yyval->object) {
1628*1031c584SApple OSS Distributions 			  yyerror("buildSet");
1629*1031c584SApple OSS Distributions 			  YYERROR;
1630*1031c584SApple OSS Distributions 		  }
1631*1031c584SApple OSS Distributions 		  STATE->parsedObjectCount++;
1632*1031c584SApple OSS Distributions 		  if (STATE->parsedObjectCount > MAX_OBJECTS) {
1633*1031c584SApple OSS Distributions 			  yyerror("maximum object count");
1634*1031c584SApple OSS Distributions 			  YYERROR;
1635*1031c584SApple OSS Distributions 		  }
1636*1031c584SApple OSS Distributions 		  ;}
1637*1031c584SApple OSS Distributions 		break;
1638*1031c584SApple OSS Distributions 
1639*1031c584SApple OSS Distributions 	case 8:
1640*1031c584SApple OSS Distributions #line 266 "OSUnserializeXML.y"
1641*1031c584SApple OSS Distributions 		{ (yyval) = buildString(STATE, (yyvsp[(1) - (1)]));
1642*1031c584SApple OSS Distributions 
1643*1031c584SApple OSS Distributions 		  if (!yyval->object) {
1644*1031c584SApple OSS Distributions 			  yyerror("buildString");
1645*1031c584SApple OSS Distributions 			  YYERROR;
1646*1031c584SApple OSS Distributions 		  }
1647*1031c584SApple OSS Distributions 		  STATE->parsedObjectCount++;
1648*1031c584SApple OSS Distributions 		  if (STATE->parsedObjectCount > MAX_OBJECTS) {
1649*1031c584SApple OSS Distributions 			  yyerror("maximum object count");
1650*1031c584SApple OSS Distributions 			  YYERROR;
1651*1031c584SApple OSS Distributions 		  }
1652*1031c584SApple OSS Distributions 		  ;}
1653*1031c584SApple OSS Distributions 		break;
1654*1031c584SApple OSS Distributions 
1655*1031c584SApple OSS Distributions 	case 9:
1656*1031c584SApple OSS Distributions #line 278 "OSUnserializeXML.y"
1657*1031c584SApple OSS Distributions 		{ (yyval) = buildData(STATE, (yyvsp[(1) - (1)]));
1658*1031c584SApple OSS Distributions 
1659*1031c584SApple OSS Distributions 		  if (!yyval->object) {
1660*1031c584SApple OSS Distributions 			  yyerror("buildData");
1661*1031c584SApple OSS Distributions 			  YYERROR;
1662*1031c584SApple OSS Distributions 		  }
1663*1031c584SApple OSS Distributions 		  STATE->parsedObjectCount++;
1664*1031c584SApple OSS Distributions 		  if (STATE->parsedObjectCount > MAX_OBJECTS) {
1665*1031c584SApple OSS Distributions 			  yyerror("maximum object count");
1666*1031c584SApple OSS Distributions 			  YYERROR;
1667*1031c584SApple OSS Distributions 		  }
1668*1031c584SApple OSS Distributions 		  ;}
1669*1031c584SApple OSS Distributions 		break;
1670*1031c584SApple OSS Distributions 
1671*1031c584SApple OSS Distributions 	case 10:
1672*1031c584SApple OSS Distributions #line 290 "OSUnserializeXML.y"
1673*1031c584SApple OSS Distributions 		{ (yyval) = buildNumber(STATE, (yyvsp[(1) - (1)]));
1674*1031c584SApple OSS Distributions 
1675*1031c584SApple OSS Distributions 		  if (!yyval->object) {
1676*1031c584SApple OSS Distributions 			  yyerror("buildNumber");
1677*1031c584SApple OSS Distributions 			  YYERROR;
1678*1031c584SApple OSS Distributions 		  }
1679*1031c584SApple OSS Distributions 		  STATE->parsedObjectCount++;
1680*1031c584SApple OSS Distributions 		  if (STATE->parsedObjectCount > MAX_OBJECTS) {
1681*1031c584SApple OSS Distributions 			  yyerror("maximum object count");
1682*1031c584SApple OSS Distributions 			  YYERROR;
1683*1031c584SApple OSS Distributions 		  }
1684*1031c584SApple OSS Distributions 		  ;}
1685*1031c584SApple OSS Distributions 		break;
1686*1031c584SApple OSS Distributions 
1687*1031c584SApple OSS Distributions 	case 11:
1688*1031c584SApple OSS Distributions #line 302 "OSUnserializeXML.y"
1689*1031c584SApple OSS Distributions 		{ (yyval) = buildBoolean(STATE, (yyvsp[(1) - (1)]));
1690*1031c584SApple OSS Distributions 
1691*1031c584SApple OSS Distributions 		  if (!yyval->object) {
1692*1031c584SApple OSS Distributions 			  yyerror("buildBoolean");
1693*1031c584SApple OSS Distributions 			  YYERROR;
1694*1031c584SApple OSS Distributions 		  }
1695*1031c584SApple OSS Distributions 		  STATE->parsedObjectCount++;
1696*1031c584SApple OSS Distributions 		  if (STATE->parsedObjectCount > MAX_OBJECTS) {
1697*1031c584SApple OSS Distributions 			  yyerror("maximum object count");
1698*1031c584SApple OSS Distributions 			  YYERROR;
1699*1031c584SApple OSS Distributions 		  }
1700*1031c584SApple OSS Distributions 		  ;}
1701*1031c584SApple OSS Distributions 		break;
1702*1031c584SApple OSS Distributions 
1703*1031c584SApple OSS Distributions 	case 12:
1704*1031c584SApple OSS Distributions #line 314 "OSUnserializeXML.y"
1705*1031c584SApple OSS Distributions 		{ (yyval) = retrieveObject(STATE, (yyvsp[(1) - (1)])->idref);
1706*1031c584SApple OSS Distributions 		  if ((yyval)) {
1707*1031c584SApple OSS Distributions 			  STATE->retrievedObjectCount++;
1708*1031c584SApple OSS Distributions 			  (yyval)->object->retain();
1709*1031c584SApple OSS Distributions 			  if (STATE->retrievedObjectCount > MAX_REFED_OBJECTS) {
1710*1031c584SApple OSS Distributions 				  yyerror("maximum object reference count");
1711*1031c584SApple OSS Distributions 				  YYERROR;
1712*1031c584SApple OSS Distributions 			  }
1713*1031c584SApple OSS Distributions 		  } else {
1714*1031c584SApple OSS Distributions 			  yyerror("forward reference detected");
1715*1031c584SApple OSS Distributions 			  YYERROR;
1716*1031c584SApple OSS Distributions 		  }
1717*1031c584SApple OSS Distributions 		  freeObject(STATE, (yyvsp[(1) - (1)]));
1718*1031c584SApple OSS Distributions 
1719*1031c584SApple OSS Distributions 		  STATE->parsedObjectCount++;
1720*1031c584SApple OSS Distributions 		  if (STATE->parsedObjectCount > MAX_OBJECTS) {
1721*1031c584SApple OSS Distributions 			  yyerror("maximum object count");
1722*1031c584SApple OSS Distributions 			  YYERROR;
1723*1031c584SApple OSS Distributions 		  }
1724*1031c584SApple OSS Distributions 		  ;}
1725*1031c584SApple OSS Distributions 		break;
1726*1031c584SApple OSS Distributions 
1727*1031c584SApple OSS Distributions 	case 13:
1728*1031c584SApple OSS Distributions #line 338 "OSUnserializeXML.y"
1729*1031c584SApple OSS Distributions 		{ (yyval) = (yyvsp[(1) - (2)]);
1730*1031c584SApple OSS Distributions 		  (yyval)->elements = NULL;
1731*1031c584SApple OSS Distributions 		  ;}
1732*1031c584SApple OSS Distributions 		break;
1733*1031c584SApple OSS Distributions 
1734*1031c584SApple OSS Distributions 	case 14:
1735*1031c584SApple OSS Distributions #line 341 "OSUnserializeXML.y"
1736*1031c584SApple OSS Distributions 		{ (yyval) = (yyvsp[(1) - (3)]);
1737*1031c584SApple OSS Distributions 		  (yyval)->elements = (yyvsp[(2) - (3)]);
1738*1031c584SApple OSS Distributions 		  ;}
1739*1031c584SApple OSS Distributions 		break;
1740*1031c584SApple OSS Distributions 
1741*1031c584SApple OSS Distributions 	case 17:
1742*1031c584SApple OSS Distributions #line 348 "OSUnserializeXML.y"
1743*1031c584SApple OSS Distributions 		{ (yyval) = (yyvsp[(2) - (2)]);
1744*1031c584SApple OSS Distributions 		  (yyval)->next = (yyvsp[(1) - (2)]);
1745*1031c584SApple OSS Distributions 
1746*1031c584SApple OSS Distributions 		  object_t *o;
1747*1031c584SApple OSS Distributions 		  o = (yyval)->next;
1748*1031c584SApple OSS Distributions 		  while (o) {
1749*1031c584SApple OSS Distributions 			  if (o->key == (yyval)->key) {
1750*1031c584SApple OSS Distributions 				  yyerror("duplicate dictionary key");
1751*1031c584SApple OSS Distributions 				  YYERROR;
1752*1031c584SApple OSS Distributions 			  }
1753*1031c584SApple OSS Distributions 			  o = o->next;
1754*1031c584SApple OSS Distributions 		  }
1755*1031c584SApple OSS Distributions 		  ;}
1756*1031c584SApple OSS Distributions 		break;
1757*1031c584SApple OSS Distributions 
1758*1031c584SApple OSS Distributions 	case 18:
1759*1031c584SApple OSS Distributions #line 363 "OSUnserializeXML.y"
1760*1031c584SApple OSS Distributions 		{ (yyval) = (yyvsp[(1) - (2)]);
1761*1031c584SApple OSS Distributions 		  (yyval)->key = (OSSymbol *)(yyval)->object;
1762*1031c584SApple OSS Distributions 		  (yyval)->object = (yyvsp[(2) - (2)])->object;
1763*1031c584SApple OSS Distributions 		  (yyval)->next = NULL;
1764*1031c584SApple OSS Distributions 		  (yyvsp[(2) - (2)])->object = 0;
1765*1031c584SApple OSS Distributions 		  freeObject(STATE, (yyvsp[(2) - (2)]));
1766*1031c584SApple OSS Distributions 		  ;}
1767*1031c584SApple OSS Distributions 		break;
1768*1031c584SApple OSS Distributions 
1769*1031c584SApple OSS Distributions 	case 19:
1770*1031c584SApple OSS Distributions #line 372 "OSUnserializeXML.y"
1771*1031c584SApple OSS Distributions 		{ (yyval) = buildSymbol(STATE, (yyvsp[(1) - (1)]));
1772*1031c584SApple OSS Distributions 
1773*1031c584SApple OSS Distributions //				  STATE->parsedObjectCount++;
1774*1031c584SApple OSS Distributions //				  if (STATE->parsedObjectCount > MAX_OBJECTS) {
1775*1031c584SApple OSS Distributions //				    yyerror("maximum object count");
1776*1031c584SApple OSS Distributions //				    YYERROR;
1777*1031c584SApple OSS Distributions //				  }
1778*1031c584SApple OSS Distributions 		  ;}
1779*1031c584SApple OSS Distributions 		break;
1780*1031c584SApple OSS Distributions 
1781*1031c584SApple OSS Distributions 	case 20:
1782*1031c584SApple OSS Distributions #line 384 "OSUnserializeXML.y"
1783*1031c584SApple OSS Distributions 		{ (yyval) = (yyvsp[(1) - (2)]);
1784*1031c584SApple OSS Distributions 		  (yyval)->elements = NULL;
1785*1031c584SApple OSS Distributions 		  ;}
1786*1031c584SApple OSS Distributions 		break;
1787*1031c584SApple OSS Distributions 
1788*1031c584SApple OSS Distributions 	case 21:
1789*1031c584SApple OSS Distributions #line 387 "OSUnserializeXML.y"
1790*1031c584SApple OSS Distributions 		{ (yyval) = (yyvsp[(1) - (3)]);
1791*1031c584SApple OSS Distributions 		  (yyval)->elements = (yyvsp[(2) - (3)]);
1792*1031c584SApple OSS Distributions 		  ;}
1793*1031c584SApple OSS Distributions 		break;
1794*1031c584SApple OSS Distributions 
1795*1031c584SApple OSS Distributions 	case 23:
1796*1031c584SApple OSS Distributions #line 393 "OSUnserializeXML.y"
1797*1031c584SApple OSS Distributions 		{ (yyval) = (yyvsp[(1) - (2)]);
1798*1031c584SApple OSS Distributions 		  (yyval)->elements = NULL;
1799*1031c584SApple OSS Distributions 		  ;}
1800*1031c584SApple OSS Distributions 		break;
1801*1031c584SApple OSS Distributions 
1802*1031c584SApple OSS Distributions 	case 24:
1803*1031c584SApple OSS Distributions #line 396 "OSUnserializeXML.y"
1804*1031c584SApple OSS Distributions 		{ (yyval) = (yyvsp[(1) - (3)]);
1805*1031c584SApple OSS Distributions 		  (yyval)->elements = (yyvsp[(2) - (3)]);
1806*1031c584SApple OSS Distributions 		  ;}
1807*1031c584SApple OSS Distributions 		break;
1808*1031c584SApple OSS Distributions 
1809*1031c584SApple OSS Distributions 	case 26:
1810*1031c584SApple OSS Distributions #line 402 "OSUnserializeXML.y"
1811*1031c584SApple OSS Distributions 		{ (yyval) = (yyvsp[(1) - (1)]);
1812*1031c584SApple OSS Distributions 		  (yyval)->next = NULL;
1813*1031c584SApple OSS Distributions 		  ;}
1814*1031c584SApple OSS Distributions 		break;
1815*1031c584SApple OSS Distributions 
1816*1031c584SApple OSS Distributions 	case 27:
1817*1031c584SApple OSS Distributions #line 405 "OSUnserializeXML.y"
1818*1031c584SApple OSS Distributions 		{ (yyval) = (yyvsp[(2) - (2)]);
1819*1031c584SApple OSS Distributions 		  (yyval)->next = (yyvsp[(1) - (2)]);
1820*1031c584SApple OSS Distributions 		  ;}
1821*1031c584SApple OSS Distributions 		break;
1822*1031c584SApple OSS Distributions 
1823*1031c584SApple OSS Distributions 
1824*1031c584SApple OSS Distributions /* Line 1267 of yacc.c.  */
1825*1031c584SApple OSS Distributions #line 1772 "OSUnserializeXML.tab.c"
1826*1031c584SApple OSS Distributions 	default: break;
1827*1031c584SApple OSS Distributions 	}
1828*1031c584SApple OSS Distributions 	YY_SYMBOL_PRINT("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1829*1031c584SApple OSS Distributions 
1830*1031c584SApple OSS Distributions 	YYPOPSTACK(yylen);
1831*1031c584SApple OSS Distributions 	yylen = 0;
1832*1031c584SApple OSS Distributions 	YY_STACK_PRINT(yyss, yyssp);
1833*1031c584SApple OSS Distributions 
1834*1031c584SApple OSS Distributions 	*++yyvsp = yyval;
1835*1031c584SApple OSS Distributions 
1836*1031c584SApple OSS Distributions 
1837*1031c584SApple OSS Distributions 	/* Now `shift' the result of the reduction.  Determine what state
1838*1031c584SApple OSS Distributions 	 *  that goes to, based on the state we popped back to and the rule
1839*1031c584SApple OSS Distributions 	 *  number reduced by.  */
1840*1031c584SApple OSS Distributions 
1841*1031c584SApple OSS Distributions 	yyn = yyr1[yyn];
1842*1031c584SApple OSS Distributions 
1843*1031c584SApple OSS Distributions 	yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1844*1031c584SApple OSS Distributions 	if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) {
1845*1031c584SApple OSS Distributions 		yystate = yytable[yystate];
1846*1031c584SApple OSS Distributions 	} else {
1847*1031c584SApple OSS Distributions 		yystate = yydefgoto[yyn - YYNTOKENS];
1848*1031c584SApple OSS Distributions 	}
1849*1031c584SApple OSS Distributions 
1850*1031c584SApple OSS Distributions 	goto yynewstate;
1851*1031c584SApple OSS Distributions 
1852*1031c584SApple OSS Distributions 
1853*1031c584SApple OSS Distributions /*------------------------------------.
1854*1031c584SApple OSS Distributions  | yyerrlab -- here on detecting error |
1855*1031c584SApple OSS Distributions  |   `------------------------------------*/
1856*1031c584SApple OSS Distributions yyerrlab:
1857*1031c584SApple OSS Distributions 	/* If not already recovering from an error, report this error.  */
1858*1031c584SApple OSS Distributions 	if (!yyerrstatus) {
1859*1031c584SApple OSS Distributions 		++yynerrs;
1860*1031c584SApple OSS Distributions #if !YYERROR_VERBOSE
1861*1031c584SApple OSS Distributions 		yyerror(YY_("syntax error"));
1862*1031c584SApple OSS Distributions #else
1863*1031c584SApple OSS Distributions 		{
1864*1031c584SApple OSS Distributions 			YYSIZE_T yysize = yysyntax_error(0, yystate, yychar);
1865*1031c584SApple OSS Distributions 			if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) {
1866*1031c584SApple OSS Distributions 				YYSIZE_T yyalloc = 2 * yysize;
1867*1031c584SApple OSS Distributions 				if (!(yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) {
1868*1031c584SApple OSS Distributions 					yyalloc = YYSTACK_ALLOC_MAXIMUM;
1869*1031c584SApple OSS Distributions 				}
1870*1031c584SApple OSS Distributions 				if (yymsg != yymsgbuf) {
1871*1031c584SApple OSS Distributions 					YYSTACK_FREE(yymsg);
1872*1031c584SApple OSS Distributions 				}
1873*1031c584SApple OSS Distributions 				yymsg = (char *) YYSTACK_ALLOC(yyalloc);
1874*1031c584SApple OSS Distributions 				if (yymsg) {
1875*1031c584SApple OSS Distributions 					yymsg_alloc = yyalloc;
1876*1031c584SApple OSS Distributions 				} else {
1877*1031c584SApple OSS Distributions 					yymsg = yymsgbuf;
1878*1031c584SApple OSS Distributions 					yymsg_alloc = sizeof yymsgbuf;
1879*1031c584SApple OSS Distributions 				}
1880*1031c584SApple OSS Distributions 			}
1881*1031c584SApple OSS Distributions 
1882*1031c584SApple OSS Distributions 			if (0 < yysize && yysize <= yymsg_alloc) {
1883*1031c584SApple OSS Distributions 				(void) yysyntax_error(yymsg, yystate, yychar);
1884*1031c584SApple OSS Distributions 				yyerror(yymsg);
1885*1031c584SApple OSS Distributions 			} else {
1886*1031c584SApple OSS Distributions 				yyerror(YY_("syntax error"));
1887*1031c584SApple OSS Distributions 				if (yysize != 0) {
1888*1031c584SApple OSS Distributions 					goto yyexhaustedlab;
1889*1031c584SApple OSS Distributions 				}
1890*1031c584SApple OSS Distributions 			}
1891*1031c584SApple OSS Distributions 		}
1892*1031c584SApple OSS Distributions #endif
1893*1031c584SApple OSS Distributions 	}
1894*1031c584SApple OSS Distributions 
1895*1031c584SApple OSS Distributions 
1896*1031c584SApple OSS Distributions 
1897*1031c584SApple OSS Distributions 	if (yyerrstatus == 3) {
1898*1031c584SApple OSS Distributions 		/* If just tried and failed to reuse look-ahead token after an
1899*1031c584SApple OSS Distributions 		 *  error, discard it.  */
1900*1031c584SApple OSS Distributions 
1901*1031c584SApple OSS Distributions 		if (yychar <= YYEOF) {
1902*1031c584SApple OSS Distributions 			/* Return failure if at end of input.  */
1903*1031c584SApple OSS Distributions 			if (yychar == YYEOF) {
1904*1031c584SApple OSS Distributions 				YYABORT;
1905*1031c584SApple OSS Distributions 			}
1906*1031c584SApple OSS Distributions 		} else {
1907*1031c584SApple OSS Distributions 			yydestruct("Error: discarding",
1908*1031c584SApple OSS Distributions 			    yytoken, &yylval);
1909*1031c584SApple OSS Distributions 			yychar = YYEMPTY;
1910*1031c584SApple OSS Distributions 		}
1911*1031c584SApple OSS Distributions 	}
1912*1031c584SApple OSS Distributions 
1913*1031c584SApple OSS Distributions 	/* Else will try to reuse look-ahead token after shifting the error
1914*1031c584SApple OSS Distributions 	 *  token.  */
1915*1031c584SApple OSS Distributions 	goto yyerrlab1;
1916*1031c584SApple OSS Distributions 
1917*1031c584SApple OSS Distributions 
1918*1031c584SApple OSS Distributions /*---------------------------------------------------.
1919*1031c584SApple OSS Distributions  | yyerrorlab -- error raised explicitly by YYERROR.  |
1920*1031c584SApple OSS Distributions  |   `---------------------------------------------------*/
1921*1031c584SApple OSS Distributions yyerrorlab:
1922*1031c584SApple OSS Distributions 
1923*1031c584SApple OSS Distributions 	/* Pacify compilers like GCC when the user code never invokes
1924*1031c584SApple OSS Distributions 	 *  YYERROR and the label yyerrorlab therefore never appears in user
1925*1031c584SApple OSS Distributions 	 *  code.  */
1926*1031c584SApple OSS Distributions 	if (/*CONSTCOND*/ 0) {
1927*1031c584SApple OSS Distributions 		goto yyerrorlab;
1928*1031c584SApple OSS Distributions 	}
1929*1031c584SApple OSS Distributions 
1930*1031c584SApple OSS Distributions 	/* Do not reclaim the symbols of the rule which action triggered
1931*1031c584SApple OSS Distributions 	 *  this YYERROR.  */
1932*1031c584SApple OSS Distributions 	YYPOPSTACK(yylen);
1933*1031c584SApple OSS Distributions 	yylen = 0;
1934*1031c584SApple OSS Distributions 	YY_STACK_PRINT(yyss, yyssp);
1935*1031c584SApple OSS Distributions 	yystate = *yyssp;
1936*1031c584SApple OSS Distributions 	goto yyerrlab1;
1937*1031c584SApple OSS Distributions 
1938*1031c584SApple OSS Distributions 
1939*1031c584SApple OSS Distributions /*-------------------------------------------------------------.
1940*1031c584SApple OSS Distributions  | yyerrlab1 -- common code for both syntax error and YYERROR.  |
1941*1031c584SApple OSS Distributions  |   `-------------------------------------------------------------*/
1942*1031c584SApple OSS Distributions yyerrlab1:
1943*1031c584SApple OSS Distributions 	yyerrstatus = 3; /* Each real token shifted decrements this.  */
1944*1031c584SApple OSS Distributions 
1945*1031c584SApple OSS Distributions 	for (;;) {
1946*1031c584SApple OSS Distributions 		yyn = yypact[yystate];
1947*1031c584SApple OSS Distributions 		if (yyn != YYPACT_NINF) {
1948*1031c584SApple OSS Distributions 			yyn += YYTERROR;
1949*1031c584SApple OSS Distributions 			if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) {
1950*1031c584SApple OSS Distributions 				yyn = yytable[yyn];
1951*1031c584SApple OSS Distributions 				if (0 < yyn) {
1952*1031c584SApple OSS Distributions 					break;
1953*1031c584SApple OSS Distributions 				}
1954*1031c584SApple OSS Distributions 			}
1955*1031c584SApple OSS Distributions 		}
1956*1031c584SApple OSS Distributions 
1957*1031c584SApple OSS Distributions 		/* Pop the current state because it cannot handle the error token.  */
1958*1031c584SApple OSS Distributions 		if (yyssp == yyss) {
1959*1031c584SApple OSS Distributions 			YYABORT;
1960*1031c584SApple OSS Distributions 		}
1961*1031c584SApple OSS Distributions 
1962*1031c584SApple OSS Distributions 
1963*1031c584SApple OSS Distributions 		yydestruct("Error: popping",
1964*1031c584SApple OSS Distributions 		    yystos[yystate], yyvsp);
1965*1031c584SApple OSS Distributions 		YYPOPSTACK(1);
1966*1031c584SApple OSS Distributions 		yystate = *yyssp;
1967*1031c584SApple OSS Distributions 		YY_STACK_PRINT(yyss, yyssp);
1968*1031c584SApple OSS Distributions 	}
1969*1031c584SApple OSS Distributions 
1970*1031c584SApple OSS Distributions 	if (yyn == YYFINAL) {
1971*1031c584SApple OSS Distributions 		YYACCEPT;
1972*1031c584SApple OSS Distributions 	}
1973*1031c584SApple OSS Distributions 
1974*1031c584SApple OSS Distributions 	*++yyvsp = yylval;
1975*1031c584SApple OSS Distributions 
1976*1031c584SApple OSS Distributions 
1977*1031c584SApple OSS Distributions 	/* Shift the error token.  */
1978*1031c584SApple OSS Distributions 	YY_SYMBOL_PRINT("Shifting", yystos[yyn], yyvsp, yylsp);
1979*1031c584SApple OSS Distributions 
1980*1031c584SApple OSS Distributions 	yystate = yyn;
1981*1031c584SApple OSS Distributions 	goto yynewstate;
1982*1031c584SApple OSS Distributions 
1983*1031c584SApple OSS Distributions 
1984*1031c584SApple OSS Distributions /*-------------------------------------.
1985*1031c584SApple OSS Distributions  | yyacceptlab -- YYACCEPT comes here.  |
1986*1031c584SApple OSS Distributions  |   `-------------------------------------*/
1987*1031c584SApple OSS Distributions yyacceptlab:
1988*1031c584SApple OSS Distributions 	yyresult = 0;
1989*1031c584SApple OSS Distributions 	goto yyreturn;
1990*1031c584SApple OSS Distributions 
1991*1031c584SApple OSS Distributions /*-----------------------------------.
1992*1031c584SApple OSS Distributions  | yyabortlab -- YYABORT comes here.  |
1993*1031c584SApple OSS Distributions  |   `-----------------------------------*/
1994*1031c584SApple OSS Distributions yyabortlab:
1995*1031c584SApple OSS Distributions 	yyresult = 1;
1996*1031c584SApple OSS Distributions 	goto yyreturn;
1997*1031c584SApple OSS Distributions 
1998*1031c584SApple OSS Distributions #ifndef yyoverflow
1999*1031c584SApple OSS Distributions /*-------------------------------------------------.
2000*1031c584SApple OSS Distributions  | yyexhaustedlab -- memory exhaustion comes here.  |
2001*1031c584SApple OSS Distributions  |   `-------------------------------------------------*/
2002*1031c584SApple OSS Distributions yyexhaustedlab:
2003*1031c584SApple OSS Distributions 	yyerror(YY_("memory exhausted"));
2004*1031c584SApple OSS Distributions 	yyresult = 2;
2005*1031c584SApple OSS Distributions 	/* Fall through.  */
2006*1031c584SApple OSS Distributions #endif
2007*1031c584SApple OSS Distributions 
2008*1031c584SApple OSS Distributions yyreturn:
2009*1031c584SApple OSS Distributions 	if (yychar != YYEOF && yychar != YYEMPTY) {
2010*1031c584SApple OSS Distributions 		yydestruct("Cleanup: discarding lookahead",
2011*1031c584SApple OSS Distributions 		    yytoken, &yylval);
2012*1031c584SApple OSS Distributions 	}
2013*1031c584SApple OSS Distributions 	/* Do not reclaim the symbols of the rule which action triggered
2014*1031c584SApple OSS Distributions 	 *  this YYABORT or YYACCEPT.  */
2015*1031c584SApple OSS Distributions 	YYPOPSTACK(yylen);
2016*1031c584SApple OSS Distributions 	YY_STACK_PRINT(yyss, yyssp);
2017*1031c584SApple OSS Distributions 	while (yyssp != yyss) {
2018*1031c584SApple OSS Distributions 		yydestruct("Cleanup: popping",
2019*1031c584SApple OSS Distributions 		    yystos[*yyssp], yyvsp);
2020*1031c584SApple OSS Distributions 		YYPOPSTACK(1);
2021*1031c584SApple OSS Distributions 	}
2022*1031c584SApple OSS Distributions #ifndef yyoverflow
2023*1031c584SApple OSS Distributions 	if (yyss != yyssa) {
2024*1031c584SApple OSS Distributions 		YYSTACK_FREE(yyss);
2025*1031c584SApple OSS Distributions 	}
2026*1031c584SApple OSS Distributions #endif
2027*1031c584SApple OSS Distributions #if YYERROR_VERBOSE
2028*1031c584SApple OSS Distributions 	if (yymsg != yymsgbuf) {
2029*1031c584SApple OSS Distributions 		YYSTACK_FREE(yymsg);
2030*1031c584SApple OSS Distributions 	}
2031*1031c584SApple OSS Distributions #endif
2032*1031c584SApple OSS Distributions 	/* Make sure YYID is used.  */
2033*1031c584SApple OSS Distributions 	return YYID(yyresult);
2034*1031c584SApple OSS Distributions }
2035*1031c584SApple OSS Distributions 
2036*1031c584SApple OSS Distributions 
2037*1031c584SApple OSS Distributions #line 427 "OSUnserializeXML.y"
2038*1031c584SApple OSS Distributions 
2039*1031c584SApple OSS Distributions 
2040*1031c584SApple OSS Distributions int
OSUnserializeerror(parser_state_t * state,const char * s)2041*1031c584SApple OSS Distributions OSUnserializeerror(parser_state_t * state, const char *s)  /* Called by yyparse on errors */
2042*1031c584SApple OSS Distributions {
2043*1031c584SApple OSS Distributions 	if (state->errorString) {
2044*1031c584SApple OSS Distributions 		char tempString[128];
2045*1031c584SApple OSS Distributions 		snprintf(tempString, 128, "OSUnserializeXML: %s near line %d\n", s, state->lineNumber);
2046*1031c584SApple OSS Distributions 		*(state->errorString) = OSString::withCString(tempString);
2047*1031c584SApple OSS Distributions 	}
2048*1031c584SApple OSS Distributions 
2049*1031c584SApple OSS Distributions 	return 0;
2050*1031c584SApple OSS Distributions }
2051*1031c584SApple OSS Distributions 
2052*1031c584SApple OSS Distributions #define TAG_MAX_LENGTH          32
2053*1031c584SApple OSS Distributions #define TAG_MAX_ATTRIBUTES      32
2054*1031c584SApple OSS Distributions #define TAG_BAD                 0
2055*1031c584SApple OSS Distributions #define TAG_START               1
2056*1031c584SApple OSS Distributions #define TAG_END                 2
2057*1031c584SApple OSS Distributions #define TAG_EMPTY               3
2058*1031c584SApple OSS Distributions #define TAG_IGNORE              4
2059*1031c584SApple OSS Distributions 
2060*1031c584SApple OSS Distributions #define currentChar()   (state->parseBuffer[state->parseBufferIndex])
2061*1031c584SApple OSS Distributions #define nextChar()      (state->parseBuffer[++state->parseBufferIndex])
2062*1031c584SApple OSS Distributions #define prevChar()      (state->parseBuffer[state->parseBufferIndex - 1])
2063*1031c584SApple OSS Distributions 
2064*1031c584SApple OSS Distributions #define isSpace(c)      ((c) == ' ' || (c) == '\t')
2065*1031c584SApple OSS Distributions #define isAlpha(c)      (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z'))
2066*1031c584SApple OSS Distributions #define isDigit(c)      ((c) >= '0' && (c) <= '9')
2067*1031c584SApple OSS Distributions #define isAlphaDigit(c) ((c) >= 'a' && (c) <= 'f')
2068*1031c584SApple OSS Distributions #define isHexDigit(c)   (isDigit(c) || isAlphaDigit(c))
2069*1031c584SApple OSS Distributions #define isAlphaNumeric(c) (isAlpha(c) || isDigit(c) || ((c) == '-'))
2070*1031c584SApple OSS Distributions 
2071*1031c584SApple OSS Distributions static int
getTag(parser_state_t * state,char tag[TAG_MAX_LENGTH],int * attributeCount,char attributes[TAG_MAX_ATTRIBUTES][TAG_MAX_LENGTH],char values[TAG_MAX_ATTRIBUTES][TAG_MAX_LENGTH])2072*1031c584SApple OSS Distributions getTag(parser_state_t *state,
2073*1031c584SApple OSS Distributions     char tag[TAG_MAX_LENGTH],
2074*1031c584SApple OSS Distributions     int *attributeCount,
2075*1031c584SApple OSS Distributions     char attributes[TAG_MAX_ATTRIBUTES][TAG_MAX_LENGTH],
2076*1031c584SApple OSS Distributions     char values[TAG_MAX_ATTRIBUTES][TAG_MAX_LENGTH] )
2077*1031c584SApple OSS Distributions {
2078*1031c584SApple OSS Distributions 	int length = 0;
2079*1031c584SApple OSS Distributions 	int c = currentChar();
2080*1031c584SApple OSS Distributions 	int tagType = TAG_START;
2081*1031c584SApple OSS Distributions 
2082*1031c584SApple OSS Distributions 	*attributeCount = 0;
2083*1031c584SApple OSS Distributions 
2084*1031c584SApple OSS Distributions 	if (c != '<') {
2085*1031c584SApple OSS Distributions 		return TAG_BAD;
2086*1031c584SApple OSS Distributions 	}
2087*1031c584SApple OSS Distributions 	c = nextChar();         // skip '<'
2088*1031c584SApple OSS Distributions 
2089*1031c584SApple OSS Distributions 
2090*1031c584SApple OSS Distributions 	// <!TAG   declarations     >
2091*1031c584SApple OSS Distributions 	// <!--     comments      -->
2092*1031c584SApple OSS Distributions 	if (c == '!') {
2093*1031c584SApple OSS Distributions 		c = nextChar();
2094*1031c584SApple OSS Distributions 		bool isComment = (c == '-') && ((c = nextChar()) != 0) && (c == '-');
2095*1031c584SApple OSS Distributions 		if (!isComment && !isAlpha(c)) {
2096*1031c584SApple OSS Distributions 			return TAG_BAD;                      // <!1, <!-A, <!eos
2097*1031c584SApple OSS Distributions 		}
2098*1031c584SApple OSS Distributions 		while (c && (c = nextChar()) != 0) {
2099*1031c584SApple OSS Distributions 			if (c == '\n') {
2100*1031c584SApple OSS Distributions 				state->lineNumber++;
2101*1031c584SApple OSS Distributions 			}
2102*1031c584SApple OSS Distributions 			if (isComment) {
2103*1031c584SApple OSS Distributions 				if (c != '-') {
2104*1031c584SApple OSS Distributions 					continue;
2105*1031c584SApple OSS Distributions 				}
2106*1031c584SApple OSS Distributions 				c = nextChar();
2107*1031c584SApple OSS Distributions 				if (c != '-') {
2108*1031c584SApple OSS Distributions 					continue;
2109*1031c584SApple OSS Distributions 				}
2110*1031c584SApple OSS Distributions 				c = nextChar();
2111*1031c584SApple OSS Distributions 			}
2112*1031c584SApple OSS Distributions 			if (c == '>') {
2113*1031c584SApple OSS Distributions 				(void)nextChar();
2114*1031c584SApple OSS Distributions 				return TAG_IGNORE;
2115*1031c584SApple OSS Distributions 			}
2116*1031c584SApple OSS Distributions 			if (isComment) {
2117*1031c584SApple OSS Distributions 				break;
2118*1031c584SApple OSS Distributions 			}
2119*1031c584SApple OSS Distributions 		}
2120*1031c584SApple OSS Distributions 		return TAG_BAD;
2121*1031c584SApple OSS Distributions 	} else
2122*1031c584SApple OSS Distributions 	// <? Processing Instructions  ?>
2123*1031c584SApple OSS Distributions 	if (c == '?') {
2124*1031c584SApple OSS Distributions 		while ((c = nextChar()) != 0) {
2125*1031c584SApple OSS Distributions 			if (c == '\n') {
2126*1031c584SApple OSS Distributions 				state->lineNumber++;
2127*1031c584SApple OSS Distributions 			}
2128*1031c584SApple OSS Distributions 			if (c != '?') {
2129*1031c584SApple OSS Distributions 				continue;
2130*1031c584SApple OSS Distributions 			}
2131*1031c584SApple OSS Distributions 			c = nextChar();
2132*1031c584SApple OSS Distributions 			if (!c) {
2133*1031c584SApple OSS Distributions 				return TAG_IGNORE;
2134*1031c584SApple OSS Distributions 			}
2135*1031c584SApple OSS Distributions 			if (c == '>') {
2136*1031c584SApple OSS Distributions 				(void)nextChar();
2137*1031c584SApple OSS Distributions 				return TAG_IGNORE;
2138*1031c584SApple OSS Distributions 			}
2139*1031c584SApple OSS Distributions 		}
2140*1031c584SApple OSS Distributions 		return TAG_BAD;
2141*1031c584SApple OSS Distributions 	} else
2142*1031c584SApple OSS Distributions 	// </ end tag >
2143*1031c584SApple OSS Distributions 	if (c == '/') {
2144*1031c584SApple OSS Distributions 		c = nextChar();         // skip '/'
2145*1031c584SApple OSS Distributions 		tagType = TAG_END;
2146*1031c584SApple OSS Distributions 	}
2147*1031c584SApple OSS Distributions 	if (!isAlpha(c)) {
2148*1031c584SApple OSS Distributions 		return TAG_BAD;
2149*1031c584SApple OSS Distributions 	}
2150*1031c584SApple OSS Distributions 
2151*1031c584SApple OSS Distributions 	/* find end of tag while copying it */
2152*1031c584SApple OSS Distributions 	while (isAlphaNumeric(c)) {
2153*1031c584SApple OSS Distributions 		tag[length++] = c;
2154*1031c584SApple OSS Distributions 		c = nextChar();
2155*1031c584SApple OSS Distributions 		if (length >= (TAG_MAX_LENGTH - 1)) {
2156*1031c584SApple OSS Distributions 			return TAG_BAD;
2157*1031c584SApple OSS Distributions 		}
2158*1031c584SApple OSS Distributions 	}
2159*1031c584SApple OSS Distributions 
2160*1031c584SApple OSS Distributions 	tag[length] = 0;
2161*1031c584SApple OSS Distributions 
2162*1031c584SApple OSS Distributions //	printf("tag %s, type %d\n", tag, tagType);
2163*1031c584SApple OSS Distributions 
2164*1031c584SApple OSS Distributions 	// look for attributes of the form attribute = "value" ...
2165*1031c584SApple OSS Distributions 	while ((c != '>') && (c != '/')) {
2166*1031c584SApple OSS Distributions 		while (isSpace(c)) {
2167*1031c584SApple OSS Distributions 			c = nextChar();
2168*1031c584SApple OSS Distributions 		}
2169*1031c584SApple OSS Distributions 
2170*1031c584SApple OSS Distributions 		length = 0;
2171*1031c584SApple OSS Distributions 		while (isAlphaNumeric(c)) {
2172*1031c584SApple OSS Distributions 			attributes[*attributeCount][length++] = c;
2173*1031c584SApple OSS Distributions 			if (length >= (TAG_MAX_LENGTH - 1)) {
2174*1031c584SApple OSS Distributions 				return TAG_BAD;
2175*1031c584SApple OSS Distributions 			}
2176*1031c584SApple OSS Distributions 			c = nextChar();
2177*1031c584SApple OSS Distributions 		}
2178*1031c584SApple OSS Distributions 		attributes[*attributeCount][length] = 0;
2179*1031c584SApple OSS Distributions 
2180*1031c584SApple OSS Distributions 		while (isSpace(c)) {
2181*1031c584SApple OSS Distributions 			c = nextChar();
2182*1031c584SApple OSS Distributions 		}
2183*1031c584SApple OSS Distributions 
2184*1031c584SApple OSS Distributions 		if (c != '=') {
2185*1031c584SApple OSS Distributions 			return TAG_BAD;
2186*1031c584SApple OSS Distributions 		}
2187*1031c584SApple OSS Distributions 		c = nextChar();
2188*1031c584SApple OSS Distributions 
2189*1031c584SApple OSS Distributions 		while (isSpace(c)) {
2190*1031c584SApple OSS Distributions 			c = nextChar();
2191*1031c584SApple OSS Distributions 		}
2192*1031c584SApple OSS Distributions 
2193*1031c584SApple OSS Distributions 		if (c != '"') {
2194*1031c584SApple OSS Distributions 			return TAG_BAD;
2195*1031c584SApple OSS Distributions 		}
2196*1031c584SApple OSS Distributions 		c = nextChar();
2197*1031c584SApple OSS Distributions 		length = 0;
2198*1031c584SApple OSS Distributions 		while (c != '"') {
2199*1031c584SApple OSS Distributions 			values[*attributeCount][length++] = c;
2200*1031c584SApple OSS Distributions 			if (length >= (TAG_MAX_LENGTH - 1)) {
2201*1031c584SApple OSS Distributions 				return TAG_BAD;
2202*1031c584SApple OSS Distributions 			}
2203*1031c584SApple OSS Distributions 			c = nextChar();
2204*1031c584SApple OSS Distributions 			if (!c) {
2205*1031c584SApple OSS Distributions 				return TAG_BAD;
2206*1031c584SApple OSS Distributions 			}
2207*1031c584SApple OSS Distributions 		}
2208*1031c584SApple OSS Distributions 		values[*attributeCount][length] = 0;
2209*1031c584SApple OSS Distributions 
2210*1031c584SApple OSS Distributions 		c = nextChar(); // skip closing quote
2211*1031c584SApple OSS Distributions 
2212*1031c584SApple OSS Distributions //		printf("	attribute '%s' = '%s', nextchar = '%c'\n",
2213*1031c584SApple OSS Distributions //		       attributes[*attributeCount], values[*attributeCount], c);
2214*1031c584SApple OSS Distributions 
2215*1031c584SApple OSS Distributions 		(*attributeCount)++;
2216*1031c584SApple OSS Distributions 		if (*attributeCount >= TAG_MAX_ATTRIBUTES) {
2217*1031c584SApple OSS Distributions 			return TAG_BAD;
2218*1031c584SApple OSS Distributions 		}
2219*1031c584SApple OSS Distributions 	}
2220*1031c584SApple OSS Distributions 
2221*1031c584SApple OSS Distributions 	if (c == '/') {
2222*1031c584SApple OSS Distributions 		c = nextChar();         // skip '/'
2223*1031c584SApple OSS Distributions 		tagType = TAG_EMPTY;
2224*1031c584SApple OSS Distributions 	}
2225*1031c584SApple OSS Distributions 	if (c != '>') {
2226*1031c584SApple OSS Distributions 		return TAG_BAD;
2227*1031c584SApple OSS Distributions 	}
2228*1031c584SApple OSS Distributions 	c = nextChar();         // skip '>'
2229*1031c584SApple OSS Distributions 
2230*1031c584SApple OSS Distributions 	return tagType;
2231*1031c584SApple OSS Distributions }
2232*1031c584SApple OSS Distributions 
2233*1031c584SApple OSS Distributions static char *
getString(parser_state_t * state,int * alloc_lengthp)2234*1031c584SApple OSS Distributions getString(parser_state_t *state, int *alloc_lengthp)
2235*1031c584SApple OSS Distributions {
2236*1031c584SApple OSS Distributions 	int c = currentChar();
2237*1031c584SApple OSS Distributions 	int start, length, i, j;
2238*1031c584SApple OSS Distributions 	char * tempString;
2239*1031c584SApple OSS Distributions 
2240*1031c584SApple OSS Distributions 	start = state->parseBufferIndex;
2241*1031c584SApple OSS Distributions 	/* find end of string */
2242*1031c584SApple OSS Distributions 
2243*1031c584SApple OSS Distributions 	while (c != 0) {
2244*1031c584SApple OSS Distributions 		if (c == '\n') {
2245*1031c584SApple OSS Distributions 			state->lineNumber++;
2246*1031c584SApple OSS Distributions 		}
2247*1031c584SApple OSS Distributions 		if (c == '<') {
2248*1031c584SApple OSS Distributions 			break;
2249*1031c584SApple OSS Distributions 		}
2250*1031c584SApple OSS Distributions 		c = nextChar();
2251*1031c584SApple OSS Distributions 	}
2252*1031c584SApple OSS Distributions 
2253*1031c584SApple OSS Distributions 	if (c != '<') {
2254*1031c584SApple OSS Distributions 		return 0;
2255*1031c584SApple OSS Distributions 	}
2256*1031c584SApple OSS Distributions 
2257*1031c584SApple OSS Distributions 	length = state->parseBufferIndex - start;
2258*1031c584SApple OSS Distributions 
2259*1031c584SApple OSS Distributions 	/* copy to null terminated buffer */
2260*1031c584SApple OSS Distributions 	tempString = (char *)malloc(length + 1);
2261*1031c584SApple OSS Distributions 	if (tempString == NULL) {
2262*1031c584SApple OSS Distributions 		printf("OSUnserializeXML: can't alloc temp memory\n");
2263*1031c584SApple OSS Distributions 		goto error;
2264*1031c584SApple OSS Distributions 	}
2265*1031c584SApple OSS Distributions 	if (alloc_lengthp) {
2266*1031c584SApple OSS Distributions 		*alloc_lengthp = length + 1;
2267*1031c584SApple OSS Distributions 	}
2268*1031c584SApple OSS Distributions 
2269*1031c584SApple OSS Distributions 	// copy out string in tempString
2270*1031c584SApple OSS Distributions 	// "&amp;" -> '&', "&lt;" -> '<', "&gt;" -> '>'
2271*1031c584SApple OSS Distributions 
2272*1031c584SApple OSS Distributions 	i = j = 0;
2273*1031c584SApple OSS Distributions 	while (i < length) {
2274*1031c584SApple OSS Distributions 		c = state->parseBuffer[start + i++];
2275*1031c584SApple OSS Distributions 		if (c != '&') {
2276*1031c584SApple OSS Distributions 			tempString[j++] = c;
2277*1031c584SApple OSS Distributions 		} else {
2278*1031c584SApple OSS Distributions 			if ((i + 3) > length) {
2279*1031c584SApple OSS Distributions 				goto error;
2280*1031c584SApple OSS Distributions 			}
2281*1031c584SApple OSS Distributions 			c = state->parseBuffer[start + i++];
2282*1031c584SApple OSS Distributions 			if (c == 'l') {
2283*1031c584SApple OSS Distributions 				if (state->parseBuffer[start + i++] != 't') {
2284*1031c584SApple OSS Distributions 					goto error;
2285*1031c584SApple OSS Distributions 				}
2286*1031c584SApple OSS Distributions 				if (state->parseBuffer[start + i++] != ';') {
2287*1031c584SApple OSS Distributions 					goto error;
2288*1031c584SApple OSS Distributions 				}
2289*1031c584SApple OSS Distributions 				tempString[j++] = '<';
2290*1031c584SApple OSS Distributions 				continue;
2291*1031c584SApple OSS Distributions 			}
2292*1031c584SApple OSS Distributions 			if (c == 'g') {
2293*1031c584SApple OSS Distributions 				if (state->parseBuffer[start + i++] != 't') {
2294*1031c584SApple OSS Distributions 					goto error;
2295*1031c584SApple OSS Distributions 				}
2296*1031c584SApple OSS Distributions 				if (state->parseBuffer[start + i++] != ';') {
2297*1031c584SApple OSS Distributions 					goto error;
2298*1031c584SApple OSS Distributions 				}
2299*1031c584SApple OSS Distributions 				tempString[j++] = '>';
2300*1031c584SApple OSS Distributions 				continue;
2301*1031c584SApple OSS Distributions 			}
2302*1031c584SApple OSS Distributions 			if ((i + 3) > length) {
2303*1031c584SApple OSS Distributions 				goto error;
2304*1031c584SApple OSS Distributions 			}
2305*1031c584SApple OSS Distributions 			if (c == 'a') {
2306*1031c584SApple OSS Distributions 				if (state->parseBuffer[start + i++] != 'm') {
2307*1031c584SApple OSS Distributions 					goto error;
2308*1031c584SApple OSS Distributions 				}
2309*1031c584SApple OSS Distributions 				if (state->parseBuffer[start + i++] != 'p') {
2310*1031c584SApple OSS Distributions 					goto error;
2311*1031c584SApple OSS Distributions 				}
2312*1031c584SApple OSS Distributions 				if (state->parseBuffer[start + i++] != ';') {
2313*1031c584SApple OSS Distributions 					goto error;
2314*1031c584SApple OSS Distributions 				}
2315*1031c584SApple OSS Distributions 				tempString[j++] = '&';
2316*1031c584SApple OSS Distributions 				continue;
2317*1031c584SApple OSS Distributions 			}
2318*1031c584SApple OSS Distributions 			goto error;
2319*1031c584SApple OSS Distributions 		}
2320*1031c584SApple OSS Distributions 	}
2321*1031c584SApple OSS Distributions 	tempString[j] = 0;
2322*1031c584SApple OSS Distributions 
2323*1031c584SApple OSS Distributions //	printf("string %s\n", tempString);
2324*1031c584SApple OSS Distributions 
2325*1031c584SApple OSS Distributions 	return tempString;
2326*1031c584SApple OSS Distributions 
2327*1031c584SApple OSS Distributions error:
2328*1031c584SApple OSS Distributions 	if (tempString) {
2329*1031c584SApple OSS Distributions 		safe_free(tempString, length + 1);
2330*1031c584SApple OSS Distributions 		if (alloc_lengthp) {
2331*1031c584SApple OSS Distributions 			*alloc_lengthp = 0;
2332*1031c584SApple OSS Distributions 		}
2333*1031c584SApple OSS Distributions 	}
2334*1031c584SApple OSS Distributions 	return 0;
2335*1031c584SApple OSS Distributions }
2336*1031c584SApple OSS Distributions 
2337*1031c584SApple OSS Distributions static long long
getNumber(parser_state_t * state)2338*1031c584SApple OSS Distributions getNumber(parser_state_t *state)
2339*1031c584SApple OSS Distributions {
2340*1031c584SApple OSS Distributions 	unsigned long long n = 0;
2341*1031c584SApple OSS Distributions 	int base = 10;
2342*1031c584SApple OSS Distributions 	bool negate = false;
2343*1031c584SApple OSS Distributions 	int c = currentChar();
2344*1031c584SApple OSS Distributions 
2345*1031c584SApple OSS Distributions 	if (c == '0') {
2346*1031c584SApple OSS Distributions 		c = nextChar();
2347*1031c584SApple OSS Distributions 		if (c == 'x') {
2348*1031c584SApple OSS Distributions 			base = 16;
2349*1031c584SApple OSS Distributions 			c = nextChar();
2350*1031c584SApple OSS Distributions 		}
2351*1031c584SApple OSS Distributions 	}
2352*1031c584SApple OSS Distributions 	if (base == 10) {
2353*1031c584SApple OSS Distributions 		if (c == '-') {
2354*1031c584SApple OSS Distributions 			negate = true;
2355*1031c584SApple OSS Distributions 			c = nextChar();
2356*1031c584SApple OSS Distributions 		}
2357*1031c584SApple OSS Distributions 		while (isDigit(c)) {
2358*1031c584SApple OSS Distributions 			n = (n * base + c - '0');
2359*1031c584SApple OSS Distributions 			c = nextChar();
2360*1031c584SApple OSS Distributions 		}
2361*1031c584SApple OSS Distributions 		if (negate) {
2362*1031c584SApple OSS Distributions 			n = (unsigned long long)((long long)n * (long long)-1);
2363*1031c584SApple OSS Distributions 		}
2364*1031c584SApple OSS Distributions 	} else {
2365*1031c584SApple OSS Distributions 		while (isHexDigit(c)) {
2366*1031c584SApple OSS Distributions 			if (isDigit(c)) {
2367*1031c584SApple OSS Distributions 				n = (n * base + c - '0');
2368*1031c584SApple OSS Distributions 			} else {
2369*1031c584SApple OSS Distributions 				n = (n * base + 0xa + c - 'a');
2370*1031c584SApple OSS Distributions 			}
2371*1031c584SApple OSS Distributions 			c = nextChar();
2372*1031c584SApple OSS Distributions 		}
2373*1031c584SApple OSS Distributions 	}
2374*1031c584SApple OSS Distributions //	printf("number 0x%x\n", (unsigned long)n);
2375*1031c584SApple OSS Distributions 	return n;
2376*1031c584SApple OSS Distributions }
2377*1031c584SApple OSS Distributions 
2378*1031c584SApple OSS Distributions // taken from CFXMLParsing/CFPropertyList.c
2379*1031c584SApple OSS Distributions 
2380*1031c584SApple OSS Distributions static const signed char __CFPLDataDecodeTable[128] = {
2381*1031c584SApple OSS Distributions 	/* 000 */ -1, -1, -1, -1, -1, -1, -1, -1,
2382*1031c584SApple OSS Distributions 	/* 010 */ -1, -1, -1, -1, -1, -1, -1, -1,
2383*1031c584SApple OSS Distributions 	/* 020 */ -1, -1, -1, -1, -1, -1, -1, -1,
2384*1031c584SApple OSS Distributions 	/* 030 */ -1, -1, -1, -1, -1, -1, -1, -1,
2385*1031c584SApple OSS Distributions 	/* ' ' */ -1, -1, -1, -1, -1, -1, -1, -1,
2386*1031c584SApple OSS Distributions 	/* '(' */ -1, -1, -1, 62, -1, -1, -1, 63,
2387*1031c584SApple OSS Distributions 	/* '0' */ 52, 53, 54, 55, 56, 57, 58, 59,
2388*1031c584SApple OSS Distributions 	/* '8' */ 60, 61, -1, -1, -1, 0, -1, -1,
2389*1031c584SApple OSS Distributions 	/* '@' */ -1, 0, 1, 2, 3, 4, 5, 6,
2390*1031c584SApple OSS Distributions 	/* 'H' */ 7, 8, 9, 10, 11, 12, 13, 14,
2391*1031c584SApple OSS Distributions 	/* 'P' */ 15, 16, 17, 18, 19, 20, 21, 22,
2392*1031c584SApple OSS Distributions 	/* 'X' */ 23, 24, 25, -1, -1, -1, -1, -1,
2393*1031c584SApple OSS Distributions 	/* '`' */ -1, 26, 27, 28, 29, 30, 31, 32,
2394*1031c584SApple OSS Distributions 	/* 'h' */ 33, 34, 35, 36, 37, 38, 39, 40,
2395*1031c584SApple OSS Distributions 	/* 'p' */ 41, 42, 43, 44, 45, 46, 47, 48,
2396*1031c584SApple OSS Distributions 	/* 'x' */ 49, 50, 51, -1, -1, -1, -1, -1
2397*1031c584SApple OSS Distributions };
2398*1031c584SApple OSS Distributions 
2399*1031c584SApple OSS Distributions #define DATA_ALLOC_SIZE 4096
2400*1031c584SApple OSS Distributions 
2401*1031c584SApple OSS Distributions static void *
getCFEncodedData(parser_state_t * state,unsigned int * size)2402*1031c584SApple OSS Distributions getCFEncodedData(parser_state_t *state, unsigned int *size)
2403*1031c584SApple OSS Distributions {
2404*1031c584SApple OSS Distributions 	int numeq = 0, cntr = 0;
2405*1031c584SApple OSS Distributions 	unsigned int acc = 0;
2406*1031c584SApple OSS Distributions 	int tmpbufpos = 0;
2407*1031c584SApple OSS Distributions 	size_t tmpbuflen = DATA_ALLOC_SIZE;
2408*1031c584SApple OSS Distributions 	unsigned char *tmpbuf = (unsigned char *)malloc(tmpbuflen);
2409*1031c584SApple OSS Distributions 
2410*1031c584SApple OSS Distributions 	int c = currentChar();
2411*1031c584SApple OSS Distributions 	*size = 0;
2412*1031c584SApple OSS Distributions 
2413*1031c584SApple OSS Distributions 	while (c != '<') {
2414*1031c584SApple OSS Distributions 		c &= 0x7f;
2415*1031c584SApple OSS Distributions 		if (c == 0) {
2416*1031c584SApple OSS Distributions 			safe_free(tmpbuf, tmpbuflen);
2417*1031c584SApple OSS Distributions 			return 0;
2418*1031c584SApple OSS Distributions 		}
2419*1031c584SApple OSS Distributions 		if (c == '=') {
2420*1031c584SApple OSS Distributions 			numeq++;
2421*1031c584SApple OSS Distributions 		} else {
2422*1031c584SApple OSS Distributions 			numeq = 0;
2423*1031c584SApple OSS Distributions 		}
2424*1031c584SApple OSS Distributions 		if (c == '\n') {
2425*1031c584SApple OSS Distributions 			state->lineNumber++;
2426*1031c584SApple OSS Distributions 		}
2427*1031c584SApple OSS Distributions 		if (__CFPLDataDecodeTable[c] < 0) {
2428*1031c584SApple OSS Distributions 			c = nextChar();
2429*1031c584SApple OSS Distributions 			continue;
2430*1031c584SApple OSS Distributions 		}
2431*1031c584SApple OSS Distributions 		cntr++;
2432*1031c584SApple OSS Distributions 		acc <<= 6;
2433*1031c584SApple OSS Distributions 		acc += __CFPLDataDecodeTable[c];
2434*1031c584SApple OSS Distributions 		if (0 == (cntr & 0x3)) {
2435*1031c584SApple OSS Distributions 			if (tmpbuflen <= tmpbufpos + 2) {
2436*1031c584SApple OSS Distributions 				size_t oldsize = tmpbuflen;
2437*1031c584SApple OSS Distributions 				tmpbuflen *= 2;
2438*1031c584SApple OSS Distributions 				tmpbuf = (unsigned char *)realloc(tmpbuf, oldsize, tmpbuflen);
2439*1031c584SApple OSS Distributions 			}
2440*1031c584SApple OSS Distributions 			tmpbuf[tmpbufpos++] = (acc >> 16) & 0xff;
2441*1031c584SApple OSS Distributions 			if (numeq < 2) {
2442*1031c584SApple OSS Distributions 				tmpbuf[tmpbufpos++] = (acc >> 8) & 0xff;
2443*1031c584SApple OSS Distributions 			}
2444*1031c584SApple OSS Distributions 			if (numeq < 1) {
2445*1031c584SApple OSS Distributions 				tmpbuf[tmpbufpos++] = acc & 0xff;
2446*1031c584SApple OSS Distributions 			}
2447*1031c584SApple OSS Distributions 		}
2448*1031c584SApple OSS Distributions 		c = nextChar();
2449*1031c584SApple OSS Distributions 	}
2450*1031c584SApple OSS Distributions 	*size = tmpbufpos;
2451*1031c584SApple OSS Distributions 	if (*size == 0) {
2452*1031c584SApple OSS Distributions 		safe_free(tmpbuf, tmpbuflen);
2453*1031c584SApple OSS Distributions 		return 0;
2454*1031c584SApple OSS Distributions 	}
2455*1031c584SApple OSS Distributions 	return tmpbuf;
2456*1031c584SApple OSS Distributions }
2457*1031c584SApple OSS Distributions 
2458*1031c584SApple OSS Distributions static void *
getHexData(parser_state_t * state,unsigned int * size)2459*1031c584SApple OSS Distributions getHexData(parser_state_t *state, unsigned int *size)
2460*1031c584SApple OSS Distributions {
2461*1031c584SApple OSS Distributions 	int c;
2462*1031c584SApple OSS Distributions 	unsigned char *d, *start;
2463*1031c584SApple OSS Distributions 
2464*1031c584SApple OSS Distributions 	size_t buflen = DATA_ALLOC_SIZE; // initial buffer size
2465*1031c584SApple OSS Distributions 	start = d = (unsigned char *)malloc(buflen);
2466*1031c584SApple OSS Distributions 	c = currentChar();
2467*1031c584SApple OSS Distributions 
2468*1031c584SApple OSS Distributions 	while (c != '<') {
2469*1031c584SApple OSS Distributions 		if (isSpace(c)) {
2470*1031c584SApple OSS Distributions 			while ((c = nextChar()) != 0 && isSpace(c)) {
2471*1031c584SApple OSS Distributions 			}
2472*1031c584SApple OSS Distributions 		}
2473*1031c584SApple OSS Distributions 		;
2474*1031c584SApple OSS Distributions 		if (c == '\n') {
2475*1031c584SApple OSS Distributions 			state->lineNumber++;
2476*1031c584SApple OSS Distributions 			c = nextChar();
2477*1031c584SApple OSS Distributions 			continue;
2478*1031c584SApple OSS Distributions 		}
2479*1031c584SApple OSS Distributions 
2480*1031c584SApple OSS Distributions 		// get high nibble
2481*1031c584SApple OSS Distributions 		if (isDigit(c)) {
2482*1031c584SApple OSS Distributions 			*d = (c - '0') << 4;
2483*1031c584SApple OSS Distributions 		} else if (isAlphaDigit(c)) {
2484*1031c584SApple OSS Distributions 			*d =  (0xa + (c - 'a')) << 4;
2485*1031c584SApple OSS Distributions 		} else {
2486*1031c584SApple OSS Distributions 			goto error;
2487*1031c584SApple OSS Distributions 		}
2488*1031c584SApple OSS Distributions 
2489*1031c584SApple OSS Distributions 		// get low nibble
2490*1031c584SApple OSS Distributions 		c = nextChar();
2491*1031c584SApple OSS Distributions 		if (isDigit(c)) {
2492*1031c584SApple OSS Distributions 			*d |= c - '0';
2493*1031c584SApple OSS Distributions 		} else if (isAlphaDigit(c)) {
2494*1031c584SApple OSS Distributions 			*d |= 0xa + (c - 'a');
2495*1031c584SApple OSS Distributions 		} else {
2496*1031c584SApple OSS Distributions 			goto error;
2497*1031c584SApple OSS Distributions 		}
2498*1031c584SApple OSS Distributions 
2499*1031c584SApple OSS Distributions 		d++;
2500*1031c584SApple OSS Distributions 		size_t oldsize = d - start;
2501*1031c584SApple OSS Distributions 		if (oldsize >= buflen) {
2502*1031c584SApple OSS Distributions 			assert(oldsize == buflen);
2503*1031c584SApple OSS Distributions 			buflen *= 2;
2504*1031c584SApple OSS Distributions 			start = (unsigned char *)realloc(start, oldsize, buflen);
2505*1031c584SApple OSS Distributions 			d = start + oldsize;
2506*1031c584SApple OSS Distributions 		}
2507*1031c584SApple OSS Distributions 		c = nextChar();
2508*1031c584SApple OSS Distributions 	}
2509*1031c584SApple OSS Distributions 
2510*1031c584SApple OSS Distributions 	*size = d - start;
2511*1031c584SApple OSS Distributions 	return start;
2512*1031c584SApple OSS Distributions 
2513*1031c584SApple OSS Distributions error:
2514*1031c584SApple OSS Distributions 
2515*1031c584SApple OSS Distributions 	*size = 0;
2516*1031c584SApple OSS Distributions 	safe_free(start, buflen);
2517*1031c584SApple OSS Distributions 	return 0;
2518*1031c584SApple OSS Distributions }
2519*1031c584SApple OSS Distributions 
2520*1031c584SApple OSS Distributions static int
yylex(YYSTYPE * lvalp,parser_state_t * state)2521*1031c584SApple OSS Distributions yylex(YYSTYPE *lvalp, parser_state_t *state)
2522*1031c584SApple OSS Distributions {
2523*1031c584SApple OSS Distributions 	int c, i;
2524*1031c584SApple OSS Distributions 	int tagType;
2525*1031c584SApple OSS Distributions 	char tag[TAG_MAX_LENGTH];
2526*1031c584SApple OSS Distributions 	int attributeCount;
2527*1031c584SApple OSS Distributions 	char attributes[TAG_MAX_ATTRIBUTES][TAG_MAX_LENGTH];
2528*1031c584SApple OSS Distributions 	char values[TAG_MAX_ATTRIBUTES][TAG_MAX_LENGTH];
2529*1031c584SApple OSS Distributions 	object_t *object;
2530*1031c584SApple OSS Distributions 	int alloc_length;
2531*1031c584SApple OSS Distributions top:
2532*1031c584SApple OSS Distributions 	c = currentChar();
2533*1031c584SApple OSS Distributions 
2534*1031c584SApple OSS Distributions 	/* skip white space  */
2535*1031c584SApple OSS Distributions 	if (isSpace(c)) {
2536*1031c584SApple OSS Distributions 		while ((c = nextChar()) != 0 && isSpace(c)) {
2537*1031c584SApple OSS Distributions 		}
2538*1031c584SApple OSS Distributions 	}
2539*1031c584SApple OSS Distributions 	;
2540*1031c584SApple OSS Distributions 
2541*1031c584SApple OSS Distributions 	/* keep track of line number, don't return \n's */
2542*1031c584SApple OSS Distributions 	if (c == '\n') {
2543*1031c584SApple OSS Distributions 		STATE->lineNumber++;
2544*1031c584SApple OSS Distributions 		(void)nextChar();
2545*1031c584SApple OSS Distributions 		goto top;
2546*1031c584SApple OSS Distributions 	}
2547*1031c584SApple OSS Distributions 
2548*1031c584SApple OSS Distributions 	// end of the buffer?
2549*1031c584SApple OSS Distributions 	if (!c) {
2550*1031c584SApple OSS Distributions 		return 0;
2551*1031c584SApple OSS Distributions 	}
2552*1031c584SApple OSS Distributions 
2553*1031c584SApple OSS Distributions 	tagType = getTag(STATE, tag, &attributeCount, attributes, values);
2554*1031c584SApple OSS Distributions 	if (tagType == TAG_BAD) {
2555*1031c584SApple OSS Distributions 		return SYNTAX_ERROR;
2556*1031c584SApple OSS Distributions 	}
2557*1031c584SApple OSS Distributions 	if (tagType == TAG_IGNORE) {
2558*1031c584SApple OSS Distributions 		goto top;
2559*1031c584SApple OSS Distributions 	}
2560*1031c584SApple OSS Distributions 
2561*1031c584SApple OSS Distributions 	// handle allocation and check for "ID" and "IDREF" tags up front
2562*1031c584SApple OSS Distributions 	*lvalp = object = newObject(STATE);
2563*1031c584SApple OSS Distributions 	object->idref = -1;
2564*1031c584SApple OSS Distributions 	for (i = 0; i < attributeCount; i++) {
2565*1031c584SApple OSS Distributions 		if (attributes[i][0] == 'I' && attributes[i][1] == 'D') {
2566*1031c584SApple OSS Distributions 			// check for idref's, note: we ignore the tag, for
2567*1031c584SApple OSS Distributions 			// this to work correctly, all idrefs must be unique
2568*1031c584SApple OSS Distributions 			// across the whole serialization
2569*1031c584SApple OSS Distributions 			if (attributes[i][2] == 'R' && attributes[i][3] == 'E' &&
2570*1031c584SApple OSS Distributions 			    attributes[i][4] == 'F' && !attributes[i][5]) {
2571*1031c584SApple OSS Distributions 				if (tagType != TAG_EMPTY) {
2572*1031c584SApple OSS Distributions 					return SYNTAX_ERROR;
2573*1031c584SApple OSS Distributions 				}
2574*1031c584SApple OSS Distributions 				object->idref = strtol(values[i], NULL, 0);
2575*1031c584SApple OSS Distributions 				return IDREF;
2576*1031c584SApple OSS Distributions 			}
2577*1031c584SApple OSS Distributions 			// check for id's
2578*1031c584SApple OSS Distributions 			if (!attributes[i][2]) {
2579*1031c584SApple OSS Distributions 				object->idref = strtol(values[i], NULL, 0);
2580*1031c584SApple OSS Distributions 			} else {
2581*1031c584SApple OSS Distributions 				return SYNTAX_ERROR;
2582*1031c584SApple OSS Distributions 			}
2583*1031c584SApple OSS Distributions 		}
2584*1031c584SApple OSS Distributions 	}
2585*1031c584SApple OSS Distributions 
2586*1031c584SApple OSS Distributions 	switch (*tag) {
2587*1031c584SApple OSS Distributions 	case 'a':
2588*1031c584SApple OSS Distributions 		if (!strcmp(tag, "array")) {
2589*1031c584SApple OSS Distributions 			if (tagType == TAG_EMPTY) {
2590*1031c584SApple OSS Distributions 				object->elements = NULL;
2591*1031c584SApple OSS Distributions 				return ARRAY;
2592*1031c584SApple OSS Distributions 			}
2593*1031c584SApple OSS Distributions 			return (tagType == TAG_START) ? '(' : ')';
2594*1031c584SApple OSS Distributions 		}
2595*1031c584SApple OSS Distributions 		break;
2596*1031c584SApple OSS Distributions 	case 'd':
2597*1031c584SApple OSS Distributions 		if (!strcmp(tag, "dict")) {
2598*1031c584SApple OSS Distributions 			if (tagType == TAG_EMPTY) {
2599*1031c584SApple OSS Distributions 				object->elements = NULL;
2600*1031c584SApple OSS Distributions 				return DICTIONARY;
2601*1031c584SApple OSS Distributions 			}
2602*1031c584SApple OSS Distributions 			return (tagType == TAG_START) ? '{' : '}';
2603*1031c584SApple OSS Distributions 		}
2604*1031c584SApple OSS Distributions 		if (!strcmp(tag, "data")) {
2605*1031c584SApple OSS Distributions 			unsigned int size;
2606*1031c584SApple OSS Distributions 			if (tagType == TAG_EMPTY) {
2607*1031c584SApple OSS Distributions 				object->data = NULL;
2608*1031c584SApple OSS Distributions 				object->size = 0;
2609*1031c584SApple OSS Distributions 				return DATA;
2610*1031c584SApple OSS Distributions 			}
2611*1031c584SApple OSS Distributions 
2612*1031c584SApple OSS Distributions 			bool isHexFormat = false;
2613*1031c584SApple OSS Distributions 			for (i = 0; i < attributeCount; i++) {
2614*1031c584SApple OSS Distributions 				if (!strcmp(attributes[i], "format") && !strcmp(values[i], "hex")) {
2615*1031c584SApple OSS Distributions 					isHexFormat = true;
2616*1031c584SApple OSS Distributions 					break;
2617*1031c584SApple OSS Distributions 				}
2618*1031c584SApple OSS Distributions 			}
2619*1031c584SApple OSS Distributions 			// CF encoded is the default form
2620*1031c584SApple OSS Distributions 			if (isHexFormat) {
2621*1031c584SApple OSS Distributions 				object->data = getHexData(STATE, &size);
2622*1031c584SApple OSS Distributions 			} else {
2623*1031c584SApple OSS Distributions 				object->data = getCFEncodedData(STATE, &size);
2624*1031c584SApple OSS Distributions 			}
2625*1031c584SApple OSS Distributions 			object->size = size;
2626*1031c584SApple OSS Distributions 			if ((getTag(STATE, tag, &attributeCount, attributes, values) != TAG_END) || strcmp(tag, "data")) {
2627*1031c584SApple OSS Distributions 				return SYNTAX_ERROR;
2628*1031c584SApple OSS Distributions 			}
2629*1031c584SApple OSS Distributions 			return DATA;
2630*1031c584SApple OSS Distributions 		}
2631*1031c584SApple OSS Distributions 		break;
2632*1031c584SApple OSS Distributions 	case 'f':
2633*1031c584SApple OSS Distributions 		if (!strcmp(tag, "false")) {
2634*1031c584SApple OSS Distributions 			if (tagType == TAG_EMPTY) {
2635*1031c584SApple OSS Distributions 				object->number = 0;
2636*1031c584SApple OSS Distributions 				return BOOLEAN;
2637*1031c584SApple OSS Distributions 			}
2638*1031c584SApple OSS Distributions 		}
2639*1031c584SApple OSS Distributions 		break;
2640*1031c584SApple OSS Distributions 	case 'i':
2641*1031c584SApple OSS Distributions 		if (!strcmp(tag, "integer")) {
2642*1031c584SApple OSS Distributions 			object->size = 64;      // default
2643*1031c584SApple OSS Distributions 			for (i = 0; i < attributeCount; i++) {
2644*1031c584SApple OSS Distributions 				if (!strcmp(attributes[i], "size")) {
2645*1031c584SApple OSS Distributions 					object->size = strtoul(values[i], NULL, 0);
2646*1031c584SApple OSS Distributions 				}
2647*1031c584SApple OSS Distributions 			}
2648*1031c584SApple OSS Distributions 			if (tagType == TAG_EMPTY) {
2649*1031c584SApple OSS Distributions 				object->number = 0;
2650*1031c584SApple OSS Distributions 				return NUMBER;
2651*1031c584SApple OSS Distributions 			}
2652*1031c584SApple OSS Distributions 			object->number = getNumber(STATE);
2653*1031c584SApple OSS Distributions 			if ((getTag(STATE, tag, &attributeCount, attributes, values) != TAG_END) || strcmp(tag, "integer")) {
2654*1031c584SApple OSS Distributions 				return SYNTAX_ERROR;
2655*1031c584SApple OSS Distributions 			}
2656*1031c584SApple OSS Distributions 			return NUMBER;
2657*1031c584SApple OSS Distributions 		}
2658*1031c584SApple OSS Distributions 		break;
2659*1031c584SApple OSS Distributions 	case 'k':
2660*1031c584SApple OSS Distributions 		if (!strcmp(tag, "key")) {
2661*1031c584SApple OSS Distributions 			if (tagType == TAG_EMPTY) {
2662*1031c584SApple OSS Distributions 				return SYNTAX_ERROR;
2663*1031c584SApple OSS Distributions 			}
2664*1031c584SApple OSS Distributions 			object->string = getString(STATE, &alloc_length);
2665*1031c584SApple OSS Distributions 			if (!object->string) {
2666*1031c584SApple OSS Distributions 				return SYNTAX_ERROR;
2667*1031c584SApple OSS Distributions 			}
2668*1031c584SApple OSS Distributions 			object->string_alloc_length = alloc_length;
2669*1031c584SApple OSS Distributions 			if ((getTag(STATE, tag, &attributeCount, attributes, values) != TAG_END)
2670*1031c584SApple OSS Distributions 			    || strcmp(tag, "key")) {
2671*1031c584SApple OSS Distributions 				return SYNTAX_ERROR;
2672*1031c584SApple OSS Distributions 			}
2673*1031c584SApple OSS Distributions 			return KEY;
2674*1031c584SApple OSS Distributions 		}
2675*1031c584SApple OSS Distributions 		break;
2676*1031c584SApple OSS Distributions 	case 'p':
2677*1031c584SApple OSS Distributions 		if (!strcmp(tag, "plist")) {
2678*1031c584SApple OSS Distributions 			freeObject(STATE, object);
2679*1031c584SApple OSS Distributions 			goto top;
2680*1031c584SApple OSS Distributions 		}
2681*1031c584SApple OSS Distributions 		break;
2682*1031c584SApple OSS Distributions 	case 's':
2683*1031c584SApple OSS Distributions 		if (!strcmp(tag, "string")) {
2684*1031c584SApple OSS Distributions 			if (tagType == TAG_EMPTY) {
2685*1031c584SApple OSS Distributions 				object->string = (char *)malloc(1);
2686*1031c584SApple OSS Distributions 				object->string_alloc_length = 1;
2687*1031c584SApple OSS Distributions 				object->string[0] = 0;
2688*1031c584SApple OSS Distributions 				return STRING;
2689*1031c584SApple OSS Distributions 			}
2690*1031c584SApple OSS Distributions 			object->string = getString(STATE, &alloc_length);
2691*1031c584SApple OSS Distributions 			if (!object->string) {
2692*1031c584SApple OSS Distributions 				return SYNTAX_ERROR;
2693*1031c584SApple OSS Distributions 			}
2694*1031c584SApple OSS Distributions 			object->string_alloc_length = alloc_length;
2695*1031c584SApple OSS Distributions 			if ((getTag(STATE, tag, &attributeCount, attributes, values) != TAG_END)
2696*1031c584SApple OSS Distributions 			    || strcmp(tag, "string")) {
2697*1031c584SApple OSS Distributions 				return SYNTAX_ERROR;
2698*1031c584SApple OSS Distributions 			}
2699*1031c584SApple OSS Distributions 			return STRING;
2700*1031c584SApple OSS Distributions 		}
2701*1031c584SApple OSS Distributions 		if (!strcmp(tag, "set")) {
2702*1031c584SApple OSS Distributions 			if (tagType == TAG_EMPTY) {
2703*1031c584SApple OSS Distributions 				object->elements = NULL;
2704*1031c584SApple OSS Distributions 				return SET;
2705*1031c584SApple OSS Distributions 			}
2706*1031c584SApple OSS Distributions 			if (tagType == TAG_START) {
2707*1031c584SApple OSS Distributions 				return '[';
2708*1031c584SApple OSS Distributions 			} else {
2709*1031c584SApple OSS Distributions 				return ']';
2710*1031c584SApple OSS Distributions 			}
2711*1031c584SApple OSS Distributions 		}
2712*1031c584SApple OSS Distributions 		break;
2713*1031c584SApple OSS Distributions 	case 't':
2714*1031c584SApple OSS Distributions 		if (!strcmp(tag, "true")) {
2715*1031c584SApple OSS Distributions 			if (tagType == TAG_EMPTY) {
2716*1031c584SApple OSS Distributions 				object->number = 1;
2717*1031c584SApple OSS Distributions 				return BOOLEAN;
2718*1031c584SApple OSS Distributions 			}
2719*1031c584SApple OSS Distributions 		}
2720*1031c584SApple OSS Distributions 		break;
2721*1031c584SApple OSS Distributions 	}
2722*1031c584SApple OSS Distributions 
2723*1031c584SApple OSS Distributions 	return SYNTAX_ERROR;
2724*1031c584SApple OSS Distributions }
2725*1031c584SApple OSS Distributions 
2726*1031c584SApple OSS Distributions // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2727*1031c584SApple OSS Distributions // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2728*1031c584SApple OSS Distributions // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2729*1031c584SApple OSS Distributions 
2730*1031c584SApple OSS Distributions // "java" like allocation, if this code hits a syntax error in the
2731*1031c584SApple OSS Distributions // the middle of the parsed string we just bail with pointers hanging
2732*1031c584SApple OSS Distributions // all over place, this code helps keeps it all together
2733*1031c584SApple OSS Distributions 
2734*1031c584SApple OSS Distributions //static int object_count = 0;
2735*1031c584SApple OSS Distributions 
2736*1031c584SApple OSS Distributions object_t *
newObject(parser_state_t * state)2737*1031c584SApple OSS Distributions newObject(parser_state_t *state)
2738*1031c584SApple OSS Distributions {
2739*1031c584SApple OSS Distributions 	object_t *o;
2740*1031c584SApple OSS Distributions 
2741*1031c584SApple OSS Distributions 	if (state->freeObjects) {
2742*1031c584SApple OSS Distributions 		o = state->freeObjects;
2743*1031c584SApple OSS Distributions 		state->freeObjects = state->freeObjects->next;
2744*1031c584SApple OSS Distributions 	} else {
2745*1031c584SApple OSS Distributions 		o = malloc_type(object_t);
2746*1031c584SApple OSS Distributions //		object_count++;
2747*1031c584SApple OSS Distributions 		o->free = state->objects;
2748*1031c584SApple OSS Distributions 		state->objects = o;
2749*1031c584SApple OSS Distributions 	}
2750*1031c584SApple OSS Distributions 
2751*1031c584SApple OSS Distributions 	return o;
2752*1031c584SApple OSS Distributions }
2753*1031c584SApple OSS Distributions 
2754*1031c584SApple OSS Distributions void
freeObject(parser_state_t * state,object_t * o)2755*1031c584SApple OSS Distributions freeObject(parser_state_t * state, object_t *o)
2756*1031c584SApple OSS Distributions {
2757*1031c584SApple OSS Distributions 	o->next = state->freeObjects;
2758*1031c584SApple OSS Distributions 	state->freeObjects = o;
2759*1031c584SApple OSS Distributions }
2760*1031c584SApple OSS Distributions 
2761*1031c584SApple OSS Distributions void
cleanupObjects(parser_state_t * state)2762*1031c584SApple OSS Distributions cleanupObjects(parser_state_t *state)
2763*1031c584SApple OSS Distributions {
2764*1031c584SApple OSS Distributions 	object_t *t, *o = state->objects;
2765*1031c584SApple OSS Distributions 
2766*1031c584SApple OSS Distributions 	while (o) {
2767*1031c584SApple OSS Distributions 		if (o->object) {
2768*1031c584SApple OSS Distributions //			printf("OSUnserializeXML: releasing object o=%x object=%x\n", (int)o, (int)o->object);
2769*1031c584SApple OSS Distributions 			o->object->release();
2770*1031c584SApple OSS Distributions 		}
2771*1031c584SApple OSS Distributions 		if (o->data) {
2772*1031c584SApple OSS Distributions //			printf("OSUnserializeXML: freeing   object o=%x data=%x\n", (int)o, (int)o->data);
2773*1031c584SApple OSS Distributions 			free(o->data);
2774*1031c584SApple OSS Distributions 		}
2775*1031c584SApple OSS Distributions 		if (o->key) {
2776*1031c584SApple OSS Distributions //			printf("OSUnserializeXML: releasing object o=%x key=%x\n", (int)o, (int)o->key);
2777*1031c584SApple OSS Distributions 			o->key->release();
2778*1031c584SApple OSS Distributions 		}
2779*1031c584SApple OSS Distributions 		if (o->string) {
2780*1031c584SApple OSS Distributions //			printf("OSUnserializeXML: freeing   object o=%x string=%x\n", (int)o, (int)o->string);
2781*1031c584SApple OSS Distributions 			free(o->string);
2782*1031c584SApple OSS Distributions 		}
2783*1031c584SApple OSS Distributions 
2784*1031c584SApple OSS Distributions 		t = o;
2785*1031c584SApple OSS Distributions 		o = o->free;
2786*1031c584SApple OSS Distributions 		free_type(object_t, t);
2787*1031c584SApple OSS Distributions //		object_count--;
2788*1031c584SApple OSS Distributions 	}
2789*1031c584SApple OSS Distributions //	printf("object_count = %d\n", object_count);
2790*1031c584SApple OSS Distributions }
2791*1031c584SApple OSS Distributions 
2792*1031c584SApple OSS Distributions // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2793*1031c584SApple OSS Distributions // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2794*1031c584SApple OSS Distributions // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2795*1031c584SApple OSS Distributions 
2796*1031c584SApple OSS Distributions static void
rememberObject(parser_state_t * state,int tag,OSObject * o)2797*1031c584SApple OSS Distributions rememberObject(parser_state_t *state, int tag, OSObject *o)
2798*1031c584SApple OSS Distributions {
2799*1031c584SApple OSS Distributions 	char key[16];
2800*1031c584SApple OSS Distributions 	snprintf(key, 16, "%u", tag);
2801*1031c584SApple OSS Distributions 
2802*1031c584SApple OSS Distributions //	printf("remember key %s\n", key);
2803*1031c584SApple OSS Distributions 
2804*1031c584SApple OSS Distributions 	state->tags->setObject(key, o);
2805*1031c584SApple OSS Distributions }
2806*1031c584SApple OSS Distributions 
2807*1031c584SApple OSS Distributions static object_t *
retrieveObject(parser_state_t * state,int tag)2808*1031c584SApple OSS Distributions retrieveObject(parser_state_t *state, int tag)
2809*1031c584SApple OSS Distributions {
2810*1031c584SApple OSS Distributions 	OSObject *ref;
2811*1031c584SApple OSS Distributions 	object_t *o;
2812*1031c584SApple OSS Distributions 	char key[16];
2813*1031c584SApple OSS Distributions 	snprintf(key, 16, "%u", tag);
2814*1031c584SApple OSS Distributions 
2815*1031c584SApple OSS Distributions //	printf("retrieve key '%s'\n", key);
2816*1031c584SApple OSS Distributions 
2817*1031c584SApple OSS Distributions 	ref = state->tags->getObject(key);
2818*1031c584SApple OSS Distributions 	if (!ref) {
2819*1031c584SApple OSS Distributions 		return 0;
2820*1031c584SApple OSS Distributions 	}
2821*1031c584SApple OSS Distributions 
2822*1031c584SApple OSS Distributions 	o = newObject(state);
2823*1031c584SApple OSS Distributions 	o->object = ref;
2824*1031c584SApple OSS Distributions 	return o;
2825*1031c584SApple OSS Distributions }
2826*1031c584SApple OSS Distributions 
2827*1031c584SApple OSS Distributions // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2828*1031c584SApple OSS Distributions // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2829*1031c584SApple OSS Distributions // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2830*1031c584SApple OSS Distributions 
2831*1031c584SApple OSS Distributions object_t *
buildDictionary(parser_state_t * state,object_t * header)2832*1031c584SApple OSS Distributions buildDictionary(parser_state_t *state, object_t * header)
2833*1031c584SApple OSS Distributions {
2834*1031c584SApple OSS Distributions 	object_t *o, *t;
2835*1031c584SApple OSS Distributions 	int count = 0;
2836*1031c584SApple OSS Distributions 	OSDictionary *dict;
2837*1031c584SApple OSS Distributions 
2838*1031c584SApple OSS Distributions 	// get count and reverse order
2839*1031c584SApple OSS Distributions 	o = header->elements;
2840*1031c584SApple OSS Distributions 	header->elements = 0;
2841*1031c584SApple OSS Distributions 	while (o) {
2842*1031c584SApple OSS Distributions 		count++;
2843*1031c584SApple OSS Distributions 		t = o;
2844*1031c584SApple OSS Distributions 		o = o->next;
2845*1031c584SApple OSS Distributions 
2846*1031c584SApple OSS Distributions 		t->next = header->elements;
2847*1031c584SApple OSS Distributions 		header->elements = t;
2848*1031c584SApple OSS Distributions 	}
2849*1031c584SApple OSS Distributions 
2850*1031c584SApple OSS Distributions 	dict = OSDictionary::withCapacity(count);
2851*1031c584SApple OSS Distributions 	if (header->idref >= 0) {
2852*1031c584SApple OSS Distributions 		rememberObject(state, header->idref, dict);
2853*1031c584SApple OSS Distributions 	}
2854*1031c584SApple OSS Distributions 
2855*1031c584SApple OSS Distributions 	o = header->elements;
2856*1031c584SApple OSS Distributions 	while (o) {
2857*1031c584SApple OSS Distributions 		dict->setObject(o->key, o->object);
2858*1031c584SApple OSS Distributions 
2859*1031c584SApple OSS Distributions 		o->key->release();
2860*1031c584SApple OSS Distributions 		o->object->release();
2861*1031c584SApple OSS Distributions 		o->key = 0;
2862*1031c584SApple OSS Distributions 		o->object = 0;
2863*1031c584SApple OSS Distributions 
2864*1031c584SApple OSS Distributions 		t = o;
2865*1031c584SApple OSS Distributions 		o = o->next;
2866*1031c584SApple OSS Distributions 		freeObject(state, t);
2867*1031c584SApple OSS Distributions 	}
2868*1031c584SApple OSS Distributions 	o = header;
2869*1031c584SApple OSS Distributions 	o->object = dict;
2870*1031c584SApple OSS Distributions 	return o;
2871*1031c584SApple OSS Distributions };
2872*1031c584SApple OSS Distributions 
2873*1031c584SApple OSS Distributions object_t *
buildArray(parser_state_t * state,object_t * header)2874*1031c584SApple OSS Distributions buildArray(parser_state_t *state, object_t * header)
2875*1031c584SApple OSS Distributions {
2876*1031c584SApple OSS Distributions 	object_t *o, *t;
2877*1031c584SApple OSS Distributions 	int count = 0;
2878*1031c584SApple OSS Distributions 	OSArray *array;
2879*1031c584SApple OSS Distributions 
2880*1031c584SApple OSS Distributions 	// get count and reverse order
2881*1031c584SApple OSS Distributions 	o = header->elements;
2882*1031c584SApple OSS Distributions 	header->elements = 0;
2883*1031c584SApple OSS Distributions 	while (o) {
2884*1031c584SApple OSS Distributions 		count++;
2885*1031c584SApple OSS Distributions 		t = o;
2886*1031c584SApple OSS Distributions 		o = o->next;
2887*1031c584SApple OSS Distributions 
2888*1031c584SApple OSS Distributions 		t->next = header->elements;
2889*1031c584SApple OSS Distributions 		header->elements = t;
2890*1031c584SApple OSS Distributions 	}
2891*1031c584SApple OSS Distributions 
2892*1031c584SApple OSS Distributions 	array = OSArray::withCapacity(count);
2893*1031c584SApple OSS Distributions 	if (header->idref >= 0) {
2894*1031c584SApple OSS Distributions 		rememberObject(state, header->idref, array);
2895*1031c584SApple OSS Distributions 	}
2896*1031c584SApple OSS Distributions 
2897*1031c584SApple OSS Distributions 	o = header->elements;
2898*1031c584SApple OSS Distributions 	while (o) {
2899*1031c584SApple OSS Distributions 		array->setObject(o->object);
2900*1031c584SApple OSS Distributions 
2901*1031c584SApple OSS Distributions 		o->object->release();
2902*1031c584SApple OSS Distributions 		o->object = 0;
2903*1031c584SApple OSS Distributions 
2904*1031c584SApple OSS Distributions 		t = o;
2905*1031c584SApple OSS Distributions 		o = o->next;
2906*1031c584SApple OSS Distributions 		freeObject(state, t);
2907*1031c584SApple OSS Distributions 	}
2908*1031c584SApple OSS Distributions 	o = header;
2909*1031c584SApple OSS Distributions 	o->object = array;
2910*1031c584SApple OSS Distributions 	return o;
2911*1031c584SApple OSS Distributions };
2912*1031c584SApple OSS Distributions 
2913*1031c584SApple OSS Distributions object_t *
buildSet(parser_state_t * state,object_t * header)2914*1031c584SApple OSS Distributions buildSet(parser_state_t *state, object_t *header)
2915*1031c584SApple OSS Distributions {
2916*1031c584SApple OSS Distributions 	object_t *o = buildArray(state, header);
2917*1031c584SApple OSS Distributions 
2918*1031c584SApple OSS Distributions #if KERNEL
2919*1031c584SApple OSS Distributions 	OSArray *array = (OSArray *)o->object;
2920*1031c584SApple OSS Distributions 	OSSet *set = OSSet::withArray(array, array->getCapacity());
2921*1031c584SApple OSS Distributions 
2922*1031c584SApple OSS Distributions 	// write over the reference created in buildArray
2923*1031c584SApple OSS Distributions 	if (header->idref >= 0) {
2924*1031c584SApple OSS Distributions 		rememberObject(state, header->idref, set);
2925*1031c584SApple OSS Distributions 	}
2926*1031c584SApple OSS Distributions 
2927*1031c584SApple OSS Distributions 	array->release();
2928*1031c584SApple OSS Distributions 	o->object = set;
2929*1031c584SApple OSS Distributions #endif /* KERNEL */
2930*1031c584SApple OSS Distributions 	return o;
2931*1031c584SApple OSS Distributions };
2932*1031c584SApple OSS Distributions 
2933*1031c584SApple OSS Distributions object_t *
buildString(parser_state_t * state,object_t * o)2934*1031c584SApple OSS Distributions buildString(parser_state_t *state, object_t *o)
2935*1031c584SApple OSS Distributions {
2936*1031c584SApple OSS Distributions 	OSString *string;
2937*1031c584SApple OSS Distributions 
2938*1031c584SApple OSS Distributions 	string = OSString::withCString(o->string);
2939*1031c584SApple OSS Distributions 	if (o->idref >= 0) {
2940*1031c584SApple OSS Distributions 		rememberObject(state, o->idref, string);
2941*1031c584SApple OSS Distributions 	}
2942*1031c584SApple OSS Distributions 
2943*1031c584SApple OSS Distributions 	free(o->string);
2944*1031c584SApple OSS Distributions 	o->string = 0;
2945*1031c584SApple OSS Distributions 	o->object = string;
2946*1031c584SApple OSS Distributions 
2947*1031c584SApple OSS Distributions 	return o;
2948*1031c584SApple OSS Distributions };
2949*1031c584SApple OSS Distributions 
2950*1031c584SApple OSS Distributions object_t *
buildSymbol(parser_state_t * state,object_t * o)2951*1031c584SApple OSS Distributions buildSymbol(parser_state_t *state, object_t *o)
2952*1031c584SApple OSS Distributions {
2953*1031c584SApple OSS Distributions 	OSSymbol *symbol;
2954*1031c584SApple OSS Distributions 
2955*1031c584SApple OSS Distributions 	symbol = const_cast < OSSymbol * > (OSSymbol::withCString(o->string));
2956*1031c584SApple OSS Distributions 	if (o->idref >= 0) {
2957*1031c584SApple OSS Distributions 		rememberObject(state, o->idref, symbol);
2958*1031c584SApple OSS Distributions 	}
2959*1031c584SApple OSS Distributions 
2960*1031c584SApple OSS Distributions 	safe_free(o->string, o->string_alloc_length);
2961*1031c584SApple OSS Distributions 	o->string = 0;
2962*1031c584SApple OSS Distributions 	o->object = symbol;
2963*1031c584SApple OSS Distributions 
2964*1031c584SApple OSS Distributions 	return o;
2965*1031c584SApple OSS Distributions };
2966*1031c584SApple OSS Distributions 
2967*1031c584SApple OSS Distributions object_t *
buildData(parser_state_t * state,object_t * o)2968*1031c584SApple OSS Distributions buildData(parser_state_t *state, object_t *o)
2969*1031c584SApple OSS Distributions {
2970*1031c584SApple OSS Distributions 	OSData *data;
2971*1031c584SApple OSS Distributions 
2972*1031c584SApple OSS Distributions 	if (o->size) {
2973*1031c584SApple OSS Distributions 		data = OSData::withBytes(o->data, o->size);
2974*1031c584SApple OSS Distributions 	} else {
2975*1031c584SApple OSS Distributions 		data = OSData::withCapacity(0);
2976*1031c584SApple OSS Distributions 	}
2977*1031c584SApple OSS Distributions 	if (o->idref >= 0) {
2978*1031c584SApple OSS Distributions 		rememberObject(state, o->idref, data);
2979*1031c584SApple OSS Distributions 	}
2980*1031c584SApple OSS Distributions 
2981*1031c584SApple OSS Distributions 	if (o->size) {
2982*1031c584SApple OSS Distributions 		free(o->data);
2983*1031c584SApple OSS Distributions 	}
2984*1031c584SApple OSS Distributions 	o->data = 0;
2985*1031c584SApple OSS Distributions 	o->object = data;
2986*1031c584SApple OSS Distributions 	return o;
2987*1031c584SApple OSS Distributions };
2988*1031c584SApple OSS Distributions 
2989*1031c584SApple OSS Distributions object_t *
buildNumber(parser_state_t * state,object_t * o)2990*1031c584SApple OSS Distributions buildNumber(parser_state_t *state, object_t *o)
2991*1031c584SApple OSS Distributions {
2992*1031c584SApple OSS Distributions 	OSNumber *number = OSNumber::withNumber(o->number, o->size);
2993*1031c584SApple OSS Distributions 
2994*1031c584SApple OSS Distributions 	if (o->idref >= 0) {
2995*1031c584SApple OSS Distributions 		rememberObject(state, o->idref, number);
2996*1031c584SApple OSS Distributions 	}
2997*1031c584SApple OSS Distributions 
2998*1031c584SApple OSS Distributions 	o->object = number;
2999*1031c584SApple OSS Distributions 	return o;
3000*1031c584SApple OSS Distributions };
3001*1031c584SApple OSS Distributions 
3002*1031c584SApple OSS Distributions object_t *
buildBoolean(parser_state_t * state __unused,object_t * o)3003*1031c584SApple OSS Distributions buildBoolean(parser_state_t *state __unused, object_t *o)
3004*1031c584SApple OSS Distributions {
3005*1031c584SApple OSS Distributions 	o->object = ((o->number == 0) ? kOSBooleanFalse : kOSBooleanTrue);
3006*1031c584SApple OSS Distributions 	o->object->retain();
3007*1031c584SApple OSS Distributions 	return o;
3008*1031c584SApple OSS Distributions };
3009*1031c584SApple OSS Distributions 
3010*1031c584SApple OSS Distributions OSObject*
OSUnserializeXML(const char * buffer,OSString ** errorString)3011*1031c584SApple OSS Distributions OSUnserializeXML(const char *buffer, OSString **errorString)
3012*1031c584SApple OSS Distributions {
3013*1031c584SApple OSS Distributions 	OSObject *object;
3014*1031c584SApple OSS Distributions 
3015*1031c584SApple OSS Distributions 	if (!buffer) {
3016*1031c584SApple OSS Distributions 		return 0;
3017*1031c584SApple OSS Distributions 	}
3018*1031c584SApple OSS Distributions 	parser_state_t *state = (parser_state_t *)malloc_type(parser_state_t);
3019*1031c584SApple OSS Distributions 	if (!state) {
3020*1031c584SApple OSS Distributions 		return 0;
3021*1031c584SApple OSS Distributions 	}
3022*1031c584SApple OSS Distributions 
3023*1031c584SApple OSS Distributions 	// just in case
3024*1031c584SApple OSS Distributions 	if (errorString) {
3025*1031c584SApple OSS Distributions 		*errorString = NULL;
3026*1031c584SApple OSS Distributions 	}
3027*1031c584SApple OSS Distributions 
3028*1031c584SApple OSS Distributions 	state->parseBuffer = buffer;
3029*1031c584SApple OSS Distributions 	state->parseBufferIndex = 0;
3030*1031c584SApple OSS Distributions 	state->lineNumber = 1;
3031*1031c584SApple OSS Distributions 	state->objects = 0;
3032*1031c584SApple OSS Distributions 	state->freeObjects = 0;
3033*1031c584SApple OSS Distributions 	state->tags = OSDictionary::withCapacity(128);
3034*1031c584SApple OSS Distributions 	state->errorString = errorString;
3035*1031c584SApple OSS Distributions 	state->parsedObject = 0;
3036*1031c584SApple OSS Distributions 	state->parsedObjectCount = 0;
3037*1031c584SApple OSS Distributions 	state->retrievedObjectCount = 0;
3038*1031c584SApple OSS Distributions 
3039*1031c584SApple OSS Distributions 	(void)yyparse((void *)state);
3040*1031c584SApple OSS Distributions 
3041*1031c584SApple OSS Distributions 	object = state->parsedObject;
3042*1031c584SApple OSS Distributions 
3043*1031c584SApple OSS Distributions 	cleanupObjects(state);
3044*1031c584SApple OSS Distributions 	state->tags->release();
3045*1031c584SApple OSS Distributions 	free_type(parser_state_t, state);
3046*1031c584SApple OSS Distributions 
3047*1031c584SApple OSS Distributions 	return object;
3048*1031c584SApple OSS Distributions }
3049*1031c584SApple OSS Distributions 
3050*1031c584SApple OSS Distributions #if KERNEL
3051*1031c584SApple OSS Distributions #include <libkern/OSSerializeBinary.h>
3052*1031c584SApple OSS Distributions 
3053*1031c584SApple OSS Distributions OSObject*
OSUnserializeXML(const char * buffer,size_t bufferSize,OSString ** errorString)3054*1031c584SApple OSS Distributions OSUnserializeXML(const char *buffer, size_t bufferSize, OSString **errorString)
3055*1031c584SApple OSS Distributions {
3056*1031c584SApple OSS Distributions 	if (!buffer) {
3057*1031c584SApple OSS Distributions 		return 0;
3058*1031c584SApple OSS Distributions 	}
3059*1031c584SApple OSS Distributions 	if (bufferSize < sizeof(kOSSerializeBinarySignature)) {
3060*1031c584SApple OSS Distributions 		return 0;
3061*1031c584SApple OSS Distributions 	}
3062*1031c584SApple OSS Distributions 
3063*1031c584SApple OSS Distributions 	if (!strcmp(kOSSerializeBinarySignature, buffer)
3064*1031c584SApple OSS Distributions 	    || (kOSSerializeIndexedBinarySignature == (uint8_t)buffer[0])) {
3065*1031c584SApple OSS Distributions 		return OSUnserializeBinary(buffer, bufferSize, errorString);
3066*1031c584SApple OSS Distributions 	}
3067*1031c584SApple OSS Distributions 
3068*1031c584SApple OSS Distributions 	// XML must be null terminated
3069*1031c584SApple OSS Distributions 	if (buffer[bufferSize - 1]) {
3070*1031c584SApple OSS Distributions 		return 0;
3071*1031c584SApple OSS Distributions 	}
3072*1031c584SApple OSS Distributions 
3073*1031c584SApple OSS Distributions 	return OSUnserializeXML(buffer, errorString);
3074*1031c584SApple OSS Distributions }
3075*1031c584SApple OSS Distributions 
3076*1031c584SApple OSS Distributions #else /* !KERNEL */
3077*1031c584SApple OSS Distributions 
3078*1031c584SApple OSS Distributions OSObject*
OSUnserializeXML(const char * buffer,size_t bufferSize,OSString ** errorString)3079*1031c584SApple OSS Distributions OSUnserializeXML(const char *buffer, size_t bufferSize, OSString **errorString)
3080*1031c584SApple OSS Distributions {
3081*1031c584SApple OSS Distributions 	if (!buffer) {
3082*1031c584SApple OSS Distributions 		return 0;
3083*1031c584SApple OSS Distributions 	}
3084*1031c584SApple OSS Distributions 
3085*1031c584SApple OSS Distributions 	// XML must be null terminated
3086*1031c584SApple OSS Distributions 	if (buffer[bufferSize - 1]) {
3087*1031c584SApple OSS Distributions 		return 0;
3088*1031c584SApple OSS Distributions 	}
3089*1031c584SApple OSS Distributions 
3090*1031c584SApple OSS Distributions 	return OSUnserializeXML(buffer, errorString);
3091*1031c584SApple OSS Distributions }
3092*1031c584SApple OSS Distributions 
3093*1031c584SApple OSS Distributions #endif /* KERNEL */
3094*1031c584SApple OSS Distributions 
3095*1031c584SApple OSS Distributions 
3096*1031c584SApple OSS Distributions //
3097*1031c584SApple OSS Distributions //
3098*1031c584SApple OSS Distributions //
3099*1031c584SApple OSS Distributions //
3100*1031c584SApple OSS Distributions //
3101*1031c584SApple OSS Distributions //		 DO NOT EDIT OSUnserializeXMLSharedImplementation.h!
3102*1031c584SApple OSS Distributions //
3103*1031c584SApple OSS Distributions //			this means you!
3104*1031c584SApple OSS Distributions //
3105*1031c584SApple OSS Distributions //
3106*1031c584SApple OSS Distributions //
3107*1031c584SApple OSS Distributions //
3108*1031c584SApple OSS Distributions //
3109