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