Merge branch 'master' of git://git.theshell.com/dragonfly
[dragonfly.git] / lib / libevtr / ktrfmt.tab.c
1
2 /* A Bison parser, made by GNU Bison 2.4.1.  */
3
4 /* Skeleton implementation for Bison's Yacc-like parsers in C
5    
6       Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
7    Free Software Foundation, Inc.
8    
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.
13    
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.
18    
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/>.  */
21
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.
31    
32    This special exception was added by the Free Software Foundation in
33    version 2.2 of Bison.  */
34
35 /* C LALR(1) parser skeleton written by Richard Stallman, by
36    simplifying the original so-called "semantic" parser.  */
37
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.  */
44
45 /* Identify Bison output.  */
46 #define YYBISON 1
47
48 /* Bison version.  */
49 #define YYBISON_VERSION "2.4.1"
50
51 /* Skeleton name.  */
52 #define YYSKELETON_NAME "yacc.c"
53
54 /* Pure parsers.  */
55 #define YYPURE 1
56
57 /* Push parsers.  */
58 #define YYPUSH 0
59
60 /* Pull parsers.  */
61 #define YYPULL 1
62
63 /* Using locations.  */
64 #define YYLSP_NEEDED 0
65
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
74
75
76 /* Copy the first part of user declarations.  */
77
78 /* Line 189 of yacc.c  */
79 #line 1 "ktrfmt.y"
80
81
82 #include <assert.h>
83 #include <errno.h>
84 #include <stdarg.h>
85 #include <stdlib.h>
86 #include <string.h>
87 #include <sys/queue.h>
88
89 #include "evtr.h"
90 #include "tok.h"
91 #include "ktrfmt.tab.h"
92 #include "internal.h"
93
94 struct ktrfmt_parse_ctx {
95         struct symtab *symtab;
96         struct evtr_variable *var;
97         struct evtr_variable_value *val;
98         evtr_event_t ev;
99         char *errbuf;
100         size_t errbufsz;
101         int err;
102 };
103
104 int __ktrfmtlex(YYSTYPE *);
105 #define __ktrfmt_lex __ktrfmtlex
106
107 void __ktrfmt_error (struct ktrfmt_parse_ctx *, const char *);
108
109 static void do_parse_err(struct ktrfmt_parse_ctx *, const char *, ...)
110                 __printflike(2, 3);
111
112 static
113 void
114 do_parse_err(struct ktrfmt_parse_ctx *ctx, const char *fmt, ...)
115 {
116         va_list ap;
117
118         va_start(ap, fmt);
119         vsnprintf(ctx->errbuf, ctx->errbufsz, fmt, ap);
120         va_end(ap);
121         ctx->err = !0;
122 }
123
124 #define parse_err(fmt, ...)                     \
125         do {                                    \
126                 do_parse_err(ctx, fmt, ##__VA_ARGS__);  \
127                 YYABORT;                                \
128         } while (0)
129
130 static
131 struct evtr_variable *
132 evtr_var_new(const char *name)
133 {
134         struct evtr_variable *var;
135
136         var = calloc(1, sizeof(*var));
137         if (var) {
138                 if (!(var->name = strdup(name))) {
139                         free(var);
140                         return NULL;
141                 }
142                 var->val.type = EVTR_VAL_NIL;
143         }
144         return var;
145 }
146
147 /*
148  * XXX: should be reentrant
149  */
150 static
151 char *
152 uniq_varname(void)
153 {
154         static long serno;
155         static char buf[100];
156
157         serno++;
158         snprintf(buf, sizeof(buf), "@%ld", serno);
159         return &buf[0];
160 }
161
162 static
163 int
164 index_hash(struct ktrfmt_parse_ctx *ctx, const char *hashname,
165            evtr_variable_value_t val, evtr_var_t *_var)
166 {
167         evtr_var_t hsh, var;
168         uintptr_t ret, key;
169         hsh = symtab_find(ctx->symtab, hashname);
170         if (hsh->val.type == EVTR_VAL_NIL) {
171                 /* it's probably the first time we see this "variable" */
172                 printd(PARSE, "creating hash for %s\n", hsh->name);
173                 hsh->val.type = EVTR_VAL_HASH;
174                 hsh->val.hashtab = hash_new();
175         } else if (hsh->val.type != EVTR_VAL_HASH) {
176                 printd(PARSE, "trying to use type %d as hash\n", hsh->val.type);
177                 return !0;
178         }
179         if (val->type == EVTR_VAL_INT) {
180                 key = val->num;
181                 printd(PARSE, "looking up %s[%jd] in %p\n", hsh->name,
182                        val->num, hsh->val.hashtab);
183         } else if (val->type == EVTR_VAL_STR) {
184                 key = (uintptr_t)val->str;
185                 printd(PARSE, "looking up %s[\"%s\"] in %p\n", hsh->name,
186                        val->str, hsh->val.hashtab);
187         } else {
188                 do_parse_err(ctx, "trying to index hash '%s' with "
189                              "non-supported value", hashname);
190                 return !0;
191         }
192
193         if (hash_find(hsh->val.hashtab, key, &ret)) {
194                 printd(PARSE, "didn't find it\n");
195                 var = evtr_var_new(uniq_varname());
196                 if (var) {
197                         printd(PARSE, "inserting it as %s\n", var->name);
198                         if (!hash_insert(hsh->val.hashtab, key,
199                                          (uintptr_t)var)) {
200                                 do_parse_err(ctx, "can't insert temporary "
201                                         "variable into hash\n");
202                                 return !0;
203                         }
204                         symtab_insert(ctx->symtab, var->name, var);
205                 } else {
206                         do_parse_err(ctx, "out of memory");
207                 }
208         } else {
209                 var = (struct evtr_variable *)ret;
210         }
211         if (!var) {
212                 fprintf(stderr, "no var!\n");
213                 return !0;
214                 /* XXX */
215         }
216         *_var = var;
217         return 0;
218 }
219
220
221
222 /* Line 189 of yacc.c  */
223 #line 221 "ktrfmt.tab.c"
224
225 /* Enabling traces.  */
226 #ifndef YYDEBUG
227 # define YYDEBUG 1
228 #endif
229
230 /* Enabling verbose error messages.  */
231 #ifdef YYERROR_VERBOSE
232 # undef YYERROR_VERBOSE
233 # define YYERROR_VERBOSE 1
234 #else
235 # define YYERROR_VERBOSE 1
236 #endif
237
238 /* Enabling the token table.  */
239 #ifndef YYTOKEN_TABLE
240 # define YYTOKEN_TABLE 0
241 #endif
242
243
244 /* Tokens.  */
245 #ifndef YYTOKENTYPE
246 # define YYTOKENTYPE
247    /* Put the tokens into the symbol table, so that GDB and other debuggers
248       know about them.  */
249    enum yytokentype {
250      TOK_ID = 258,
251      TOK_CTOR = 259,
252      TOK_INT = 260,
253      TOK_STR = 261,
254      TOK_EQ = 262,
255      TOK_LEFT_BRACK = 263,
256      TOK_RIGHT_BRACK = 264,
257      TOK_DOT = 265
258    };
259 #endif
260
261
262
263 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
264 typedef union YYSTYPE
265 {
266
267 /* Line 214 of yacc.c  */
268 #line 147 "ktrfmt.y"
269
270         struct token *tok;
271         struct evtr_variable *var;
272         struct evtr_variable_value *val;
273         void *na;
274
275
276
277 /* Line 214 of yacc.c  */
278 #line 276 "ktrfmt.tab.c"
279 } YYSTYPE;
280 # define YYSTYPE_IS_TRIVIAL 1
281 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
282 # define YYSTYPE_IS_DECLARED 1
283 #endif
284
285
286 /* Copy the second part of user declarations.  */
287
288
289 /* Line 264 of yacc.c  */
290 #line 288 "ktrfmt.tab.c"
291
292 #ifdef short
293 # undef short
294 #endif
295
296 #ifdef YYTYPE_UINT8
297 typedef YYTYPE_UINT8 yytype_uint8;
298 #else
299 typedef unsigned char yytype_uint8;
300 #endif
301
302 #ifdef YYTYPE_INT8
303 typedef YYTYPE_INT8 yytype_int8;
304 #elif (defined __STDC__ || defined __C99__FUNC__ \
305      || defined __cplusplus || defined _MSC_VER)
306 typedef signed char yytype_int8;
307 #else
308 typedef short int yytype_int8;
309 #endif
310
311 #ifdef YYTYPE_UINT16
312 typedef YYTYPE_UINT16 yytype_uint16;
313 #else
314 typedef unsigned short int yytype_uint16;
315 #endif
316
317 #ifdef YYTYPE_INT16
318 typedef YYTYPE_INT16 yytype_int16;
319 #else
320 typedef short int yytype_int16;
321 #endif
322
323 #ifndef YYSIZE_T
324 # ifdef __SIZE_TYPE__
325 #  define YYSIZE_T __SIZE_TYPE__
326 # elif defined size_t
327 #  define YYSIZE_T size_t
328 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
329      || defined __cplusplus || defined _MSC_VER)
330 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
331 #  define YYSIZE_T size_t
332 # else
333 #  define YYSIZE_T unsigned int
334 # endif
335 #endif
336
337 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
338
339 #ifndef YY_
340 # if YYENABLE_NLS
341 #  if ENABLE_NLS
342 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
343 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
344 #  endif
345 # endif
346 # ifndef YY_
347 #  define YY_(msgid) msgid
348 # endif
349 #endif
350
351 /* Suppress unused-variable warnings by "using" E.  */
352 #if ! defined lint || defined __GNUC__
353 # define YYUSE(e) ((void) (e))
354 #else
355 # define YYUSE(e) /* empty */
356 #endif
357
358 /* Identity function, used to suppress warnings about constant conditions.  */
359 #ifndef lint
360 # define YYID(n) (n)
361 #else
362 #if (defined __STDC__ || defined __C99__FUNC__ \
363      || defined __cplusplus || defined _MSC_VER)
364 static int
365 YYID (int yyi)
366 #else
367 static int
368 YYID (yyi)
369     int yyi;
370 #endif
371 {
372   return yyi;
373 }
374 #endif
375
376 #if ! defined yyoverflow || YYERROR_VERBOSE
377
378 /* The parser invokes alloca or malloc; define the necessary symbols.  */
379
380 # ifdef YYSTACK_USE_ALLOCA
381 #  if YYSTACK_USE_ALLOCA
382 #   ifdef __GNUC__
383 #    define YYSTACK_ALLOC __builtin_alloca
384 #   elif defined __BUILTIN_VA_ARG_INCR
385 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
386 #   elif defined _AIX
387 #    define YYSTACK_ALLOC __alloca
388 #   elif defined _MSC_VER
389 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
390 #    define alloca _alloca
391 #   else
392 #    define YYSTACK_ALLOC alloca
393 #    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
394      || defined __cplusplus || defined _MSC_VER)
395 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
396 #     ifndef _STDLIB_H
397 #      define _STDLIB_H 1
398 #     endif
399 #    endif
400 #   endif
401 #  endif
402 # endif
403
404 # ifdef YYSTACK_ALLOC
405    /* Pacify GCC's `empty if-body' warning.  */
406 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
407 #  ifndef YYSTACK_ALLOC_MAXIMUM
408     /* The OS might guarantee only one guard page at the bottom of the stack,
409        and a page size can be as small as 4096 bytes.  So we cannot safely
410        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
411        to allow for a few compiler-allocated temporary stack slots.  */
412 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
413 #  endif
414 # else
415 #  define YYSTACK_ALLOC YYMALLOC
416 #  define YYSTACK_FREE YYFREE
417 #  ifndef YYSTACK_ALLOC_MAXIMUM
418 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
419 #  endif
420 #  if (defined __cplusplus && ! defined _STDLIB_H \
421        && ! ((defined YYMALLOC || defined malloc) \
422              && (defined YYFREE || defined free)))
423 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
424 #   ifndef _STDLIB_H
425 #    define _STDLIB_H 1
426 #   endif
427 #  endif
428 #  ifndef YYMALLOC
429 #   define YYMALLOC malloc
430 #   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
431      || defined __cplusplus || defined _MSC_VER)
432 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
433 #   endif
434 #  endif
435 #  ifndef YYFREE
436 #   define YYFREE free
437 #   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
438      || defined __cplusplus || defined _MSC_VER)
439 void free (void *); /* INFRINGES ON USER NAME SPACE */
440 #   endif
441 #  endif
442 # endif
443 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
444
445
446 #if (! defined yyoverflow \
447      && (! defined __cplusplus \
448          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
449
450 /* A type that is properly aligned for any stack member.  */
451 union yyalloc
452 {
453   yytype_int16 yyss_alloc;
454   YYSTYPE yyvs_alloc;
455 };
456
457 /* The size of the maximum gap between one aligned stack and the next.  */
458 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
459
460 /* The size of an array large to enough to hold all stacks, each with
461    N elements.  */
462 # define YYSTACK_BYTES(N) \
463      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
464       + YYSTACK_GAP_MAXIMUM)
465
466 /* Copy COUNT objects from FROM to TO.  The source and destination do
467    not overlap.  */
468 # ifndef YYCOPY
469 #  if defined __GNUC__ && 1 < __GNUC__
470 #   define YYCOPY(To, From, Count) \
471       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
472 #  else
473 #   define YYCOPY(To, From, Count)              \
474       do                                        \
475         {                                       \
476           YYSIZE_T yyi;                         \
477           for (yyi = 0; yyi < (Count); yyi++)   \
478             (To)[yyi] = (From)[yyi];            \
479         }                                       \
480       while (YYID (0))
481 #  endif
482 # endif
483
484 /* Relocate STACK from its old location to the new one.  The
485    local variables YYSIZE and YYSTACKSIZE give the old and new number of
486    elements in the stack, and YYPTR gives the new location of the
487    stack.  Advance YYPTR to a properly aligned location for the next
488    stack.  */
489 # define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
490     do                                                                  \
491       {                                                                 \
492         YYSIZE_T yynewbytes;                                            \
493         YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
494         Stack = &yyptr->Stack_alloc;                                    \
495         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
496         yyptr += yynewbytes / sizeof (*yyptr);                          \
497       }                                                                 \
498     while (YYID (0))
499
500 #endif
501
502 /* YYFINAL -- State number of the termination state.  */
503 #define YYFINAL  12
504 /* YYLAST -- Last index in YYTABLE.  */
505 #define YYLAST   20
506
507 /* YYNTOKENS -- Number of terminals.  */
508 #define YYNTOKENS  11
509 /* YYNNTS -- Number of nonterminals.  */
510 #define YYNNTS  11
511 /* YYNRULES -- Number of rules.  */
512 #define YYNRULES  19
513 /* YYNRULES -- Number of states.  */
514 #define YYNSTATES  25
515
516 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
517 #define YYUNDEFTOK  2
518 #define YYMAXUTOK   265
519
520 #define YYTRANSLATE(YYX)                                                \
521   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
522
523 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
524 static const yytype_uint8 yytranslate[] =
525 {
526        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
527        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
528        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
529        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
530        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
531        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
532        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
533        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
534        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
535        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
536        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
537        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
538        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
539        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
540        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
541        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
542        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
543        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
544        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
545        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
546        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
547        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
548        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
549        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
550        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
551        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
552        5,     6,     7,     8,     9,    10
553 };
554
555 #if YYDEBUG
556 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
557    YYRHS.  */
558 static const yytype_uint8 yyprhs[] =
559 {
560        0,     0,     3,     5,     7,     9,    11,    13,    15,    18,
561       20,    23,    25,    27,    32,    36,    38,    40,    44,    48
562 };
563
564 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
565 static const yytype_int8 yyrhs[] =
566 {
567       12,     0,    -1,    13,    -1,    19,    -1,    21,    -1,     5,
568       -1,     6,    -1,    14,    -1,    14,    15,    -1,     4,    -1,
569        4,    15,    -1,     3,    -1,    14,    -1,    18,     8,    18,
570        9,    -1,    18,    10,     3,    -1,    17,    -1,    18,    -1,
571       19,     7,    14,    -1,    19,     7,    16,    -1,    20,    -1
572 };
573
574 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
575 static const yytype_uint16 yyrline[] =
576 {
577        0,   175,   175,   177,   180,   182,   196,   210,   219,   224,
578      237,   262,   280,   284,   291,   304,   308,   312,   319,   327
579 };
580 #endif
581
582 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
583 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
584    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
585 static const char *const yytname[] =
586 {
587   "$end", "error", "$undefined", "TOK_ID", "TOK_CTOR", "TOK_INT",
588   "TOK_STR", "TOK_EQ", "TOK_LEFT_BRACK", "TOK_RIGHT_BRACK", "TOK_DOT",
589   "$accept", "input", "stmt", "constant", "ctor_args", "construct_expr",
590   "primary_expr", "postfix_expr", "unary_expr", "assign_expr", "expr", 0
591 };
592 #endif
593
594 # ifdef YYPRINT
595 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
596    token YYLEX-NUM.  */
597 static const yytype_uint16 yytoknum[] =
598 {
599        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
600      265
601 };
602 # endif
603
604 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
605 static const yytype_uint8 yyr1[] =
606 {
607        0,    11,    12,    13,    13,    14,    14,    15,    15,    16,
608       16,    17,    17,    18,    18,    18,    19,    20,    20,    21
609 };
610
611 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
612 static const yytype_uint8 yyr2[] =
613 {
614        0,     2,     1,     1,     1,     1,     1,     1,     2,     1,
615        2,     1,     1,     4,     3,     1,     1,     3,     3,     1
616 };
617
618 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
619    STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
620    means the default is an error.  */
621 static const yytype_uint8 yydefact[] =
622 {
623        0,    11,     5,     6,     0,     2,    12,    15,    16,     3,
624       19,     4,     1,     0,     0,     0,     0,    14,     9,    17,
625       18,    13,     7,    10,     8
626 };
627
628 /* YYDEFGOTO[NTERM-NUM].  */
629 static const yytype_int8 yydefgoto[] =
630 {
631       -1,     4,     5,     6,    23,    20,     7,     8,     9,    10,
632       11
633 };
634
635 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
636    STATE-NUM.  */
637 #define YYPACT_NINF -17
638 static const yytype_int8 yypact[] =
639 {
640       -1,   -17,   -17,   -17,     1,   -17,   -17,   -17,     6,     8,
641      -17,   -17,   -17,    -1,    16,     4,     3,   -17,    12,   -17,
642      -17,   -17,    12,   -17,   -17
643 };
644
645 /* YYPGOTO[NTERM-NUM].  */
646 static const yytype_int8 yypgoto[] =
647 {
648      -17,   -17,   -17,   -15,   -16,   -17,   -17,     7,   -17,   -17,
649      -17
650 };
651
652 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
653    positive, shift that token.  If negative, reduce the rule which
654    number is the opposite.  If zero, do what YYDEFACT says.
655    If YYTABLE_NINF, syntax error.  */
656 #define YYTABLE_NINF -1
657 static const yytype_uint8 yytable[] =
658 {
659       19,    12,     1,    22,     2,     3,    24,    22,    18,     2,
660        3,    13,    21,    14,    13,    15,    14,     2,     3,    17,
661       16
662 };
663
664 static const yytype_uint8 yycheck[] =
665 {
666       15,     0,     3,    18,     5,     6,    22,    22,     4,     5,
667        6,     8,     9,    10,     8,     7,    10,     5,     6,     3,
668       13
669 };
670
671 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
672    symbol of state STATE-NUM.  */
673 static const yytype_uint8 yystos[] =
674 {
675        0,     3,     5,     6,    12,    13,    14,    17,    18,    19,
676       20,    21,     0,     8,    10,     7,    18,     3,     4,    14,
677       16,     9,    14,    15,    15
678 };
679
680 #define yyerrok         (yyerrstatus = 0)
681 #define yyclearin       (yychar = YYEMPTY)
682 #define YYEMPTY         (-2)
683 #define YYEOF           0
684
685 #define YYACCEPT        goto yyacceptlab
686 #define YYABORT         goto yyabortlab
687 #define YYERROR         goto yyerrorlab
688
689
690 /* Like YYERROR except do call yyerror.  This remains here temporarily
691    to ease the transition to the new meaning of YYERROR, for GCC.
692    Once GCC version 2 has supplanted version 1, this can go.  */
693
694 #define YYFAIL          goto yyerrlab
695
696 #define YYRECOVERING()  (!!yyerrstatus)
697
698 #define YYBACKUP(Token, Value)                                  \
699 do                                                              \
700   if (yychar == YYEMPTY && yylen == 1)                          \
701     {                                                           \
702       yychar = (Token);                                         \
703       yylval = (Value);                                         \
704       yytoken = YYTRANSLATE (yychar);                           \
705       YYPOPSTACK (1);                                           \
706       goto yybackup;                                            \
707     }                                                           \
708   else                                                          \
709     {                                                           \
710       yyerror (ctx, YY_("syntax error: cannot back up")); \
711       YYERROR;                                                  \
712     }                                                           \
713 while (YYID (0))
714
715
716 #define YYTERROR        1
717 #define YYERRCODE       256
718
719
720 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
721    If N is 0, then set CURRENT to the empty location which ends
722    the previous symbol: RHS[0] (always defined).  */
723
724 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
725 #ifndef YYLLOC_DEFAULT
726 # define YYLLOC_DEFAULT(Current, Rhs, N)                                \
727     do                                                                  \
728       if (YYID (N))                                                    \
729         {                                                               \
730           (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
731           (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
732           (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
733           (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
734         }                                                               \
735       else                                                              \
736         {                                                               \
737           (Current).first_line   = (Current).last_line   =              \
738             YYRHSLOC (Rhs, 0).last_line;                                \
739           (Current).first_column = (Current).last_column =              \
740             YYRHSLOC (Rhs, 0).last_column;                              \
741         }                                                               \
742     while (YYID (0))
743 #endif
744
745
746 /* YY_LOCATION_PRINT -- Print the location on the stream.
747    This macro was not mandated originally: define only if we know
748    we won't break user code: when these are the locations we know.  */
749
750 #ifndef YY_LOCATION_PRINT
751 # if YYLTYPE_IS_TRIVIAL
752 #  define YY_LOCATION_PRINT(File, Loc)                  \
753      fprintf (File, "%d.%d-%d.%d",                      \
754               (Loc).first_line, (Loc).first_column,     \
755               (Loc).last_line,  (Loc).last_column)
756 # else
757 #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
758 # endif
759 #endif
760
761
762 /* YYLEX -- calling `yylex' with the right arguments.  */
763
764 #ifdef YYLEX_PARAM
765 # define YYLEX yylex (&yylval, YYLEX_PARAM)
766 #else
767 # define YYLEX yylex (&yylval)
768 #endif
769
770 /* Enable debugging if requested.  */
771 #if YYDEBUG
772
773 # ifndef YYFPRINTF
774 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
775 #  define YYFPRINTF fprintf
776 # endif
777
778 # define YYDPRINTF(Args)                        \
779 do {                                            \
780   if (yydebug)                                  \
781     YYFPRINTF Args;                             \
782 } while (YYID (0))
783
784 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
785 do {                                                                      \
786   if (yydebug)                                                            \
787     {                                                                     \
788       YYFPRINTF (stderr, "%s ", Title);                                   \
789       yy_symbol_print (stderr,                                            \
790                   Type, Value, ctx); \
791       YYFPRINTF (stderr, "\n");                                           \
792     }                                                                     \
793 } while (YYID (0))
794
795
796 /*--------------------------------.
797 | Print this symbol on YYOUTPUT.  |
798 `--------------------------------*/
799
800 /*ARGSUSED*/
801 #if (defined __STDC__ || defined __C99__FUNC__ \
802      || defined __cplusplus || defined _MSC_VER)
803 static void
804 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct ktrfmt_parse_ctx *ctx)
805 #else
806 static void
807 yy_symbol_value_print (yyoutput, yytype, yyvaluep, ctx)
808     FILE *yyoutput;
809     int yytype;
810     YYSTYPE const * const yyvaluep;
811     struct ktrfmt_parse_ctx *ctx;
812 #endif
813 {
814   if (!yyvaluep)
815     return;
816   YYUSE (ctx);
817 # ifdef YYPRINT
818   if (yytype < YYNTOKENS)
819     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
820 # else
821   YYUSE (yyoutput);
822 # endif
823   switch (yytype)
824     {
825       default:
826         break;
827     }
828 }
829
830
831 /*--------------------------------.
832 | Print this symbol on YYOUTPUT.  |
833 `--------------------------------*/
834
835 #if (defined __STDC__ || defined __C99__FUNC__ \
836      || defined __cplusplus || defined _MSC_VER)
837 static void
838 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct ktrfmt_parse_ctx *ctx)
839 #else
840 static void
841 yy_symbol_print (yyoutput, yytype, yyvaluep, ctx)
842     FILE *yyoutput;
843     int yytype;
844     YYSTYPE const * const yyvaluep;
845     struct ktrfmt_parse_ctx *ctx;
846 #endif
847 {
848   if (yytype < YYNTOKENS)
849     YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
850   else
851     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
852
853   yy_symbol_value_print (yyoutput, yytype, yyvaluep, ctx);
854   YYFPRINTF (yyoutput, ")");
855 }
856
857 /*------------------------------------------------------------------.
858 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
859 | TOP (included).                                                   |
860 `------------------------------------------------------------------*/
861
862 #if (defined __STDC__ || defined __C99__FUNC__ \
863      || defined __cplusplus || defined _MSC_VER)
864 static void
865 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
866 #else
867 static void
868 yy_stack_print (yybottom, yytop)
869     yytype_int16 *yybottom;
870     yytype_int16 *yytop;
871 #endif
872 {
873   YYFPRINTF (stderr, "Stack now");
874   for (; yybottom <= yytop; yybottom++)
875     {
876       int yybot = *yybottom;
877       YYFPRINTF (stderr, " %d", yybot);
878     }
879   YYFPRINTF (stderr, "\n");
880 }
881
882 # define YY_STACK_PRINT(Bottom, Top)                            \
883 do {                                                            \
884   if (yydebug)                                                  \
885     yy_stack_print ((Bottom), (Top));                           \
886 } while (YYID (0))
887
888
889 /*------------------------------------------------.
890 | Report that the YYRULE is going to be reduced.  |
891 `------------------------------------------------*/
892
893 #if (defined __STDC__ || defined __C99__FUNC__ \
894      || defined __cplusplus || defined _MSC_VER)
895 static void
896 yy_reduce_print (YYSTYPE *yyvsp, int yyrule, struct ktrfmt_parse_ctx *ctx)
897 #else
898 static void
899 yy_reduce_print (yyvsp, yyrule, ctx)
900     YYSTYPE *yyvsp;
901     int yyrule;
902     struct ktrfmt_parse_ctx *ctx;
903 #endif
904 {
905   int yynrhs = yyr2[yyrule];
906   int yyi;
907   unsigned long int yylno = yyrline[yyrule];
908   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
909              yyrule - 1, yylno);
910   /* The symbols being reduced.  */
911   for (yyi = 0; yyi < yynrhs; yyi++)
912     {
913       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
914       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
915                        &(yyvsp[(yyi + 1) - (yynrhs)])
916                                        , ctx);
917       YYFPRINTF (stderr, "\n");
918     }
919 }
920
921 # define YY_REDUCE_PRINT(Rule)          \
922 do {                                    \
923   if (yydebug)                          \
924     yy_reduce_print (yyvsp, Rule, ctx); \
925 } while (YYID (0))
926
927 /* Nonzero means print parse trace.  It is left uninitialized so that
928    multiple parsers can coexist.  */
929 int yydebug;
930 #else /* !YYDEBUG */
931 # define YYDPRINTF(Args)
932 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
933 # define YY_STACK_PRINT(Bottom, Top)
934 # define YY_REDUCE_PRINT(Rule)
935 #endif /* !YYDEBUG */
936
937
938 /* YYINITDEPTH -- initial size of the parser's stacks.  */
939 #ifndef YYINITDEPTH
940 # define YYINITDEPTH 200
941 #endif
942
943 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
944    if the built-in stack extension method is used).
945
946    Do not make this value too large; the results are undefined if
947    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
948    evaluated with infinite-precision integer arithmetic.  */
949
950 #ifndef YYMAXDEPTH
951 # define YYMAXDEPTH 10000
952 #endif
953
954 \f
955
956 #if YYERROR_VERBOSE
957
958 # ifndef yystrlen
959 #  if defined __GLIBC__ && defined _STRING_H
960 #   define yystrlen strlen
961 #  else
962 /* Return the length of YYSTR.  */
963 #if (defined __STDC__ || defined __C99__FUNC__ \
964      || defined __cplusplus || defined _MSC_VER)
965 static YYSIZE_T
966 yystrlen (const char *yystr)
967 #else
968 static YYSIZE_T
969 yystrlen (yystr)
970     const char *yystr;
971 #endif
972 {
973   YYSIZE_T yylen;
974   for (yylen = 0; yystr[yylen]; yylen++)
975     continue;
976   return yylen;
977 }
978 #  endif
979 # endif
980
981 # ifndef yystpcpy
982 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
983 #   define yystpcpy stpcpy
984 #  else
985 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
986    YYDEST.  */
987 #if (defined __STDC__ || defined __C99__FUNC__ \
988      || defined __cplusplus || defined _MSC_VER)
989 static char *
990 yystpcpy (char *yydest, const char *yysrc)
991 #else
992 static char *
993 yystpcpy (yydest, yysrc)
994     char *yydest;
995     const char *yysrc;
996 #endif
997 {
998   char *yyd = yydest;
999   const char *yys = yysrc;
1000
1001   while ((*yyd++ = *yys++) != '\0')
1002     continue;
1003
1004   return yyd - 1;
1005 }
1006 #  endif
1007 # endif
1008
1009 # ifndef yytnamerr
1010 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1011    quotes and backslashes, so that it's suitable for yyerror.  The
1012    heuristic is that double-quoting is unnecessary unless the string
1013    contains an apostrophe, a comma, or backslash (other than
1014    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
1015    null, do not copy; instead, return the length of what the result
1016    would have been.  */
1017 static YYSIZE_T
1018 yytnamerr (char *yyres, const char *yystr)
1019 {
1020   if (*yystr == '"')
1021     {
1022       YYSIZE_T yyn = 0;
1023       char const *yyp = yystr;
1024
1025       for (;;)
1026         switch (*++yyp)
1027           {
1028           case '\'':
1029           case ',':
1030             goto do_not_strip_quotes;
1031
1032           case '\\':
1033             if (*++yyp != '\\')
1034               goto do_not_strip_quotes;
1035             /* Fall through.  */
1036           default:
1037             if (yyres)
1038               yyres[yyn] = *yyp;
1039             yyn++;
1040             break;
1041
1042           case '"':
1043             if (yyres)
1044               yyres[yyn] = '\0';
1045             return yyn;
1046           }
1047     do_not_strip_quotes: ;
1048     }
1049
1050   if (! yyres)
1051     return yystrlen (yystr);
1052
1053   return yystpcpy (yyres, yystr) - yyres;
1054 }
1055 # endif
1056
1057 /* Copy into YYRESULT an error message about the unexpected token
1058    YYCHAR while in state YYSTATE.  Return the number of bytes copied,
1059    including the terminating null byte.  If YYRESULT is null, do not
1060    copy anything; just return the number of bytes that would be
1061    copied.  As a special case, return 0 if an ordinary "syntax error"
1062    message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
1063    size calculation.  */
1064 static YYSIZE_T
1065 yysyntax_error (char *yyresult, int yystate, int yychar)
1066 {
1067   int yyn = yypact[yystate];
1068
1069   if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1070     return 0;
1071   else
1072     {
1073       int yytype = YYTRANSLATE (yychar);
1074       YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1075       YYSIZE_T yysize = yysize0;
1076       YYSIZE_T yysize1;
1077       int yysize_overflow = 0;
1078       enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1079       char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1080       int yyx;
1081
1082 # if 0
1083       /* This is so xgettext sees the translatable formats that are
1084          constructed on the fly.  */
1085       YY_("syntax error, unexpected %s");
1086       YY_("syntax error, unexpected %s, expecting %s");
1087       YY_("syntax error, unexpected %s, expecting %s or %s");
1088       YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1089       YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1090 # endif
1091       char *yyfmt;
1092       char const *yyf;
1093       static char const yyunexpected[] = "syntax error, unexpected %s";
1094       static char const yyexpecting[] = ", expecting %s";
1095       static char const yyor[] = " or %s";
1096       char yyformat[sizeof yyunexpected
1097                     + sizeof yyexpecting - 1
1098                     + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1099                        * (sizeof yyor - 1))];
1100       char const *yyprefix = yyexpecting;
1101
1102       /* Start YYX at -YYN if negative to avoid negative indexes in
1103          YYCHECK.  */
1104       int yyxbegin = yyn < 0 ? -yyn : 0;
1105
1106       /* Stay within bounds of both yycheck and yytname.  */
1107       int yychecklim = YYLAST - yyn + 1;
1108       int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1109       int yycount = 1;
1110
1111       yyarg[0] = yytname[yytype];
1112       yyfmt = yystpcpy (yyformat, yyunexpected);
1113
1114       for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1115         if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1116           {
1117             if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1118               {
1119                 yycount = 1;
1120                 yysize = yysize0;
1121                 yyformat[sizeof yyunexpected - 1] = '\0';
1122                 break;
1123               }
1124             yyarg[yycount++] = yytname[yyx];
1125             yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1126             yysize_overflow |= (yysize1 < yysize);
1127             yysize = yysize1;
1128             yyfmt = yystpcpy (yyfmt, yyprefix);
1129             yyprefix = yyor;
1130           }
1131
1132       yyf = YY_(yyformat);
1133       yysize1 = yysize + yystrlen (yyf);
1134       yysize_overflow |= (yysize1 < yysize);
1135       yysize = yysize1;
1136
1137       if (yysize_overflow)
1138         return YYSIZE_MAXIMUM;
1139
1140       if (yyresult)
1141         {
1142           /* Avoid sprintf, as that infringes on the user's name space.
1143              Don't have undefined behavior even if the translation
1144              produced a string with the wrong number of "%s"s.  */
1145           char *yyp = yyresult;
1146           int yyi = 0;
1147           while ((*yyp = *yyf) != '\0')
1148             {
1149               if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1150                 {
1151                   yyp += yytnamerr (yyp, yyarg[yyi++]);
1152                   yyf += 2;
1153                 }
1154               else
1155                 {
1156                   yyp++;
1157                   yyf++;
1158                 }
1159             }
1160         }
1161       return yysize;
1162     }
1163 }
1164 #endif /* YYERROR_VERBOSE */
1165 \f
1166
1167 /*-----------------------------------------------.
1168 | Release the memory associated to this symbol.  |
1169 `-----------------------------------------------*/
1170
1171 /*ARGSUSED*/
1172 #if (defined __STDC__ || defined __C99__FUNC__ \
1173      || defined __cplusplus || defined _MSC_VER)
1174 static void
1175 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, struct ktrfmt_parse_ctx *ctx)
1176 #else
1177 static void
1178 yydestruct (yymsg, yytype, yyvaluep, ctx)
1179     const char *yymsg;
1180     int yytype;
1181     YYSTYPE *yyvaluep;
1182     struct ktrfmt_parse_ctx *ctx;
1183 #endif
1184 {
1185   YYUSE (yyvaluep);
1186   YYUSE (ctx);
1187
1188   if (!yymsg)
1189     yymsg = "Deleting";
1190   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1191
1192   switch (yytype)
1193     {
1194
1195       default:
1196         break;
1197     }
1198 }
1199
1200 /* Prevent warnings from -Wmissing-prototypes.  */
1201 #ifdef YYPARSE_PARAM
1202 #if defined __STDC__ || defined __cplusplus
1203 int yyparse (void *YYPARSE_PARAM);
1204 #else
1205 int yyparse ();
1206 #endif
1207 #else /* ! YYPARSE_PARAM */
1208 #if defined __STDC__ || defined __cplusplus
1209 int yyparse (struct ktrfmt_parse_ctx *ctx);
1210 #else
1211 int yyparse ();
1212 #endif
1213 #endif /* ! YYPARSE_PARAM */
1214
1215
1216
1217
1218
1219 /*-------------------------.
1220 | yyparse or yypush_parse.  |
1221 `-------------------------*/
1222
1223 #ifdef YYPARSE_PARAM
1224 #if (defined __STDC__ || defined __C99__FUNC__ \
1225      || defined __cplusplus || defined _MSC_VER)
1226 int
1227 yyparse (void *YYPARSE_PARAM)
1228 #else
1229 int
1230 yyparse (YYPARSE_PARAM)
1231     void *YYPARSE_PARAM;
1232 #endif
1233 #else /* ! YYPARSE_PARAM */
1234 #if (defined __STDC__ || defined __C99__FUNC__ \
1235      || defined __cplusplus || defined _MSC_VER)
1236 int
1237 yyparse (struct ktrfmt_parse_ctx *ctx)
1238 #else
1239 int
1240 yyparse (ctx)
1241     struct ktrfmt_parse_ctx *ctx;
1242 #endif
1243 #endif
1244 {
1245 /* The lookahead symbol.  */
1246 int yychar;
1247
1248 /* The semantic value of the lookahead symbol.  */
1249 YYSTYPE yylval;
1250
1251     /* Number of syntax errors so far.  */
1252     int yynerrs;
1253
1254     int yystate;
1255     /* Number of tokens to shift before error messages enabled.  */
1256     int yyerrstatus;
1257
1258     /* The stacks and their tools:
1259        `yyss': related to states.
1260        `yyvs': related to semantic values.
1261
1262        Refer to the stacks thru separate pointers, to allow yyoverflow
1263        to reallocate them elsewhere.  */
1264
1265     /* The state stack.  */
1266     yytype_int16 yyssa[YYINITDEPTH];
1267     yytype_int16 *yyss;
1268     yytype_int16 *yyssp;
1269
1270     /* The semantic value stack.  */
1271     YYSTYPE yyvsa[YYINITDEPTH];
1272     YYSTYPE *yyvs;
1273     YYSTYPE *yyvsp;
1274
1275     YYSIZE_T yystacksize;
1276
1277   int yyn;
1278   int yyresult;
1279   /* Lookahead token as an internal (translated) token number.  */
1280   int yytoken;
1281   /* The variables used to return semantic value and location from the
1282      action routines.  */
1283   YYSTYPE yyval;
1284
1285 #if YYERROR_VERBOSE
1286   /* Buffer for error messages, and its allocated size.  */
1287   char yymsgbuf[128];
1288   char *yymsg = yymsgbuf;
1289   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1290 #endif
1291
1292 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1293
1294   /* The number of symbols on the RHS of the reduced rule.
1295      Keep to zero when no symbol should be popped.  */
1296   int yylen = 0;
1297
1298   yytoken = 0;
1299   yyss = yyssa;
1300   yyvs = yyvsa;
1301   yystacksize = YYINITDEPTH;
1302
1303   YYDPRINTF ((stderr, "Starting parse\n"));
1304
1305   yystate = 0;
1306   yyerrstatus = 0;
1307   yynerrs = 0;
1308   yychar = YYEMPTY; /* Cause a token to be read.  */
1309
1310   /* Initialize stack pointers.
1311      Waste one element of value and location stack
1312      so that they stay on the same level as the state stack.
1313      The wasted elements are never initialized.  */
1314   yyssp = yyss;
1315   yyvsp = yyvs;
1316
1317   goto yysetstate;
1318
1319 /*------------------------------------------------------------.
1320 | yynewstate -- Push a new state, which is found in yystate.  |
1321 `------------------------------------------------------------*/
1322  yynewstate:
1323   /* In all cases, when you get here, the value and location stacks
1324      have just been pushed.  So pushing a state here evens the stacks.  */
1325   yyssp++;
1326
1327  yysetstate:
1328   *yyssp = yystate;
1329
1330   if (yyss + yystacksize - 1 <= yyssp)
1331     {
1332       /* Get the current used size of the three stacks, in elements.  */
1333       YYSIZE_T yysize = yyssp - yyss + 1;
1334
1335 #ifdef yyoverflow
1336       {
1337         /* Give user a chance to reallocate the stack.  Use copies of
1338            these so that the &'s don't force the real ones into
1339            memory.  */
1340         YYSTYPE *yyvs1 = yyvs;
1341         yytype_int16 *yyss1 = yyss;
1342
1343         /* Each stack pointer address is followed by the size of the
1344            data in use in that stack, in bytes.  This used to be a
1345            conditional around just the two extra args, but that might
1346            be undefined if yyoverflow is a macro.  */
1347         yyoverflow (YY_("memory exhausted"),
1348                     &yyss1, yysize * sizeof (*yyssp),
1349                     &yyvs1, yysize * sizeof (*yyvsp),
1350                     &yystacksize);
1351
1352         yyss = yyss1;
1353         yyvs = yyvs1;
1354       }
1355 #else /* no yyoverflow */
1356 # ifndef YYSTACK_RELOCATE
1357       goto yyexhaustedlab;
1358 # else
1359       /* Extend the stack our own way.  */
1360       if (YYMAXDEPTH <= yystacksize)
1361         goto yyexhaustedlab;
1362       yystacksize *= 2;
1363       if (YYMAXDEPTH < yystacksize)
1364         yystacksize = YYMAXDEPTH;
1365
1366       {
1367         yytype_int16 *yyss1 = yyss;
1368         union yyalloc *yyptr =
1369           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1370         if (! yyptr)
1371           goto yyexhaustedlab;
1372         YYSTACK_RELOCATE (yyss_alloc, yyss);
1373         YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1374 #  undef YYSTACK_RELOCATE
1375         if (yyss1 != yyssa)
1376           YYSTACK_FREE (yyss1);
1377       }
1378 # endif
1379 #endif /* no yyoverflow */
1380
1381       yyssp = yyss + yysize - 1;
1382       yyvsp = yyvs + yysize - 1;
1383
1384       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1385                   (unsigned long int) yystacksize));
1386
1387       if (yyss + yystacksize - 1 <= yyssp)
1388         YYABORT;
1389     }
1390
1391   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1392
1393   if (yystate == YYFINAL)
1394     YYACCEPT;
1395
1396   goto yybackup;
1397
1398 /*-----------.
1399 | yybackup.  |
1400 `-----------*/
1401 yybackup:
1402
1403   /* Do appropriate processing given the current state.  Read a
1404      lookahead token if we need one and don't already have one.  */
1405
1406   /* First try to decide what to do without reference to lookahead token.  */
1407   yyn = yypact[yystate];
1408   if (yyn == YYPACT_NINF)
1409     goto yydefault;
1410
1411   /* Not known => get a lookahead token if don't already have one.  */
1412
1413   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1414   if (yychar == YYEMPTY)
1415     {
1416       YYDPRINTF ((stderr, "Reading a token: "));
1417       yychar = YYLEX;
1418     }
1419
1420   if (yychar <= YYEOF)
1421     {
1422       yychar = yytoken = YYEOF;
1423       YYDPRINTF ((stderr, "Now at end of input.\n"));
1424     }
1425   else
1426     {
1427       yytoken = YYTRANSLATE (yychar);
1428       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1429     }
1430
1431   /* If the proper action on seeing token YYTOKEN is to reduce or to
1432      detect an error, take that action.  */
1433   yyn += yytoken;
1434   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1435     goto yydefault;
1436   yyn = yytable[yyn];
1437   if (yyn <= 0)
1438     {
1439       if (yyn == 0 || yyn == YYTABLE_NINF)
1440         goto yyerrlab;
1441       yyn = -yyn;
1442       goto yyreduce;
1443     }
1444
1445   /* Count tokens shifted since error; after three, turn off error
1446      status.  */
1447   if (yyerrstatus)
1448     yyerrstatus--;
1449
1450   /* Shift the lookahead token.  */
1451   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1452
1453   /* Discard the shifted token.  */
1454   yychar = YYEMPTY;
1455
1456   yystate = yyn;
1457   *++yyvsp = yylval;
1458
1459   goto yynewstate;
1460
1461
1462 /*-----------------------------------------------------------.
1463 | yydefault -- do the default action for the current state.  |
1464 `-----------------------------------------------------------*/
1465 yydefault:
1466   yyn = yydefact[yystate];
1467   if (yyn == 0)
1468     goto yyerrlab;
1469   goto yyreduce;
1470
1471
1472 /*-----------------------------.
1473 | yyreduce -- Do a reduction.  |
1474 `-----------------------------*/
1475 yyreduce:
1476   /* yyn is the number of a rule to reduce with.  */
1477   yylen = yyr2[yyn];
1478
1479   /* If YYLEN is nonzero, implement the default value of the action:
1480      `$$ = $1'.
1481
1482      Otherwise, the following line sets YYVAL to garbage.
1483      This behavior is undocumented and Bison
1484      users should not rely upon it.  Assigning to YYVAL
1485      unconditionally makes the parser a bit smaller, and it avoids a
1486      GCC warning that YYVAL may be used uninitialized.  */
1487   yyval = yyvsp[1-yylen];
1488
1489
1490   YY_REDUCE_PRINT (yyn);
1491   switch (yyn)
1492     {
1493         case 3:
1494
1495 /* Line 1455 of yacc.c  */
1496 #line 177 "ktrfmt.y"
1497     {
1498         ctx->var = (yyvsp[(1) - (1)].var);
1499  ;}
1500     break;
1501
1502   case 5:
1503
1504 /* Line 1455 of yacc.c  */
1505 #line 182 "ktrfmt.y"
1506     {
1507         evtr_var_t var;
1508         if (!(yyvsp[(1) - (1)].tok)->str)
1509                 parse_err("out of memory");
1510         var = evtr_var_new(uniq_varname());
1511         var->val.type = EVTR_VAL_INT;
1512         errno = 0;
1513         var->val.num = strtoll((yyvsp[(1) - (1)].tok)->str, NULL, 0);
1514         if (errno) {
1515                 parse_err("Can't parse numeric constant '%s'", (yyvsp[(1) - (1)].tok)->str);
1516         }
1517         (yyval.var) = var;
1518         tok_free((yyvsp[(1) - (1)].tok));
1519         ;}
1520     break;
1521
1522   case 6:
1523
1524 /* Line 1455 of yacc.c  */
1525 #line 196 "ktrfmt.y"
1526     {
1527         evtr_var_t var;
1528         if (!(yyvsp[(1) - (1)].tok)->str)
1529                 parse_err("out of memory");
1530         var = evtr_var_new(uniq_varname());
1531         var->val.type = EVTR_VAL_STR;
1532         var->val.str = (yyvsp[(1) - (1)].tok)->str;
1533         if (!var->val.str) {
1534                 parse_err("out of memory");
1535         }
1536         (yyval.var) = var;
1537         tok_free((yyvsp[(1) - (1)].tok));
1538         ;}
1539     break;
1540
1541   case 7:
1542
1543 /* Line 1455 of yacc.c  */
1544 #line 210 "ktrfmt.y"
1545     {
1546         evtr_var_t ctor;
1547         ctor = evtr_var_new(uniq_varname());
1548         ctor->val.type = EVTR_VAL_CTOR;
1549         ctor->val.ctor.name = NULL;
1550         TAILQ_INIT(&ctor->val.ctor.args);
1551         TAILQ_INSERT_HEAD(&ctor->val.ctor.args, &(yyvsp[(1) - (1)].var)->val, link);
1552         (yyval.var) = ctor;
1553  ;}
1554     break;
1555
1556   case 8:
1557
1558 /* Line 1455 of yacc.c  */
1559 #line 219 "ktrfmt.y"
1560     {
1561         TAILQ_INSERT_HEAD(&(yyvsp[(2) - (2)].var)->val.ctor.args, &(yyvsp[(1) - (2)].var)->val, link);
1562         (yyval.var) = (yyvsp[(2) - (2)].var);
1563  ;}
1564     break;
1565
1566   case 9:
1567
1568 /* Line 1455 of yacc.c  */
1569 #line 224 "ktrfmt.y"
1570     {
1571         evtr_var_t var;
1572         if (!(yyvsp[(1) - (1)].tok)->str)
1573                 parse_err("out of memory");
1574         printd(PARSE, "TOK_CTOR\n");
1575         printd(PARSE, "tok: %p, str = %p\n", (yyvsp[(1) - (1)].tok), (yyvsp[(1) - (1)].tok)->str);
1576         var = evtr_var_new(uniq_varname());
1577         var->val.type = EVTR_VAL_CTOR;
1578         var->val.ctor.name = (yyvsp[(1) - (1)].tok)->str;
1579         TAILQ_INIT(&var->val.ctor.args);
1580         tok_free((yyvsp[(1) - (1)].tok));
1581         (yyval.var) = var;
1582  ;}
1583     break;
1584
1585   case 10:
1586
1587 /* Line 1455 of yacc.c  */
1588 #line 237 "ktrfmt.y"
1589     {
1590         evtr_variable_value_t val;
1591         if (!(yyvsp[(1) - (2)].tok)->str)
1592                 parse_err("out of memory");
1593         printd(PARSE, "TOK_CTOR\n");
1594         printd(PARSE, "tok: %p, str = %p\n", (yyvsp[(1) - (2)].tok), (yyvsp[(1) - (2)].tok)->str);
1595         (yyvsp[(2) - (2)].var)->val.ctor.name = (yyvsp[(1) - (2)].tok)->str;
1596         (yyval.var) = (yyvsp[(2) - (2)].var);
1597         printd(PARSE, "CTOR: %s\n", (yyvsp[(1) - (2)].tok)->str);
1598         TAILQ_FOREACH(val, &(yyvsp[(2) - (2)].var)->val.ctor.args, link) {
1599                 switch (val->type) {
1600                 case EVTR_VAL_INT:
1601                         printd(PARSE, "\t%jd\n", val->num);
1602                         break;
1603                 case EVTR_VAL_STR:
1604                         printd(PARSE, "\t\"%s\"\n", val->str);
1605                         break;
1606                 case EVTR_VAL_NIL:
1607                         assert(!"can't get here");
1608                 default:
1609                         ;
1610                 }
1611         }
1612  ;}
1613     break;
1614
1615   case 11:
1616
1617 /* Line 1455 of yacc.c  */
1618 #line 262 "ktrfmt.y"
1619     {
1620         evtr_var_t var;
1621         if (!(yyvsp[(1) - (1)].tok)->str)
1622                 parse_err("out of memory");
1623         printd(PARSE, "TOK_ID\n");
1624         printd(PARSE, "tok: %p, str = %p\n", (yyvsp[(1) - (1)].tok), (yyvsp[(1) - (1)].tok)->str);
1625         var = symtab_find(ctx->symtab, (yyvsp[(1) - (1)].tok)->str);
1626         if (!var) {
1627                 if (!(var = evtr_var_new((yyvsp[(1) - (1)].tok)->str))) {
1628                         tok_free((yyvsp[(1) - (1)].tok));
1629                         parse_err("out of memory");
1630                 }
1631                 printd(PARSE, "creating var %s\n", (yyvsp[(1) - (1)].tok)->str);
1632                 symtab_insert(ctx->symtab, (yyvsp[(1) - (1)].tok)->str, var);
1633         }
1634         (yyval.var) = var;
1635         tok_free((yyvsp[(1) - (1)].tok));
1636  ;}
1637     break;
1638
1639   case 12:
1640
1641 /* Line 1455 of yacc.c  */
1642 #line 280 "ktrfmt.y"
1643     {
1644         (yyval.var) = (yyvsp[(1) - (1)].var);
1645   ;}
1646     break;
1647
1648   case 13:
1649
1650 /* Line 1455 of yacc.c  */
1651 #line 284 "ktrfmt.y"
1652     {
1653         evtr_var_t var;
1654
1655         if (index_hash(ctx, (yyvsp[(1) - (4)].var)->name, &(yyvsp[(3) - (4)].var)->val, &var))
1656                 YYABORT;
1657         (yyval.var) = var;
1658  ;}
1659     break;
1660
1661   case 14:
1662
1663 /* Line 1455 of yacc.c  */
1664 #line 291 "ktrfmt.y"
1665     {
1666         evtr_var_t var, tmp;
1667         if (!(yyvsp[(3) - (3)].tok)->str)
1668                 parse_err("out of memory");
1669         tmp = evtr_var_new(uniq_varname());
1670         tmp->val.type = EVTR_VAL_STR;
1671         tmp->val.str = (yyvsp[(3) - (3)].tok)->str;
1672
1673         if (index_hash(ctx, (yyvsp[(1) - (3)].var)->name, &tmp->val, &var))
1674                 YYABORT;
1675         tok_free((yyvsp[(3) - (3)].tok));
1676         (yyval.var) = var;
1677  ;}
1678     break;
1679
1680   case 15:
1681
1682 /* Line 1455 of yacc.c  */
1683 #line 304 "ktrfmt.y"
1684     {
1685         (yyval.var) = (yyvsp[(1) - (1)].var);
1686  ;}
1687     break;
1688
1689   case 16:
1690
1691 /* Line 1455 of yacc.c  */
1692 #line 308 "ktrfmt.y"
1693     {
1694         (yyval.var) = (yyvsp[(1) - (1)].var);
1695  ;}
1696     break;
1697
1698   case 17:
1699
1700 /* Line 1455 of yacc.c  */
1701 #line 312 "ktrfmt.y"
1702     {
1703         (yyvsp[(1) - (3)].var)->val = (yyvsp[(3) - (3)].var)->val;
1704         ctx->ev->type = EVTR_TYPE_STMT;
1705         ctx->ev->stmt.var = (yyvsp[(1) - (3)].var);
1706         ctx->ev->stmt.val = &(yyvsp[(3) - (3)].var)->val;
1707         ctx->ev->stmt.op = EVTR_OP_SET;
1708  ;}
1709     break;
1710
1711   case 18:
1712
1713 /* Line 1455 of yacc.c  */
1714 #line 319 "ktrfmt.y"
1715     {
1716         (yyvsp[(1) - (3)].var)->val = (yyvsp[(3) - (3)].var)->val;
1717         ctx->ev->type = EVTR_TYPE_STMT;
1718         ctx->ev->stmt.var = (yyvsp[(1) - (3)].var);
1719         ctx->ev->stmt.val = &(yyvsp[(3) - (3)].var)->val;
1720         ctx->ev->stmt.op = EVTR_OP_SET;
1721  ;}
1722     break;
1723
1724   case 19:
1725
1726 /* Line 1455 of yacc.c  */
1727 #line 327 "ktrfmt.y"
1728     {
1729         (yyval.na) = (yyvsp[(1) - (1)].na);
1730  ;}
1731     break;
1732
1733
1734
1735 /* Line 1455 of yacc.c  */
1736 #line 1734 "ktrfmt.tab.c"
1737       default: break;
1738     }
1739   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1740
1741   YYPOPSTACK (yylen);
1742   yylen = 0;
1743   YY_STACK_PRINT (yyss, yyssp);
1744
1745   *++yyvsp = yyval;
1746
1747   /* Now `shift' the result of the reduction.  Determine what state
1748      that goes to, based on the state we popped back to and the rule
1749      number reduced by.  */
1750
1751   yyn = yyr1[yyn];
1752
1753   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1754   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1755     yystate = yytable[yystate];
1756   else
1757     yystate = yydefgoto[yyn - YYNTOKENS];
1758
1759   goto yynewstate;
1760
1761
1762 /*------------------------------------.
1763 | yyerrlab -- here on detecting error |
1764 `------------------------------------*/
1765 yyerrlab:
1766   /* If not already recovering from an error, report this error.  */
1767   if (!yyerrstatus)
1768     {
1769       ++yynerrs;
1770 #if ! YYERROR_VERBOSE
1771       yyerror (ctx, YY_("syntax error"));
1772 #else
1773       {
1774         YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1775         if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1776           {
1777             YYSIZE_T yyalloc = 2 * yysize;
1778             if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1779               yyalloc = YYSTACK_ALLOC_MAXIMUM;
1780             if (yymsg != yymsgbuf)
1781               YYSTACK_FREE (yymsg);
1782             yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1783             if (yymsg)
1784               yymsg_alloc = yyalloc;
1785             else
1786               {
1787                 yymsg = yymsgbuf;
1788                 yymsg_alloc = sizeof yymsgbuf;
1789               }
1790           }
1791
1792         if (0 < yysize && yysize <= yymsg_alloc)
1793           {
1794             (void) yysyntax_error (yymsg, yystate, yychar);
1795             yyerror (ctx, yymsg);
1796           }
1797         else
1798           {
1799             yyerror (ctx, YY_("syntax error"));
1800             if (yysize != 0)
1801               goto yyexhaustedlab;
1802           }
1803       }
1804 #endif
1805     }
1806
1807
1808
1809   if (yyerrstatus == 3)
1810     {
1811       /* If just tried and failed to reuse lookahead token after an
1812          error, discard it.  */
1813
1814       if (yychar <= YYEOF)
1815         {
1816           /* Return failure if at end of input.  */
1817           if (yychar == YYEOF)
1818             YYABORT;
1819         }
1820       else
1821         {
1822           yydestruct ("Error: discarding",
1823                       yytoken, &yylval, ctx);
1824           yychar = YYEMPTY;
1825         }
1826     }
1827
1828   /* Else will try to reuse lookahead token after shifting the error
1829      token.  */
1830   goto yyerrlab1;
1831
1832
1833 /*---------------------------------------------------.
1834 | yyerrorlab -- error raised explicitly by YYERROR.  |
1835 `---------------------------------------------------*/
1836 yyerrorlab:
1837
1838   /* Pacify compilers like GCC when the user code never invokes
1839      YYERROR and the label yyerrorlab therefore never appears in user
1840      code.  */
1841   if (/*CONSTCOND*/ 0)
1842      goto yyerrorlab;
1843
1844   /* Do not reclaim the symbols of the rule which action triggered
1845      this YYERROR.  */
1846   YYPOPSTACK (yylen);
1847   yylen = 0;
1848   YY_STACK_PRINT (yyss, yyssp);
1849   yystate = *yyssp;
1850   goto yyerrlab1;
1851
1852
1853 /*-------------------------------------------------------------.
1854 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
1855 `-------------------------------------------------------------*/
1856 yyerrlab1:
1857   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
1858
1859   for (;;)
1860     {
1861       yyn = yypact[yystate];
1862       if (yyn != YYPACT_NINF)
1863         {
1864           yyn += YYTERROR;
1865           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1866             {
1867               yyn = yytable[yyn];
1868               if (0 < yyn)
1869                 break;
1870             }
1871         }
1872
1873       /* Pop the current state because it cannot handle the error token.  */
1874       if (yyssp == yyss)
1875         YYABORT;
1876
1877
1878       yydestruct ("Error: popping",
1879                   yystos[yystate], yyvsp, ctx);
1880       YYPOPSTACK (1);
1881       yystate = *yyssp;
1882       YY_STACK_PRINT (yyss, yyssp);
1883     }
1884
1885   *++yyvsp = yylval;
1886
1887
1888   /* Shift the error token.  */
1889   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1890
1891   yystate = yyn;
1892   goto yynewstate;
1893
1894
1895 /*-------------------------------------.
1896 | yyacceptlab -- YYACCEPT comes here.  |
1897 `-------------------------------------*/
1898 yyacceptlab:
1899   yyresult = 0;
1900   goto yyreturn;
1901
1902 /*-----------------------------------.
1903 | yyabortlab -- YYABORT comes here.  |
1904 `-----------------------------------*/
1905 yyabortlab:
1906   yyresult = 1;
1907   goto yyreturn;
1908
1909 #if !defined(yyoverflow) || YYERROR_VERBOSE
1910 /*-------------------------------------------------.
1911 | yyexhaustedlab -- memory exhaustion comes here.  |
1912 `-------------------------------------------------*/
1913 yyexhaustedlab:
1914   yyerror (ctx, YY_("memory exhausted"));
1915   yyresult = 2;
1916   /* Fall through.  */
1917 #endif
1918
1919 yyreturn:
1920   if (yychar != YYEMPTY)
1921      yydestruct ("Cleanup: discarding lookahead",
1922                  yytoken, &yylval, ctx);
1923   /* Do not reclaim the symbols of the rule which action triggered
1924      this YYABORT or YYACCEPT.  */
1925   YYPOPSTACK (yylen);
1926   YY_STACK_PRINT (yyss, yyssp);
1927   while (yyssp != yyss)
1928     {
1929       yydestruct ("Cleanup: popping",
1930                   yystos[*yyssp], yyvsp, ctx);
1931       YYPOPSTACK (1);
1932     }
1933 #ifndef yyoverflow
1934   if (yyss != yyssa)
1935     YYSTACK_FREE (yyss);
1936 #endif
1937 #if YYERROR_VERBOSE
1938   if (yymsg != yymsgbuf)
1939     YYSTACK_FREE (yymsg);
1940 #endif
1941   /* Make sure YYID is used.  */
1942   return YYID (yyresult);
1943 }
1944
1945
1946
1947 /* Line 1675 of yacc.c  */
1948 #line 332 "ktrfmt.y"
1949
1950
1951 void * __ktrfmt_scan_string(const char *);
1952 void __ktrfmt_delete_buffer(void *);
1953
1954 void
1955 __ktrfmt_error (struct ktrfmt_parse_ctx *ctx, const char *s)
1956 {
1957         do_parse_err(ctx, s);
1958 }
1959
1960 int
1961 parse_string(evtr_event_t ev, struct symtab *symtab, const char *str,
1962              char *errbuf, size_t errbufsz)
1963 {
1964         void *bufstate;
1965         int ret;
1966         struct ktrfmt_parse_ctx ctx;
1967
1968         printd(PARSE, "parsing \"%s\"\n", str);
1969         ctx.ev = ev;
1970         ctx.symtab = symtab;
1971         ctx.errbuf = errbuf;
1972         ctx.errbuf[0] = '\0';
1973         ctx.errbufsz = errbufsz;
1974         ctx.err = 0;
1975         bufstate = __ktrfmt_scan_string(str);
1976         ret = __ktrfmt_parse(&ctx);
1977         __ktrfmt_delete_buffer(bufstate);
1978
1979         return ret;
1980 }
1981
1982 int
1983 parse_var(const char *str, struct symtab *symtab, struct evtr_variable **var,
1984           char *errbuf, size_t errbufsz)
1985 {
1986         void *bufstate;
1987         int ret;
1988         struct ktrfmt_parse_ctx ctx;
1989
1990         printd(PARSE, "parsing \"%s\"\n", str);
1991         ctx.ev = NULL;
1992         ctx.symtab = symtab;
1993         ctx.var = NULL;
1994         ctx.errbuf = errbuf;
1995         ctx.errbuf[0] = '\0';
1996         ctx.errbufsz = errbufsz;
1997         ctx.err = 0;
1998         bufstate = __ktrfmt_scan_string(str);
1999         ret = __ktrfmt_parse(&ctx);
2000         __ktrfmt_delete_buffer(bufstate);
2001
2002         *var = ctx.var;
2003         return ret;
2004 }
2005