xref: /dflybsd-src/lib/libevtr/ktrfmt.tab.c (revision d83c779ab2c938232fa7b53777cd18cc9c4fc8e4)
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  13
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  13
425 /* YYNRULES -- Number of states.  */
426 #define YYNSTATES  18
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,    24,    26,    30
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,     3,     7,    15,
481        8,    -1,    14,    -1,    15,    -1,    16,     6,    13,    -1,
482       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      182,   186,   190,   198
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,    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        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,    10,    11,     3,
534       13,     4,     0,     1,     0,     0,    12,     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,    -2,    -6,    -6,     6,    -6,    -6,    -6,    -6,     1,
549       -6,    -6,    -3,    -6,    -1,     0,    -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,     2,     3,    12,    13,    14,    17,    16,
566        0,     0,     0,     0,    15
567 };
568 
569 static const yytype_int8 yycheck[] =
570 {
571        3,     4,     5,     4,     5,     7,     0,     6,     8,    14,
572       -1,    -1,    -1,    -1,    12
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,     7,     0,     6,    15,    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 
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 
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_INT;
1428 	var->val.str = strdup((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 	hsh = symtab_find(ctx->symtab, (yyvsp[(1) - (4)].tok)->str);
1474 	if (!hsh) {
1475 		printd(PARSE, "creating hash: %s\n", (yyvsp[(1) - (4)].tok)->str);
1476 		hsh = evtr_var_new((yyvsp[(1) - (4)].tok)->str);
1477 		hsh->val.type = EVTR_VAL_HASH;
1478 		hsh->val.hashtab = hash_new();
1479 		symtab_insert(ctx->symtab, (yyvsp[(1) - (4)].tok)->str, hsh);
1480 	}
1481 	if (hsh->val.type != EVTR_VAL_HASH) {
1482 		printd(PARSE, "variable %s does not contain a hash\n", hsh->name);
1483 		YYABORT;
1484 	}
1485 	val = &(yyvsp[(3) - (4)].var)->val;
1486 	if (val->type == EVTR_VAL_INT) {
1487 		uintptr_t ret;
1488 		uintptr_t key = val->num;
1489 		printd(PARSE, "looking up %s[%jd] in %p\n", (yyvsp[(1) - (4)].tok)->str, val->num, hsh->val.hashtab);
1490 		/* XXX: should definitely be using uintptr_t for keys/values */
1491 		if (hash_find(hsh->val.hashtab, key, &ret)) {
1492 			printd(PARSE, "didn't find it\n");
1493 			var = evtr_var_new(uniq_varname());
1494 			if (var) {
1495 				printd(PARSE, "inserting it as %s\n", var->name);
1496 				if (!hash_insert(hsh->val.hashtab, key, (uintptr_t)var)) {
1497 					fprintf(stderr, "can't insert tmp "
1498 						"variable into hash\n");
1499 					YYABORT;
1500 				}
1501 			}
1502 		} else {
1503 			var = (struct evtr_variable *)ret;
1504 		}
1505 	} else {
1506 		fprintf(stderr, "trying to index hash w/ non-integral value\n");
1507 		YYABORT;
1508 	}
1509 	if (!var) {
1510 		fprintf(stderr, "no var!\n");
1511 		YYABORT;
1512 		/* XXX */
1513 	}
1514 	tok_free((yyvsp[(1) - (4)].tok));
1515 	(yyval.var) = var;
1516  ;}
1517     break;
1518 
1519   case 10:
1520 
1521 /* Line 1455 of yacc.c  */
1522 #line 182 "ktrfmt.y"
1523     {
1524 	(yyval.var) = (yyvsp[(1) - (1)].var);
1525  ;}
1526     break;
1527 
1528   case 11:
1529 
1530 /* Line 1455 of yacc.c  */
1531 #line 186 "ktrfmt.y"
1532     {
1533 	(yyval.var) = (yyvsp[(1) - (1)].var);
1534  ;}
1535     break;
1536 
1537   case 12:
1538 
1539 /* Line 1455 of yacc.c  */
1540 #line 190 "ktrfmt.y"
1541     {
1542 	(yyvsp[(1) - (3)].var)->val = (yyvsp[(3) - (3)].var)->val;
1543 	ctx->ev->type = EVTR_TYPE_STMT;
1544 	ctx->ev->stmt.var = (yyvsp[(1) - (3)].var);
1545 	ctx->ev->stmt.val = &(yyvsp[(3) - (3)].var)->val;
1546 	ctx->ev->stmt.op = EVTR_OP_SET;
1547  ;}
1548     break;
1549 
1550   case 13:
1551 
1552 /* Line 1455 of yacc.c  */
1553 #line 198 "ktrfmt.y"
1554     {
1555 	(yyval.na) = (yyvsp[(1) - (1)].na);
1556  ;}
1557     break;
1558 
1559 
1560 
1561 /* Line 1455 of yacc.c  */
1562 #line 1563 "ktrfmt.tab.c"
1563       default: break;
1564     }
1565   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1566 
1567   YYPOPSTACK (yylen);
1568   yylen = 0;
1569   YY_STACK_PRINT (yyss, yyssp);
1570 
1571   *++yyvsp = yyval;
1572 
1573   /* Now `shift' the result of the reduction.  Determine what state
1574      that goes to, based on the state we popped back to and the rule
1575      number reduced by.  */
1576 
1577   yyn = yyr1[yyn];
1578 
1579   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1580   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1581     yystate = yytable[yystate];
1582   else
1583     yystate = yydefgoto[yyn - YYNTOKENS];
1584 
1585   goto yynewstate;
1586 
1587 
1588 /*------------------------------------.
1589 | yyerrlab -- here on detecting error |
1590 `------------------------------------*/
1591 yyerrlab:
1592   /* If not already recovering from an error, report this error.  */
1593   if (!yyerrstatus)
1594     {
1595       ++yynerrs;
1596 #if ! YYERROR_VERBOSE
1597       yyerror (ctx, YY_("syntax error"));
1598 #else
1599       {
1600 	YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1601 	if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1602 	  {
1603 	    YYSIZE_T yyalloc = 2 * yysize;
1604 	    if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1605 	      yyalloc = YYSTACK_ALLOC_MAXIMUM;
1606 	    if (yymsg != yymsgbuf)
1607 	      YYSTACK_FREE (yymsg);
1608 	    yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1609 	    if (yymsg)
1610 	      yymsg_alloc = yyalloc;
1611 	    else
1612 	      {
1613 		yymsg = yymsgbuf;
1614 		yymsg_alloc = sizeof yymsgbuf;
1615 	      }
1616 	  }
1617 
1618 	if (0 < yysize && yysize <= yymsg_alloc)
1619 	  {
1620 	    (void) yysyntax_error (yymsg, yystate, yychar);
1621 	    yyerror (ctx, yymsg);
1622 	  }
1623 	else
1624 	  {
1625 	    yyerror (ctx, YY_("syntax error"));
1626 	    if (yysize != 0)
1627 	      goto yyexhaustedlab;
1628 	  }
1629       }
1630 #endif
1631     }
1632 
1633 
1634 
1635   if (yyerrstatus == 3)
1636     {
1637       /* If just tried and failed to reuse lookahead token after an
1638 	 error, discard it.  */
1639 
1640       if (yychar <= YYEOF)
1641 	{
1642 	  /* Return failure if at end of input.  */
1643 	  if (yychar == YYEOF)
1644 	    YYABORT;
1645 	}
1646       else
1647 	{
1648 	  yydestruct ("Error: discarding",
1649 		      yytoken, &yylval, ctx);
1650 	  yychar = YYEMPTY;
1651 	}
1652     }
1653 
1654   /* Else will try to reuse lookahead token after shifting the error
1655      token.  */
1656   goto yyerrlab1;
1657 
1658 
1659 /*---------------------------------------------------.
1660 | yyerrorlab -- error raised explicitly by YYERROR.  |
1661 `---------------------------------------------------*/
1662 yyerrorlab:
1663 
1664   /* Pacify compilers like GCC when the user code never invokes
1665      YYERROR and the label yyerrorlab therefore never appears in user
1666      code.  */
1667   if (/*CONSTCOND*/ 0)
1668      goto yyerrorlab;
1669 
1670   /* Do not reclaim the symbols of the rule which action triggered
1671      this YYERROR.  */
1672   YYPOPSTACK (yylen);
1673   yylen = 0;
1674   YY_STACK_PRINT (yyss, yyssp);
1675   yystate = *yyssp;
1676   goto yyerrlab1;
1677 
1678 
1679 /*-------------------------------------------------------------.
1680 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
1681 `-------------------------------------------------------------*/
1682 yyerrlab1:
1683   yyerrstatus = 3;	/* Each real token shifted decrements this.  */
1684 
1685   for (;;)
1686     {
1687       yyn = yypact[yystate];
1688       if (yyn != YYPACT_NINF)
1689 	{
1690 	  yyn += YYTERROR;
1691 	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1692 	    {
1693 	      yyn = yytable[yyn];
1694 	      if (0 < yyn)
1695 		break;
1696 	    }
1697 	}
1698 
1699       /* Pop the current state because it cannot handle the error token.  */
1700       if (yyssp == yyss)
1701 	YYABORT;
1702 
1703 
1704       yydestruct ("Error: popping",
1705 		  yystos[yystate], yyvsp, ctx);
1706       YYPOPSTACK (1);
1707       yystate = *yyssp;
1708       YY_STACK_PRINT (yyss, yyssp);
1709     }
1710 
1711   *++yyvsp = yylval;
1712 
1713 
1714   /* Shift the error token.  */
1715   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1716 
1717   yystate = yyn;
1718   goto yynewstate;
1719 
1720 
1721 /*-------------------------------------.
1722 | yyacceptlab -- YYACCEPT comes here.  |
1723 `-------------------------------------*/
1724 yyacceptlab:
1725   yyresult = 0;
1726   goto yyreturn;
1727 
1728 /*-----------------------------------.
1729 | yyabortlab -- YYABORT comes here.  |
1730 `-----------------------------------*/
1731 yyabortlab:
1732   yyresult = 1;
1733   goto yyreturn;
1734 
1735 #if !defined(yyoverflow) || YYERROR_VERBOSE
1736 /*-------------------------------------------------.
1737 | yyexhaustedlab -- memory exhaustion comes here.  |
1738 `-------------------------------------------------*/
1739 yyexhaustedlab:
1740   yyerror (ctx, YY_("memory exhausted"));
1741   yyresult = 2;
1742   /* Fall through.  */
1743 #endif
1744 
1745 yyreturn:
1746   if (yychar != YYEMPTY)
1747      yydestruct ("Cleanup: discarding lookahead",
1748 		 yytoken, &yylval, ctx);
1749   /* Do not reclaim the symbols of the rule which action triggered
1750      this YYABORT or YYACCEPT.  */
1751   YYPOPSTACK (yylen);
1752   YY_STACK_PRINT (yyss, yyssp);
1753   while (yyssp != yyss)
1754     {
1755       yydestruct ("Cleanup: popping",
1756 		  yystos[*yyssp], yyvsp, ctx);
1757       YYPOPSTACK (1);
1758     }
1759 #ifndef yyoverflow
1760   if (yyss != yyssa)
1761     YYSTACK_FREE (yyss);
1762 #endif
1763 #if YYERROR_VERBOSE
1764   if (yymsg != yymsgbuf)
1765     YYSTACK_FREE (yymsg);
1766 #endif
1767   /* Make sure YYID is used.  */
1768   return YYID (yyresult);
1769 }
1770 
1771 
1772 
1773 /* Line 1675 of yacc.c  */
1774 #line 203 "ktrfmt.y"
1775 
1776 
1777 void * __ktrfmt_scan_string(const char *);
1778 void __ktrfmt_delete_buffer(void *);
1779 
1780 void
1781 __ktrfmt_error (struct ktrfmt_parse_ctx *ctx, const char *s)
1782 {
1783 	(void)ctx;
1784 	fprintf(stderr, "%s\n", s);
1785 }
1786 
1787 int
1788 parse_string(evtr_event_t ev, struct symtab *symtab, const char *str)
1789 {
1790 	void *bufstate;
1791 	int ret;
1792 	struct ktrfmt_parse_ctx ctx;
1793 
1794 	printd(PARSE, "parsing \"%s\"\n", str);
1795 	ctx.ev = ev;
1796 	ctx.symtab = symtab;
1797 	bufstate = __ktrfmt_scan_string(str);
1798 	ret = __ktrfmt_parse(&ctx);
1799 	__ktrfmt_delete_buffer(bufstate);
1800 
1801 	return ret;
1802 }
1803 
1804 int
1805 parse_var(const char *str, struct symtab *symtab, struct evtr_variable **var)
1806 {
1807 	void *bufstate;
1808 	int ret;
1809 	struct ktrfmt_parse_ctx ctx;
1810 
1811 	ctx.ev = NULL;
1812 	ctx.symtab = symtab;
1813 	ctx.var = NULL;
1814 	bufstate = __ktrfmt_scan_string(str);
1815 	ret = __ktrfmt_parse(&ctx);
1816 	__ktrfmt_delete_buffer(bufstate);
1817 
1818 	*var = ctx.var;
1819 	return ret;
1820 }
1821 
1822