2 * Copyright (c) 1999-2007 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
, char *s
);
200 static int yylex(YYSTYPE
*lvalp
, parser_state_t
*state
);
201 static int yyparse(void * state
);
203 static object_t
*newObject(parser_state_t
*state
);
204 static void freeObject(parser_state_t
*state
, object_t
*o
);
205 static void rememberObject(parser_state_t
*state
, int tag
, OSObject
*o
);
206 static object_t
*retrieveObject(parser_state_t
*state
, int tag
);
207 static void cleanupObjects(parser_state_t
*state
);
209 static object_t
*buildDictionary(parser_state_t
*state
, object_t
*o
);
210 static object_t
*buildArray(parser_state_t
*state
, object_t
*o
);
211 static object_t
*buildSet(parser_state_t
*state
, object_t
*o
);
212 static object_t
*buildString(parser_state_t
*state
, object_t
*o
);
213 static object_t
*buildData(parser_state_t
*state
, object_t
*o
);
214 static object_t
*buildNumber(parser_state_t
*state
, object_t
*o
);
215 static object_t
*buildBoolean(parser_state_t
*state
, object_t
*o
);
218 extern void *kern_os_malloc(size_t size
);
219 extern void *kern_os_realloc(void * addr
, size_t size
);
220 extern void kern_os_free(void * addr
);
222 //XXX shouldn't have to define these
223 extern long strtol(const char *, char **, int);
224 extern unsigned long strtoul(const char *, char **, int);
228 #define malloc(s) kern_os_malloc(s)
229 #define realloc(a, s) kern_os_realloc(a, s)
230 #define free(a) kern_os_free((void *)a)
234 /* Enabling traces. */
239 /* Enabling verbose error messages. */
240 #ifdef YYERROR_VERBOSE
241 # undef YYERROR_VERBOSE
242 # define YYERROR_VERBOSE 1
244 # define YYERROR_VERBOSE 0
247 /* Enabling the token table. */
248 #ifndef YYTOKEN_TABLE
249 # define YYTOKEN_TABLE 0
252 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
254 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
255 # define YYSTYPE_IS_DECLARED 1
256 # define YYSTYPE_IS_TRIVIAL 1
261 /* Copy the second part of user declarations. */
264 /* Line 216 of yacc.c. */
265 #line 216 "OSUnserializeXML.tab.c"
272 typedef YYTYPE_UINT8 yytype_uint8
;
274 typedef unsigned char yytype_uint8
;
278 typedef YYTYPE_INT8 yytype_int8
;
279 #elif (defined __STDC__ || defined __C99__FUNC__ \
280 || defined __cplusplus || defined _MSC_VER)
281 typedef signed char yytype_int8
;
283 typedef short int yytype_int8
;
287 typedef YYTYPE_UINT16 yytype_uint16
;
289 typedef unsigned short int yytype_uint16
;
293 typedef YYTYPE_INT16 yytype_int16
;
295 typedef short int yytype_int16
;
299 # ifdef __SIZE_TYPE__
300 # define YYSIZE_T __SIZE_TYPE__
301 # elif defined size_t
302 # define YYSIZE_T size_t
303 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
304 || defined __cplusplus || defined _MSC_VER)
305 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
306 # define YYSIZE_T size_t
308 # define YYSIZE_T unsigned int
312 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
317 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
318 # define YY_(msgid) dgettext ("bison-runtime", msgid)
322 # define YY_(msgid) msgid
326 /* Suppress unused-variable warnings by "using" E. */
327 #if ! defined lint || defined __GNUC__
328 # define YYUSE(e) ((void) (e))
330 # define YYUSE(e) /* empty */
333 /* Identity function, used to suppress warnings about constant conditions. */
337 #if (defined __STDC__ || defined __C99__FUNC__ \
338 || defined __cplusplus || defined _MSC_VER)
351 #if ! defined yyoverflow || YYERROR_VERBOSE
353 /* The parser invokes alloca or malloc; define the necessary symbols. */
355 # ifdef YYSTACK_USE_ALLOCA
356 # if YYSTACK_USE_ALLOCA
358 # define YYSTACK_ALLOC __builtin_alloca
359 # elif defined __BUILTIN_VA_ARG_INCR
360 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
362 # define YYSTACK_ALLOC __alloca
363 # elif defined _MSC_VER
364 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
365 # define alloca _alloca
367 # define YYSTACK_ALLOC alloca
368 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
369 || defined __cplusplus || defined _MSC_VER)
370 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
379 # ifdef YYSTACK_ALLOC
380 /* Pacify GCC's `empty if-body' warning. */
381 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
382 # ifndef YYSTACK_ALLOC_MAXIMUM
383 /* The OS might guarantee only one guard page at the bottom of the stack,
384 and a page size can be as small as 4096 bytes. So we cannot safely
385 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
386 to allow for a few compiler-allocated temporary stack slots. */
387 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
390 # define YYSTACK_ALLOC YYMALLOC
391 # define YYSTACK_FREE YYFREE
392 # ifndef YYSTACK_ALLOC_MAXIMUM
393 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
395 # if (defined __cplusplus && ! defined _STDLIB_H \
396 && ! ((defined YYMALLOC || defined malloc) \
397 && (defined YYFREE || defined free)))
398 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
404 # define YYMALLOC malloc
405 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
406 || defined __cplusplus || defined _MSC_VER)
407 void *malloc (YYSIZE_T
); /* INFRINGES ON USER NAME SPACE */
412 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
413 || defined __cplusplus || defined _MSC_VER)
414 void free (void *); /* INFRINGES ON USER NAME SPACE */
418 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
421 #if (! defined yyoverflow \
422 && (! defined __cplusplus \
423 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
425 /* A type that is properly aligned for any stack member. */
432 /* The size of the maximum gap between one aligned stack and the next. */
433 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
435 /* The size of an array large to enough to hold all stacks, each with
437 # define YYSTACK_BYTES(N) \
438 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
439 + YYSTACK_GAP_MAXIMUM)
441 /* Copy COUNT objects from FROM to TO. The source and destination do
444 # if defined __GNUC__ && 1 < __GNUC__
445 # define YYCOPY(To, From, Count) \
446 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
448 # define YYCOPY(To, From, Count) \
452 for (yyi = 0; yyi < (Count); yyi++) \
453 (To)[yyi] = (From)[yyi]; \
459 /* Relocate STACK from its old location to the new one. The
460 local variables YYSIZE and YYSTACKSIZE give the old and new number of
461 elements in the stack, and YYPTR gives the new location of the
462 stack. Advance YYPTR to a properly aligned location for the next
464 # define YYSTACK_RELOCATE(Stack) \
467 YYSIZE_T yynewbytes; \
468 YYCOPY (&yyptr->Stack, Stack, yysize); \
469 Stack = &yyptr->Stack; \
470 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
471 yyptr += yynewbytes / sizeof (*yyptr); \
477 /* YYFINAL -- State number of the termination state. */
479 /* YYLAST -- Last index in YYTABLE. */
482 /* YYNTOKENS -- Number of terminals. */
484 /* YYNNTS -- Number of nonterminals. */
486 /* YYNRULES -- Number of rules. */
488 /* YYNRULES -- Number of states. */
491 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
493 #define YYMAXUTOK 267
495 #define YYTRANSLATE(YYX) \
496 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
498 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
499 static const yytype_uint8 yytranslate
[] =
501 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
502 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
503 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
504 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
505 15, 16, 2, 2, 2, 2, 2, 2, 2, 2,
506 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
507 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
508 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
509 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
510 2, 17, 2, 18, 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, 13, 2, 14, 2, 2, 2, 2,
514 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
515 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
516 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
517 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
518 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
519 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
520 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
521 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
522 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
523 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
524 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
525 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
526 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
527 5, 6, 7, 8, 9, 10, 11, 12
531 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
533 static const yytype_uint8 yyprhs
[] =
535 0, 0, 3, 4, 6, 8, 10, 12, 14, 16,
536 18, 20, 22, 24, 27, 31, 33, 35, 38, 41,
537 43, 46, 50, 52, 55, 59, 61, 63, 66, 68,
541 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
542 static const yytype_int8 yyrhs
[] =
544 20, 0, -1, -1, 21, -1, 12, -1, 22, -1,
545 26, -1, 27, -1, 33, -1, 30, -1, 32, -1,
546 29, -1, 31, -1, 13, 14, -1, 13, 23, 14,
547 -1, 6, -1, 24, -1, 23, 24, -1, 25, 21,
548 -1, 8, -1, 15, 16, -1, 15, 28, 16, -1,
549 3, -1, 17, 18, -1, 17, 28, 18, -1, 10,
550 -1, 21, -1, 28, 21, -1, 4, -1, 5, -1,
554 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
555 static const yytype_uint8 yyrline
[] =
557 0, 150, 150, 153, 158, 163, 164, 165, 166, 167,
558 168, 169, 170, 183, 186, 189, 192, 193, 198, 207,
559 212, 215, 218, 221, 224, 227, 230, 233, 240, 243,
564 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
565 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
566 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
567 static const char *const yytname
[] =
569 "$end", "error", "$undefined", "ARRAY", "BOOLEAN", "DATA", "DICTIONARY",
570 "IDREF", "KEY", "NUMBER", "SET", "STRING", "SYNTAX_ERROR", "'{'", "'}'",
571 "'('", "')'", "'['", "']'", "$accept", "input", "object", "dict",
572 "pairs", "pair", "key", "array", "set", "elements", "boolean", "data",
573 "idref", "number", "string", 0
578 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
580 static const yytype_uint16 yytoknum
[] =
582 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
583 265, 266, 267, 123, 125, 40, 41, 91, 93
587 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
588 static const yytype_uint8 yyr1
[] =
590 0, 19, 20, 20, 20, 21, 21, 21, 21, 21,
591 21, 21, 21, 22, 22, 22, 23, 23, 24, 25,
592 26, 26, 26, 27, 27, 27, 28, 28, 29, 30,
596 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
597 static const yytype_uint8 yyr2
[] =
599 0, 2, 0, 1, 1, 1, 1, 1, 1, 1,
600 1, 1, 1, 2, 3, 1, 1, 2, 2, 1,
601 2, 3, 1, 2, 3, 1, 1, 2, 1, 1,
605 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
606 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
607 means the default is an error. */
608 static const yytype_uint8 yydefact
[] =
610 2, 22, 28, 29, 15, 30, 31, 25, 32, 4,
611 0, 0, 0, 0, 3, 5, 6, 7, 11, 9,
612 12, 10, 8, 19, 13, 0, 16, 0, 20, 26,
613 0, 23, 0, 1, 14, 17, 18, 21, 27, 24
616 /* YYDEFGOTO[NTERM-NUM]. */
617 static const yytype_int8 yydefgoto
[] =
619 -1, 13, 29, 15, 25, 26, 27, 16, 17, 30,
623 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
625 #define YYPACT_NINF -20
626 static const yytype_int8 yypact
[] =
628 46, -20, -20, -20, -20, -20, -20, -20, -20, -20,
629 4, 61, -2, 10, -20, -20, -20, -20, -20, -20,
630 -20, -20, -20, -20, -20, 6, -20, 91, -20, -20,
631 76, -20, 30, -20, -20, -20, -20, -20, -20, -20
634 /* YYPGOTO[NTERM-NUM]. */
635 static const yytype_int8 yypgoto
[] =
637 -20, -20, 0, -20, -20, -19, -20, -20, -20, 5,
638 -20, -20, -20, -20, -20
641 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
642 positive, shift that token. If negative, reduce the rule which
643 number is the opposite. If zero, do what YYDEFACT says.
644 If YYTABLE_NINF, syntax error. */
645 #define YYTABLE_NINF -1
646 static const yytype_uint8 yytable
[] =
648 14, 1, 2, 3, 4, 5, 35, 6, 7, 8,
649 33, 10, 23, 11, 23, 12, 31, 32, 24, 0,
650 34, 0, 0, 0, 0, 0, 0, 36, 0, 0,
651 38, 0, 38, 1, 2, 3, 4, 5, 0, 6,
652 7, 8, 0, 10, 0, 11, 0, 12, 39, 1,
653 2, 3, 4, 5, 0, 6, 7, 8, 9, 10,
654 0, 11, 0, 12, 1, 2, 3, 4, 5, 0,
655 6, 7, 8, 0, 10, 0, 11, 28, 12, 1,
656 2, 3, 4, 5, 0, 6, 7, 8, 0, 10,
657 0, 11, 37, 12, 1, 2, 3, 4, 5, 0,
658 6, 7, 8, 0, 10, 0, 11, 0, 12
661 static const yytype_int8 yycheck
[] =
663 0, 3, 4, 5, 6, 7, 25, 9, 10, 11,
664 0, 13, 8, 15, 8, 17, 18, 12, 14, -1,
665 14, -1, -1, -1, -1, -1, -1, 27, -1, -1,
666 30, -1, 32, 3, 4, 5, 6, 7, -1, 9,
667 10, 11, -1, 13, -1, 15, -1, 17, 18, 3,
668 4, 5, 6, 7, -1, 9, 10, 11, 12, 13,
669 -1, 15, -1, 17, 3, 4, 5, 6, 7, -1,
670 9, 10, 11, -1, 13, -1, 15, 16, 17, 3,
671 4, 5, 6, 7, -1, 9, 10, 11, -1, 13,
672 -1, 15, 16, 17, 3, 4, 5, 6, 7, -1,
673 9, 10, 11, -1, 13, -1, 15, -1, 17
676 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
677 symbol of state STATE-NUM. */
678 static const yytype_uint8 yystos
[] =
680 0, 3, 4, 5, 6, 7, 9, 10, 11, 12,
681 13, 15, 17, 20, 21, 22, 26, 27, 29, 30,
682 31, 32, 33, 8, 14, 23, 24, 25, 16, 21,
683 28, 18, 28, 0, 14, 24, 21, 16, 21, 18
686 #define yyerrok (yyerrstatus = 0)
687 #define yyclearin (yychar = YYEMPTY)
691 #define YYACCEPT goto yyacceptlab
692 #define YYABORT goto yyabortlab
693 #define YYERROR goto yyerrorlab
696 /* Like YYERROR except do call yyerror. This remains here temporarily
697 to ease the transition to the new meaning of YYERROR, for GCC.
698 Once GCC version 2 has supplanted version 1, this can go. */
700 #define YYFAIL goto yyerrlab
702 #define YYRECOVERING() (!!yyerrstatus)
704 #define YYBACKUP(Token, Value) \
706 if (yychar == YYEMPTY && yylen == 1) \
710 yytoken = YYTRANSLATE (yychar); \
716 yyerror (YY_("syntax error: cannot back up")); \
723 #define YYERRCODE 256
726 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
727 If N is 0, then set CURRENT to the empty location which ends
728 the previous symbol: RHS[0] (always defined). */
730 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
731 #ifndef YYLLOC_DEFAULT
732 # define YYLLOC_DEFAULT(Current, Rhs, N) \
736 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
737 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
738 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
739 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
743 (Current).first_line = (Current).last_line = \
744 YYRHSLOC (Rhs, 0).last_line; \
745 (Current).first_column = (Current).last_column = \
746 YYRHSLOC (Rhs, 0).last_column; \
752 /* YY_LOCATION_PRINT -- Print the location on the stream.
753 This macro was not mandated originally: define only if we know
754 we won't break user code: when these are the locations we know. */
756 #ifndef YY_LOCATION_PRINT
757 # if YYLTYPE_IS_TRIVIAL
758 # define YY_LOCATION_PRINT(File, Loc) \
759 fprintf (File, "%d.%d-%d.%d", \
760 (Loc).first_line, (Loc).first_column, \
761 (Loc).last_line, (Loc).last_column)
763 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
768 /* YYLEX -- calling `yylex' with the right arguments. */
771 # define YYLEX yylex (&yylval, YYLEX_PARAM)
773 # define YYLEX yylex (&yylval)
776 /* Enable debugging if requested. */
780 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
781 # define YYFPRINTF fprintf
784 # define YYDPRINTF(Args) \
790 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
794 YYFPRINTF (stderr, "%s ", Title); \
795 yy_symbol_print (stderr, \
797 YYFPRINTF (stderr, "\n"); \
802 /*--------------------------------.
803 | Print this symbol on YYOUTPUT. |
804 `--------------------------------*/
807 #if (defined __STDC__ || defined __C99__FUNC__ \
808 || defined __cplusplus || defined _MSC_VER)
810 yy_symbol_value_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
)
813 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
)
816 YYSTYPE
const * const yyvaluep
;
822 if (yytype
< YYNTOKENS
)
823 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
835 /*--------------------------------.
836 | Print this symbol on YYOUTPUT. |
837 `--------------------------------*/
839 #if (defined __STDC__ || defined __C99__FUNC__ \
840 || defined __cplusplus || defined _MSC_VER)
842 yy_symbol_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
)
845 yy_symbol_print (yyoutput
, yytype
, yyvaluep
)
848 YYSTYPE
const * const yyvaluep
;
851 if (yytype
< YYNTOKENS
)
852 YYFPRINTF (yyoutput
, "token %s (", yytname
[yytype
]);
854 YYFPRINTF (yyoutput
, "nterm %s (", yytname
[yytype
]);
856 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
);
857 YYFPRINTF (yyoutput
, ")");
860 /*------------------------------------------------------------------.
861 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
863 `------------------------------------------------------------------*/
865 #if (defined __STDC__ || defined __C99__FUNC__ \
866 || defined __cplusplus || defined _MSC_VER)
868 yy_stack_print (yytype_int16
*bottom
, yytype_int16
*top
)
871 yy_stack_print (bottom
, top
)
872 yytype_int16
*bottom
;
876 YYFPRINTF (stderr
, "Stack now");
877 for (; bottom
<= top
; ++bottom
)
878 YYFPRINTF (stderr
, " %d", *bottom
);
879 YYFPRINTF (stderr
, "\n");
882 # define YY_STACK_PRINT(Bottom, Top) \
885 yy_stack_print ((Bottom), (Top)); \
889 /*------------------------------------------------.
890 | Report that the YYRULE is going to be reduced. |
891 `------------------------------------------------*/
893 #if (defined __STDC__ || defined __C99__FUNC__ \
894 || defined __cplusplus || defined _MSC_VER)
896 yy_reduce_print (YYSTYPE
*yyvsp
, int yyrule
)
899 yy_reduce_print (yyvsp
, yyrule
)
904 int yynrhs
= yyr2
[yyrule
];
906 unsigned long int yylno
= yyrline
[yyrule
];
907 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu):\n",
909 /* The symbols being reduced. */
910 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
912 fprintf (stderr
, " $%d = ", yyi
+ 1);
913 yy_symbol_print (stderr
, yyrhs
[yyprhs
[yyrule
] + yyi
],
914 &(yyvsp
[(yyi
+ 1) - (yynrhs
)])
916 fprintf (stderr
, "\n");
920 # define YY_REDUCE_PRINT(Rule) \
923 yy_reduce_print (yyvsp, Rule); \
926 /* Nonzero means print parse trace. It is left uninitialized so that
927 multiple parsers can coexist. */
930 # define YYDPRINTF(Args)
931 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
932 # define YY_STACK_PRINT(Bottom, Top)
933 # define YY_REDUCE_PRINT(Rule)
934 #endif /* !YYDEBUG */
937 /* YYINITDEPTH -- initial size of the parser's stacks. */
939 # define YYINITDEPTH 200
942 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
943 if the built-in stack extension method is used).
945 Do not make this value too large; the results are undefined if
946 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
947 evaluated with infinite-precision integer arithmetic. */
950 # define YYMAXDEPTH 10000
958 # if defined __GLIBC__ && defined _STRING_H
959 # define yystrlen strlen
961 /* Return the length of YYSTR. */
962 #if (defined __STDC__ || defined __C99__FUNC__ \
963 || defined __cplusplus || defined _MSC_VER)
965 yystrlen (const char *yystr
)
973 for (yylen
= 0; yystr
[yylen
]; yylen
++)
981 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
982 # define yystpcpy stpcpy
984 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
986 #if (defined __STDC__ || defined __C99__FUNC__ \
987 || defined __cplusplus || defined _MSC_VER)
989 yystpcpy (char *yydest
, const char *yysrc
)
992 yystpcpy (yydest
, yysrc
)
998 const char *yys
= yysrc
;
1000 while ((*yyd
++ = *yys
++) != '\0')
1009 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1010 quotes and backslashes, so that it's suitable for yyerror. The
1011 heuristic is that double-quoting is unnecessary unless the string
1012 contains an apostrophe, a comma, or backslash (other than
1013 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1014 null, do not copy; instead, return the length of what the result
1017 yytnamerr (char *yyres
, const char *yystr
)
1022 char const *yyp
= yystr
;
1029 goto do_not_strip_quotes
;
1033 goto do_not_strip_quotes
;
1046 do_not_strip_quotes
: ;
1050 return yystrlen (yystr
);
1052 return yystpcpy (yyres
, yystr
) - yyres
;
1056 /* Copy into YYRESULT an error message about the unexpected token
1057 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1058 including the terminating null byte. If YYRESULT is null, do not
1059 copy anything; just return the number of bytes that would be
1060 copied. As a special case, return 0 if an ordinary "syntax error"
1061 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1062 size calculation. */
1064 yysyntax_error (char *yyresult
, int yystate
, int yychar
)
1066 int yyn
= yypact
[yystate
];
1068 if (! (YYPACT_NINF
< yyn
&& yyn
<= YYLAST
))
1072 int yytype
= YYTRANSLATE (yychar
);
1073 YYSIZE_T yysize0
= yytnamerr (0, yytname
[yytype
]);
1074 YYSIZE_T yysize
= yysize0
;
1076 int yysize_overflow
= 0;
1077 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1078 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1082 /* This is so xgettext sees the translatable formats that are
1083 constructed on the fly. */
1084 YY_("syntax error, unexpected %s");
1085 YY_("syntax error, unexpected %s, expecting %s");
1086 YY_("syntax error, unexpected %s, expecting %s or %s");
1087 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1088 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1092 static char const yyunexpected
[] = "syntax error, unexpected %s";
1093 static char const yyexpecting
[] = ", expecting %s";
1094 static char const yyor
[] = " or %s";
1095 char yyformat
[sizeof yyunexpected
1096 + sizeof yyexpecting
- 1
1097 + ((YYERROR_VERBOSE_ARGS_MAXIMUM
- 2)
1098 * (sizeof yyor
- 1))];
1099 char const *yyprefix
= yyexpecting
;
1101 /* Start YYX at -YYN if negative to avoid negative indexes in
1103 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1105 /* Stay within bounds of both yycheck and yytname. */
1106 int yychecklim
= YYLAST
- yyn
+ 1;
1107 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1110 yyarg
[0] = yytname
[yytype
];
1111 yyfmt
= yystpcpy (yyformat
, yyunexpected
);
1113 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1114 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1116 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1120 yyformat
[sizeof yyunexpected
- 1] = '\0';
1123 yyarg
[yycount
++] = yytname
[yyx
];
1124 yysize1
= yysize
+ yytnamerr (0, yytname
[yyx
]);
1125 yysize_overflow
|= (yysize1
< yysize
);
1127 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
1131 yyf
= YY_(yyformat
);
1132 yysize1
= yysize
+ yystrlen (yyf
);
1133 yysize_overflow
|= (yysize1
< yysize
);
1136 if (yysize_overflow
)
1137 return YYSIZE_MAXIMUM
;
1141 /* Avoid sprintf, as that infringes on the user's name space.
1142 Don't have undefined behavior even if the translation
1143 produced a string with the wrong number of "%s"s. */
1144 char *yyp
= yyresult
;
1146 while ((*yyp
= *yyf
) != '\0')
1148 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
1150 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1163 #endif /* YYERROR_VERBOSE */
1166 /*-----------------------------------------------.
1167 | Release the memory associated to this symbol. |
1168 `-----------------------------------------------*/
1171 #if (defined __STDC__ || defined __C99__FUNC__ \
1172 || defined __cplusplus || defined _MSC_VER)
1174 yydestruct (const char *yymsg
, int yytype
, YYSTYPE
*yyvaluep
)
1177 yydestruct (yymsg
, yytype
, yyvaluep
)
1187 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
1198 /* Prevent warnings from -Wmissing-prototypes. */
1200 #ifdef YYPARSE_PARAM
1201 #if defined __STDC__ || defined __cplusplus
1202 int yyparse (void *YYPARSE_PARAM
);
1206 #else /* ! YYPARSE_PARAM */
1207 #if defined __STDC__ || defined __cplusplus
1212 #endif /* ! YYPARSE_PARAM */
1223 #ifdef YYPARSE_PARAM
1224 #if (defined __STDC__ || defined __C99__FUNC__ \
1225 || defined __cplusplus || defined _MSC_VER)
1227 yyparse (void *YYPARSE_PARAM
)
1230 yyparse (YYPARSE_PARAM
)
1231 void *YYPARSE_PARAM
;
1233 #else /* ! YYPARSE_PARAM */
1234 #if (defined __STDC__ || defined __C99__FUNC__ \
1235 || defined __cplusplus || defined _MSC_VER)
1245 /* The look-ahead symbol. */
1248 /* The semantic value of the look-ahead symbol. */
1251 /* Number of syntax errors so far. */
1257 /* Number of tokens to shift before error messages enabled. */
1259 /* Look-ahead token as an internal (translated) token number. */
1262 /* Buffer for error messages, and its allocated size. */
1264 char *yymsg
= yymsgbuf
;
1265 YYSIZE_T yymsg_alloc
= sizeof yymsgbuf
;
1268 /* Three stacks and their tools:
1269 `yyss': related to states,
1270 `yyvs': related to semantic values,
1271 `yyls': related to locations.
1273 Refer to the stacks thru separate pointers, to allow yyoverflow
1274 to reallocate them elsewhere. */
1276 /* The state stack. */
1277 yytype_int16 yyssa
[YYINITDEPTH
];
1278 yytype_int16
*yyss
= yyssa
;
1279 yytype_int16
*yyssp
;
1281 /* The semantic value stack. */
1282 YYSTYPE yyvsa
[YYINITDEPTH
];
1283 YYSTYPE
*yyvs
= yyvsa
;
1288 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1290 YYSIZE_T yystacksize
= YYINITDEPTH
;
1292 /* The variables used to return semantic value and location from the
1297 /* The number of symbols on the RHS of the reduced rule.
1298 Keep to zero when no symbol should be popped. */
1301 YYDPRINTF ((stderr
, "Starting parse\n"));
1306 yychar
= YYEMPTY
; /* Cause a token to be read. */
1308 /* Initialize stack pointers.
1309 Waste one element of value and location stack
1310 so that they stay on the same level as the state stack.
1311 The wasted elements are never initialized. */
1318 /*------------------------------------------------------------.
1319 | yynewstate -- Push a new state, which is found in yystate. |
1320 `------------------------------------------------------------*/
1322 /* In all cases, when you get here, the value and location stacks
1323 have just been pushed. So pushing a state here evens the stacks. */
1329 if (yyss
+ yystacksize
- 1 <= yyssp
)
1331 /* Get the current used size of the three stacks, in elements. */
1332 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1336 /* Give user a chance to reallocate the stack. Use copies of
1337 these so that the &'s don't force the real ones into
1339 YYSTYPE
*yyvs1
= yyvs
;
1340 yytype_int16
*yyss1
= yyss
;
1343 /* Each stack pointer address is followed by the size of the
1344 data in use in that stack, in bytes. This used to be a
1345 conditional around just the two extra args, but that might
1346 be undefined if yyoverflow is a macro. */
1347 yyoverflow (YY_("memory exhausted"),
1348 &yyss1
, yysize
* sizeof (*yyssp
),
1349 &yyvs1
, yysize
* sizeof (*yyvsp
),
1356 #else /* no yyoverflow */
1357 # ifndef YYSTACK_RELOCATE
1358 goto yyexhaustedlab
;
1360 /* Extend the stack our own way. */
1361 if (YYMAXDEPTH
<= yystacksize
)
1362 goto yyexhaustedlab
;
1364 if (YYMAXDEPTH
< yystacksize
)
1365 yystacksize
= YYMAXDEPTH
;
1368 yytype_int16
*yyss1
= yyss
;
1369 union yyalloc
*yyptr
=
1370 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1372 goto yyexhaustedlab
;
1373 YYSTACK_RELOCATE (yyss
);
1374 YYSTACK_RELOCATE (yyvs
);
1376 # undef YYSTACK_RELOCATE
1378 YYSTACK_FREE (yyss1
);
1381 #endif /* no yyoverflow */
1383 yyssp
= yyss
+ yysize
- 1;
1384 yyvsp
= yyvs
+ yysize
- 1;
1387 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1388 (unsigned long int) yystacksize
));
1390 if (yyss
+ yystacksize
- 1 <= yyssp
)
1394 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1403 /* Do appropriate processing given the current state. Read a
1404 look-ahead token if we need one and don't already have one. */
1406 /* First try to decide what to do without reference to look-ahead token. */
1407 yyn
= yypact
[yystate
];
1408 if (yyn
== YYPACT_NINF
)
1411 /* Not known => get a look-ahead token if don't already have one. */
1413 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1414 if (yychar
== YYEMPTY
)
1416 YYDPRINTF ((stderr
, "Reading a token: "));
1420 if (yychar
<= YYEOF
)
1422 yychar
= yytoken
= YYEOF
;
1423 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1427 yytoken
= YYTRANSLATE (yychar
);
1428 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1431 /* If the proper action on seeing token YYTOKEN is to reduce or to
1432 detect an error, take that action. */
1434 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1439 if (yyn
== 0 || yyn
== YYTABLE_NINF
)
1448 /* Count tokens shifted since error; after three, turn off error
1453 /* Shift the look-ahead token. */
1454 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1456 /* Discard the shifted token unless it is eof. */
1457 if (yychar
!= YYEOF
)
1466 /*-----------------------------------------------------------.
1467 | yydefault -- do the default action for the current state. |
1468 `-----------------------------------------------------------*/
1470 yyn
= yydefact
[yystate
];
1476 /*-----------------------------.
1477 | yyreduce -- Do a reduction. |
1478 `-----------------------------*/
1480 /* yyn is the number of a rule to reduce with. */
1483 /* If YYLEN is nonzero, implement the default value of the action:
1486 Otherwise, the following line sets YYVAL to garbage.
1487 This behavior is undocumented and Bison
1488 users should not rely upon it. Assigning to YYVAL
1489 unconditionally makes the parser a bit smaller, and it avoids a
1490 GCC warning that YYVAL may be used uninitialized. */
1491 yyval
= yyvsp
[1-yylen
];
1494 YY_REDUCE_PRINT (yyn
);
1498 #line 150 "OSUnserializeXML.y"
1499 { yyerror("unexpected end of buffer");
1505 #line 153 "OSUnserializeXML.y"
1506 { STATE
->parsedObject
= (yyvsp
[(1) - (1)])->object
;
1507 (yyvsp
[(1) - (1)])->object
= 0;
1508 freeObject(STATE
, (yyvsp
[(1) - (1)]));
1514 #line 158 "OSUnserializeXML.y"
1515 { yyerror("syntax error");
1521 #line 163 "OSUnserializeXML.y"
1522 { (yyval
) = buildDictionary(STATE
, (yyvsp
[(1) - (1)])); ;}
1526 #line 164 "OSUnserializeXML.y"
1527 { (yyval
) = buildArray(STATE
, (yyvsp
[(1) - (1)])); ;}
1531 #line 165 "OSUnserializeXML.y"
1532 { (yyval
) = buildSet(STATE
, (yyvsp
[(1) - (1)])); ;}
1536 #line 166 "OSUnserializeXML.y"
1537 { (yyval
) = buildString(STATE
, (yyvsp
[(1) - (1)])); ;}
1541 #line 167 "OSUnserializeXML.y"
1542 { (yyval
) = buildData(STATE
, (yyvsp
[(1) - (1)])); ;}
1546 #line 168 "OSUnserializeXML.y"
1547 { (yyval
) = buildNumber(STATE
, (yyvsp
[(1) - (1)])); ;}
1551 #line 169 "OSUnserializeXML.y"
1552 { (yyval
) = buildBoolean(STATE
, (yyvsp
[(1) - (1)])); ;}
1556 #line 170 "OSUnserializeXML.y"
1557 { (yyval
) = retrieveObject(STATE
, (yyvsp
[(1) - (1)])->idref
);
1559 (yyval
)->object
->retain();
1561 yyerror("forward reference detected");
1564 freeObject(STATE
, (yyvsp
[(1) - (1)]));
1569 #line 183 "OSUnserializeXML.y"
1570 { (yyval
) = (yyvsp
[(1) - (2)]);
1571 (yyval
)->elements
= NULL
;
1576 #line 186 "OSUnserializeXML.y"
1577 { (yyval
) = (yyvsp
[(1) - (3)]);
1578 (yyval
)->elements
= (yyvsp
[(2) - (3)]);
1583 #line 193 "OSUnserializeXML.y"
1584 { (yyval
) = (yyvsp
[(2) - (2)]);
1585 (yyval
)->next
= (yyvsp
[(1) - (2)]);
1590 #line 198 "OSUnserializeXML.y"
1591 { (yyval
) = (yyvsp
[(1) - (2)]);
1592 (yyval
)->key
= (OSString
*)(yyval
)->object
;
1593 (yyval
)->object
= (yyvsp
[(2) - (2)])->object
;
1594 (yyval
)->next
= NULL
;
1595 (yyvsp
[(2) - (2)])->object
= 0;
1596 freeObject(STATE
, (yyvsp
[(2) - (2)]));
1601 #line 207 "OSUnserializeXML.y"
1602 { (yyval
) = buildString(STATE
, (yyvsp
[(1) - (1)])); ;}
1606 #line 212 "OSUnserializeXML.y"
1607 { (yyval
) = (yyvsp
[(1) - (2)]);
1608 (yyval
)->elements
= NULL
;
1613 #line 215 "OSUnserializeXML.y"
1614 { (yyval
) = (yyvsp
[(1) - (3)]);
1615 (yyval
)->elements
= (yyvsp
[(2) - (3)]);
1620 #line 221 "OSUnserializeXML.y"
1621 { (yyval
) = (yyvsp
[(1) - (2)]);
1622 (yyval
)->elements
= NULL
;
1627 #line 224 "OSUnserializeXML.y"
1628 { (yyval
) = (yyvsp
[(1) - (3)]);
1629 (yyval
)->elements
= (yyvsp
[(2) - (3)]);
1634 #line 230 "OSUnserializeXML.y"
1635 { (yyval
) = (yyvsp
[(1) - (1)]);
1636 (yyval
)->next
= NULL
;
1641 #line 233 "OSUnserializeXML.y"
1642 { (yyval
) = (yyvsp
[(2) - (2)]);
1643 (yyval
)->next
= (yyvsp
[(1) - (2)]);
1648 /* Line 1267 of yacc.c. */
1649 #line 1600 "OSUnserializeXML.tab.c"
1652 YY_SYMBOL_PRINT ("-> $$ =", yyr1
[yyn
], &yyval
, &yyloc
);
1656 YY_STACK_PRINT (yyss
, yyssp
);
1661 /* Now `shift' the result of the reduction. Determine what state
1662 that goes to, based on the state we popped back to and the rule
1663 number reduced by. */
1667 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
1668 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1669 yystate
= yytable
[yystate
];
1671 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
1676 /*------------------------------------.
1677 | yyerrlab -- here on detecting error |
1678 `------------------------------------*/
1680 /* If not already recovering from an error, report this error. */
1684 #if ! YYERROR_VERBOSE
1685 yyerror (YY_("syntax error"));
1688 YYSIZE_T yysize
= yysyntax_error (0, yystate
, yychar
);
1689 if (yymsg_alloc
< yysize
&& yymsg_alloc
< YYSTACK_ALLOC_MAXIMUM
)
1691 YYSIZE_T yyalloc
= 2 * yysize
;
1692 if (! (yysize
<= yyalloc
&& yyalloc
<= YYSTACK_ALLOC_MAXIMUM
))
1693 yyalloc
= YYSTACK_ALLOC_MAXIMUM
;
1694 if (yymsg
!= yymsgbuf
)
1695 YYSTACK_FREE (yymsg
);
1696 yymsg
= (char *) YYSTACK_ALLOC (yyalloc
);
1698 yymsg_alloc
= yyalloc
;
1702 yymsg_alloc
= sizeof yymsgbuf
;
1706 if (0 < yysize
&& yysize
<= yymsg_alloc
)
1708 (void) yysyntax_error (yymsg
, yystate
, yychar
);
1713 yyerror (YY_("syntax error"));
1715 goto yyexhaustedlab
;
1723 if (yyerrstatus
== 3)
1725 /* If just tried and failed to reuse look-ahead token after an
1726 error, discard it. */
1728 if (yychar
<= YYEOF
)
1730 /* Return failure if at end of input. */
1731 if (yychar
== YYEOF
)
1736 yydestruct ("Error: discarding",
1742 /* Else will try to reuse look-ahead token after shifting the error
1747 /*---------------------------------------------------.
1748 | yyerrorlab -- error raised explicitly by YYERROR. |
1749 `---------------------------------------------------*/
1752 /* Pacify compilers like GCC when the user code never invokes
1753 YYERROR and the label yyerrorlab therefore never appears in user
1755 if (/*CONSTCOND*/ 0)
1758 /* Do not reclaim the symbols of the rule which action triggered
1762 YY_STACK_PRINT (yyss
, yyssp
);
1767 /*-------------------------------------------------------------.
1768 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1769 `-------------------------------------------------------------*/
1771 yyerrstatus
= 3; /* Each real token shifted decrements this. */
1775 yyn
= yypact
[yystate
];
1776 if (yyn
!= YYPACT_NINF
)
1779 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
1787 /* Pop the current state because it cannot handle the error token. */
1792 yydestruct ("Error: popping",
1793 yystos
[yystate
], yyvsp
);
1796 YY_STACK_PRINT (yyss
, yyssp
);
1805 /* Shift the error token. */
1806 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
1812 /*-------------------------------------.
1813 | yyacceptlab -- YYACCEPT comes here. |
1814 `-------------------------------------*/
1819 /*-----------------------------------.
1820 | yyabortlab -- YYABORT comes here. |
1821 `-----------------------------------*/
1827 /*-------------------------------------------------.
1828 | yyexhaustedlab -- memory exhaustion comes here. |
1829 `-------------------------------------------------*/
1831 yyerror (YY_("memory exhausted"));
1837 if (yychar
!= YYEOF
&& yychar
!= YYEMPTY
)
1838 yydestruct ("Cleanup: discarding lookahead",
1840 /* Do not reclaim the symbols of the rule which action triggered
1841 this YYABORT or YYACCEPT. */
1843 YY_STACK_PRINT (yyss
, yyssp
);
1844 while (yyssp
!= yyss
)
1846 yydestruct ("Cleanup: popping",
1847 yystos
[*yyssp
], yyvsp
);
1852 YYSTACK_FREE (yyss
);
1855 if (yymsg
!= yymsgbuf
)
1856 YYSTACK_FREE (yymsg
);
1858 /* Make sure YYID is used. */
1859 return YYID (yyresult
);
1863 #line 255 "OSUnserializeXML.y"
1867 OSUnserializeerror(parser_state_t
* state
, char *s
) /* Called by yyparse on errors */
1869 char tempString
[128];
1871 if (state
->errorString
) {
1872 snprintf(tempString
, 128, "OSUnserializeXML: %s near line %d\n", s
, state
->lineNumber
);
1873 *(state
->errorString
) = OSString::withCString(tempString
);
1879 #define TAG_MAX_LENGTH 32
1880 #define TAG_MAX_ATTRIBUTES 32
1885 #define TAG_COMMENT 4
1887 #define currentChar() (state->parseBuffer[state->parseBufferIndex])
1888 #define nextChar() (state->parseBuffer[++state->parseBufferIndex])
1889 #define prevChar() (state->parseBuffer[state->parseBufferIndex - 1])
1891 #define isSpace(c) ((c) == ' ' || (c) == '\t')
1892 #define isAlpha(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z'))
1893 #define isDigit(c) ((c) >= '0' && (c) <= '9')
1894 #define isAlphaDigit(c) ((c) >= 'a' && (c) <= 'f')
1895 #define isHexDigit(c) (isDigit(c) || isAlphaDigit(c))
1896 #define isAlphaNumeric(c) (isAlpha(c) || isDigit(c) || ((c) == '-'))
1899 getTag(parser_state_t
*state
,
1900 char tag
[TAG_MAX_LENGTH
],
1901 int *attributeCount
,
1902 char attributes
[TAG_MAX_ATTRIBUTES
][TAG_MAX_LENGTH
],
1903 char values
[TAG_MAX_ATTRIBUTES
][TAG_MAX_LENGTH
] )
1906 int c
= currentChar();
1907 int tagType
= TAG_START
;
1909 *attributeCount
= 0;
1911 if (c
!= '<') return TAG_BAD
;
1912 c
= nextChar(); // skip '<'
1914 if (c
== '?' || c
== '!') {
1915 while ((c
= nextChar()) != 0) {
1916 if (c
== '\n') state
->lineNumber
++;
1925 c
= nextChar(); // skip '/'
1928 if (!isAlpha(c
)) return TAG_BAD
;
1930 /* find end of tag while copying it */
1931 while (isAlphaNumeric(c
)) {
1934 if (length
>= (TAG_MAX_LENGTH
- 1)) return TAG_BAD
;
1939 // printf("tag %s, type %d\n", tag, tagType);
1941 // look for attributes of the form attribute = "value" ...
1942 while ((c
!= '>') && (c
!= '/')) {
1943 while (isSpace(c
)) c
= nextChar();
1946 while (isAlphaNumeric(c
)) {
1947 attributes
[*attributeCount
][length
++] = c
;
1948 if (length
>= (TAG_MAX_LENGTH
- 1)) return TAG_BAD
;
1951 attributes
[*attributeCount
][length
] = 0;
1953 while (isSpace(c
)) c
= nextChar();
1955 if (c
!= '=') return TAG_BAD
;
1958 while (isSpace(c
)) c
= nextChar();
1960 if (c
!= '"') return TAG_BAD
;
1964 values
[*attributeCount
][length
++] = c
;
1965 if (length
>= (TAG_MAX_LENGTH
- 1)) return TAG_BAD
;
1968 values
[*attributeCount
][length
] = 0;
1970 c
= nextChar(); // skip closing quote
1972 // printf(" attribute '%s' = '%s', nextchar = '%c'\n",
1973 // attributes[*attributeCount], values[*attributeCount], c);
1975 (*attributeCount
)++;
1976 if (*attributeCount
>= TAG_MAX_ATTRIBUTES
) return TAG_BAD
;
1980 c
= nextChar(); // skip '/'
1981 tagType
= TAG_EMPTY
;
1983 if (c
!= '>') return TAG_BAD
;
1984 c
= nextChar(); // skip '>'
1990 getString(parser_state_t
*state
)
1992 int c
= currentChar();
1993 int start
, length
, i
, j
;
1996 start
= state
->parseBufferIndex
;
1997 /* find end of string */
2000 if (c
== '\n') state
->lineNumber
++;
2007 if (c
!= '<') return 0;
2009 length
= state
->parseBufferIndex
- start
;
2011 /* copy to null terminated buffer */
2012 tempString
= (char *)malloc(length
+ 1);
2013 if (tempString
== 0) {
2014 printf("OSUnserializeXML: can't alloc temp memory\n");
2018 // copy out string in tempString
2019 // "&" -> '&', "<" -> '<', ">" -> '>'
2022 while (i
< length
) {
2023 c
= state
->parseBuffer
[start
+ i
++];
2025 tempString
[j
++] = c
;
2027 if ((i
+3) > length
) goto error
;
2028 c
= state
->parseBuffer
[start
+ i
++];
2030 if (state
->parseBuffer
[start
+ i
++] != 't') goto error
;
2031 if (state
->parseBuffer
[start
+ i
++] != ';') goto error
;
2032 tempString
[j
++] = '<';
2036 if (state
->parseBuffer
[start
+ i
++] != 't') goto error
;
2037 if (state
->parseBuffer
[start
+ i
++] != ';') goto error
;
2038 tempString
[j
++] = '>';
2041 if ((i
+3) > length
) goto error
;
2043 if (state
->parseBuffer
[start
+ i
++] != 'm') goto error
;
2044 if (state
->parseBuffer
[start
+ i
++] != 'p') goto error
;
2045 if (state
->parseBuffer
[start
+ i
++] != ';') goto error
;
2046 tempString
[j
++] = '&';
2054 // printf("string %s\n", tempString);
2059 if (tempString
) free(tempString
);
2064 getNumber(parser_state_t
*state
)
2066 unsigned long long n
= 0;
2068 bool negate
= false;
2069 int c
= currentChar();
2084 n
= (n
* base
+ c
- '0');
2088 n
= (unsigned long long)((long long)n
* (long long)-1);
2091 while(isHexDigit(c
)) {
2093 n
= (n
* base
+ c
- '0');
2095 n
= (n
* base
+ 0xa + c
- 'a');
2100 // printf("number 0x%x\n", (unsigned long)n);
2104 // taken from CFXMLParsing/CFPropertyList.c
2106 static const signed char __CFPLDataDecodeTable
[128] = {
2107 /* 000 */ -1, -1, -1, -1, -1, -1, -1, -1,
2108 /* 010 */ -1, -1, -1, -1, -1, -1, -1, -1,
2109 /* 020 */ -1, -1, -1, -1, -1, -1, -1, -1,
2110 /* 030 */ -1, -1, -1, -1, -1, -1, -1, -1,
2111 /* ' ' */ -1, -1, -1, -1, -1, -1, -1, -1,
2112 /* '(' */ -1, -1, -1, 62, -1, -1, -1, 63,
2113 /* '0' */ 52, 53, 54, 55, 56, 57, 58, 59,
2114 /* '8' */ 60, 61, -1, -1, -1, 0, -1, -1,
2115 /* '@' */ -1, 0, 1, 2, 3, 4, 5, 6,
2116 /* 'H' */ 7, 8, 9, 10, 11, 12, 13, 14,
2117 /* 'P' */ 15, 16, 17, 18, 19, 20, 21, 22,
2118 /* 'X' */ 23, 24, 25, -1, -1, -1, -1, -1,
2119 /* '`' */ -1, 26, 27, 28, 29, 30, 31, 32,
2120 /* 'h' */ 33, 34, 35, 36, 37, 38, 39, 40,
2121 /* 'p' */ 41, 42, 43, 44, 45, 46, 47, 48,
2122 /* 'x' */ 49, 50, 51, -1, -1, -1, -1, -1
2125 #define DATA_ALLOC_SIZE 4096
2128 getCFEncodedData(parser_state_t
*state
, unsigned int *size
)
2130 int numeq
= 0, acc
= 0, cntr
= 0;
2131 int tmpbufpos
= 0, tmpbuflen
= 0;
2132 unsigned char *tmpbuf
= (unsigned char *)malloc(DATA_ALLOC_SIZE
);
2134 int c
= currentChar();
2143 if (c
== '=') numeq
++; else numeq
= 0;
2144 if (c
== '\n') state
->lineNumber
++;
2145 if (__CFPLDataDecodeTable
[c
] < 0) {
2151 acc
+= __CFPLDataDecodeTable
[c
];
2152 if (0 == (cntr
& 0x3)) {
2153 if (tmpbuflen
<= tmpbufpos
+ 2) {
2154 tmpbuflen
+= DATA_ALLOC_SIZE
;
2155 tmpbuf
= (unsigned char *)realloc(tmpbuf
, tmpbuflen
);
2157 tmpbuf
[tmpbufpos
++] = (acc
>> 16) & 0xff;
2159 tmpbuf
[tmpbufpos
++] = (acc
>> 8) & 0xff;
2161 tmpbuf
[tmpbufpos
++] = acc
& 0xff;
2174 getHexData(parser_state_t
*state
, unsigned int *size
)
2177 unsigned char *d
, *start
, *lastStart
;
2179 start
= lastStart
= d
= (unsigned char *)malloc(DATA_ALLOC_SIZE
);
2184 if (isSpace(c
)) while ((c
= nextChar()) != 0 && isSpace(c
)) {};
2186 state
->lineNumber
++;
2193 *d
= (c
- '0') << 4;
2194 } else if (isAlphaDigit(c
)) {
2195 *d
= (0xa + (c
- 'a')) << 4;
2204 } else if (isAlphaDigit(c
)) {
2205 *d
|= 0xa + (c
- 'a');
2211 if ((d
- lastStart
) >= DATA_ALLOC_SIZE
) {
2212 int oldsize
= d
- start
;
2213 start
= (unsigned char *)realloc(start
, oldsize
+ DATA_ALLOC_SIZE
);
2214 d
= lastStart
= start
+ oldsize
;
2230 yylex(YYSTYPE
*lvalp
, parser_state_t
*state
)
2234 char tag
[TAG_MAX_LENGTH
];
2236 char attributes
[TAG_MAX_ATTRIBUTES
][TAG_MAX_LENGTH
];
2237 char values
[TAG_MAX_ATTRIBUTES
][TAG_MAX_LENGTH
];
2243 /* skip white space */
2244 if (isSpace(c
)) while ((c
= nextChar()) != 0 && isSpace(c
)) {};
2246 /* keep track of line number, don't return \n's */
2248 STATE
->lineNumber
++;
2253 // end of the buffer?
2256 tagType
= getTag(STATE
, tag
, &attributeCount
, attributes
, values
);
2257 if (tagType
== TAG_BAD
) return SYNTAX_ERROR
;
2258 if (tagType
== TAG_COMMENT
) goto top
;
2260 // handle allocation and check for "ID" and "IDREF" tags up front
2261 *lvalp
= object
= newObject(STATE
);
2263 for (i
=0; i
< attributeCount
; i
++) {
2264 if (attributes
[i
][0] == 'I' && attributes
[i
][1] == 'D') {
2265 // check for idref's, note: we ignore the tag, for
2266 // this to work correctly, all idrefs must be unique
2267 // across the whole serialization
2268 if (attributes
[i
][2] == 'R' && attributes
[i
][3] == 'E' &&
2269 attributes
[i
][4] == 'F' && !attributes
[i
][5]) {
2270 if (tagType
!= TAG_EMPTY
) return SYNTAX_ERROR
;
2271 object
->idref
= strtol(values
[i
], NULL
, 0);
2275 if (!attributes
[i
][2]) {
2276 object
->idref
= strtol(values
[i
], NULL
, 0);
2278 return SYNTAX_ERROR
;
2285 if (!strcmp(tag
, "array")) {
2286 if (tagType
== TAG_EMPTY
) {
2287 object
->elements
= NULL
;
2290 return (tagType
== TAG_START
) ? '(' : ')';
2294 if (!strcmp(tag
, "dict")) {
2295 if (tagType
== TAG_EMPTY
) {
2296 object
->elements
= NULL
;
2299 return (tagType
== TAG_START
) ? '{' : '}';
2301 if (!strcmp(tag
, "data")) {
2303 if (tagType
== TAG_EMPTY
) {
2304 object
->data
= NULL
;
2309 bool isHexFormat
= false;
2310 for (i
=0; i
< attributeCount
; i
++) {
2311 if (!strcmp(attributes
[i
], "format") && !strcmp(values
[i
], "hex")) {
2316 // CF encoded is the default form
2318 object
->data
= getHexData(STATE
, &size
);
2320 object
->data
= getCFEncodedData(STATE
, &size
);
2322 object
->size
= size
;
2323 if ((getTag(STATE
, tag
, &attributeCount
, attributes
, values
) != TAG_END
) || strcmp(tag
, "data")) {
2324 return SYNTAX_ERROR
;
2330 if (!strcmp(tag
, "false")) {
2331 if (tagType
== TAG_EMPTY
) {
2338 if (!strcmp(tag
, "integer")) {
2339 object
->size
= 64; // default
2340 for (i
=0; i
< attributeCount
; i
++) {
2341 if (!strcmp(attributes
[i
], "size")) {
2342 object
->size
= strtoul(values
[i
], NULL
, 0);
2345 if (tagType
== TAG_EMPTY
) {
2349 object
->number
= getNumber(STATE
);
2350 if ((getTag(STATE
, tag
, &attributeCount
, attributes
, values
) != TAG_END
) || strcmp(tag
, "integer")) {
2351 return SYNTAX_ERROR
;
2357 if (!strcmp(tag
, "key")) {
2358 if (tagType
== TAG_EMPTY
) return SYNTAX_ERROR
;
2359 object
->string
= getString(STATE
);
2360 if (!object
->string
) {
2361 return SYNTAX_ERROR
;
2363 if ((getTag(STATE
, tag
, &attributeCount
, attributes
, values
) != TAG_END
)
2364 || strcmp(tag
, "key")) {
2365 return SYNTAX_ERROR
;
2371 if (!strcmp(tag
, "plist")) {
2372 freeObject(STATE
, object
);
2377 if (!strcmp(tag
, "string")) {
2378 if (tagType
== TAG_EMPTY
) {
2379 object
->string
= (char *)malloc(1);
2380 object
->string
[0] = 0;
2383 object
->string
= getString(STATE
);
2384 if (!object
->string
) {
2385 return SYNTAX_ERROR
;
2387 if ((getTag(STATE
, tag
, &attributeCount
, attributes
, values
) != TAG_END
)
2388 || strcmp(tag
, "string")) {
2389 return SYNTAX_ERROR
;
2393 if (!strcmp(tag
, "set")) {
2394 if (tagType
== TAG_EMPTY
) {
2395 object
->elements
= NULL
;
2398 if (tagType
== TAG_START
) {
2406 if (!strcmp(tag
, "true")) {
2407 if (tagType
== TAG_EMPTY
) {
2415 return SYNTAX_ERROR
;
2418 // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2419 // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2420 // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2422 // "java" like allocation, if this code hits a syntax error in the
2423 // the middle of the parsed string we just bail with pointers hanging
2424 // all over place, this code helps keeps it all together
2426 //static int object_count = 0;
2429 newObject(parser_state_t
*state
)
2433 if (state
->freeObjects
) {
2434 o
= state
->freeObjects
;
2435 state
->freeObjects
= state
->freeObjects
->next
;
2437 o
= (object_t
*)malloc(sizeof(object_t
));
2439 bzero(o
, sizeof(object_t
));
2440 o
->free
= state
->objects
;
2448 freeObject(parser_state_t
* state
, object_t
*o
)
2450 o
->next
= state
->freeObjects
;
2451 state
->freeObjects
= o
;
2455 cleanupObjects(parser_state_t
*state
)
2457 object_t
*t
, *o
= state
->objects
;
2461 // printf("OSUnserializeXML: releasing object o=%x object=%x\n", (int)o, (int)o->object);
2462 o
->object
->release();
2465 // printf("OSUnserializeXML: freeing object o=%x data=%x\n", (int)o, (int)o->data);
2469 // printf("OSUnserializeXML: releasing object o=%x key=%x\n", (int)o, (int)o->key);
2473 // printf("OSUnserializeXML: freeing object o=%x string=%x\n", (int)o, (int)o->string);
2482 // printf("object_count = %d\n", object_count);
2485 // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2486 // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2487 // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2490 rememberObject(parser_state_t
*state
, int tag
, OSObject
*o
)
2493 snprintf(key
, 16, "%u", tag
);
2495 // printf("remember key %s\n", key);
2497 state
->tags
->setObject(key
, o
);
2501 retrieveObject(parser_state_t
*state
, int tag
)
2506 snprintf(key
, 16, "%u", tag
);
2508 // printf("retrieve key '%s'\n", key);
2510 ref
= state
->tags
->getObject(key
);
2513 o
= newObject(state
);
2518 // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2519 // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2520 // !@$&)(^Q$&*^!$(*!@$_(^%_(*Q#$(_*&!$_(*&!$_(*&!#$(*!@&^!@#%!_!#
2523 buildDictionary(parser_state_t
*state
, object_t
* header
)
2529 // get count and reverse order
2530 o
= header
->elements
;
2531 header
->elements
= 0;
2537 t
->next
= header
->elements
;
2538 header
->elements
= t
;
2541 dict
= OSDictionary::withCapacity(count
);
2542 if (header
->idref
>= 0) rememberObject(state
, header
->idref
, dict
);
2544 o
= header
->elements
;
2546 dict
->setObject(o
->key
, o
->object
);
2549 o
->object
->release();
2555 freeObject(state
, t
);
2563 buildArray(parser_state_t
*state
, object_t
* header
)
2569 // get count and reverse order
2570 o
= header
->elements
;
2571 header
->elements
= 0;
2577 t
->next
= header
->elements
;
2578 header
->elements
= t
;
2581 array
= OSArray::withCapacity(count
);
2582 if (header
->idref
>= 0) rememberObject(state
, header
->idref
, array
);
2584 o
= header
->elements
;
2586 array
->setObject(o
->object
);
2588 o
->object
->release();
2593 freeObject(state
, t
);
2601 buildSet(parser_state_t
*state
, object_t
*header
)
2603 object_t
*o
= buildArray(state
, header
);
2605 OSArray
*array
= (OSArray
*)o
->object
;
2606 OSSet
*set
= OSSet::withArray(array
, array
->getCapacity());
2608 // write over the reference created in buildArray
2609 if (header
->idref
>= 0) rememberObject(state
, header
->idref
, set
);
2617 buildString(parser_state_t
*state
, object_t
*o
)
2621 string
= OSString::withCString(o
->string
);
2622 if (o
->idref
>= 0) rememberObject(state
, o
->idref
, string
);
2632 buildData(parser_state_t
*state
, object_t
*o
)
2637 data
= OSData::withBytes(o
->data
, o
->size
);
2639 data
= OSData::withCapacity(0);
2641 if (o
->idref
>= 0) rememberObject(state
, o
->idref
, data
);
2643 if (o
->size
) free(o
->data
);
2650 buildNumber(parser_state_t
*state
, object_t
*o
)
2652 OSNumber
*number
= OSNumber::withNumber(o
->number
, o
->size
);
2654 if (o
->idref
>= 0) rememberObject(state
, o
->idref
, number
);
2661 buildBoolean(parser_state_t
*state
, object_t
*o
)
2663 o
->object
= ((o
->number
== 0) ? kOSBooleanFalse
: kOSBooleanTrue
);
2664 o
->object
->retain();
2669 OSUnserializeXML(const char *buffer
, OSString
**errorString
)
2672 parser_state_t
*state
= (parser_state_t
*)malloc(sizeof(parser_state_t
));
2674 if ((!state
) || (!buffer
)) return 0;
2677 if (errorString
) *errorString
= NULL
;
2679 state
->parseBuffer
= buffer
;
2680 state
->parseBufferIndex
= 0;
2681 state
->lineNumber
= 1;
2683 state
->freeObjects
= 0;
2684 state
->tags
= OSDictionary::withCapacity(128);
2685 state
->errorString
= errorString
;
2686 state
->parsedObject
= 0;
2688 (void)yyparse((void *)state
);
2690 object
= state
->parsedObject
;
2692 cleanupObjects(state
);
2693 state
->tags
->release();
2705 // DO NOT EDIT OSUnserializeXML.cpp!