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 */
88 #include "ktrfmt.tab.h"
91 struct ktrfmt_parse_ctx {
92 struct symtab *symtab;
93 struct evtr_variable *var;
94 struct evtr_variable_value *val;
98 int __ktrfmtlex(YYSTYPE *);
99 #define __ktrfmt_lex __ktrfmtlex
101 void __ktrfmt_error (struct ktrfmt_parse_ctx *, const char *);
104 struct evtr_variable *
105 evtr_var_new(const char *name)
107 struct evtr_variable *var;
109 var = calloc(1, sizeof(*var));
111 var->name = strdup(name);
113 var->val.type = EVTR_VAL_NIL;
119 * XXX: should be reentrant
126 static char buf[100];
129 snprintf(buf, sizeof(buf), "@%ld", serno);
135 /* Line 189 of yacc.c */
136 #line 137 "ktrfmt.tab.c"
138 /* Enabling traces. */
143 /* Enabling verbose error messages. */
144 #ifdef YYERROR_VERBOSE
145 # undef YYERROR_VERBOSE
146 # define YYERROR_VERBOSE 1
148 # define YYERROR_VERBOSE 1
151 /* Enabling the token table. */
152 #ifndef YYTOKEN_TABLE
153 # define YYTOKEN_TABLE 0
160 /* Put the tokens into the symbol table, so that GDB and other debuggers
167 TOK_LEFT_BRACK = 262,
168 TOK_RIGHT_BRACK = 263,
175 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
176 typedef union YYSTYPE
179 /* Line 214 of yacc.c */
183 struct evtr_variable *var;
184 struct evtr_variable_value *val;
189 /* Line 214 of yacc.c */
190 #line 191 "ktrfmt.tab.c"
192 # define YYSTYPE_IS_TRIVIAL 1
193 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
194 # define YYSTYPE_IS_DECLARED 1
198 /* Copy the second part of user declarations. */
201 /* Line 264 of yacc.c */
202 #line 203 "ktrfmt.tab.c"
209 typedef YYTYPE_UINT8 yytype_uint8;
211 typedef unsigned char yytype_uint8;
215 typedef YYTYPE_INT8 yytype_int8;
216 #elif (defined __STDC__ || defined __C99__FUNC__ \
217 || defined __cplusplus || defined _MSC_VER)
218 typedef signed char yytype_int8;
220 typedef short int yytype_int8;
224 typedef YYTYPE_UINT16 yytype_uint16;
226 typedef unsigned short int yytype_uint16;
230 typedef YYTYPE_INT16 yytype_int16;
232 typedef short int yytype_int16;
236 # ifdef __SIZE_TYPE__
237 # define YYSIZE_T __SIZE_TYPE__
238 # elif defined size_t
239 # define YYSIZE_T size_t
240 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
241 || defined __cplusplus || defined _MSC_VER)
242 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
243 # define YYSIZE_T size_t
245 # define YYSIZE_T unsigned int
249 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
254 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
255 # define YY_(msgid) dgettext ("bison-runtime", msgid)
259 # define YY_(msgid) msgid
263 /* Suppress unused-variable warnings by "using" E. */
264 #if ! defined lint || defined __GNUC__
265 # define YYUSE(e) ((void) (e))
267 # define YYUSE(e) /* empty */
270 /* Identity function, used to suppress warnings about constant conditions. */
274 #if (defined __STDC__ || defined __C99__FUNC__ \
275 || defined __cplusplus || defined _MSC_VER)
288 #if ! defined yyoverflow || YYERROR_VERBOSE
290 /* The parser invokes alloca or malloc; define the necessary symbols. */
292 # ifdef YYSTACK_USE_ALLOCA
293 # if YYSTACK_USE_ALLOCA
295 # define YYSTACK_ALLOC __builtin_alloca
296 # elif defined __BUILTIN_VA_ARG_INCR
297 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
299 # define YYSTACK_ALLOC __alloca
300 # elif defined _MSC_VER
301 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
302 # define alloca _alloca
304 # define YYSTACK_ALLOC alloca
305 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
306 || defined __cplusplus || defined _MSC_VER)
307 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
316 # ifdef YYSTACK_ALLOC
317 /* Pacify GCC's `empty if-body' warning. */
318 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
319 # ifndef YYSTACK_ALLOC_MAXIMUM
320 /* The OS might guarantee only one guard page at the bottom of the stack,
321 and a page size can be as small as 4096 bytes. So we cannot safely
322 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
323 to allow for a few compiler-allocated temporary stack slots. */
324 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
327 # define YYSTACK_ALLOC YYMALLOC
328 # define YYSTACK_FREE YYFREE
329 # ifndef YYSTACK_ALLOC_MAXIMUM
330 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
332 # if (defined __cplusplus && ! defined _STDLIB_H \
333 && ! ((defined YYMALLOC || defined malloc) \
334 && (defined YYFREE || defined free)))
335 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
341 # define YYMALLOC malloc
342 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
343 || defined __cplusplus || defined _MSC_VER)
344 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
349 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
350 || defined __cplusplus || defined _MSC_VER)
351 void free (void *); /* INFRINGES ON USER NAME SPACE */
355 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
358 #if (! defined yyoverflow \
359 && (! defined __cplusplus \
360 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
362 /* A type that is properly aligned for any stack member. */
365 yytype_int16 yyss_alloc;
369 /* The size of the maximum gap between one aligned stack and the next. */
370 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
372 /* The size of an array large to enough to hold all stacks, each with
374 # define YYSTACK_BYTES(N) \
375 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
376 + YYSTACK_GAP_MAXIMUM)
378 /* Copy COUNT objects from FROM to TO. The source and destination do
381 # if defined __GNUC__ && 1 < __GNUC__
382 # define YYCOPY(To, From, Count) \
383 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
385 # define YYCOPY(To, From, Count) \
389 for (yyi = 0; yyi < (Count); yyi++) \
390 (To)[yyi] = (From)[yyi]; \
396 /* Relocate STACK from its old location to the new one. The
397 local variables YYSIZE and YYSTACKSIZE give the old and new number of
398 elements in the stack, and YYPTR gives the new location of the
399 stack. Advance YYPTR to a properly aligned location for the next
401 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
404 YYSIZE_T yynewbytes; \
405 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
406 Stack = &yyptr->Stack_alloc; \
407 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
408 yyptr += yynewbytes / sizeof (*yyptr); \
414 /* YYFINAL -- State number of the termination state. */
416 /* YYLAST -- Last index in YYTABLE. */
419 /* YYNTOKENS -- Number of terminals. */
421 /* YYNNTS -- Number of nonterminals. */
423 /* YYNRULES -- Number of rules. */
425 /* YYNRULES -- Number of states. */
428 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
430 #define YYMAXUTOK 264
432 #define YYTRANSLATE(YYX) \
433 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
435 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
436 static const yytype_uint8 yytranslate[] =
438 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
439 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
440 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
441 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
442 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
443 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
444 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
445 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
446 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
447 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
448 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
449 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
450 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
451 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
452 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
453 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
454 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
455 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
456 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
457 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
458 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
459 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
460 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
461 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
462 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
463 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
468 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
470 static const yytype_uint8 yyprhs[] =
472 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
476 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
477 static const yytype_int8 yyrhs[] =
479 11, 0, -1, 12, -1, 16, -1, 18, -1, 4,
480 -1, 5, -1, 3, -1, 13, -1, 14, 7, 15,
481 8, -1, 14, 9, 3, -1, 14, -1, 15, -1,
482 16, 6, 13, -1, 17, -1
485 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
486 static const yytype_uint8 yyrline[] =
488 0, 88, 88, 90, 93, 95, 104, 118, 131, 135,
489 193, 196, 200, 204, 212
493 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
494 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
495 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
496 static const char *const yytname[] =
498 "$end", "error", "$undefined", "TOK_ID", "TOK_INT", "TOK_STR", "TOK_EQ",
499 "TOK_LEFT_BRACK", "TOK_RIGHT_BRACK", "TOK_DOT", "$accept", "input",
500 "stmt", "constant", "primary_expr", "postfix_expr", "unary_expr",
501 "assign_expr", "expr", 0
506 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
508 static const yytype_uint16 yytoknum[] =
510 0, 256, 257, 258, 259, 260, 261, 262, 263, 264
514 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
515 static const yytype_uint8 yyr1[] =
517 0, 10, 11, 12, 12, 13, 13, 14, 14, 15,
521 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
522 static const yytype_uint8 yyr2[] =
524 0, 2, 1, 1, 1, 1, 1, 1, 1, 4,
528 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
529 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
530 means the default is an error. */
531 static const yytype_uint8 yydefact[] =
533 0, 7, 5, 6, 0, 2, 8, 11, 12, 3,
534 14, 4, 1, 0, 0, 0, 0, 10, 13, 9
537 /* YYDEFGOTO[NTERM-NUM]. */
538 static const yytype_int8 yydefgoto[] =
540 -1, 4, 5, 6, 7, 8, 9, 10, 11
543 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
545 #define YYPACT_NINF -6
546 static const yytype_int8 yypact[] =
548 -3, -6, -6, -6, 4, -6, -6, -4, -6, 3,
549 -6, -6, -6, -3, 5, 2, 6, -6, -6, -6
552 /* YYPGOTO[NTERM-NUM]. */
553 static const yytype_int8 yypgoto[] =
555 -6, -6, -6, -5, -6, -2, -6, -6, -6
558 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
559 positive, shift that token. If negative, reduce the rule which
560 number is the opposite. If zero, do what YYDEFACT says.
561 If YYTABLE_NINF, syntax error. */
562 #define YYTABLE_NINF -1
563 static const yytype_uint8 yytable[] =
565 1, 2, 3, 13, 12, 14, 2, 3, 17, 15,
569 static const yytype_int8 yycheck[] =
571 3, 4, 5, 7, 0, 9, 4, 5, 3, 6,
575 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
576 symbol of state STATE-NUM. */
577 static const yytype_uint8 yystos[] =
579 0, 3, 4, 5, 11, 12, 13, 14, 15, 16,
580 17, 18, 0, 7, 9, 6, 15, 3, 13, 8
583 #define yyerrok (yyerrstatus = 0)
584 #define yyclearin (yychar = YYEMPTY)
588 #define YYACCEPT goto yyacceptlab
589 #define YYABORT goto yyabortlab
590 #define YYERROR goto yyerrorlab
593 /* Like YYERROR except do call yyerror. This remains here temporarily
594 to ease the transition to the new meaning of YYERROR, for GCC.
595 Once GCC version 2 has supplanted version 1, this can go. */
597 #define YYFAIL goto yyerrlab
599 #define YYRECOVERING() (!!yyerrstatus)
601 #define YYBACKUP(Token, Value) \
603 if (yychar == YYEMPTY && yylen == 1) \
607 yytoken = YYTRANSLATE (yychar); \
613 yyerror (ctx, YY_("syntax error: cannot back up")); \
620 #define YYERRCODE 256
623 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
624 If N is 0, then set CURRENT to the empty location which ends
625 the previous symbol: RHS[0] (always defined). */
627 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
628 #ifndef YYLLOC_DEFAULT
629 # define YYLLOC_DEFAULT(Current, Rhs, N) \
633 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
634 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
635 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
636 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
640 (Current).first_line = (Current).last_line = \
641 YYRHSLOC (Rhs, 0).last_line; \
642 (Current).first_column = (Current).last_column = \
643 YYRHSLOC (Rhs, 0).last_column; \
649 /* YY_LOCATION_PRINT -- Print the location on the stream.
650 This macro was not mandated originally: define only if we know
651 we won't break user code: when these are the locations we know. */
653 #ifndef YY_LOCATION_PRINT
654 # if YYLTYPE_IS_TRIVIAL
655 # define YY_LOCATION_PRINT(File, Loc) \
656 fprintf (File, "%d.%d-%d.%d", \
657 (Loc).first_line, (Loc).first_column, \
658 (Loc).last_line, (Loc).last_column)
660 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
665 /* YYLEX -- calling `yylex' with the right arguments. */
668 # define YYLEX yylex (&yylval, YYLEX_PARAM)
670 # define YYLEX yylex (&yylval)
673 /* Enable debugging if requested. */
677 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
678 # define YYFPRINTF fprintf
681 # define YYDPRINTF(Args) \
687 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
691 YYFPRINTF (stderr, "%s ", Title); \
692 yy_symbol_print (stderr, \
694 YYFPRINTF (stderr, "\n"); \
699 /*--------------------------------.
700 | Print this symbol on YYOUTPUT. |
701 `--------------------------------*/
704 #if (defined __STDC__ || defined __C99__FUNC__ \
705 || defined __cplusplus || defined _MSC_VER)
707 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct ktrfmt_parse_ctx *ctx)
710 yy_symbol_value_print (yyoutput, yytype, yyvaluep, ctx)
713 YYSTYPE const * const yyvaluep;
714 struct ktrfmt_parse_ctx *ctx;
721 if (yytype < YYNTOKENS)
722 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
734 /*--------------------------------.
735 | Print this symbol on YYOUTPUT. |
736 `--------------------------------*/
738 #if (defined __STDC__ || defined __C99__FUNC__ \
739 || defined __cplusplus || defined _MSC_VER)
741 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct ktrfmt_parse_ctx *ctx)
744 yy_symbol_print (yyoutput, yytype, yyvaluep, ctx)
747 YYSTYPE const * const yyvaluep;
748 struct ktrfmt_parse_ctx *ctx;
751 if (yytype < YYNTOKENS)
752 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
754 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
756 yy_symbol_value_print (yyoutput, yytype, yyvaluep, ctx);
757 YYFPRINTF (yyoutput, ")");
760 /*------------------------------------------------------------------.
761 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
763 `------------------------------------------------------------------*/
765 #if (defined __STDC__ || defined __C99__FUNC__ \
766 || defined __cplusplus || defined _MSC_VER)
768 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
771 yy_stack_print (yybottom, yytop)
772 yytype_int16 *yybottom;
776 YYFPRINTF (stderr, "Stack now");
777 for (; yybottom <= yytop; yybottom++)
779 int yybot = *yybottom;
780 YYFPRINTF (stderr, " %d", yybot);
782 YYFPRINTF (stderr, "\n");
785 # define YY_STACK_PRINT(Bottom, Top) \
788 yy_stack_print ((Bottom), (Top)); \
792 /*------------------------------------------------.
793 | Report that the YYRULE is going to be reduced. |
794 `------------------------------------------------*/
796 #if (defined __STDC__ || defined __C99__FUNC__ \
797 || defined __cplusplus || defined _MSC_VER)
799 yy_reduce_print (YYSTYPE *yyvsp, int yyrule, struct ktrfmt_parse_ctx *ctx)
802 yy_reduce_print (yyvsp, yyrule, ctx)
805 struct ktrfmt_parse_ctx *ctx;
808 int yynrhs = yyr2[yyrule];
810 unsigned long int yylno = yyrline[yyrule];
811 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
813 /* The symbols being reduced. */
814 for (yyi = 0; yyi < yynrhs; yyi++)
816 YYFPRINTF (stderr, " $%d = ", yyi + 1);
817 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
818 &(yyvsp[(yyi + 1) - (yynrhs)])
820 YYFPRINTF (stderr, "\n");
824 # define YY_REDUCE_PRINT(Rule) \
827 yy_reduce_print (yyvsp, Rule, ctx); \
830 /* Nonzero means print parse trace. It is left uninitialized so that
831 multiple parsers can coexist. */
834 # define YYDPRINTF(Args)
835 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
836 # define YY_STACK_PRINT(Bottom, Top)
837 # define YY_REDUCE_PRINT(Rule)
838 #endif /* !YYDEBUG */
841 /* YYINITDEPTH -- initial size of the parser's stacks. */
843 # define YYINITDEPTH 200
846 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
847 if the built-in stack extension method is used).
849 Do not make this value too large; the results are undefined if
850 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
851 evaluated with infinite-precision integer arithmetic. */
854 # define YYMAXDEPTH 10000
862 # if defined __GLIBC__ && defined _STRING_H
863 # define yystrlen strlen
865 /* Return the length of YYSTR. */
866 #if (defined __STDC__ || defined __C99__FUNC__ \
867 || defined __cplusplus || defined _MSC_VER)
869 yystrlen (const char *yystr)
877 for (yylen = 0; yystr[yylen]; yylen++)
885 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
886 # define yystpcpy stpcpy
888 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
890 #if (defined __STDC__ || defined __C99__FUNC__ \
891 || defined __cplusplus || defined _MSC_VER)
893 yystpcpy (char *yydest, const char *yysrc)
896 yystpcpy (yydest, yysrc)
902 const char *yys = yysrc;
904 while ((*yyd++ = *yys++) != '\0')
913 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
914 quotes and backslashes, so that it's suitable for yyerror. The
915 heuristic is that double-quoting is unnecessary unless the string
916 contains an apostrophe, a comma, or backslash (other than
917 backslash-backslash). YYSTR is taken from yytname. If YYRES is
918 null, do not copy; instead, return the length of what the result
921 yytnamerr (char *yyres, const char *yystr)
926 char const *yyp = yystr;
933 goto do_not_strip_quotes;
937 goto do_not_strip_quotes;
950 do_not_strip_quotes: ;
954 return yystrlen (yystr);
956 return yystpcpy (yyres, yystr) - yyres;
960 /* Copy into YYRESULT an error message about the unexpected token
961 YYCHAR while in state YYSTATE. Return the number of bytes copied,
962 including the terminating null byte. If YYRESULT is null, do not
963 copy anything; just return the number of bytes that would be
964 copied. As a special case, return 0 if an ordinary "syntax error"
965 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
968 yysyntax_error (char *yyresult, int yystate, int yychar)
970 int yyn = yypact[yystate];
972 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
976 int yytype = YYTRANSLATE (yychar);
977 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
978 YYSIZE_T yysize = yysize0;
980 int yysize_overflow = 0;
981 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
982 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
986 /* This is so xgettext sees the translatable formats that are
987 constructed on the fly. */
988 YY_("syntax error, unexpected %s");
989 YY_("syntax error, unexpected %s, expecting %s");
990 YY_("syntax error, unexpected %s, expecting %s or %s");
991 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
992 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
996 static char const yyunexpected[] = "syntax error, unexpected %s";
997 static char const yyexpecting[] = ", expecting %s";
998 static char const yyor[] = " or %s";
999 char yyformat[sizeof yyunexpected
1000 + sizeof yyexpecting - 1
1001 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1002 * (sizeof yyor - 1))];
1003 char const *yyprefix = yyexpecting;
1005 /* Start YYX at -YYN if negative to avoid negative indexes in
1007 int yyxbegin = yyn < 0 ? -yyn : 0;
1009 /* Stay within bounds of both yycheck and yytname. */
1010 int yychecklim = YYLAST - yyn + 1;
1011 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1014 yyarg[0] = yytname[yytype];
1015 yyfmt = yystpcpy (yyformat, yyunexpected);
1017 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1018 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1020 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1024 yyformat[sizeof yyunexpected - 1] = '\0';
1027 yyarg[yycount++] = yytname[yyx];
1028 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1029 yysize_overflow |= (yysize1 < yysize);
1031 yyfmt = yystpcpy (yyfmt, yyprefix);
1035 yyf = YY_(yyformat);
1036 yysize1 = yysize + yystrlen (yyf);
1037 yysize_overflow |= (yysize1 < yysize);
1040 if (yysize_overflow)
1041 return YYSIZE_MAXIMUM;
1045 /* Avoid sprintf, as that infringes on the user's name space.
1046 Don't have undefined behavior even if the translation
1047 produced a string with the wrong number of "%s"s. */
1048 char *yyp = yyresult;
1050 while ((*yyp = *yyf) != '\0')
1052 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1054 yyp += yytnamerr (yyp, yyarg[yyi++]);
1067 #endif /* YYERROR_VERBOSE */
1070 /*-----------------------------------------------.
1071 | Release the memory associated to this symbol. |
1072 `-----------------------------------------------*/
1075 #if (defined __STDC__ || defined __C99__FUNC__ \
1076 || defined __cplusplus || defined _MSC_VER)
1078 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, struct ktrfmt_parse_ctx *ctx)
1081 yydestruct (yymsg, yytype, yyvaluep, ctx)
1085 struct ktrfmt_parse_ctx *ctx;
1093 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1103 /* Prevent warnings from -Wmissing-prototypes. */
1104 #ifdef YYPARSE_PARAM
1105 #if defined __STDC__ || defined __cplusplus
1106 int yyparse (void *YYPARSE_PARAM);
1110 #else /* ! YYPARSE_PARAM */
1111 #if defined __STDC__ || defined __cplusplus
1112 int yyparse (struct ktrfmt_parse_ctx *ctx);
1116 #endif /* ! YYPARSE_PARAM */
1122 /*-------------------------.
1123 | yyparse or yypush_parse. |
1124 `-------------------------*/
1126 #ifdef YYPARSE_PARAM
1127 #if (defined __STDC__ || defined __C99__FUNC__ \
1128 || defined __cplusplus || defined _MSC_VER)
1130 yyparse (void *YYPARSE_PARAM)
1133 yyparse (YYPARSE_PARAM)
1134 void *YYPARSE_PARAM;
1136 #else /* ! YYPARSE_PARAM */
1137 #if (defined __STDC__ || defined __C99__FUNC__ \
1138 || defined __cplusplus || defined _MSC_VER)
1140 yyparse (struct ktrfmt_parse_ctx *ctx)
1144 struct ktrfmt_parse_ctx *ctx;
1148 /* The lookahead symbol. */
1151 /* The semantic value of the lookahead symbol. */
1154 /* Number of syntax errors so far. */
1158 /* Number of tokens to shift before error messages enabled. */
1161 /* The stacks and their tools:
1162 `yyss': related to states.
1163 `yyvs': related to semantic values.
1165 Refer to the stacks thru separate pointers, to allow yyoverflow
1166 to reallocate them elsewhere. */
1168 /* The state stack. */
1169 yytype_int16 yyssa[YYINITDEPTH];
1171 yytype_int16 *yyssp;
1173 /* The semantic value stack. */
1174 YYSTYPE yyvsa[YYINITDEPTH];
1178 YYSIZE_T yystacksize;
1182 /* Lookahead token as an internal (translated) token number. */
1184 /* The variables used to return semantic value and location from the
1189 /* Buffer for error messages, and its allocated size. */
1191 char *yymsg = yymsgbuf;
1192 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1195 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1197 /* The number of symbols on the RHS of the reduced rule.
1198 Keep to zero when no symbol should be popped. */
1204 yystacksize = YYINITDEPTH;
1206 YYDPRINTF ((stderr, "Starting parse\n"));
1211 yychar = YYEMPTY; /* Cause a token to be read. */
1213 /* Initialize stack pointers.
1214 Waste one element of value and location stack
1215 so that they stay on the same level as the state stack.
1216 The wasted elements are never initialized. */
1222 /*------------------------------------------------------------.
1223 | yynewstate -- Push a new state, which is found in yystate. |
1224 `------------------------------------------------------------*/
1226 /* In all cases, when you get here, the value and location stacks
1227 have just been pushed. So pushing a state here evens the stacks. */
1233 if (yyss + yystacksize - 1 <= yyssp)
1235 /* Get the current used size of the three stacks, in elements. */
1236 YYSIZE_T yysize = yyssp - yyss + 1;
1240 /* Give user a chance to reallocate the stack. Use copies of
1241 these so that the &'s don't force the real ones into
1243 YYSTYPE *yyvs1 = yyvs;
1244 yytype_int16 *yyss1 = yyss;
1246 /* Each stack pointer address is followed by the size of the
1247 data in use in that stack, in bytes. This used to be a
1248 conditional around just the two extra args, but that might
1249 be undefined if yyoverflow is a macro. */
1250 yyoverflow (YY_("memory exhausted"),
1251 &yyss1, yysize * sizeof (*yyssp),
1252 &yyvs1, yysize * sizeof (*yyvsp),
1258 #else /* no yyoverflow */
1259 # ifndef YYSTACK_RELOCATE
1260 goto yyexhaustedlab;
1262 /* Extend the stack our own way. */
1263 if (YYMAXDEPTH <= yystacksize)
1264 goto yyexhaustedlab;
1266 if (YYMAXDEPTH < yystacksize)
1267 yystacksize = YYMAXDEPTH;
1270 yytype_int16 *yyss1 = yyss;
1271 union yyalloc *yyptr =
1272 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1274 goto yyexhaustedlab;
1275 YYSTACK_RELOCATE (yyss_alloc, yyss);
1276 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1277 # undef YYSTACK_RELOCATE
1279 YYSTACK_FREE (yyss1);
1282 #endif /* no yyoverflow */
1284 yyssp = yyss + yysize - 1;
1285 yyvsp = yyvs + yysize - 1;
1287 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1288 (unsigned long int) yystacksize));
1290 if (yyss + yystacksize - 1 <= yyssp)
1294 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1296 if (yystate == YYFINAL)
1306 /* Do appropriate processing given the current state. Read a
1307 lookahead token if we need one and don't already have one. */
1309 /* First try to decide what to do without reference to lookahead token. */
1310 yyn = yypact[yystate];
1311 if (yyn == YYPACT_NINF)
1314 /* Not known => get a lookahead token if don't already have one. */
1316 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1317 if (yychar == YYEMPTY)
1319 YYDPRINTF ((stderr, "Reading a token: "));
1323 if (yychar <= YYEOF)
1325 yychar = yytoken = YYEOF;
1326 YYDPRINTF ((stderr, "Now at end of input.\n"));
1330 yytoken = YYTRANSLATE (yychar);
1331 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1334 /* If the proper action on seeing token YYTOKEN is to reduce or to
1335 detect an error, take that action. */
1337 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1342 if (yyn == 0 || yyn == YYTABLE_NINF)
1348 /* Count tokens shifted since error; after three, turn off error
1353 /* Shift the lookahead token. */
1354 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1356 /* Discard the shifted token. */
1365 /*-----------------------------------------------------------.
1366 | yydefault -- do the default action for the current state. |
1367 `-----------------------------------------------------------*/
1369 yyn = yydefact[yystate];
1375 /*-----------------------------.
1376 | yyreduce -- Do a reduction. |
1377 `-----------------------------*/
1379 /* yyn is the number of a rule to reduce with. */
1382 /* If YYLEN is nonzero, implement the default value of the action:
1385 Otherwise, the following line sets YYVAL to garbage.
1386 This behavior is undocumented and Bison
1387 users should not rely upon it. Assigning to YYVAL
1388 unconditionally makes the parser a bit smaller, and it avoids a
1389 GCC warning that YYVAL may be used uninitialized. */
1390 yyval = yyvsp[1-yylen];
1393 YY_REDUCE_PRINT (yyn);
1398 /* Line 1455 of yacc.c */
1401 ctx->var = (yyvsp[(1) - (1)].var);
1407 /* Line 1455 of yacc.c */
1411 var = evtr_var_new(uniq_varname());
1412 var->val.type = EVTR_VAL_INT;
1414 atoll((yyvsp[(1) - (1)].tok)->str); /* XXX */
1416 tok_free((yyvsp[(1) - (1)].tok));
1422 /* Line 1455 of yacc.c */
1423 #line 104 "ktrfmt.y"
1426 var = evtr_var_new(uniq_varname());
1427 var->val.type = EVTR_VAL_STR;
1428 var->val.str = (yyvsp[(1) - (1)].tok)->str;
1429 if (!var->val.str) {
1430 fprintf(stderr, "oom\n");
1434 tok_free((yyvsp[(1) - (1)].tok));
1440 /* Line 1455 of yacc.c */
1441 #line 118 "ktrfmt.y"
1444 printd(PARSE, "TOK_ID\n");
1445 printd(PARSE, "tok: %p, str = %p\n", (yyvsp[(1) - (1)].tok), (yyvsp[(1) - (1)].tok)->str);
1446 var = symtab_find(ctx->symtab, (yyvsp[(1) - (1)].tok)->str);
1448 var = evtr_var_new((yyvsp[(1) - (1)].tok)->str); /* XXX: oom */
1449 printd(PARSE, "creating var %s\n", (yyvsp[(1) - (1)].tok)->str);
1450 symtab_insert(ctx->symtab, (yyvsp[(1) - (1)].tok)->str, var);
1453 tok_free((yyvsp[(1) - (1)].tok));
1459 /* Line 1455 of yacc.c */
1460 #line 131 "ktrfmt.y"
1462 (yyval.var) = (yyvsp[(1) - (1)].var);
1468 /* Line 1455 of yacc.c */
1469 #line 135 "ktrfmt.y"
1471 evtr_var_t hsh, var;
1472 evtr_variable_value_t val;
1474 hsh = symtab_find(ctx->symtab, (yyvsp[(1) - (4)].var)->name);
1477 printd(PARSE, "creating hash: %s\n", (yyvsp[(1) - (4)].var)->name);
1478 hsh = evtr_var_new((yyvsp[(1) - (4)].var)->name);
1479 hsh->val.type = EVTR_VAL_HASH;
1480 hsh->val.hashtab = hash_new();
1481 symtab_insert(ctx->symtab, (yyvsp[(1) - (4)].var)->str, hsh);
1484 if (hsh->val.type == EVTR_VAL_NIL) {
1485 /* it's probably the first time we see this "variable" */
1486 printd(PARSE, "creating hash for %s\n", hsh->name);
1487 hsh->val.type = EVTR_VAL_HASH;
1488 hsh->val.hashtab = hash_new();
1489 } else if (hsh->val.type != EVTR_VAL_HASH) {
1490 printd(PARSE, "trying to use type %d as hash\n", hsh->val.type);
1493 val = &(yyvsp[(3) - (4)].var)->val;
1494 if (val->type == EVTR_VAL_INT) {
1496 printd(PARSE, "looking up %s[%jd] in %p\n", hsh->name, val->num, hsh->val.hashtab);
1497 } else if (val->type == EVTR_VAL_STR) {
1498 key = (uintptr_t)val->str;
1499 printd(PARSE, "looking up %s[\"%s\"] in %p\n", hsh->name, val->str, hsh->val.hashtab);
1501 fprintf(stderr, "trying to index hash w/ non-supported value\n");
1505 if (hash_find(hsh->val.hashtab, key, &ret)) {
1506 printd(PARSE, "didn't find it\n");
1507 var = evtr_var_new(uniq_varname());
1509 printd(PARSE, "inserting it as %s\n", var->name);
1510 if (!hash_insert(hsh->val.hashtab, key, (uintptr_t)var)) {
1511 fprintf(stderr, "can't insert tmp "
1512 "variable into hash\n");
1519 var = (struct evtr_variable *)ret;
1522 fprintf(stderr, "no var!\n");
1532 /* Line 1455 of yacc.c */
1533 #line 193 "ktrfmt.y"
1541 /* Line 1455 of yacc.c */
1542 #line 196 "ktrfmt.y"
1544 (yyval.var) = (yyvsp[(1) - (1)].var);
1550 /* Line 1455 of yacc.c */
1551 #line 200 "ktrfmt.y"
1553 (yyval.var) = (yyvsp[(1) - (1)].var);
1559 /* Line 1455 of yacc.c */
1560 #line 204 "ktrfmt.y"
1562 (yyvsp[(1) - (3)].var)->val = (yyvsp[(3) - (3)].var)->val;
1563 ctx->ev->type = EVTR_TYPE_STMT;
1564 ctx->ev->stmt.var = (yyvsp[(1) - (3)].var);
1565 ctx->ev->stmt.val = &(yyvsp[(3) - (3)].var)->val;
1566 ctx->ev->stmt.op = EVTR_OP_SET;
1572 /* Line 1455 of yacc.c */
1573 #line 212 "ktrfmt.y"
1575 (yyval.na) = (yyvsp[(1) - (1)].na);
1581 /* Line 1455 of yacc.c */
1582 #line 1583 "ktrfmt.tab.c"
1585 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1589 YY_STACK_PRINT (yyss, yyssp);
1593 /* Now `shift' the result of the reduction. Determine what state
1594 that goes to, based on the state we popped back to and the rule
1595 number reduced by. */
1599 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1600 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1601 yystate = yytable[yystate];
1603 yystate = yydefgoto[yyn - YYNTOKENS];
1608 /*------------------------------------.
1609 | yyerrlab -- here on detecting error |
1610 `------------------------------------*/
1612 /* If not already recovering from an error, report this error. */
1616 #if ! YYERROR_VERBOSE
1617 yyerror (ctx, YY_("syntax error"));
1620 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1621 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1623 YYSIZE_T yyalloc = 2 * yysize;
1624 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1625 yyalloc = YYSTACK_ALLOC_MAXIMUM;
1626 if (yymsg != yymsgbuf)
1627 YYSTACK_FREE (yymsg);
1628 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1630 yymsg_alloc = yyalloc;
1634 yymsg_alloc = sizeof yymsgbuf;
1638 if (0 < yysize && yysize <= yymsg_alloc)
1640 (void) yysyntax_error (yymsg, yystate, yychar);
1641 yyerror (ctx, yymsg);
1645 yyerror (ctx, YY_("syntax error"));
1647 goto yyexhaustedlab;
1655 if (yyerrstatus == 3)
1657 /* If just tried and failed to reuse lookahead token after an
1658 error, discard it. */
1660 if (yychar <= YYEOF)
1662 /* Return failure if at end of input. */
1663 if (yychar == YYEOF)
1668 yydestruct ("Error: discarding",
1669 yytoken, &yylval, ctx);
1674 /* Else will try to reuse lookahead token after shifting the error
1679 /*---------------------------------------------------.
1680 | yyerrorlab -- error raised explicitly by YYERROR. |
1681 `---------------------------------------------------*/
1684 /* Pacify compilers like GCC when the user code never invokes
1685 YYERROR and the label yyerrorlab therefore never appears in user
1687 if (/*CONSTCOND*/ 0)
1690 /* Do not reclaim the symbols of the rule which action triggered
1694 YY_STACK_PRINT (yyss, yyssp);
1699 /*-------------------------------------------------------------.
1700 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1701 `-------------------------------------------------------------*/
1703 yyerrstatus = 3; /* Each real token shifted decrements this. */
1707 yyn = yypact[yystate];
1708 if (yyn != YYPACT_NINF)
1711 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1719 /* Pop the current state because it cannot handle the error token. */
1724 yydestruct ("Error: popping",
1725 yystos[yystate], yyvsp, ctx);
1728 YY_STACK_PRINT (yyss, yyssp);
1734 /* Shift the error token. */
1735 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1741 /*-------------------------------------.
1742 | yyacceptlab -- YYACCEPT comes here. |
1743 `-------------------------------------*/
1748 /*-----------------------------------.
1749 | yyabortlab -- YYABORT comes here. |
1750 `-----------------------------------*/
1755 #if !defined(yyoverflow) || YYERROR_VERBOSE
1756 /*-------------------------------------------------.
1757 | yyexhaustedlab -- memory exhaustion comes here. |
1758 `-------------------------------------------------*/
1760 yyerror (ctx, YY_("memory exhausted"));
1766 if (yychar != YYEMPTY)
1767 yydestruct ("Cleanup: discarding lookahead",
1768 yytoken, &yylval, ctx);
1769 /* Do not reclaim the symbols of the rule which action triggered
1770 this YYABORT or YYACCEPT. */
1772 YY_STACK_PRINT (yyss, yyssp);
1773 while (yyssp != yyss)
1775 yydestruct ("Cleanup: popping",
1776 yystos[*yyssp], yyvsp, ctx);
1781 YYSTACK_FREE (yyss);
1784 if (yymsg != yymsgbuf)
1785 YYSTACK_FREE (yymsg);
1787 /* Make sure YYID is used. */
1788 return YYID (yyresult);
1793 /* Line 1675 of yacc.c */
1794 #line 217 "ktrfmt.y"
1797 void * __ktrfmt_scan_string(const char *);
1798 void __ktrfmt_delete_buffer(void *);
1801 __ktrfmt_error (struct ktrfmt_parse_ctx *ctx, const char *s)
1804 fprintf(stderr, "%s\n", s);
1808 parse_string(evtr_event_t ev, struct symtab *symtab, const char *str)
1812 struct ktrfmt_parse_ctx ctx;
1814 printd(PARSE, "parsing \"%s\"\n", str);
1816 ctx.symtab = symtab;
1817 bufstate = __ktrfmt_scan_string(str);
1818 ret = __ktrfmt_parse(&ctx);
1819 __ktrfmt_delete_buffer(bufstate);
1825 parse_var(const char *str, struct symtab *symtab, struct evtr_variable **var)
1829 struct ktrfmt_parse_ctx ctx;
1832 ctx.symtab = symtab;
1834 bufstate = __ktrfmt_scan_string(str);
1835 ret = __ktrfmt_parse(&ctx);
1836 __ktrfmt_delete_buffer(bufstate);