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 *);
111 do_parse_err(struct ktrfmt_parse_ctx *ctx, const char *fmt, ...)
116 vsnprintf(ctx->errbuf, ctx->errbufsz, fmt, ap);
121 #define parse_err(fmt, ...) \
123 do_parse_err(ctx, fmt, ##__VA_ARGS__); \
128 struct evtr_variable *
129 evtr_var_new(const char *name)
131 struct evtr_variable *var;
133 var = calloc(1, sizeof(*var));
135 if (!(var->name = strdup(name))) {
139 var->val.type = EVTR_VAL_NIL;
145 * XXX: should be reentrant
152 static char buf[100];
155 snprintf(buf, sizeof(buf), "@%ld", serno);
161 index_hash(struct ktrfmt_parse_ctx *ctx, const char *hashname,
162 evtr_variable_value_t val, evtr_var_t *_var)
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);
176 if (val->type == EVTR_VAL_INT) {
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);
185 do_parse_err(ctx, "trying to index hash '%s' with "
186 "non-supported value", hashname);
190 if (hash_find(hsh->val.hashtab, key, &ret)) {
191 printd(PARSE, "didn't find it\n");
192 var = evtr_var_new(uniq_varname());
194 printd(PARSE, "inserting it as %s\n", var->name);
195 if (!hash_insert(hsh->val.hashtab, key,
197 do_parse_err(ctx, "can't insert temporary "
198 "variable into hash\n");
201 symtab_insert(ctx->symtab, var->name, var);
203 do_parse_err(ctx, "out of memory");
206 var = (struct evtr_variable *)ret;
209 fprintf(stderr, "no var!\n");
219 /* Line 189 of yacc.c */
220 #line 221 "ktrfmt.tab.c"
222 /* Enabling traces. */
227 /* Enabling verbose error messages. */
228 #ifdef YYERROR_VERBOSE
229 # undef YYERROR_VERBOSE
230 # define YYERROR_VERBOSE 1
232 # define YYERROR_VERBOSE 1
235 /* Enabling the token table. */
236 #ifndef YYTOKEN_TABLE
237 # define YYTOKEN_TABLE 0
244 /* Put the tokens into the symbol table, so that GDB and other debuggers
252 TOK_LEFT_BRACK = 263,
253 TOK_RIGHT_BRACK = 264,
260 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
261 typedef union YYSTYPE
264 /* Line 214 of yacc.c */
268 struct evtr_variable *var;
269 struct evtr_variable_value *val;
274 /* Line 214 of yacc.c */
275 #line 276 "ktrfmt.tab.c"
277 # define YYSTYPE_IS_TRIVIAL 1
278 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
279 # define YYSTYPE_IS_DECLARED 1
283 /* Copy the second part of user declarations. */
286 /* Line 264 of yacc.c */
287 #line 288 "ktrfmt.tab.c"
294 typedef YYTYPE_UINT8 yytype_uint8;
296 typedef unsigned char yytype_uint8;
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;
305 typedef short int yytype_int8;
309 typedef YYTYPE_UINT16 yytype_uint16;
311 typedef unsigned short int yytype_uint16;
315 typedef YYTYPE_INT16 yytype_int16;
317 typedef short int yytype_int16;
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
330 # define YYSIZE_T unsigned int
334 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
339 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
340 # define YY_(msgid) dgettext ("bison-runtime", msgid)
344 # define YY_(msgid) msgid
348 /* Suppress unused-variable warnings by "using" E. */
349 #if ! defined lint || defined __GNUC__
350 # define YYUSE(e) ((void) (e))
352 # define YYUSE(e) /* empty */
355 /* Identity function, used to suppress warnings about constant conditions. */
359 #if (defined __STDC__ || defined __C99__FUNC__ \
360 || defined __cplusplus || defined _MSC_VER)
373 #if ! defined yyoverflow || YYERROR_VERBOSE
375 /* The parser invokes alloca or malloc; define the necessary symbols. */
377 # ifdef YYSTACK_USE_ALLOCA
378 # if YYSTACK_USE_ALLOCA
380 # define YYSTACK_ALLOC __builtin_alloca
381 # elif defined __BUILTIN_VA_ARG_INCR
382 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
384 # define YYSTACK_ALLOC __alloca
385 # elif defined _MSC_VER
386 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
387 # define alloca _alloca
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 */
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 */
412 # define YYSTACK_ALLOC YYMALLOC
413 # define YYSTACK_FREE YYFREE
414 # ifndef YYSTACK_ALLOC_MAXIMUM
415 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
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 */
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 */
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 */
440 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
443 #if (! defined yyoverflow \
444 && (! defined __cplusplus \
445 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
447 /* A type that is properly aligned for any stack member. */
450 yytype_int16 yyss_alloc;
454 /* The size of the maximum gap between one aligned stack and the next. */
455 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
457 /* The size of an array large to enough to hold all stacks, each with
459 # define YYSTACK_BYTES(N) \
460 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
461 + YYSTACK_GAP_MAXIMUM)
463 /* Copy COUNT objects from FROM to TO. The source and destination do
466 # if defined __GNUC__ && 1 < __GNUC__
467 # define YYCOPY(To, From, Count) \
468 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
470 # define YYCOPY(To, From, Count) \
474 for (yyi = 0; yyi < (Count); yyi++) \
475 (To)[yyi] = (From)[yyi]; \
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
486 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
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); \
499 /* YYFINAL -- State number of the termination state. */
501 /* YYLAST -- Last index in YYTABLE. */
504 /* YYNTOKENS -- Number of terminals. */
506 /* YYNNTS -- Number of nonterminals. */
508 /* YYNRULES -- Number of rules. */
510 /* YYNRULES -- Number of states. */
513 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
515 #define YYMAXUTOK 265
517 #define YYTRANSLATE(YYX) \
518 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
520 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
521 static const yytype_uint8 yytranslate[] =
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,
553 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
555 static const yytype_uint8 yyprhs[] =
557 0, 0, 3, 5, 7, 9, 11, 13, 15, 18,
558 20, 23, 25, 27, 32, 36, 38, 40, 44, 48
561 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
562 static const yytype_int8 yyrhs[] =
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
571 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
572 static const yytype_uint16 yyrline[] =
574 0, 175, 175, 177, 180, 182, 196, 210, 219, 224,
575 237, 262, 280, 284, 291, 304, 308, 312, 319, 327
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[] =
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
592 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
594 static const yytype_uint16 yytoknum[] =
596 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
601 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
602 static const yytype_uint8 yyr1[] =
604 0, 11, 12, 13, 13, 14, 14, 15, 15, 16,
605 16, 17, 17, 18, 18, 18, 19, 20, 20, 21
608 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
609 static const yytype_uint8 yyr2[] =
611 0, 2, 1, 1, 1, 1, 1, 1, 2, 1,
612 2, 1, 1, 4, 3, 1, 1, 3, 3, 1
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[] =
620 0, 11, 5, 6, 0, 2, 12, 15, 16, 3,
621 19, 4, 1, 0, 0, 0, 0, 14, 9, 17,
625 /* YYDEFGOTO[NTERM-NUM]. */
626 static const yytype_int8 yydefgoto[] =
628 -1, 4, 5, 6, 23, 20, 7, 8, 9, 10,
632 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
634 #define YYPACT_NINF -17
635 static const yytype_int8 yypact[] =
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
642 /* YYPGOTO[NTERM-NUM]. */
643 static const yytype_int8 yypgoto[] =
645 -17, -17, -17, -15, -16, -17, -17, 7, -17, -17,
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[] =
656 19, 12, 1, 22, 2, 3, 24, 22, 18, 2,
657 3, 13, 21, 14, 13, 15, 14, 2, 3, 17,
661 static const yytype_uint8 yycheck[] =
663 15, 0, 3, 18, 5, 6, 22, 22, 4, 5,
664 6, 8, 9, 10, 8, 7, 10, 5, 6, 3,
668 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
669 symbol of state STATE-NUM. */
670 static const yytype_uint8 yystos[] =
672 0, 3, 5, 6, 12, 13, 14, 17, 18, 19,
673 20, 21, 0, 8, 10, 7, 18, 3, 4, 14,
677 #define yyerrok (yyerrstatus = 0)
678 #define yyclearin (yychar = YYEMPTY)
682 #define YYACCEPT goto yyacceptlab
683 #define YYABORT goto yyabortlab
684 #define YYERROR goto yyerrorlab
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. */
691 #define YYFAIL goto yyerrlab
693 #define YYRECOVERING() (!!yyerrstatus)
695 #define YYBACKUP(Token, Value) \
697 if (yychar == YYEMPTY && yylen == 1) \
701 yytoken = YYTRANSLATE (yychar); \
707 yyerror (ctx, YY_("syntax error: cannot back up")); \
714 #define YYERRCODE 256
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). */
721 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
722 #ifndef YYLLOC_DEFAULT
723 # define YYLLOC_DEFAULT(Current, Rhs, N) \
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; \
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; \
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. */
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)
754 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
759 /* YYLEX -- calling `yylex' with the right arguments. */
762 # define YYLEX yylex (&yylval, YYLEX_PARAM)
764 # define YYLEX yylex (&yylval)
767 /* Enable debugging if requested. */
771 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
772 # define YYFPRINTF fprintf
775 # define YYDPRINTF(Args) \
781 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
785 YYFPRINTF (stderr, "%s ", Title); \
786 yy_symbol_print (stderr, \
788 YYFPRINTF (stderr, "\n"); \
793 /*--------------------------------.
794 | Print this symbol on YYOUTPUT. |
795 `--------------------------------*/
798 #if (defined __STDC__ || defined __C99__FUNC__ \
799 || defined __cplusplus || defined _MSC_VER)
801 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct ktrfmt_parse_ctx *ctx)
804 yy_symbol_value_print (yyoutput, yytype, yyvaluep, ctx)
807 YYSTYPE const * const yyvaluep;
808 struct ktrfmt_parse_ctx *ctx;
815 if (yytype < YYNTOKENS)
816 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
828 /*--------------------------------.
829 | Print this symbol on YYOUTPUT. |
830 `--------------------------------*/
832 #if (defined __STDC__ || defined __C99__FUNC__ \
833 || defined __cplusplus || defined _MSC_VER)
835 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct ktrfmt_parse_ctx *ctx)
838 yy_symbol_print (yyoutput, yytype, yyvaluep, ctx)
841 YYSTYPE const * const yyvaluep;
842 struct ktrfmt_parse_ctx *ctx;
845 if (yytype < YYNTOKENS)
846 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
848 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
850 yy_symbol_value_print (yyoutput, yytype, yyvaluep, ctx);
851 YYFPRINTF (yyoutput, ")");
854 /*------------------------------------------------------------------.
855 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
857 `------------------------------------------------------------------*/
859 #if (defined __STDC__ || defined __C99__FUNC__ \
860 || defined __cplusplus || defined _MSC_VER)
862 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
865 yy_stack_print (yybottom, yytop)
866 yytype_int16 *yybottom;
870 YYFPRINTF (stderr, "Stack now");
871 for (; yybottom <= yytop; yybottom++)
873 int yybot = *yybottom;
874 YYFPRINTF (stderr, " %d", yybot);
876 YYFPRINTF (stderr, "\n");
879 # define YY_STACK_PRINT(Bottom, Top) \
882 yy_stack_print ((Bottom), (Top)); \
886 /*------------------------------------------------.
887 | Report that the YYRULE is going to be reduced. |
888 `------------------------------------------------*/
890 #if (defined __STDC__ || defined __C99__FUNC__ \
891 || defined __cplusplus || defined _MSC_VER)
893 yy_reduce_print (YYSTYPE *yyvsp, int yyrule, struct ktrfmt_parse_ctx *ctx)
896 yy_reduce_print (yyvsp, yyrule, ctx)
899 struct ktrfmt_parse_ctx *ctx;
902 int yynrhs = yyr2[yyrule];
904 unsigned long int yylno = yyrline[yyrule];
905 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
907 /* The symbols being reduced. */
908 for (yyi = 0; yyi < yynrhs; yyi++)
910 YYFPRINTF (stderr, " $%d = ", yyi + 1);
911 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
912 &(yyvsp[(yyi + 1) - (yynrhs)])
914 YYFPRINTF (stderr, "\n");
918 # define YY_REDUCE_PRINT(Rule) \
921 yy_reduce_print (yyvsp, Rule, ctx); \
924 /* Nonzero means print parse trace. It is left uninitialized so that
925 multiple parsers can coexist. */
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 */
935 /* YYINITDEPTH -- initial size of the parser's stacks. */
937 # define YYINITDEPTH 200
940 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
941 if the built-in stack extension method is used).
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. */
948 # define YYMAXDEPTH 10000
956 # if defined __GLIBC__ && defined _STRING_H
957 # define yystrlen strlen
959 /* Return the length of YYSTR. */
960 #if (defined __STDC__ || defined __C99__FUNC__ \
961 || defined __cplusplus || defined _MSC_VER)
963 yystrlen (const char *yystr)
971 for (yylen = 0; yystr[yylen]; yylen++)
979 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
980 # define yystpcpy stpcpy
982 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
984 #if (defined __STDC__ || defined __C99__FUNC__ \
985 || defined __cplusplus || defined _MSC_VER)
987 yystpcpy (char *yydest, const char *yysrc)
990 yystpcpy (yydest, yysrc)
996 const char *yys = yysrc;
998 while ((*yyd++ = *yys++) != '\0')
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
1015 yytnamerr (char *yyres, const char *yystr)
1020 char const *yyp = yystr;
1027 goto do_not_strip_quotes;
1031 goto do_not_strip_quotes;
1044 do_not_strip_quotes: ;
1048 return yystrlen (yystr);
1050 return yystpcpy (yyres, yystr) - yyres;
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. */
1062 yysyntax_error (char *yyresult, int yystate, int yychar)
1064 int yyn = yypact[yystate];
1066 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1070 int yytype = YYTRANSLATE (yychar);
1071 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1072 YYSIZE_T yysize = yysize0;
1074 int yysize_overflow = 0;
1075 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1076 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
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");
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;
1099 /* Start YYX at -YYN if negative to avoid negative indexes in
1101 int yyxbegin = yyn < 0 ? -yyn : 0;
1103 /* Stay within bounds of both yycheck and yytname. */
1104 int yychecklim = YYLAST - yyn + 1;
1105 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1108 yyarg[0] = yytname[yytype];
1109 yyfmt = yystpcpy (yyformat, yyunexpected);
1111 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1112 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1114 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1118 yyformat[sizeof yyunexpected - 1] = '\0';
1121 yyarg[yycount++] = yytname[yyx];
1122 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1123 yysize_overflow |= (yysize1 < yysize);
1125 yyfmt = yystpcpy (yyfmt, yyprefix);
1129 yyf = YY_(yyformat);
1130 yysize1 = yysize + yystrlen (yyf);
1131 yysize_overflow |= (yysize1 < yysize);
1134 if (yysize_overflow)
1135 return YYSIZE_MAXIMUM;
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;
1144 while ((*yyp = *yyf) != '\0')
1146 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1148 yyp += yytnamerr (yyp, yyarg[yyi++]);
1161 #endif /* YYERROR_VERBOSE */
1164 /*-----------------------------------------------.
1165 | Release the memory associated to this symbol. |
1166 `-----------------------------------------------*/
1169 #if (defined __STDC__ || defined __C99__FUNC__ \
1170 || defined __cplusplus || defined _MSC_VER)
1172 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, struct ktrfmt_parse_ctx *ctx)
1175 yydestruct (yymsg, yytype, yyvaluep, ctx)
1179 struct ktrfmt_parse_ctx *ctx;
1187 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1197 /* Prevent warnings from -Wmissing-prototypes. */
1198 #ifdef YYPARSE_PARAM
1199 #if defined __STDC__ || defined __cplusplus
1200 int yyparse (void *YYPARSE_PARAM);
1204 #else /* ! YYPARSE_PARAM */
1205 #if defined __STDC__ || defined __cplusplus
1206 int yyparse (struct ktrfmt_parse_ctx *ctx);
1210 #endif /* ! YYPARSE_PARAM */
1216 /*-------------------------.
1217 | yyparse or yypush_parse. |
1218 `-------------------------*/
1220 #ifdef YYPARSE_PARAM
1221 #if (defined __STDC__ || defined __C99__FUNC__ \
1222 || defined __cplusplus || defined _MSC_VER)
1224 yyparse (void *YYPARSE_PARAM)
1227 yyparse (YYPARSE_PARAM)
1228 void *YYPARSE_PARAM;
1230 #else /* ! YYPARSE_PARAM */
1231 #if (defined __STDC__ || defined __C99__FUNC__ \
1232 || defined __cplusplus || defined _MSC_VER)
1234 yyparse (struct ktrfmt_parse_ctx *ctx)
1238 struct ktrfmt_parse_ctx *ctx;
1242 /* The lookahead symbol. */
1245 /* The semantic value of the lookahead symbol. */
1248 /* Number of syntax errors so far. */
1252 /* Number of tokens to shift before error messages enabled. */
1255 /* The stacks and their tools:
1256 `yyss': related to states.
1257 `yyvs': related to semantic values.
1259 Refer to the stacks thru separate pointers, to allow yyoverflow
1260 to reallocate them elsewhere. */
1262 /* The state stack. */
1263 yytype_int16 yyssa[YYINITDEPTH];
1265 yytype_int16 *yyssp;
1267 /* The semantic value stack. */
1268 YYSTYPE yyvsa[YYINITDEPTH];
1272 YYSIZE_T yystacksize;
1276 /* Lookahead token as an internal (translated) token number. */
1278 /* The variables used to return semantic value and location from the
1283 /* Buffer for error messages, and its allocated size. */
1285 char *yymsg = yymsgbuf;
1286 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1289 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1291 /* The number of symbols on the RHS of the reduced rule.
1292 Keep to zero when no symbol should be popped. */
1298 yystacksize = YYINITDEPTH;
1300 YYDPRINTF ((stderr, "Starting parse\n"));
1305 yychar = YYEMPTY; /* Cause a token to be read. */
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. */
1316 /*------------------------------------------------------------.
1317 | yynewstate -- Push a new state, which is found in yystate. |
1318 `------------------------------------------------------------*/
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. */
1327 if (yyss + yystacksize - 1 <= yyssp)
1329 /* Get the current used size of the three stacks, in elements. */
1330 YYSIZE_T yysize = yyssp - yyss + 1;
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
1337 YYSTYPE *yyvs1 = yyvs;
1338 yytype_int16 *yyss1 = yyss;
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),
1352 #else /* no yyoverflow */
1353 # ifndef YYSTACK_RELOCATE
1354 goto yyexhaustedlab;
1356 /* Extend the stack our own way. */
1357 if (YYMAXDEPTH <= yystacksize)
1358 goto yyexhaustedlab;
1360 if (YYMAXDEPTH < yystacksize)
1361 yystacksize = YYMAXDEPTH;
1364 yytype_int16 *yyss1 = yyss;
1365 union yyalloc *yyptr =
1366 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1368 goto yyexhaustedlab;
1369 YYSTACK_RELOCATE (yyss_alloc, yyss);
1370 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1371 # undef YYSTACK_RELOCATE
1373 YYSTACK_FREE (yyss1);
1376 #endif /* no yyoverflow */
1378 yyssp = yyss + yysize - 1;
1379 yyvsp = yyvs + yysize - 1;
1381 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1382 (unsigned long int) yystacksize));
1384 if (yyss + yystacksize - 1 <= yyssp)
1388 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1390 if (yystate == YYFINAL)
1400 /* Do appropriate processing given the current state. Read a
1401 lookahead token if we need one and don't already have one. */
1403 /* First try to decide what to do without reference to lookahead token. */
1404 yyn = yypact[yystate];
1405 if (yyn == YYPACT_NINF)
1408 /* Not known => get a lookahead token if don't already have one. */
1410 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1411 if (yychar == YYEMPTY)
1413 YYDPRINTF ((stderr, "Reading a token: "));
1417 if (yychar <= YYEOF)
1419 yychar = yytoken = YYEOF;
1420 YYDPRINTF ((stderr, "Now at end of input.\n"));
1424 yytoken = YYTRANSLATE (yychar);
1425 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1428 /* If the proper action on seeing token YYTOKEN is to reduce or to
1429 detect an error, take that action. */
1431 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1436 if (yyn == 0 || yyn == YYTABLE_NINF)
1442 /* Count tokens shifted since error; after three, turn off error
1447 /* Shift the lookahead token. */
1448 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1450 /* Discard the shifted token. */
1459 /*-----------------------------------------------------------.
1460 | yydefault -- do the default action for the current state. |
1461 `-----------------------------------------------------------*/
1463 yyn = yydefact[yystate];
1469 /*-----------------------------.
1470 | yyreduce -- Do a reduction. |
1471 `-----------------------------*/
1473 /* yyn is the number of a rule to reduce with. */
1476 /* If YYLEN is nonzero, implement the default value of the action:
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];
1487 YY_REDUCE_PRINT (yyn);
1492 /* Line 1455 of yacc.c */
1493 #line 177 "ktrfmt.y"
1495 ctx->var = (yyvsp[(1) - (1)].var);
1501 /* Line 1455 of yacc.c */
1502 #line 182 "ktrfmt.y"
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;
1510 var->val.num = strtoll((yyvsp[(1) - (1)].tok)->str, NULL, 0);
1512 parse_err("Can't parse numeric constant '%s'", (yyvsp[(1) - (1)].tok)->str);
1515 tok_free((yyvsp[(1) - (1)].tok));
1521 /* Line 1455 of yacc.c */
1522 #line 196 "ktrfmt.y"
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");
1534 tok_free((yyvsp[(1) - (1)].tok));
1540 /* Line 1455 of yacc.c */
1541 #line 210 "ktrfmt.y"
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);
1555 /* Line 1455 of yacc.c */
1556 #line 219 "ktrfmt.y"
1558 TAILQ_INSERT_HEAD(&(yyvsp[(2) - (2)].var)->val.ctor.args, &(yyvsp[(1) - (2)].var)->val, link);
1559 (yyval.var) = (yyvsp[(2) - (2)].var);
1565 /* Line 1455 of yacc.c */
1566 #line 224 "ktrfmt.y"
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));
1584 /* Line 1455 of yacc.c */
1585 #line 237 "ktrfmt.y"
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) {
1598 printd(PARSE, "\t%jd\n", val->num);
1601 printd(PARSE, "\t\"%s\"\n", val->str);
1604 assert(!"can't get here");
1614 /* Line 1455 of yacc.c */
1615 #line 262 "ktrfmt.y"
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);
1624 if (!(var = evtr_var_new((yyvsp[(1) - (1)].tok)->str))) {
1625 tok_free((yyvsp[(1) - (1)].tok));
1626 parse_err("out of memory");
1628 printd(PARSE, "creating var %s\n", (yyvsp[(1) - (1)].tok)->str);
1629 symtab_insert(ctx->symtab, (yyvsp[(1) - (1)].tok)->str, var);
1632 tok_free((yyvsp[(1) - (1)].tok));
1638 /* Line 1455 of yacc.c */
1639 #line 280 "ktrfmt.y"
1641 (yyval.var) = (yyvsp[(1) - (1)].var);
1647 /* Line 1455 of yacc.c */
1648 #line 284 "ktrfmt.y"
1652 if (index_hash(ctx, (yyvsp[(1) - (4)].var)->name, &(yyvsp[(3) - (4)].var)->val, &var))
1660 /* Line 1455 of yacc.c */
1661 #line 291 "ktrfmt.y"
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;
1670 if (index_hash(ctx, (yyvsp[(1) - (3)].var)->name, &tmp->val, &var))
1672 tok_free((yyvsp[(3) - (3)].tok));
1679 /* Line 1455 of yacc.c */
1680 #line 304 "ktrfmt.y"
1682 (yyval.var) = (yyvsp[(1) - (1)].var);
1688 /* Line 1455 of yacc.c */
1689 #line 308 "ktrfmt.y"
1691 (yyval.var) = (yyvsp[(1) - (1)].var);
1697 /* Line 1455 of yacc.c */
1698 #line 312 "ktrfmt.y"
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;
1710 /* Line 1455 of yacc.c */
1711 #line 319 "ktrfmt.y"
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;
1723 /* Line 1455 of yacc.c */
1724 #line 327 "ktrfmt.y"
1726 (yyval.na) = (yyvsp[(1) - (1)].na);
1732 /* Line 1455 of yacc.c */
1733 #line 1734 "ktrfmt.tab.c"
1736 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1740 YY_STACK_PRINT (yyss, yyssp);
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. */
1750 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1751 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1752 yystate = yytable[yystate];
1754 yystate = yydefgoto[yyn - YYNTOKENS];
1759 /*------------------------------------.
1760 | yyerrlab -- here on detecting error |
1761 `------------------------------------*/
1763 /* If not already recovering from an error, report this error. */
1767 #if ! YYERROR_VERBOSE
1768 yyerror (ctx, YY_("syntax error"));
1771 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1772 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
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);
1781 yymsg_alloc = yyalloc;
1785 yymsg_alloc = sizeof yymsgbuf;
1789 if (0 < yysize && yysize <= yymsg_alloc)
1791 (void) yysyntax_error (yymsg, yystate, yychar);
1792 yyerror (ctx, yymsg);
1796 yyerror (ctx, YY_("syntax error"));
1798 goto yyexhaustedlab;
1806 if (yyerrstatus == 3)
1808 /* If just tried and failed to reuse lookahead token after an
1809 error, discard it. */
1811 if (yychar <= YYEOF)
1813 /* Return failure if at end of input. */
1814 if (yychar == YYEOF)
1819 yydestruct ("Error: discarding",
1820 yytoken, &yylval, ctx);
1825 /* Else will try to reuse lookahead token after shifting the error
1830 /*---------------------------------------------------.
1831 | yyerrorlab -- error raised explicitly by YYERROR. |
1832 `---------------------------------------------------*/
1835 /* Pacify compilers like GCC when the user code never invokes
1836 YYERROR and the label yyerrorlab therefore never appears in user
1838 if (/*CONSTCOND*/ 0)
1841 /* Do not reclaim the symbols of the rule which action triggered
1845 YY_STACK_PRINT (yyss, yyssp);
1850 /*-------------------------------------------------------------.
1851 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1852 `-------------------------------------------------------------*/
1854 yyerrstatus = 3; /* Each real token shifted decrements this. */
1858 yyn = yypact[yystate];
1859 if (yyn != YYPACT_NINF)
1862 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1870 /* Pop the current state because it cannot handle the error token. */
1875 yydestruct ("Error: popping",
1876 yystos[yystate], yyvsp, ctx);
1879 YY_STACK_PRINT (yyss, yyssp);
1885 /* Shift the error token. */
1886 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1892 /*-------------------------------------.
1893 | yyacceptlab -- YYACCEPT comes here. |
1894 `-------------------------------------*/
1899 /*-----------------------------------.
1900 | yyabortlab -- YYABORT comes here. |
1901 `-----------------------------------*/
1906 #if !defined(yyoverflow) || YYERROR_VERBOSE
1907 /*-------------------------------------------------.
1908 | yyexhaustedlab -- memory exhaustion comes here. |
1909 `-------------------------------------------------*/
1911 yyerror (ctx, YY_("memory exhausted"));
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. */
1923 YY_STACK_PRINT (yyss, yyssp);
1924 while (yyssp != yyss)
1926 yydestruct ("Cleanup: popping",
1927 yystos[*yyssp], yyvsp, ctx);
1932 YYSTACK_FREE (yyss);
1935 if (yymsg != yymsgbuf)
1936 YYSTACK_FREE (yymsg);
1938 /* Make sure YYID is used. */
1939 return YYID (yyresult);
1944 /* Line 1675 of yacc.c */
1945 #line 332 "ktrfmt.y"
1948 void * __ktrfmt_scan_string(const char *);
1949 void __ktrfmt_delete_buffer(void *);
1952 __ktrfmt_error (struct ktrfmt_parse_ctx *ctx, const char *s)
1954 do_parse_err(ctx, s);
1958 parse_string(evtr_event_t ev, struct symtab *symtab, const char *str,
1959 char *errbuf, size_t errbufsz)
1963 struct ktrfmt_parse_ctx ctx;
1965 printd(PARSE, "parsing \"%s\"\n", str);
1967 ctx.symtab = symtab;
1968 ctx.errbuf = errbuf;
1969 ctx.errbuf[0] = '\0';
1970 ctx.errbufsz = errbufsz;
1972 bufstate = __ktrfmt_scan_string(str);
1973 ret = __ktrfmt_parse(&ctx);
1974 __ktrfmt_delete_buffer(bufstate);
1980 parse_var(const char *str, struct symtab *symtab, struct evtr_variable **var,
1981 char *errbuf, size_t errbufsz)
1985 struct ktrfmt_parse_ctx ctx;
1987 printd(PARSE, "parsing \"%s\"\n", str);
1989 ctx.symtab = symtab;
1991 ctx.errbuf = errbuf;
1992 ctx.errbuf[0] = '\0';
1993 ctx.errbufsz = errbufsz;
1995 bufstate = __ktrfmt_scan_string(str);
1996 ret = __ktrfmt_parse(&ctx);
1997 __ktrfmt_delete_buffer(bufstate);