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