2 * Copyright (c) 1999-2009 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
32 * OSUnserializeXML.y created by rsulack on Tue Oct 12 1999
35 // parser for unserializing OSContainer objects serialized to XML
38 // bison -p OSUnserializeXML OSUnserializeXML.y
39 // head -50 OSUnserializeXML.y > OSUnserializeXML.cpp
40 // sed -e "s/#include <stdio.h>//" < OSUnserializeXML.tab.c >> OSUnserializeXML.cpp
42 // when changing code check in both OSUnserializeXML.y and OSUnserializeXML.cpp
48 // DO NOT EDIT OSUnserializeXML.cpp!
51 /* A Bison parser, made by GNU Bison 2.3. */
53 /* Skeleton implementation for Bison's Yacc-like parsers in C
55 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
56 Free Software Foundation, Inc.
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)
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.
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. */
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.
83 This special exception was added by the Free Software Foundation in
84 version 2.2 of Bison. */
86 /* C LALR(1) parser skeleton written by Richard Stallman, by
87 simplifying the original so-called "semantic" parser. */
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. */
96 /* Identify Bison output. */
100 #define YYBISON_VERSION "2.3"
103 #define YYSKELETON_NAME "yacc.c"
108 /* Using locations. */
109 #define YYLSP_NEEDED 0
111 /* Substitute the variable and function names. */
112 #define yyparse OSUnserializeXMLparse
113 #define yylex OSUnserializeXMLlex
114 #define yyerror OSUnserializeXMLerror
115 #define yylval OSUnserializeXMLlval
116 #define yychar OSUnserializeXMLchar
117 #define yydebug OSUnserializeXMLdebug
118 #define yynerrs OSUnserializeXMLnerrs
124 /* Put the tokens into the symbol table, so that GDB and other debuggers
143 #define DICTIONARY 261
149 #define SYNTAX_ERROR 267
154 /* Copy the first part of user declarations. */
155 #line 61 "OSUnserializeXML.y"
158 #include <libkern/c++/OSMetaClass.h>
159 #include <libkern/c++/OSContainers.h>
160 #include <libkern/c++/OSLib.h>
162 #define YYSTYPE object_t *
163 #define YYPARSE_PARAM state
164 #define YYLEX_PARAM (parser_state_t *)state
166 // this is the internal struct used to hold objects on parser stack
167 // it represents objects both before and after they have been created
168 typedef struct object
{
171 struct object
*elements
;
173 OSString
*key
; // for dictionary
175 void *data
; // for data
176 char *string
; // for string & symbol
177 long long number
; // for number
181 // this code is reentrant, this structure contains all
182 // state information for the parsing of a single buffer
183 typedef struct parser_state
{
184 const char *parseBuffer
; // start of text to be parsed
185 int parseBufferIndex
; // current index into text
186 int lineNumber
; // current line number
187 object_t
*objects
; // internal objects in use
188 object_t
*freeObjects
; // internal objects that are free
189 OSDictionary
*tags
; // used to remember "ID" tags
190 OSString
**errorString
; // parse error with line
191 OSObject
*parsedObject
; // resultant object of parsed text
194 #define STATE ((parser_state_t *)state)
197 #define yyerror(s) OSUnserializeerror(STATE, (s))
198 static int OSUnserializeerror(parser_state_t
*state
, const char *s
);
200 static int yylex(YYSTYPE
*lvalp
, parser_state_t
*state
);
202 static object_t
*newObject(parser_state_t
*state
);
203 static void freeObject(parser_state_t
*state
, object_t
*o
);
204 static void rememberObject(parser_state_t
*state
, int tag
, OSObject
*o
);
205 static object_t
*retrieveObject(parser_state_t
*state
, int tag
);
206 static void cleanupObjects(parser_state_t
*state
);
208 static object_t
*buildDictionary(parser_state_t
*state
, object_t
*o
);
209 static object_t
*buildArray(parser_state_t
*state
, object_t
*o
);
210 static object_t
*buildSet(parser_state_t
*state
, object_t
*o
);
211 static object_t
*buildString(parser_state_t
*state
, object_t
*o
);
212 static object_t
*buildData(parser_state_t
*state
, object_t
*o
);
213 static object_t
*buildNumber(parser_state_t
*state
, object_t
*o
);
214 static object_t
*buildBoolean(parser_state_t
*state
, object_t
*o
);
217 extern void *kern_os_malloc(size_t size
);
218 extern void *kern_os_realloc(void * addr
, size_t size
);
219 extern void kern_os_free(void * addr
);
223 #define malloc(s) kern_os_malloc(s)
224 #define realloc(a, s) kern_os_realloc(a, s)
225 #define free(a) kern_os_free((void *)a)
229 /* Enabling traces. */
234 /* Enabling verbose error messages. */
235 #ifdef YYERROR_VERBOSE
236 # undef YYERROR_VERBOSE
237 # define YYERROR_VERBOSE 1
239 # define YYERROR_VERBOSE 0
242 /* Enabling the token table. */
243 #ifndef YYTOKEN_TABLE
244 # define YYTOKEN_TABLE 0
247 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
249 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
250 # define YYSTYPE_IS_DECLARED 1
251 # define YYSTYPE_IS_TRIVIAL 1
256 /* Copy the second part of user declarations. */
259 /* Line 216 of yacc.c. */
260 #line 211 "OSUnserializeXML.tab.c"
267 typedef YYTYPE_UINT8 yytype_uint8
;
269 typedef unsigned char yytype_uint8
;
273 typedef YYTYPE_INT8 yytype_int8
;
274 #elif (defined __STDC__ || defined __C99__FUNC__ \
275 || defined __cplusplus || defined _MSC_VER)
276 typedef signed char yytype_int8
;
278 typedef short int yytype_int8
;
282 typedef YYTYPE_UINT16 yytype_uint16
;
284 typedef unsigned short int yytype_uint16
;
288 typedef YYTYPE_INT16 yytype_int16
;
290 typedef short int yytype_int16
;
294 # ifdef __SIZE_TYPE__
295 # define YYSIZE_T __SIZE_TYPE__
296 # elif defined size_t
297 # define YYSIZE_T size_t
298 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
299 || defined __cplusplus || defined _MSC_VER)
300 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
301 # define YYSIZE_T size_t
303 # define YYSIZE_T unsigned int
307 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
310 # if defined YYENABLE_NLS && YYENABLE_NLS
312 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
313 # define YY_(msgid) dgettext ("bison-runtime", msgid)
317 # define YY_(msgid) msgid
321 /* Suppress unused-variable warnings by "using" E. */
322 #if ! defined lint || defined __GNUC__
323 # define YYUSE(e) ((void) (e))
325 # define YYUSE(e) /* empty */
328 /* Identity function, used to suppress warnings about constant conditions. */
332 #if (defined __STDC__ || defined __C99__FUNC__ \
333 || defined __cplusplus || defined _MSC_VER)
346 #if ! defined yyoverflow || YYERROR_VERBOSE
348 /* The parser invokes alloca or malloc; define the necessary symbols. */
350 # ifdef YYSTACK_USE_ALLOCA
351 # if YYSTACK_USE_ALLOCA
353 # define YYSTACK_ALLOC __builtin_alloca
354 # elif defined __BUILTIN_VA_ARG_INCR
355 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
357 # define YYSTACK_ALLOC __alloca
358 # elif defined _MSC_VER
359 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
360 # define alloca _alloca
362 # define YYSTACK_ALLOC alloca
363 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
364 || defined __cplusplus || defined _MSC_VER)
365 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
374 # ifdef YYSTACK_ALLOC
375 /* Pacify GCC's `empty if-body' warning. */
376 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
377 # ifndef YYSTACK_ALLOC_MAXIMUM
378 /* The OS might guarantee only one guard page at the bottom of the stack,
379 and a page size can be as small as 4096 bytes. So we cannot safely
380 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
381 to allow for a few compiler-allocated temporary stack slots. */
382 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
385 # define YYSTACK_ALLOC YYMALLOC
386 # define YYSTACK_FREE YYFREE
387 # ifndef YYSTACK_ALLOC_MAXIMUM
388 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
390 # if (defined __cplusplus && ! defined _STDLIB_H \
391 && ! ((defined YYMALLOC || defined malloc) \
392 && (defined YYFREE || defined free)))
393 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
399 # define YYMALLOC malloc
400 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
401 || defined __cplusplus || defined _MSC_VER)
402 void *malloc (YYSIZE_T
); /* INFRINGES ON USER NAME SPACE */
407 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
408 || defined __cplusplus || defined _MSC_VER)
409 void free (void *); /* INFRINGES ON USER NAME SPACE */
413 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
416 #if (! defined yyoverflow \
417 && (! defined __cplusplus \
418 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
420 /* A type that is properly aligned for any stack member. */
427 /* The size of the maximum gap between one aligned stack and the next. */
428 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
430 /* The size of an array large to enough to hold all stacks, each with
432 # define YYSTACK_BYTES(N) \
433 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
434 + YYSTACK_GAP_MAXIMUM)
436 /* Copy COUNT objects from FROM to TO. The source and destination do
439 # if defined __GNUC__ && 1 < __GNUC__
440 # define YYCOPY(To, From, Count) \
441 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
443 # define YYCOPY(To, From, Count) \
447 for (yyi = 0; yyi < (Count); yyi++) \
448 (To)[yyi] = (From)[yyi]; \
454 /* Relocate STACK from its old location to the new one. The
455 local variables YYSIZE and YYSTACKSIZE give the old and new number of
456 elements in the stack, and YYPTR gives the new location of the
457 stack. Advance YYPTR to a properly aligned location for the next
459 # define YYSTACK_RELOCATE(Stack) \
462 YYSIZE_T yynewbytes; \
463 YYCOPY (&yyptr->Stack, Stack, yysize); \
464 Stack = &yyptr->Stack; \
465 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
466 yyptr += yynewbytes / sizeof (*yyptr); \
472 /* YYFINAL -- State number of the termination state. */
474 /* YYLAST -- Last index in YYTABLE. */
477 /* YYNTOKENS -- Number of terminals. */
479 /* YYNNTS -- Number of nonterminals. */
481 /* YYNRULES -- Number of rules. */
483 /* YYNRULES -- Number of states. */
486 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
488 #define YYMAXUTOK 267
490 #define YYTRANSLATE(YYX) \
491 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
493 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
494 static const yytype_uint8 yytranslate
[] =
496 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
497 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
498 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
499 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
500 15, 16, 2, 2, 2, 2, 2, 2, 2, 2,
501 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
502 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
503 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
504 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
505 2, 17, 2, 18, 2, 2, 2, 2, 2, 2,
506 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
507 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
508 2, 2, 2, 13, 2, 14, 2, 2, 2, 2,
509 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
510 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
511 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
512 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
513 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
514 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
515 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
516 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
517 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
518 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
519 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
520 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
521 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
522 5, 6, 7, 8, 9, 10, 11, 12
526 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
528 static const yytype_uint8 yyprhs
[] =
530 0, 0, 3, 4, 6, 8, 10, 12, 14, 16,
531 18, 20, 22, 24, 27, 31, 33, 35, 38, 41,
532 43, 46, 50, 52, 55, 59, 61, 63, 66, 68,
536 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
537 static const yytype_int8 yyrhs
[] =
539 20, 0, -1, -1, 21, -1, 12, -1, 22, -1,
540 26, -1, 27, -1, 33, -1, 30, -1, 32, -1,
541 29, -1, 31, -1, 13, 14, -1, 13, 23, 14,
542 -1, 6, -1, 24, -1, 23, 24, -1, 25, 21,
543 -1, 8, -1, 15, 16, -1, 15, 28, 16, -1,
544 3, -1, 17, 18, -1, 17, 28, 18, -1, 10,
545 -1, 21, -1, 28, 21, -1, 4, -1, 5, -1,
549 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
550 static const yytype_uint8 yyrline
[] =
552 0, 145, 145, 148, 153, 158, 159, 160, 161, 162,
553 163, 164, 165, 178, 181, 184, 187, 188, 193, 202,
554 207, 210, 213, 216, 219, 222, 225, 228, 235, 238,
559 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
560 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
561 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
562 static const char *const yytname
[] =
564 "$end", "error", "$undefined", "ARRAY", "BOOLEAN", "DATA", "DICTIONARY",
565 "IDREF", "KEY", "NUMBER", "SET", "STRING", "SYNTAX_ERROR", "'{'", "'}'",
566 "'('", "')'", "'['", "']'", "$accept", "input", "object", "dict",
567 "pairs", "pair", "key", "array", "set", "elements", "boolean", "data",
568 "idref", "number", "string", 0
573 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
575 static const yytype_uint16 yytoknum
[] =
577 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
578 265, 266, 267, 123, 125, 40, 41, 91, 93
582 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
583 static const yytype_uint8 yyr1
[] =
585 0, 19, 20, 20, 20, 21, 21, 21, 21, 21,
586 21, 21, 21, 22, 22, 22, 23, 23, 24, 25,
587 26, 26, 26, 27, 27, 27, 28, 28, 29, 30,
591 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
592 static const yytype_uint8 yyr2
[] =
594 0, 2, 0, 1, 1, 1, 1, 1, 1, 1,
595 1, 1, 1, 2, 3, 1, 1, 2, 2, 1,
596 2, 3, 1, 2, 3, 1, 1, 2, 1, 1,
600 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
601 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
602 means the default is an error. */
603 static const yytype_uint8 yydefact
[] =
605 2, 22, 28, 29, 15, 30, 31, 25, 32, 4,
606 0, 0, 0, 0, 3, 5, 6, 7, 11, 9,
607 12, 10, 8, 19, 13, 0, 16, 0, 20, 26,
608 0, 23, 0, 1, 14, 17, 18, 21, 27, 24
611 /* YYDEFGOTO[NTERM-NUM]. */
612 static const yytype_int8 yydefgoto
[] =
614 -1, 13, 29, 15, 25, 26, 27, 16, 17, 30,
618 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
620 #define YYPACT_NINF -20
621 static const yytype_int8 yypact
[] =
623 46, -20, -20, -20, -20, -20, -20, -20, -20, -20,
624 4, 61, -2, 10, -20, -20, -20, -20, -20, -20,
625 -20, -20, -20, -20, -20, 6, -20, 91, -20, -20,
626 76, -20, 30, -20, -20, -20, -20, -20, -20, -20
629 /* YYPGOTO[NTERM-NUM]. */
630 static const yytype_int8 yypgoto
[] =
632 -20, -20, 0, -20, -20, -19, -20, -20, -20, 5,
633 -20, -20, -20, -20, -20
636 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
637 positive, shift that token. If negative, reduce the rule which
638 number is the opposite. If zero, do what YYDEFACT says.
639 If YYTABLE_NINF, syntax error. */
640 #define YYTABLE_NINF -1
641 static const yytype_uint8 yytable
[] =
643 14, 1, 2, 3, 4, 5, 35, 6, 7, 8,
644 33, 10, 23, 11, 23, 12, 31, 32, 24, 0,
645 34, 0, 0, 0, 0, 0, 0, 36, 0, 0,
646 38, 0, 38, 1, 2, 3, 4, 5, 0, 6,
647 7, 8, 0, 10, 0, 11, 0, 12, 39, 1,
648 2, 3, 4, 5, 0, 6, 7, 8, 9, 10,
649 0, 11, 0, 12, 1, 2, 3, 4, 5, 0,
650 6, 7, 8, 0, 10, 0, 11, 28, 12, 1,
651 2, 3, 4, 5, 0, 6, 7, 8, 0, 10,
652 0, 11, 37, 12, 1, 2, 3, 4, 5, 0,
653 6, 7, 8, 0, 10, 0, 11, 0, 12
656 static const yytype_int8 yycheck
[] =
658 0, 3, 4, 5, 6, 7, 25, 9, 10, 11,
659 0, 13, 8, 15, 8, 17, 18, 12, 14, -1,
660 14, -1, -1, -1, -1, -1, -1, 27, -1, -1,
661 30, -1, 32, 3, 4, 5, 6, 7, -1, 9,
662 10, 11, -1, 13, -1, 15, -1, 17, 18, 3,
663 4, 5, 6, 7, -1, 9, 10, 11, 12, 13,
664 -1, 15, -1, 17, 3, 4, 5, 6, 7, -1,
665 9, 10, 11, -1, 13, -1, 15, 16, 17, 3,
666 4, 5, 6, 7, -1, 9, 10, 11, -1, 13,
667 -1, 15, 16, 17, 3, 4, 5, 6, 7, -1,
668 9, 10, 11, -1, 13, -1, 15, -1, 17
671 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
672 symbol of state STATE-NUM. */
673 static const yytype_uint8 yystos
[] =
675 0, 3, 4, 5, 6, 7, 9, 10, 11, 12,
676 13, 15, 17, 20, 21, 22, 26, 27, 29, 30,
677 31, 32, 33, 8, 14, 23, 24, 25, 16, 21,
678 28, 18, 28, 0, 14, 24, 21, 16, 21, 18
681 #define yyerrok (yyerrstatus = 0)
682 #define yyclearin (yychar = YYEMPTY)
686 #define YYACCEPT goto yyacceptlab
687 #define YYABORT goto yyabortlab
688 #define YYERROR goto yyerrorlab
691 /* Like YYERROR except do call yyerror. This remains here temporarily
692 to ease the transition to the new meaning of YYERROR, for GCC.
693 Once GCC version 2 has supplanted version 1, this can go. */
695 #define YYFAIL goto yyerrlab
697 #define YYRECOVERING() (!!yyerrstatus)
699 #define YYBACKUP(Token, Value) \
701 if (yychar == YYEMPTY && yylen == 1) \
705 yytoken = YYTRANSLATE (yychar); \
711 yyerror (YY_("syntax error: cannot back up")); \
718 #define YYERRCODE 256
721 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
722 If N is 0, then set CURRENT to the empty location which ends
723 the previous symbol: RHS[0] (always defined). */
725 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
726 #ifndef YYLLOC_DEFAULT
727 # define YYLLOC_DEFAULT(Current, Rhs, N) \
731 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
732 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
733 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
734 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
738 (Current).first_line = (Current).last_line = \
739 YYRHSLOC (Rhs, 0).last_line; \
740 (Current).first_column = (Current).last_column = \
741 YYRHSLOC (Rhs, 0).last_column; \
747 /* YY_LOCATION_PRINT -- Print the location on the stream.
748 This macro was not mandated originally: define only if we know
749 we won't break user code: when these are the locations we know. */
751 #ifndef YY_LOCATION_PRINT
752 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
753 # define YY_LOCATION_PRINT(File, Loc) \
754 fprintf (File, "%d.%d-%d.%d", \
755 (Loc).first_line, (Loc).first_column, \
756 (Loc).last_line, (Loc).last_column)
758 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
763 /* YYLEX -- calling `yylex' with the right arguments. */
766 # define YYLEX yylex (&yylval, YYLEX_PARAM)
768 # define YYLEX yylex (&yylval)
771 /* Enable debugging if requested. */
775 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
776 # define YYFPRINTF fprintf
779 # define YYDPRINTF(Args) \
785 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
789 YYFPRINTF (stderr, "%s ", Title); \
790 yy_symbol_print (stderr, \
792 YYFPRINTF (stderr, "\n"); \
797 /*--------------------------------.
798 | Print this symbol on YYOUTPUT. |
799 `--------------------------------*/
802 #if (defined __STDC__ || defined __C99__FUNC__ \
803 || defined __cplusplus || defined _MSC_VER)
805 yy_symbol_value_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
)
808 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
)
811 YYSTYPE
const * const yyvaluep
;
817 if (yytype
< YYNTOKENS
)
818 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
830 /*--------------------------------.
831 | Print this symbol on YYOUTPUT. |
832 `--------------------------------*/
834 #if (defined __STDC__ || defined __C99__FUNC__ \
835 || defined __cplusplus || defined _MSC_VER)
837 yy_symbol_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
)
840 yy_symbol_print (yyoutput
, yytype
, yyvaluep
)
843 YYSTYPE
const * const yyvaluep
;
846 if (yytype
< YYNTOKENS
)
847 YYFPRINTF (yyoutput
, "token %s (", yytname
[yytype
]);
849 YYFPRINTF (yyoutput
, "nterm %s (", yytname
[yytype
]);
851 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
);
852 YYFPRINTF (yyoutput
, ")");
855 /*------------------------------------------------------------------.
856 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
858 `------------------------------------------------------------------*/
860 #if (defined __STDC__ || defined __C99__FUNC__ \
861 || defined __cplusplus || defined _MSC_VER)
863 yy_stack_print (yytype_int16
*bottom
, yytype_int16
*top
)
866 yy_stack_print (bottom
, top
)
867 yytype_int16
*bottom
;
871 YYFPRINTF (stderr
, "Stack now");
872 for (; bottom
<= top
; ++bottom
)
873 YYFPRINTF (stderr
, " %d", *bottom
);
874 YYFPRINTF (stderr
, "\n");
877 # define YY_STACK_PRINT(Bottom, Top) \
880 yy_stack_print ((Bottom), (Top)); \
884 /*------------------------------------------------.
885 | Report that the YYRULE is going to be reduced. |
886 `------------------------------------------------*/
888 #if (defined __STDC__ || defined __C99__FUNC__ \
889 || defined __cplusplus || defined _MSC_VER)
891 yy_reduce_print (YYSTYPE
*yyvsp
, int yyrule
)
894 yy_reduce_print (yyvsp
, yyrule
)
899 int yynrhs
= yyr2
[yyrule
];
901 unsigned long int yylno
= yyrline
[yyrule
];
902 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu):\n",
904 /* The symbols being reduced. */
905 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
907 fprintf (stderr
, " $%d = ", yyi
+ 1);
908 yy_symbol_print (stderr
, yyrhs
[yyprhs
[yyrule
] + yyi
],
909 &(yyvsp
[(yyi
+ 1) - (yynrhs
)])
911 fprintf (stderr
, "\n");
915 # define YY_REDUCE_PRINT(Rule) \
918 yy_reduce_print (yyvsp, Rule); \
921 /* Nonzero means print parse trace. It is left uninitialized so that
922 multiple parsers can coexist. */
925 # define YYDPRINTF(Args)
926 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
927 # define YY_STACK_PRINT(Bottom, Top)
928 # define YY_REDUCE_PRINT(Rule)
929 #endif /* !YYDEBUG */
932 /* YYINITDEPTH -- initial size of the parser's stacks. */
934 # define YYINITDEPTH 200
937 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
938 if the built-in stack extension method is used).
940 Do not make this value too large; the results are undefined if
941 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
942 evaluated with infinite-precision integer arithmetic. */
945 # define YYMAXDEPTH 10000
953 # if defined __GLIBC__ && defined _STRING_H
954 # define yystrlen strlen
956 /* Return the length of YYSTR. */
957 #if (defined __STDC__ || defined __C99__FUNC__ \
958 || defined __cplusplus || defined _MSC_VER)
960 yystrlen (const char *yystr
)
968 for (yylen
= 0; yystr
[yylen
]; yylen
++)
976 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
977 # define yystpcpy stpcpy
979 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
981 #if (defined __STDC__ || defined __C99__FUNC__ \
982 || defined __cplusplus || defined _MSC_VER)
984 yystpcpy (char *yydest
, const char *yysrc
)
987 yystpcpy (yydest
, yysrc
)
993 const char *yys
= yysrc
;
995 while ((*yyd
++ = *yys
++) != '\0')
1004 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1005 quotes and backslashes, so that it's suitable for yyerror. The
1006 heuristic is that double-quoting is unnecessary unless the string
1007 contains an apostrophe, a comma, or backslash (other than
1008 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1009 null, do not copy; instead, return the length of what the result
1012 yytnamerr (char *yyres
, const char *yystr
)
1017 char const *yyp
= yystr
;
1024 goto do_not_strip_quotes
;
1028 goto do_not_strip_quotes
;
1041 do_not_strip_quotes
: ;
1045 return yystrlen (yystr
);
1047 return yystpcpy (yyres
, yystr
) - yyres
;
1051 /* Copy into YYRESULT an error message about the unexpected token
1052 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1053 including the terminating null byte. If YYRESULT is null, do not
1054 copy anything; just return the number of bytes that would be
1055 copied. As a special case, return 0 if an ordinary "syntax error"
1056 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1057 size calculation. */
1059 yysyntax_error (char *yyresult
, int yystate
, int yychar
)
1061 int yyn
= yypact
[yystate
];
1063 if (! (YYPACT_NINF
< yyn
&& yyn
<= YYLAST
))
1067 int yytype
= YYTRANSLATE (yychar
);
1068 YYSIZE_T yysize0
= yytnamerr (0, yytname
[yytype
]);
1069 YYSIZE_T yysize
= yysize0
;
1071 int yysize_overflow
= 0;
1072 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1073 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1077 /* This is so xgettext sees the translatable formats that are
1078 constructed on the fly. */
1079 YY_("syntax error, unexpected %s");
1080 YY_("syntax error, unexpected %s, expecting %s");
1081 YY_("syntax error, unexpected %s, expecting %s or %s");
1082 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1083 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1087 static char const yyunexpected
[] = "syntax error, unexpected %s";
1088 static char const yyexpecting
[] = ", expecting %s";
1089 static char const yyor
[] = " or %s";
1090 char yyformat
[sizeof yyunexpected
1091 + sizeof yyexpecting
- 1
1092 + ((YYERROR_VERBOSE_ARGS_MAXIMUM
- 2)
1093 * (sizeof yyor
- 1))];
1094 char const *yyprefix
= yyexpecting
;
1096 /* Start YYX at -YYN if negative to avoid negative indexes in
1098 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1100 /* Stay within bounds of both yycheck and yytname. */
1101 int yychecklim
= YYLAST
- yyn
+ 1;
1102 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1105 yyarg
[0] = yytname
[yytype
];
1106 yyfmt
= yystpcpy (yyformat
, yyunexpected
);
1108 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1109 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1111 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1115 yyformat
[sizeof yyunexpected
- 1] = '\0';
1118 yyarg
[yycount
++] = yytname
[yyx
];
1119 yysize1
= yysize
+ yytnamerr (0, yytname
[yyx
]);
1120 yysize_overflow
|= (yysize1
< yysize
);
1122 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
1126 yyf
= YY_(yyformat
);
1127 yysize1
= yysize
+ yystrlen (yyf
);
1128 yysize_overflow
|= (yysize1
< yysize
);
1131 if (yysize_overflow
)
1132 return YYSIZE_MAXIMUM
;
1136 /* Avoid sprintf, as that infringes on the user's name space.
1137 Don't have undefined behavior even if the translation
1138 produced a string with the wrong number of "%s"s. */
1139 char *yyp
= yyresult
;
1141 while ((*yyp
= *yyf
) != '\0')
1143 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
1145 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1158 #endif /* YYERROR_VERBOSE */
1161 /*-----------------------------------------------.
1162 | Release the memory associated to this symbol. |
1163 `-----------------------------------------------*/
1166 #if (defined __STDC__ || defined __C99__FUNC__ \
1167 || defined __cplusplus || defined _MSC_VER)
1169 yydestruct (const char *yymsg
, int yytype
, YYSTYPE
*yyvaluep
)
1172 yydestruct (yymsg
, yytype
, yyvaluep
)
1182 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
1193 /* Prevent warnings from -Wmissing-prototypes. */
1195 #ifdef YYPARSE_PARAM
1196 #if defined __STDC__ || defined __cplusplus
1197 int yyparse (void *YYPARSE_PARAM
);
1201 #else /* ! YYPARSE_PARAM */
1202 #if defined __STDC__ || defined __cplusplus
1207 #endif /* ! YYPARSE_PARAM */
1218 #ifdef YYPARSE_PARAM
1219 #if (defined __STDC__ || defined __C99__FUNC__ \
1220 || defined __cplusplus || defined _MSC_VER)
1222 yyparse (void *YYPARSE_PARAM
)
1225 yyparse (YYPARSE_PARAM
)
1226 void *YYPARSE_PARAM
;
1228 #else /* ! YYPARSE_PARAM */
1229 #if (defined __STDC__ || defined __C99__FUNC__ \
1230 || defined __cplusplus || defined _MSC_VER)
1240 /* The look-ahead symbol. */
1243 /* The semantic value of the look-ahead symbol. */
1246 /* Number of syntax errors so far. */
1252 /* Number of tokens to shift before error messages enabled. */
1254 /* Look-ahead token as an internal (translated) token number. */
1257 /* Buffer for error messages, and its allocated size. */
1259 char *yymsg
= yymsgbuf
;
1260 YYSIZE_T yymsg_alloc
= sizeof yymsgbuf
;
1263 /* Three stacks and their tools:
1264 `yyss': related to states,
1265 `yyvs': related to semantic values,
1266 `yyls': related to locations.
1268 Refer to the stacks thru separate pointers, to allow yyoverflow
1269 to reallocate them elsewhere. */
1271 /* The state stack. */
1272 yytype_int16 yyssa
[YYINITDEPTH
];
1273 yytype_int16
*yyss
= yyssa
;
1274 yytype_int16
*yyssp
;
1276 /* The semantic value stack. */
1277 YYSTYPE yyvsa
[YYINITDEPTH
];
1278 YYSTYPE
*yyvs
= yyvsa
;
1283 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1285 YYSIZE_T yystacksize
= YYINITDEPTH
;
1287 /* The variables used to return semantic value and location from the
1292 /* The number of symbols on the RHS of the reduced rule.
1293 Keep to zero when no symbol should be popped. */
1296 YYDPRINTF ((stderr
, "Starting parse\n"));
1301 yychar
= YYEMPTY
; /* Cause a token to be read. */
1303 /* Initialize stack pointers.
1304 Waste one element of value and location stack
1305 so that they stay on the same level as the state stack.
1306 The wasted elements are never initialized. */
1313 /*------------------------------------------------------------.
1314 | yynewstate -- Push a new state, which is found in yystate. |
1315 `------------------------------------------------------------*/
1317 /* In all cases, when you get here, the value and location stacks
1318 have just been pushed. So pushing a state here evens the stacks. */
1324 if (yyss
+ yystacksize
- 1 <= yyssp
)
1326 /* Get the current used size of the three stacks, in elements. */
1327 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1331 /* Give user a chance to reallocate the stack. Use copies of
1332 these so that the &'s don't force the real ones into
1334 YYSTYPE
*yyvs1
= yyvs
;
1335 yytype_int16
*yyss1
= yyss
;
1338 /* Each stack pointer address is followed by the size of the
1339 data in use in that stack, in bytes. This used to be a
1340 conditional around just the two extra args, but that might
1341 be undefined if yyoverflow is a macro. */
1342 yyoverflow (YY_("memory exhausted"),
1343 &yyss1
, yysize
* sizeof (*yyssp
),
1344 &yyvs1
, yysize
* sizeof (*yyvsp
),
1351 #else /* no yyoverflow */
1352 # ifndef YYSTACK_RELOCATE
1353 goto yyexhaustedlab
;
1355 /* Extend the stack our own way. */
1356 if (YYMAXDEPTH
<= yystacksize
)
1357 goto yyexhaustedlab
;
1359 if (YYMAXDEPTH
< yystacksize
)
1360 yystacksize
= YYMAXDEPTH
;
1363 yytype_int16
*yyss1
= yyss
;
1364 union yyalloc
*yyptr
=
1365 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1367 goto yyexhaustedlab
;
1368 YYSTACK_RELOCATE (yyss
);
1369 YYSTACK_RELOCATE (yyvs
);
1371 # undef YYSTACK_RELOCATE
1373 YYSTACK_FREE (yyss1
);
1376 #endif /* no yyoverflow */
1378 yyssp
= yyss
+ yysize
- 1;
1379 yyvsp
= yyvs
+ yysize
- 1;
1382 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1383 (unsigned long int) yystacksize
));
1385 if (yyss
+ yystacksize
- 1 <= yyssp
)
1389 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1398 /* Do appropriate processing given the current state. Read a
1399 look-ahead token if we need one and don't already have one. */
1401 /* First try to decide what to do without reference to look-ahead token. */
1402 yyn
= yypact
[yystate
];
1403 if (yyn
== YYPACT_NINF
)
1406 /* Not known => get a look-ahead token if don't already have one. */
1408 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1409 if (yychar
== YYEMPTY
)
1411 YYDPRINTF ((stderr
, "Reading a token: "));
1415 if (yychar
<= YYEOF
)
1417 yychar
= yytoken
= YYEOF
;
1418 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1422 yytoken
= YYTRANSLATE (yychar
);
1423 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1426 /* If the proper action on seeing token YYTOKEN is to reduce or to
1427 detect an error, take that action. */
1429 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1434 if (yyn
== 0 || yyn
== YYTABLE_NINF
)
1443 /* Count tokens shifted since error; after three, turn off error
1448 /* Shift the look-ahead token. */
1449 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1451 /* Discard the shifted token unless it is eof. */
1452 if (yychar
!= YYEOF
)
1461 /*-----------------------------------------------------------.
1462 | yydefault -- do the default action for the current state. |
1463 `-----------------------------------------------------------*/
1465 yyn
= yydefact
[yystate
];
1471 /*-----------------------------.
1472 | yyreduce -- Do a reduction. |
1473 `-----------------------------*/
1475 /* yyn is the number of a rule to reduce with. */
1478 /* If YYLEN is nonzero, implement the default value of the action:
1481 Otherwise, the following line sets YYVAL to garbage.
1482 This behavior is undocumented and Bison
1483 users should not rely upon it. Assigning to YYVAL
1484 unconditionally makes the parser a bit smaller, and it avoids a
1485 GCC warning that YYVAL may be used uninitialized. */
1486 yyval
= yyvsp
[1-yylen
];
1489 YY_REDUCE_PRINT (yyn
);
1493 #line 145 "OSUnserializeXML.y"
1494 { yyerror("unexpected end of buffer");
1500 #line 148 "OSUnserializeXML.y"
1501 { STATE
->parsedObject
= (yyvsp
[(1) - (1)])->object
;
1502 (yyvsp
[(1) - (1)])->object
= 0;
1503 freeObject(STATE
, (yyvsp
[(1) - (1)]));
1509 #line 153 "OSUnserializeXML.y"
1510 { yyerror("syntax error");
1516 #line 158 "OSUnserializeXML.y"
1517 { (yyval
) = buildDictionary(STATE
, (yyvsp
[(1) - (1)])); ;}
1521 #line 159 "OSUnserializeXML.y"
1522 { (yyval
) = buildArray(STATE
, (yyvsp
[(1) - (1)])); ;}
1526 #line 160 "OSUnserializeXML.y"
1527 { (yyval
) = buildSet(STATE
, (yyvsp
[(1) - (1)])); ;}
1531 #line 161 "OSUnserializeXML.y"
1532 { (yyval
) = buildString(STATE
, (yyvsp
[(1) - (1)])); ;}
1536 #line 162 "OSUnserializeXML.y"
1537 { (yyval
) = buildData(STATE
, (yyvsp
[(1) - (1)])); ;}
1541 #line 163 "OSUnserializeXML.y"
1542 { (yyval
) = buildNumber(STATE
, (yyvsp
[(1) - (1)])); ;}
1546 #line 164 "OSUnserializeXML.y"
1547 { (yyval
) = buildBoolean(STATE
, (yyvsp
[(1) - (1)])); ;}
1551 #line 165 "OSUnserializeXML.y"
1552 { (yyval
) = retrieveObject(STATE
, (yyvsp
[(1) - (1)])->idref
);
1554 (yyval
)->object
->retain();
1556 yyerror("forward reference detected");
1559 freeObject(STATE
, (yyvsp
[(1) - (1)]));
1564 #line 178 "OSUnserializeXML.y"
1565 { (yyval
) = (yyvsp
[(1) - (2)]);
1566 (yyval
)->elements
= NULL
;
1571 #line 181 "OSUnserializeXML.y"
1572 { (yyval
) = (yyvsp
[(1) - (3)]);
1573 (yyval
)->elements
= (yyvsp
[(2) - (3)]);
1578 #line 188 "OSUnserializeXML.y"
1579 { (yyval
) = (yyvsp
[(2) - (2)]);
1580 (yyval
)->next
= (yyvsp
[(1) - (2)]);
1585 #line 193 "OSUnserializeXML.y"
1586 { (yyval
) = (yyvsp
[(1) - (2)]);
1587 (yyval
)->key
= (OSString
*)(yyval
)->object
;
1588 (yyval
)->object
= (yyvsp
[(2) - (2)])->object
;
1589 (yyval
)->next
= NULL
;
1590 (yyvsp
[(2) - (2)])->object
= 0;
1591 freeObject(STATE
, (yyvsp
[(2) - (2)]));
1596 #line 202 "OSUnserializeXML.y"
1597 { (yyval
) = buildString(STATE
, (yyvsp
[(1) - (1)])); ;}
1601 #line 207 "OSUnserializeXML.y"
1602 { (yyval
) = (yyvsp
[(1) - (2)]);
1603 (yyval
)->elements
= NULL
;
1608 #line 210 "OSUnserializeXML.y"
1609 { (yyval
) = (yyvsp
[(1) - (3)]);
1610 (yyval
)->elements
= (yyvsp
[(2) - (3)]);
1615 #line 216 "OSUnserializeXML.y"
1616 { (yyval
) = (yyvsp
[(1) - (2)]);
1617 (yyval
)->elements
= NULL
;
1622 #line 219 "OSUnserializeXML.y"
1623 { (yyval
) = (yyvsp
[(1) - (3)]);
1624 (yyval
)->elements
= (yyvsp
[(2) - (3)]);
1629 #line 225 "OSUnserializeXML.y"
1630 { (yyval
) = (yyvsp
[(1) - (1)]);
1631 (yyval
)->next
= NULL
;
1636 #line 228 "OSUnserializeXML.y"
1637 { (yyval
) = (yyvsp
[(2) - (2)]);
1638 (yyval
)->next
= (yyvsp
[(1) - (2)]);
1643 /* Line 1267 of yacc.c. */
1644 #line 1595 "OSUnserializeXML.tab.c"
1647 YY_SYMBOL_PRINT ("-> $$ =", yyr1
[yyn
], &yyval
, &yyloc
);
1651 YY_STACK_PRINT (yyss
, yyssp
);
1656 /* Now `shift' the result of the reduction. Determine what state
1657 that goes to, based on the state we popped back to and the rule
1658 number reduced by. */
1662 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
1663 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1664 yystate
= yytable
[yystate
];
1666 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
1671 /*------------------------------------.
1672 | yyerrlab -- here on detecting error |
1673 `------------------------------------*/
1675 /* If not already recovering from an error, report this error. */
1679 #if ! YYERROR_VERBOSE
1680 yyerror (YY_("syntax error"));
1683 YYSIZE_T yysize
= yysyntax_error (0, yystate
, yychar
);
1684 if (yymsg_alloc
< yysize
&& yymsg_alloc
< YYSTACK_ALLOC_MAXIMUM
)
1686 YYSIZE_T yyalloc
= 2 * yysize
;
1687 if (! (yysize
<= yyalloc
&& yyalloc
<= YYSTACK_ALLOC_MAXIMUM
))
1688 yyalloc
= YYSTACK_ALLOC_MAXIMUM
;
1689 if (yymsg
!= yymsgbuf
)
1690 YYSTACK_FREE (yymsg
);
1691 yymsg
= (char *) YYSTACK_ALLOC (yyalloc
);
1693 yymsg_alloc
= yyalloc
;
1697 yymsg_alloc
= sizeof yymsgbuf
;
1701 if (0 < yysize
&& yysize
<= yymsg_alloc
)
1703 (void) yysyntax_error (yymsg
, yystate
, yychar
);
1708 yyerror (YY_("syntax error"));
1710 goto yyexhaustedlab
;
1718 if (yyerrstatus
== 3)
1720 /* If just tried and failed to reuse look-ahead token after an
1721 error, discard it. */
1723 if (yychar
<= YYEOF
)
1725 /* Return failure if at end of input. */
1726 if (yychar
== YYEOF
)
1731 yydestruct ("Error: discarding",
1737 /* Else will try to reuse look-ahead token after shifting the error
1742 /*---------------------------------------------------.
1743 | yyerrorlab -- error raised explicitly by YYERROR. |
1744 `---------------------------------------------------*/
1747 /* Pacify compilers like GCC when the user code never invokes
1748 YYERROR and the label yyerrorlab therefore never appears in user
1750 if (/*CONSTCOND*/ 0)
1753 /* Do not reclaim the symbols of the rule which action triggered
1757 YY_STACK_PRINT (yyss
, yyssp
);
1762 /*-------------------------------------------------------------.
1763 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1764 `-------------------------------------------------------------*/
1766 yyerrstatus
= 3; /* Each real token shifted decrements this. */
1770 yyn
= yypact
[yystate
];
1771 if (yyn
!= YYPACT_NINF
)
1774 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
1782 /* Pop the current state because it cannot handle the error token. */
1787 yydestruct ("Error: popping",
1788 yystos
[yystate
], yyvsp
);
1791 YY_STACK_PRINT (yyss
, yyssp
);
1800 /* Shift the error token. */
1801 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
1807 /*-------------------------------------.
1808 | yyacceptlab -- YYACCEPT comes here. |
1809 `-------------------------------------*/
1814 /*-----------------------------------.
1815 | yyabortlab -- YYABORT comes here. |
1816 `-----------------------------------*/
1822 /*-------------------------------------------------.
1823 | yyexhaustedlab -- memory exhaustion comes here. |
1824 `-------------------------------------------------*/
1826 yyerror (YY_("memory exhausted"));
1832 if (yychar
!= YYEOF
&& yychar
!= YYEMPTY
)
1833 yydestruct ("Cleanup: discarding lookahead",
1835 /* Do not reclaim the symbols of the rule which action triggered
1836 this YYABORT or YYACCEPT. */
1838 YY_STACK_PRINT (yyss
, yyssp
);
1839 while (yyssp
!= yyss
)
1841 yydestruct ("Cleanup: popping",
1842 yystos
[*yyssp
], yyvsp
);
1847 YYSTACK_FREE (yyss
);
1850 if (yymsg
!= yymsgbuf
)
1851 YYSTACK_FREE (yymsg
);
1853 /* Make sure YYID is used. */
1854 return YYID (yyresult
);
1858 #line 250 "OSUnserializeXML.y"
1862 OSUnserializeerror(parser_state_t
* state
, const char *s
) /* Called by yyparse on errors */
1864 if (state
->errorString
) {
1865 char tempString
[128];
1866 snprintf(tempString
, 128, "OSUnserializeXML: %s near line %d\n", s
, state
->lineNumber
);
1867 *(state
->errorString
) = OSString::withCString(tempString
);
1873 #define TAG_MAX_LENGTH 32
1874 #define TAG_MAX_ATTRIBUTES 32
1879 #define TAG_IGNORE 4
1881 #define currentChar() (state->parseBuffer[state->parseBufferIndex])
1882 #define nextChar() (state->parseBuffer[++state->parseBufferIndex])
1883 #define prevChar() (state->parseBuffer[state->parseBufferIndex - 1])
1885 #define isSpace(c) ((c) == ' ' || (c) == '\t')
1886 #define isAlpha(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z'))
1887 #define isDigit(c) ((c) >= '0' && (c) <= '9')
1888 #define isAlphaDigit(c) ((c) >= 'a' && (c) <= 'f')
1889 #define isHexDigit(c) (isDigit(c) || isAlphaDigit(c))
1890 #define isAlphaNumeric(c) (isAlpha(c) || isDigit(c) || ((c) == '-'))
1893 getTag(parser_state_t
*state
,
1894 char tag
[TAG_MAX_LENGTH
],
1895 int *attributeCount
,
1896 char attributes
[TAG_MAX_ATTRIBUTES
][TAG_MAX_LENGTH
],
1897 char values
[TAG_MAX_ATTRIBUTES
][TAG_MAX_LENGTH
] )
1900 int c
= currentChar();
1901 int tagType
= TAG_START
;
1903 *attributeCount
= 0;
1905 if (c
!= '<') return TAG_BAD
;
1906 c
= nextChar(); // skip '<'
1909 // <!TAG declarations >
1910 // <!-- comments -->
1913 bool isComment
= (c
== '-') && ((c
= nextChar()) != 0) && (c
== '-');
1914 if (!isComment
&& !isAlpha(c
)) return TAG_BAD
; // <!1, <!-A, <!eos
1916 while (c
&& (c
= nextChar()) != 0) {
1917 if (c
== '\n') state
->lineNumber
++;
1919 if (c
!= '-') continue;
1921 if (c
!= '-') continue;
1928 if (isComment
) break;
1935 // <? Processing Instructions ?>
1937 while ((c
= nextChar()) != 0) {
1938 if (c
== '\n') state
->lineNumber
++;
1939 if (c
!= '?') continue;
1953 c
= nextChar(); // skip '/'
1956 if (!isAlpha(c
)) return TAG_BAD
;
1958 /* find end of tag while copying it */
1959 while (isAlphaNumeric(c
)) {
1962 if (length
>= (TAG_MAX_LENGTH
- 1)) return TAG_BAD
;
1967 // printf("tag %s, type %d\n", tag, tagType);
1969 // look for attributes of the form attribute = "value" ...
1970 while ((c
!= '>') && (c
!= '/')) {
1971 while (isSpace(c
)) c
= nextChar();
1974 while (isAlphaNumeric(c
)) {
1975 attributes
[*attributeCount
][length
++] = c
;
1976 if (length
>= (TAG_MAX_LENGTH
- 1)) return TAG_BAD
;
1979 attributes
[*attributeCount
][length
] = 0;
1981 while (isSpace(c
)) c
= nextChar();
1983 if (c
!= '=') return TAG_BAD
;
1986 while (isSpace(c
)) c
= nextChar();
1988 if (c
!= '"') return TAG_BAD
;
1992 values
[*attributeCount
][length
++] = c
;
1993 if (length
>= (TAG_MAX_LENGTH
- 1)) return TAG_BAD
;
1996 values
[*attributeCount
][length
] = 0;
1998 c
= nextChar(); // skip closing quote
2000 // printf(" attribute '%s' = '%s', nextchar = '%c'\n",
2001 // attributes[*attributeCount], values[*attributeCount], c);
2003 (*attributeCount
)++;
2004 if (*attributeCount
>= TAG_MAX_ATTRIBUTES
) return TAG_BAD
;
2008 c
= nextChar(); // skip '/'
2009 tagType
= TAG_EMPTY
;
2011 if (c
!= '>') return TAG_BAD
;
2012 c
= nextChar(); // skip '>'
2018 getString(parser_state_t
*state
)
2020 int c
= currentChar();
2021 int start
, length
, i
, j
;
2024 start
= state
->parseBufferIndex
;
2025 /* find end of string */
2028 if (c
== '\n') state
->lineNumber
++;
2035 if (c
!= '<') return 0;
2037 length
= state
->parseBufferIndex
- start
;
2039 /* copy to null terminated buffer */
2040 tempString
= (char *)malloc(length
+ 1);
2041 if (tempString
== 0) {
2042 printf("OSUnserializeXML: can't alloc temp memory\n");
2046 // copy out string in tempString
2047 // "&" -> '&', "<" -> '<', ">" -> '>'
2050 while (i
< length
) {
2051 c
= state
->parseBuffer
[start
+ i
++];
2053 tempString
[j
++] = c
;
2055 if ((i
+3) > length
) goto error
;
2056 c
= state
->parseBuffer
[start
+ i
++];
2058 if (state
->parseBuffer
[start
+ i
++] != 't') goto error
;
2059 if (state
->parseBuffer
[start
+ i
++] != ';') goto error
;
2060 tempString
[j
++] = '<';
2064 if (state
->parseBuffer
[start
+ i
++] != 't') goto error
;
2065 if (state
->parseBuffer
[start
+ i
++] != ';') goto error
;
2066 tempString
[j
++] = '>';
2069 if ((i
+3) > length
) goto error
;
2071 if (state
->parseBuffer
[start
+ i
++] != 'm') goto error
;
2072 if (state
->parseBuffer
[start
+ i
++] != 'p') goto error
;
2073 if (state
->parseBuffer
[start
+ i
++] != ';') goto error
;
2074 tempString
[j
++] = '&';
2082 // printf("string %s\n", tempString);
2087 if (tempString
) free(tempString
);
2092 getNumber(parser_state_t
*state
)
2094 unsigned long long n
= 0;
2096 bool negate
= false;
2097 int c
= currentChar();
2112 n
= (n
* base
+ c
- '0');
2116 n
= (unsigned long long)((long long)n
* (long long)-1);
2119 while(isHexDigit(c
)) {
2121 n
= (n
* base
+ c
- '0');
2123 n
= (n
* base
+ 0xa + c
- 'a');
2128 // printf("number 0x%x\n", (unsigned long)n);
2132 // taken from CFXMLParsing/CFPropertyList.c
2134 static const signed char __CFPLDataDecodeTable
[128] = {
2135 /* 000 */ -1, -1, -1, -1, -1, -1, -1, -1,
2136 /* 010 */ -1, -1, -1, -1, -1, -1, -1, -1,
2137 /* 020 */ -1, -1, -1, -1, -1, -1, -1, -1,
2138 /* 030 */ -1, -1, -1, -1, -1, -1, -1, -1,
2139 /* ' ' */ -1, -1, -1, -1, -1, -1, -1, -1,
2140 /* '(' */ -1, -1, -1, 62, -1, -1, -1, 63,
2141 /* '0' */ 52, 53, 54, 55, 56, 57, 58, 59,
2142 /* '8' */ 60, 61, -1, -1, -1, 0, -1, -1,
2143 /* '@' */ -1, 0, 1, 2, 3, 4, 5, 6,
2144 /* 'H' */ 7, 8, 9, 10, 11, 12, 13, 14,
2145 /* 'P' */ 15, 16, 17, 18, 19, 20, 21, 22,
2146 /* 'X' */ 23, 24, 25, -1, -1, -1, -1, -1,
2147 /* '`' */ -1, 26, 27, 28, 29, 30, 31, 32,
2148 /* 'h' */ 33, 34, 35, 36, 37, 38, 39, 40,
2149 /* 'p' */ 41, 42, 43, 44, 45, 46, 47, 48,
2150 /* 'x' */ 49, 50, 51, -1, -1, -1, -1, -1
2153 #define DATA_ALLOC_SIZE 4096
2156 getCFEncodedData(parser_state_t
*state
, unsigned int *size
)
2158 int numeq
= 0, acc
= 0, cntr
= 0;
2159 int tmpbufpos
= 0, tmpbuflen
= 0;
2160 unsigned char *tmpbuf
= (unsigned char *)malloc(DATA_ALLOC_SIZE
);
2162 int c
= currentChar();
2171 if (c
== '=') numeq
++; else numeq
= 0;
2172 if (c
== '\n') state
->lineNumber
++;
2173 if (__CFPLDataDecodeTable
[c
] < 0) {
2179 acc
+= __CFPLDataDecodeTable
[c
];
2180 if (0 == (cntr
& 0x3)) {
2181 if (tmpbuflen
<= tmpbufpos
+ 2) {
2182 tmpbuflen
+= DATA_ALLOC_SIZE
;
2183 tmpbuf
= (unsigned char *)realloc(tmpbuf
, tmpbuflen
);
2185 tmpbuf
[tmpbufpos
++] = (acc
>> 16) & 0xff;
2187 tmpbuf
[tmpbufpos
++] = (acc
>> 8) & 0xff;
2189 tmpbuf
[tmpbufpos
++] = acc
& 0xff;
2202 getHexData(parser_state_t
*state
, unsigned int *size
)
2205 unsigned char *d
, *start
, *lastStart
;
2207 start
= lastStart
= d
= (unsigned char *)malloc(DATA_ALLOC_SIZE
);
2212 if (isSpace(c
)) while ((c
= nextChar()) != 0 && isSpace(c
)) {};
2214 state
->lineNumber
++;
2221 *d
= (c
- '0') << 4;
2222 } else if (isAlphaDigit(c
)) {
2223 *d
= (0xa + (c
- 'a')) << 4;
2232 } else if (isAlphaDigit(c
)) {
2233 *d
|= 0xa + (c
- 'a');
2239 if ((d
- lastStart
) >= DATA_ALLOC_SIZE
) {
2240 int oldsize
= d
- start
;
2241 start
= (unsigned char *)realloc(start
, oldsize
+ DATA_ALLOC_SIZE
);
2242 d
= lastStart
= start
+ oldsize
;
2258 yylex(YYSTYPE
*lvalp
, parser_state_t
*state
)
2262 char tag
[TAG_MAX_LENGTH
];
2264 char attributes
[TAG_MAX_ATTRIBUTES
][TAG_MAX_LENGTH
];
2265 char values
[TAG_MAX_ATTRIBUTES
][TAG_MAX_LENGTH
];
2271 /* skip white space */
2272 if (isSpace(c
)) while ((c
= nextChar()) != 0 && isSpace(c
)) {};
2274 /* keep track of line number, don't return \n's */
2276 STATE
->lineNumber
++;
2281 // end of the buffer?
2284 tagType
= getTag(STATE
, tag
, &attributeCount
, attributes
, values
);
2285 if (tagType
== TAG_BAD
) return SYNTAX_ERROR
;
2286 if (tagType
== TAG_IGNORE
) goto top
;
2288 // handle allocation and check for "ID" and "IDREF" tags up front
2289 *lvalp
= object
= newObject(STATE
);
2291 for (i
=0; i
< attributeCount
; i
++) {
2292 if (attributes
[i
][0] == 'I' && attributes
[i
][1] == 'D') {
2293 // check for idref's, note: we ignore the tag, for
2294 // this to work correctly, all idrefs must be unique
2295 // across the whole serialization
2296 if (attributes
[i
][2] == 'R' && attributes
[i
][3] == 'E' &&
2297 attributes
[i
][4] == 'F' && !attributes
[i
][5]) {
2298 if (tagType
!= TAG_EMPTY
) return SYNTAX_ERROR
;
2299 object
->idref
= strtol(values
[i
], NULL
, 0);
2303 if (!attributes
[i
][2]) {
2304 object
->idref
= strtol(values
[i
], NULL
, 0);
2306 return SYNTAX_ERROR
;
2313 if (!strcmp(tag
, "array")) {
2314 if (tagType
== TAG_EMPTY
) {
2315 object
->elements
= NULL
;
2318 return (tagType
== TAG_START
) ? '(' : ')';
2322 if (!strcmp(tag
, "dict")) {
2323 if (tagType
== TAG_EMPTY
) {
2324 object
->elements
= NULL
;
2327 return (tagType
== TAG_START
) ? '{' : '}';
2329 if (!strcmp(tag
, "data")) {
2331 if (tagType
== TAG_EMPTY
) {
2332 object
->data
= NULL
;
2337 bool isHexFormat
= false;
2338 for (i
=0; i
< attributeCount
; i
++) {
2339 if (!strcmp(attributes
[i
], "format") && !strcmp(values
[i
], "hex")) {
2344 // CF encoded is the default form
2346 object
->data
= getHexData(STATE
, &size
);
2348 object
->data
= getCFEncodedData(STATE
, &size
);
2350 object
->size
= size
;
2351 if ((getTag(STATE
, tag
, &attributeCount
, attributes
, values
) != TAG_END
) || strcmp(tag
, "data")) {
2352 return SYNTAX_ERROR
;
2358 if (!strcmp(tag
, "false")) {
2359 if (tagType
== TAG_EMPTY
) {
2366 if (!strcmp(tag
, "integer")) {
2367 object
->size
= 64; // default
2368 for (i
=0; i
< attributeCount
; i
++) {
2369 if (!strcmp(attributes
[i
], "size")) {
2370 object
->size
= strtoul(values
[i
], NULL
, 0);
2373 if (tagType
== TAG_EMPTY
) {
2377 object
->number
= getNumber(STATE
);
2378 if ((getTag(STATE
, tag
, &attributeCount
, attributes
, values
) != TAG_END
) || strcmp(tag
, "integer")) {
2379 return SYNTAX_ERROR
;
2385 if (!strcmp(tag
, "key")) {
2386 if (tagType
== TAG_EMPTY
) return SYNTAX_ERROR
;
2387 object
->string
= getString(STATE
);
2388 if (!object
->string
) {
2389 return SYNTAX_ERROR
;
2391 if ((getTag(STATE
, tag
, &attributeCount
, attributes
, values
) != TAG_END
)
2392 || strcmp(tag
, "key")) {
2393 return SYNTAX_ERROR
;
2399 if (!strcmp(tag
, "plist")) {
2400 freeObject(STATE
, object
);
2405 if (!strcmp(tag
, "string")) {
2406 if (tagType
== TAG_EMPTY
) {
2407 object
->string
= (char *)malloc(1);
2408 object
->string
[0] = 0;
2411 object
->string
= getString(STATE
);
2412 if (!object
->string
) {
2413 return SYNTAX_ERROR
;
2415 if ((getTag(STATE
, tag
, &attributeCount
, attributes
, values
) != TAG_END
)
2416 || strcmp(tag
, "string")) {
2417 return SYNTAX_ERROR
;
2421 if (!strcmp(tag
, "set")) {
2422 if (tagType
== TAG_EMPTY
) {
2423 object
->elements
= NULL
;
2426 if (tagType
== TAG_START
) {
2434 if (!strcmp(tag
, "true")) {
2435 if (tagType
== TAG_EMPTY
) {
2443 return SYNTAX_ERROR
;
2446 // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2447 // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2448 // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2450 // "java" like allocation, if this code hits a syntax error in the
2451 // the middle of the parsed string we just bail with pointers hanging
2452 // all over place, this code helps keeps it all together
2454 //static int object_count = 0;
2457 newObject(parser_state_t
*state
)
2461 if (state
->freeObjects
) {
2462 o
= state
->freeObjects
;
2463 state
->freeObjects
= state
->freeObjects
->next
;
2465 o
= (object_t
*)malloc(sizeof(object_t
));
2467 bzero(o
, sizeof(object_t
));
2468 o
->free
= state
->objects
;
2476 freeObject(parser_state_t
* state
, object_t
*o
)
2478 o
->next
= state
->freeObjects
;
2479 state
->freeObjects
= o
;
2483 cleanupObjects(parser_state_t
*state
)
2485 object_t
*t
, *o
= state
->objects
;
2489 // printf("OSUnserializeXML: releasing object o=%x object=%x\n", (int)o, (int)o->object);
2490 o
->object
->release();
2493 // printf("OSUnserializeXML: freeing object o=%x data=%x\n", (int)o, (int)o->data);
2497 // printf("OSUnserializeXML: releasing object o=%x key=%x\n", (int)o, (int)o->key);
2501 // printf("OSUnserializeXML: freeing object o=%x string=%x\n", (int)o, (int)o->string);
2510 // printf("object_count = %d\n", object_count);
2513 // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2514 // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2515 // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2518 rememberObject(parser_state_t
*state
, int tag
, OSObject
*o
)
2521 snprintf(key
, 16, "%u", tag
);
2523 // printf("remember key %s\n", key);
2525 state
->tags
->setObject(key
, o
);
2529 retrieveObject(parser_state_t
*state
, int tag
)
2534 snprintf(key
, 16, "%u", tag
);
2536 // printf("retrieve key '%s'\n", key);
2538 ref
= state
->tags
->getObject(key
);
2541 o
= newObject(state
);
2546 // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2547 // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2548 // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2551 buildDictionary(parser_state_t
*state
, object_t
* header
)
2557 // get count and reverse order
2558 o
= header
->elements
;
2559 header
->elements
= 0;
2565 t
->next
= header
->elements
;
2566 header
->elements
= t
;
2569 dict
= OSDictionary::withCapacity(count
);
2570 if (header
->idref
>= 0) rememberObject(state
, header
->idref
, dict
);
2572 o
= header
->elements
;
2574 dict
->setObject(o
->key
, o
->object
);
2577 o
->object
->release();
2583 freeObject(state
, t
);
2591 buildArray(parser_state_t
*state
, object_t
* header
)
2597 // get count and reverse order
2598 o
= header
->elements
;
2599 header
->elements
= 0;
2605 t
->next
= header
->elements
;
2606 header
->elements
= t
;
2609 array
= OSArray::withCapacity(count
);
2610 if (header
->idref
>= 0) rememberObject(state
, header
->idref
, array
);
2612 o
= header
->elements
;
2614 array
->setObject(o
->object
);
2616 o
->object
->release();
2621 freeObject(state
, t
);
2629 buildSet(parser_state_t
*state
, object_t
*header
)
2631 object_t
*o
= buildArray(state
, header
);
2633 OSArray
*array
= (OSArray
*)o
->object
;
2634 OSSet
*set
= OSSet::withArray(array
, array
->getCapacity());
2636 // write over the reference created in buildArray
2637 if (header
->idref
>= 0) rememberObject(state
, header
->idref
, set
);
2645 buildString(parser_state_t
*state
, object_t
*o
)
2649 string
= OSString::withCString(o
->string
);
2650 if (o
->idref
>= 0) rememberObject(state
, o
->idref
, string
);
2660 buildData(parser_state_t
*state
, object_t
*o
)
2665 data
= OSData::withBytes(o
->data
, o
->size
);
2667 data
= OSData::withCapacity(0);
2669 if (o
->idref
>= 0) rememberObject(state
, o
->idref
, data
);
2671 if (o
->size
) free(o
->data
);
2678 buildNumber(parser_state_t
*state
, object_t
*o
)
2680 OSNumber
*number
= OSNumber::withNumber(o
->number
, o
->size
);
2682 if (o
->idref
>= 0) rememberObject(state
, o
->idref
, number
);
2689 buildBoolean(parser_state_t
*state __unused
, object_t
*o
)
2691 o
->object
= ((o
->number
== 0) ? kOSBooleanFalse
: kOSBooleanTrue
);
2692 o
->object
->retain();
2697 OSUnserializeXML(const char *buffer
, OSString
**errorString
)
2700 parser_state_t
*state
= (parser_state_t
*)malloc(sizeof(parser_state_t
));
2702 if ((!state
) || (!buffer
)) return 0;
2705 if (errorString
) *errorString
= NULL
;
2707 state
->parseBuffer
= buffer
;
2708 state
->parseBufferIndex
= 0;
2709 state
->lineNumber
= 1;
2711 state
->freeObjects
= 0;
2712 state
->tags
= OSDictionary::withCapacity(128);
2713 state
->errorString
= errorString
;
2714 state
->parsedObject
= 0;
2716 (void)yyparse((void *)state
);
2718 object
= state
->parsedObject
;
2720 cleanupObjects(state
);
2721 state
->tags
->release();
2733 // DO NOT EDIT OSUnserializeXML.cpp!