1 /* A Bison parser, made by GNU Bison 2.7.12-4996. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* As a special exception, you may create a larger work that contains
21 part or all of the Bison parser skeleton and distribute that work
22 under terms of your choice, so long as that work isn't itself a
23 parser generator using the skeleton or a modified version thereof
24 as a parser skeleton. Alternatively, if you modify or redistribute
25 the parser skeleton itself, you may (at your option) remove this
26 special exception, which will cause the skeleton and the resulting
27 Bison output files to be licensed under the GNU General Public
28 License without this special exception.
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
36 /* All symbols defined below should begin with yy or YY, to avoid
37 infringing on user name space. This should be done even for local
38 variables, as they might otherwise be expanded by user macros.
39 There are some unavoidable exceptions within include files to
40 define necessary library symbols; they are noted "INFRINGES ON
41 USER NAME SPACE" below. */
43 /* Identify Bison output. */
47 #define YYBISON_VERSION "2.7.12-4996"
50 #define YYSKELETON_NAME "yacc.c"
62 /* Substitute the variable and function names. */
63 #define yyparse __ktrfmt_parse
64 #define yylex __ktrfmt_lex
65 #define yyerror __ktrfmt_error
66 #define yylval __ktrfmt_lval
67 #define yychar __ktrfmt_char
68 #define yydebug __ktrfmt_debug
69 #define yynerrs __ktrfmt_nerrs
71 /* Copy the first part of user declarations. */
72 /* Line 371 of yacc.c */
81 #include <sys/queue.h>
86 #include "ktrfmt.tab.h"
88 int __ktrfmtlex(YYSTYPE
*);
89 #define __ktrfmt_lex __ktrfmtlex
91 void __ktrfmt_error (struct ktrfmt_parse_ctx
*, const char *);
93 static void do_parse_err(struct ktrfmt_parse_ctx
*, const char *, ...)
98 do_parse_err(struct ktrfmt_parse_ctx
*ctx
, const char *fmt
, ...)
103 vsnprintf(ctx
->errbuf
, ctx
->errbufsz
, fmt
, ap
);
108 #define parse_err(fmt, ...) \
110 do_parse_err(ctx, fmt, ##__VA_ARGS__); \
115 struct evtr_variable
*
116 evtr_var_new(const char *name
)
118 struct evtr_variable
*var
;
120 var
= calloc(1, sizeof(*var
));
122 if (!(var
->name
= strdup(name
))) {
126 var
->val
.type
= EVTR_VAL_NIL
;
132 * XXX: should be reentrant
139 static char buf
[100];
142 snprintf(buf
, sizeof(buf
), "@%ld", serno
);
148 index_hash(struct ktrfmt_parse_ctx
*ctx
, const char *hashname
,
149 evtr_variable_value_t val
, evtr_var_t
*_var
)
153 hsh
= symtab_find(ctx
->symtab
, hashname
);
154 if (hsh
->val
.type
== EVTR_VAL_NIL
) {
155 /* it's probably the first time we see this "variable" */
156 printd(PARSE
, "creating hash for %s\n", hsh
->name
);
157 hsh
->val
.type
= EVTR_VAL_HASH
;
158 hsh
->val
.hashtab
= hash_new();
159 } else if (hsh
->val
.type
!= EVTR_VAL_HASH
) {
160 printd(PARSE
, "trying to use type %d as hash\n", hsh
->val
.type
);
163 if (val
->type
== EVTR_VAL_INT
) {
165 printd(PARSE
, "looking up %s[%jd] in %p\n", hsh
->name
,
166 val
->num
, hsh
->val
.hashtab
);
167 } else if (val
->type
== EVTR_VAL_STR
) {
168 key
= (uintptr_t)val
->str
;
169 printd(PARSE
, "looking up %s[\"%s\"] in %p\n", hsh
->name
,
170 val
->str
, hsh
->val
.hashtab
);
172 do_parse_err(ctx
, "trying to index hash '%s' with "
173 "non-supported value", hashname
);
177 if (hash_find(hsh
->val
.hashtab
, key
, &ret
)) {
178 printd(PARSE
, "didn't find it\n");
179 var
= evtr_var_new(uniq_varname());
181 printd(PARSE
, "inserting it as %s\n", var
->name
);
182 if (!hash_insert(hsh
->val
.hashtab
, key
,
184 do_parse_err(ctx
, "can't insert temporary "
185 "variable into hash\n");
188 symtab_insert(ctx
->symtab
, var
->name
, var
);
190 do_parse_err(ctx
, "out of memory");
193 var
= (struct evtr_variable
*)ret
;
196 fprintf(stderr
, "no var!\n");
205 /* Line 371 of yacc.c */
206 #line 207 "ktrfmt.tab.c"
209 # if defined __cplusplus && 201103L <= __cplusplus
210 # define YY_NULL nullptr
216 /* Enabling verbose error messages. */
217 #ifdef YYERROR_VERBOSE
218 # undef YYERROR_VERBOSE
219 # define YYERROR_VERBOSE 1
221 # define YYERROR_VERBOSE 1
224 /* In a future release of Bison, this section will be replaced
225 by #include "ktrfmt.tab.h". */
226 #ifndef YY__KTRFMT_KTRFMT_TAB_H_INCLUDED
227 # define YY__KTRFMT_KTRFMT_TAB_H_INCLUDED
228 /* Enabling traces. */
233 extern int __ktrfmt_debug
;
239 /* Put the tokens into the symbol table, so that GDB and other debuggers
247 TOK_LEFT_BRACK
= 263,
248 TOK_RIGHT_BRACK
= 264,
254 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
255 typedef union YYSTYPE
257 /* Line 387 of yacc.c */
261 struct evtr_variable
*var
;
262 struct evtr_variable_value
*val
;
266 /* Line 387 of yacc.c */
267 #line 268 "ktrfmt.tab.c"
269 # define YYSTYPE_IS_TRIVIAL 1
270 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
271 # define YYSTYPE_IS_DECLARED 1
276 #if defined __STDC__ || defined __cplusplus
277 int __ktrfmt_parse (void *YYPARSE_PARAM
);
279 int __ktrfmt_parse ();
281 #else /* ! YYPARSE_PARAM */
282 #if defined __STDC__ || defined __cplusplus
283 int __ktrfmt_parse (struct ktrfmt_parse_ctx
*ctx
);
285 int __ktrfmt_parse ();
287 #endif /* ! YYPARSE_PARAM */
289 #endif /* !YY__KTRFMT_KTRFMT_TAB_H_INCLUDED */
291 /* Copy the second part of user declarations. */
293 /* Line 390 of yacc.c */
294 #line 295 "ktrfmt.tab.c"
301 typedef YYTYPE_UINT8 yytype_uint8
;
303 typedef unsigned char yytype_uint8
;
307 typedef YYTYPE_INT8 yytype_int8
;
308 #elif (defined __STDC__ || defined __C99__FUNC__ \
309 || defined __cplusplus || defined _MSC_VER)
310 typedef signed char yytype_int8
;
312 typedef short int yytype_int8
;
316 typedef YYTYPE_UINT16 yytype_uint16
;
318 typedef unsigned short int yytype_uint16
;
322 typedef YYTYPE_INT16 yytype_int16
;
324 typedef short int yytype_int16
;
328 # ifdef __SIZE_TYPE__
329 # define YYSIZE_T __SIZE_TYPE__
330 # elif defined size_t
331 # define YYSIZE_T size_t
332 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
333 || defined __cplusplus || defined _MSC_VER)
334 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
335 # define YYSIZE_T size_t
337 # define YYSIZE_T unsigned int
341 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
344 # if defined YYENABLE_NLS && YYENABLE_NLS
346 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
347 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
351 # define YY_(Msgid) Msgid
355 #ifndef __attribute__
356 /* This feature is available in gcc versions 2.5 and later. */
357 # if (! defined __GNUC__ || __GNUC__ < 2 \
358 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
359 # define __attribute__(Spec) /* empty */
363 /* Suppress unused-variable warnings by "using" E. */
364 #if ! defined lint || defined __GNUC__
365 # define YYUSE(E) ((void) (E))
367 # define YYUSE(E) /* empty */
371 /* Identity function, used to suppress warnings about constant conditions. */
375 #if (defined __STDC__ || defined __C99__FUNC__ \
376 || defined __cplusplus || defined _MSC_VER)
389 #if ! defined yyoverflow || YYERROR_VERBOSE
391 /* The parser invokes alloca or malloc; define the necessary symbols. */
393 # ifdef YYSTACK_USE_ALLOCA
394 # if YYSTACK_USE_ALLOCA
396 # define YYSTACK_ALLOC __builtin_alloca
397 # elif defined __BUILTIN_VA_ARG_INCR
398 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
400 # define YYSTACK_ALLOC __alloca
401 # elif defined _MSC_VER
402 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
403 # define alloca _alloca
405 # define YYSTACK_ALLOC alloca
406 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
407 || defined __cplusplus || defined _MSC_VER)
408 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
409 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
410 # ifndef EXIT_SUCCESS
411 # define EXIT_SUCCESS 0
418 # ifdef YYSTACK_ALLOC
419 /* Pacify GCC's `empty if-body' warning. */
420 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
421 # ifndef YYSTACK_ALLOC_MAXIMUM
422 /* The OS might guarantee only one guard page at the bottom of the stack,
423 and a page size can be as small as 4096 bytes. So we cannot safely
424 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
425 to allow for a few compiler-allocated temporary stack slots. */
426 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
429 # define YYSTACK_ALLOC YYMALLOC
430 # define YYSTACK_FREE YYFREE
431 # ifndef YYSTACK_ALLOC_MAXIMUM
432 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
434 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
435 && ! ((defined YYMALLOC || defined malloc) \
436 && (defined YYFREE || defined free)))
437 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
438 # ifndef EXIT_SUCCESS
439 # define EXIT_SUCCESS 0
443 # define YYMALLOC malloc
444 # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
445 || defined __cplusplus || defined _MSC_VER)
446 void *malloc (YYSIZE_T
); /* INFRINGES ON USER NAME SPACE */
451 # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
452 || defined __cplusplus || defined _MSC_VER)
453 void free (void *); /* INFRINGES ON USER NAME SPACE */
457 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
460 #if (! defined yyoverflow \
461 && (! defined __cplusplus \
462 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
464 /* A type that is properly aligned for any stack member. */
467 yytype_int16 yyss_alloc
;
471 /* The size of the maximum gap between one aligned stack and the next. */
472 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
474 /* The size of an array large to enough to hold all stacks, each with
476 # define YYSTACK_BYTES(N) \
477 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
478 + YYSTACK_GAP_MAXIMUM)
480 # define YYCOPY_NEEDED 1
482 /* Relocate STACK from its old location to the new one. The
483 local variables YYSIZE and YYSTACKSIZE give the old and new number of
484 elements in the stack, and YYPTR gives the new location of the
485 stack. Advance YYPTR to a properly aligned location for the next
487 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
490 YYSIZE_T yynewbytes; \
491 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
492 Stack = &yyptr->Stack_alloc; \
493 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
494 yyptr += yynewbytes / sizeof (*yyptr); \
500 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
501 /* Copy COUNT objects from SRC to DST. The source and destination do
504 # if defined __GNUC__ && 1 < __GNUC__
505 # define YYCOPY(Dst, Src, Count) \
506 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
508 # define YYCOPY(Dst, Src, Count) \
512 for (yyi = 0; yyi < (Count); yyi++) \
513 (Dst)[yyi] = (Src)[yyi]; \
518 #endif /* !YYCOPY_NEEDED */
520 /* YYFINAL -- State number of the termination state. */
522 /* YYLAST -- Last index in YYTABLE. */
525 /* YYNTOKENS -- Number of terminals. */
527 /* YYNNTS -- Number of nonterminals. */
529 /* YYNRULES -- Number of rules. */
531 /* YYNRULES -- Number of states. */
534 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
536 #define YYMAXUTOK 265
538 #define YYTRANSLATE(YYX) \
539 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
541 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
542 static const yytype_uint8 yytranslate
[] =
544 0, 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, 2, 2, 2, 2,
552 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
553 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
554 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
555 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
556 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
557 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
558 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
559 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
560 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
561 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
562 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
563 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
564 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
565 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
566 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
567 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
568 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
569 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
574 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
576 static const yytype_uint8 yyprhs
[] =
578 0, 0, 3, 5, 7, 9, 11, 13, 15, 18,
579 20, 23, 25, 27, 32, 36, 38, 40, 44, 48
582 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
583 static const yytype_int8 yyrhs
[] =
585 12, 0, -1, 13, -1, 19, -1, 21, -1, 5,
586 -1, 6, -1, 14, -1, 14, 15, -1, 4, -1,
587 4, 15, -1, 3, -1, 14, -1, 18, 8, 18,
588 9, -1, 18, 10, 3, -1, 17, -1, 18, -1,
589 19, 7, 14, -1, 19, 7, 16, -1, 20, -1
592 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
593 static const yytype_uint16 yyrline
[] =
595 0, 168, 168, 170, 173, 175, 189, 203, 212, 217,
596 230, 255, 273, 277, 284, 297, 301, 305, 312, 320
600 #if YYDEBUG || YYERROR_VERBOSE || 1
601 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
602 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
603 static const char *const yytname
[] =
605 "$end", "error", "$undefined", "TOK_ID", "TOK_CTOR", "TOK_INT",
606 "TOK_STR", "TOK_EQ", "TOK_LEFT_BRACK", "TOK_RIGHT_BRACK", "TOK_DOT",
607 "$accept", "input", "stmt", "constant", "ctor_args", "construct_expr",
608 "primary_expr", "postfix_expr", "unary_expr", "assign_expr", "expr", YY_NULL
613 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
615 static const yytype_uint16 yytoknum
[] =
617 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
622 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
623 static const yytype_uint8 yyr1
[] =
625 0, 11, 12, 13, 13, 14, 14, 15, 15, 16,
626 16, 17, 17, 18, 18, 18, 19, 20, 20, 21
629 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
630 static const yytype_uint8 yyr2
[] =
632 0, 2, 1, 1, 1, 1, 1, 1, 2, 1,
633 2, 1, 1, 4, 3, 1, 1, 3, 3, 1
636 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
637 Performed when YYTABLE doesn't specify something else to do. Zero
638 means the default is an error. */
639 static const yytype_uint8 yydefact
[] =
641 0, 11, 5, 6, 0, 2, 12, 15, 16, 3,
642 19, 4, 1, 0, 0, 0, 0, 14, 9, 17,
646 /* YYDEFGOTO[NTERM-NUM]. */
647 static const yytype_int8 yydefgoto
[] =
649 -1, 4, 5, 6, 23, 20, 7, 8, 9, 10,
653 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
655 #define YYPACT_NINF -17
656 static const yytype_int8 yypact
[] =
658 -1, -17, -17, -17, 1, -17, -17, -17, 6, 8,
659 -17, -17, -17, -1, 16, 4, 3, -17, 12, -17,
660 -17, -17, 12, -17, -17
663 /* YYPGOTO[NTERM-NUM]. */
664 static const yytype_int8 yypgoto
[] =
666 -17, -17, -17, -15, -16, -17, -17, 7, -17, -17,
670 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
671 positive, shift that token. If negative, reduce the rule which
672 number is the opposite. If YYTABLE_NINF, syntax error. */
673 #define YYTABLE_NINF -1
674 static const yytype_uint8 yytable
[] =
676 19, 12, 1, 22, 2, 3, 24, 22, 18, 2,
677 3, 13, 21, 14, 13, 15, 14, 2, 3, 17,
681 #define yypact_value_is_default(Yystate) \
682 (!!((Yystate) == (-17)))
684 #define yytable_value_is_error(Yytable_value) \
687 static const yytype_uint8 yycheck
[] =
689 15, 0, 3, 18, 5, 6, 22, 22, 4, 5,
690 6, 8, 9, 10, 8, 7, 10, 5, 6, 3,
694 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
695 symbol of state STATE-NUM. */
696 static const yytype_uint8 yystos
[] =
698 0, 3, 5, 6, 12, 13, 14, 17, 18, 19,
699 20, 21, 0, 8, 10, 7, 18, 3, 4, 14,
703 #define yyerrok (yyerrstatus = 0)
704 #define yyclearin (yychar = YYEMPTY)
708 #define YYACCEPT goto yyacceptlab
709 #define YYABORT goto yyabortlab
710 #define YYERROR goto yyerrorlab
713 /* Like YYERROR except do call yyerror. This remains here temporarily
714 to ease the transition to the new meaning of YYERROR, for GCC.
715 Once GCC version 2 has supplanted version 1, this can go. However,
716 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
717 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
720 #define YYFAIL goto yyerrlab
722 /* This is here to suppress warnings from the GCC cpp's
723 -Wunused-macros. Normally we don't worry about that warning, but
724 some users do, and we want to make it easy for users to remove
725 YYFAIL uses, which will produce warnings from Bison 2.5. */
728 #define YYRECOVERING() (!!yyerrstatus)
730 #define YYBACKUP(Token, Value) \
732 if (yychar == YYEMPTY) \
736 YYPOPSTACK (yylen); \
742 yyerror (ctx, YY_("syntax error: cannot back up")); \
747 /* Error token number */
749 #define YYERRCODE 256
752 /* This macro is provided for backward compatibility. */
753 #ifndef YY_LOCATION_PRINT
754 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
758 /* YYLEX -- calling `yylex' with the right arguments. */
760 # define YYLEX yylex (&yylval, YYLEX_PARAM)
762 # define YYLEX yylex (&yylval)
765 /* Enable debugging if requested. */
769 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
770 # define YYFPRINTF fprintf
773 # define YYDPRINTF(Args) \
779 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
783 YYFPRINTF (stderr, "%s ", Title); \
784 yy_symbol_print (stderr, \
786 YYFPRINTF (stderr, "\n"); \
791 /*--------------------------------.
792 | Print this symbol on YYOUTPUT. |
793 `--------------------------------*/
796 #if (defined __STDC__ || defined __C99__FUNC__ \
797 || defined __cplusplus || defined _MSC_VER)
799 yy_symbol_value_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
, struct ktrfmt_parse_ctx
*ctx
)
802 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
, ctx
)
805 YYSTYPE
const * const yyvaluep
;
806 struct ktrfmt_parse_ctx
*ctx
;
809 FILE *yyo
= yyoutput
;
815 if (yytype
< YYNTOKENS
)
816 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
824 /*--------------------------------.
825 | Print this symbol on YYOUTPUT. |
826 `--------------------------------*/
828 #if (defined __STDC__ || defined __C99__FUNC__ \
829 || defined __cplusplus || defined _MSC_VER)
831 yy_symbol_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
, struct ktrfmt_parse_ctx
*ctx
)
834 yy_symbol_print (yyoutput
, yytype
, yyvaluep
, ctx
)
837 YYSTYPE
const * const yyvaluep
;
838 struct ktrfmt_parse_ctx
*ctx
;
841 if (yytype
< YYNTOKENS
)
842 YYFPRINTF (yyoutput
, "token %s (", yytname
[yytype
]);
844 YYFPRINTF (yyoutput
, "nterm %s (", yytname
[yytype
]);
846 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
, ctx
);
847 YYFPRINTF (yyoutput
, ")");
850 /*------------------------------------------------------------------.
851 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
853 `------------------------------------------------------------------*/
855 #if (defined __STDC__ || defined __C99__FUNC__ \
856 || defined __cplusplus || defined _MSC_VER)
858 yy_stack_print (yytype_int16
*yybottom
, yytype_int16
*yytop
)
861 yy_stack_print (yybottom
, yytop
)
862 yytype_int16
*yybottom
;
866 YYFPRINTF (stderr
, "Stack now");
867 for (; yybottom
<= yytop
; yybottom
++)
869 int yybot
= *yybottom
;
870 YYFPRINTF (stderr
, " %d", yybot
);
872 YYFPRINTF (stderr
, "\n");
875 # define YY_STACK_PRINT(Bottom, Top) \
878 yy_stack_print ((Bottom), (Top)); \
882 /*------------------------------------------------.
883 | Report that the YYRULE is going to be reduced. |
884 `------------------------------------------------*/
886 #if (defined __STDC__ || defined __C99__FUNC__ \
887 || defined __cplusplus || defined _MSC_VER)
889 yy_reduce_print (YYSTYPE
*yyvsp
, int yyrule
, struct ktrfmt_parse_ctx
*ctx
)
892 yy_reduce_print (yyvsp
, yyrule
, ctx
)
895 struct ktrfmt_parse_ctx
*ctx
;
898 int yynrhs
= yyr2
[yyrule
];
900 unsigned long int yylno
= yyrline
[yyrule
];
901 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu):\n",
903 /* The symbols being reduced. */
904 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
906 YYFPRINTF (stderr
, " $%d = ", yyi
+ 1);
907 yy_symbol_print (stderr
, yyrhs
[yyprhs
[yyrule
] + yyi
],
908 &(yyvsp
[(yyi
+ 1) - (yynrhs
)])
910 YYFPRINTF (stderr
, "\n");
914 # define YY_REDUCE_PRINT(Rule) \
917 yy_reduce_print (yyvsp, Rule, ctx); \
920 /* Nonzero means print parse trace. It is left uninitialized so that
921 multiple parsers can coexist. */
924 # define YYDPRINTF(Args)
925 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
926 # define YY_STACK_PRINT(Bottom, Top)
927 # define YY_REDUCE_PRINT(Rule)
928 #endif /* !YYDEBUG */
931 /* YYINITDEPTH -- initial size of the parser's stacks. */
933 # define YYINITDEPTH 200
936 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
937 if the built-in stack extension method is used).
939 Do not make this value too large; the results are undefined if
940 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
941 evaluated with infinite-precision integer arithmetic. */
944 # define YYMAXDEPTH 10000
951 # if defined __GLIBC__ && defined _STRING_H
952 # define yystrlen strlen
954 /* Return the length of YYSTR. */
955 #if (defined __STDC__ || defined __C99__FUNC__ \
956 || defined __cplusplus || defined _MSC_VER)
958 yystrlen (const char *yystr
)
966 for (yylen
= 0; yystr
[yylen
]; yylen
++)
974 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
975 # define yystpcpy stpcpy
977 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
979 #if (defined __STDC__ || defined __C99__FUNC__ \
980 || defined __cplusplus || defined _MSC_VER)
982 yystpcpy (char *yydest
, const char *yysrc
)
985 yystpcpy (yydest
, yysrc
)
991 const char *yys
= yysrc
;
993 while ((*yyd
++ = *yys
++) != '\0')
1002 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1003 quotes and backslashes, so that it's suitable for yyerror. The
1004 heuristic is that double-quoting is unnecessary unless the string
1005 contains an apostrophe, a comma, or backslash (other than
1006 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1007 null, do not copy; instead, return the length of what the result
1010 yytnamerr (char *yyres
, const char *yystr
)
1015 char const *yyp
= yystr
;
1022 goto do_not_strip_quotes
;
1026 goto do_not_strip_quotes
;
1039 do_not_strip_quotes
: ;
1043 return yystrlen (yystr
);
1045 return yystpcpy (yyres
, yystr
) - yyres
;
1049 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1050 about the unexpected token YYTOKEN for the state stack whose top is
1053 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1054 not large enough to hold the message. In that case, also set
1055 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1056 required number of bytes is too large to store. */
1058 yysyntax_error (YYSIZE_T
*yymsg_alloc
, char **yymsg
,
1059 yytype_int16
*yyssp
, int yytoken
)
1061 YYSIZE_T yysize0
= yytnamerr (YY_NULL
, yytname
[yytoken
]);
1062 YYSIZE_T yysize
= yysize0
;
1063 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1064 /* Internationalized format string. */
1065 const char *yyformat
= YY_NULL
;
1066 /* Arguments of yyformat. */
1067 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1068 /* Number of reported tokens (one for the "unexpected", one per
1072 /* There are many possibilities here to consider:
1073 - Assume YYFAIL is not used. It's too flawed to consider. See
1074 <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1075 for details. YYERROR is fine as it does not invoke this
1077 - If this state is a consistent state with a default action, then
1078 the only way this function was invoked is if the default action
1079 is an error action. In that case, don't check for expected
1080 tokens because there are none.
1081 - The only way there can be no lookahead present (in yychar) is if
1082 this state is a consistent state with a default action. Thus,
1083 detecting the absence of a lookahead is sufficient to determine
1084 that there is no unexpected or expected token to report. In that
1085 case, just report a simple "syntax error".
1086 - Don't assume there isn't a lookahead just because this state is a
1087 consistent state with a default action. There might have been a
1088 previous inconsistent state, consistent state with a non-default
1089 action, or user semantic action that manipulated yychar.
1090 - Of course, the expected token list depends on states to have
1091 correct lookahead information, and it depends on the parser not
1092 to perform extra reductions after fetching a lookahead from the
1093 scanner and before detecting a syntax error. Thus, state merging
1094 (from LALR or IELR) and default reductions corrupt the expected
1095 token list. However, the list is correct for canonical LR with
1096 one exception: it will still contain any token that will not be
1097 accepted due to an error action in a later state.
1099 if (yytoken
!= YYEMPTY
)
1101 int yyn
= yypact
[*yyssp
];
1102 yyarg
[yycount
++] = yytname
[yytoken
];
1103 if (!yypact_value_is_default (yyn
))
1105 /* Start YYX at -YYN if negative to avoid negative indexes in
1106 YYCHECK. In other words, skip the first -YYN actions for
1107 this state because they are default actions. */
1108 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1109 /* Stay within bounds of both yycheck and yytname. */
1110 int yychecklim
= YYLAST
- yyn
+ 1;
1111 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1114 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1115 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
1116 && !yytable_value_is_error (yytable
[yyx
+ yyn
]))
1118 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1124 yyarg
[yycount
++] = yytname
[yyx
];
1126 YYSIZE_T yysize1
= yysize
+ yytnamerr (YY_NULL
, yytname
[yyx
]);
1127 if (! (yysize
<= yysize1
1128 && yysize1
<= YYSTACK_ALLOC_MAXIMUM
))
1138 # define YYCASE_(N, S) \
1142 YYCASE_(0, YY_("syntax error"));
1143 YYCASE_(1, YY_("syntax error, unexpected %s"));
1144 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1145 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1146 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1147 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1152 YYSIZE_T yysize1
= yysize
+ yystrlen (yyformat
);
1153 if (! (yysize
<= yysize1
&& yysize1
<= YYSTACK_ALLOC_MAXIMUM
))
1158 if (*yymsg_alloc
< yysize
)
1160 *yymsg_alloc
= 2 * yysize
;
1161 if (! (yysize
<= *yymsg_alloc
1162 && *yymsg_alloc
<= YYSTACK_ALLOC_MAXIMUM
))
1163 *yymsg_alloc
= YYSTACK_ALLOC_MAXIMUM
;
1167 /* Avoid sprintf, as that infringes on the user's name space.
1168 Don't have undefined behavior even if the translation
1169 produced a string with the wrong number of "%s"s. */
1173 while ((*yyp
= *yyformat
) != '\0')
1174 if (*yyp
== '%' && yyformat
[1] == 's' && yyi
< yycount
)
1176 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1187 #endif /* YYERROR_VERBOSE */
1189 /*-----------------------------------------------.
1190 | Release the memory associated to this symbol. |
1191 `-----------------------------------------------*/
1194 #if (defined __STDC__ || defined __C99__FUNC__ \
1195 || defined __cplusplus || defined _MSC_VER)
1197 yydestruct (const char *yymsg
, int yytype
, YYSTYPE
*yyvaluep
, struct ktrfmt_parse_ctx
*ctx
)
1200 yydestruct (yymsg
, yytype
, yyvaluep
, ctx
)
1204 struct ktrfmt_parse_ctx
*ctx
;
1212 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
1224 #ifdef YYPARSE_PARAM
1225 #if (defined __STDC__ || defined __C99__FUNC__ \
1226 || defined __cplusplus || defined _MSC_VER)
1228 yyparse (void *YYPARSE_PARAM
)
1231 yyparse (YYPARSE_PARAM
)
1232 void *YYPARSE_PARAM
;
1234 #else /* ! YYPARSE_PARAM */
1235 #if (defined __STDC__ || defined __C99__FUNC__ \
1236 || defined __cplusplus || defined _MSC_VER)
1238 yyparse (struct ktrfmt_parse_ctx
*ctx
)
1242 struct ktrfmt_parse_ctx
*ctx
;
1246 /* The lookahead symbol. */
1250 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
1251 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
1252 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
1253 _Pragma ("GCC diagnostic push") \
1254 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
1255 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
1256 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
1257 _Pragma ("GCC diagnostic pop")
1259 /* Default value used for initialization, for pacifying older GCCs
1260 or non-GCC compilers. */
1261 static YYSTYPE yyval_default
;
1262 # define YY_INITIAL_VALUE(Value) = Value
1264 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1265 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1266 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
1268 #ifndef YY_INITIAL_VALUE
1269 # define YY_INITIAL_VALUE(Value) /* Nothing. */
1272 /* The semantic value of the lookahead symbol. */
1273 YYSTYPE yylval
YY_INITIAL_VALUE(yyval_default
);
1275 /* Number of syntax errors so far. */
1279 /* Number of tokens to shift before error messages enabled. */
1282 /* The stacks and their tools:
1283 `yyss': related to states.
1284 `yyvs': related to semantic values.
1286 Refer to the stacks through separate pointers, to allow yyoverflow
1287 to reallocate them elsewhere. */
1289 /* The state stack. */
1290 yytype_int16 yyssa
[YYINITDEPTH
];
1292 yytype_int16
*yyssp
;
1294 /* The semantic value stack. */
1295 YYSTYPE yyvsa
[YYINITDEPTH
];
1299 YYSIZE_T yystacksize
;
1303 /* Lookahead token as an internal (translated) token number. */
1305 /* The variables used to return semantic value and location from the
1310 /* Buffer for error messages, and its allocated size. */
1312 char *yymsg
= yymsgbuf
;
1313 YYSIZE_T yymsg_alloc
= sizeof yymsgbuf
;
1316 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1318 /* The number of symbols on the RHS of the reduced rule.
1319 Keep to zero when no symbol should be popped. */
1322 yyssp
= yyss
= yyssa
;
1323 yyvsp
= yyvs
= yyvsa
;
1324 yystacksize
= YYINITDEPTH
;
1326 YYDPRINTF ((stderr
, "Starting parse\n"));
1331 yychar
= YYEMPTY
; /* Cause a token to be read. */
1334 /*------------------------------------------------------------.
1335 | yynewstate -- Push a new state, which is found in yystate. |
1336 `------------------------------------------------------------*/
1338 /* In all cases, when you get here, the value and location stacks
1339 have just been pushed. So pushing a state here evens the stacks. */
1345 if (yyss
+ yystacksize
- 1 <= yyssp
)
1347 /* Get the current used size of the three stacks, in elements. */
1348 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1352 /* Give user a chance to reallocate the stack. Use copies of
1353 these so that the &'s don't force the real ones into
1355 YYSTYPE
*yyvs1
= yyvs
;
1356 yytype_int16
*yyss1
= yyss
;
1358 /* Each stack pointer address is followed by the size of the
1359 data in use in that stack, in bytes. This used to be a
1360 conditional around just the two extra args, but that might
1361 be undefined if yyoverflow is a macro. */
1362 yyoverflow (YY_("memory exhausted"),
1363 &yyss1
, yysize
* sizeof (*yyssp
),
1364 &yyvs1
, yysize
* sizeof (*yyvsp
),
1370 #else /* no yyoverflow */
1371 # ifndef YYSTACK_RELOCATE
1372 goto yyexhaustedlab
;
1374 /* Extend the stack our own way. */
1375 if (YYMAXDEPTH
<= yystacksize
)
1376 goto yyexhaustedlab
;
1378 if (YYMAXDEPTH
< yystacksize
)
1379 yystacksize
= YYMAXDEPTH
;
1382 yytype_int16
*yyss1
= yyss
;
1383 union yyalloc
*yyptr
=
1384 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1386 goto yyexhaustedlab
;
1387 YYSTACK_RELOCATE (yyss_alloc
, yyss
);
1388 YYSTACK_RELOCATE (yyvs_alloc
, yyvs
);
1389 # undef YYSTACK_RELOCATE
1391 YYSTACK_FREE (yyss1
);
1394 #endif /* no yyoverflow */
1396 yyssp
= yyss
+ yysize
- 1;
1397 yyvsp
= yyvs
+ yysize
- 1;
1399 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1400 (unsigned long int) yystacksize
));
1402 if (yyss
+ yystacksize
- 1 <= yyssp
)
1406 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1408 if (yystate
== YYFINAL
)
1418 /* Do appropriate processing given the current state. Read a
1419 lookahead token if we need one and don't already have one. */
1421 /* First try to decide what to do without reference to lookahead token. */
1422 yyn
= yypact
[yystate
];
1423 if (yypact_value_is_default (yyn
))
1426 /* Not known => get a lookahead token if don't already have one. */
1428 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1429 if (yychar
== YYEMPTY
)
1431 YYDPRINTF ((stderr
, "Reading a token: "));
1435 if (yychar
<= YYEOF
)
1437 yychar
= yytoken
= YYEOF
;
1438 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1442 yytoken
= YYTRANSLATE (yychar
);
1443 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1446 /* If the proper action on seeing token YYTOKEN is to reduce or to
1447 detect an error, take that action. */
1449 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1454 if (yytable_value_is_error (yyn
))
1460 /* Count tokens shifted since error; after three, turn off error
1465 /* Shift the lookahead token. */
1466 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1468 /* Discard the shifted token. */
1472 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1474 YY_IGNORE_MAYBE_UNINITIALIZED_END
1479 /*-----------------------------------------------------------.
1480 | yydefault -- do the default action for the current state. |
1481 `-----------------------------------------------------------*/
1483 yyn
= yydefact
[yystate
];
1489 /*-----------------------------.
1490 | yyreduce -- Do a reduction. |
1491 `-----------------------------*/
1493 /* yyn is the number of a rule to reduce with. */
1496 /* If YYLEN is nonzero, implement the default value of the action:
1499 Otherwise, the following line sets YYVAL to garbage.
1500 This behavior is undocumented and Bison
1501 users should not rely upon it. Assigning to YYVAL
1502 unconditionally makes the parser a bit smaller, and it avoids a
1503 GCC warning that YYVAL may be used uninitialized. */
1504 yyval
= yyvsp
[1-yylen
];
1507 YY_REDUCE_PRINT (yyn
);
1511 /* Line 1787 of yacc.c */
1512 #line 170 "ktrfmt.y"
1514 ctx
->var
= (yyvsp
[(1) - (1)].var
);
1519 /* Line 1787 of yacc.c */
1520 #line 175 "ktrfmt.y"
1523 if (!(yyvsp
[(1) - (1)].tok
)->str
)
1524 parse_err("out of memory");
1525 var
= evtr_var_new(uniq_varname());
1526 var
->val
.type
= EVTR_VAL_INT
;
1528 var
->val
.num
= strtoll((yyvsp
[(1) - (1)].tok
)->str
, NULL
, 0);
1530 parse_err("Can't parse numeric constant '%s'", (yyvsp
[(1) - (1)].tok
)->str
);
1533 tok_free((yyvsp
[(1) - (1)].tok
));
1538 /* Line 1787 of yacc.c */
1539 #line 189 "ktrfmt.y"
1542 if (!(yyvsp
[(1) - (1)].tok
)->str
)
1543 parse_err("out of memory");
1544 var
= evtr_var_new(uniq_varname());
1545 var
->val
.type
= EVTR_VAL_STR
;
1546 var
->val
.str
= (yyvsp
[(1) - (1)].tok
)->str
;
1547 if (!var
->val
.str
) {
1548 parse_err("out of memory");
1551 tok_free((yyvsp
[(1) - (1)].tok
));
1556 /* Line 1787 of yacc.c */
1557 #line 203 "ktrfmt.y"
1560 ctor
= evtr_var_new(uniq_varname());
1561 ctor
->val
.type
= EVTR_VAL_CTOR
;
1562 ctor
->val
.ctor
.name
= NULL
;
1563 TAILQ_INIT(&ctor
->val
.ctor
.args
);
1564 TAILQ_INSERT_HEAD(&ctor
->val
.ctor
.args
, &(yyvsp
[(1) - (1)].var
)->val
, link
);
1570 /* Line 1787 of yacc.c */
1571 #line 212 "ktrfmt.y"
1573 TAILQ_INSERT_HEAD(&(yyvsp
[(2) - (2)].var
)->val
.ctor
.args
, &(yyvsp
[(1) - (2)].var
)->val
, link
);
1574 (yyval
.var
) = (yyvsp
[(2) - (2)].var
);
1579 /* Line 1787 of yacc.c */
1580 #line 217 "ktrfmt.y"
1583 if (!(yyvsp
[(1) - (1)].tok
)->str
)
1584 parse_err("out of memory");
1585 printd(PARSE
, "TOK_CTOR\n");
1586 printd(PARSE
, "tok: %p, str = %p\n", (yyvsp
[(1) - (1)].tok
), (yyvsp
[(1) - (1)].tok
)->str
);
1587 var
= evtr_var_new(uniq_varname());
1588 var
->val
.type
= EVTR_VAL_CTOR
;
1589 var
->val
.ctor
.name
= (yyvsp
[(1) - (1)].tok
)->str
;
1590 TAILQ_INIT(&var
->val
.ctor
.args
);
1591 tok_free((yyvsp
[(1) - (1)].tok
));
1597 /* Line 1787 of yacc.c */
1598 #line 230 "ktrfmt.y"
1600 evtr_variable_value_t val
;
1601 if (!(yyvsp
[(1) - (2)].tok
)->str
)
1602 parse_err("out of memory");
1603 printd(PARSE
, "TOK_CTOR\n");
1604 printd(PARSE
, "tok: %p, str = %p\n", (yyvsp
[(1) - (2)].tok
), (yyvsp
[(1) - (2)].tok
)->str
);
1605 (yyvsp
[(2) - (2)].var
)->val
.ctor
.name
= (yyvsp
[(1) - (2)].tok
)->str
;
1606 (yyval
.var
) = (yyvsp
[(2) - (2)].var
);
1607 printd(PARSE
, "CTOR: %s\n", (yyvsp
[(1) - (2)].tok
)->str
);
1608 TAILQ_FOREACH(val
, &(yyvsp
[(2) - (2)].var
)->val
.ctor
.args
, link
) {
1609 switch (val
->type
) {
1611 printd(PARSE
, "\t%jd\n", val
->num
);
1614 printd(PARSE
, "\t\"%s\"\n", val
->str
);
1617 assert(!"can't get here");
1626 /* Line 1787 of yacc.c */
1627 #line 255 "ktrfmt.y"
1630 if (!(yyvsp
[(1) - (1)].tok
)->str
)
1631 parse_err("out of memory");
1632 printd(PARSE
, "TOK_ID\n");
1633 printd(PARSE
, "tok: %p, str = %p\n", (yyvsp
[(1) - (1)].tok
), (yyvsp
[(1) - (1)].tok
)->str
);
1634 var
= symtab_find(ctx
->symtab
, (yyvsp
[(1) - (1)].tok
)->str
);
1636 if (!(var
= evtr_var_new((yyvsp
[(1) - (1)].tok
)->str
))) {
1637 tok_free((yyvsp
[(1) - (1)].tok
));
1638 parse_err("out of memory");
1640 printd(PARSE
, "creating var %s\n", (yyvsp
[(1) - (1)].tok
)->str
);
1641 symtab_insert(ctx
->symtab
, (yyvsp
[(1) - (1)].tok
)->str
, var
);
1644 tok_free((yyvsp
[(1) - (1)].tok
));
1649 /* Line 1787 of yacc.c */
1650 #line 273 "ktrfmt.y"
1652 (yyval
.var
) = (yyvsp
[(1) - (1)].var
);
1657 /* Line 1787 of yacc.c */
1658 #line 277 "ktrfmt.y"
1662 if (index_hash(ctx
, (yyvsp
[(1) - (4)].var
)->name
, &(yyvsp
[(3) - (4)].var
)->val
, &var
))
1669 /* Line 1787 of yacc.c */
1670 #line 284 "ktrfmt.y"
1672 evtr_var_t var
, tmp
;
1673 if (!(yyvsp
[(3) - (3)].tok
)->str
)
1674 parse_err("out of memory");
1675 tmp
= evtr_var_new(uniq_varname());
1676 tmp
->val
.type
= EVTR_VAL_STR
;
1677 tmp
->val
.str
= (yyvsp
[(3) - (3)].tok
)->str
;
1679 if (index_hash(ctx
, (yyvsp
[(1) - (3)].var
)->name
, &tmp
->val
, &var
))
1681 tok_free((yyvsp
[(3) - (3)].tok
));
1687 /* Line 1787 of yacc.c */
1688 #line 297 "ktrfmt.y"
1690 (yyval
.var
) = (yyvsp
[(1) - (1)].var
);
1695 /* Line 1787 of yacc.c */
1696 #line 301 "ktrfmt.y"
1698 (yyval
.var
) = (yyvsp
[(1) - (1)].var
);
1703 /* Line 1787 of yacc.c */
1704 #line 305 "ktrfmt.y"
1706 (yyvsp
[(1) - (3)].var
)->val
= (yyvsp
[(3) - (3)].var
)->val
;
1707 ctx
->ev
->type
= EVTR_TYPE_STMT
;
1708 ctx
->ev
->stmt
.var
= (yyvsp
[(1) - (3)].var
);
1709 ctx
->ev
->stmt
.val
= &(yyvsp
[(3) - (3)].var
)->val
;
1710 ctx
->ev
->stmt
.op
= EVTR_OP_SET
;
1715 /* Line 1787 of yacc.c */
1716 #line 312 "ktrfmt.y"
1718 (yyvsp
[(1) - (3)].var
)->val
= (yyvsp
[(3) - (3)].var
)->val
;
1719 ctx
->ev
->type
= EVTR_TYPE_STMT
;
1720 ctx
->ev
->stmt
.var
= (yyvsp
[(1) - (3)].var
);
1721 ctx
->ev
->stmt
.val
= &(yyvsp
[(3) - (3)].var
)->val
;
1722 ctx
->ev
->stmt
.op
= EVTR_OP_SET
;
1727 /* Line 1787 of yacc.c */
1728 #line 320 "ktrfmt.y"
1730 (yyval
.na
) = (yyvsp
[(1) - (1)].na
);
1735 /* Line 1787 of yacc.c */
1736 #line 1737 "ktrfmt.tab.c"
1739 /* User semantic actions sometimes alter yychar, and that requires
1740 that yytoken be updated with the new translation. We take the
1741 approach of translating immediately before every use of yytoken.
1742 One alternative is translating here after every semantic action,
1743 but that translation would be missed if the semantic action invokes
1744 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1745 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1746 incorrect destructor might then be invoked immediately. In the
1747 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1748 to an incorrect destructor call or verbose syntax error message
1749 before the lookahead is translated. */
1750 YY_SYMBOL_PRINT ("-> $$ =", yyr1
[yyn
], &yyval
, &yyloc
);
1754 YY_STACK_PRINT (yyss
, yyssp
);
1758 /* Now `shift' the result of the reduction. Determine what state
1759 that goes to, based on the state we popped back to and the rule
1760 number reduced by. */
1764 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
1765 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1766 yystate
= yytable
[yystate
];
1768 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
1773 /*------------------------------------.
1774 | yyerrlab -- here on detecting error |
1775 `------------------------------------*/
1777 /* Make sure we have latest lookahead translation. See comments at
1778 user semantic actions for why this is necessary. */
1779 yytoken
= yychar
== YYEMPTY
? YYEMPTY
: YYTRANSLATE (yychar
);
1781 /* If not already recovering from an error, report this error. */
1785 #if ! YYERROR_VERBOSE
1786 yyerror (ctx
, YY_("syntax error"));
1788 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1791 char const *yymsgp
= YY_("syntax error");
1792 int yysyntax_error_status
;
1793 yysyntax_error_status
= YYSYNTAX_ERROR
;
1794 if (yysyntax_error_status
== 0)
1796 else if (yysyntax_error_status
== 1)
1798 if (yymsg
!= yymsgbuf
)
1799 YYSTACK_FREE (yymsg
);
1800 yymsg
= (char *) YYSTACK_ALLOC (yymsg_alloc
);
1804 yymsg_alloc
= sizeof yymsgbuf
;
1805 yysyntax_error_status
= 2;
1809 yysyntax_error_status
= YYSYNTAX_ERROR
;
1813 yyerror (ctx
, yymsgp
);
1814 if (yysyntax_error_status
== 2)
1815 goto yyexhaustedlab
;
1817 # undef YYSYNTAX_ERROR
1823 if (yyerrstatus
== 3)
1825 /* If just tried and failed to reuse lookahead token after an
1826 error, discard it. */
1828 if (yychar
<= YYEOF
)
1830 /* Return failure if at end of input. */
1831 if (yychar
== YYEOF
)
1836 yydestruct ("Error: discarding",
1837 yytoken
, &yylval
, ctx
);
1842 /* Else will try to reuse lookahead token after shifting the error
1847 /*---------------------------------------------------.
1848 | yyerrorlab -- error raised explicitly by YYERROR. |
1849 `---------------------------------------------------*/
1852 /* Pacify compilers like GCC when the user code never invokes
1853 YYERROR and the label yyerrorlab therefore never appears in user
1855 if (/*CONSTCOND*/ 0)
1858 /* Do not reclaim the symbols of the rule which action triggered
1862 YY_STACK_PRINT (yyss
, yyssp
);
1867 /*-------------------------------------------------------------.
1868 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1869 `-------------------------------------------------------------*/
1871 yyerrstatus
= 3; /* Each real token shifted decrements this. */
1875 yyn
= yypact
[yystate
];
1876 if (!yypact_value_is_default (yyn
))
1879 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
1887 /* Pop the current state because it cannot handle the error token. */
1892 yydestruct ("Error: popping",
1893 yystos
[yystate
], yyvsp
, ctx
);
1896 YY_STACK_PRINT (yyss
, yyssp
);
1899 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1901 YY_IGNORE_MAYBE_UNINITIALIZED_END
1904 /* Shift the error token. */
1905 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
1911 /*-------------------------------------.
1912 | yyacceptlab -- YYACCEPT comes here. |
1913 `-------------------------------------*/
1918 /*-----------------------------------.
1919 | yyabortlab -- YYABORT comes here. |
1920 `-----------------------------------*/
1925 #if !defined yyoverflow || YYERROR_VERBOSE
1926 /*-------------------------------------------------.
1927 | yyexhaustedlab -- memory exhaustion comes here. |
1928 `-------------------------------------------------*/
1930 yyerror (ctx
, YY_("memory exhausted"));
1936 if (yychar
!= YYEMPTY
)
1938 /* Make sure we have latest lookahead translation. See comments at
1939 user semantic actions for why this is necessary. */
1940 yytoken
= YYTRANSLATE (yychar
);
1941 yydestruct ("Cleanup: discarding lookahead",
1942 yytoken
, &yylval
, ctx
);
1944 /* Do not reclaim the symbols of the rule which action triggered
1945 this YYABORT or YYACCEPT. */
1947 YY_STACK_PRINT (yyss
, yyssp
);
1948 while (yyssp
!= yyss
)
1950 yydestruct ("Cleanup: popping",
1951 yystos
[*yyssp
], yyvsp
, ctx
);
1956 YYSTACK_FREE (yyss
);
1959 if (yymsg
!= yymsgbuf
)
1960 YYSTACK_FREE (yymsg
);
1962 /* Make sure YYID is used. */
1963 return YYID (yyresult
);
1967 /* Line 2050 of yacc.c */
1968 #line 325 "ktrfmt.y"
1971 void * __ktrfmt_scan_string(const char *);
1972 void __ktrfmt_delete_buffer(void *);
1975 __ktrfmt_error (struct ktrfmt_parse_ctx
*ctx
, const char *s
)
1977 do_parse_err(ctx
, "%s", s
);
1981 parse_string(evtr_event_t ev
, struct symtab
*symtab
, const char *str
,
1982 char *errbuf
, size_t errbufsz
)
1986 struct ktrfmt_parse_ctx ctx
;
1988 printd(PARSE
, "parsing \"%s\"\n", str
);
1990 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
);
2003 parse_var(const char *str
, struct symtab
*symtab
, struct evtr_variable
**var
,
2004 char *errbuf
, size_t errbufsz
)
2008 struct ktrfmt_parse_ctx ctx
;
2010 printd(PARSE
, "parsing \"%s\"\n", str
);
2012 ctx
.symtab
= symtab
;
2014 ctx
.errbuf
= errbuf
;
2015 ctx
.errbuf
[0] = '\0';
2016 ctx
.errbufsz
= errbufsz
;
2018 bufstate
= __ktrfmt_scan_string(str
);
2019 ret
= __ktrfmt_parse(&ctx
);
2020 __ktrfmt_delete_buffer(bufstate
);