gdb - Local mods (compile)
[dragonfly.git] / lib / libevtr / ktrfmt.tab.c
1 /* A Bison parser, made by GNU Bison 2.7.12-4996.  */
2
3 /* Bison implementation for Yacc-like parsers in C
4    
5       Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
6    
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.
11    
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.
16    
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/>.  */
19
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.
29    
30    This special exception was added by the Free Software Foundation in
31    version 2.2 of Bison.  */
32
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34    simplifying the original so-called "semantic" parser.  */
35
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.  */
42
43 /* Identify Bison output.  */
44 #define YYBISON 1
45
46 /* Bison version.  */
47 #define YYBISON_VERSION "2.7.12-4996"
48
49 /* Skeleton name.  */
50 #define YYSKELETON_NAME "yacc.c"
51
52 /* Pure parsers.  */
53 #define YYPURE 1
54
55 /* Push parsers.  */
56 #define YYPUSH 0
57
58 /* Pull parsers.  */
59 #define YYPULL 1
60
61
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
70
71 /* Copy the first part of user declarations.  */
72 /* Line 371 of yacc.c  */
73 #line 1 "ktrfmt.y"
74
75
76 #include <assert.h>
77 #include <errno.h>
78 #include <stdarg.h>
79 #include <stdlib.h>
80 #include <string.h>
81 #include <sys/queue.h>
82
83 #include "evtr.h"
84 #include "tok.h"
85 #include "internal.h"
86 #include "ktrfmt.tab.h"
87
88 int __ktrfmtlex(YYSTYPE *);
89 #define __ktrfmt_lex __ktrfmtlex
90
91 void __ktrfmt_error (struct ktrfmt_parse_ctx *, const char *);
92
93 static void do_parse_err(struct ktrfmt_parse_ctx *, const char *, ...)
94                 __printflike(2, 3);
95
96 static
97 void
98 do_parse_err(struct ktrfmt_parse_ctx *ctx, const char *fmt, ...)
99 {
100         va_list ap;
101
102         va_start(ap, fmt);
103         vsnprintf(ctx->errbuf, ctx->errbufsz, fmt, ap);
104         va_end(ap);
105         ctx->err = !0;
106 }
107
108 #define parse_err(fmt, ...)                     \
109         do {                                    \
110                 do_parse_err(ctx, fmt, ##__VA_ARGS__);  \
111                 YYABORT;                                \
112         } while (0)
113
114 static
115 struct evtr_variable *
116 evtr_var_new(const char *name)
117 {
118         struct evtr_variable *var;
119
120         var = calloc(1, sizeof(*var));
121         if (var) {
122                 if (!(var->name = strdup(name))) {
123                         free(var);
124                         return NULL;
125                 }
126                 var->val.type = EVTR_VAL_NIL;
127         }
128         return var;
129 }
130
131 /*
132  * XXX: should be reentrant
133  */
134 static
135 char *
136 uniq_varname(void)
137 {
138         static long serno;
139         static char buf[100];
140
141         serno++;
142         snprintf(buf, sizeof(buf), "@%ld", serno);
143         return &buf[0];
144 }
145
146 static
147 int
148 index_hash(struct ktrfmt_parse_ctx *ctx, const char *hashname,
149            evtr_variable_value_t val, evtr_var_t *_var)
150 {
151         evtr_var_t hsh, var;
152         uintptr_t ret, key;
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);
161                 return !0;
162         }
163         if (val->type == EVTR_VAL_INT) {
164                 key = val->num;
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);
171         } else {
172                 do_parse_err(ctx, "trying to index hash '%s' with "
173                              "non-supported value", hashname);
174                 return !0;
175         }
176
177         if (hash_find(hsh->val.hashtab, key, &ret)) {
178                 printd(PARSE, "didn't find it\n");
179                 var = evtr_var_new(uniq_varname());
180                 if (var) {
181                         printd(PARSE, "inserting it as %s\n", var->name);
182                         if (!hash_insert(hsh->val.hashtab, key,
183                                          (uintptr_t)var)) {
184                                 do_parse_err(ctx, "can't insert temporary "
185                                         "variable into hash\n");
186                                 return !0;
187                         }
188                         symtab_insert(ctx->symtab, var->name, var);
189                 } else {
190                         do_parse_err(ctx, "out of memory");
191                 }
192         } else {
193                 var = (struct evtr_variable *)ret;
194         }
195         if (!var) {
196                 fprintf(stderr, "no var!\n");
197                 return !0;
198                 /* XXX */
199         }
200         *_var = var;
201         return 0;
202 }
203
204
205 /* Line 371 of yacc.c  */
206 #line 207 "ktrfmt.tab.c"
207
208 # ifndef YY_NULL
209 #  if defined __cplusplus && 201103L <= __cplusplus
210 #   define YY_NULL nullptr
211 #  else
212 #   define YY_NULL 0
213 #  endif
214 # endif
215
216 /* Enabling verbose error messages.  */
217 #ifdef YYERROR_VERBOSE
218 # undef YYERROR_VERBOSE
219 # define YYERROR_VERBOSE 1
220 #else
221 # define YYERROR_VERBOSE 1
222 #endif
223
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.  */
229 #ifndef YYDEBUG
230 # define YYDEBUG 1
231 #endif
232 #if YYDEBUG
233 extern int __ktrfmt_debug;
234 #endif
235
236 /* Tokens.  */
237 #ifndef YYTOKENTYPE
238 # define YYTOKENTYPE
239    /* Put the tokens into the symbol table, so that GDB and other debuggers
240       know about them.  */
241    enum yytokentype {
242      TOK_ID = 258,
243      TOK_CTOR = 259,
244      TOK_INT = 260,
245      TOK_STR = 261,
246      TOK_EQ = 262,
247      TOK_LEFT_BRACK = 263,
248      TOK_RIGHT_BRACK = 264,
249      TOK_DOT = 265
250    };
251 #endif
252
253
254 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
255 typedef union YYSTYPE
256 {
257 /* Line 387 of yacc.c  */
258 #line 140 "ktrfmt.y"
259
260         struct token *tok;
261         struct evtr_variable *var;
262         struct evtr_variable_value *val;
263         void *na;
264
265
266 /* Line 387 of yacc.c  */
267 #line 268 "ktrfmt.tab.c"
268 } YYSTYPE;
269 # define YYSTYPE_IS_TRIVIAL 1
270 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
271 # define YYSTYPE_IS_DECLARED 1
272 #endif
273
274
275 #ifdef YYPARSE_PARAM
276 #if defined __STDC__ || defined __cplusplus
277 int __ktrfmt_parse (void *YYPARSE_PARAM);
278 #else
279 int __ktrfmt_parse ();
280 #endif
281 #else /* ! YYPARSE_PARAM */
282 #if defined __STDC__ || defined __cplusplus
283 int __ktrfmt_parse (struct ktrfmt_parse_ctx *ctx);
284 #else
285 int __ktrfmt_parse ();
286 #endif
287 #endif /* ! YYPARSE_PARAM */
288
289 #endif /* !YY__KTRFMT_KTRFMT_TAB_H_INCLUDED  */
290
291 /* Copy the second part of user declarations.  */
292
293 /* Line 390 of yacc.c  */
294 #line 295 "ktrfmt.tab.c"
295
296 #ifdef short
297 # undef short
298 #endif
299
300 #ifdef YYTYPE_UINT8
301 typedef YYTYPE_UINT8 yytype_uint8;
302 #else
303 typedef unsigned char yytype_uint8;
304 #endif
305
306 #ifdef YYTYPE_INT8
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;
311 #else
312 typedef short int yytype_int8;
313 #endif
314
315 #ifdef YYTYPE_UINT16
316 typedef YYTYPE_UINT16 yytype_uint16;
317 #else
318 typedef unsigned short int yytype_uint16;
319 #endif
320
321 #ifdef YYTYPE_INT16
322 typedef YYTYPE_INT16 yytype_int16;
323 #else
324 typedef short int yytype_int16;
325 #endif
326
327 #ifndef YYSIZE_T
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
336 # else
337 #  define YYSIZE_T unsigned int
338 # endif
339 #endif
340
341 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
342
343 #ifndef YY_
344 # if defined YYENABLE_NLS && YYENABLE_NLS
345 #  if ENABLE_NLS
346 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
347 #   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
348 #  endif
349 # endif
350 # ifndef YY_
351 #  define YY_(Msgid) Msgid
352 # endif
353 #endif
354
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 */
360 # endif
361 #endif
362
363 /* Suppress unused-variable warnings by "using" E.  */
364 #if ! defined lint || defined __GNUC__
365 # define YYUSE(E) ((void) (E))
366 #else
367 # define YYUSE(E) /* empty */
368 #endif
369
370
371 /* Identity function, used to suppress warnings about constant conditions.  */
372 #ifndef lint
373 # define YYID(N) (N)
374 #else
375 #if (defined __STDC__ || defined __C99__FUNC__ \
376      || defined __cplusplus || defined _MSC_VER)
377 static int
378 YYID (int yyi)
379 #else
380 static int
381 YYID (yyi)
382     int yyi;
383 #endif
384 {
385   return yyi;
386 }
387 #endif
388
389 #if ! defined yyoverflow || YYERROR_VERBOSE
390
391 /* The parser invokes alloca or malloc; define the necessary symbols.  */
392
393 # ifdef YYSTACK_USE_ALLOCA
394 #  if YYSTACK_USE_ALLOCA
395 #   ifdef __GNUC__
396 #    define YYSTACK_ALLOC __builtin_alloca
397 #   elif defined __BUILTIN_VA_ARG_INCR
398 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
399 #   elif defined _AIX
400 #    define YYSTACK_ALLOC __alloca
401 #   elif defined _MSC_VER
402 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
403 #    define alloca _alloca
404 #   else
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
412 #     endif
413 #    endif
414 #   endif
415 #  endif
416 # endif
417
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 */
427 #  endif
428 # else
429 #  define YYSTACK_ALLOC YYMALLOC
430 #  define YYSTACK_FREE YYFREE
431 #  ifndef YYSTACK_ALLOC_MAXIMUM
432 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
433 #  endif
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
440 #   endif
441 #  endif
442 #  ifndef YYMALLOC
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 */
447 #   endif
448 #  endif
449 #  ifndef YYFREE
450 #   define YYFREE free
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 */
454 #   endif
455 #  endif
456 # endif
457 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
458
459
460 #if (! defined yyoverflow \
461      && (! defined __cplusplus \
462          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
463
464 /* A type that is properly aligned for any stack member.  */
465 union yyalloc
466 {
467   yytype_int16 yyss_alloc;
468   YYSTYPE yyvs_alloc;
469 };
470
471 /* The size of the maximum gap between one aligned stack and the next.  */
472 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
473
474 /* The size of an array large to enough to hold all stacks, each with
475    N elements.  */
476 # define YYSTACK_BYTES(N) \
477      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
478       + YYSTACK_GAP_MAXIMUM)
479
480 # define YYCOPY_NEEDED 1
481
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
486    stack.  */
487 # define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
488     do                                                                  \
489       {                                                                 \
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);                          \
495       }                                                                 \
496     while (YYID (0))
497
498 #endif
499
500 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
501 /* Copy COUNT objects from SRC to DST.  The source and destination do
502    not overlap.  */
503 # ifndef YYCOPY
504 #  if defined __GNUC__ && 1 < __GNUC__
505 #   define YYCOPY(Dst, Src, Count) \
506       __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
507 #  else
508 #   define YYCOPY(Dst, Src, Count)              \
509       do                                        \
510         {                                       \
511           YYSIZE_T yyi;                         \
512           for (yyi = 0; yyi < (Count); yyi++)   \
513             (Dst)[yyi] = (Src)[yyi];            \
514         }                                       \
515       while (YYID (0))
516 #  endif
517 # endif
518 #endif /* !YYCOPY_NEEDED */
519
520 /* YYFINAL -- State number of the termination state.  */
521 #define YYFINAL  12
522 /* YYLAST -- Last index in YYTABLE.  */
523 #define YYLAST   20
524
525 /* YYNTOKENS -- Number of terminals.  */
526 #define YYNTOKENS  11
527 /* YYNNTS -- Number of nonterminals.  */
528 #define YYNNTS  11
529 /* YYNRULES -- Number of rules.  */
530 #define YYNRULES  19
531 /* YYNRULES -- Number of states.  */
532 #define YYNSTATES  25
533
534 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
535 #define YYUNDEFTOK  2
536 #define YYMAXUTOK   265
537
538 #define YYTRANSLATE(YYX)                                                \
539   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
540
541 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
542 static const yytype_uint8 yytranslate[] =
543 {
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,
570        5,     6,     7,     8,     9,    10
571 };
572
573 #if YYDEBUG
574 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
575    YYRHS.  */
576 static const yytype_uint8 yyprhs[] =
577 {
578        0,     0,     3,     5,     7,     9,    11,    13,    15,    18,
579       20,    23,    25,    27,    32,    36,    38,    40,    44,    48
580 };
581
582 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
583 static const yytype_int8 yyrhs[] =
584 {
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
590 };
591
592 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
593 static const yytype_uint16 yyrline[] =
594 {
595        0,   168,   168,   170,   173,   175,   189,   203,   212,   217,
596      230,   255,   273,   277,   284,   297,   301,   305,   312,   320
597 };
598 #endif
599
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[] =
604 {
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
609 };
610 #endif
611
612 # ifdef YYPRINT
613 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
614    token YYLEX-NUM.  */
615 static const yytype_uint16 yytoknum[] =
616 {
617        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
618      265
619 };
620 # endif
621
622 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
623 static const yytype_uint8 yyr1[] =
624 {
625        0,    11,    12,    13,    13,    14,    14,    15,    15,    16,
626       16,    17,    17,    18,    18,    18,    19,    20,    20,    21
627 };
628
629 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
630 static const yytype_uint8 yyr2[] =
631 {
632        0,     2,     1,     1,     1,     1,     1,     1,     2,     1,
633        2,     1,     1,     4,     3,     1,     1,     3,     3,     1
634 };
635
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[] =
640 {
641        0,    11,     5,     6,     0,     2,    12,    15,    16,     3,
642       19,     4,     1,     0,     0,     0,     0,    14,     9,    17,
643       18,    13,     7,    10,     8
644 };
645
646 /* YYDEFGOTO[NTERM-NUM].  */
647 static const yytype_int8 yydefgoto[] =
648 {
649       -1,     4,     5,     6,    23,    20,     7,     8,     9,    10,
650       11
651 };
652
653 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
654    STATE-NUM.  */
655 #define YYPACT_NINF -17
656 static const yytype_int8 yypact[] =
657 {
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
661 };
662
663 /* YYPGOTO[NTERM-NUM].  */
664 static const yytype_int8 yypgoto[] =
665 {
666      -17,   -17,   -17,   -15,   -16,   -17,   -17,     7,   -17,   -17,
667      -17
668 };
669
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[] =
675 {
676       19,    12,     1,    22,     2,     3,    24,    22,    18,     2,
677        3,    13,    21,    14,    13,    15,    14,     2,     3,    17,
678       16
679 };
680
681 #define yypact_value_is_default(Yystate) \
682   (!!((Yystate) == (-17)))
683
684 #define yytable_value_is_error(Yytable_value) \
685   YYID (0)
686
687 static const yytype_uint8 yycheck[] =
688 {
689       15,     0,     3,    18,     5,     6,    22,    22,     4,     5,
690        6,     8,     9,    10,     8,     7,    10,     5,     6,     3,
691       13
692 };
693
694 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
695    symbol of state STATE-NUM.  */
696 static const yytype_uint8 yystos[] =
697 {
698        0,     3,     5,     6,    12,    13,    14,    17,    18,    19,
699       20,    21,     0,     8,    10,     7,    18,     3,     4,    14,
700       16,     9,    14,    15,    15
701 };
702
703 #define yyerrok         (yyerrstatus = 0)
704 #define yyclearin       (yychar = YYEMPTY)
705 #define YYEMPTY         (-2)
706 #define YYEOF           0
707
708 #define YYACCEPT        goto yyacceptlab
709 #define YYABORT         goto yyabortlab
710 #define YYERROR         goto yyerrorlab
711
712
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
718    discussed.  */
719
720 #define YYFAIL          goto yyerrlab
721 #if defined YYFAIL
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.  */
726 #endif
727
728 #define YYRECOVERING()  (!!yyerrstatus)
729
730 #define YYBACKUP(Token, Value)                                  \
731 do                                                              \
732   if (yychar == YYEMPTY)                                        \
733     {                                                           \
734       yychar = (Token);                                         \
735       yylval = (Value);                                         \
736       YYPOPSTACK (yylen);                                       \
737       yystate = *yyssp;                                         \
738       goto yybackup;                                            \
739     }                                                           \
740   else                                                          \
741     {                                                           \
742       yyerror (ctx, YY_("syntax error: cannot back up")); \
743       YYERROR;                                                  \
744     }                                                           \
745 while (YYID (0))
746
747 /* Error token number */
748 #define YYTERROR        1
749 #define YYERRCODE       256
750
751
752 /* This macro is provided for backward compatibility. */
753 #ifndef YY_LOCATION_PRINT
754 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
755 #endif
756
757
758 /* YYLEX -- calling `yylex' with the right arguments.  */
759 #ifdef YYLEX_PARAM
760 # define YYLEX yylex (&yylval, YYLEX_PARAM)
761 #else
762 # define YYLEX yylex (&yylval)
763 #endif
764
765 /* Enable debugging if requested.  */
766 #if YYDEBUG
767
768 # ifndef YYFPRINTF
769 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
770 #  define YYFPRINTF fprintf
771 # endif
772
773 # define YYDPRINTF(Args)                        \
774 do {                                            \
775   if (yydebug)                                  \
776     YYFPRINTF Args;                             \
777 } while (YYID (0))
778
779 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
780 do {                                                                      \
781   if (yydebug)                                                            \
782     {                                                                     \
783       YYFPRINTF (stderr, "%s ", Title);                                   \
784       yy_symbol_print (stderr,                                            \
785                   Type, Value, ctx); \
786       YYFPRINTF (stderr, "\n");                                           \
787     }                                                                     \
788 } while (YYID (0))
789
790
791 /*--------------------------------.
792 | Print this symbol on YYOUTPUT.  |
793 `--------------------------------*/
794
795 /*ARGSUSED*/
796 #if (defined __STDC__ || defined __C99__FUNC__ \
797      || defined __cplusplus || defined _MSC_VER)
798 static void
799 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct ktrfmt_parse_ctx *ctx)
800 #else
801 static void
802 yy_symbol_value_print (yyoutput, yytype, yyvaluep, ctx)
803     FILE *yyoutput;
804     int yytype;
805     YYSTYPE const * const yyvaluep;
806     struct ktrfmt_parse_ctx *ctx;
807 #endif
808 {
809   FILE *yyo = yyoutput;
810   YYUSE (yyo);
811   if (!yyvaluep)
812     return;
813   YYUSE (ctx);
814 # ifdef YYPRINT
815   if (yytype < YYNTOKENS)
816     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
817 # else
818   YYUSE (yyoutput);
819 # endif
820   YYUSE (yytype);
821 }
822
823
824 /*--------------------------------.
825 | Print this symbol on YYOUTPUT.  |
826 `--------------------------------*/
827
828 #if (defined __STDC__ || defined __C99__FUNC__ \
829      || defined __cplusplus || defined _MSC_VER)
830 static void
831 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct ktrfmt_parse_ctx *ctx)
832 #else
833 static void
834 yy_symbol_print (yyoutput, yytype, yyvaluep, ctx)
835     FILE *yyoutput;
836     int yytype;
837     YYSTYPE const * const yyvaluep;
838     struct ktrfmt_parse_ctx *ctx;
839 #endif
840 {
841   if (yytype < YYNTOKENS)
842     YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
843   else
844     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
845
846   yy_symbol_value_print (yyoutput, yytype, yyvaluep, ctx);
847   YYFPRINTF (yyoutput, ")");
848 }
849
850 /*------------------------------------------------------------------.
851 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
852 | TOP (included).                                                   |
853 `------------------------------------------------------------------*/
854
855 #if (defined __STDC__ || defined __C99__FUNC__ \
856      || defined __cplusplus || defined _MSC_VER)
857 static void
858 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
859 #else
860 static void
861 yy_stack_print (yybottom, yytop)
862     yytype_int16 *yybottom;
863     yytype_int16 *yytop;
864 #endif
865 {
866   YYFPRINTF (stderr, "Stack now");
867   for (; yybottom <= yytop; yybottom++)
868     {
869       int yybot = *yybottom;
870       YYFPRINTF (stderr, " %d", yybot);
871     }
872   YYFPRINTF (stderr, "\n");
873 }
874
875 # define YY_STACK_PRINT(Bottom, Top)                            \
876 do {                                                            \
877   if (yydebug)                                                  \
878     yy_stack_print ((Bottom), (Top));                           \
879 } while (YYID (0))
880
881
882 /*------------------------------------------------.
883 | Report that the YYRULE is going to be reduced.  |
884 `------------------------------------------------*/
885
886 #if (defined __STDC__ || defined __C99__FUNC__ \
887      || defined __cplusplus || defined _MSC_VER)
888 static void
889 yy_reduce_print (YYSTYPE *yyvsp, int yyrule, struct ktrfmt_parse_ctx *ctx)
890 #else
891 static void
892 yy_reduce_print (yyvsp, yyrule, ctx)
893     YYSTYPE *yyvsp;
894     int yyrule;
895     struct ktrfmt_parse_ctx *ctx;
896 #endif
897 {
898   int yynrhs = yyr2[yyrule];
899   int yyi;
900   unsigned long int yylno = yyrline[yyrule];
901   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
902              yyrule - 1, yylno);
903   /* The symbols being reduced.  */
904   for (yyi = 0; yyi < yynrhs; yyi++)
905     {
906       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
907       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
908                        &(yyvsp[(yyi + 1) - (yynrhs)])
909                                        , ctx);
910       YYFPRINTF (stderr, "\n");
911     }
912 }
913
914 # define YY_REDUCE_PRINT(Rule)          \
915 do {                                    \
916   if (yydebug)                          \
917     yy_reduce_print (yyvsp, Rule, ctx); \
918 } while (YYID (0))
919
920 /* Nonzero means print parse trace.  It is left uninitialized so that
921    multiple parsers can coexist.  */
922 int yydebug;
923 #else /* !YYDEBUG */
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 */
929
930
931 /* YYINITDEPTH -- initial size of the parser's stacks.  */
932 #ifndef YYINITDEPTH
933 # define YYINITDEPTH 200
934 #endif
935
936 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
937    if the built-in stack extension method is used).
938
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.  */
942
943 #ifndef YYMAXDEPTH
944 # define YYMAXDEPTH 10000
945 #endif
946
947
948 #if YYERROR_VERBOSE
949
950 # ifndef yystrlen
951 #  if defined __GLIBC__ && defined _STRING_H
952 #   define yystrlen strlen
953 #  else
954 /* Return the length of YYSTR.  */
955 #if (defined __STDC__ || defined __C99__FUNC__ \
956      || defined __cplusplus || defined _MSC_VER)
957 static YYSIZE_T
958 yystrlen (const char *yystr)
959 #else
960 static YYSIZE_T
961 yystrlen (yystr)
962     const char *yystr;
963 #endif
964 {
965   YYSIZE_T yylen;
966   for (yylen = 0; yystr[yylen]; yylen++)
967     continue;
968   return yylen;
969 }
970 #  endif
971 # endif
972
973 # ifndef yystpcpy
974 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
975 #   define yystpcpy stpcpy
976 #  else
977 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
978    YYDEST.  */
979 #if (defined __STDC__ || defined __C99__FUNC__ \
980      || defined __cplusplus || defined _MSC_VER)
981 static char *
982 yystpcpy (char *yydest, const char *yysrc)
983 #else
984 static char *
985 yystpcpy (yydest, yysrc)
986     char *yydest;
987     const char *yysrc;
988 #endif
989 {
990   char *yyd = yydest;
991   const char *yys = yysrc;
992
993   while ((*yyd++ = *yys++) != '\0')
994     continue;
995
996   return yyd - 1;
997 }
998 #  endif
999 # endif
1000
1001 # ifndef yytnamerr
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
1008    would have been.  */
1009 static YYSIZE_T
1010 yytnamerr (char *yyres, const char *yystr)
1011 {
1012   if (*yystr == '"')
1013     {
1014       YYSIZE_T yyn = 0;
1015       char const *yyp = yystr;
1016
1017       for (;;)
1018         switch (*++yyp)
1019           {
1020           case '\'':
1021           case ',':
1022             goto do_not_strip_quotes;
1023
1024           case '\\':
1025             if (*++yyp != '\\')
1026               goto do_not_strip_quotes;
1027             /* Fall through.  */
1028           default:
1029             if (yyres)
1030               yyres[yyn] = *yyp;
1031             yyn++;
1032             break;
1033
1034           case '"':
1035             if (yyres)
1036               yyres[yyn] = '\0';
1037             return yyn;
1038           }
1039     do_not_strip_quotes: ;
1040     }
1041
1042   if (! yyres)
1043     return yystrlen (yystr);
1044
1045   return yystpcpy (yyres, yystr) - yyres;
1046 }
1047 # endif
1048
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
1051    YYSSP.
1052
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.  */
1057 static int
1058 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1059                 yytype_int16 *yyssp, int yytoken)
1060 {
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
1069      "expected"). */
1070   int yycount = 0;
1071
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
1076        function.
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.
1098   */
1099   if (yytoken != YYEMPTY)
1100     {
1101       int yyn = yypact[*yyssp];
1102       yyarg[yycount++] = yytname[yytoken];
1103       if (!yypact_value_is_default (yyn))
1104         {
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;
1112           int yyx;
1113
1114           for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1115             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1116                 && !yytable_value_is_error (yytable[yyx + yyn]))
1117               {
1118                 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1119                   {
1120                     yycount = 1;
1121                     yysize = yysize0;
1122                     break;
1123                   }
1124                 yyarg[yycount++] = yytname[yyx];
1125                 {
1126                   YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
1127                   if (! (yysize <= yysize1
1128                          && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1129                     return 2;
1130                   yysize = yysize1;
1131                 }
1132               }
1133         }
1134     }
1135
1136   switch (yycount)
1137     {
1138 # define YYCASE_(N, S)                      \
1139       case N:                               \
1140         yyformat = S;                       \
1141       break
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"));
1148 # undef YYCASE_
1149     }
1150
1151   {
1152     YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1153     if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1154       return 2;
1155     yysize = yysize1;
1156   }
1157
1158   if (*yymsg_alloc < yysize)
1159     {
1160       *yymsg_alloc = 2 * yysize;
1161       if (! (yysize <= *yymsg_alloc
1162              && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1163         *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1164       return 1;
1165     }
1166
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.  */
1170   {
1171     char *yyp = *yymsg;
1172     int yyi = 0;
1173     while ((*yyp = *yyformat) != '\0')
1174       if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1175         {
1176           yyp += yytnamerr (yyp, yyarg[yyi++]);
1177           yyformat += 2;
1178         }
1179       else
1180         {
1181           yyp++;
1182           yyformat++;
1183         }
1184   }
1185   return 0;
1186 }
1187 #endif /* YYERROR_VERBOSE */
1188
1189 /*-----------------------------------------------.
1190 | Release the memory associated to this symbol.  |
1191 `-----------------------------------------------*/
1192
1193 /*ARGSUSED*/
1194 #if (defined __STDC__ || defined __C99__FUNC__ \
1195      || defined __cplusplus || defined _MSC_VER)
1196 static void
1197 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, struct ktrfmt_parse_ctx *ctx)
1198 #else
1199 static void
1200 yydestruct (yymsg, yytype, yyvaluep, ctx)
1201     const char *yymsg;
1202     int yytype;
1203     YYSTYPE *yyvaluep;
1204     struct ktrfmt_parse_ctx *ctx;
1205 #endif
1206 {
1207   YYUSE (yyvaluep);
1208   YYUSE (ctx);
1209
1210   if (!yymsg)
1211     yymsg = "Deleting";
1212   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1213
1214   YYUSE (yytype);
1215 }
1216
1217
1218
1219
1220 /*----------.
1221 | yyparse.  |
1222 `----------*/
1223
1224 #ifdef YYPARSE_PARAM
1225 #if (defined __STDC__ || defined __C99__FUNC__ \
1226      || defined __cplusplus || defined _MSC_VER)
1227 int
1228 yyparse (void *YYPARSE_PARAM)
1229 #else
1230 int
1231 yyparse (YYPARSE_PARAM)
1232     void *YYPARSE_PARAM;
1233 #endif
1234 #else /* ! YYPARSE_PARAM */
1235 #if (defined __STDC__ || defined __C99__FUNC__ \
1236      || defined __cplusplus || defined _MSC_VER)
1237 int
1238 yyparse (struct ktrfmt_parse_ctx *ctx)
1239 #else
1240 int
1241 yyparse (ctx)
1242     struct ktrfmt_parse_ctx *ctx;
1243 #endif
1244 #endif
1245 {
1246 /* The lookahead symbol.  */
1247 int yychar;
1248
1249
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")
1258 #else
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
1263 #endif
1264 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1265 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1266 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
1267 #endif
1268 #ifndef YY_INITIAL_VALUE
1269 # define YY_INITIAL_VALUE(Value) /* Nothing. */
1270 #endif
1271
1272 /* The semantic value of the lookahead symbol.  */
1273 YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
1274
1275     /* Number of syntax errors so far.  */
1276     int yynerrs;
1277
1278     int yystate;
1279     /* Number of tokens to shift before error messages enabled.  */
1280     int yyerrstatus;
1281
1282     /* The stacks and their tools:
1283        `yyss': related to states.
1284        `yyvs': related to semantic values.
1285
1286        Refer to the stacks through separate pointers, to allow yyoverflow
1287        to reallocate them elsewhere.  */
1288
1289     /* The state stack.  */
1290     yytype_int16 yyssa[YYINITDEPTH];
1291     yytype_int16 *yyss;
1292     yytype_int16 *yyssp;
1293
1294     /* The semantic value stack.  */
1295     YYSTYPE yyvsa[YYINITDEPTH];
1296     YYSTYPE *yyvs;
1297     YYSTYPE *yyvsp;
1298
1299     YYSIZE_T yystacksize;
1300
1301   int yyn;
1302   int yyresult;
1303   /* Lookahead token as an internal (translated) token number.  */
1304   int yytoken = 0;
1305   /* The variables used to return semantic value and location from the
1306      action routines.  */
1307   YYSTYPE yyval;
1308
1309 #if YYERROR_VERBOSE
1310   /* Buffer for error messages, and its allocated size.  */
1311   char yymsgbuf[128];
1312   char *yymsg = yymsgbuf;
1313   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1314 #endif
1315
1316 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1317
1318   /* The number of symbols on the RHS of the reduced rule.
1319      Keep to zero when no symbol should be popped.  */
1320   int yylen = 0;
1321
1322   yyssp = yyss = yyssa;
1323   yyvsp = yyvs = yyvsa;
1324   yystacksize = YYINITDEPTH;
1325
1326   YYDPRINTF ((stderr, "Starting parse\n"));
1327
1328   yystate = 0;
1329   yyerrstatus = 0;
1330   yynerrs = 0;
1331   yychar = YYEMPTY; /* Cause a token to be read.  */
1332   goto yysetstate;
1333
1334 /*------------------------------------------------------------.
1335 | yynewstate -- Push a new state, which is found in yystate.  |
1336 `------------------------------------------------------------*/
1337  yynewstate:
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.  */
1340   yyssp++;
1341
1342  yysetstate:
1343   *yyssp = yystate;
1344
1345   if (yyss + yystacksize - 1 <= yyssp)
1346     {
1347       /* Get the current used size of the three stacks, in elements.  */
1348       YYSIZE_T yysize = yyssp - yyss + 1;
1349
1350 #ifdef yyoverflow
1351       {
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
1354            memory.  */
1355         YYSTYPE *yyvs1 = yyvs;
1356         yytype_int16 *yyss1 = yyss;
1357
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),
1365                     &yystacksize);
1366
1367         yyss = yyss1;
1368         yyvs = yyvs1;
1369       }
1370 #else /* no yyoverflow */
1371 # ifndef YYSTACK_RELOCATE
1372       goto yyexhaustedlab;
1373 # else
1374       /* Extend the stack our own way.  */
1375       if (YYMAXDEPTH <= yystacksize)
1376         goto yyexhaustedlab;
1377       yystacksize *= 2;
1378       if (YYMAXDEPTH < yystacksize)
1379         yystacksize = YYMAXDEPTH;
1380
1381       {
1382         yytype_int16 *yyss1 = yyss;
1383         union yyalloc *yyptr =
1384           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1385         if (! yyptr)
1386           goto yyexhaustedlab;
1387         YYSTACK_RELOCATE (yyss_alloc, yyss);
1388         YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1389 #  undef YYSTACK_RELOCATE
1390         if (yyss1 != yyssa)
1391           YYSTACK_FREE (yyss1);
1392       }
1393 # endif
1394 #endif /* no yyoverflow */
1395
1396       yyssp = yyss + yysize - 1;
1397       yyvsp = yyvs + yysize - 1;
1398
1399       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1400                   (unsigned long int) yystacksize));
1401
1402       if (yyss + yystacksize - 1 <= yyssp)
1403         YYABORT;
1404     }
1405
1406   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1407
1408   if (yystate == YYFINAL)
1409     YYACCEPT;
1410
1411   goto yybackup;
1412
1413 /*-----------.
1414 | yybackup.  |
1415 `-----------*/
1416 yybackup:
1417
1418   /* Do appropriate processing given the current state.  Read a
1419      lookahead token if we need one and don't already have one.  */
1420
1421   /* First try to decide what to do without reference to lookahead token.  */
1422   yyn = yypact[yystate];
1423   if (yypact_value_is_default (yyn))
1424     goto yydefault;
1425
1426   /* Not known => get a lookahead token if don't already have one.  */
1427
1428   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1429   if (yychar == YYEMPTY)
1430     {
1431       YYDPRINTF ((stderr, "Reading a token: "));
1432       yychar = YYLEX;
1433     }
1434
1435   if (yychar <= YYEOF)
1436     {
1437       yychar = yytoken = YYEOF;
1438       YYDPRINTF ((stderr, "Now at end of input.\n"));
1439     }
1440   else
1441     {
1442       yytoken = YYTRANSLATE (yychar);
1443       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1444     }
1445
1446   /* If the proper action on seeing token YYTOKEN is to reduce or to
1447      detect an error, take that action.  */
1448   yyn += yytoken;
1449   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1450     goto yydefault;
1451   yyn = yytable[yyn];
1452   if (yyn <= 0)
1453     {
1454       if (yytable_value_is_error (yyn))
1455         goto yyerrlab;
1456       yyn = -yyn;
1457       goto yyreduce;
1458     }
1459
1460   /* Count tokens shifted since error; after three, turn off error
1461      status.  */
1462   if (yyerrstatus)
1463     yyerrstatus--;
1464
1465   /* Shift the lookahead token.  */
1466   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1467
1468   /* Discard the shifted token.  */
1469   yychar = YYEMPTY;
1470
1471   yystate = yyn;
1472   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1473   *++yyvsp = yylval;
1474   YY_IGNORE_MAYBE_UNINITIALIZED_END
1475
1476   goto yynewstate;
1477
1478
1479 /*-----------------------------------------------------------.
1480 | yydefault -- do the default action for the current state.  |
1481 `-----------------------------------------------------------*/
1482 yydefault:
1483   yyn = yydefact[yystate];
1484   if (yyn == 0)
1485     goto yyerrlab;
1486   goto yyreduce;
1487
1488
1489 /*-----------------------------.
1490 | yyreduce -- Do a reduction.  |
1491 `-----------------------------*/
1492 yyreduce:
1493   /* yyn is the number of a rule to reduce with.  */
1494   yylen = yyr2[yyn];
1495
1496   /* If YYLEN is nonzero, implement the default value of the action:
1497      `$$ = $1'.
1498
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];
1505
1506
1507   YY_REDUCE_PRINT (yyn);
1508   switch (yyn)
1509     {
1510         case 3:
1511 /* Line 1787 of yacc.c  */
1512 #line 170 "ktrfmt.y"
1513     {
1514         ctx->var = (yyvsp[(1) - (1)].var);
1515  }
1516     break;
1517
1518   case 5:
1519 /* Line 1787 of yacc.c  */
1520 #line 175 "ktrfmt.y"
1521     {
1522         evtr_var_t var;
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;
1527         errno = 0;
1528         var->val.num = strtoll((yyvsp[(1) - (1)].tok)->str, NULL, 0);
1529         if (errno) {
1530                 parse_err("Can't parse numeric constant '%s'", (yyvsp[(1) - (1)].tok)->str);
1531         }
1532         (yyval.var) = var;
1533         tok_free((yyvsp[(1) - (1)].tok));
1534         }
1535     break;
1536
1537   case 6:
1538 /* Line 1787 of yacc.c  */
1539 #line 189 "ktrfmt.y"
1540     {
1541         evtr_var_t var;
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");
1549         }
1550         (yyval.var) = var;
1551         tok_free((yyvsp[(1) - (1)].tok));
1552         }
1553     break;
1554
1555   case 7:
1556 /* Line 1787 of yacc.c  */
1557 #line 203 "ktrfmt.y"
1558     {
1559         evtr_var_t ctor;
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);
1565         (yyval.var) = ctor;
1566  }
1567     break;
1568
1569   case 8:
1570 /* Line 1787 of yacc.c  */
1571 #line 212 "ktrfmt.y"
1572     {
1573         TAILQ_INSERT_HEAD(&(yyvsp[(2) - (2)].var)->val.ctor.args, &(yyvsp[(1) - (2)].var)->val, link);
1574         (yyval.var) = (yyvsp[(2) - (2)].var);
1575  }
1576     break;
1577
1578   case 9:
1579 /* Line 1787 of yacc.c  */
1580 #line 217 "ktrfmt.y"
1581     {
1582         evtr_var_t var;
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));
1592         (yyval.var) = var;
1593  }
1594     break;
1595
1596   case 10:
1597 /* Line 1787 of yacc.c  */
1598 #line 230 "ktrfmt.y"
1599     {
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) {
1610                 case EVTR_VAL_INT:
1611                         printd(PARSE, "\t%jd\n", val->num);
1612                         break;
1613                 case EVTR_VAL_STR:
1614                         printd(PARSE, "\t\"%s\"\n", val->str);
1615                         break;
1616                 case EVTR_VAL_NIL:
1617                         assert(!"can't get here");
1618                 default:
1619                         ;
1620                 }
1621         }
1622  }
1623     break;
1624
1625   case 11:
1626 /* Line 1787 of yacc.c  */
1627 #line 255 "ktrfmt.y"
1628     {
1629         evtr_var_t var;
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);
1635         if (!var) {
1636                 if (!(var = evtr_var_new((yyvsp[(1) - (1)].tok)->str))) {
1637                         tok_free((yyvsp[(1) - (1)].tok));
1638                         parse_err("out of memory");
1639                 }
1640                 printd(PARSE, "creating var %s\n", (yyvsp[(1) - (1)].tok)->str);
1641                 symtab_insert(ctx->symtab, (yyvsp[(1) - (1)].tok)->str, var);
1642         }
1643         (yyval.var) = var;
1644         tok_free((yyvsp[(1) - (1)].tok));
1645  }
1646     break;
1647
1648   case 12:
1649 /* Line 1787 of yacc.c  */
1650 #line 273 "ktrfmt.y"
1651     {
1652         (yyval.var) = (yyvsp[(1) - (1)].var);
1653   }
1654     break;
1655
1656   case 13:
1657 /* Line 1787 of yacc.c  */
1658 #line 277 "ktrfmt.y"
1659     {
1660         evtr_var_t var;
1661
1662         if (index_hash(ctx, (yyvsp[(1) - (4)].var)->name, &(yyvsp[(3) - (4)].var)->val, &var))
1663                 YYABORT;
1664         (yyval.var) = var;
1665  }
1666     break;
1667
1668   case 14:
1669 /* Line 1787 of yacc.c  */
1670 #line 284 "ktrfmt.y"
1671     {
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;
1678
1679         if (index_hash(ctx, (yyvsp[(1) - (3)].var)->name, &tmp->val, &var))
1680                 YYABORT;
1681         tok_free((yyvsp[(3) - (3)].tok));
1682         (yyval.var) = var;
1683  }
1684     break;
1685
1686   case 15:
1687 /* Line 1787 of yacc.c  */
1688 #line 297 "ktrfmt.y"
1689     {
1690         (yyval.var) = (yyvsp[(1) - (1)].var);
1691  }
1692     break;
1693
1694   case 16:
1695 /* Line 1787 of yacc.c  */
1696 #line 301 "ktrfmt.y"
1697     {
1698         (yyval.var) = (yyvsp[(1) - (1)].var);
1699  }
1700     break;
1701
1702   case 17:
1703 /* Line 1787 of yacc.c  */
1704 #line 305 "ktrfmt.y"
1705     {
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;
1711  }
1712     break;
1713
1714   case 18:
1715 /* Line 1787 of yacc.c  */
1716 #line 312 "ktrfmt.y"
1717     {
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;
1723  }
1724     break;
1725
1726   case 19:
1727 /* Line 1787 of yacc.c  */
1728 #line 320 "ktrfmt.y"
1729     {
1730         (yyval.na) = (yyvsp[(1) - (1)].na);
1731  }
1732     break;
1733
1734
1735 /* Line 1787 of yacc.c  */
1736 #line 1737 "ktrfmt.tab.c"
1737       default: break;
1738     }
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);
1751
1752   YYPOPSTACK (yylen);
1753   yylen = 0;
1754   YY_STACK_PRINT (yyss, yyssp);
1755
1756   *++yyvsp = yyval;
1757
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.  */
1761
1762   yyn = yyr1[yyn];
1763
1764   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1765   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1766     yystate = yytable[yystate];
1767   else
1768     yystate = yydefgoto[yyn - YYNTOKENS];
1769
1770   goto yynewstate;
1771
1772
1773 /*------------------------------------.
1774 | yyerrlab -- here on detecting error |
1775 `------------------------------------*/
1776 yyerrlab:
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);
1780
1781   /* If not already recovering from an error, report this error.  */
1782   if (!yyerrstatus)
1783     {
1784       ++yynerrs;
1785 #if ! YYERROR_VERBOSE
1786       yyerror (ctx, YY_("syntax error"));
1787 #else
1788 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1789                                         yyssp, yytoken)
1790       {
1791         char const *yymsgp = YY_("syntax error");
1792         int yysyntax_error_status;
1793         yysyntax_error_status = YYSYNTAX_ERROR;
1794         if (yysyntax_error_status == 0)
1795           yymsgp = yymsg;
1796         else if (yysyntax_error_status == 1)
1797           {
1798             if (yymsg != yymsgbuf)
1799               YYSTACK_FREE (yymsg);
1800             yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1801             if (!yymsg)
1802               {
1803                 yymsg = yymsgbuf;
1804                 yymsg_alloc = sizeof yymsgbuf;
1805                 yysyntax_error_status = 2;
1806               }
1807             else
1808               {
1809                 yysyntax_error_status = YYSYNTAX_ERROR;
1810                 yymsgp = yymsg;
1811               }
1812           }
1813         yyerror (ctx, yymsgp);
1814         if (yysyntax_error_status == 2)
1815           goto yyexhaustedlab;
1816       }
1817 # undef YYSYNTAX_ERROR
1818 #endif
1819     }
1820
1821
1822
1823   if (yyerrstatus == 3)
1824     {
1825       /* If just tried and failed to reuse lookahead token after an
1826          error, discard it.  */
1827
1828       if (yychar <= YYEOF)
1829         {
1830           /* Return failure if at end of input.  */
1831           if (yychar == YYEOF)
1832             YYABORT;
1833         }
1834       else
1835         {
1836           yydestruct ("Error: discarding",
1837                       yytoken, &yylval, ctx);
1838           yychar = YYEMPTY;
1839         }
1840     }
1841
1842   /* Else will try to reuse lookahead token after shifting the error
1843      token.  */
1844   goto yyerrlab1;
1845
1846
1847 /*---------------------------------------------------.
1848 | yyerrorlab -- error raised explicitly by YYERROR.  |
1849 `---------------------------------------------------*/
1850 yyerrorlab:
1851
1852   /* Pacify compilers like GCC when the user code never invokes
1853      YYERROR and the label yyerrorlab therefore never appears in user
1854      code.  */
1855   if (/*CONSTCOND*/ 0)
1856      goto yyerrorlab;
1857
1858   /* Do not reclaim the symbols of the rule which action triggered
1859      this YYERROR.  */
1860   YYPOPSTACK (yylen);
1861   yylen = 0;
1862   YY_STACK_PRINT (yyss, yyssp);
1863   yystate = *yyssp;
1864   goto yyerrlab1;
1865
1866
1867 /*-------------------------------------------------------------.
1868 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
1869 `-------------------------------------------------------------*/
1870 yyerrlab1:
1871   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
1872
1873   for (;;)
1874     {
1875       yyn = yypact[yystate];
1876       if (!yypact_value_is_default (yyn))
1877         {
1878           yyn += YYTERROR;
1879           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1880             {
1881               yyn = yytable[yyn];
1882               if (0 < yyn)
1883                 break;
1884             }
1885         }
1886
1887       /* Pop the current state because it cannot handle the error token.  */
1888       if (yyssp == yyss)
1889         YYABORT;
1890
1891
1892       yydestruct ("Error: popping",
1893                   yystos[yystate], yyvsp, ctx);
1894       YYPOPSTACK (1);
1895       yystate = *yyssp;
1896       YY_STACK_PRINT (yyss, yyssp);
1897     }
1898
1899   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1900   *++yyvsp = yylval;
1901   YY_IGNORE_MAYBE_UNINITIALIZED_END
1902
1903
1904   /* Shift the error token.  */
1905   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1906
1907   yystate = yyn;
1908   goto yynewstate;
1909
1910
1911 /*-------------------------------------.
1912 | yyacceptlab -- YYACCEPT comes here.  |
1913 `-------------------------------------*/
1914 yyacceptlab:
1915   yyresult = 0;
1916   goto yyreturn;
1917
1918 /*-----------------------------------.
1919 | yyabortlab -- YYABORT comes here.  |
1920 `-----------------------------------*/
1921 yyabortlab:
1922   yyresult = 1;
1923   goto yyreturn;
1924
1925 #if !defined yyoverflow || YYERROR_VERBOSE
1926 /*-------------------------------------------------.
1927 | yyexhaustedlab -- memory exhaustion comes here.  |
1928 `-------------------------------------------------*/
1929 yyexhaustedlab:
1930   yyerror (ctx, YY_("memory exhausted"));
1931   yyresult = 2;
1932   /* Fall through.  */
1933 #endif
1934
1935 yyreturn:
1936   if (yychar != YYEMPTY)
1937     {
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);
1943     }
1944   /* Do not reclaim the symbols of the rule which action triggered
1945      this YYABORT or YYACCEPT.  */
1946   YYPOPSTACK (yylen);
1947   YY_STACK_PRINT (yyss, yyssp);
1948   while (yyssp != yyss)
1949     {
1950       yydestruct ("Cleanup: popping",
1951                   yystos[*yyssp], yyvsp, ctx);
1952       YYPOPSTACK (1);
1953     }
1954 #ifndef yyoverflow
1955   if (yyss != yyssa)
1956     YYSTACK_FREE (yyss);
1957 #endif
1958 #if YYERROR_VERBOSE
1959   if (yymsg != yymsgbuf)
1960     YYSTACK_FREE (yymsg);
1961 #endif
1962   /* Make sure YYID is used.  */
1963   return YYID (yyresult);
1964 }
1965
1966
1967 /* Line 2050 of yacc.c  */
1968 #line 325 "ktrfmt.y"
1969
1970
1971 void * __ktrfmt_scan_string(const char *);
1972 void __ktrfmt_delete_buffer(void *);
1973
1974 void
1975 __ktrfmt_error (struct ktrfmt_parse_ctx *ctx, const char *s)
1976 {
1977         do_parse_err(ctx, "%s", s);
1978 }
1979
1980 int
1981 parse_string(evtr_event_t ev, struct symtab *symtab, const char *str,
1982              char *errbuf, size_t errbufsz)
1983 {
1984         void *bufstate;
1985         int ret;
1986         struct ktrfmt_parse_ctx ctx;
1987
1988         printd(PARSE, "parsing \"%s\"\n", str);
1989         ctx.ev = ev;
1990         ctx.symtab = symtab;
1991         ctx.errbuf = errbuf;
1992         ctx.errbuf[0] = '\0';
1993         ctx.errbufsz = errbufsz;
1994         ctx.err = 0;
1995         bufstate = __ktrfmt_scan_string(str);
1996         ret = __ktrfmt_parse(&ctx);
1997         __ktrfmt_delete_buffer(bufstate);
1998
1999         return ret;
2000 }
2001
2002 int
2003 parse_var(const char *str, struct symtab *symtab, struct evtr_variable **var,
2004           char *errbuf, size_t errbufsz)
2005 {
2006         void *bufstate;
2007         int ret;
2008         struct ktrfmt_parse_ctx ctx;
2009
2010         printd(PARSE, "parsing \"%s\"\n", str);
2011         ctx.ev = NULL;
2012         ctx.symtab = symtab;
2013         ctx.var = NULL;
2014         ctx.errbuf = errbuf;
2015         ctx.errbuf[0] = '\0';
2016         ctx.errbufsz = errbufsz;
2017         ctx.err = 0;
2018         bufstate = __ktrfmt_scan_string(str);
2019         ret = __ktrfmt_parse(&ctx);
2020         __ktrfmt_delete_buffer(bufstate);
2021
2022         *var = ctx.var;
2023         return ret;
2024 }