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