1 2 /* A Bison parser, made by GNU Bison 2.4.1. */ 3 4 /* Skeleton implementation for Bison's Yacc-like parsers in C 5 6 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 7 Free Software Foundation, Inc. 8 9 This program is free software: you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation, either version 3 of the License, or 12 (at your option) any later version. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 21 22 /* As a special exception, you may create a larger work that contains 23 part or all of the Bison parser skeleton and distribute that work 24 under terms of your choice, so long as that work isn't itself a 25 parser generator using the skeleton or a modified version thereof 26 as a parser skeleton. Alternatively, if you modify or redistribute 27 the parser skeleton itself, you may (at your option) remove this 28 special exception, which will cause the skeleton and the resulting 29 Bison output files to be licensed under the GNU General Public 30 License without this special exception. 31 32 This special exception was added by the Free Software Foundation in 33 version 2.2 of Bison. */ 34 35 /* C LALR(1) parser skeleton written by Richard Stallman, by 36 simplifying the original so-called "semantic" parser. */ 37 38 /* All symbols defined below should begin with yy or YY, to avoid 39 infringing on user name space. This should be done even for local 40 variables, as they might otherwise be expanded by user macros. 41 There are some unavoidable exceptions within include files to 42 define necessary library symbols; they are noted "INFRINGES ON 43 USER NAME SPACE" below. */ 44 45 /* Identify Bison output. */ 46 #define YYBISON 1 47 48 /* Bison version. */ 49 #define YYBISON_VERSION "2.4.1" 50 51 /* Skeleton name. */ 52 #define YYSKELETON_NAME "yacc.c" 53 54 /* Pure parsers. */ 55 #define YYPURE 1 56 57 /* Push parsers. */ 58 #define YYPUSH 0 59 60 /* Pull parsers. */ 61 #define YYPULL 1 62 63 /* Using locations. */ 64 #define YYLSP_NEEDED 0 65 66 /* Substitute the variable and function names. */ 67 #define yyparse __ktrfmt_parse 68 #define yylex __ktrfmt_lex 69 #define yyerror __ktrfmt_error 70 #define yylval __ktrfmt_lval 71 #define yychar __ktrfmt_char 72 #define yydebug __ktrfmt_debug 73 #define yynerrs __ktrfmt_nerrs 74 75 76 /* Copy the first part of user declarations. */ 77 78 /* Line 189 of yacc.c */ 79 #line 1 "ktrfmt.y" 80 81 82 #include <assert.h> 83 #include <errno.h> 84 #include <stdarg.h> 85 #include <stdlib.h> 86 #include <string.h> 87 #include <sys/queue.h> 88 89 #include "evtr.h" 90 #include "tok.h" 91 #include "ktrfmt.tab.h" 92 #include "internal.h" 93 94 struct ktrfmt_parse_ctx { 95 struct symtab *symtab; 96 struct evtr_variable *var; 97 struct evtr_variable_value *val; 98 evtr_event_t ev; 99 char *errbuf; 100 size_t errbufsz; 101 int err; 102 }; 103 104 int __ktrfmtlex(YYSTYPE *); 105 #define __ktrfmt_lex __ktrfmtlex 106 107 void __ktrfmt_error (struct ktrfmt_parse_ctx *, const char *); 108 109 static 110 void 111 do_parse_err(struct ktrfmt_parse_ctx *ctx, const char *fmt, ...) 112 { 113 va_list ap; 114 115 va_start(ap, fmt); 116 vsnprintf(ctx->errbuf, ctx->errbufsz, fmt, ap); 117 va_end(ap); 118 ctx->err = !0; 119 } 120 121 #define parse_err(fmt, ...) \ 122 do { \ 123 do_parse_err(ctx, fmt, ##__VA_ARGS__); \ 124 YYABORT; \ 125 } while (0) 126 127 static 128 struct evtr_variable * 129 evtr_var_new(const char *name) 130 { 131 struct evtr_variable *var; 132 133 var = calloc(1, sizeof(*var)); 134 if (var) { 135 if (!(var->name = strdup(name))) { 136 free(var); 137 return NULL; 138 } 139 var->val.type = EVTR_VAL_NIL; 140 } 141 return var; 142 } 143 144 /* 145 * XXX: should be reentrant 146 */ 147 static 148 char * 149 uniq_varname(void) 150 { 151 static long serno; 152 static char buf[100]; 153 154 serno++; 155 snprintf(buf, sizeof(buf), "@%ld", serno); 156 return &buf[0]; 157 } 158 159 static 160 int 161 index_hash(struct ktrfmt_parse_ctx *ctx, const char *hashname, 162 evtr_variable_value_t val, evtr_var_t *_var) 163 { 164 evtr_var_t hsh, var; 165 uintptr_t ret, key; 166 hsh = symtab_find(ctx->symtab, hashname); 167 if (hsh->val.type == EVTR_VAL_NIL) { 168 /* it's probably the first time we see this "variable" */ 169 printd(PARSE, "creating hash for %s\n", hsh->name); 170 hsh->val.type = EVTR_VAL_HASH; 171 hsh->val.hashtab = hash_new(); 172 } else if (hsh->val.type != EVTR_VAL_HASH) { 173 printd(PARSE, "trying to use type %d as hash\n", hsh->val.type); 174 return !0; 175 } 176 if (val->type == EVTR_VAL_INT) { 177 key = val->num; 178 printd(PARSE, "looking up %s[%jd] in %p\n", hsh->name, 179 val->num, hsh->val.hashtab); 180 } else if (val->type == EVTR_VAL_STR) { 181 key = (uintptr_t)val->str; 182 printd(PARSE, "looking up %s[\"%s\"] in %p\n", hsh->name, 183 val->str, hsh->val.hashtab); 184 } else { 185 do_parse_err(ctx, "trying to index hash '%s' with " 186 "non-supported value", hashname); 187 return !0; 188 } 189 190 if (hash_find(hsh->val.hashtab, key, &ret)) { 191 printd(PARSE, "didn't find it\n"); 192 var = evtr_var_new(uniq_varname()); 193 if (var) { 194 printd(PARSE, "inserting it as %s\n", var->name); 195 if (!hash_insert(hsh->val.hashtab, key, 196 (uintptr_t)var)) { 197 do_parse_err(ctx, "can't insert temporary " 198 "variable into hash\n"); 199 return !0; 200 } 201 symtab_insert(ctx->symtab, var->name, var); 202 } else { 203 do_parse_err(ctx, "out of memory"); 204 } 205 } else { 206 var = (struct evtr_variable *)ret; 207 } 208 if (!var) { 209 fprintf(stderr, "no var!\n"); 210 return !0; 211 /* XXX */ 212 } 213 *_var = var; 214 return 0; 215 } 216 217 218 219 /* Line 189 of yacc.c */ 220 #line 221 "ktrfmt.tab.c" 221 222 /* Enabling traces. */ 223 #ifndef YYDEBUG 224 # define YYDEBUG 1 225 #endif 226 227 /* Enabling verbose error messages. */ 228 #ifdef YYERROR_VERBOSE 229 # undef YYERROR_VERBOSE 230 # define YYERROR_VERBOSE 1 231 #else 232 # define YYERROR_VERBOSE 1 233 #endif 234 235 /* Enabling the token table. */ 236 #ifndef YYTOKEN_TABLE 237 # define YYTOKEN_TABLE 0 238 #endif 239 240 241 /* Tokens. */ 242 #ifndef YYTOKENTYPE 243 # define YYTOKENTYPE 244 /* Put the tokens into the symbol table, so that GDB and other debuggers 245 know about them. */ 246 enum yytokentype { 247 TOK_ID = 258, 248 TOK_CTOR = 259, 249 TOK_INT = 260, 250 TOK_STR = 261, 251 TOK_EQ = 262, 252 TOK_LEFT_BRACK = 263, 253 TOK_RIGHT_BRACK = 264, 254 TOK_DOT = 265 255 }; 256 #endif 257 258 259 260 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED 261 typedef union YYSTYPE 262 { 263 264 /* Line 214 of yacc.c */ 265 #line 147 "ktrfmt.y" 266 267 struct token *tok; 268 struct evtr_variable *var; 269 struct evtr_variable_value *val; 270 void *na; 271 272 273 274 /* Line 214 of yacc.c */ 275 #line 276 "ktrfmt.tab.c" 276 } YYSTYPE; 277 # define YYSTYPE_IS_TRIVIAL 1 278 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ 279 # define YYSTYPE_IS_DECLARED 1 280 #endif 281 282 283 /* Copy the second part of user declarations. */ 284 285 286 /* Line 264 of yacc.c */ 287 #line 288 "ktrfmt.tab.c" 288 289 #ifdef short 290 # undef short 291 #endif 292 293 #ifdef YYTYPE_UINT8 294 typedef YYTYPE_UINT8 yytype_uint8; 295 #else 296 typedef unsigned char yytype_uint8; 297 #endif 298 299 #ifdef YYTYPE_INT8 300 typedef YYTYPE_INT8 yytype_int8; 301 #elif (defined __STDC__ || defined __C99__FUNC__ \ 302 || defined __cplusplus || defined _MSC_VER) 303 typedef signed char yytype_int8; 304 #else 305 typedef short int yytype_int8; 306 #endif 307 308 #ifdef YYTYPE_UINT16 309 typedef YYTYPE_UINT16 yytype_uint16; 310 #else 311 typedef unsigned short int yytype_uint16; 312 #endif 313 314 #ifdef YYTYPE_INT16 315 typedef YYTYPE_INT16 yytype_int16; 316 #else 317 typedef short int yytype_int16; 318 #endif 319 320 #ifndef YYSIZE_T 321 # ifdef __SIZE_TYPE__ 322 # define YYSIZE_T __SIZE_TYPE__ 323 # elif defined size_t 324 # define YYSIZE_T size_t 325 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ 326 || defined __cplusplus || defined _MSC_VER) 327 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ 328 # define YYSIZE_T size_t 329 # else 330 # define YYSIZE_T unsigned int 331 # endif 332 #endif 333 334 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) 335 336 #ifndef YY_ 337 # if YYENABLE_NLS 338 # if ENABLE_NLS 339 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ 340 # define YY_(msgid) dgettext ("bison-runtime", msgid) 341 # endif 342 # endif 343 # ifndef YY_ 344 # define YY_(msgid) msgid 345 # endif 346 #endif 347 348 /* Suppress unused-variable warnings by "using" E. */ 349 #if ! defined lint || defined __GNUC__ 350 # define YYUSE(e) ((void) (e)) 351 #else 352 # define YYUSE(e) /* empty */ 353 #endif 354 355 /* Identity function, used to suppress warnings about constant conditions. */ 356 #ifndef lint 357 # define YYID(n) (n) 358 #else 359 #if (defined __STDC__ || defined __C99__FUNC__ \ 360 || defined __cplusplus || defined _MSC_VER) 361 static int 362 YYID (int yyi) 363 #else 364 static int 365 YYID (yyi) 366 int yyi; 367 #endif 368 { 369 return yyi; 370 } 371 #endif 372 373 #if ! defined yyoverflow || YYERROR_VERBOSE 374 375 /* The parser invokes alloca or malloc; define the necessary symbols. */ 376 377 # ifdef YYSTACK_USE_ALLOCA 378 # if YYSTACK_USE_ALLOCA 379 # ifdef __GNUC__ 380 # define YYSTACK_ALLOC __builtin_alloca 381 # elif defined __BUILTIN_VA_ARG_INCR 382 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ 383 # elif defined _AIX 384 # define YYSTACK_ALLOC __alloca 385 # elif defined _MSC_VER 386 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ 387 # define alloca _alloca 388 # else 389 # define YYSTACK_ALLOC alloca 390 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ 391 || defined __cplusplus || defined _MSC_VER) 392 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 393 # ifndef _STDLIB_H 394 # define _STDLIB_H 1 395 # endif 396 # endif 397 # endif 398 # endif 399 # endif 400 401 # ifdef YYSTACK_ALLOC 402 /* Pacify GCC's `empty if-body' warning. */ 403 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) 404 # ifndef YYSTACK_ALLOC_MAXIMUM 405 /* The OS might guarantee only one guard page at the bottom of the stack, 406 and a page size can be as small as 4096 bytes. So we cannot safely 407 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number 408 to allow for a few compiler-allocated temporary stack slots. */ 409 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ 410 # endif 411 # else 412 # define YYSTACK_ALLOC YYMALLOC 413 # define YYSTACK_FREE YYFREE 414 # ifndef YYSTACK_ALLOC_MAXIMUM 415 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM 416 # endif 417 # if (defined __cplusplus && ! defined _STDLIB_H \ 418 && ! ((defined YYMALLOC || defined malloc) \ 419 && (defined YYFREE || defined free))) 420 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 421 # ifndef _STDLIB_H 422 # define _STDLIB_H 1 423 # endif 424 # endif 425 # ifndef YYMALLOC 426 # define YYMALLOC malloc 427 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ 428 || defined __cplusplus || defined _MSC_VER) 429 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ 430 # endif 431 # endif 432 # ifndef YYFREE 433 # define YYFREE free 434 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ 435 || defined __cplusplus || defined _MSC_VER) 436 void free (void *); /* INFRINGES ON USER NAME SPACE */ 437 # endif 438 # endif 439 # endif 440 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ 441 442 443 #if (! defined yyoverflow \ 444 && (! defined __cplusplus \ 445 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) 446 447 /* A type that is properly aligned for any stack member. */ 448 union yyalloc 449 { 450 yytype_int16 yyss_alloc; 451 YYSTYPE yyvs_alloc; 452 }; 453 454 /* The size of the maximum gap between one aligned stack and the next. */ 455 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) 456 457 /* The size of an array large to enough to hold all stacks, each with 458 N elements. */ 459 # define YYSTACK_BYTES(N) \ 460 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ 461 + YYSTACK_GAP_MAXIMUM) 462 463 /* Copy COUNT objects from FROM to TO. The source and destination do 464 not overlap. */ 465 # ifndef YYCOPY 466 # if defined __GNUC__ && 1 < __GNUC__ 467 # define YYCOPY(To, From, Count) \ 468 __builtin_memcpy (To, From, (Count) * sizeof (*(From))) 469 # else 470 # define YYCOPY(To, From, Count) \ 471 do \ 472 { \ 473 YYSIZE_T yyi; \ 474 for (yyi = 0; yyi < (Count); yyi++) \ 475 (To)[yyi] = (From)[yyi]; \ 476 } \ 477 while (YYID (0)) 478 # endif 479 # endif 480 481 /* Relocate STACK from its old location to the new one. The 482 local variables YYSIZE and YYSTACKSIZE give the old and new number of 483 elements in the stack, and YYPTR gives the new location of the 484 stack. Advance YYPTR to a properly aligned location for the next 485 stack. */ 486 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ 487 do \ 488 { \ 489 YYSIZE_T yynewbytes; \ 490 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ 491 Stack = &yyptr->Stack_alloc; \ 492 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ 493 yyptr += yynewbytes / sizeof (*yyptr); \ 494 } \ 495 while (YYID (0)) 496 497 #endif 498 499 /* YYFINAL -- State number of the termination state. */ 500 #define YYFINAL 12 501 /* YYLAST -- Last index in YYTABLE. */ 502 #define YYLAST 20 503 504 /* YYNTOKENS -- Number of terminals. */ 505 #define YYNTOKENS 11 506 /* YYNNTS -- Number of nonterminals. */ 507 #define YYNNTS 11 508 /* YYNRULES -- Number of rules. */ 509 #define YYNRULES 19 510 /* YYNRULES -- Number of states. */ 511 #define YYNSTATES 25 512 513 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ 514 #define YYUNDEFTOK 2 515 #define YYMAXUTOK 265 516 517 #define YYTRANSLATE(YYX) \ 518 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) 519 520 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ 521 static const yytype_uint8 yytranslate[] = 522 { 523 0, 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, 2, 2, 2, 2, 527 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 528 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 529 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 530 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 531 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 532 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 533 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 534 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 535 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 536 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 537 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 538 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 539 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 540 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 541 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 542 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 543 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 544 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 545 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 546 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 547 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 548 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 549 5, 6, 7, 8, 9, 10 550 }; 551 552 #if YYDEBUG 553 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in 554 YYRHS. */ 555 static const yytype_uint8 yyprhs[] = 556 { 557 0, 0, 3, 5, 7, 9, 11, 13, 15, 18, 558 20, 23, 25, 27, 32, 36, 38, 40, 44, 48 559 }; 560 561 /* YYRHS -- A `-1'-separated list of the rules' RHS. */ 562 static const yytype_int8 yyrhs[] = 563 { 564 12, 0, -1, 13, -1, 19, -1, 21, -1, 5, 565 -1, 6, -1, 14, -1, 14, 15, -1, 4, -1, 566 4, 15, -1, 3, -1, 14, -1, 18, 8, 18, 567 9, -1, 18, 10, 3, -1, 17, -1, 18, -1, 568 19, 7, 14, -1, 19, 7, 16, -1, 20, -1 569 }; 570 571 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ 572 static const yytype_uint16 yyrline[] = 573 { 574 0, 175, 175, 177, 180, 182, 196, 210, 219, 224, 575 237, 262, 280, 284, 291, 304, 308, 312, 319, 327 576 }; 577 #endif 578 579 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE 580 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. 581 First, the terminals, then, starting at YYNTOKENS, nonterminals. */ 582 static const char *const yytname[] = 583 { 584 "$end", "error", "$undefined", "TOK_ID", "TOK_CTOR", "TOK_INT", 585 "TOK_STR", "TOK_EQ", "TOK_LEFT_BRACK", "TOK_RIGHT_BRACK", "TOK_DOT", 586 "$accept", "input", "stmt", "constant", "ctor_args", "construct_expr", 587 "primary_expr", "postfix_expr", "unary_expr", "assign_expr", "expr", 0 588 }; 589 #endif 590 591 # ifdef YYPRINT 592 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to 593 token YYLEX-NUM. */ 594 static const yytype_uint16 yytoknum[] = 595 { 596 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 597 265 598 }; 599 # endif 600 601 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ 602 static const yytype_uint8 yyr1[] = 603 { 604 0, 11, 12, 13, 13, 14, 14, 15, 15, 16, 605 16, 17, 17, 18, 18, 18, 19, 20, 20, 21 606 }; 607 608 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ 609 static const yytype_uint8 yyr2[] = 610 { 611 0, 2, 1, 1, 1, 1, 1, 1, 2, 1, 612 2, 1, 1, 4, 3, 1, 1, 3, 3, 1 613 }; 614 615 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state 616 STATE-NUM when YYTABLE doesn't specify something else to do. Zero 617 means the default is an error. */ 618 static const yytype_uint8 yydefact[] = 619 { 620 0, 11, 5, 6, 0, 2, 12, 15, 16, 3, 621 19, 4, 1, 0, 0, 0, 0, 14, 9, 17, 622 18, 13, 7, 10, 8 623 }; 624 625 /* YYDEFGOTO[NTERM-NUM]. */ 626 static const yytype_int8 yydefgoto[] = 627 { 628 -1, 4, 5, 6, 23, 20, 7, 8, 9, 10, 629 11 630 }; 631 632 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 633 STATE-NUM. */ 634 #define YYPACT_NINF -17 635 static const yytype_int8 yypact[] = 636 { 637 -1, -17, -17, -17, 1, -17, -17, -17, 6, 8, 638 -17, -17, -17, -1, 16, 4, 3, -17, 12, -17, 639 -17, -17, 12, -17, -17 640 }; 641 642 /* YYPGOTO[NTERM-NUM]. */ 643 static const yytype_int8 yypgoto[] = 644 { 645 -17, -17, -17, -15, -16, -17, -17, 7, -17, -17, 646 -17 647 }; 648 649 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If 650 positive, shift that token. If negative, reduce the rule which 651 number is the opposite. If zero, do what YYDEFACT says. 652 If YYTABLE_NINF, syntax error. */ 653 #define YYTABLE_NINF -1 654 static const yytype_uint8 yytable[] = 655 { 656 19, 12, 1, 22, 2, 3, 24, 22, 18, 2, 657 3, 13, 21, 14, 13, 15, 14, 2, 3, 17, 658 16 659 }; 660 661 static const yytype_uint8 yycheck[] = 662 { 663 15, 0, 3, 18, 5, 6, 22, 22, 4, 5, 664 6, 8, 9, 10, 8, 7, 10, 5, 6, 3, 665 13 666 }; 667 668 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing 669 symbol of state STATE-NUM. */ 670 static const yytype_uint8 yystos[] = 671 { 672 0, 3, 5, 6, 12, 13, 14, 17, 18, 19, 673 20, 21, 0, 8, 10, 7, 18, 3, 4, 14, 674 16, 9, 14, 15, 15 675 }; 676 677 #define yyerrok (yyerrstatus = 0) 678 #define yyclearin (yychar = YYEMPTY) 679 #define YYEMPTY (-2) 680 #define YYEOF 0 681 682 #define YYACCEPT goto yyacceptlab 683 #define YYABORT goto yyabortlab 684 #define YYERROR goto yyerrorlab 685 686 687 /* Like YYERROR except do call yyerror. This remains here temporarily 688 to ease the transition to the new meaning of YYERROR, for GCC. 689 Once GCC version 2 has supplanted version 1, this can go. */ 690 691 #define YYFAIL goto yyerrlab 692 693 #define YYRECOVERING() (!!yyerrstatus) 694 695 #define YYBACKUP(Token, Value) \ 696 do \ 697 if (yychar == YYEMPTY && yylen == 1) \ 698 { \ 699 yychar = (Token); \ 700 yylval = (Value); \ 701 yytoken = YYTRANSLATE (yychar); \ 702 YYPOPSTACK (1); \ 703 goto yybackup; \ 704 } \ 705 else \ 706 { \ 707 yyerror (ctx, YY_("syntax error: cannot back up")); \ 708 YYERROR; \ 709 } \ 710 while (YYID (0)) 711 712 713 #define YYTERROR 1 714 #define YYERRCODE 256 715 716 717 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. 718 If N is 0, then set CURRENT to the empty location which ends 719 the previous symbol: RHS[0] (always defined). */ 720 721 #define YYRHSLOC(Rhs, K) ((Rhs)[K]) 722 #ifndef YYLLOC_DEFAULT 723 # define YYLLOC_DEFAULT(Current, Rhs, N) \ 724 do \ 725 if (YYID (N)) \ 726 { \ 727 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ 728 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ 729 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ 730 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ 731 } \ 732 else \ 733 { \ 734 (Current).first_line = (Current).last_line = \ 735 YYRHSLOC (Rhs, 0).last_line; \ 736 (Current).first_column = (Current).last_column = \ 737 YYRHSLOC (Rhs, 0).last_column; \ 738 } \ 739 while (YYID (0)) 740 #endif 741 742 743 /* YY_LOCATION_PRINT -- Print the location on the stream. 744 This macro was not mandated originally: define only if we know 745 we won't break user code: when these are the locations we know. */ 746 747 #ifndef YY_LOCATION_PRINT 748 # if YYLTYPE_IS_TRIVIAL 749 # define YY_LOCATION_PRINT(File, Loc) \ 750 fprintf (File, "%d.%d-%d.%d", \ 751 (Loc).first_line, (Loc).first_column, \ 752 (Loc).last_line, (Loc).last_column) 753 # else 754 # define YY_LOCATION_PRINT(File, Loc) ((void) 0) 755 # endif 756 #endif 757 758 759 /* YYLEX -- calling `yylex' with the right arguments. */ 760 761 #ifdef YYLEX_PARAM 762 # define YYLEX yylex (&yylval, YYLEX_PARAM) 763 #else 764 # define YYLEX yylex (&yylval) 765 #endif 766 767 /* Enable debugging if requested. */ 768 #if YYDEBUG 769 770 # ifndef YYFPRINTF 771 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ 772 # define YYFPRINTF fprintf 773 # endif 774 775 # define YYDPRINTF(Args) \ 776 do { \ 777 if (yydebug) \ 778 YYFPRINTF Args; \ 779 } while (YYID (0)) 780 781 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ 782 do { \ 783 if (yydebug) \ 784 { \ 785 YYFPRINTF (stderr, "%s ", Title); \ 786 yy_symbol_print (stderr, \ 787 Type, Value, ctx); \ 788 YYFPRINTF (stderr, "\n"); \ 789 } \ 790 } while (YYID (0)) 791 792 793 /*--------------------------------. 794 | Print this symbol on YYOUTPUT. | 795 `--------------------------------*/ 796 797 /*ARGSUSED*/ 798 #if (defined __STDC__ || defined __C99__FUNC__ \ 799 || defined __cplusplus || defined _MSC_VER) 800 static void 801 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct ktrfmt_parse_ctx *ctx) 802 #else 803 static void 804 yy_symbol_value_print (yyoutput, yytype, yyvaluep, ctx) 805 FILE *yyoutput; 806 int yytype; 807 YYSTYPE const * const yyvaluep; 808 struct ktrfmt_parse_ctx *ctx; 809 #endif 810 { 811 if (!yyvaluep) 812 return; 813 YYUSE (ctx); 814 # ifdef YYPRINT 815 if (yytype < YYNTOKENS) 816 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); 817 # else 818 YYUSE (yyoutput); 819 # endif 820 switch (yytype) 821 { 822 default: 823 break; 824 } 825 } 826 827 828 /*--------------------------------. 829 | Print this symbol on YYOUTPUT. | 830 `--------------------------------*/ 831 832 #if (defined __STDC__ || defined __C99__FUNC__ \ 833 || defined __cplusplus || defined _MSC_VER) 834 static void 835 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct ktrfmt_parse_ctx *ctx) 836 #else 837 static void 838 yy_symbol_print (yyoutput, yytype, yyvaluep, ctx) 839 FILE *yyoutput; 840 int yytype; 841 YYSTYPE const * const yyvaluep; 842 struct ktrfmt_parse_ctx *ctx; 843 #endif 844 { 845 if (yytype < YYNTOKENS) 846 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); 847 else 848 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); 849 850 yy_symbol_value_print (yyoutput, yytype, yyvaluep, ctx); 851 YYFPRINTF (yyoutput, ")"); 852 } 853 854 /*------------------------------------------------------------------. 855 | yy_stack_print -- Print the state stack from its BOTTOM up to its | 856 | TOP (included). | 857 `------------------------------------------------------------------*/ 858 859 #if (defined __STDC__ || defined __C99__FUNC__ \ 860 || defined __cplusplus || defined _MSC_VER) 861 static void 862 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) 863 #else 864 static void 865 yy_stack_print (yybottom, yytop) 866 yytype_int16 *yybottom; 867 yytype_int16 *yytop; 868 #endif 869 { 870 YYFPRINTF (stderr, "Stack now"); 871 for (; yybottom <= yytop; yybottom++) 872 { 873 int yybot = *yybottom; 874 YYFPRINTF (stderr, " %d", yybot); 875 } 876 YYFPRINTF (stderr, "\n"); 877 } 878 879 # define YY_STACK_PRINT(Bottom, Top) \ 880 do { \ 881 if (yydebug) \ 882 yy_stack_print ((Bottom), (Top)); \ 883 } while (YYID (0)) 884 885 886 /*------------------------------------------------. 887 | Report that the YYRULE is going to be reduced. | 888 `------------------------------------------------*/ 889 890 #if (defined __STDC__ || defined __C99__FUNC__ \ 891 || defined __cplusplus || defined _MSC_VER) 892 static void 893 yy_reduce_print (YYSTYPE *yyvsp, int yyrule, struct ktrfmt_parse_ctx *ctx) 894 #else 895 static void 896 yy_reduce_print (yyvsp, yyrule, ctx) 897 YYSTYPE *yyvsp; 898 int yyrule; 899 struct ktrfmt_parse_ctx *ctx; 900 #endif 901 { 902 int yynrhs = yyr2[yyrule]; 903 int yyi; 904 unsigned long int yylno = yyrline[yyrule]; 905 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", 906 yyrule - 1, yylno); 907 /* The symbols being reduced. */ 908 for (yyi = 0; yyi < yynrhs; yyi++) 909 { 910 YYFPRINTF (stderr, " $%d = ", yyi + 1); 911 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], 912 &(yyvsp[(yyi + 1) - (yynrhs)]) 913 , ctx); 914 YYFPRINTF (stderr, "\n"); 915 } 916 } 917 918 # define YY_REDUCE_PRINT(Rule) \ 919 do { \ 920 if (yydebug) \ 921 yy_reduce_print (yyvsp, Rule, ctx); \ 922 } while (YYID (0)) 923 924 /* Nonzero means print parse trace. It is left uninitialized so that 925 multiple parsers can coexist. */ 926 int yydebug; 927 #else /* !YYDEBUG */ 928 # define YYDPRINTF(Args) 929 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) 930 # define YY_STACK_PRINT(Bottom, Top) 931 # define YY_REDUCE_PRINT(Rule) 932 #endif /* !YYDEBUG */ 933 934 935 /* YYINITDEPTH -- initial size of the parser's stacks. */ 936 #ifndef YYINITDEPTH 937 # define YYINITDEPTH 200 938 #endif 939 940 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only 941 if the built-in stack extension method is used). 942 943 Do not make this value too large; the results are undefined if 944 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) 945 evaluated with infinite-precision integer arithmetic. */ 946 947 #ifndef YYMAXDEPTH 948 # define YYMAXDEPTH 10000 949 #endif 950 951 952 953 #if YYERROR_VERBOSE 954 955 # ifndef yystrlen 956 # if defined __GLIBC__ && defined _STRING_H 957 # define yystrlen strlen 958 # else 959 /* Return the length of YYSTR. */ 960 #if (defined __STDC__ || defined __C99__FUNC__ \ 961 || defined __cplusplus || defined _MSC_VER) 962 static YYSIZE_T 963 yystrlen (const char *yystr) 964 #else 965 static YYSIZE_T 966 yystrlen (yystr) 967 const char *yystr; 968 #endif 969 { 970 YYSIZE_T yylen; 971 for (yylen = 0; yystr[yylen]; yylen++) 972 continue; 973 return yylen; 974 } 975 # endif 976 # endif 977 978 # ifndef yystpcpy 979 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE 980 # define yystpcpy stpcpy 981 # else 982 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in 983 YYDEST. */ 984 #if (defined __STDC__ || defined __C99__FUNC__ \ 985 || defined __cplusplus || defined _MSC_VER) 986 static char * 987 yystpcpy (char *yydest, const char *yysrc) 988 #else 989 static char * 990 yystpcpy (yydest, yysrc) 991 char *yydest; 992 const char *yysrc; 993 #endif 994 { 995 char *yyd = yydest; 996 const char *yys = yysrc; 997 998 while ((*yyd++ = *yys++) != '\0') 999 continue; 1000 1001 return yyd - 1; 1002 } 1003 # endif 1004 # endif 1005 1006 # ifndef yytnamerr 1007 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary 1008 quotes and backslashes, so that it's suitable for yyerror. The 1009 heuristic is that double-quoting is unnecessary unless the string 1010 contains an apostrophe, a comma, or backslash (other than 1011 backslash-backslash). YYSTR is taken from yytname. If YYRES is 1012 null, do not copy; instead, return the length of what the result 1013 would have been. */ 1014 static YYSIZE_T 1015 yytnamerr (char *yyres, const char *yystr) 1016 { 1017 if (*yystr == '"') 1018 { 1019 YYSIZE_T yyn = 0; 1020 char const *yyp = yystr; 1021 1022 for (;;) 1023 switch (*++yyp) 1024 { 1025 case '\'': 1026 case ',': 1027 goto do_not_strip_quotes; 1028 1029 case '\\': 1030 if (*++yyp != '\\') 1031 goto do_not_strip_quotes; 1032 /* Fall through. */ 1033 default: 1034 if (yyres) 1035 yyres[yyn] = *yyp; 1036 yyn++; 1037 break; 1038 1039 case '"': 1040 if (yyres) 1041 yyres[yyn] = '\0'; 1042 return yyn; 1043 } 1044 do_not_strip_quotes: ; 1045 } 1046 1047 if (! yyres) 1048 return yystrlen (yystr); 1049 1050 return yystpcpy (yyres, yystr) - yyres; 1051 } 1052 # endif 1053 1054 /* Copy into YYRESULT an error message about the unexpected token 1055 YYCHAR while in state YYSTATE. Return the number of bytes copied, 1056 including the terminating null byte. If YYRESULT is null, do not 1057 copy anything; just return the number of bytes that would be 1058 copied. As a special case, return 0 if an ordinary "syntax error" 1059 message will do. Return YYSIZE_MAXIMUM if overflow occurs during 1060 size calculation. */ 1061 static YYSIZE_T 1062 yysyntax_error (char *yyresult, int yystate, int yychar) 1063 { 1064 int yyn = yypact[yystate]; 1065 1066 if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) 1067 return 0; 1068 else 1069 { 1070 int yytype = YYTRANSLATE (yychar); 1071 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); 1072 YYSIZE_T yysize = yysize0; 1073 YYSIZE_T yysize1; 1074 int yysize_overflow = 0; 1075 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; 1076 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; 1077 int yyx; 1078 1079 # if 0 1080 /* This is so xgettext sees the translatable formats that are 1081 constructed on the fly. */ 1082 YY_("syntax error, unexpected %s"); 1083 YY_("syntax error, unexpected %s, expecting %s"); 1084 YY_("syntax error, unexpected %s, expecting %s or %s"); 1085 YY_("syntax error, unexpected %s, expecting %s or %s or %s"); 1086 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); 1087 # endif 1088 char *yyfmt; 1089 char const *yyf; 1090 static char const yyunexpected[] = "syntax error, unexpected %s"; 1091 static char const yyexpecting[] = ", expecting %s"; 1092 static char const yyor[] = " or %s"; 1093 char yyformat[sizeof yyunexpected 1094 + sizeof yyexpecting - 1 1095 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) 1096 * (sizeof yyor - 1))]; 1097 char const *yyprefix = yyexpecting; 1098 1099 /* Start YYX at -YYN if negative to avoid negative indexes in 1100 YYCHECK. */ 1101 int yyxbegin = yyn < 0 ? -yyn : 0; 1102 1103 /* Stay within bounds of both yycheck and yytname. */ 1104 int yychecklim = YYLAST - yyn + 1; 1105 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; 1106 int yycount = 1; 1107 1108 yyarg[0] = yytname[yytype]; 1109 yyfmt = yystpcpy (yyformat, yyunexpected); 1110 1111 for (yyx = yyxbegin; yyx < yyxend; ++yyx) 1112 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) 1113 { 1114 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) 1115 { 1116 yycount = 1; 1117 yysize = yysize0; 1118 yyformat[sizeof yyunexpected - 1] = '\0'; 1119 break; 1120 } 1121 yyarg[yycount++] = yytname[yyx]; 1122 yysize1 = yysize + yytnamerr (0, yytname[yyx]); 1123 yysize_overflow |= (yysize1 < yysize); 1124 yysize = yysize1; 1125 yyfmt = yystpcpy (yyfmt, yyprefix); 1126 yyprefix = yyor; 1127 } 1128 1129 yyf = YY_(yyformat); 1130 yysize1 = yysize + yystrlen (yyf); 1131 yysize_overflow |= (yysize1 < yysize); 1132 yysize = yysize1; 1133 1134 if (yysize_overflow) 1135 return YYSIZE_MAXIMUM; 1136 1137 if (yyresult) 1138 { 1139 /* Avoid sprintf, as that infringes on the user's name space. 1140 Don't have undefined behavior even if the translation 1141 produced a string with the wrong number of "%s"s. */ 1142 char *yyp = yyresult; 1143 int yyi = 0; 1144 while ((*yyp = *yyf) != '\0') 1145 { 1146 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) 1147 { 1148 yyp += yytnamerr (yyp, yyarg[yyi++]); 1149 yyf += 2; 1150 } 1151 else 1152 { 1153 yyp++; 1154 yyf++; 1155 } 1156 } 1157 } 1158 return yysize; 1159 } 1160 } 1161 #endif /* YYERROR_VERBOSE */ 1162 1163 1164 /*-----------------------------------------------. 1165 | Release the memory associated to this symbol. | 1166 `-----------------------------------------------*/ 1167 1168 /*ARGSUSED*/ 1169 #if (defined __STDC__ || defined __C99__FUNC__ \ 1170 || defined __cplusplus || defined _MSC_VER) 1171 static void 1172 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, struct ktrfmt_parse_ctx *ctx) 1173 #else 1174 static void 1175 yydestruct (yymsg, yytype, yyvaluep, ctx) 1176 const char *yymsg; 1177 int yytype; 1178 YYSTYPE *yyvaluep; 1179 struct ktrfmt_parse_ctx *ctx; 1180 #endif 1181 { 1182 YYUSE (yyvaluep); 1183 YYUSE (ctx); 1184 1185 if (!yymsg) 1186 yymsg = "Deleting"; 1187 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); 1188 1189 switch (yytype) 1190 { 1191 1192 default: 1193 break; 1194 } 1195 } 1196 1197 /* Prevent warnings from -Wmissing-prototypes. */ 1198 #ifdef YYPARSE_PARAM 1199 #if defined __STDC__ || defined __cplusplus 1200 int yyparse (void *YYPARSE_PARAM); 1201 #else 1202 int yyparse (); 1203 #endif 1204 #else /* ! YYPARSE_PARAM */ 1205 #if defined __STDC__ || defined __cplusplus 1206 int yyparse (struct ktrfmt_parse_ctx *ctx); 1207 #else 1208 int yyparse (); 1209 #endif 1210 #endif /* ! YYPARSE_PARAM */ 1211 1212 1213 1214 1215 1216 /*-------------------------. 1217 | yyparse or yypush_parse. | 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 (struct ktrfmt_parse_ctx *ctx) 1235 #else 1236 int 1237 yyparse (ctx) 1238 struct ktrfmt_parse_ctx *ctx; 1239 #endif 1240 #endif 1241 { 1242 /* The lookahead symbol. */ 1243 int yychar; 1244 1245 /* The semantic value of the lookahead symbol. */ 1246 YYSTYPE yylval; 1247 1248 /* Number of syntax errors so far. */ 1249 int yynerrs; 1250 1251 int yystate; 1252 /* Number of tokens to shift before error messages enabled. */ 1253 int yyerrstatus; 1254 1255 /* The stacks and their tools: 1256 `yyss': related to states. 1257 `yyvs': related to semantic values. 1258 1259 Refer to the stacks thru separate pointers, to allow yyoverflow 1260 to reallocate them elsewhere. */ 1261 1262 /* The state stack. */ 1263 yytype_int16 yyssa[YYINITDEPTH]; 1264 yytype_int16 *yyss; 1265 yytype_int16 *yyssp; 1266 1267 /* The semantic value stack. */ 1268 YYSTYPE yyvsa[YYINITDEPTH]; 1269 YYSTYPE *yyvs; 1270 YYSTYPE *yyvsp; 1271 1272 YYSIZE_T yystacksize; 1273 1274 int yyn; 1275 int yyresult; 1276 /* Lookahead token as an internal (translated) token number. */ 1277 int yytoken; 1278 /* The variables used to return semantic value and location from the 1279 action routines. */ 1280 YYSTYPE yyval; 1281 1282 #if YYERROR_VERBOSE 1283 /* Buffer for error messages, and its allocated size. */ 1284 char yymsgbuf[128]; 1285 char *yymsg = yymsgbuf; 1286 YYSIZE_T yymsg_alloc = sizeof yymsgbuf; 1287 #endif 1288 1289 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) 1290 1291 /* The number of symbols on the RHS of the reduced rule. 1292 Keep to zero when no symbol should be popped. */ 1293 int yylen = 0; 1294 1295 yytoken = 0; 1296 yyss = yyssa; 1297 yyvs = yyvsa; 1298 yystacksize = YYINITDEPTH; 1299 1300 YYDPRINTF ((stderr, "Starting parse\n")); 1301 1302 yystate = 0; 1303 yyerrstatus = 0; 1304 yynerrs = 0; 1305 yychar = YYEMPTY; /* Cause a token to be read. */ 1306 1307 /* Initialize stack pointers. 1308 Waste one element of value and location stack 1309 so that they stay on the same level as the state stack. 1310 The wasted elements are never initialized. */ 1311 yyssp = yyss; 1312 yyvsp = yyvs; 1313 1314 goto yysetstate; 1315 1316 /*------------------------------------------------------------. 1317 | yynewstate -- Push a new state, which is found in yystate. | 1318 `------------------------------------------------------------*/ 1319 yynewstate: 1320 /* In all cases, when you get here, the value and location stacks 1321 have just been pushed. So pushing a state here evens the stacks. */ 1322 yyssp++; 1323 1324 yysetstate: 1325 *yyssp = yystate; 1326 1327 if (yyss + yystacksize - 1 <= yyssp) 1328 { 1329 /* Get the current used size of the three stacks, in elements. */ 1330 YYSIZE_T yysize = yyssp - yyss + 1; 1331 1332 #ifdef yyoverflow 1333 { 1334 /* Give user a chance to reallocate the stack. Use copies of 1335 these so that the &'s don't force the real ones into 1336 memory. */ 1337 YYSTYPE *yyvs1 = yyvs; 1338 yytype_int16 *yyss1 = yyss; 1339 1340 /* Each stack pointer address is followed by the size of the 1341 data in use in that stack, in bytes. This used to be a 1342 conditional around just the two extra args, but that might 1343 be undefined if yyoverflow is a macro. */ 1344 yyoverflow (YY_("memory exhausted"), 1345 &yyss1, yysize * sizeof (*yyssp), 1346 &yyvs1, yysize * sizeof (*yyvsp), 1347 &yystacksize); 1348 1349 yyss = yyss1; 1350 yyvs = yyvs1; 1351 } 1352 #else /* no yyoverflow */ 1353 # ifndef YYSTACK_RELOCATE 1354 goto yyexhaustedlab; 1355 # else 1356 /* Extend the stack our own way. */ 1357 if (YYMAXDEPTH <= yystacksize) 1358 goto yyexhaustedlab; 1359 yystacksize *= 2; 1360 if (YYMAXDEPTH < yystacksize) 1361 yystacksize = YYMAXDEPTH; 1362 1363 { 1364 yytype_int16 *yyss1 = yyss; 1365 union yyalloc *yyptr = 1366 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 1367 if (! yyptr) 1368 goto yyexhaustedlab; 1369 YYSTACK_RELOCATE (yyss_alloc, yyss); 1370 YYSTACK_RELOCATE (yyvs_alloc, yyvs); 1371 # undef YYSTACK_RELOCATE 1372 if (yyss1 != yyssa) 1373 YYSTACK_FREE (yyss1); 1374 } 1375 # endif 1376 #endif /* no yyoverflow */ 1377 1378 yyssp = yyss + yysize - 1; 1379 yyvsp = yyvs + yysize - 1; 1380 1381 YYDPRINTF ((stderr, "Stack size increased to %lu\n", 1382 (unsigned long int) yystacksize)); 1383 1384 if (yyss + yystacksize - 1 <= yyssp) 1385 YYABORT; 1386 } 1387 1388 YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 1389 1390 if (yystate == YYFINAL) 1391 YYACCEPT; 1392 1393 goto yybackup; 1394 1395 /*-----------. 1396 | yybackup. | 1397 `-----------*/ 1398 yybackup: 1399 1400 /* Do appropriate processing given the current state. Read a 1401 lookahead token if we need one and don't already have one. */ 1402 1403 /* First try to decide what to do without reference to lookahead token. */ 1404 yyn = yypact[yystate]; 1405 if (yyn == YYPACT_NINF) 1406 goto yydefault; 1407 1408 /* Not known => get a lookahead token if don't already have one. */ 1409 1410 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ 1411 if (yychar == YYEMPTY) 1412 { 1413 YYDPRINTF ((stderr, "Reading a token: ")); 1414 yychar = YYLEX; 1415 } 1416 1417 if (yychar <= YYEOF) 1418 { 1419 yychar = yytoken = YYEOF; 1420 YYDPRINTF ((stderr, "Now at end of input.\n")); 1421 } 1422 else 1423 { 1424 yytoken = YYTRANSLATE (yychar); 1425 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); 1426 } 1427 1428 /* If the proper action on seeing token YYTOKEN is to reduce or to 1429 detect an error, take that action. */ 1430 yyn += yytoken; 1431 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) 1432 goto yydefault; 1433 yyn = yytable[yyn]; 1434 if (yyn <= 0) 1435 { 1436 if (yyn == 0 || yyn == YYTABLE_NINF) 1437 goto yyerrlab; 1438 yyn = -yyn; 1439 goto yyreduce; 1440 } 1441 1442 /* Count tokens shifted since error; after three, turn off error 1443 status. */ 1444 if (yyerrstatus) 1445 yyerrstatus--; 1446 1447 /* Shift the lookahead token. */ 1448 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); 1449 1450 /* Discard the shifted token. */ 1451 yychar = YYEMPTY; 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 goto yyreduce; 1467 1468 1469 /*-----------------------------. 1470 | yyreduce -- Do a reduction. | 1471 `-----------------------------*/ 1472 yyreduce: 1473 /* yyn is the number of a rule to reduce with. */ 1474 yylen = yyr2[yyn]; 1475 1476 /* If YYLEN is nonzero, implement the default value of the action: 1477 `$$ = $1'. 1478 1479 Otherwise, the following line sets YYVAL to garbage. 1480 This behavior is undocumented and Bison 1481 users should not rely upon it. Assigning to YYVAL 1482 unconditionally makes the parser a bit smaller, and it avoids a 1483 GCC warning that YYVAL may be used uninitialized. */ 1484 yyval = yyvsp[1-yylen]; 1485 1486 1487 YY_REDUCE_PRINT (yyn); 1488 switch (yyn) 1489 { 1490 case 3: 1491 1492 /* Line 1455 of yacc.c */ 1493 #line 177 "ktrfmt.y" 1494 { 1495 ctx->var = (yyvsp[(1) - (1)].var); 1496 ;} 1497 break; 1498 1499 case 5: 1500 1501 /* Line 1455 of yacc.c */ 1502 #line 182 "ktrfmt.y" 1503 { 1504 evtr_var_t var; 1505 if (!(yyvsp[(1) - (1)].tok)->str) 1506 parse_err("out of memory"); 1507 var = evtr_var_new(uniq_varname()); 1508 var->val.type = EVTR_VAL_INT; 1509 errno = 0; 1510 var->val.num = strtoll((yyvsp[(1) - (1)].tok)->str, NULL, 0); 1511 if (errno) { 1512 parse_err("Can't parse numeric constant '%s'", (yyvsp[(1) - (1)].tok)->str); 1513 } 1514 (yyval.var) = var; 1515 tok_free((yyvsp[(1) - (1)].tok)); 1516 ;} 1517 break; 1518 1519 case 6: 1520 1521 /* Line 1455 of yacc.c */ 1522 #line 196 "ktrfmt.y" 1523 { 1524 evtr_var_t var; 1525 if (!(yyvsp[(1) - (1)].tok)->str) 1526 parse_err("out of memory"); 1527 var = evtr_var_new(uniq_varname()); 1528 var->val.type = EVTR_VAL_STR; 1529 var->val.str = (yyvsp[(1) - (1)].tok)->str; 1530 if (!var->val.str) { 1531 parse_err("out of memory"); 1532 } 1533 (yyval.var) = var; 1534 tok_free((yyvsp[(1) - (1)].tok)); 1535 ;} 1536 break; 1537 1538 case 7: 1539 1540 /* Line 1455 of yacc.c */ 1541 #line 210 "ktrfmt.y" 1542 { 1543 evtr_var_t ctor; 1544 ctor = evtr_var_new(uniq_varname()); 1545 ctor->val.type = EVTR_VAL_CTOR; 1546 ctor->val.ctor.name = NULL; 1547 TAILQ_INIT(&ctor->val.ctor.args); 1548 TAILQ_INSERT_HEAD(&ctor->val.ctor.args, &(yyvsp[(1) - (1)].var)->val, link); 1549 (yyval.var) = ctor; 1550 ;} 1551 break; 1552 1553 case 8: 1554 1555 /* Line 1455 of yacc.c */ 1556 #line 219 "ktrfmt.y" 1557 { 1558 TAILQ_INSERT_HEAD(&(yyvsp[(2) - (2)].var)->val.ctor.args, &(yyvsp[(1) - (2)].var)->val, link); 1559 (yyval.var) = (yyvsp[(2) - (2)].var); 1560 ;} 1561 break; 1562 1563 case 9: 1564 1565 /* Line 1455 of yacc.c */ 1566 #line 224 "ktrfmt.y" 1567 { 1568 evtr_var_t var; 1569 if (!(yyvsp[(1) - (1)].tok)->str) 1570 parse_err("out of memory"); 1571 printd(PARSE, "TOK_CTOR\n"); 1572 printd(PARSE, "tok: %p, str = %p\n", (yyvsp[(1) - (1)].tok), (yyvsp[(1) - (1)].tok)->str); 1573 var = evtr_var_new(uniq_varname()); 1574 var->val.type = EVTR_VAL_CTOR; 1575 var->val.ctor.name = (yyvsp[(1) - (1)].tok)->str; 1576 TAILQ_INIT(&var->val.ctor.args); 1577 tok_free((yyvsp[(1) - (1)].tok)); 1578 (yyval.var) = var; 1579 ;} 1580 break; 1581 1582 case 10: 1583 1584 /* Line 1455 of yacc.c */ 1585 #line 237 "ktrfmt.y" 1586 { 1587 evtr_variable_value_t val; 1588 if (!(yyvsp[(1) - (2)].tok)->str) 1589 parse_err("out of memory"); 1590 printd(PARSE, "TOK_CTOR\n"); 1591 printd(PARSE, "tok: %p, str = %p\n", (yyvsp[(1) - (2)].tok), (yyvsp[(1) - (2)].tok)->str); 1592 (yyvsp[(2) - (2)].var)->val.ctor.name = (yyvsp[(1) - (2)].tok)->str; 1593 (yyval.var) = (yyvsp[(2) - (2)].var); 1594 printd(PARSE, "CTOR: %s\n", (yyvsp[(1) - (2)].tok)->str); 1595 TAILQ_FOREACH(val, &(yyvsp[(2) - (2)].var)->val.ctor.args, link) { 1596 switch (val->type) { 1597 case EVTR_VAL_INT: 1598 printd(PARSE, "\t%jd\n", val->num); 1599 break; 1600 case EVTR_VAL_STR: 1601 printd(PARSE, "\t\"%s\"\n", val->str); 1602 break; 1603 case EVTR_VAL_NIL: 1604 assert(!"can't get here"); 1605 default: 1606 ; 1607 } 1608 } 1609 ;} 1610 break; 1611 1612 case 11: 1613 1614 /* Line 1455 of yacc.c */ 1615 #line 262 "ktrfmt.y" 1616 { 1617 evtr_var_t var; 1618 if (!(yyvsp[(1) - (1)].tok)->str) 1619 parse_err("out of memory"); 1620 printd(PARSE, "TOK_ID\n"); 1621 printd(PARSE, "tok: %p, str = %p\n", (yyvsp[(1) - (1)].tok), (yyvsp[(1) - (1)].tok)->str); 1622 var = symtab_find(ctx->symtab, (yyvsp[(1) - (1)].tok)->str); 1623 if (!var) { 1624 if (!(var = evtr_var_new((yyvsp[(1) - (1)].tok)->str))) { 1625 tok_free((yyvsp[(1) - (1)].tok)); 1626 parse_err("out of memory"); 1627 } 1628 printd(PARSE, "creating var %s\n", (yyvsp[(1) - (1)].tok)->str); 1629 symtab_insert(ctx->symtab, (yyvsp[(1) - (1)].tok)->str, var); 1630 } 1631 (yyval.var) = var; 1632 tok_free((yyvsp[(1) - (1)].tok)); 1633 ;} 1634 break; 1635 1636 case 12: 1637 1638 /* Line 1455 of yacc.c */ 1639 #line 280 "ktrfmt.y" 1640 { 1641 (yyval.var) = (yyvsp[(1) - (1)].var); 1642 ;} 1643 break; 1644 1645 case 13: 1646 1647 /* Line 1455 of yacc.c */ 1648 #line 284 "ktrfmt.y" 1649 { 1650 evtr_var_t var; 1651 1652 if (index_hash(ctx, (yyvsp[(1) - (4)].var)->name, &(yyvsp[(3) - (4)].var)->val, &var)) 1653 YYABORT; 1654 (yyval.var) = var; 1655 ;} 1656 break; 1657 1658 case 14: 1659 1660 /* Line 1455 of yacc.c */ 1661 #line 291 "ktrfmt.y" 1662 { 1663 evtr_var_t var, tmp; 1664 if (!(yyvsp[(3) - (3)].tok)->str) 1665 parse_err("out of memory"); 1666 tmp = evtr_var_new(uniq_varname()); 1667 tmp->val.type = EVTR_VAL_STR; 1668 tmp->val.str = (yyvsp[(3) - (3)].tok)->str; 1669 1670 if (index_hash(ctx, (yyvsp[(1) - (3)].var)->name, &tmp->val, &var)) 1671 YYABORT; 1672 tok_free((yyvsp[(3) - (3)].tok)); 1673 (yyval.var) = var; 1674 ;} 1675 break; 1676 1677 case 15: 1678 1679 /* Line 1455 of yacc.c */ 1680 #line 304 "ktrfmt.y" 1681 { 1682 (yyval.var) = (yyvsp[(1) - (1)].var); 1683 ;} 1684 break; 1685 1686 case 16: 1687 1688 /* Line 1455 of yacc.c */ 1689 #line 308 "ktrfmt.y" 1690 { 1691 (yyval.var) = (yyvsp[(1) - (1)].var); 1692 ;} 1693 break; 1694 1695 case 17: 1696 1697 /* Line 1455 of yacc.c */ 1698 #line 312 "ktrfmt.y" 1699 { 1700 (yyvsp[(1) - (3)].var)->val = (yyvsp[(3) - (3)].var)->val; 1701 ctx->ev->type = EVTR_TYPE_STMT; 1702 ctx->ev->stmt.var = (yyvsp[(1) - (3)].var); 1703 ctx->ev->stmt.val = &(yyvsp[(3) - (3)].var)->val; 1704 ctx->ev->stmt.op = EVTR_OP_SET; 1705 ;} 1706 break; 1707 1708 case 18: 1709 1710 /* Line 1455 of yacc.c */ 1711 #line 319 "ktrfmt.y" 1712 { 1713 (yyvsp[(1) - (3)].var)->val = (yyvsp[(3) - (3)].var)->val; 1714 ctx->ev->type = EVTR_TYPE_STMT; 1715 ctx->ev->stmt.var = (yyvsp[(1) - (3)].var); 1716 ctx->ev->stmt.val = &(yyvsp[(3) - (3)].var)->val; 1717 ctx->ev->stmt.op = EVTR_OP_SET; 1718 ;} 1719 break; 1720 1721 case 19: 1722 1723 /* Line 1455 of yacc.c */ 1724 #line 327 "ktrfmt.y" 1725 { 1726 (yyval.na) = (yyvsp[(1) - (1)].na); 1727 ;} 1728 break; 1729 1730 1731 1732 /* Line 1455 of yacc.c */ 1733 #line 1734 "ktrfmt.tab.c" 1734 default: break; 1735 } 1736 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); 1737 1738 YYPOPSTACK (yylen); 1739 yylen = 0; 1740 YY_STACK_PRINT (yyss, yyssp); 1741 1742 *++yyvsp = yyval; 1743 1744 /* Now `shift' the result of the reduction. Determine what state 1745 that goes to, based on the state we popped back to and the rule 1746 number reduced by. */ 1747 1748 yyn = yyr1[yyn]; 1749 1750 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; 1751 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) 1752 yystate = yytable[yystate]; 1753 else 1754 yystate = yydefgoto[yyn - YYNTOKENS]; 1755 1756 goto yynewstate; 1757 1758 1759 /*------------------------------------. 1760 | yyerrlab -- here on detecting error | 1761 `------------------------------------*/ 1762 yyerrlab: 1763 /* If not already recovering from an error, report this error. */ 1764 if (!yyerrstatus) 1765 { 1766 ++yynerrs; 1767 #if ! YYERROR_VERBOSE 1768 yyerror (ctx, YY_("syntax error")); 1769 #else 1770 { 1771 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); 1772 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) 1773 { 1774 YYSIZE_T yyalloc = 2 * yysize; 1775 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) 1776 yyalloc = YYSTACK_ALLOC_MAXIMUM; 1777 if (yymsg != yymsgbuf) 1778 YYSTACK_FREE (yymsg); 1779 yymsg = (char *) YYSTACK_ALLOC (yyalloc); 1780 if (yymsg) 1781 yymsg_alloc = yyalloc; 1782 else 1783 { 1784 yymsg = yymsgbuf; 1785 yymsg_alloc = sizeof yymsgbuf; 1786 } 1787 } 1788 1789 if (0 < yysize && yysize <= yymsg_alloc) 1790 { 1791 (void) yysyntax_error (yymsg, yystate, yychar); 1792 yyerror (ctx, yymsg); 1793 } 1794 else 1795 { 1796 yyerror (ctx, YY_("syntax error")); 1797 if (yysize != 0) 1798 goto yyexhaustedlab; 1799 } 1800 } 1801 #endif 1802 } 1803 1804 1805 1806 if (yyerrstatus == 3) 1807 { 1808 /* If just tried and failed to reuse lookahead token after an 1809 error, discard it. */ 1810 1811 if (yychar <= YYEOF) 1812 { 1813 /* Return failure if at end of input. */ 1814 if (yychar == YYEOF) 1815 YYABORT; 1816 } 1817 else 1818 { 1819 yydestruct ("Error: discarding", 1820 yytoken, &yylval, ctx); 1821 yychar = YYEMPTY; 1822 } 1823 } 1824 1825 /* Else will try to reuse lookahead token after shifting the error 1826 token. */ 1827 goto yyerrlab1; 1828 1829 1830 /*---------------------------------------------------. 1831 | yyerrorlab -- error raised explicitly by YYERROR. | 1832 `---------------------------------------------------*/ 1833 yyerrorlab: 1834 1835 /* Pacify compilers like GCC when the user code never invokes 1836 YYERROR and the label yyerrorlab therefore never appears in user 1837 code. */ 1838 if (/*CONSTCOND*/ 0) 1839 goto yyerrorlab; 1840 1841 /* Do not reclaim the symbols of the rule which action triggered 1842 this YYERROR. */ 1843 YYPOPSTACK (yylen); 1844 yylen = 0; 1845 YY_STACK_PRINT (yyss, yyssp); 1846 yystate = *yyssp; 1847 goto yyerrlab1; 1848 1849 1850 /*-------------------------------------------------------------. 1851 | yyerrlab1 -- common code for both syntax error and YYERROR. | 1852 `-------------------------------------------------------------*/ 1853 yyerrlab1: 1854 yyerrstatus = 3; /* Each real token shifted decrements this. */ 1855 1856 for (;;) 1857 { 1858 yyn = yypact[yystate]; 1859 if (yyn != YYPACT_NINF) 1860 { 1861 yyn += YYTERROR; 1862 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) 1863 { 1864 yyn = yytable[yyn]; 1865 if (0 < yyn) 1866 break; 1867 } 1868 } 1869 1870 /* Pop the current state because it cannot handle the error token. */ 1871 if (yyssp == yyss) 1872 YYABORT; 1873 1874 1875 yydestruct ("Error: popping", 1876 yystos[yystate], yyvsp, ctx); 1877 YYPOPSTACK (1); 1878 yystate = *yyssp; 1879 YY_STACK_PRINT (yyss, yyssp); 1880 } 1881 1882 *++yyvsp = yylval; 1883 1884 1885 /* Shift the error token. */ 1886 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); 1887 1888 yystate = yyn; 1889 goto yynewstate; 1890 1891 1892 /*-------------------------------------. 1893 | yyacceptlab -- YYACCEPT comes here. | 1894 `-------------------------------------*/ 1895 yyacceptlab: 1896 yyresult = 0; 1897 goto yyreturn; 1898 1899 /*-----------------------------------. 1900 | yyabortlab -- YYABORT comes here. | 1901 `-----------------------------------*/ 1902 yyabortlab: 1903 yyresult = 1; 1904 goto yyreturn; 1905 1906 #if !defined(yyoverflow) || YYERROR_VERBOSE 1907 /*-------------------------------------------------. 1908 | yyexhaustedlab -- memory exhaustion comes here. | 1909 `-------------------------------------------------*/ 1910 yyexhaustedlab: 1911 yyerror (ctx, YY_("memory exhausted")); 1912 yyresult = 2; 1913 /* Fall through. */ 1914 #endif 1915 1916 yyreturn: 1917 if (yychar != YYEMPTY) 1918 yydestruct ("Cleanup: discarding lookahead", 1919 yytoken, &yylval, ctx); 1920 /* Do not reclaim the symbols of the rule which action triggered 1921 this YYABORT or YYACCEPT. */ 1922 YYPOPSTACK (yylen); 1923 YY_STACK_PRINT (yyss, yyssp); 1924 while (yyssp != yyss) 1925 { 1926 yydestruct ("Cleanup: popping", 1927 yystos[*yyssp], yyvsp, ctx); 1928 YYPOPSTACK (1); 1929 } 1930 #ifndef yyoverflow 1931 if (yyss != yyssa) 1932 YYSTACK_FREE (yyss); 1933 #endif 1934 #if YYERROR_VERBOSE 1935 if (yymsg != yymsgbuf) 1936 YYSTACK_FREE (yymsg); 1937 #endif 1938 /* Make sure YYID is used. */ 1939 return YYID (yyresult); 1940 } 1941 1942 1943 1944 /* Line 1675 of yacc.c */ 1945 #line 332 "ktrfmt.y" 1946 1947 1948 void * __ktrfmt_scan_string(const char *); 1949 void __ktrfmt_delete_buffer(void *); 1950 1951 void 1952 __ktrfmt_error (struct ktrfmt_parse_ctx *ctx, const char *s) 1953 { 1954 do_parse_err(ctx, s); 1955 } 1956 1957 int 1958 parse_string(evtr_event_t ev, struct symtab *symtab, const char *str, 1959 char *errbuf, size_t errbufsz) 1960 { 1961 void *bufstate; 1962 int ret; 1963 struct ktrfmt_parse_ctx ctx; 1964 1965 printd(PARSE, "parsing \"%s\"\n", str); 1966 ctx.ev = ev; 1967 ctx.symtab = symtab; 1968 ctx.errbuf = errbuf; 1969 ctx.errbuf[0] = '\0'; 1970 ctx.errbufsz = errbufsz; 1971 ctx.err = 0; 1972 bufstate = __ktrfmt_scan_string(str); 1973 ret = __ktrfmt_parse(&ctx); 1974 __ktrfmt_delete_buffer(bufstate); 1975 1976 return ret; 1977 } 1978 1979 int 1980 parse_var(const char *str, struct symtab *symtab, struct evtr_variable **var, 1981 char *errbuf, size_t errbufsz) 1982 { 1983 void *bufstate; 1984 int ret; 1985 struct ktrfmt_parse_ctx ctx; 1986 1987 printd(PARSE, "parsing \"%s\"\n", str); 1988 ctx.ev = NULL; 1989 ctx.symtab = symtab; 1990 ctx.var = NULL; 1991 ctx.errbuf = errbuf; 1992 ctx.errbuf[0] = '\0'; 1993 ctx.errbufsz = errbufsz; 1994 ctx.err = 0; 1995 bufstate = __ktrfmt_scan_string(str); 1996 ret = __ktrfmt_parse(&ctx); 1997 __ktrfmt_delete_buffer(bufstate); 1998 1999 *var = ctx.var; 2000 return ret; 2001 } 2002 2003