xref: /xnu-11215/libkern/c++/OSUnserialize.cpp (revision a5e72196)
1 /*
2  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3  *
4  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5  *
6  * This file contains Original Code and/or Modifications of Original Code
7  * as defined in and that are subject to the Apple Public Source License
8  * Version 2.0 (the 'License'). You may not use this file except in
9  * compliance with the License. The rights granted to you under the License
10  * may not be used to create, or enable the creation or redistribution of,
11  * unlawful or unlicensed copies of an Apple operating system, or to
12  * circumvent, violate, or enable the circumvention or violation of, any
13  * terms of an Apple operating system software license agreement.
14  *
15  * Please obtain a copy of the License at
16  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17  *
18  * The Original Code and all software distributed under the License are
19  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23  * Please see the License for the specific language governing rights and
24  * limitations under the License.
25  *
26  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27  */
28 
29 /*  OSUnserialize.y created by rsulack on Nov 21 1998 */
30 
31 //              "classic" parser for unserializing OSContainer objects
32 //
33 //  XXX - this code should really be removed!
34 //	- the XML format is now prefered
35 //	- this code leaks on syntax errors, the XML doesn't
36 //	- "classic" looks, reads, ... much better than XML :-(
37 //	- well except the XML is more efficent on OSData
38 //
39 //
40 // to build :
41 //	bison -p OSUnserialize OSUnserialize.y
42 //	head -50 OSUnserialize.y > OSUnserialize.cpp
43 //	sed -e "s/stdio.h/stddef.h/" < OSUnserialize.tab.c >> OSUnserialize.cpp
44 //
45 //	when changing code check in both OSUnserialize.y and OSUnserialize.cpp
46 //
47 //
48 //
49 //
50 //		 DO NOT EDIT OSUnserialize.tab.cpp!
51 /* A Bison parser, made by GNU Bison 2.3.  */
52 
53 /* Skeleton implementation for Bison's Yacc-like parsers in C
54  *
55  *  Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
56  *  Free Software Foundation, Inc.
57  *
58  *  This program is free software; you can redistribute it and/or modify
59  *  it under the terms of the GNU General Public License as published by
60  *  the Free Software Foundation; either version 2, or (at your option)
61  *  any later version.
62  *
63  *  This program is distributed in the hope that it will be useful,
64  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
65  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
66  *  GNU General Public License for more details.
67  *
68  *  You should have received a copy of the GNU General Public License
69  *  along with this program; if not, write to the Free Software
70  *  Foundation, Inc., 51 Franklin Street, Fifth Floor,
71  *  Boston, MA 02110-1301, USA.  */
72 
73 /* As a special exception, you may create a larger work that contains
74  *  part or all of the Bison parser skeleton and distribute that work
75  *  under terms of your choice, so long as that work isn't itself a
76  *  parser generator using the skeleton or a modified version thereof
77  *  as a parser skeleton.  Alternatively, if you modify or redistribute
78  *  the parser skeleton itself, you may (at your option) remove this
79  *  special exception, which will cause the skeleton and the resulting
80  *  Bison output files to be licensed under the GNU General Public
81  *  License without this special exception.
82  *
83  *  This special exception was added by the Free Software Foundation in
84  *  version 2.2 of Bison.  */
85 
86 /* C LALR(1) parser skeleton written by Richard Stallman, by
87 *  simplifying the original so-called "semantic" parser.  */
88 
89 /* All symbols defined below should begin with yy or YY, to avoid
90  *  infringing on user name space.  This should be done even for local
91  *  variables, as they might otherwise be expanded by user macros.
92  *  There are some unavoidable exceptions within include files to
93  *  define necessary library symbols; they are noted "INFRINGES ON
94  *  USER NAME SPACE" below.  */
95 
96 /* Identify Bison output.  */
97 #define YYBISON 1
98 
99 /* Bison version.  */
100 #define YYBISON_VERSION "2.3"
101 
102 /* Skeleton name.  */
103 #define YYSKELETON_NAME "yacc.c"
104 
105 /* Pure parsers.  */
106 #define YYPURE 0
107 
108 /* Using locations.  */
109 #define YYLSP_NEEDED 0
110 
111 /* Substitute the variable and function names.  */
112 #define yyparse OSUnserializeparse
113 #define yylex   OSUnserializelex
114 #define yyerror OSUnserializeerror
115 #define yylval  OSUnserializelval
116 #define yychar  OSUnserializechar
117 #define yydebug OSUnserializedebug
118 #define yynerrs OSUnserializenerrs
119 
120 
121 /* Tokens.  */
122 #ifndef YYTOKENTYPE
123 # define YYTOKENTYPE
124 /* Put the tokens into the symbol table, so that GDB and other debuggers
125  *  know about them.  */
126 enum yytokentype {
127 	NUMBER = 258,
128 	STRING = 259,
129 	DATA = 260,
130 	BOOLEAN = 261,
131 	SYNTAX_ERROR = 262
132 };
133 #endif
134 /* Tokens.  */
135 #define NUMBER 258
136 #define STRING 259
137 #define DATA 260
138 #define BOOLEAN 261
139 #define SYNTAX_ERROR 262
140 
141 
142 
143 
144 /* Copy the first part of user declarations.  */
145 #line 60 "OSUnserialize.y"
146 
147 #include <libkern/c++/OSMetaClass.h>
148 #include <libkern/c++/OSContainers.h>
149 #include <libkern/c++/OSLib.h>
150 
151 typedef struct object {
152 	struct object   *next;
153 	struct object   *prev;
154 	void            *object;
155 	int             size;           // for data
156 	union {
157 		void    *key;           // for dictionary
158 		long long offset;       // for offset
159 	} u;
160 } object_t;
161 
162 static int yyerror(const char *s);
163 static int yylex();
164 
165 static object_t * newObject();
166 static void freeObject(object_t *o);
167 
168 static OSObject *buildOSDictionary(object_t *);
169 static OSObject *buildOSArray(object_t *);
170 static OSObject *buildOSSet(object_t *);
171 static OSObject *buildOSString(object_t *);
172 static OSObject *buildOSData(object_t *);
173 static OSObject *buildOSOffset(object_t *);
174 static OSObject *buildOSBoolean(object_t *o);
175 
176 static void rememberObject(int, object_t *);
177 static OSObject *retrieveObject(int);
178 
179 // temp variable to use during parsing
180 static object_t *oo;
181 
182 // resultant object of parsed text
183 static OSObject *parsedObject;
184 
185 #define YYSTYPE object_t *
186 
187 #include <libkern/OSRuntime.h>
188 
189 #define malloc(s) kern_os_malloc(s)
190 #define realloc(a, s) kern_os_realloc(a, s)
191 #define free(a) kern_os_free(a)
192 
193 
194 
195 /* Enabling traces.  */
196 #ifndef YYDEBUG
197 # define YYDEBUG 0
198 #endif
199 
200 /* Enabling verbose error messages.  */
201 #ifdef YYERROR_VERBOSE
202 # undef YYERROR_VERBOSE
203 # define YYERROR_VERBOSE 1
204 #else
205 # define YYERROR_VERBOSE 0
206 #endif
207 
208 /* Enabling the token table.  */
209 #ifndef YYTOKEN_TABLE
210 # define YYTOKEN_TABLE 0
211 #endif
212 
213 #if !defined YYSTYPE && !defined YYSTYPE_IS_DECLARED
214 typedef int YYSTYPE;
215 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
216 # define YYSTYPE_IS_DECLARED 1
217 # define YYSTYPE_IS_TRIVIAL 1
218 #endif
219 
220 
221 
222 /* Copy the second part of user declarations.  */
223 
224 
225 /* Line 216 of yacc.c.  */
226 #line 182 "OSUnserialize.tab.c"
227 
228 #ifdef short
229 # undef short
230 #endif
231 
232 #ifdef YYTYPE_UINT8
233 typedef YYTYPE_UINT8 yytype_uint8;
234 #else
235 typedef unsigned char yytype_uint8;
236 #endif
237 
238 #ifdef YYTYPE_INT8
239 typedef YYTYPE_INT8 yytype_int8;
240 #elif (defined __STDC__ || defined __C99__FUNC__ \
241         || defined __cplusplus || defined _MSC_VER)
242 typedef signed char yytype_int8;
243 #else
244 typedef short int yytype_int8;
245 #endif
246 
247 #ifdef YYTYPE_UINT16
248 typedef YYTYPE_UINT16 yytype_uint16;
249 #else
250 typedef unsigned short int yytype_uint16;
251 #endif
252 
253 #ifdef YYTYPE_INT16
254 typedef YYTYPE_INT16 yytype_int16;
255 #else
256 typedef short int yytype_int16;
257 #endif
258 
259 #ifndef YYSIZE_T
260 # ifdef __SIZE_TYPE__
261 #  define YYSIZE_T __SIZE_TYPE__
262 # elif defined size_t
263 #  define YYSIZE_T size_t
264 # elif !defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
265         || defined __cplusplus || defined _MSC_VER)
266 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
267 #  define YYSIZE_T size_t
268 # else
269 #  define YYSIZE_T unsigned int
270 # endif
271 #endif
272 
273 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
274 
275 #ifndef YY_
276 # if defined YYENABLE_NLS && YYENABLE_NLS
277 #  if ENABLE_NLS
278 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
279 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
280 #  endif
281 # endif
282 # ifndef YY_
283 #  define YY_(msgid) msgid
284 # endif
285 #endif
286 
287 /* Suppress unused-variable warnings by "using" E.  */
288 #if !defined lint || defined __GNUC__
289 # define YYUSE(e) ((void) (e))
290 #else
291 # define YYUSE(e) /* empty */
292 #endif
293 
294 /* Identity function, used to suppress warnings about constant conditions.  */
295 #ifndef lint
296 # define YYID(n) (n)
297 #else
298 #if (defined __STDC__ || defined __C99__FUNC__ \
299         || defined __cplusplus || defined _MSC_VER)
300 static int
301 YYID(int i)
302 #else
303 static int
304     YYID(i)
305 int i;
306 #endif
307 {
308 	return i;
309 }
310 #endif
311 
312 #if !defined yyoverflow || YYERROR_VERBOSE
313 
314 /* The parser invokes alloca or malloc; define the necessary symbols.  */
315 
316 # ifdef YYSTACK_USE_ALLOCA
317 #  if YYSTACK_USE_ALLOCA
318 #   ifdef __GNUC__
319 #    define YYSTACK_ALLOC __builtin_alloca
320 #   elif defined __BUILTIN_VA_ARG_INCR
321 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
322 #   elif defined _AIX
323 #    define YYSTACK_ALLOC __alloca
324 #   elif defined _MSC_VER
325 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
326 #    define alloca _alloca
327 #   else
328 #    define YYSTACK_ALLOC alloca
329 #    if !defined _ALLOCA_H && !defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
330         || defined __cplusplus || defined _MSC_VER)
331 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
332 #     ifndef _STDLIB_H
333 #      define _STDLIB_H 1
334 #     endif
335 #    endif
336 #   endif
337 #  endif
338 # endif
339 
340 # ifdef YYSTACK_ALLOC
341 /* Pacify GCC's `empty if-body' warning.  */
342 #  define YYSTACK_FREE(Ptr) do { /* empty */ ; } while (YYID (0))
343 #  ifndef YYSTACK_ALLOC_MAXIMUM
344 /* The OS might guarantee only one guard page at the bottom of the stack,
345  *  and a page size can be as small as 4096 bytes.  So we cannot safely
346  *  invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
347  *  to allow for a few compiler-allocated temporary stack slots.  */
348 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
349 #  endif
350 # else
351 #  define YYSTACK_ALLOC YYMALLOC
352 #  define YYSTACK_FREE YYFREE
353 #  ifndef YYSTACK_ALLOC_MAXIMUM
354 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
355 #  endif
356 #  if (defined __cplusplus && !defined _STDLIB_H \
357         && !((defined YYMALLOC || defined malloc) \
358         && (defined YYFREE || defined free)))
359 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
360 #   ifndef _STDLIB_H
361 #    define _STDLIB_H 1
362 #   endif
363 #  endif
364 #  ifndef YYMALLOC
365 #   define YYMALLOC malloc
366 #   if !defined malloc && !defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
367         || defined __cplusplus || defined _MSC_VER)
368 void *malloc(YYSIZE_T);  /* INFRINGES ON USER NAME SPACE */
369 #   endif
370 #  endif
371 #  ifndef YYFREE
372 #   define YYFREE free
373 #   if !defined free && !defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
374         || defined __cplusplus || defined _MSC_VER)
375 void free(void *);  /* INFRINGES ON USER NAME SPACE */
376 #   endif
377 #  endif
378 # endif
379 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
380 
381 
382 #if (!defined yyoverflow \
383         && (!defined __cplusplus \
384         || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
385 
386 /* A type that is properly aligned for any stack member.  */
387 union yyalloc {
388 	yytype_int16 yyss;
389 	YYSTYPE yyvs;
390 };
391 
392 /* The size of the maximum gap between one aligned stack and the next.  */
393 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
394 
395 /* The size of an array large to enough to hold all stacks, each with
396  *  N elements.  */
397 # define YYSTACK_BYTES(N) \
398      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
399       + YYSTACK_GAP_MAXIMUM)
400 
401 /* Copy COUNT objects from FROM to TO.  The source and destination do
402  *  not overlap.  */
403 # ifndef YYCOPY
404 #  if defined __GNUC__ && 1 < __GNUC__
405 #   define YYCOPY(To, From, Count) \
406       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
407 #  else
408 #   define YYCOPY(To, From, Count)              \
409       do                                        \
410 	{                                       \
411 	  YYSIZE_T yyi;                         \
412 	  for (yyi = 0; yyi < (Count); yyi++)   \
413 	    (To)[yyi] = (From)[yyi];            \
414 	}                                       \
415       while (YYID (0))
416 #  endif
417 # endif
418 
419 /* Relocate STACK from its old location to the new one.  The
420  *  local variables YYSIZE and YYSTACKSIZE give the old and new number of
421  *  elements in the stack, and YYPTR gives the new location of the
422  *  stack.  Advance YYPTR to a properly aligned location for the next
423  *  stack.  */
424 # define YYSTACK_RELOCATE(Stack)                                        \
425     do                                                                  \
426       {                                                                 \
427 	YYSIZE_T yynewbytes;                                            \
428 	YYCOPY (&yyptr->Stack, Stack, yysize);                          \
429 	Stack = &yyptr->Stack;                                          \
430 	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
431 	yyptr += yynewbytes / sizeof (*yyptr);                          \
432       }                                                                 \
433     while (YYID (0))
434 
435 #endif
436 
437 /* YYFINAL -- State number of the termination state.  */
438 #define YYFINAL  30
439 /* YYLAST -- Last index in YYTABLE.  */
440 #define YYLAST   80
441 
442 /* YYNTOKENS -- Number of terminals.  */
443 #define YYNTOKENS  19
444 /* YYNNTS -- Number of nonterminals.  */
445 #define YYNNTS  13
446 /* YYNRULES -- Number of rules.  */
447 #define YYNRULES  28
448 /* YYNRULES -- Number of states.  */
449 #define YYNSTATES  43
450 
451 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
452 #define YYUNDEFTOK  2
453 #define YYMAXUTOK   262
454 
455 #define YYTRANSLATE(YYX)                                                \
456   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
457 
458 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
459 static const yytype_uint8 yytranslate[] =
460 {
461 	0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
462 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
463 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
464 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
465 	13, 14, 2, 2, 17, 2, 2, 2, 2, 2,
466 	2, 2, 2, 2, 2, 2, 2, 2, 18, 12,
467 	2, 11, 2, 2, 8, 2, 2, 2, 2, 2,
468 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
469 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
470 	2, 15, 2, 16, 2, 2, 2, 2, 2, 2,
471 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
472 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
473 	2, 2, 2, 9, 2, 10, 2, 2, 2, 2,
474 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
475 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
476 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
477 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
478 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
479 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
480 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
481 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
482 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
483 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
484 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
485 	2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
486 	2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
487 	5, 6, 7
488 };
489 
490 #if YYDEBUG
491 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
492  *  YYRHS.  */
493 static const yytype_uint8 yyprhs[] =
494 {
495 	0, 0, 3, 4, 6, 8, 10, 12, 14, 16,
496 	18, 20, 22, 25, 29, 32, 36, 38, 41, 46,
497 	49, 53, 56, 60, 62, 66, 70, 72, 74
498 };
499 
500 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
501 static const yytype_int8 yyrhs[] =
502 {
503 	20, 0, -1, -1, 21, -1, 7, -1, 22, -1,
504 	25, -1, 26, -1, 30, -1, 29, -1, 28, -1,
505 	31, -1, 8, 3, -1, 21, 8, 3, -1, 9,
506 	10, -1, 9, 23, 10, -1, 24, -1, 23, 24,
507 	-1, 21, 11, 21, 12, -1, 13, 14, -1, 13,
508 	27, 14, -1, 15, 16, -1, 15, 27, 16, -1,
509 	21, -1, 27, 17, 21, -1, 3, 18, 3, -1,
510 	5, -1, 4, -1, 6, -1
511 };
512 
513 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
514 static const yytype_uint8 yyrline[] =
515 {
516 	0, 121, 121, 122, 123, 126, 127, 128, 129, 130,
517 	131, 132, 133, 142, 150, 151, 154, 155, 158, 168,
518 	169, 172, 173, 176, 181, 192, 200, 205, 210
519 };
520 #endif
521 
522 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
523 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
524  *  First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
525 static const char *const yytname[] =
526 {
527 	"$end", "error", "$undefined", "NUMBER", "STRING", "DATA", "BOOLEAN",
528 	"SYNTAX_ERROR", "'@'", "'{'", "'}'", "'='", "';'", "'('", "')'", "'['",
529 	"']'", "','", "':'", "$accept", "input", "object", "dict", "pairs",
530 	"pair", "array", "set", "elements", "offset", "data", "string",
531 	"boolean", 0
532 };
533 #endif
534 
535 # ifdef YYPRINT
536 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
537  *  token YYLEX-NUM.  */
538 static const yytype_uint16 yytoknum[] =
539 {
540 	0, 256, 257, 258, 259, 260, 261, 262, 64, 123,
541 	125, 61, 59, 40, 41, 91, 93, 44, 58
542 };
543 # endif
544 
545 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
546 static const yytype_uint8 yyr1[] =
547 {
548 	0, 19, 20, 20, 20, 21, 21, 21, 21, 21,
549 	21, 21, 21, 21, 22, 22, 23, 23, 24, 25,
550 	25, 26, 26, 27, 27, 28, 29, 30, 31
551 };
552 
553 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
554 static const yytype_uint8 yyr2[] =
555 {
556 	0, 2, 0, 1, 1, 1, 1, 1, 1, 1,
557 	1, 1, 2, 3, 2, 3, 1, 2, 4, 2,
558 	3, 2, 3, 1, 3, 3, 1, 1, 1
559 };
560 
561 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
562  *  STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
563  *  means the default is an error.  */
564 static const yytype_uint8 yydefact[] =
565 {
566 	2, 0, 27, 26, 28, 4, 0, 0, 0, 0,
567 	0, 3, 5, 6, 7, 10, 9, 8, 11, 0,
568 	12, 14, 0, 0, 16, 19, 23, 0, 21, 0,
569 	1, 0, 25, 0, 15, 17, 20, 0, 22, 13,
570 	0, 24, 18
571 };
572 
573 /* YYDEFGOTO[NTERM-NUM].  */
574 static const yytype_int8 yydefgoto[] =
575 {
576 	-1, 10, 22, 12, 23, 24, 13, 14, 27, 15,
577 	16, 17, 18
578 };
579 
580 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
581  *  STATE-NUM.  */
582 #define YYPACT_NINF -14
583 static const yytype_int8 yypact[] =
584 {
585 	12, -13, -14, -14, -14, -14, 9, 26, 39, -2,
586 	10, 20, -14, -14, -14, -14, -14, -14, -14, 35,
587 	-14, -14, 38, 52, -14, -14, 20, 49, -14, 7,
588 	-14, 37, -14, 65, -14, -14, -14, 65, -14, -14,
589 	14, 20, -14
590 };
591 
592 /* YYPGOTO[NTERM-NUM].  */
593 static const yytype_int8 yypgoto[] =
594 {
595 	-14, -14, 0, -14, -14, 27, -14, -14, 42, -14,
596 	-14, -14, -14
597 };
598 
599 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
600  *  positive, shift that token.  If negative, reduce the rule which
601  *  number is the opposite.  If zero, do what YYDEFACT says.
602  *  If YYTABLE_NINF, syntax error.  */
603 #define YYTABLE_NINF -1
604 static const yytype_uint8 yytable[] =
605 {
606 	11, 1, 2, 3, 4, 19, 6, 7, 26, 26,
607 	30, 8, 20, 9, 28, 1, 2, 3, 4, 5,
608 	6, 7, 31, 38, 37, 8, 42, 9, 31, 1,
609 	2, 3, 4, 40, 6, 7, 21, 41, 32, 8,
610 	39, 9, 1, 2, 3, 4, 31, 6, 7, 33,
611 	35, 29, 8, 25, 9, 1, 2, 3, 4, 0,
612 	6, 7, 34, 36, 0, 8, 37, 9, 1, 2,
613 	3, 4, 0, 6, 7, 0, 0, 0, 8, 0,
614 	9
615 };
616 
617 static const yytype_int8 yycheck[] =
618 {
619 	0, 3, 4, 5, 6, 18, 8, 9, 8, 9,
620 	0, 13, 3, 15, 16, 3, 4, 5, 6, 7,
621 	8, 9, 8, 16, 17, 13, 12, 15, 8, 3,
622 	4, 5, 6, 33, 8, 9, 10, 37, 3, 13,
623 	3, 15, 3, 4, 5, 6, 8, 8, 9, 11,
624 	23, 9, 13, 14, 15, 3, 4, 5, 6, -1,
625 	8, 9, 10, 14, -1, 13, 17, 15, 3, 4,
626 	5, 6, -1, 8, 9, -1, -1, -1, 13, -1,
627 	15
628 };
629 
630 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
631  *  symbol of state STATE-NUM.  */
632 static const yytype_uint8 yystos[] =
633 {
634 	0, 3, 4, 5, 6, 7, 8, 9, 13, 15,
635 	20, 21, 22, 25, 26, 28, 29, 30, 31, 18,
636 	3, 10, 21, 23, 24, 14, 21, 27, 16, 27,
637 	0, 8, 3, 11, 10, 24, 14, 17, 16, 3,
638 	21, 21, 12
639 };
640 
641 #define yyerrok         (yyerrstatus = 0)
642 #define yyclearin       (yychar = YYEMPTY)
643 #define YYEMPTY         (-2)
644 #define YYEOF           0
645 
646 #define YYACCEPT        goto yyacceptlab
647 #define YYABORT         goto yyabortlab
648 #define YYERROR         goto yyerrorlab
649 
650 
651 /* Like YYERROR except do call yyerror.  This remains here temporarily
652  *  to ease the transition to the new meaning of YYERROR, for GCC.
653  *  Once GCC version 2 has supplanted version 1, this can go.  */
654 
655 #define YYFAIL          goto yyerrlab
656 
657 #define YYRECOVERING()  (!!yyerrstatus)
658 
659 #define YYBACKUP(Token, Value)                                  \
660 do                                                              \
661   if (yychar == YYEMPTY && yylen == 1)                          \
662     {                                                           \
663       yychar = (Token);                                         \
664       yylval = (Value);                                         \
665       yytoken = YYTRANSLATE (yychar);                           \
666       YYPOPSTACK (1);                                           \
667       goto yybackup;                                            \
668     }                                                           \
669   else                                                          \
670     {                                                           \
671       yyerror (YY_("syntax error: cannot back up")); \
672       YYERROR;                                                  \
673     }                                                           \
674 while (YYID (0))
675 
676 
677 #define YYTERROR        1
678 #define YYERRCODE       256
679 
680 
681 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
682  *  If N is 0, then set CURRENT to the empty location which ends
683  *  the previous symbol: RHS[0] (always defined).  */
684 
685 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
686 #ifndef YYLLOC_DEFAULT
687 # define YYLLOC_DEFAULT(Current, Rhs, N)                                \
688     do                                                                  \
689       if (YYID (N))                                                    \
690 	{                                                               \
691 	  (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
692 	  (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
693 	  (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
694 	  (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
695 	}                                                               \
696       else                                                              \
697 	{                                                               \
698 	  (Current).first_line   = (Current).last_line   =              \
699 	    YYRHSLOC (Rhs, 0).last_line;                                \
700 	  (Current).first_column = (Current).last_column =              \
701 	    YYRHSLOC (Rhs, 0).last_column;                              \
702 	}                                                               \
703     while (YYID (0))
704 #endif
705 
706 
707 /* YY_LOCATION_PRINT -- Print the location on the stream.
708  *  This macro was not mandated originally: define only if we know
709  *  we won't break user code: when these are the locations we know.  */
710 
711 #ifndef YY_LOCATION_PRINT
712 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
713 #  define YY_LOCATION_PRINT(File, Loc)                  \
714      fprintf (File, "%d.%d-%d.%d",                      \
715 	      (Loc).first_line, (Loc).first_column,     \
716 	      (Loc).last_line,  (Loc).last_column)
717 # else
718 #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
719 # endif
720 #endif
721 
722 
723 /* YYLEX -- calling `yylex' with the right arguments.  */
724 
725 #ifdef YYLEX_PARAM
726 # define YYLEX yylex (YYLEX_PARAM)
727 #else
728 # define YYLEX yylex ()
729 #endif
730 
731 /* Enable debugging if requested.  */
732 #if YYDEBUG
733 
734 # ifndef YYFPRINTF
735 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
736 #  define YYFPRINTF fprintf
737 # endif
738 
739 # define YYDPRINTF(Args)                        \
740 do {                                            \
741   if (yydebug)                                  \
742     YYFPRINTF Args;                             \
743 } while (YYID (0))
744 
745 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
746 do {                                                                      \
747   if (yydebug)                                                            \
748     {                                                                     \
749       YYFPRINTF (stderr, "%s ", Title);                                   \
750       yy_symbol_print (stderr,                                            \
751 	          Type, Value); \
752       YYFPRINTF (stderr, "\n");                                           \
753     }                                                                     \
754 } while (YYID (0))
755 
756 
757 /*--------------------------------.
758  | Print this symbol on YYOUTPUT.  |
759  |   `--------------------------------*/
760 
761 /*ARGSUSED*/
762 #if (defined __STDC__ || defined __C99__FUNC__ \
763         || defined __cplusplus || defined _MSC_VER)
764 static void
765 yy_symbol_value_print(FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
766 #else
767 static void
768     yy_symbol_value_print(yyoutput, yytype, yyvaluep)
769 FILE *yyoutput;
770 int yytype;
771 YYSTYPE const * const yyvaluep;
772 #endif
773 {
774 	if (!yyvaluep) {
775 		return;
776 	}
777 # ifdef YYPRINT
778 	if (yytype < YYNTOKENS) {
779 		YYPRINT(yyoutput, yytoknum[yytype], *yyvaluep);
780 	}
781 # else
782 	YYUSE(yyoutput);
783 # endif
784 	switch (yytype) {
785 	default:
786 		break;
787 	}
788 }
789 
790 
791 /*--------------------------------.
792  | Print this symbol on YYOUTPUT.  |
793  |   `--------------------------------*/
794 
795 #if (defined __STDC__ || defined __C99__FUNC__ \
796         || defined __cplusplus || defined _MSC_VER)
797 static void
798 yy_symbol_print(FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
799 #else
800 static void
801     yy_symbol_print(yyoutput, yytype, yyvaluep)
802 FILE *yyoutput;
803 int yytype;
804 YYSTYPE const * const yyvaluep;
805 #endif
806 {
807 	if (yytype < YYNTOKENS) {
808 		YYFPRINTF(yyoutput, "token %s (", yytname[yytype]);
809 	} else {
810 		YYFPRINTF(yyoutput, "nterm %s (", yytname[yytype]);
811 	}
812 
813 	yy_symbol_value_print(yyoutput, yytype, yyvaluep);
814 	YYFPRINTF(yyoutput, ")");
815 }
816 
817 /*------------------------------------------------------------------.
818  | yy_stack_print -- Print the state stack from its BOTTOM up to its |
819  | TOP (included).                                                   |
820  |   `------------------------------------------------------------------*/
821 
822 #if (defined __STDC__ || defined __C99__FUNC__ \
823         || defined __cplusplus || defined _MSC_VER)
824 static void
825 yy_stack_print(yytype_int16 *bottom, yytype_int16 *top)
826 #else
827 static void
828     yy_stack_print(bottom, top)
829 yytype_int16 *bottom;
830 yytype_int16 *top;
831 #endif
832 {
833 	YYFPRINTF(stderr, "Stack now");
834 	for (; bottom <= top; ++bottom) {
835 		YYFPRINTF(stderr, " %d", *bottom);
836 	}
837 	YYFPRINTF(stderr, "\n");
838 }
839 
840 # define YY_STACK_PRINT(Bottom, Top)                            \
841 do {                                                            \
842   if (yydebug)                                                  \
843     yy_stack_print ((Bottom), (Top));                           \
844 } while (YYID (0))
845 
846 
847 /*------------------------------------------------.
848  | Report that the YYRULE is going to be reduced.  |
849  |   `------------------------------------------------*/
850 
851 #if (defined __STDC__ || defined __C99__FUNC__ \
852         || defined __cplusplus || defined _MSC_VER)
853 static void
854 yy_reduce_print(YYSTYPE *yyvsp, int yyrule)
855 #else
856 static void
857     yy_reduce_print(yyvsp, yyrule)
858 YYSTYPE *yyvsp;
859 int yyrule;
860 #endif
861 {
862 	int yynrhs = yyr2[yyrule];
863 	int yyi;
864 	unsigned long int yylno = yyrline[yyrule];
865 	YYFPRINTF(stderr, "Reducing stack by rule %d (line %lu):\n",
866 	    yyrule - 1, yylno);
867 	/* The symbols being reduced.  */
868 	for (yyi = 0; yyi < yynrhs; yyi++) {
869 		fprintf(stderr, "   $%d = ", yyi + 1);
870 		yy_symbol_print(stderr, yyrhs[yyprhs[yyrule] + yyi],
871 		    &(yyvsp[(yyi + 1) - (yynrhs)])
872 		    );
873 		fprintf(stderr, "\n");
874 	}
875 }
876 
877 # define YY_REDUCE_PRINT(Rule)          \
878 do {                                    \
879   if (yydebug)                          \
880     yy_reduce_print (yyvsp, Rule); \
881 } while (YYID (0))
882 
883 /* Nonzero means print parse trace.  It is left uninitialized so that
884  *  multiple parsers can coexist.  */
885 int yydebug;
886 #else /* !YYDEBUG */
887 # define YYDPRINTF(Args)
888 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
889 # define YY_STACK_PRINT(Bottom, Top)
890 # define YY_REDUCE_PRINT(Rule)
891 #endif /* !YYDEBUG */
892 
893 
894 /* YYINITDEPTH -- initial size of the parser's stacks.  */
895 #ifndef YYINITDEPTH
896 # define YYINITDEPTH 200
897 #endif
898 
899 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
900  *  if the built-in stack extension method is used).
901  *
902  *  Do not make this value too large; the results are undefined if
903  *  YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
904  *  evaluated with infinite-precision integer arithmetic.  */
905 
906 #ifndef YYMAXDEPTH
907 # define YYMAXDEPTH 10000
908 #endif
909 
910 
911 
912 #if YYERROR_VERBOSE
913 
914 # ifndef yystrlen
915 #  if defined __GLIBC__ && defined _STRING_H
916 #   define yystrlen strlen
917 #  else
918 /* Return the length of YYSTR.  */
919 #if (defined __STDC__ || defined __C99__FUNC__ \
920         || defined __cplusplus || defined _MSC_VER)
921 static YYSIZE_T
922 yystrlen(const char *yystr)
923 #else
924 static YYSIZE_T
925     yystrlen(yystr)
926 const char *yystr;
927 #endif
928 {
929 	YYSIZE_T yylen;
930 	for (yylen = 0; yystr[yylen]; yylen++) {
931 		continue;
932 	}
933 	return yylen;
934 }
935 #  endif
936 # endif
937 
938 # ifndef yystpcpy
939 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
940 #   define yystpcpy stpcpy
941 #  else
942 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
943  *  YYDEST.  */
944 #if (defined __STDC__ || defined __C99__FUNC__ \
945         || defined __cplusplus || defined _MSC_VER)
946 static char *
947 yystpcpy(char *yydest, const char *yysrc)
948 #else
949 static char *
950 yystpcpy(yydest, yysrc)
951 char *yydest;
952 const char *yysrc;
953 #endif
954 {
955 	char *yyd = yydest;
956 	const char *yys = yysrc;
957 
958 	while ((*yyd++ = *yys++) != '\0') {
959 		continue;
960 	}
961 
962 	return yyd - 1;
963 }
964 #  endif
965 # endif
966 
967 # ifndef yytnamerr
968 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
969  *  quotes and backslashes, so that it's suitable for yyerror.  The
970  *  heuristic is that double-quoting is unnecessary unless the string
971  *  contains an apostrophe, a comma, or backslash (other than
972  *  backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
973  *  null, do not copy; instead, return the length of what the result
974  *  would have been.  */
975 static YYSIZE_T
976 yytnamerr(char *yyres, const char *yystr)
977 {
978 	if (*yystr == '"') {
979 		YYSIZE_T yyn = 0;
980 		char const *yyp = yystr;
981 
982 		for (;;) {
983 			switch (*++yyp) {
984 			case '\'':
985 			case ',':
986 				goto do_not_strip_quotes;
987 
988 			case '\\':
989 				if (*++yyp != '\\') {
990 					goto do_not_strip_quotes;
991 				}
992 			/* Fall through.  */
993 			default:
994 				if (yyres) {
995 					yyres[yyn] = *yyp;
996 				}
997 				yyn++;
998 				break;
999 
1000 			case '"':
1001 				if (yyres) {
1002 					yyres[yyn] = '\0';
1003 				}
1004 				return yyn;
1005 			}
1006 		}
1007 do_not_strip_quotes:;
1008 	}
1009 
1010 	if (!yyres) {
1011 		return yystrlen(yystr);
1012 	}
1013 
1014 	return yystpcpy(yyres, yystr) - yyres;
1015 }
1016 # endif
1017 
1018 /* Copy into YYRESULT an error message about the unexpected token
1019  *  YYCHAR while in state YYSTATE.  Return the number of bytes copied,
1020  *  including the terminating null byte.  If YYRESULT is null, do not
1021  *  copy anything; just return the number of bytes that would be
1022  *  copied.  As a special case, return 0 if an ordinary "syntax error"
1023  *  message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
1024  *  size calculation.  */
1025 static YYSIZE_T
1026 yysyntax_error(char *yyresult, int yystate, int yychar)
1027 {
1028 	int yyn = yypact[yystate];
1029 
1030 	if (!(YYPACT_NINF < yyn && yyn <= YYLAST)) {
1031 		return 0;
1032 	} else {
1033 		int yytype = YYTRANSLATE(yychar);
1034 		YYSIZE_T yysize0 = yytnamerr(0, yytname[yytype]);
1035 		YYSIZE_T yysize = yysize0;
1036 		YYSIZE_T yysize1;
1037 		int yysize_overflow = 0;
1038 		enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1039 		char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1040 		int yyx;
1041 
1042 # if 0
1043 		/* This is so xgettext sees the translatable formats that are
1044 		 *  constructed on the fly.  */
1045 		YY_("syntax error, unexpected %s");
1046 		YY_("syntax error, unexpected %s, expecting %s");
1047 		YY_("syntax error, unexpected %s, expecting %s or %s");
1048 		YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1049 		YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1050 # endif
1051 		char *yyfmt;
1052 		char const *yyf;
1053 		static char const yyunexpected[] = "syntax error, unexpected %s";
1054 		static char const yyexpecting[] = ", expecting %s";
1055 		static char const yyor[] = " or %s";
1056 		char yyformat[sizeof yyunexpected
1057 		+ sizeof yyexpecting - 1
1058 		+ ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1059 		* (sizeof yyor - 1))];
1060 		char const *yyprefix = yyexpecting;
1061 
1062 		/* Start YYX at -YYN if negative to avoid negative indexes in
1063 		 *  YYCHECK.  */
1064 		int yyxbegin = yyn < 0 ? -yyn : 0;
1065 
1066 		/* Stay within bounds of both yycheck and yytname.  */
1067 		int yychecklim = YYLAST - yyn + 1;
1068 		int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1069 		int yycount = 1;
1070 
1071 		yyarg[0] = yytname[yytype];
1072 		yyfmt = yystpcpy(yyformat, yyunexpected);
1073 
1074 		for (yyx = yyxbegin; yyx < yyxend; ++yyx) {
1075 			if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) {
1076 				if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) {
1077 					yycount = 1;
1078 					yysize = yysize0;
1079 					yyformat[sizeof yyunexpected - 1] = '\0';
1080 					break;
1081 				}
1082 				yyarg[yycount++] = yytname[yyx];
1083 				yysize1 = yysize + yytnamerr(0, yytname[yyx]);
1084 				yysize_overflow |= (yysize1 < yysize);
1085 				yysize = yysize1;
1086 				yyfmt = yystpcpy(yyfmt, yyprefix);
1087 				yyprefix = yyor;
1088 			}
1089 		}
1090 
1091 		yyf = YY_(yyformat);
1092 		yysize1 = yysize + yystrlen(yyf);
1093 		yysize_overflow |= (yysize1 < yysize);
1094 		yysize = yysize1;
1095 
1096 		if (yysize_overflow) {
1097 			return YYSIZE_MAXIMUM;
1098 		}
1099 
1100 		if (yyresult) {
1101 			/* Avoid sprintf, as that infringes on the user's name space.
1102 			 *  Don't have undefined behavior even if the translation
1103 			 *  produced a string with the wrong number of "%s"s.  */
1104 			char *yyp = yyresult;
1105 			int yyi = 0;
1106 			while ((*yyp = *yyf) != '\0') {
1107 				if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) {
1108 					yyp += yytnamerr(yyp, yyarg[yyi++]);
1109 					yyf += 2;
1110 				} else {
1111 					yyp++;
1112 					yyf++;
1113 				}
1114 			}
1115 		}
1116 		return yysize;
1117 	}
1118 }
1119 #endif /* YYERROR_VERBOSE */
1120 
1121 
1122 /*-----------------------------------------------.
1123  | Release the memory associated to this symbol.  |
1124  |   `-----------------------------------------------*/
1125 
1126 /*ARGSUSED*/
1127 #if (defined __STDC__ || defined __C99__FUNC__ \
1128         || defined __cplusplus || defined _MSC_VER)
1129 static void
1130 yydestruct(const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1131 #else
1132 static void
1133     yydestruct(yymsg, yytype, yyvaluep)
1134 const char *yymsg;
1135 int yytype;
1136 YYSTYPE *yyvaluep;
1137 #endif
1138 {
1139 	YYUSE(yyvaluep);
1140 
1141 	if (!yymsg) {
1142 		yymsg = "Deleting";
1143 	}
1144 	YY_SYMBOL_PRINT(yymsg, yytype, yyvaluep, yylocationp);
1145 
1146 	switch (yytype) {
1147 	default:
1148 		break;
1149 	}
1150 }
1151 
1152 
1153 /* Prevent warnings from -Wmissing-prototypes.  */
1154 
1155 #ifdef YYPARSE_PARAM
1156 #if defined __STDC__ || defined __cplusplus
1157 int yyparse(void *YYPARSE_PARAM);
1158 #else
1159 int yyparse();
1160 #endif
1161 #else /* ! YYPARSE_PARAM */
1162 #if defined __STDC__ || defined __cplusplus
1163 int yyparse(void);
1164 #else
1165 int yyparse();
1166 #endif
1167 #endif /* ! YYPARSE_PARAM */
1168 
1169 
1170 
1171 /* The look-ahead symbol.  */
1172 int yychar;
1173 
1174 /* The semantic value of the look-ahead symbol.  */
1175 YYSTYPE yylval;
1176 
1177 /* Number of syntax errors so far.  */
1178 int yynerrs;
1179 
1180 
1181 
1182 /*----------.
1183  | yyparse.  |
1184  |   `----------*/
1185 
1186 #ifdef YYPARSE_PARAM
1187 #if (defined __STDC__ || defined __C99__FUNC__ \
1188         || defined __cplusplus || defined _MSC_VER)
1189 int
1190 yyparse(void *YYPARSE_PARAM)
1191 #else
1192 int
1193     yyparse(YYPARSE_PARAM)
1194 void *YYPARSE_PARAM;
1195 #endif
1196 #else /* ! YYPARSE_PARAM */
1197 #if (defined __STDC__ || defined __C99__FUNC__ \
1198         || defined __cplusplus || defined _MSC_VER)
1199 int
1200 yyparse(void)
1201 #else
1202 int
1203 yyparse()
1204 
1205 #endif
1206 #endif
1207 {
1208 	int yystate;
1209 	int yyn;
1210 	int yyresult;
1211 	/* Number of tokens to shift before error messages enabled.  */
1212 	int yyerrstatus;
1213 	/* Look-ahead token as an internal (translated) token number.  */
1214 	int yytoken = 0;
1215 #if YYERROR_VERBOSE
1216 	/* Buffer for error messages, and its allocated size.  */
1217 	char yymsgbuf[128];
1218 	char *yymsg = yymsgbuf;
1219 	YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1220 #endif
1221 
1222 	/* Three stacks and their tools:
1223 	 *  `yyss': related to states,
1224 	 *  `yyvs': related to semantic values,
1225 	 *  `yyls': related to locations.
1226 	 *
1227 	 *  Refer to the stacks thru separate pointers, to allow yyoverflow
1228 	 *  to reallocate them elsewhere.  */
1229 
1230 	/* The state stack.  */
1231 	yytype_int16 yyssa[YYINITDEPTH];
1232 	yytype_int16 *yyss = yyssa;
1233 	yytype_int16 *yyssp;
1234 
1235 	/* The semantic value stack.  */
1236 	YYSTYPE yyvsa[YYINITDEPTH];
1237 	YYSTYPE *yyvs = yyvsa;
1238 	YYSTYPE *yyvsp;
1239 
1240 
1241 
1242 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1243 
1244 	YYSIZE_T yystacksize = YYINITDEPTH;
1245 
1246 	/* The variables used to return semantic value and location from the
1247 	 *  action routines.  */
1248 	YYSTYPE yyval;
1249 
1250 
1251 	/* The number of symbols on the RHS of the reduced rule.
1252 	 *  Keep to zero when no symbol should be popped.  */
1253 	int yylen = 0;
1254 
1255 	YYDPRINTF((stderr, "Starting parse\n"));
1256 
1257 	yystate = 0;
1258 	yyerrstatus = 0;
1259 	yynerrs = 0;
1260 	yychar = YYEMPTY;       /* Cause a token to be read.  */
1261 
1262 	/* Initialize stack pointers.
1263 	 *  Waste one element of value and location stack
1264 	 *  so that they stay on the same level as the state stack.
1265 	 *  The wasted elements are never initialized.  */
1266 
1267 	yyssp = yyss;
1268 	yyvsp = yyvs;
1269 
1270 	goto yysetstate;
1271 
1272 /*------------------------------------------------------------.
1273  | yynewstate -- Push a new state, which is found in yystate.  |
1274  |   `------------------------------------------------------------*/
1275 yynewstate:
1276 	/* In all cases, when you get here, the value and location stacks
1277 	 *  have just been pushed.  So pushing a state here evens the stacks.  */
1278 	yyssp++;
1279 
1280 yysetstate:
1281 	*yyssp = yystate;
1282 
1283 	if (yyss + yystacksize - 1 <= yyssp) {
1284 		/* Get the current used size of the three stacks, in elements.  */
1285 		YYSIZE_T yysize = yyssp - yyss + 1;
1286 
1287 #ifdef yyoverflow
1288 		{
1289 			/* Give user a chance to reallocate the stack.  Use copies of
1290 			 *  these so that the &'s don't force the real ones into
1291 			 *  memory.  */
1292 			YYSTYPE *yyvs1 = yyvs;
1293 			yytype_int16 *yyss1 = yyss;
1294 
1295 
1296 			/* Each stack pointer address is followed by the size of the
1297 			 *  data in use in that stack, in bytes.  This used to be a
1298 			 *  conditional around just the two extra args, but that might
1299 			 *  be undefined if yyoverflow is a macro.  */
1300 			yyoverflow(YY_("memory exhausted"),
1301 			    &yyss1, yysize * sizeof(*yyssp),
1302 			    &yyvs1, yysize * sizeof(*yyvsp),
1303 
1304 			    &yystacksize);
1305 
1306 			yyss = yyss1;
1307 			yyvs = yyvs1;
1308 		}
1309 #else /* no yyoverflow */
1310 # ifndef YYSTACK_RELOCATE
1311 		goto yyexhaustedlab;
1312 # else
1313 		/* Extend the stack our own way.  */
1314 		if (YYMAXDEPTH <= yystacksize) {
1315 			goto yyexhaustedlab;
1316 		}
1317 		yystacksize *= 2;
1318 		if (YYMAXDEPTH < yystacksize) {
1319 			yystacksize = YYMAXDEPTH;
1320 		}
1321 
1322 		{
1323 			yytype_int16 *yyss1 = yyss;
1324 			union yyalloc *yyptr =
1325 			    (union yyalloc *) YYSTACK_ALLOC(YYSTACK_BYTES(yystacksize));
1326 			if (!yyptr) {
1327 				goto yyexhaustedlab;
1328 			}
1329 			YYSTACK_RELOCATE(yyss);
1330 			YYSTACK_RELOCATE(yyvs);
1331 
1332 #  undef YYSTACK_RELOCATE
1333 			if (yyss1 != yyssa) {
1334 				YYSTACK_FREE(yyss1);
1335 			}
1336 		}
1337 # endif
1338 #endif /* no yyoverflow */
1339 
1340 		yyssp = yyss + yysize - 1;
1341 		yyvsp = yyvs + yysize - 1;
1342 
1343 
1344 		YYDPRINTF((stderr, "Stack size increased to %lu\n",
1345 		    (unsigned long int) yystacksize));
1346 
1347 		if (yyss + yystacksize - 1 <= yyssp) {
1348 			YYABORT;
1349 		}
1350 	}
1351 
1352 	YYDPRINTF((stderr, "Entering state %d\n", yystate));
1353 
1354 	goto yybackup;
1355 
1356 /*-----------.
1357  | yybackup.  |
1358  |   `-----------*/
1359 yybackup:
1360 
1361 	/* Do appropriate processing given the current state.  Read a
1362 	 *  look-ahead token if we need one and don't already have one.  */
1363 
1364 	/* First try to decide what to do without reference to look-ahead token.  */
1365 	yyn = yypact[yystate];
1366 	if (yyn == YYPACT_NINF) {
1367 		goto yydefault;
1368 	}
1369 
1370 	/* Not known => get a look-ahead token if don't already have one.  */
1371 
1372 	/* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol.  */
1373 	if (yychar == YYEMPTY) {
1374 		YYDPRINTF((stderr, "Reading a token: "));
1375 		yychar = YYLEX;
1376 	}
1377 
1378 	if (yychar <= YYEOF) {
1379 		yychar = yytoken = YYEOF;
1380 		YYDPRINTF((stderr, "Now at end of input.\n"));
1381 	} else {
1382 		yytoken = YYTRANSLATE(yychar);
1383 		YY_SYMBOL_PRINT("Next token is", yytoken, &yylval, &yylloc);
1384 	}
1385 
1386 	/* If the proper action on seeing token YYTOKEN is to reduce or to
1387 	 *  detect an error, take that action.  */
1388 	yyn += yytoken;
1389 	if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) {
1390 		goto yydefault;
1391 	}
1392 	yyn = yytable[yyn];
1393 	if (yyn <= 0) {
1394 		if (yyn == 0 || yyn == YYTABLE_NINF) {
1395 			goto yyerrlab;
1396 		}
1397 		yyn = -yyn;
1398 		goto yyreduce;
1399 	}
1400 
1401 	if (yyn == YYFINAL) {
1402 		YYACCEPT;
1403 	}
1404 
1405 	/* Count tokens shifted since error; after three, turn off error
1406 	 *  status.  */
1407 	if (yyerrstatus) {
1408 		yyerrstatus--;
1409 	}
1410 
1411 	/* Shift the look-ahead token.  */
1412 	YY_SYMBOL_PRINT("Shifting", yytoken, &yylval, &yylloc);
1413 
1414 	/* Discard the shifted token unless it is eof.  */
1415 	if (yychar != YYEOF) {
1416 		yychar = YYEMPTY;
1417 	}
1418 
1419 	yystate = yyn;
1420 	*++yyvsp = yylval;
1421 
1422 	goto yynewstate;
1423 
1424 
1425 /*-----------------------------------------------------------.
1426  | yydefault -- do the default action for the current state.  |
1427  |   `-----------------------------------------------------------*/
1428 yydefault:
1429 	yyn = yydefact[yystate];
1430 	if (yyn == 0) {
1431 		goto yyerrlab;
1432 	}
1433 	goto yyreduce;
1434 
1435 
1436 /*-----------------------------.
1437  | yyreduce -- Do a reduction.  |
1438  |   `-----------------------------*/
1439 yyreduce:
1440 	/* yyn is the number of a rule to reduce with.  */
1441 	yylen = yyr2[yyn];
1442 
1443 	/* If YYLEN is nonzero, implement the default value of the action:
1444 	 *  `$$ = $1'.
1445 	 *
1446 	 *  Otherwise, the following line sets YYVAL to garbage.
1447 	 *  This behavior is undocumented and Bison
1448 	 *  users should not rely upon it.  Assigning to YYVAL
1449 	 *  unconditionally makes the parser a bit smaller, and it avoids a
1450 	 *  GCC warning that YYVAL may be used uninitialized.  */
1451 	yyval = yyvsp[1 - yylen];
1452 
1453 
1454 	YY_REDUCE_PRINT(yyn);
1455 	switch (yyn) {
1456 	case 2:
1457 #line 121 "OSUnserialize.y"
1458 		{ parsedObject = (OSObject *)NULL; YYACCEPT;;}
1459 		break;
1460 
1461 	case 3:
1462 #line 122 "OSUnserialize.y"
1463 		{ parsedObject = (OSObject *)(yyvsp[(1) - (1)]); YYACCEPT;;}
1464 		break;
1465 
1466 	case 4:
1467 #line 123 "OSUnserialize.y"
1468 		{ yyerror("syntax error"); YYERROR;;}
1469 		break;
1470 
1471 	case 5:
1472 #line 126 "OSUnserialize.y"
1473 		{ (yyval) = (object_t *)buildOSDictionary((yyvsp[(1) - (1)]));;}
1474 		break;
1475 
1476 	case 6:
1477 #line 127 "OSUnserialize.y"
1478 		{ (yyval) = (object_t *)buildOSArray((yyvsp[(1) - (1)]));;}
1479 		break;
1480 
1481 	case 7:
1482 #line 128 "OSUnserialize.y"
1483 		{ (yyval) = (object_t *)buildOSSet((yyvsp[(1) - (1)]));;}
1484 		break;
1485 
1486 	case 8:
1487 #line 129 "OSUnserialize.y"
1488 		{ (yyval) = (object_t *)buildOSString((yyvsp[(1) - (1)]));;}
1489 		break;
1490 
1491 	case 9:
1492 #line 130 "OSUnserialize.y"
1493 		{ (yyval) = (object_t *)buildOSData((yyvsp[(1) - (1)]));;}
1494 		break;
1495 
1496 	case 10:
1497 #line 131 "OSUnserialize.y"
1498 		{ (yyval) = (object_t *)buildOSOffset((yyvsp[(1) - (1)]));;}
1499 		break;
1500 
1501 	case 11:
1502 #line 132 "OSUnserialize.y"
1503 		{ (yyval) = (object_t *)buildOSBoolean((yyvsp[(1) - (1)]));;}
1504 		break;
1505 
1506 	case 12:
1507 #line 133 "OSUnserialize.y"
1508 		{ (yyval) = (object_t *)retrieveObject((yyvsp[(2) - (2)])->u.offset);
1509 		  if ((yyval)) {
1510 			  ((OSObject *)(yyval))->retain();
1511 		  } else {
1512 			  yyerror("forward reference detected");
1513 			  YYERROR;
1514 		  }
1515 		  freeObject((yyvsp[(2) - (2)]));
1516 		  ;}
1517 		break;
1518 
1519 	case 13:
1520 #line 142 "OSUnserialize.y"
1521 		{ (yyval) = (yyvsp[(1) - (3)]);
1522 		  rememberObject((yyvsp[(3) - (3)])->u.offset, (yyvsp[(1) - (3)]));
1523 		  freeObject((yyvsp[(3) - (3)]));
1524 		  ;}
1525 		break;
1526 
1527 	case 14:
1528 #line 150 "OSUnserialize.y"
1529 		{ (yyval) = NULL;;}
1530 		break;
1531 
1532 	case 15:
1533 #line 151 "OSUnserialize.y"
1534 		{ (yyval) = (yyvsp[(2) - (3)]);;}
1535 		break;
1536 
1537 	case 17:
1538 #line 155 "OSUnserialize.y"
1539 		{ (yyvsp[(2) - (2)])->next = (yyvsp[(1) - (2)]); (yyvsp[(1) - (2)])->prev = (yyvsp[(2) - (2)]); (yyval) = (yyvsp[(2) - (2)]);;}
1540 		break;
1541 
1542 	case 18:
1543 #line 158 "OSUnserialize.y"
1544 		{ (yyval) = newObject();
1545 		  (yyval)->next = NULL;
1546 		  (yyval)->prev = NULL;
1547 		  (yyval)->u.key = (yyvsp[(1) - (4)]);
1548 		  (yyval)->object = (yyvsp[(3) - (4)]);
1549 		  ;}
1550 		break;
1551 
1552 	case 19:
1553 #line 168 "OSUnserialize.y"
1554 		{ (yyval) = NULL;;}
1555 		break;
1556 
1557 	case 20:
1558 #line 169 "OSUnserialize.y"
1559 		{ (yyval) = (yyvsp[(2) - (3)]);;}
1560 		break;
1561 
1562 	case 21:
1563 #line 172 "OSUnserialize.y"
1564 		{ (yyval) = NULL;;}
1565 		break;
1566 
1567 	case 22:
1568 #line 173 "OSUnserialize.y"
1569 		{ (yyval) = (yyvsp[(2) - (3)]);;}
1570 		break;
1571 
1572 	case 23:
1573 #line 176 "OSUnserialize.y"
1574 		{ (yyval) = newObject();
1575 		  (yyval)->object = (yyvsp[(1) - (1)]);
1576 		  (yyval)->next = NULL;
1577 		  (yyval)->prev = NULL;
1578 		  ;}
1579 		break;
1580 
1581 	case 24:
1582 #line 181 "OSUnserialize.y"
1583 		{ oo = newObject();
1584 		  oo->object = (yyvsp[(3) - (3)]);
1585 		  oo->next = (yyvsp[(1) - (3)]);
1586 		  oo->prev = NULL;
1587 		  (yyvsp[(1) - (3)])->prev = oo;
1588 		  (yyval) = oo;
1589 		  ;}
1590 		break;
1591 
1592 	case 25:
1593 #line 192 "OSUnserialize.y"
1594 		{ (yyval) = (yyvsp[(1) - (3)]);
1595 		  (yyval)->size = (yyvsp[(3) - (3)])->u.offset;
1596 		  freeObject((yyvsp[(3) - (3)]));
1597 		  ;}
1598 		break;
1599 
1600 
1601 /* Line 1267 of yacc.c.  */
1602 #line 1555 "OSUnserialize.tab.c"
1603 	default: break;
1604 	}
1605 	YY_SYMBOL_PRINT("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1606 
1607 	YYPOPSTACK(yylen);
1608 	yylen = 0;
1609 	YY_STACK_PRINT(yyss, yyssp);
1610 
1611 	*++yyvsp = yyval;
1612 
1613 
1614 	/* Now `shift' the result of the reduction.  Determine what state
1615 	 *  that goes to, based on the state we popped back to and the rule
1616 	 *  number reduced by.  */
1617 
1618 	yyn = yyr1[yyn];
1619 
1620 	yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1621 	if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) {
1622 		yystate = yytable[yystate];
1623 	} else {
1624 		yystate = yydefgoto[yyn - YYNTOKENS];
1625 	}
1626 
1627 	goto yynewstate;
1628 
1629 
1630 /*------------------------------------.
1631  | yyerrlab -- here on detecting error |
1632  |   `------------------------------------*/
1633 yyerrlab:
1634 	/* If not already recovering from an error, report this error.  */
1635 	if (!yyerrstatus) {
1636 		++yynerrs;
1637 #if !YYERROR_VERBOSE
1638 		yyerror(YY_("syntax error"));
1639 #else
1640 		{
1641 			YYSIZE_T yysize = yysyntax_error(0, yystate, yychar);
1642 			if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) {
1643 				YYSIZE_T yyalloc = 2 * yysize;
1644 				if (!(yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) {
1645 					yyalloc = YYSTACK_ALLOC_MAXIMUM;
1646 				}
1647 				if (yymsg != yymsgbuf) {
1648 					YYSTACK_FREE(yymsg);
1649 				}
1650 				yymsg = (char *) YYSTACK_ALLOC(yyalloc);
1651 				if (yymsg) {
1652 					yymsg_alloc = yyalloc;
1653 				} else {
1654 					yymsg = yymsgbuf;
1655 					yymsg_alloc = sizeof yymsgbuf;
1656 				}
1657 			}
1658 
1659 			if (0 < yysize && yysize <= yymsg_alloc) {
1660 				(void) yysyntax_error(yymsg, yystate, yychar);
1661 				yyerror(yymsg);
1662 			} else {
1663 				yyerror(YY_("syntax error"));
1664 				if (yysize != 0) {
1665 					goto yyexhaustedlab;
1666 				}
1667 			}
1668 		}
1669 #endif
1670 	}
1671 
1672 
1673 
1674 	if (yyerrstatus == 3) {
1675 		/* If just tried and failed to reuse look-ahead token after an
1676 		 *  error, discard it.  */
1677 
1678 		if (yychar <= YYEOF) {
1679 			/* Return failure if at end of input.  */
1680 			if (yychar == YYEOF) {
1681 				YYABORT;
1682 			}
1683 		} else {
1684 			yydestruct("Error: discarding",
1685 			    yytoken, &yylval);
1686 			yychar = YYEMPTY;
1687 		}
1688 	}
1689 
1690 	/* Else will try to reuse look-ahead token after shifting the error
1691 	 *  token.  */
1692 	goto yyerrlab1;
1693 
1694 
1695 /*---------------------------------------------------.
1696  | yyerrorlab -- error raised explicitly by YYERROR.  |
1697  |   `---------------------------------------------------*/
1698 yyerrorlab:
1699 
1700 	/* Pacify compilers like GCC when the user code never invokes
1701 	 *  YYERROR and the label yyerrorlab therefore never appears in user
1702 	 *  code.  */
1703 	if (/*CONSTCOND*/ 0) {
1704 		goto yyerrorlab;
1705 	}
1706 
1707 	/* Do not reclaim the symbols of the rule which action triggered
1708 	 *  this YYERROR.  */
1709 	YYPOPSTACK(yylen);
1710 	yylen = 0;
1711 	YY_STACK_PRINT(yyss, yyssp);
1712 	yystate = *yyssp;
1713 	goto yyerrlab1;
1714 
1715 
1716 /*-------------------------------------------------------------.
1717  | yyerrlab1 -- common code for both syntax error and YYERROR.  |
1718  |   `-------------------------------------------------------------*/
1719 yyerrlab1:
1720 	yyerrstatus = 3; /* Each real token shifted decrements this.  */
1721 
1722 	for (;;) {
1723 		yyn = yypact[yystate];
1724 		if (yyn != YYPACT_NINF) {
1725 			yyn += YYTERROR;
1726 			if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) {
1727 				yyn = yytable[yyn];
1728 				if (0 < yyn) {
1729 					break;
1730 				}
1731 			}
1732 		}
1733 
1734 		/* Pop the current state because it cannot handle the error token.  */
1735 		if (yyssp == yyss) {
1736 			YYABORT;
1737 		}
1738 
1739 
1740 		yydestruct("Error: popping",
1741 		    yystos[yystate], yyvsp);
1742 		YYPOPSTACK(1);
1743 		yystate = *yyssp;
1744 		YY_STACK_PRINT(yyss, yyssp);
1745 	}
1746 
1747 	if (yyn == YYFINAL) {
1748 		YYACCEPT;
1749 	}
1750 
1751 	*++yyvsp = yylval;
1752 
1753 
1754 	/* Shift the error token.  */
1755 	YY_SYMBOL_PRINT("Shifting", yystos[yyn], yyvsp, yylsp);
1756 
1757 	yystate = yyn;
1758 	goto yynewstate;
1759 
1760 
1761 /*-------------------------------------.
1762  | yyacceptlab -- YYACCEPT comes here.  |
1763  |   `-------------------------------------*/
1764 yyacceptlab:
1765 	yyresult = 0;
1766 	goto yyreturn;
1767 
1768 /*-----------------------------------.
1769  | yyabortlab -- YYABORT comes here.  |
1770  |   `-----------------------------------*/
1771 yyabortlab:
1772 	yyresult = 1;
1773 	goto yyreturn;
1774 
1775 #ifndef yyoverflow
1776 /*-------------------------------------------------.
1777  | yyexhaustedlab -- memory exhaustion comes here.  |
1778  |   `-------------------------------------------------*/
1779 yyexhaustedlab:
1780 	yyerror(YY_("memory exhausted"));
1781 	yyresult = 2;
1782 	/* Fall through.  */
1783 #endif
1784 
1785 yyreturn:
1786 	if (yychar != YYEOF && yychar != YYEMPTY) {
1787 		yydestruct("Cleanup: discarding lookahead",
1788 		    yytoken, &yylval);
1789 	}
1790 	/* Do not reclaim the symbols of the rule which action triggered
1791 	 *  this YYABORT or YYACCEPT.  */
1792 	YYPOPSTACK(yylen);
1793 	YY_STACK_PRINT(yyss, yyssp);
1794 	while (yyssp != yyss) {
1795 		yydestruct("Cleanup: popping",
1796 		    yystos[*yyssp], yyvsp);
1797 		YYPOPSTACK(1);
1798 	}
1799 #ifndef yyoverflow
1800 	if (yyss != yyssa) {
1801 		YYSTACK_FREE(yyss);
1802 	}
1803 #endif
1804 #if YYERROR_VERBOSE
1805 	if (yymsg != yymsgbuf) {
1806 		YYSTACK_FREE(yymsg);
1807 	}
1808 #endif
1809 	/* Make sure YYID is used.  */
1810 	return YYID(yyresult);
1811 }
1812 
1813 
1814 #line 213 "OSUnserialize.y"
1815 
1816 
1817 static int              lineNumber = 0;
1818 static const char       *parseBuffer;
1819 static int              parseBufferIndex;
1820 
1821 #define currentChar()   (parseBuffer[parseBufferIndex])
1822 #define nextChar()      (parseBuffer[++parseBufferIndex])
1823 #define prevChar()      (parseBuffer[parseBufferIndex - 1])
1824 
1825 #define isSpace(c)      ((c) == ' ' || (c) == '\t')
1826 #define isAlpha(c)      (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z'))
1827 #define isDigit(c)      ((c) >= '0' && (c) <= '9')
1828 #define isAlphaDigit(c) ((c) >= 'a' && (c) <= 'f')
1829 #define isHexDigit(c)   (isDigit(c) || isAlphaDigit(c))
1830 #define isAlphaNumeric(c) (isAlpha(c) || isDigit(c) || ((c) == '-'))
1831 
1832 static char yyerror_message[128];
1833 
1834 int
1835 yyerror(const char *s)  /* Called by yyparse on error */
1836 {
1837 	snprintf(yyerror_message, sizeof(yyerror_message), "OSUnserialize: %s near line %d\n", s, lineNumber);
1838 	return 0;
1839 }
1840 
1841 int
1842 yylex()
1843 {
1844 	int c;
1845 
1846 	if (parseBufferIndex == 0) {
1847 		lineNumber = 1;
1848 	}
1849 
1850 top:
1851 	c = currentChar();
1852 
1853 	/* skip white space  */
1854 	if (isSpace(c)) {
1855 		while ((c = nextChar()) != 0 && isSpace(c)) {
1856 		}
1857 	}
1858 	;
1859 
1860 	/* skip over comments */
1861 	if (c == '#') {
1862 		while ((c = nextChar()) != 0 && c != '\n') {
1863 		}
1864 	}
1865 	;
1866 
1867 	/* keep track of line number, don't return \n's */
1868 	if (c == '\n') {
1869 		lineNumber++;
1870 		(void)nextChar();
1871 		goto top;
1872 	}
1873 
1874 	/* parse boolean */
1875 	if (c == '.') {
1876 		bool boolean = false;
1877 		if (nextChar() == 't') {
1878 			if (nextChar() != 'r') {
1879 				return SYNTAX_ERROR;
1880 			}
1881 			if (nextChar() != 'u') {
1882 				return SYNTAX_ERROR;
1883 			}
1884 			if (nextChar() != 'e') {
1885 				return SYNTAX_ERROR;
1886 			}
1887 			boolean = true;
1888 		} else {
1889 			if (currentChar() != 'f') {
1890 				return SYNTAX_ERROR;
1891 			}
1892 			if (nextChar() != 'a') {
1893 				return SYNTAX_ERROR;
1894 			}
1895 			if (nextChar() != 'l') {
1896 				return SYNTAX_ERROR;
1897 			}
1898 			if (nextChar() != 's') {
1899 				return SYNTAX_ERROR;
1900 			}
1901 			if (nextChar() != 'e') {
1902 				return SYNTAX_ERROR;
1903 			}
1904 		}
1905 		if (nextChar() != '.') {
1906 			return SYNTAX_ERROR;
1907 		}
1908 		/* skip over dot */
1909 		(void)nextChar();
1910 
1911 		yylval = (object_t *)boolean;
1912 		return BOOLEAN;
1913 	}
1914 
1915 	/* parse unquoted string */
1916 	if (isAlpha(c)) {
1917 		int start, length;
1918 		char * tempString;
1919 
1920 		start = parseBufferIndex;
1921 		/* find end of string */
1922 		while (isAlphaNumeric(c)) {
1923 			c = nextChar();
1924 		}
1925 		length = parseBufferIndex - start;
1926 
1927 		/* copy to null terminated buffer */
1928 		tempString = (char *)malloc(length + 1);
1929 		if (tempString == 0) {
1930 			printf("OSUnserialize: can't alloc temp memory\n");
1931 			return 0;
1932 		}
1933 		bcopy(&parseBuffer[start], tempString, length);
1934 		tempString[length] = 0;
1935 		yylval = (object_t *)tempString;
1936 		return STRING;
1937 	}
1938 
1939 	/* parse quoted string */
1940 	if (c == '"' || c == '\'') {
1941 		int start, length;
1942 		char * tempString;
1943 		char quoteChar = c;
1944 
1945 		start = parseBufferIndex + 1;           // skip quote
1946 		/* find end of string, line, buffer */
1947 		while ((c = nextChar()) != quoteChar) {
1948 			if (c == '\\') {
1949 				c = nextChar();
1950 			}
1951 			if (c == '\n') {
1952 				lineNumber++;
1953 			}
1954 			if (c == 0) {
1955 				return SYNTAX_ERROR;
1956 			}
1957 		}
1958 		length = parseBufferIndex - start;
1959 		/* skip over trailing quote */
1960 		(void)nextChar();
1961 		/* copy to null terminated buffer */
1962 		tempString = (char *)malloc(length + 1);
1963 		if (tempString == 0) {
1964 			printf("OSUnserialize: can't alloc temp memory\n");
1965 			return 0;
1966 		}
1967 
1968 		int to = 0;
1969 		for (int from = start; from < parseBufferIndex; from++) {
1970 			// hack - skip over backslashes
1971 			if (parseBuffer[from] == '\\') {
1972 				length--;
1973 				continue;
1974 			}
1975 			tempString[to] = parseBuffer[from];
1976 			to++;
1977 		}
1978 		tempString[length] = 0;
1979 		yylval = (object_t *)tempString;
1980 		return STRING;
1981 	}
1982 
1983 	/* process numbers */
1984 	if (isDigit(c)) {
1985 		unsigned long long n = 0;
1986 		int base = 10;
1987 
1988 		if (c == '0') {
1989 			c = nextChar();
1990 			if (c == 'x') {
1991 				base = 16;
1992 				c = nextChar();
1993 			}
1994 		}
1995 		if (base == 10) {
1996 			while (isDigit(c)) {
1997 				n = (n * base + c - '0');
1998 				c = nextChar();
1999 			}
2000 		} else {
2001 			while (isHexDigit(c)) {
2002 				if (isDigit(c)) {
2003 					n = (n * base + c - '0');
2004 				} else {
2005 					n = (n * base + 0xa + c - 'a');
2006 				}
2007 				c = nextChar();
2008 			}
2009 		}
2010 
2011 		yylval = newObject();
2012 		yylval->u.offset = n;
2013 
2014 		return NUMBER;
2015 	}
2016 
2017 #define OSDATA_ALLOC_SIZE 4096
2018 
2019 	/* process data */
2020 	if (c == '<') {
2021 		unsigned char *d, *start, *lastStart;
2022 
2023 		start = lastStart = d = (unsigned char *)malloc(OSDATA_ALLOC_SIZE);
2024 		c = nextChar(); // skip over '<'
2025 		while (c != 0 && c != '>') {
2026 			if (isSpace(c)) {
2027 				while ((c = nextChar()) != 0 && isSpace(c)) {
2028 				}
2029 			}
2030 			;
2031 			if (c == '#') {
2032 				while ((c = nextChar()) != 0 && c != '\n') {
2033 				}
2034 			}
2035 			;
2036 			if (c == '\n') {
2037 				lineNumber++;
2038 				c = nextChar();
2039 				continue;
2040 			}
2041 
2042 			// get high nibble
2043 			if (!isHexDigit(c)) {
2044 				break;
2045 			}
2046 			if (isDigit(c)) {
2047 				*d = (c - '0') << 4;
2048 			} else {
2049 				*d =  (0xa + (c - 'a')) << 4;
2050 			}
2051 
2052 			// get low nibble
2053 			c = nextChar();
2054 			if (!isHexDigit(c)) {
2055 				break;
2056 			}
2057 			if (isDigit(c)) {
2058 				*d |= c - '0';
2059 			} else {
2060 				*d |= 0xa + (c - 'a');
2061 			}
2062 
2063 			d++;
2064 			if ((d - lastStart) >= OSDATA_ALLOC_SIZE) {
2065 				int oldsize = d - start;
2066 				start = (unsigned char *)realloc(start, oldsize + OSDATA_ALLOC_SIZE);
2067 				d = lastStart = start + oldsize;
2068 			}
2069 			c = nextChar();
2070 		}
2071 		if (c != '>') {
2072 			free(start);
2073 			return SYNTAX_ERROR;
2074 		}
2075 
2076 		// got it!
2077 		yylval = newObject();
2078 		yylval->object = start;
2079 		yylval->size = d - start;
2080 
2081 		(void)nextChar();       // skip over '>'
2082 		return DATA;
2083 	}
2084 
2085 
2086 	/* return single chars, move pointer to next char */
2087 	(void)nextChar();
2088 	return c;
2089 }
2090 
2091 // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2092 // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2093 // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2094 
2095 #if DEBUG
2096 int debugUnserializeAllocCount = 0;
2097 #endif
2098 
2099 object_t *
2100 newObject()
2101 {
2102 #if DEBUG
2103 	debugUnserializeAllocCount++;
2104 #endif
2105 	return (object_t *)malloc(sizeof(object_t));
2106 }
2107 
2108 void
2109 freeObject(object_t *o)
2110 {
2111 #if DEBUG
2112 	debugUnserializeAllocCount--;
2113 #endif
2114 	free(o);
2115 }
2116 
2117 static OSDictionary *tags;
2118 
2119 static void
2120 rememberObject(int tag, object_t *o)
2121 {
2122 	char key[16];
2123 	snprintf(key, sizeof(key), "%u", tag);
2124 
2125 	tags->setObject(key, (OSObject *)o);
2126 }
2127 
2128 static OSObject *
2129 retrieveObject(int tag)
2130 {
2131 	char key[16];
2132 	snprintf(key, sizeof(key), "%u", tag);
2133 
2134 	return tags->getObject(key);
2135 }
2136 
2137 OSObject *
2138 buildOSDictionary(object_t *o)
2139 {
2140 	object_t *temp, *last = o;
2141 	int count = 0;
2142 
2143 	// get count and last object
2144 	while (o) {
2145 		count++;
2146 		last = o;
2147 		o = o->next;
2148 	}
2149 	o = last;
2150 
2151 	OSDictionary *d = OSDictionary::withCapacity(count);
2152 
2153 	while (o) {
2154 #ifdef metaclass_stuff_worksXXX
2155 		if (((OSObject *)o->u.key)->metaCast("OSSymbol")) {
2156 			// XXX the evil frontdoor
2157 			d->setObject((OSSymbol *)o->u.key, (OSObject *)o->object);
2158 		} else {
2159 			// If it isn't a symbol, I hope it's a string!
2160 			d->setObject((OSString *)o->u.key, (OSObject *)o->object);
2161 		}
2162 #else
2163 		d->setObject((OSString *)o->u.key, (OSObject *)o->object);
2164 #endif
2165 		((OSObject *)o->object)->release();
2166 		((OSObject *)o->u.key)->release();
2167 		temp = o;
2168 		o = o->prev;
2169 		freeObject(temp);
2170 	}
2171 	return d;
2172 };
2173 
2174 OSObject *
2175 buildOSArray(object_t *o)
2176 {
2177 	object_t *temp, *last = o;
2178 	int count = 0;
2179 
2180 	// get count and last object
2181 	while (o) {
2182 		count++;
2183 		last = o;
2184 		o = o->next;
2185 	}
2186 	o = last;
2187 
2188 	OSArray *a = OSArray::withCapacity(count);
2189 
2190 	while (o) {
2191 		a->setObject((OSObject *)o->object);
2192 		((OSObject *)o->object)->release();
2193 		temp = o;
2194 		o = o->prev;
2195 		freeObject(temp);
2196 	}
2197 	return a;
2198 };
2199 
2200 OSObject *
2201 buildOSSet(object_t *o)
2202 {
2203 	OSArray *a = (OSArray *)buildOSArray(o);
2204 	OSSet *s = OSSet::withArray(a, a->getCapacity());
2205 
2206 	a->release();
2207 	return s;
2208 };
2209 
2210 OSObject *
2211 buildOSString(object_t *o)
2212 {
2213 	OSString *s = OSString::withCString((char *)o);
2214 
2215 	free(o);
2216 
2217 	return s;
2218 };
2219 
2220 OSObject *
2221 buildOSData(object_t *o)
2222 {
2223 	OSData *d;
2224 
2225 	if (o->size) {
2226 		d = OSData::withBytes(o->object, o->size);
2227 	} else {
2228 		d = OSData::withCapacity(0);
2229 	}
2230 	free(o->object);
2231 	freeObject(o);
2232 	return d;
2233 };
2234 
2235 OSObject *
2236 buildOSOffset(object_t *o)
2237 {
2238 	OSNumber *off = OSNumber::withNumber(o->u.offset, o->size);
2239 	freeObject(o);
2240 	return off;
2241 };
2242 
2243 OSObject *
2244 buildOSBoolean(object_t *o)
2245 {
2246 	OSBoolean *b = OSBoolean::withBoolean((bool)o);
2247 	return b;
2248 };
2249 
2250 __BEGIN_DECLS
2251 #include <kern/locks.h>
2252 __END_DECLS
2253 
2254 static lck_mtx_t * lock = 0;
2255 extern lck_grp_t *IOLockGroup;
2256 
2257 OSObject*
2258 OSUnserialize(const char *buffer, OSString **errorString)
2259 {
2260 	OSObject *object;
2261 
2262 	if (!lock) {
2263 		lock = lck_mtx_alloc_init(IOLockGroup, LCK_ATTR_NULL);
2264 		lck_mtx_lock(lock);
2265 	} else {
2266 		lck_mtx_lock(lock);
2267 	}
2268 
2269 #if DEBUG
2270 	debugUnserializeAllocCount = 0;
2271 #endif
2272 	yyerror_message[0] = 0; //just in case
2273 	parseBuffer = buffer;
2274 	parseBufferIndex = 0;
2275 	tags = OSDictionary::withCapacity(128);
2276 	if (yyparse() == 0) {
2277 		object = parsedObject;
2278 		if (errorString) {
2279 			*errorString = 0;
2280 		}
2281 	} else {
2282 		object = 0;
2283 		if (errorString) {
2284 			*errorString = OSString::withCString(yyerror_message);
2285 		}
2286 	}
2287 
2288 	tags->release();
2289 #if DEBUG
2290 	if (debugUnserializeAllocCount) {
2291 		printf("OSUnserialize: allocation check failed, count = %d.\n",
2292 		    debugUnserializeAllocCount);
2293 	}
2294 #endif
2295 	lck_mtx_unlock(lock);
2296 
2297 	return object;
2298 }
2299 
2300 
2301 //
2302 //
2303 //
2304 //
2305 //
2306 //		 DO NOT EDIT OSUnserialize.cpp!
2307 //
2308 //			this means you!
2309 //
2310 //
2311 //
2312 //
2313 //
2314