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