Linux Perf
expr-bison.c
Go to the documentation of this file.
1 /* A Bison parser, made by GNU Bison 3.0.4. */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5  Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
6 
7  This program is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 
20 /* As a special exception, you may create a larger work that contains
21  part or all of the Bison parser skeleton and distribute that work
22  under terms of your choice, so long as that work isn't itself a
23  parser generator using the skeleton or a modified version thereof
24  as a parser skeleton. Alternatively, if you modify or redistribute
25  the parser skeleton itself, you may (at your option) remove this
26  special exception, which will cause the skeleton and the resulting
27  Bison output files to be licensed under the GNU General Public
28  License without this special exception.
29 
30  This special exception was added by the Free Software Foundation in
31  version 2.2 of Bison. */
32 
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34  simplifying the original so-called "semantic" parser. */
35 
36 /* All symbols defined below should begin with yy or YY, to avoid
37  infringing on user name space. This should be done even for local
38  variables, as they might otherwise be expanded by user macros.
39  There are some unavoidable exceptions within include files to
40  define necessary library symbols; they are noted "INFRINGES ON
41  USER NAME SPACE" below. */
42 
43 /* Identify Bison output. */
44 #define YYBISON 1
45 
46 /* Bison version. */
47 #define YYBISON_VERSION "3.0.4"
48 
49 /* Skeleton name. */
50 #define YYSKELETON_NAME "yacc.c"
51 
52 /* Pure parsers. */
53 #define YYPURE 1
54 
55 /* Push parsers. */
56 #define YYPUSH 0
57 
58 /* Pull parsers. */
59 #define YYPULL 1
60 
61 
62 /* Substitute the variable and function names. */
63 #define yyparse expr__parse
64 #define yylex expr__lex
65 #define yyerror expr__error
66 #define yydebug expr__debug
67 #define yynerrs expr__nerrs
68 
69 
70 /* Copy the first part of user declarations. */
71 #line 2 "util/expr.y" /* yacc.c:339 */
72 
73 #include "util.h"
74 #include "util/debug.h"
75 #define IN_EXPR_Y 1
76 #include "expr.h"
77 #include <string.h>
78 
79 #define MAXIDLEN 256
80 
81 #line 82 "util/expr-bison.c" /* yacc.c:339 */
82 
83 # ifndef YY_NULLPTR
84 # if defined __cplusplus && 201103L <= __cplusplus
85 # define YY_NULLPTR nullptr
86 # else
87 # define YY_NULLPTR 0
88 # endif
89 # endif
90 
91 /* Enabling verbose error messages. */
92 #ifdef YYERROR_VERBOSE
93 # undef YYERROR_VERBOSE
94 # define YYERROR_VERBOSE 1
95 #else
96 # define YYERROR_VERBOSE 0
97 #endif
98 
99 /* In a future release of Bison, this section will be replaced
100  by #include "expr-bison.h". */
101 #ifndef YY_EXPR_UTIL_EXPR_BISON_H_INCLUDED
102 # define YY_EXPR_UTIL_EXPR_BISON_H_INCLUDED
103 /* Debug traces. */
104 #ifndef YYDEBUG
105 # define YYDEBUG 0
106 #endif
107 #if YYDEBUG
108 extern int expr__debug;
109 #endif
110 
111 /* Token type. */
112 #ifndef YYTOKENTYPE
113 # define YYTOKENTYPE
115  {
116  NUMBER = 258,
117  ID = 259,
118  NEG = 260,
119  NOT = 261
120  };
121 #endif
122 
123 /* Value type. */
124 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
125 
126 union YYSTYPE
127 {
128 #line 18 "util/expr.y" /* yacc.c:355 */
129 
130  double num;
131  char id[MAXIDLEN+1];
132 
133 #line 134 "util/expr-bison.c" /* yacc.c:355 */
134 };
135 
136 typedef union YYSTYPE YYSTYPE;
137 # define YYSTYPE_IS_TRIVIAL 1
138 # define YYSTYPE_IS_DECLARED 1
139 #endif
140 
141 
142 
143 int expr__parse (double *final_val, struct parse_ctx *ctx, const char **pp);
144 
145 #endif /* !YY_EXPR_UTIL_EXPR_BISON_H_INCLUDED */
146 
147 /* Copy the second part of user declarations. */
148 #line 33 "util/expr.y" /* yacc.c:358 */
149 
150 static int expr__lex(YYSTYPE *res, const char **pp);
151 
152 static void expr__error(double *final_val __maybe_unused,
153  struct parse_ctx *ctx __maybe_unused,
154  const char **pp __maybe_unused,
155  const char *s)
156 {
157  pr_debug("%s\n", s);
158 }
159 
160 static int lookup_id(struct parse_ctx *ctx, char *id, double *val)
161 {
162  int i;
163 
164  for (i = 0; i < ctx->num_ids; i++) {
165  if (!strcasecmp(ctx->ids[i].name, id)) {
166  *val = ctx->ids[i].val;
167  return 0;
168  }
169  }
170  return -1;
171 }
172 
173 
174 #line 175 "util/expr-bison.c" /* yacc.c:358 */
175 
176 #ifdef short
177 # undef short
178 #endif
179 
180 #ifdef YYTYPE_UINT8
181 typedef YYTYPE_UINT8 yytype_uint8;
182 #else
183 typedef unsigned char yytype_uint8;
184 #endif
185 
186 #ifdef YYTYPE_INT8
187 typedef YYTYPE_INT8 yytype_int8;
188 #else
189 typedef signed char yytype_int8;
190 #endif
191 
192 #ifdef YYTYPE_UINT16
193 typedef YYTYPE_UINT16 yytype_uint16;
194 #else
195 typedef unsigned short int yytype_uint16;
196 #endif
197 
198 #ifdef YYTYPE_INT16
199 typedef YYTYPE_INT16 yytype_int16;
200 #else
201 typedef short int yytype_int16;
202 #endif
203 
204 #ifndef YYSIZE_T
205 # ifdef __SIZE_TYPE__
206 # define YYSIZE_T __SIZE_TYPE__
207 # elif defined size_t
208 # define YYSIZE_T size_t
209 # elif ! defined YYSIZE_T
210 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
211 # define YYSIZE_T size_t
212 # else
213 # define YYSIZE_T unsigned int
214 # endif
215 #endif
216 
217 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
218 
219 #ifndef YY_
220 # if defined YYENABLE_NLS && YYENABLE_NLS
221 # if ENABLE_NLS
222 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
223 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
224 # endif
225 # endif
226 # ifndef YY_
227 # define YY_(Msgid) Msgid
228 # endif
229 #endif
230 
231 #ifndef YY_ATTRIBUTE
232 # if (defined __GNUC__ \
233  && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
234  || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
235 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
236 # else
237 # define YY_ATTRIBUTE(Spec) /* empty */
238 # endif
239 #endif
240 
241 #ifndef YY_ATTRIBUTE_PURE
242 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
243 #endif
244 
245 #ifndef YY_ATTRIBUTE_UNUSED
246 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
247 #endif
248 
249 #if !defined _Noreturn \
250  && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
251 # if defined _MSC_VER && 1200 <= _MSC_VER
252 # define _Noreturn __declspec (noreturn)
253 # else
254 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
255 # endif
256 #endif
257 
258 /* Suppress unused-variable warnings by "using" E. */
259 #if ! defined lint || defined __GNUC__
260 # define YYUSE(E) ((void) (E))
261 #else
262 # define YYUSE(E) /* empty */
263 #endif
264 
265 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
266 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
267 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
268  _Pragma ("GCC diagnostic push") \
269  _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
270  _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
271 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
272  _Pragma ("GCC diagnostic pop")
273 #else
274 # define YY_INITIAL_VALUE(Value) Value
275 #endif
276 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
277 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
278 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
279 #endif
280 #ifndef YY_INITIAL_VALUE
281 # define YY_INITIAL_VALUE(Value) /* Nothing. */
282 #endif
283 
284 
285 #if ! defined yyoverflow || YYERROR_VERBOSE
286 
287 /* The parser invokes alloca or malloc; define the necessary symbols. */
288 
289 # ifdef YYSTACK_USE_ALLOCA
290 # if YYSTACK_USE_ALLOCA
291 # ifdef __GNUC__
292 # define YYSTACK_ALLOC __builtin_alloca
293 # elif defined __BUILTIN_VA_ARG_INCR
294 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
295 # elif defined _AIX
296 # define YYSTACK_ALLOC __alloca
297 # elif defined _MSC_VER
298 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
299 # define alloca _alloca
300 # else
301 # define YYSTACK_ALLOC alloca
302 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
303 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
304  /* Use EXIT_SUCCESS as a witness for stdlib.h. */
305 # ifndef EXIT_SUCCESS
306 # define EXIT_SUCCESS 0
307 # endif
308 # endif
309 # endif
310 # endif
311 # endif
312 
313 # ifdef YYSTACK_ALLOC
314  /* Pacify GCC's 'empty if-body' warning. */
315 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
316 # ifndef YYSTACK_ALLOC_MAXIMUM
317  /* The OS might guarantee only one guard page at the bottom of the stack,
318  and a page size can be as small as 4096 bytes. So we cannot safely
319  invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
320  to allow for a few compiler-allocated temporary stack slots. */
321 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
322 # endif
323 # else
324 # define YYSTACK_ALLOC YYMALLOC
325 # define YYSTACK_FREE YYFREE
326 # ifndef YYSTACK_ALLOC_MAXIMUM
327 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
328 # endif
329 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
330  && ! ((defined YYMALLOC || defined malloc) \
331  && (defined YYFREE || defined free)))
332 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
333 # ifndef EXIT_SUCCESS
334 # define EXIT_SUCCESS 0
335 # endif
336 # endif
337 # ifndef YYMALLOC
338 # define YYMALLOC malloc
339 # if ! defined malloc && ! defined EXIT_SUCCESS
340 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
341 # endif
342 # endif
343 # ifndef YYFREE
344 # define YYFREE free
345 # if ! defined free && ! defined EXIT_SUCCESS
346 void free (void *); /* INFRINGES ON USER NAME SPACE */
347 # endif
348 # endif
349 # endif
350 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
351 
352 
353 #if (! defined yyoverflow \
354  && (! defined __cplusplus \
355  || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
356 
357 /* A type that is properly aligned for any stack member. */
358 union yyalloc
359 {
362 };
363 
364 /* The size of the maximum gap between one aligned stack and the next. */
365 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
366 
367 /* The size of an array large to enough to hold all stacks, each with
368  N elements. */
369 # define YYSTACK_BYTES(N) \
370  ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
371  + YYSTACK_GAP_MAXIMUM)
372 
373 # define YYCOPY_NEEDED 1
374 
375 /* Relocate STACK from its old location to the new one. The
376  local variables YYSIZE and YYSTACKSIZE give the old and new number of
377  elements in the stack, and YYPTR gives the new location of the
378  stack. Advance YYPTR to a properly aligned location for the next
379  stack. */
380 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
381  do \
382  { \
383  YYSIZE_T yynewbytes; \
384  YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
385  Stack = &yyptr->Stack_alloc; \
386  yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
387  yyptr += yynewbytes / sizeof (*yyptr); \
388  } \
389  while (0)
390 
391 #endif
392 
393 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
394 /* Copy COUNT objects from SRC to DST. The source and destination do
395  not overlap. */
396 # ifndef YYCOPY
397 # if defined __GNUC__ && 1 < __GNUC__
398 # define YYCOPY(Dst, Src, Count) \
399  __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
400 # else
401 # define YYCOPY(Dst, Src, Count) \
402  do \
403  { \
404  YYSIZE_T yyi; \
405  for (yyi = 0; yyi < (Count); yyi++) \
406  (Dst)[yyi] = (Src)[yyi]; \
407  } \
408  while (0)
409 # endif
410 # endif
411 #endif /* !YYCOPY_NEEDED */
412 
413 /* YYFINAL -- State number of the termination state. */
414 #define YYFINAL 9
415 /* YYLAST -- Last index in YYTABLE. */
416 #define YYLAST 31
417 
418 /* YYNTOKENS -- Number of terminals. */
419 #define YYNTOKENS 17
420 /* YYNNTS -- Number of nonterminals. */
421 #define YYNNTS 3
422 /* YYNRULES -- Number of rules. */
423 #define YYNRULES 11
424 /* YYNSTATES -- Number of states. */
425 #define YYNSTATES 21
426 
427 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
428  by yylex, with out-of-bounds checking. */
429 #define YYUNDEFTOK 2
430 #define YYMAXUTOK 261
431 
432 #define YYTRANSLATE(YYX) \
433  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
434 
435 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
436  as returned by yylex, without out-of-bounds checking. */
437 static const yytype_uint8 yytranslate[] =
438 {
439  0, 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, 12, 7, 2,
443  15, 16, 10, 9, 2, 8, 2, 11, 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, 6, 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, 5, 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, 2, 2, 2, 2,
464  2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
465  13, 14
466 };
467 
468 #if YYDEBUG
469  /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
470 static const yytype_uint8 yyrline[] =
471 {
472  0, 60, 60, 63, 64, 69, 70, 71, 72, 73,
473  74, 75
474 };
475 #endif
476 
477 #if YYDEBUG || YYERROR_VERBOSE || 0
478 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
479  First, the terminals, then, starting at YYNTOKENS, nonterminals. */
480 static const char *const yytname[] =
481 {
482  "$end", "error", "$undefined", "NUMBER", "ID", "'|'", "'^'", "'&'",
483  "'-'", "'+'", "'*'", "'/'", "'%'", "NEG", "NOT", "'('", "')'", "$accept",
484  "all_expr", "expr", YY_NULLPTR
485 };
486 #endif
487 
488 # ifdef YYPRINT
489 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
490  (internal) symbol number NUM (which must be that of a token). */
491 static const yytype_uint16 yytoknum[] =
492 {
493  0, 256, 257, 258, 259, 124, 94, 38, 45, 43,
494  42, 47, 37, 260, 261, 40, 41
495 };
496 # endif
497 
498 #define YYPACT_NINF -9
499 
500 #define yypact_value_is_default(Yystate) \
501  (!!((Yystate) == (-9)))
502 
503 #define YYTABLE_NINF -1
504 
505 #define yytable_value_is_error(Yytable_value) \
506  0
507 
508  /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
509  STATE-NUM. */
510 static const yytype_int8 yypact[] =
511 {
512  -3, -9, -9, -3, -3, 8, 19, -9, 10, -9,
513  -3, -3, -3, -3, -3, -9, -8, -8, -9, -9,
514  -9
515 };
516 
517  /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
518  Performed when YYTABLE does not specify something else to do. Zero
519  means the default is an error. */
520 static const yytype_uint8 yydefact[] =
521 {
522  0, 3, 4, 0, 0, 0, 2, 10, 0, 1,
523  0, 0, 0, 0, 0, 11, 6, 5, 7, 8,
524  9
525 };
526 
527  /* YYPGOTO[NTERM-NUM]. */
528 static const yytype_int8 yypgoto[] =
529 {
530  -9, -9, 3
531 };
532 
533  /* YYDEFGOTO[NTERM-NUM]. */
534 static const yytype_int8 yydefgoto[] =
535 {
536  -1, 5, 6
537 };
538 
539  /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
540  positive, shift that token. If negative, reduce the rule whose
541  number is the opposite. If YYTABLE_NINF, syntax error. */
542 static const yytype_uint8 yytable[] =
543 {
544  1, 2, 12, 13, 14, 3, 7, 8, 9, 0,
545  0, 0, 4, 16, 17, 18, 19, 20, 10, 11,
546  12, 13, 14, 0, 0, 0, 15, 10, 11, 12,
547  13, 14
548 };
549 
550 static const yytype_int8 yycheck[] =
551 {
552  3, 4, 10, 11, 12, 8, 3, 4, 0, -1,
553  -1, -1, 15, 10, 11, 12, 13, 14, 8, 9,
554  10, 11, 12, -1, -1, -1, 16, 8, 9, 10,
555  11, 12
556 };
557 
558  /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
559  symbol of state STATE-NUM. */
560 static const yytype_uint8 yystos[] =
561 {
562  0, 3, 4, 8, 15, 18, 19, 19, 19, 0,
563  8, 9, 10, 11, 12, 16, 19, 19, 19, 19,
564  19
565 };
566 
567  /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
568 static const yytype_uint8 yyr1[] =
569 {
570  0, 17, 18, 19, 19, 19, 19, 19, 19, 19,
571  19, 19
572 };
573 
574  /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
575 static const yytype_uint8 yyr2[] =
576 {
577  0, 2, 1, 1, 1, 3, 3, 3, 3, 3,
578  2, 3
579 };
580 
581 
582 #define yyerrok (yyerrstatus = 0)
583 #define yyclearin (yychar = YYEMPTY)
584 #define YYEMPTY (-2)
585 #define YYEOF 0
586 
587 #define YYACCEPT goto yyacceptlab
588 #define YYABORT goto yyabortlab
589 #define YYERROR goto yyerrorlab
590 
591 
592 #define YYRECOVERING() (!!yyerrstatus)
593 
594 #define YYBACKUP(Token, Value) \
595 do \
596  if (yychar == YYEMPTY) \
597  { \
598  yychar = (Token); \
599  yylval = (Value); \
600  YYPOPSTACK (yylen); \
601  yystate = *yyssp; \
602  goto yybackup; \
603  } \
604  else \
605  { \
606  yyerror (final_val, ctx, pp, YY_("syntax error: cannot back up")); \
607  YYERROR; \
608  } \
609 while (0)
610 
611 /* Error token number */
612 #define YYTERROR 1
613 #define YYERRCODE 256
614 
615 
616 
617 /* Enable debugging if requested. */
618 #if YYDEBUG
619 
620 # ifndef YYFPRINTF
621 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
622 # define YYFPRINTF fprintf
623 # endif
624 
625 # define YYDPRINTF(Args) \
626 do { \
627  if (yydebug) \
628  YYFPRINTF Args; \
629 } while (0)
630 
631 /* This macro is provided for backward compatibility. */
632 #ifndef YY_LOCATION_PRINT
633 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
634 #endif
635 
636 
637 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
638 do { \
639  if (yydebug) \
640  { \
641  YYFPRINTF (stderr, "%s ", Title); \
642  yy_symbol_print (stderr, \
643  Type, Value, final_val, ctx, pp); \
644  YYFPRINTF (stderr, "\n"); \
645  } \
646 } while (0)
647 
648 
649 /*----------------------------------------.
650 | Print this symbol's value on YYOUTPUT. |
651 `----------------------------------------*/
652 
653 static void
654 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, double *final_val, struct parse_ctx *ctx, const char **pp)
655 {
656  FILE *yyo = yyoutput;
657  YYUSE (yyo);
658  YYUSE (final_val);
659  YYUSE (ctx);
660  YYUSE (pp);
661  if (!yyvaluep)
662  return;
663 # ifdef YYPRINT
664  if (yytype < YYNTOKENS)
665  YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
666 # endif
667  YYUSE (yytype);
668 }
669 
670 
671 /*--------------------------------.
672 | Print this symbol on YYOUTPUT. |
673 `--------------------------------*/
674 
675 static void
676 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, double *final_val, struct parse_ctx *ctx, const char **pp)
677 {
678  YYFPRINTF (yyoutput, "%s %s (",
679  yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
680 
681  yy_symbol_value_print (yyoutput, yytype, yyvaluep, final_val, ctx, pp);
682  YYFPRINTF (yyoutput, ")");
683 }
684 
685 /*------------------------------------------------------------------.
686 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
687 | TOP (included). |
688 `------------------------------------------------------------------*/
689 
690 static void
691 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
692 {
693  YYFPRINTF (stderr, "Stack now");
694  for (; yybottom <= yytop; yybottom++)
695  {
696  int yybot = *yybottom;
697  YYFPRINTF (stderr, " %d", yybot);
698  }
699  YYFPRINTF (stderr, "\n");
700 }
701 
702 # define YY_STACK_PRINT(Bottom, Top) \
703 do { \
704  if (yydebug) \
705  yy_stack_print ((Bottom), (Top)); \
706 } while (0)
707 
708 
709 /*------------------------------------------------.
710 | Report that the YYRULE is going to be reduced. |
711 `------------------------------------------------*/
712 
713 static void
714 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, double *final_val, struct parse_ctx *ctx, const char **pp)
715 {
716  unsigned long int yylno = yyrline[yyrule];
717  int yynrhs = yyr2[yyrule];
718  int yyi;
719  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
720  yyrule - 1, yylno);
721  /* The symbols being reduced. */
722  for (yyi = 0; yyi < yynrhs; yyi++)
723  {
724  YYFPRINTF (stderr, " $%d = ", yyi + 1);
725  yy_symbol_print (stderr,
726  yystos[yyssp[yyi + 1 - yynrhs]],
727  &(yyvsp[(yyi + 1) - (yynrhs)])
728  , final_val, ctx, pp);
729  YYFPRINTF (stderr, "\n");
730  }
731 }
732 
733 # define YY_REDUCE_PRINT(Rule) \
734 do { \
735  if (yydebug) \
736  yy_reduce_print (yyssp, yyvsp, Rule, final_val, ctx, pp); \
737 } while (0)
738 
739 /* Nonzero means print parse trace. It is left uninitialized so that
740  multiple parsers can coexist. */
741 int yydebug;
742 #else /* !YYDEBUG */
743 # define YYDPRINTF(Args)
744 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
745 # define YY_STACK_PRINT(Bottom, Top)
746 # define YY_REDUCE_PRINT(Rule)
747 #endif /* !YYDEBUG */
748 
749 
750 /* YYINITDEPTH -- initial size of the parser's stacks. */
751 #ifndef YYINITDEPTH
752 # define YYINITDEPTH 200
753 #endif
754 
755 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
756  if the built-in stack extension method is used).
757 
758  Do not make this value too large; the results are undefined if
759  YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
760  evaluated with infinite-precision integer arithmetic. */
761 
762 #ifndef YYMAXDEPTH
763 # define YYMAXDEPTH 10000
764 #endif
765 
766 
767 #if YYERROR_VERBOSE
768 
769 # ifndef yystrlen
770 # if defined __GLIBC__ && defined _STRING_H
771 # define yystrlen strlen
772 # else
773 /* Return the length of YYSTR. */
774 static YYSIZE_T
775 yystrlen (const char *yystr)
776 {
777  YYSIZE_T yylen;
778  for (yylen = 0; yystr[yylen]; yylen++)
779  continue;
780  return yylen;
781 }
782 # endif
783 # endif
784 
785 # ifndef yystpcpy
786 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
787 # define yystpcpy stpcpy
788 # else
789 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
790  YYDEST. */
791 static char *
792 yystpcpy (char *yydest, const char *yysrc)
793 {
794  char *yyd = yydest;
795  const char *yys = yysrc;
796 
797  while ((*yyd++ = *yys++) != '\0')
798  continue;
799 
800  return yyd - 1;
801 }
802 # endif
803 # endif
804 
805 # ifndef yytnamerr
806 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
807  quotes and backslashes, so that it's suitable for yyerror. The
808  heuristic is that double-quoting is unnecessary unless the string
809  contains an apostrophe, a comma, or backslash (other than
810  backslash-backslash). YYSTR is taken from yytname. If YYRES is
811  null, do not copy; instead, return the length of what the result
812  would have been. */
813 static YYSIZE_T
814 yytnamerr (char *yyres, const char *yystr)
815 {
816  if (*yystr == '"')
817  {
818  YYSIZE_T yyn = 0;
819  char const *yyp = yystr;
820 
821  for (;;)
822  switch (*++yyp)
823  {
824  case '\'':
825  case ',':
826  goto do_not_strip_quotes;
827 
828  case '\\':
829  if (*++yyp != '\\')
830  goto do_not_strip_quotes;
831  /* Fall through. */
832  default:
833  if (yyres)
834  yyres[yyn] = *yyp;
835  yyn++;
836  break;
837 
838  case '"':
839  if (yyres)
840  yyres[yyn] = '\0';
841  return yyn;
842  }
843  do_not_strip_quotes: ;
844  }
845 
846  if (! yyres)
847  return yystrlen (yystr);
848 
849  return yystpcpy (yyres, yystr) - yyres;
850 }
851 # endif
852 
853 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
854  about the unexpected token YYTOKEN for the state stack whose top is
855  YYSSP.
856 
857  Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
858  not large enough to hold the message. In that case, also set
859  *YYMSG_ALLOC to the required number of bytes. Return 2 if the
860  required number of bytes is too large to store. */
861 static int
862 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
863  yytype_int16 *yyssp, int yytoken)
864 {
865  YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
866  YYSIZE_T yysize = yysize0;
867  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
868  /* Internationalized format string. */
869  const char *yyformat = YY_NULLPTR;
870  /* Arguments of yyformat. */
871  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
872  /* Number of reported tokens (one for the "unexpected", one per
873  "expected"). */
874  int yycount = 0;
875 
876  /* There are many possibilities here to consider:
877  - If this state is a consistent state with a default action, then
878  the only way this function was invoked is if the default action
879  is an error action. In that case, don't check for expected
880  tokens because there are none.
881  - The only way there can be no lookahead present (in yychar) is if
882  this state is a consistent state with a default action. Thus,
883  detecting the absence of a lookahead is sufficient to determine
884  that there is no unexpected or expected token to report. In that
885  case, just report a simple "syntax error".
886  - Don't assume there isn't a lookahead just because this state is a
887  consistent state with a default action. There might have been a
888  previous inconsistent state, consistent state with a non-default
889  action, or user semantic action that manipulated yychar.
890  - Of course, the expected token list depends on states to have
891  correct lookahead information, and it depends on the parser not
892  to perform extra reductions after fetching a lookahead from the
893  scanner and before detecting a syntax error. Thus, state merging
894  (from LALR or IELR) and default reductions corrupt the expected
895  token list. However, the list is correct for canonical LR with
896  one exception: it will still contain any token that will not be
897  accepted due to an error action in a later state.
898  */
899  if (yytoken != YYEMPTY)
900  {
901  int yyn = yypact[*yyssp];
902  yyarg[yycount++] = yytname[yytoken];
903  if (!yypact_value_is_default (yyn))
904  {
905  /* Start YYX at -YYN if negative to avoid negative indexes in
906  YYCHECK. In other words, skip the first -YYN actions for
907  this state because they are default actions. */
908  int yyxbegin = yyn < 0 ? -yyn : 0;
909  /* Stay within bounds of both yycheck and yytname. */
910  int yychecklim = YYLAST - yyn + 1;
911  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
912  int yyx;
913 
914  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
915  if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
916  && !yytable_value_is_error (yytable[yyx + yyn]))
917  {
918  if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
919  {
920  yycount = 1;
921  yysize = yysize0;
922  break;
923  }
924  yyarg[yycount++] = yytname[yyx];
925  {
926  YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
927  if (! (yysize <= yysize1
928  && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
929  return 2;
930  yysize = yysize1;
931  }
932  }
933  }
934  }
935 
936  switch (yycount)
937  {
938 # define YYCASE_(N, S) \
939  case N: \
940  yyformat = S; \
941  break
942  YYCASE_(0, YY_("syntax error"));
943  YYCASE_(1, YY_("syntax error, unexpected %s"));
944  YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
945  YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
946  YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
947  YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
948 # undef YYCASE_
949  }
950 
951  {
952  YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
953  if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
954  return 2;
955  yysize = yysize1;
956  }
957 
958  if (*yymsg_alloc < yysize)
959  {
960  *yymsg_alloc = 2 * yysize;
961  if (! (yysize <= *yymsg_alloc
962  && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
963  *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
964  return 1;
965  }
966 
967  /* Avoid sprintf, as that infringes on the user's name space.
968  Don't have undefined behavior even if the translation
969  produced a string with the wrong number of "%s"s. */
970  {
971  char *yyp = *yymsg;
972  int yyi = 0;
973  while ((*yyp = *yyformat) != '\0')
974  if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
975  {
976  yyp += yytnamerr (yyp, yyarg[yyi++]);
977  yyformat += 2;
978  }
979  else
980  {
981  yyp++;
982  yyformat++;
983  }
984  }
985  return 0;
986 }
987 #endif /* YYERROR_VERBOSE */
988 
989 /*-----------------------------------------------.
990 | Release the memory associated to this symbol. |
991 `-----------------------------------------------*/
992 
993 static void
994 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, double *final_val, struct parse_ctx *ctx, const char **pp)
995 {
996  YYUSE (yyvaluep);
997  YYUSE (final_val);
998  YYUSE (ctx);
999  YYUSE (pp);
1000  if (!yymsg)
1001  yymsg = "Deleting";
1002  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1003 
1005  YYUSE (yytype);
1007 }
1008 
1009 
1010 
1011 
1012 /*----------.
1013 | yyparse. |
1014 `----------*/
1015 
1016 int
1017 yyparse (double *final_val, struct parse_ctx *ctx, const char **pp)
1018 {
1019 /* The lookahead symbol. */
1020 int yychar;
1021 
1022 
1023 /* The semantic value of the lookahead symbol. */
1024 /* Default value used for initialization, for pacifying older GCCs
1025  or non-GCC compilers. */
1026 YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1027 YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1028 
1029  /* Number of syntax errors so far. */
1030  int yynerrs;
1031 
1032  int yystate;
1033  /* Number of tokens to shift before error messages enabled. */
1034  int yyerrstatus;
1035 
1036  /* The stacks and their tools:
1037  'yyss': related to states.
1038  'yyvs': related to semantic values.
1039 
1040  Refer to the stacks through separate pointers, to allow yyoverflow
1041  to reallocate them elsewhere. */
1042 
1043  /* The state stack. */
1044  yytype_int16 yyssa[YYINITDEPTH];
1045  yytype_int16 *yyss;
1046  yytype_int16 *yyssp;
1047 
1048  /* The semantic value stack. */
1049  YYSTYPE yyvsa[YYINITDEPTH];
1050  YYSTYPE *yyvs;
1051  YYSTYPE *yyvsp;
1052 
1053  YYSIZE_T yystacksize;
1054 
1055  int yyn;
1056  int yyresult;
1057  /* Lookahead token as an internal (translated) token number. */
1058  int yytoken = 0;
1059  /* The variables used to return semantic value and location from the
1060  action routines. */
1061  YYSTYPE yyval;
1062 
1063 #if YYERROR_VERBOSE
1064  /* Buffer for error messages, and its allocated size. */
1065  char yymsgbuf[128];
1066  char *yymsg = yymsgbuf;
1067  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1068 #endif
1069 
1070 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1071 
1072  /* The number of symbols on the RHS of the reduced rule.
1073  Keep to zero when no symbol should be popped. */
1074  int yylen = 0;
1075 
1076  yyssp = yyss = yyssa;
1077  yyvsp = yyvs = yyvsa;
1078  yystacksize = YYINITDEPTH;
1079 
1080  YYDPRINTF ((stderr, "Starting parse\n"));
1081 
1082  yystate = 0;
1083  yyerrstatus = 0;
1084  yynerrs = 0;
1085  yychar = YYEMPTY; /* Cause a token to be read. */
1086  goto yysetstate;
1087 
1088 /*------------------------------------------------------------.
1089 | yynewstate -- Push a new state, which is found in yystate. |
1090 `------------------------------------------------------------*/
1091  yynewstate:
1092  /* In all cases, when you get here, the value and location stacks
1093  have just been pushed. So pushing a state here evens the stacks. */
1094  yyssp++;
1095 
1096  yysetstate:
1097  *yyssp = yystate;
1098 
1099  if (yyss + yystacksize - 1 <= yyssp)
1100  {
1101  /* Get the current used size of the three stacks, in elements. */
1102  YYSIZE_T yysize = yyssp - yyss + 1;
1103 
1104 #ifdef yyoverflow
1105  {
1106  /* Give user a chance to reallocate the stack. Use copies of
1107  these so that the &'s don't force the real ones into
1108  memory. */
1109  YYSTYPE *yyvs1 = yyvs;
1110  yytype_int16 *yyss1 = yyss;
1111 
1112  /* Each stack pointer address is followed by the size of the
1113  data in use in that stack, in bytes. This used to be a
1114  conditional around just the two extra args, but that might
1115  be undefined if yyoverflow is a macro. */
1116  yyoverflow (YY_("memory exhausted"),
1117  &yyss1, yysize * sizeof (*yyssp),
1118  &yyvs1, yysize * sizeof (*yyvsp),
1119  &yystacksize);
1120 
1121  yyss = yyss1;
1122  yyvs = yyvs1;
1123  }
1124 #else /* no yyoverflow */
1125 # ifndef YYSTACK_RELOCATE
1126  goto yyexhaustedlab;
1127 # else
1128  /* Extend the stack our own way. */
1129  if (YYMAXDEPTH <= yystacksize)
1130  goto yyexhaustedlab;
1131  yystacksize *= 2;
1132  if (YYMAXDEPTH < yystacksize)
1133  yystacksize = YYMAXDEPTH;
1134 
1135  {
1136  yytype_int16 *yyss1 = yyss;
1137  union yyalloc *yyptr =
1138  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1139  if (! yyptr)
1140  goto yyexhaustedlab;
1141  YYSTACK_RELOCATE (yyss_alloc, yyss);
1142  YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1143 # undef YYSTACK_RELOCATE
1144  if (yyss1 != yyssa)
1145  YYSTACK_FREE (yyss1);
1146  }
1147 # endif
1148 #endif /* no yyoverflow */
1149 
1150  yyssp = yyss + yysize - 1;
1151  yyvsp = yyvs + yysize - 1;
1152 
1153  YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1154  (unsigned long int) yystacksize));
1155 
1156  if (yyss + yystacksize - 1 <= yyssp)
1157  YYABORT;
1158  }
1159 
1160  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1161 
1162  if (yystate == YYFINAL)
1163  YYACCEPT;
1164 
1165  goto yybackup;
1166 
1167 /*-----------.
1168 | yybackup. |
1169 `-----------*/
1170 yybackup:
1171 
1172  /* Do appropriate processing given the current state. Read a
1173  lookahead token if we need one and don't already have one. */
1174 
1175  /* First try to decide what to do without reference to lookahead token. */
1176  yyn = yypact[yystate];
1177  if (yypact_value_is_default (yyn))
1178  goto yydefault;
1179 
1180  /* Not known => get a lookahead token if don't already have one. */
1181 
1182  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1183  if (yychar == YYEMPTY)
1184  {
1185  YYDPRINTF ((stderr, "Reading a token: "));
1186  yychar = yylex (&yylval, pp);
1187  }
1188 
1189  if (yychar <= YYEOF)
1190  {
1191  yychar = yytoken = YYEOF;
1192  YYDPRINTF ((stderr, "Now at end of input.\n"));
1193  }
1194  else
1195  {
1196  yytoken = YYTRANSLATE (yychar);
1197  YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1198  }
1199 
1200  /* If the proper action on seeing token YYTOKEN is to reduce or to
1201  detect an error, take that action. */
1202  yyn += yytoken;
1203  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1204  goto yydefault;
1205  yyn = yytable[yyn];
1206  if (yyn <= 0)
1207  {
1208  if (yytable_value_is_error (yyn))
1209  goto yyerrlab;
1210  yyn = -yyn;
1211  goto yyreduce;
1212  }
1213 
1214  /* Count tokens shifted since error; after three, turn off error
1215  status. */
1216  if (yyerrstatus)
1217  yyerrstatus--;
1218 
1219  /* Shift the lookahead token. */
1220  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1221 
1222  /* Discard the shifted token. */
1223  yychar = YYEMPTY;
1224 
1225  yystate = yyn;
1227  *++yyvsp = yylval;
1229 
1230  goto yynewstate;
1231 
1232 
1233 /*-----------------------------------------------------------.
1234 | yydefault -- do the default action for the current state. |
1235 `-----------------------------------------------------------*/
1236 yydefault:
1237  yyn = yydefact[yystate];
1238  if (yyn == 0)
1239  goto yyerrlab;
1240  goto yyreduce;
1241 
1242 
1243 /*-----------------------------.
1244 | yyreduce -- Do a reduction. |
1245 `-----------------------------*/
1246 yyreduce:
1247  /* yyn is the number of a rule to reduce with. */
1248  yylen = yyr2[yyn];
1249 
1250  /* If YYLEN is nonzero, implement the default value of the action:
1251  '$$ = $1'.
1252 
1253  Otherwise, the following line sets YYVAL to garbage.
1254  This behavior is undocumented and Bison
1255  users should not rely upon it. Assigning to YYVAL
1256  unconditionally makes the parser a bit smaller, and it avoids a
1257  GCC warning that YYVAL may be used uninitialized. */
1258  yyval = yyvsp[1-yylen];
1259 
1260 
1261  YY_REDUCE_PRINT (yyn);
1262  switch (yyn)
1263  {
1264  case 2:
1265 #line 60 "util/expr.y" /* yacc.c:1646 */
1266  { *final_val = (yyvsp[0].num); }
1267 #line 1268 "util/expr-bison.c" /* yacc.c:1646 */
1268  break;
1269 
1270  case 4:
1271 #line 64 "util/expr.y" /* yacc.c:1646 */
1272  { if (lookup_id(ctx, (yyvsp[0].id), &(yyval.num)) < 0) {
1273  pr_debug("%s not found", (yyvsp[0].id));
1274  YYABORT;
1275  }
1276  }
1277 #line 1278 "util/expr-bison.c" /* yacc.c:1646 */
1278  break;
1279 
1280  case 5:
1281 #line 69 "util/expr.y" /* yacc.c:1646 */
1282  { (yyval.num) = (yyvsp[-2].num) + (yyvsp[0].num); }
1283 #line 1284 "util/expr-bison.c" /* yacc.c:1646 */
1284  break;
1285 
1286  case 6:
1287 #line 70 "util/expr.y" /* yacc.c:1646 */
1288  { (yyval.num) = (yyvsp[-2].num) - (yyvsp[0].num); }
1289 #line 1290 "util/expr-bison.c" /* yacc.c:1646 */
1290  break;
1291 
1292  case 7:
1293 #line 71 "util/expr.y" /* yacc.c:1646 */
1294  { (yyval.num) = (yyvsp[-2].num) * (yyvsp[0].num); }
1295 #line 1296 "util/expr-bison.c" /* yacc.c:1646 */
1296  break;
1297 
1298  case 8:
1299 #line 72 "util/expr.y" /* yacc.c:1646 */
1300  { if ((yyvsp[0].num) == 0) YYABORT; (yyval.num) = (yyvsp[-2].num) / (yyvsp[0].num); }
1301 #line 1302 "util/expr-bison.c" /* yacc.c:1646 */
1302  break;
1303 
1304  case 9:
1305 #line 73 "util/expr.y" /* yacc.c:1646 */
1306  { if ((long)(yyvsp[0].num) == 0) YYABORT; (yyval.num) = (long)(yyvsp[-2].num) % (long)(yyvsp[0].num); }
1307 #line 1308 "util/expr-bison.c" /* yacc.c:1646 */
1308  break;
1309 
1310  case 10:
1311 #line 74 "util/expr.y" /* yacc.c:1646 */
1312  { (yyval.num) = -(yyvsp[0].num); }
1313 #line 1314 "util/expr-bison.c" /* yacc.c:1646 */
1314  break;
1315 
1316  case 11:
1317 #line 75 "util/expr.y" /* yacc.c:1646 */
1318  { (yyval.num) = (yyvsp[-1].num); }
1319 #line 1320 "util/expr-bison.c" /* yacc.c:1646 */
1320  break;
1321 
1322 
1323 #line 1324 "util/expr-bison.c" /* yacc.c:1646 */
1324  default: break;
1325  }
1326  /* User semantic actions sometimes alter yychar, and that requires
1327  that yytoken be updated with the new translation. We take the
1328  approach of translating immediately before every use of yytoken.
1329  One alternative is translating here after every semantic action,
1330  but that translation would be missed if the semantic action invokes
1331  YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1332  if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1333  incorrect destructor might then be invoked immediately. In the
1334  case of YYERROR or YYBACKUP, subsequent parser actions might lead
1335  to an incorrect destructor call or verbose syntax error message
1336  before the lookahead is translated. */
1337  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1338 
1339  YYPOPSTACK (yylen);
1340  yylen = 0;
1341  YY_STACK_PRINT (yyss, yyssp);
1342 
1343  *++yyvsp = yyval;
1344 
1345  /* Now 'shift' the result of the reduction. Determine what state
1346  that goes to, based on the state we popped back to and the rule
1347  number reduced by. */
1348 
1349  yyn = yyr1[yyn];
1350 
1351  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1352  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1353  yystate = yytable[yystate];
1354  else
1355  yystate = yydefgoto[yyn - YYNTOKENS];
1356 
1357  goto yynewstate;
1358 
1359 
1360 /*--------------------------------------.
1361 | yyerrlab -- here on detecting error. |
1362 `--------------------------------------*/
1363 yyerrlab:
1364  /* Make sure we have latest lookahead translation. See comments at
1365  user semantic actions for why this is necessary. */
1366  yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1367 
1368  /* If not already recovering from an error, report this error. */
1369  if (!yyerrstatus)
1370  {
1371  ++yynerrs;
1372 #if ! YYERROR_VERBOSE
1373  yyerror (final_val, ctx, pp, YY_("syntax error"));
1374 #else
1375 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1376  yyssp, yytoken)
1377  {
1378  char const *yymsgp = YY_("syntax error");
1379  int yysyntax_error_status;
1380  yysyntax_error_status = YYSYNTAX_ERROR;
1381  if (yysyntax_error_status == 0)
1382  yymsgp = yymsg;
1383  else if (yysyntax_error_status == 1)
1384  {
1385  if (yymsg != yymsgbuf)
1386  YYSTACK_FREE (yymsg);
1387  yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1388  if (!yymsg)
1389  {
1390  yymsg = yymsgbuf;
1391  yymsg_alloc = sizeof yymsgbuf;
1392  yysyntax_error_status = 2;
1393  }
1394  else
1395  {
1396  yysyntax_error_status = YYSYNTAX_ERROR;
1397  yymsgp = yymsg;
1398  }
1399  }
1400  yyerror (final_val, ctx, pp, yymsgp);
1401  if (yysyntax_error_status == 2)
1402  goto yyexhaustedlab;
1403  }
1404 # undef YYSYNTAX_ERROR
1405 #endif
1406  }
1407 
1408 
1409 
1410  if (yyerrstatus == 3)
1411  {
1412  /* If just tried and failed to reuse lookahead token after an
1413  error, discard it. */
1414 
1415  if (yychar <= YYEOF)
1416  {
1417  /* Return failure if at end of input. */
1418  if (yychar == YYEOF)
1419  YYABORT;
1420  }
1421  else
1422  {
1423  yydestruct ("Error: discarding",
1424  yytoken, &yylval, final_val, ctx, pp);
1425  yychar = YYEMPTY;
1426  }
1427  }
1428 
1429  /* Else will try to reuse lookahead token after shifting the error
1430  token. */
1431  goto yyerrlab1;
1432 
1433 
1434 /*---------------------------------------------------.
1435 | yyerrorlab -- error raised explicitly by YYERROR. |
1436 `---------------------------------------------------*/
1437 yyerrorlab:
1438 
1439  /* Pacify compilers like GCC when the user code never invokes
1440  YYERROR and the label yyerrorlab therefore never appears in user
1441  code. */
1442  if (/*CONSTCOND*/ 0)
1443  goto yyerrorlab;
1444 
1445  /* Do not reclaim the symbols of the rule whose action triggered
1446  this YYERROR. */
1447  YYPOPSTACK (yylen);
1448  yylen = 0;
1449  YY_STACK_PRINT (yyss, yyssp);
1450  yystate = *yyssp;
1451  goto yyerrlab1;
1452 
1453 
1454 /*-------------------------------------------------------------.
1455 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1456 `-------------------------------------------------------------*/
1457 yyerrlab1:
1458  yyerrstatus = 3; /* Each real token shifted decrements this. */
1459 
1460  for (;;)
1461  {
1462  yyn = yypact[yystate];
1463  if (!yypact_value_is_default (yyn))
1464  {
1465  yyn += YYTERROR;
1466  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1467  {
1468  yyn = yytable[yyn];
1469  if (0 < yyn)
1470  break;
1471  }
1472  }
1473 
1474  /* Pop the current state because it cannot handle the error token. */
1475  if (yyssp == yyss)
1476  YYABORT;
1477 
1478 
1479  yydestruct ("Error: popping",
1480  yystos[yystate], yyvsp, final_val, ctx, pp);
1481  YYPOPSTACK (1);
1482  yystate = *yyssp;
1483  YY_STACK_PRINT (yyss, yyssp);
1484  }
1485 
1487  *++yyvsp = yylval;
1489 
1490 
1491  /* Shift the error token. */
1492  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1493 
1494  yystate = yyn;
1495  goto yynewstate;
1496 
1497 
1498 /*-------------------------------------.
1499 | yyacceptlab -- YYACCEPT comes here. |
1500 `-------------------------------------*/
1501 yyacceptlab:
1502  yyresult = 0;
1503  goto yyreturn;
1504 
1505 /*-----------------------------------.
1506 | yyabortlab -- YYABORT comes here. |
1507 `-----------------------------------*/
1508 yyabortlab:
1509  yyresult = 1;
1510  goto yyreturn;
1511 
1512 #if !defined yyoverflow || YYERROR_VERBOSE
1513 /*-------------------------------------------------.
1514 | yyexhaustedlab -- memory exhaustion comes here. |
1515 `-------------------------------------------------*/
1516 yyexhaustedlab:
1517  yyerror (final_val, ctx, pp, YY_("memory exhausted"));
1518  yyresult = 2;
1519  /* Fall through. */
1520 #endif
1521 
1522 yyreturn:
1523  if (yychar != YYEMPTY)
1524  {
1525  /* Make sure we have latest lookahead translation. See comments at
1526  user semantic actions for why this is necessary. */
1527  yytoken = YYTRANSLATE (yychar);
1528  yydestruct ("Cleanup: discarding lookahead",
1529  yytoken, &yylval, final_val, ctx, pp);
1530  }
1531  /* Do not reclaim the symbols of the rule whose action triggered
1532  this YYABORT or YYACCEPT. */
1533  YYPOPSTACK (yylen);
1534  YY_STACK_PRINT (yyss, yyssp);
1535  while (yyssp != yyss)
1536  {
1537  yydestruct ("Cleanup: popping",
1538  yystos[*yyssp], yyvsp, final_val, ctx, pp);
1539  YYPOPSTACK (1);
1540  }
1541 #ifndef yyoverflow
1542  if (yyss != yyssa)
1543  YYSTACK_FREE (yyss);
1544 #endif
1545 #if YYERROR_VERBOSE
1546  if (yymsg != yymsgbuf)
1547  YYSTACK_FREE (yymsg);
1548 #endif
1549  return yyresult;
1550 }
1551 #line 78 "util/expr.y" /* yacc.c:1906 */
1552 
1553 
1554 static int expr__symbol(YYSTYPE *res, const char *p, const char **pp)
1555 {
1556  char *dst = res->id;
1557  const char *s = p;
1558 
1559  while (isalnum(*p) || *p == '_' || *p == '.') {
1560  if (p - s >= MAXIDLEN)
1561  return -1;
1562  *dst++ = *p++;
1563  }
1564  *dst = 0;
1565  *pp = p;
1566  return ID;
1567 }
1568 
1569 static int expr__lex(YYSTYPE *res, const char **pp)
1570 {
1571  int tok;
1572  const char *s;
1573  const char *p = *pp;
1574 
1575  while (isspace(*p))
1576  p++;
1577  s = p;
1578  switch (*p++) {
1579  case 'a' ... 'z':
1580  case 'A' ... 'Z':
1581  return expr__symbol(res, p - 1, pp);
1582  case '0' ... '9': case '.':
1583  res->num = strtod(s, (char **)&p);
1584  tok = NUMBER;
1585  break;
1586  default:
1587  tok = *s;
1588  break;
1589  }
1590  *pp = p;
1591  return tok;
1592 }
1593 
1594 /* Caller must make sure id is allocated */
1595 void expr__add_id(struct parse_ctx *ctx, const char *name, double val)
1596 {
1597  int idx;
1598  assert(ctx->num_ids < MAX_PARSE_ID);
1599  idx = ctx->num_ids++;
1600  ctx->ids[idx].name = name;
1601  ctx->ids[idx].val = val;
1602 }
1603 
1604 void expr__ctx_init(struct parse_ctx *ctx)
1605 {
1606  ctx->num_ids = 0;
1607 }
1608 
1609 int expr__find_other(const char *p, const char *one, const char ***other,
1610  int *num_otherp)
1611 {
1612  const char *orig = p;
1613  int err = -1;
1614  int num_other;
1615 
1616  *other = malloc((EXPR_MAX_OTHER + 1) * sizeof(char *));
1617  if (!*other)
1618  return -1;
1619 
1620  num_other = 0;
1621  for (;;) {
1622  YYSTYPE val;
1623  int tok = expr__lex(&val, &p);
1624  if (tok == 0) {
1625  err = 0;
1626  break;
1627  }
1628  if (tok == ID && strcasecmp(one, val.id)) {
1629  if (num_other >= EXPR_MAX_OTHER - 1) {
1630  pr_debug("Too many extra events in %s\n", orig);
1631  break;
1632  }
1633  (*other)[num_other] = strdup(val.id);
1634  if (!(*other)[num_other])
1635  return -1;
1636  num_other++;
1637  }
1638  }
1639  (*other)[num_other] = NULL;
1640  *num_otherp = num_other;
1641  if (err) {
1642  *num_otherp = 0;
1643  free(*other);
1644  *other = NULL;
1645  }
1646  return err;
1647 }
#define isalnum(x)
Definition: sane_ctype.h:38
signed char yytype_int8
Definition: expr-bison.c:189
#define YYTERROR
Definition: expr-bison.c:612
static const yytype_uint8 yytranslate[]
Definition: expr-bison.c:437
#define yylex
Definition: expr-bison.c:64
struct parse_id ids[MAX_PARSE_ID]
Definition: expr.h:15
static const yytype_uint8 yystos[]
Definition: expr-bison.c:560
Definition: expr-bison.c:117
#define isspace(x)
Definition: sane_ctype.h:33
#define YYNTOKENS
Definition: expr-bison.c:419
#define YYSTACK_ALLOC
Definition: expr-bison.c:324
int int err
Definition: 5sec.c:44
#define YY_SYMBOL_PRINT(Title, Type, Value, Location)
Definition: expr-bison.c:744
unsigned short int yytype_uint16
Definition: expr-bison.c:195
#define YYFINAL
Definition: expr-bison.c:414
int yychar
Definition: pmu-bison.c:991
#define MAX_PARSE_ID
Definition: expr.h:6
static void yy_reduce_print(yytype_int16 *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, void *_data, void *scanner)
static void yy_symbol_print(FILE *yyoutput, int yytype, YYSTYPE const *const yyvaluep, YYLTYPE const *const yylocationp, void *_data, void *scanner)
static const yytype_int8 yypgoto[]
Definition: expr-bison.c:528
static void yydestruct(const char *yymsg, int yytype, YYSTYPE *yyvaluep, double *final_val, struct parse_ctx *ctx, const char **pp)
Definition: expr-bison.c:994
#define YYEOF
Definition: expr-bison.c:585
void expr__ctx_init(struct parse_ctx *ctx)
Definition: expr-bison.c:1604
static const yytype_uint8 yydefact[]
Definition: expr-bison.c:520
Definition: expr.h:13
void * malloc(YYSIZE_T)
unsigned char yytype_uint8
Definition: expr-bison.c:183
static int lookup_id(struct parse_ctx *ctx, char *id, double *val)
Definition: expr-bison.c:160
static const yytype_int8 yycheck[]
Definition: expr-bison.c:550
const char * name
char id[MAXIDLEN+1]
Definition: expr-bison.c:131
#define YYSIZE_T
Definition: expr-bison.c:211
#define yyparse
Definition: expr-bison.c:63
#define YYEMPTY
Definition: expr-bison.c:584
#define pr_debug(fmt,...)
Definition: json.h:27
#define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
Definition: expr-bison.c:277
#define EXPR_MAX_OTHER
Definition: expr.h:5
static const yytype_uint8 yytable[]
Definition: expr-bison.c:542
static const yytype_int8 yypact[]
Definition: expr-bison.c:510
#define yydebug
Definition: expr-bison.c:66
static const yytype_uint8 yyr2[]
Definition: expr-bison.c:575
yytype_int16 yyss_alloc
Definition: expr-bison.c:360
#define YYACCEPT
Definition: expr-bison.c:587
#define MAXIDLEN
Definition: expr-bison.c:79
#define YY_(Msgid)
Definition: expr-bison.c:227
#define YYSTACK_FREE
Definition: expr-bison.c:325
#define yynerrs
Definition: expr-bison.c:67
YYSTYPE yyvs_alloc
Definition: expr-bison.c:361
static void yy_symbol_value_print(FILE *yyoutput, int yytype, YYSTYPE const *const yyvaluep, YYLTYPE const *const yylocationp, void *_data, void *scanner)
#define YYSTACK_RELOCATE(Stack_alloc, Stack)
Definition: expr-bison.c:380
#define yyerror
Definition: expr-bison.c:65
const char * name
Definition: expr.h:9
static int expr__lex(YYSTYPE *res, const char **pp)
Definition: expr-bison.c:1569
#define YY_IGNORE_MAYBE_UNINITIALIZED_END
Definition: expr-bison.c:278
#define yypact_value_is_default(Yystate)
Definition: expr-bison.c:500
yytokentype
Definition: expr-bison.c:114
#define yytable_value_is_error(Yytable_value)
Definition: expr-bison.c:505
#define YYTRANSLATE(YYX)
Definition: expr-bison.c:432
#define YYSTACK_BYTES(N)
Definition: expr-bison.c:369
short int yytype_int16
Definition: expr-bison.c:201
#define YYMAXDEPTH
Definition: expr-bison.c:763
static int expr__symbol(YYSTYPE *res, const char *p, const char **pp)
Definition: expr-bison.c:1554
#define YYINITDEPTH
Definition: expr-bison.c:752
double val
Definition: expr.h:10
#define YY_REDUCE_PRINT(Rule)
Definition: expr-bison.c:746
#define YY_STACK_PRINT(Bottom, Top)
Definition: expr-bison.c:745
#define YY_INITIAL_VALUE(Value)
Definition: expr-bison.c:274
int num_ids
Definition: expr.h:14
static const char *const yytname[]
void free(void *)
static const yytype_uint16 yyrline[]
static const yytype_int8 yydefgoto[]
Definition: expr-bison.c:534
#define YYLAST
Definition: expr-bison.c:416
#define YYFPRINTF
#define YY_NULLPTR
Definition: expr-bison.c:87
static void expr__error(double *final_val __maybe_unused, struct parse_ctx *ctx __maybe_unused, const char **pp __maybe_unused, const char *s)
Definition: expr-bison.c:152
double num
Definition: expr-bison.c:130
int expr__parse(double *final_val, struct parse_ctx *ctx, const char **pp)
#define YYSTACK_ALLOC_MAXIMUM
Definition: expr-bison.c:327
#define yylval
void expr__add_id(struct parse_ctx *ctx, const char *name, double val)
Definition: expr-bison.c:1595
#define YYDPRINTF(Args)
Definition: expr-bison.c:743
#define YYUSE(E)
Definition: expr-bison.c:260
#define YYPOPSTACK(N)
int expr__find_other(const char *p, const char *one, const char ***other, int *num_otherp)
Definition: expr-bison.c:1609
#define YYABORT
Definition: expr-bison.c:588
static void yy_stack_print(yytype_int16 *yybottom, yytype_int16 *yytop)
static const yytype_uint8 yyr1[]
Definition: expr-bison.c:568