2 /* A Bison parser, made by GNU Bison 2.4.1. */
4 /* Skeleton implementation for Bison's Yacc-like parsers in C
6 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
7 Free Software Foundation, Inc.
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.
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.
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/>. */
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.
32 This special exception was added by the Free Software Foundation in
33 version 2.2 of Bison. */
35 /* C LALR(1) parser skeleton written by Richard Stallman, by
36 simplifying the original so-called "semantic" parser. */
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. */
45 /* Identify Bison output. */
49 #define YYBISON_VERSION "2.4.1"
52 #define YYSKELETON_NAME "yacc.c"
63 /* Using locations. */
64 #define YYLSP_NEEDED 0
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
76 /* Copy the first part of user declarations. */
78 /* Line 189 of yacc.c */
87 #include <sys/queue.h>
91 #include "ktrfmt.tab.h"
94 struct ktrfmt_parse_ctx {
95 struct symtab *symtab;
96 struct evtr_variable *var;
97 struct evtr_variable_value *val;
104 int __ktrfmtlex(YYSTYPE *);
105 #define __ktrfmt_lex __ktrfmtlex
107 void __ktrfmt_error (struct ktrfmt_parse_ctx *, const char *);
109 static void do_parse_err(struct ktrfmt_parse_ctx *, const char *, ...)
114 do_parse_err(struct ktrfmt_parse_ctx *ctx, const char *fmt, ...)
119 vsnprintf(ctx->errbuf, ctx->errbufsz, fmt, ap);
124 #define parse_err(fmt, ...) \
126 do_parse_err(ctx, fmt, ##__VA_ARGS__); \
131 struct evtr_variable *
132 evtr_var_new(const char *name)
134 struct evtr_variable *var;
136 var = calloc(1, sizeof(*var));
138 if (!(var->name = strdup(name))) {
142 var->val.type = EVTR_VAL_NIL;
148 * XXX: should be reentrant
155 static char buf[100];
158 snprintf(buf, sizeof(buf), "@%ld", serno);
164 index_hash(struct ktrfmt_parse_ctx *ctx, const char *hashname,
165 evtr_variable_value_t val, evtr_var_t *_var)
169 hsh = symtab_find(ctx->symtab, hashname);
170 if (hsh->val.type == EVTR_VAL_NIL) {
171 /* it's probably the first time we see this "variable" */
172 printd(PARSE, "creating hash for %s\n", hsh->name);
173 hsh->val.type = EVTR_VAL_HASH;
174 hsh->val.hashtab = hash_new();
175 } else if (hsh->val.type != EVTR_VAL_HASH) {
176 printd(PARSE, "trying to use type %d as hash\n", hsh->val.type);
179 if (val->type == EVTR_VAL_INT) {
181 printd(PARSE, "looking up %s[%jd] in %p\n", hsh->name,
182 val->num, hsh->val.hashtab);
183 } else if (val->type == EVTR_VAL_STR) {
184 key = (uintptr_t)val->str;
185 printd(PARSE, "looking up %s[\"%s\"] in %p\n", hsh->name,
186 val->str, hsh->val.hashtab);
188 do_parse_err(ctx, "trying to index hash '%s' with "
189 "non-supported value", hashname);
193 if (hash_find(hsh->val.hashtab, key, &ret)) {
194 printd(PARSE, "didn't find it\n");
195 var = evtr_var_new(uniq_varname());
197 printd(PARSE, "inserting it as %s\n", var->name);
198 if (!hash_insert(hsh->val.hashtab, key,
200 do_parse_err(ctx, "can't insert temporary "
201 "variable into hash\n");
204 symtab_insert(ctx->symtab, var->name, var);
206 do_parse_err(ctx, "out of memory");
209 var = (struct evtr_variable *)ret;
212 fprintf(stderr, "no var!\n");
222 /* Line 189 of yacc.c */
223 #line 221 "ktrfmt.tab.c"
225 /* Enabling traces. */
230 /* Enabling verbose error messages. */
231 #ifdef YYERROR_VERBOSE
232 # undef YYERROR_VERBOSE
233 # define YYERROR_VERBOSE 1
235 # define YYERROR_VERBOSE 1
238 /* Enabling the token table. */
239 #ifndef YYTOKEN_TABLE
240 # define YYTOKEN_TABLE 0
247 /* Put the tokens into the symbol table, so that GDB and other debuggers
255 TOK_LEFT_BRACK = 263,
256 TOK_RIGHT_BRACK = 264,
263 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
264 typedef union YYSTYPE
267 /* Line 214 of yacc.c */
271 struct evtr_variable *var;
272 struct evtr_variable_value *val;
277 /* Line 214 of yacc.c */
278 #line 276 "ktrfmt.tab.c"
280 # define YYSTYPE_IS_TRIVIAL 1
281 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
282 # define YYSTYPE_IS_DECLARED 1
286 /* Copy the second part of user declarations. */
289 /* Line 264 of yacc.c */
290 #line 288 "ktrfmt.tab.c"
297 typedef YYTYPE_UINT8 yytype_uint8;
299 typedef unsigned char yytype_uint8;
303 typedef YYTYPE_INT8 yytype_int8;
304 #elif (defined __STDC__ || defined __C99__FUNC__ \
305 || defined __cplusplus || defined _MSC_VER)
306 typedef signed char yytype_int8;
308 typedef short int yytype_int8;
312 typedef YYTYPE_UINT16 yytype_uint16;
314 typedef unsigned short int yytype_uint16;
318 typedef YYTYPE_INT16 yytype_int16;
320 typedef short int yytype_int16;
324 # ifdef __SIZE_TYPE__
325 # define YYSIZE_T __SIZE_TYPE__
326 # elif defined size_t
327 # define YYSIZE_T size_t
328 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
329 || defined __cplusplus || defined _MSC_VER)
330 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
331 # define YYSIZE_T size_t
333 # define YYSIZE_T unsigned int
337 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
342 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
343 # define YY_(msgid) dgettext ("bison-runtime", msgid)
347 # define YY_(msgid) msgid
351 /* Suppress unused-variable warnings by "using" E. */
352 #if ! defined lint || defined __GNUC__
353 # define YYUSE(e) ((void) (e))
355 # define YYUSE(e) /* empty */
358 /* Identity function, used to suppress warnings about constant conditions. */
362 #if (defined __STDC__ || defined __C99__FUNC__ \
363 || defined __cplusplus || defined _MSC_VER)
376 #if ! defined yyoverflow || YYERROR_VERBOSE
378 /* The parser invokes alloca or malloc; define the necessary symbols. */
380 # ifdef YYSTACK_USE_ALLOCA
381 # if YYSTACK_USE_ALLOCA
383 # define YYSTACK_ALLOC __builtin_alloca
384 # elif defined __BUILTIN_VA_ARG_INCR
385 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
387 # define YYSTACK_ALLOC __alloca
388 # elif defined _MSC_VER
389 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
390 # define alloca _alloca
392 # define YYSTACK_ALLOC alloca
393 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
394 || defined __cplusplus || defined _MSC_VER)
395 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
404 # ifdef YYSTACK_ALLOC
405 /* Pacify GCC's `empty if-body' warning. */
406 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
407 # ifndef YYSTACK_ALLOC_MAXIMUM
408 /* The OS might guarantee only one guard page at the bottom of the stack,
409 and a page size can be as small as 4096 bytes. So we cannot safely
410 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
411 to allow for a few compiler-allocated temporary stack slots. */
412 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
415 # define YYSTACK_ALLOC YYMALLOC
416 # define YYSTACK_FREE YYFREE
417 # ifndef YYSTACK_ALLOC_MAXIMUM
418 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
420 # if (defined __cplusplus && ! defined _STDLIB_H \
421 && ! ((defined YYMALLOC || defined malloc) \
422 && (defined YYFREE || defined free)))
423 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
429 # define YYMALLOC malloc
430 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
431 || defined __cplusplus || defined _MSC_VER)
432 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
437 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
438 || defined __cplusplus || defined _MSC_VER)
439 void free (void *); /* INFRINGES ON USER NAME SPACE */
443 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
446 #if (! defined yyoverflow \
447 && (! defined __cplusplus \
448 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
450 /* A type that is properly aligned for any stack member. */
453 yytype_int16 yyss_alloc;
457 /* The size of the maximum gap between one aligned stack and the next. */
458 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
460 /* The size of an array large to enough to hold all stacks, each with
462 # define YYSTACK_BYTES(N) \
463 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
464 + YYSTACK_GAP_MAXIMUM)
466 /* Copy COUNT objects from FROM to TO. The source and destination do
469 # if defined __GNUC__ && 1 < __GNUC__
470 # define YYCOPY(To, From, Count) \
471 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
473 # define YYCOPY(To, From, Count) \
477 for (yyi = 0; yyi < (Count); yyi++) \
478 (To)[yyi] = (From)[yyi]; \
484 /* Relocate STACK from its old location to the new one. The
485 local variables YYSIZE and YYSTACKSIZE give the old and new number of
486 elements in the stack, and YYPTR gives the new location of the
487 stack. Advance YYPTR to a properly aligned location for the next
489 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
492 YYSIZE_T yynewbytes; \
493 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
494 Stack = &yyptr->Stack_alloc; \
495 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
496 yyptr += yynewbytes / sizeof (*yyptr); \
502 /* YYFINAL -- State number of the termination state. */
504 /* YYLAST -- Last index in YYTABLE. */
507 /* YYNTOKENS -- Number of terminals. */
509 /* YYNNTS -- Number of nonterminals. */
511 /* YYNRULES -- Number of rules. */
513 /* YYNRULES -- Number of states. */
516 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
518 #define YYMAXUTOK 265
520 #define YYTRANSLATE(YYX) \
521 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
523 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
524 static const yytype_uint8 yytranslate[] =
526 0, 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, 2, 2, 2, 2,
549 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
550 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
551 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
556 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
558 static const yytype_uint8 yyprhs[] =
560 0, 0, 3, 5, 7, 9, 11, 13, 15, 18,
561 20, 23, 25, 27, 32, 36, 38, 40, 44, 48
564 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
565 static const yytype_int8 yyrhs[] =
567 12, 0, -1, 13, -1, 19, -1, 21, -1, 5,
568 -1, 6, -1, 14, -1, 14, 15, -1, 4, -1,
569 4, 15, -1, 3, -1, 14, -1, 18, 8, 18,
570 9, -1, 18, 10, 3, -1, 17, -1, 18, -1,
571 19, 7, 14, -1, 19, 7, 16, -1, 20, -1
574 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
575 static const yytype_uint16 yyrline[] =
577 0, 175, 175, 177, 180, 182, 196, 210, 219, 224,
578 237, 262, 280, 284, 291, 304, 308, 312, 319, 327
582 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
583 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
584 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
585 static const char *const yytname[] =
587 "$end", "error", "$undefined", "TOK_ID", "TOK_CTOR", "TOK_INT",
588 "TOK_STR", "TOK_EQ", "TOK_LEFT_BRACK", "TOK_RIGHT_BRACK", "TOK_DOT",
589 "$accept", "input", "stmt", "constant", "ctor_args", "construct_expr",
590 "primary_expr", "postfix_expr", "unary_expr", "assign_expr", "expr", 0
595 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
597 static const yytype_uint16 yytoknum[] =
599 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
604 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
605 static const yytype_uint8 yyr1[] =
607 0, 11, 12, 13, 13, 14, 14, 15, 15, 16,
608 16, 17, 17, 18, 18, 18, 19, 20, 20, 21
611 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
612 static const yytype_uint8 yyr2[] =
614 0, 2, 1, 1, 1, 1, 1, 1, 2, 1,
615 2, 1, 1, 4, 3, 1, 1, 3, 3, 1
618 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
619 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
620 means the default is an error. */
621 static const yytype_uint8 yydefact[] =
623 0, 11, 5, 6, 0, 2, 12, 15, 16, 3,
624 19, 4, 1, 0, 0, 0, 0, 14, 9, 17,
628 /* YYDEFGOTO[NTERM-NUM]. */
629 static const yytype_int8 yydefgoto[] =
631 -1, 4, 5, 6, 23, 20, 7, 8, 9, 10,
635 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
637 #define YYPACT_NINF -17
638 static const yytype_int8 yypact[] =
640 -1, -17, -17, -17, 1, -17, -17, -17, 6, 8,
641 -17, -17, -17, -1, 16, 4, 3, -17, 12, -17,
642 -17, -17, 12, -17, -17
645 /* YYPGOTO[NTERM-NUM]. */
646 static const yytype_int8 yypgoto[] =
648 -17, -17, -17, -15, -16, -17, -17, 7, -17, -17,
652 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
653 positive, shift that token. If negative, reduce the rule which
654 number is the opposite. If zero, do what YYDEFACT says.
655 If YYTABLE_NINF, syntax error. */
656 #define YYTABLE_NINF -1
657 static const yytype_uint8 yytable[] =
659 19, 12, 1, 22, 2, 3, 24, 22, 18, 2,
660 3, 13, 21, 14, 13, 15, 14, 2, 3, 17,
664 static const yytype_uint8 yycheck[] =
666 15, 0, 3, 18, 5, 6, 22, 22, 4, 5,
667 6, 8, 9, 10, 8, 7, 10, 5, 6, 3,
671 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
672 symbol of state STATE-NUM. */
673 static const yytype_uint8 yystos[] =
675 0, 3, 5, 6, 12, 13, 14, 17, 18, 19,
676 20, 21, 0, 8, 10, 7, 18, 3, 4, 14,
680 #define yyerrok (yyerrstatus = 0)
681 #define yyclearin (yychar = YYEMPTY)
685 #define YYACCEPT goto yyacceptlab
686 #define YYABORT goto yyabortlab
687 #define YYERROR goto yyerrorlab
690 /* Like YYERROR except do call yyerror. This remains here temporarily
691 to ease the transition to the new meaning of YYERROR, for GCC.
692 Once GCC version 2 has supplanted version 1, this can go. */
694 #define YYFAIL goto yyerrlab
696 #define YYRECOVERING() (!!yyerrstatus)
698 #define YYBACKUP(Token, Value) \
700 if (yychar == YYEMPTY && yylen == 1) \
704 yytoken = YYTRANSLATE (yychar); \
710 yyerror (ctx, YY_("syntax error: cannot back up")); \
717 #define YYERRCODE 256
720 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
721 If N is 0, then set CURRENT to the empty location which ends
722 the previous symbol: RHS[0] (always defined). */
724 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
725 #ifndef YYLLOC_DEFAULT
726 # define YYLLOC_DEFAULT(Current, Rhs, N) \
730 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
731 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
732 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
733 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
737 (Current).first_line = (Current).last_line = \
738 YYRHSLOC (Rhs, 0).last_line; \
739 (Current).first_column = (Current).last_column = \
740 YYRHSLOC (Rhs, 0).last_column; \
746 /* YY_LOCATION_PRINT -- Print the location on the stream.
747 This macro was not mandated originally: define only if we know
748 we won't break user code: when these are the locations we know. */
750 #ifndef YY_LOCATION_PRINT
751 # if YYLTYPE_IS_TRIVIAL
752 # define YY_LOCATION_PRINT(File, Loc) \
753 fprintf (File, "%d.%d-%d.%d", \
754 (Loc).first_line, (Loc).first_column, \
755 (Loc).last_line, (Loc).last_column)
757 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
762 /* YYLEX -- calling `yylex' with the right arguments. */
765 # define YYLEX yylex (&yylval, YYLEX_PARAM)
767 # define YYLEX yylex (&yylval)
770 /* Enable debugging if requested. */
774 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
775 # define YYFPRINTF fprintf
778 # define YYDPRINTF(Args) \
784 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
788 YYFPRINTF (stderr, "%s ", Title); \
789 yy_symbol_print (stderr, \
791 YYFPRINTF (stderr, "\n"); \
796 /*--------------------------------.
797 | Print this symbol on YYOUTPUT. |
798 `--------------------------------*/
801 #if (defined __STDC__ || defined __C99__FUNC__ \
802 || defined __cplusplus || defined _MSC_VER)
804 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct ktrfmt_parse_ctx *ctx)
807 yy_symbol_value_print (yyoutput, yytype, yyvaluep, ctx)
810 YYSTYPE const * const yyvaluep;
811 struct ktrfmt_parse_ctx *ctx;
818 if (yytype < YYNTOKENS)
819 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
831 /*--------------------------------.
832 | Print this symbol on YYOUTPUT. |
833 `--------------------------------*/
835 #if (defined __STDC__ || defined __C99__FUNC__ \
836 || defined __cplusplus || defined _MSC_VER)
838 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct ktrfmt_parse_ctx *ctx)
841 yy_symbol_print (yyoutput, yytype, yyvaluep, ctx)
844 YYSTYPE const * const yyvaluep;
845 struct ktrfmt_parse_ctx *ctx;
848 if (yytype < YYNTOKENS)
849 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
851 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
853 yy_symbol_value_print (yyoutput, yytype, yyvaluep, ctx);
854 YYFPRINTF (yyoutput, ")");
857 /*------------------------------------------------------------------.
858 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
860 `------------------------------------------------------------------*/
862 #if (defined __STDC__ || defined __C99__FUNC__ \
863 || defined __cplusplus || defined _MSC_VER)
865 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
868 yy_stack_print (yybottom, yytop)
869 yytype_int16 *yybottom;
873 YYFPRINTF (stderr, "Stack now");
874 for (; yybottom <= yytop; yybottom++)
876 int yybot = *yybottom;
877 YYFPRINTF (stderr, " %d", yybot);
879 YYFPRINTF (stderr, "\n");
882 # define YY_STACK_PRINT(Bottom, Top) \
885 yy_stack_print ((Bottom), (Top)); \
889 /*------------------------------------------------.
890 | Report that the YYRULE is going to be reduced. |
891 `------------------------------------------------*/
893 #if (defined __STDC__ || defined __C99__FUNC__ \
894 || defined __cplusplus || defined _MSC_VER)
896 yy_reduce_print (YYSTYPE *yyvsp, int yyrule, struct ktrfmt_parse_ctx *ctx)
899 yy_reduce_print (yyvsp, yyrule, ctx)
902 struct ktrfmt_parse_ctx *ctx;
905 int yynrhs = yyr2[yyrule];
907 unsigned long int yylno = yyrline[yyrule];
908 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
910 /* The symbols being reduced. */
911 for (yyi = 0; yyi < yynrhs; yyi++)
913 YYFPRINTF (stderr, " $%d = ", yyi + 1);
914 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
915 &(yyvsp[(yyi + 1) - (yynrhs)])
917 YYFPRINTF (stderr, "\n");
921 # define YY_REDUCE_PRINT(Rule) \
924 yy_reduce_print (yyvsp, Rule, ctx); \
927 /* Nonzero means print parse trace. It is left uninitialized so that
928 multiple parsers can coexist. */
931 # define YYDPRINTF(Args)
932 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
933 # define YY_STACK_PRINT(Bottom, Top)
934 # define YY_REDUCE_PRINT(Rule)
935 #endif /* !YYDEBUG */
938 /* YYINITDEPTH -- initial size of the parser's stacks. */
940 # define YYINITDEPTH 200
943 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
944 if the built-in stack extension method is used).
946 Do not make this value too large; the results are undefined if
947 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
948 evaluated with infinite-precision integer arithmetic. */
951 # define YYMAXDEPTH 10000
959 # if defined __GLIBC__ && defined _STRING_H
960 # define yystrlen strlen
962 /* Return the length of YYSTR. */
963 #if (defined __STDC__ || defined __C99__FUNC__ \
964 || defined __cplusplus || defined _MSC_VER)
966 yystrlen (const char *yystr)
974 for (yylen = 0; yystr[yylen]; yylen++)
982 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
983 # define yystpcpy stpcpy
985 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
987 #if (defined __STDC__ || defined __C99__FUNC__ \
988 || defined __cplusplus || defined _MSC_VER)
990 yystpcpy (char *yydest, const char *yysrc)
993 yystpcpy (yydest, yysrc)
999 const char *yys = yysrc;
1001 while ((*yyd++ = *yys++) != '\0')
1010 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1011 quotes and backslashes, so that it's suitable for yyerror. The
1012 heuristic is that double-quoting is unnecessary unless the string
1013 contains an apostrophe, a comma, or backslash (other than
1014 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1015 null, do not copy; instead, return the length of what the result
1018 yytnamerr (char *yyres, const char *yystr)
1023 char const *yyp = yystr;
1030 goto do_not_strip_quotes;
1034 goto do_not_strip_quotes;
1047 do_not_strip_quotes: ;
1051 return yystrlen (yystr);
1053 return yystpcpy (yyres, yystr) - yyres;
1057 /* Copy into YYRESULT an error message about the unexpected token
1058 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1059 including the terminating null byte. If YYRESULT is null, do not
1060 copy anything; just return the number of bytes that would be
1061 copied. As a special case, return 0 if an ordinary "syntax error"
1062 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1063 size calculation. */
1065 yysyntax_error (char *yyresult, int yystate, int yychar)
1067 int yyn = yypact[yystate];
1069 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1073 int yytype = YYTRANSLATE (yychar);
1074 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1075 YYSIZE_T yysize = yysize0;
1077 int yysize_overflow = 0;
1078 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1079 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1083 /* This is so xgettext sees the translatable formats that are
1084 constructed on the fly. */
1085 YY_("syntax error, unexpected %s");
1086 YY_("syntax error, unexpected %s, expecting %s");
1087 YY_("syntax error, unexpected %s, expecting %s or %s");
1088 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1089 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1093 static char const yyunexpected[] = "syntax error, unexpected %s";
1094 static char const yyexpecting[] = ", expecting %s";
1095 static char const yyor[] = " or %s";
1096 char yyformat[sizeof yyunexpected
1097 + sizeof yyexpecting - 1
1098 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1099 * (sizeof yyor - 1))];
1100 char const *yyprefix = yyexpecting;
1102 /* Start YYX at -YYN if negative to avoid negative indexes in
1104 int yyxbegin = yyn < 0 ? -yyn : 0;
1106 /* Stay within bounds of both yycheck and yytname. */
1107 int yychecklim = YYLAST - yyn + 1;
1108 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1111 yyarg[0] = yytname[yytype];
1112 yyfmt = yystpcpy (yyformat, yyunexpected);
1114 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1115 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1117 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1121 yyformat[sizeof yyunexpected - 1] = '\0';
1124 yyarg[yycount++] = yytname[yyx];
1125 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1126 yysize_overflow |= (yysize1 < yysize);
1128 yyfmt = yystpcpy (yyfmt, yyprefix);
1132 yyf = YY_(yyformat);
1133 yysize1 = yysize + yystrlen (yyf);
1134 yysize_overflow |= (yysize1 < yysize);
1137 if (yysize_overflow)
1138 return YYSIZE_MAXIMUM;
1142 /* Avoid sprintf, as that infringes on the user's name space.
1143 Don't have undefined behavior even if the translation
1144 produced a string with the wrong number of "%s"s. */
1145 char *yyp = yyresult;
1147 while ((*yyp = *yyf) != '\0')
1149 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1151 yyp += yytnamerr (yyp, yyarg[yyi++]);
1164 #endif /* YYERROR_VERBOSE */
1167 /*-----------------------------------------------.
1168 | Release the memory associated to this symbol. |
1169 `-----------------------------------------------*/
1172 #if (defined __STDC__ || defined __C99__FUNC__ \
1173 || defined __cplusplus || defined _MSC_VER)
1175 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, struct ktrfmt_parse_ctx *ctx)
1178 yydestruct (yymsg, yytype, yyvaluep, ctx)
1182 struct ktrfmt_parse_ctx *ctx;
1190 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1200 /* Prevent warnings from -Wmissing-prototypes. */
1201 #ifdef YYPARSE_PARAM
1202 #if defined __STDC__ || defined __cplusplus
1203 int yyparse (void *YYPARSE_PARAM);
1207 #else /* ! YYPARSE_PARAM */
1208 #if defined __STDC__ || defined __cplusplus
1209 int yyparse (struct ktrfmt_parse_ctx *ctx);
1213 #endif /* ! YYPARSE_PARAM */
1219 /*-------------------------.
1220 | yyparse or yypush_parse. |
1221 `-------------------------*/
1223 #ifdef YYPARSE_PARAM
1224 #if (defined __STDC__ || defined __C99__FUNC__ \
1225 || defined __cplusplus || defined _MSC_VER)
1227 yyparse (void *YYPARSE_PARAM)
1230 yyparse (YYPARSE_PARAM)
1231 void *YYPARSE_PARAM;
1233 #else /* ! YYPARSE_PARAM */
1234 #if (defined __STDC__ || defined __C99__FUNC__ \
1235 || defined __cplusplus || defined _MSC_VER)
1237 yyparse (struct ktrfmt_parse_ctx *ctx)
1241 struct ktrfmt_parse_ctx *ctx;
1245 /* The lookahead symbol. */
1248 /* The semantic value of the lookahead symbol. */
1251 /* Number of syntax errors so far. */
1255 /* Number of tokens to shift before error messages enabled. */
1258 /* The stacks and their tools:
1259 `yyss': related to states.
1260 `yyvs': related to semantic values.
1262 Refer to the stacks thru separate pointers, to allow yyoverflow
1263 to reallocate them elsewhere. */
1265 /* The state stack. */
1266 yytype_int16 yyssa[YYINITDEPTH];
1268 yytype_int16 *yyssp;
1270 /* The semantic value stack. */
1271 YYSTYPE yyvsa[YYINITDEPTH];
1275 YYSIZE_T yystacksize;
1279 /* Lookahead token as an internal (translated) token number. */
1281 /* The variables used to return semantic value and location from the
1286 /* Buffer for error messages, and its allocated size. */
1288 char *yymsg = yymsgbuf;
1289 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1292 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1294 /* The number of symbols on the RHS of the reduced rule.
1295 Keep to zero when no symbol should be popped. */
1301 yystacksize = YYINITDEPTH;
1303 YYDPRINTF ((stderr, "Starting parse\n"));
1308 yychar = YYEMPTY; /* Cause a token to be read. */
1310 /* Initialize stack pointers.
1311 Waste one element of value and location stack
1312 so that they stay on the same level as the state stack.
1313 The wasted elements are never initialized. */
1319 /*------------------------------------------------------------.
1320 | yynewstate -- Push a new state, which is found in yystate. |
1321 `------------------------------------------------------------*/
1323 /* In all cases, when you get here, the value and location stacks
1324 have just been pushed. So pushing a state here evens the stacks. */
1330 if (yyss + yystacksize - 1 <= yyssp)
1332 /* Get the current used size of the three stacks, in elements. */
1333 YYSIZE_T yysize = yyssp - yyss + 1;
1337 /* Give user a chance to reallocate the stack. Use copies of
1338 these so that the &'s don't force the real ones into
1340 YYSTYPE *yyvs1 = yyvs;
1341 yytype_int16 *yyss1 = yyss;
1343 /* Each stack pointer address is followed by the size of the
1344 data in use in that stack, in bytes. This used to be a
1345 conditional around just the two extra args, but that might
1346 be undefined if yyoverflow is a macro. */
1347 yyoverflow (YY_("memory exhausted"),
1348 &yyss1, yysize * sizeof (*yyssp),
1349 &yyvs1, yysize * sizeof (*yyvsp),
1355 #else /* no yyoverflow */
1356 # ifndef YYSTACK_RELOCATE
1357 goto yyexhaustedlab;
1359 /* Extend the stack our own way. */
1360 if (YYMAXDEPTH <= yystacksize)
1361 goto yyexhaustedlab;
1363 if (YYMAXDEPTH < yystacksize)
1364 yystacksize = YYMAXDEPTH;
1367 yytype_int16 *yyss1 = yyss;
1368 union yyalloc *yyptr =
1369 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1371 goto yyexhaustedlab;
1372 YYSTACK_RELOCATE (yyss_alloc, yyss);
1373 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1374 # undef YYSTACK_RELOCATE
1376 YYSTACK_FREE (yyss1);
1379 #endif /* no yyoverflow */
1381 yyssp = yyss + yysize - 1;
1382 yyvsp = yyvs + yysize - 1;
1384 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1385 (unsigned long int) yystacksize));
1387 if (yyss + yystacksize - 1 <= yyssp)
1391 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1393 if (yystate == YYFINAL)
1403 /* Do appropriate processing given the current state. Read a
1404 lookahead token if we need one and don't already have one. */
1406 /* First try to decide what to do without reference to lookahead token. */
1407 yyn = yypact[yystate];
1408 if (yyn == YYPACT_NINF)
1411 /* Not known => get a lookahead token if don't already have one. */
1413 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1414 if (yychar == YYEMPTY)
1416 YYDPRINTF ((stderr, "Reading a token: "));
1420 if (yychar <= YYEOF)
1422 yychar = yytoken = YYEOF;
1423 YYDPRINTF ((stderr, "Now at end of input.\n"));
1427 yytoken = YYTRANSLATE (yychar);
1428 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1431 /* If the proper action on seeing token YYTOKEN is to reduce or to
1432 detect an error, take that action. */
1434 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1439 if (yyn == 0 || yyn == YYTABLE_NINF)
1445 /* Count tokens shifted since error; after three, turn off error
1450 /* Shift the lookahead token. */
1451 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1453 /* Discard the shifted token. */
1462 /*-----------------------------------------------------------.
1463 | yydefault -- do the default action for the current state. |
1464 `-----------------------------------------------------------*/
1466 yyn = yydefact[yystate];
1472 /*-----------------------------.
1473 | yyreduce -- Do a reduction. |
1474 `-----------------------------*/
1476 /* yyn is the number of a rule to reduce with. */
1479 /* If YYLEN is nonzero, implement the default value of the action:
1482 Otherwise, the following line sets YYVAL to garbage.
1483 This behavior is undocumented and Bison
1484 users should not rely upon it. Assigning to YYVAL
1485 unconditionally makes the parser a bit smaller, and it avoids a
1486 GCC warning that YYVAL may be used uninitialized. */
1487 yyval = yyvsp[1-yylen];
1490 YY_REDUCE_PRINT (yyn);
1495 /* Line 1455 of yacc.c */
1496 #line 177 "ktrfmt.y"
1498 ctx->var = (yyvsp[(1) - (1)].var);
1504 /* Line 1455 of yacc.c */
1505 #line 182 "ktrfmt.y"
1508 if (!(yyvsp[(1) - (1)].tok)->str)
1509 parse_err("out of memory");
1510 var = evtr_var_new(uniq_varname());
1511 var->val.type = EVTR_VAL_INT;
1513 var->val.num = strtoll((yyvsp[(1) - (1)].tok)->str, NULL, 0);
1515 parse_err("Can't parse numeric constant '%s'", (yyvsp[(1) - (1)].tok)->str);
1518 tok_free((yyvsp[(1) - (1)].tok));
1524 /* Line 1455 of yacc.c */
1525 #line 196 "ktrfmt.y"
1528 if (!(yyvsp[(1) - (1)].tok)->str)
1529 parse_err("out of memory");
1530 var = evtr_var_new(uniq_varname());
1531 var->val.type = EVTR_VAL_STR;
1532 var->val.str = (yyvsp[(1) - (1)].tok)->str;
1533 if (!var->val.str) {
1534 parse_err("out of memory");
1537 tok_free((yyvsp[(1) - (1)].tok));
1543 /* Line 1455 of yacc.c */
1544 #line 210 "ktrfmt.y"
1547 ctor = evtr_var_new(uniq_varname());
1548 ctor->val.type = EVTR_VAL_CTOR;
1549 ctor->val.ctor.name = NULL;
1550 TAILQ_INIT(&ctor->val.ctor.args);
1551 TAILQ_INSERT_HEAD(&ctor->val.ctor.args, &(yyvsp[(1) - (1)].var)->val, link);
1558 /* Line 1455 of yacc.c */
1559 #line 219 "ktrfmt.y"
1561 TAILQ_INSERT_HEAD(&(yyvsp[(2) - (2)].var)->val.ctor.args, &(yyvsp[(1) - (2)].var)->val, link);
1562 (yyval.var) = (yyvsp[(2) - (2)].var);
1568 /* Line 1455 of yacc.c */
1569 #line 224 "ktrfmt.y"
1572 if (!(yyvsp[(1) - (1)].tok)->str)
1573 parse_err("out of memory");
1574 printd(PARSE, "TOK_CTOR\n");
1575 printd(PARSE, "tok: %p, str = %p\n", (yyvsp[(1) - (1)].tok), (yyvsp[(1) - (1)].tok)->str);
1576 var = evtr_var_new(uniq_varname());
1577 var->val.type = EVTR_VAL_CTOR;
1578 var->val.ctor.name = (yyvsp[(1) - (1)].tok)->str;
1579 TAILQ_INIT(&var->val.ctor.args);
1580 tok_free((yyvsp[(1) - (1)].tok));
1587 /* Line 1455 of yacc.c */
1588 #line 237 "ktrfmt.y"
1590 evtr_variable_value_t val;
1591 if (!(yyvsp[(1) - (2)].tok)->str)
1592 parse_err("out of memory");
1593 printd(PARSE, "TOK_CTOR\n");
1594 printd(PARSE, "tok: %p, str = %p\n", (yyvsp[(1) - (2)].tok), (yyvsp[(1) - (2)].tok)->str);
1595 (yyvsp[(2) - (2)].var)->val.ctor.name = (yyvsp[(1) - (2)].tok)->str;
1596 (yyval.var) = (yyvsp[(2) - (2)].var);
1597 printd(PARSE, "CTOR: %s\n", (yyvsp[(1) - (2)].tok)->str);
1598 TAILQ_FOREACH(val, &(yyvsp[(2) - (2)].var)->val.ctor.args, link) {
1599 switch (val->type) {
1601 printd(PARSE, "\t%jd\n", val->num);
1604 printd(PARSE, "\t\"%s\"\n", val->str);
1607 assert(!"can't get here");
1617 /* Line 1455 of yacc.c */
1618 #line 262 "ktrfmt.y"
1621 if (!(yyvsp[(1) - (1)].tok)->str)
1622 parse_err("out of memory");
1623 printd(PARSE, "TOK_ID\n");
1624 printd(PARSE, "tok: %p, str = %p\n", (yyvsp[(1) - (1)].tok), (yyvsp[(1) - (1)].tok)->str);
1625 var = symtab_find(ctx->symtab, (yyvsp[(1) - (1)].tok)->str);
1627 if (!(var = evtr_var_new((yyvsp[(1) - (1)].tok)->str))) {
1628 tok_free((yyvsp[(1) - (1)].tok));
1629 parse_err("out of memory");
1631 printd(PARSE, "creating var %s\n", (yyvsp[(1) - (1)].tok)->str);
1632 symtab_insert(ctx->symtab, (yyvsp[(1) - (1)].tok)->str, var);
1635 tok_free((yyvsp[(1) - (1)].tok));
1641 /* Line 1455 of yacc.c */
1642 #line 280 "ktrfmt.y"
1644 (yyval.var) = (yyvsp[(1) - (1)].var);
1650 /* Line 1455 of yacc.c */
1651 #line 284 "ktrfmt.y"
1655 if (index_hash(ctx, (yyvsp[(1) - (4)].var)->name, &(yyvsp[(3) - (4)].var)->val, &var))
1663 /* Line 1455 of yacc.c */
1664 #line 291 "ktrfmt.y"
1666 evtr_var_t var, tmp;
1667 if (!(yyvsp[(3) - (3)].tok)->str)
1668 parse_err("out of memory");
1669 tmp = evtr_var_new(uniq_varname());
1670 tmp->val.type = EVTR_VAL_STR;
1671 tmp->val.str = (yyvsp[(3) - (3)].tok)->str;
1673 if (index_hash(ctx, (yyvsp[(1) - (3)].var)->name, &tmp->val, &var))
1675 tok_free((yyvsp[(3) - (3)].tok));
1682 /* Line 1455 of yacc.c */
1683 #line 304 "ktrfmt.y"
1685 (yyval.var) = (yyvsp[(1) - (1)].var);
1691 /* Line 1455 of yacc.c */
1692 #line 308 "ktrfmt.y"
1694 (yyval.var) = (yyvsp[(1) - (1)].var);
1700 /* Line 1455 of yacc.c */
1701 #line 312 "ktrfmt.y"
1703 (yyvsp[(1) - (3)].var)->val = (yyvsp[(3) - (3)].var)->val;
1704 ctx->ev->type = EVTR_TYPE_STMT;
1705 ctx->ev->stmt.var = (yyvsp[(1) - (3)].var);
1706 ctx->ev->stmt.val = &(yyvsp[(3) - (3)].var)->val;
1707 ctx->ev->stmt.op = EVTR_OP_SET;
1713 /* Line 1455 of yacc.c */
1714 #line 319 "ktrfmt.y"
1716 (yyvsp[(1) - (3)].var)->val = (yyvsp[(3) - (3)].var)->val;
1717 ctx->ev->type = EVTR_TYPE_STMT;
1718 ctx->ev->stmt.var = (yyvsp[(1) - (3)].var);
1719 ctx->ev->stmt.val = &(yyvsp[(3) - (3)].var)->val;
1720 ctx->ev->stmt.op = EVTR_OP_SET;
1726 /* Line 1455 of yacc.c */
1727 #line 327 "ktrfmt.y"
1729 (yyval.na) = (yyvsp[(1) - (1)].na);
1735 /* Line 1455 of yacc.c */
1736 #line 1734 "ktrfmt.tab.c"
1739 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1743 YY_STACK_PRINT (yyss, yyssp);
1747 /* Now `shift' the result of the reduction. Determine what state
1748 that goes to, based on the state we popped back to and the rule
1749 number reduced by. */
1753 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1754 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1755 yystate = yytable[yystate];
1757 yystate = yydefgoto[yyn - YYNTOKENS];
1762 /*------------------------------------.
1763 | yyerrlab -- here on detecting error |
1764 `------------------------------------*/
1766 /* If not already recovering from an error, report this error. */
1770 #if ! YYERROR_VERBOSE
1771 yyerror (ctx, YY_("syntax error"));
1774 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1775 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1777 YYSIZE_T yyalloc = 2 * yysize;
1778 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1779 yyalloc = YYSTACK_ALLOC_MAXIMUM;
1780 if (yymsg != yymsgbuf)
1781 YYSTACK_FREE (yymsg);
1782 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1784 yymsg_alloc = yyalloc;
1788 yymsg_alloc = sizeof yymsgbuf;
1792 if (0 < yysize && yysize <= yymsg_alloc)
1794 (void) yysyntax_error (yymsg, yystate, yychar);
1795 yyerror (ctx, yymsg);
1799 yyerror (ctx, YY_("syntax error"));
1801 goto yyexhaustedlab;
1809 if (yyerrstatus == 3)
1811 /* If just tried and failed to reuse lookahead token after an
1812 error, discard it. */
1814 if (yychar <= YYEOF)
1816 /* Return failure if at end of input. */
1817 if (yychar == YYEOF)
1822 yydestruct ("Error: discarding",
1823 yytoken, &yylval, ctx);
1828 /* Else will try to reuse lookahead token after shifting the error
1833 /*---------------------------------------------------.
1834 | yyerrorlab -- error raised explicitly by YYERROR. |
1835 `---------------------------------------------------*/
1838 /* Pacify compilers like GCC when the user code never invokes
1839 YYERROR and the label yyerrorlab therefore never appears in user
1841 if (/*CONSTCOND*/ 0)
1844 /* Do not reclaim the symbols of the rule which action triggered
1848 YY_STACK_PRINT (yyss, yyssp);
1853 /*-------------------------------------------------------------.
1854 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1855 `-------------------------------------------------------------*/
1857 yyerrstatus = 3; /* Each real token shifted decrements this. */
1861 yyn = yypact[yystate];
1862 if (yyn != YYPACT_NINF)
1865 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1873 /* Pop the current state because it cannot handle the error token. */
1878 yydestruct ("Error: popping",
1879 yystos[yystate], yyvsp, ctx);
1882 YY_STACK_PRINT (yyss, yyssp);
1888 /* Shift the error token. */
1889 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1895 /*-------------------------------------.
1896 | yyacceptlab -- YYACCEPT comes here. |
1897 `-------------------------------------*/
1902 /*-----------------------------------.
1903 | yyabortlab -- YYABORT comes here. |
1904 `-----------------------------------*/
1909 #if !defined(yyoverflow) || YYERROR_VERBOSE
1910 /*-------------------------------------------------.
1911 | yyexhaustedlab -- memory exhaustion comes here. |
1912 `-------------------------------------------------*/
1914 yyerror (ctx, YY_("memory exhausted"));
1920 if (yychar != YYEMPTY)
1921 yydestruct ("Cleanup: discarding lookahead",
1922 yytoken, &yylval, ctx);
1923 /* Do not reclaim the symbols of the rule which action triggered
1924 this YYABORT or YYACCEPT. */
1926 YY_STACK_PRINT (yyss, yyssp);
1927 while (yyssp != yyss)
1929 yydestruct ("Cleanup: popping",
1930 yystos[*yyssp], yyvsp, ctx);
1935 YYSTACK_FREE (yyss);
1938 if (yymsg != yymsgbuf)
1939 YYSTACK_FREE (yymsg);
1941 /* Make sure YYID is used. */
1942 return YYID (yyresult);
1947 /* Line 1675 of yacc.c */
1948 #line 332 "ktrfmt.y"
1951 void * __ktrfmt_scan_string(const char *);
1952 void __ktrfmt_delete_buffer(void *);
1955 __ktrfmt_error (struct ktrfmt_parse_ctx *ctx, const char *s)
1957 do_parse_err(ctx, s);
1961 parse_string(evtr_event_t ev, struct symtab *symtab, const char *str,
1962 char *errbuf, size_t errbufsz)
1966 struct ktrfmt_parse_ctx ctx;
1968 printd(PARSE, "parsing \"%s\"\n", str);
1970 ctx.symtab = symtab;
1971 ctx.errbuf = errbuf;
1972 ctx.errbuf[0] = '\0';
1973 ctx.errbufsz = errbufsz;
1975 bufstate = __ktrfmt_scan_string(str);
1976 ret = __ktrfmt_parse(&ctx);
1977 __ktrfmt_delete_buffer(bufstate);
1983 parse_var(const char *str, struct symtab *symtab, struct evtr_variable **var,
1984 char *errbuf, size_t errbufsz)
1988 struct ktrfmt_parse_ctx ctx;
1990 printd(PARSE, "parsing \"%s\"\n", str);
1992 ctx.symtab = symtab;
1994 ctx.errbuf = errbuf;
1995 ctx.errbuf[0] = '\0';
1996 ctx.errbufsz = errbufsz;
1998 bufstate = __ktrfmt_scan_string(str);
1999 ret = __ktrfmt_parse(&ctx);
2000 __ktrfmt_delete_buffer(bufstate);