1 /* A Bison parser, made by GNU Bison 3.0.4. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
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.
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.
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/>. */
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.
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
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. */
43 /* Identify Bison output. */
47 #define YYBISON_VERSION "3.0.4"
50 #define YYSKELETON_NAME "yacc.c"
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
70 /* Copy the first part of user declarations. */
71 #line 1 "plural.y" /* yacc.c:339 */
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.
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.
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.
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/>. */
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__
106 #include "plural-exp.h"
108 /* The main function generated by the parser is called __gettextparse,
109 but we want it to be called PLURAL_PARSE. */
111 # define __gettextparse PLURAL_PARSE
115 #line 116 "plural.c" /* yacc.c:339 */
118 # if defined __cplusplus && 201103L <= __cplusplus
119 # define YY_NULLPTR nullptr
121 # define YY_NULLPTR 0
125 /* Enabling verbose error messages. */
126 #ifdef YYERROR_VERBOSE
127 # undef YYERROR_VERBOSE
128 # define YYERROR_VERBOSE 1
130 # define YYERROR_VERBOSE 0
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
142 extern int __gettextdebug;
165 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
169 #line 49 "plural.y" /* yacc.c:355 */
171 unsigned long int num;
172 enum expression_operator op;
173 struct expression *exp;
175 #line 176 "plural.c" /* yacc.c:355 */
178 typedef union YYSTYPE YYSTYPE;
179 # define YYSTYPE_IS_TRIVIAL 1
180 # define YYSTYPE_IS_DECLARED 1
185 int __gettextparse (struct parse_args *arg);
187 #endif /* !YY__GETTEXT_PLURAL_H_INCLUDED */
189 /* Copy the second part of user declarations. */
190 #line 55 "plural.y" /* yacc.c:358 */
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);
196 /* Allocation of expressions. */
198 static struct expression *
199 new_exp (int nargs, enum expression_operator op,
200 struct expression * const *args)
203 struct expression *newp;
205 /* If any of the argument could not be malloc'ed, just return NULL. */
206 for (i = nargs - 1; i >= 0; i--)
210 /* Allocate a new expression. */
211 newp = (struct expression *) malloc (sizeof (*newp));
215 newp->operation = op;
216 for (i = nargs - 1; i >= 0; i--)
217 newp->val.args[i] = args[i];
222 for (i = nargs - 1; i >= 0; i--)
223 FREE_EXPRESSION (args[i]);
228 static inline struct expression *
229 new_exp_0 (enum expression_operator op)
231 return new_exp (0, op, NULL);
234 static inline struct expression *
235 new_exp_1 (enum expression_operator op, struct expression *right)
237 struct expression *args[1];
240 return new_exp (1, op, args);
243 static struct expression *
244 new_exp_2 (enum expression_operator op, struct expression *left,
245 struct expression *right)
247 struct expression *args[2];
251 return new_exp (2, op, args);
254 static inline struct expression *
255 new_exp_3 (enum expression_operator op, struct expression *bexp,
256 struct expression *tbranch, struct expression *fbranch)
258 struct expression *args[3];
263 return new_exp (3, op, args);
267 #line 268 "plural.c" /* yacc.c:358 */
274 typedef YYTYPE_UINT8 yytype_uint8;
276 typedef unsigned char yytype_uint8;
280 typedef YYTYPE_INT8 yytype_int8;
282 typedef signed char yytype_int8;
286 typedef YYTYPE_UINT16 yytype_uint16;
288 typedef unsigned short int yytype_uint16;
292 typedef YYTYPE_INT16 yytype_int16;
294 typedef short int yytype_int16;
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
306 # define YYSIZE_T unsigned int
310 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
313 # if defined YYENABLE_NLS && YYENABLE_NLS
315 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
316 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
320 # define YY_(Msgid) Msgid
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)
330 # define YY_ATTRIBUTE(Spec) /* empty */
334 #ifndef YY_ATTRIBUTE_PURE
335 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
338 #ifndef YY_ATTRIBUTE_UNUSED
339 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
342 #if !defined _Noreturn \
343 && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
344 # if defined _MSC_VER && 1200 <= _MSC_VER
345 # define _Noreturn __declspec (noreturn)
347 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
351 /* Suppress unused-variable warnings by "using" E. */
352 #if ! defined lint || defined __GNUC__
353 # define YYUSE(E) ((void) (E))
355 # define YYUSE(E) /* empty */
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")
367 # define YY_INITIAL_VALUE(Value) Value
369 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
370 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
371 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
373 #ifndef YY_INITIAL_VALUE
374 # define YY_INITIAL_VALUE(Value) /* Nothing. */
378 #if ! defined yyoverflow || YYERROR_VERBOSE
380 /* The parser invokes alloca or malloc; define the necessary symbols. */
382 # ifdef YYSTACK_USE_ALLOCA
383 # if YYSTACK_USE_ALLOCA
385 # define YYSTACK_ALLOC __builtin_alloca
386 # elif defined __BUILTIN_VA_ARG_INCR
387 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
389 # define YYSTACK_ALLOC __alloca
390 # elif defined _MSC_VER
391 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
392 # define alloca _alloca
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
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 */
417 # define YYSTACK_ALLOC YYMALLOC
418 # define YYSTACK_FREE YYFREE
419 # ifndef YYSTACK_ALLOC_MAXIMUM
420 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
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
431 # define YYMALLOC malloc
432 # if ! defined malloc && ! defined EXIT_SUCCESS
433 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
438 # if ! defined free && ! defined EXIT_SUCCESS
439 void free (void *); /* INFRINGES ON USER NAME SPACE */
443 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
446 #if (! defined yyoverflow \
447 && (! defined __cplusplus \
448 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
450 /* A type that is properly aligned for any stack member. */
453 yytype_int16 yyss_alloc;
457 /* The size of the maximum gap between one aligned stack and the next. */
458 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
460 /* The size of an array large to enough to hold all stacks, each with
462 # define YYSTACK_BYTES(N) \
463 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
464 + YYSTACK_GAP_MAXIMUM)
466 # define YYCOPY_NEEDED 1
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
473 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
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); \
486 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
487 /* Copy COUNT objects from SRC to DST. The source and destination do
490 # if defined __GNUC__ && 1 < __GNUC__
491 # define YYCOPY(Dst, Src, Count) \
492 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
494 # define YYCOPY(Dst, Src, Count) \
498 for (yyi = 0; yyi < (Count); yyi++) \
499 (Dst)[yyi] = (Src)[yyi]; \
504 #endif /* !YYCOPY_NEEDED */
506 /* YYFINAL -- State number of the termination state. */
508 /* YYLAST -- Last index in YYTABLE. */
511 /* YYNTOKENS -- Number of terminals. */
513 /* YYNNTS -- Number of nonterminals. */
515 /* YYNRULES -- Number of rules. */
517 /* YYNSTATES -- Number of states. */
520 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
521 by yylex, with out-of-bounds checking. */
523 #define YYMAXUTOK 262
525 #define YYTRANSLATE(YYX) \
526 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
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[] =
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,
562 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
563 static const yytype_uint8 yyrline[] =
565 0, 152, 152, 160, 164, 168, 172, 176, 180, 184,
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[] =
575 "$end", "error", "$undefined", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
576 "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
577 "$accept", "start", "exp", YY_NULLPTR
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[] =
586 0, 256, 257, 63, 124, 38, 258, 259, 260, 261,
587 33, 262, 58, 110, 40, 41
591 #define YYPACT_NINF -10
593 #define yypact_value_is_default(Yystate) \
594 (!!((Yystate) == (-10)))
596 #define YYTABLE_NINF -1
598 #define yytable_value_is_error(Yytable_value) \
601 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
603 static const yytype_int8 yypact[] =
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
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[] =
615 0, 0, 12, 11, 0, 0, 2, 10, 0, 1,
616 0, 0, 0, 0, 0, 0, 0, 13, 0, 4,
620 /* YYPGOTO[NTERM-NUM]. */
621 static const yytype_int8 yypgoto[] =
626 /* YYDEFGOTO[NTERM-NUM]. */
627 static const yytype_int8 yydefgoto[] =
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[] =
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,
645 static const yytype_int8 yycheck[] =
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,
655 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
656 symbol of state STATE-NUM. */
657 static const yytype_uint8 yystos[] =
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
664 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
665 static const yytype_uint8 yyr1[] =
667 0, 16, 17, 18, 18, 18, 18, 18, 18, 18,
671 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
672 static const yytype_uint8 yyr2[] =
674 0, 2, 1, 5, 3, 3, 3, 3, 3, 3,
679 #define yyerrok (yyerrstatus = 0)
680 #define yyclearin (yychar = YYEMPTY)
684 #define YYACCEPT goto yyacceptlab
685 #define YYABORT goto yyabortlab
686 #define YYERROR goto yyerrorlab
689 #define YYRECOVERING() (!!yyerrstatus)
691 #define YYBACKUP(Token, Value) \
693 if (yychar == YYEMPTY) \
697 YYPOPSTACK (yylen); \
703 yyerror (arg, YY_("syntax error: cannot back up")); \
708 /* Error token number */
710 #define YYERRCODE 256
714 /* Enable debugging if requested. */
718 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
719 # define YYFPRINTF fprintf
722 # define YYDPRINTF(Args) \
728 /* This macro is provided for backward compatibility. */
729 #ifndef YY_LOCATION_PRINT
730 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
734 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
738 YYFPRINTF (stderr, "%s ", Title); \
739 yy_symbol_print (stderr, \
741 YYFPRINTF (stderr, "\n"); \
746 /*----------------------------------------.
747 | Print this symbol's value on YYOUTPUT. |
748 `----------------------------------------*/
751 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct parse_args *arg)
753 FILE *yyo = yyoutput;
759 if (yytype < YYNTOKENS)
760 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
766 /*--------------------------------.
767 | Print this symbol on YYOUTPUT. |
768 `--------------------------------*/
771 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct parse_args *arg)
773 YYFPRINTF (yyoutput, "%s %s (",
774 yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
776 yy_symbol_value_print (yyoutput, yytype, yyvaluep, arg);
777 YYFPRINTF (yyoutput, ")");
780 /*------------------------------------------------------------------.
781 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
783 `------------------------------------------------------------------*/
786 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
788 YYFPRINTF (stderr, "Stack now");
789 for (; yybottom <= yytop; yybottom++)
791 int yybot = *yybottom;
792 YYFPRINTF (stderr, " %d", yybot);
794 YYFPRINTF (stderr, "\n");
797 # define YY_STACK_PRINT(Bottom, Top) \
800 yy_stack_print ((Bottom), (Top)); \
804 /*------------------------------------------------.
805 | Report that the YYRULE is going to be reduced. |
806 `------------------------------------------------*/
809 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, struct parse_args *arg)
811 unsigned long int yylno = yyrline[yyrule];
812 int yynrhs = yyr2[yyrule];
814 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
816 /* The symbols being reduced. */
817 for (yyi = 0; yyi < yynrhs; yyi++)
819 YYFPRINTF (stderr, " $%d = ", yyi + 1);
820 yy_symbol_print (stderr,
821 yystos[yyssp[yyi + 1 - yynrhs]],
822 &(yyvsp[(yyi + 1) - (yynrhs)])
824 YYFPRINTF (stderr, "\n");
828 # define YY_REDUCE_PRINT(Rule) \
831 yy_reduce_print (yyssp, yyvsp, Rule, arg); \
834 /* Nonzero means print parse trace. It is left uninitialized so that
835 multiple parsers can coexist. */
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 */
845 /* YYINITDEPTH -- initial size of the parser's stacks. */
847 # define YYINITDEPTH 200
850 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
851 if the built-in stack extension method is used).
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. */
858 # define YYMAXDEPTH 10000
865 # if defined __GLIBC__ && defined _STRING_H
866 # define yystrlen strlen
868 /* Return the length of YYSTR. */
870 yystrlen (const char *yystr)
873 for (yylen = 0; yystr[yylen]; yylen++)
881 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
882 # define yystpcpy stpcpy
884 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
887 yystpcpy (char *yydest, const char *yysrc)
890 const char *yys = yysrc;
892 while ((*yyd++ = *yys++) != '\0')
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
909 yytnamerr (char *yyres, const char *yystr)
914 char const *yyp = yystr;
921 goto do_not_strip_quotes;
925 goto do_not_strip_quotes;
938 do_not_strip_quotes: ;
942 return yystrlen (yystr);
944 return yystpcpy (yyres, yystr) - yyres;
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
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. */
957 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
958 yytype_int16 *yyssp, int yytoken)
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
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.
994 if (yytoken != YYEMPTY)
996 int yyn = yypact[*yyssp];
997 yyarg[yycount++] = yytname[yytoken];
998 if (!yypact_value_is_default (yyn))
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;
1009 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1010 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1011 && !yytable_value_is_error (yytable[yyx + yyn]))
1013 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1019 yyarg[yycount++] = yytname[yyx];
1021 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
1022 if (! (yysize <= yysize1
1023 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1033 # define YYCASE_(N, S) \
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"));
1047 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1048 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1053 if (*yymsg_alloc < yysize)
1055 *yymsg_alloc = 2 * yysize;
1056 if (! (yysize <= *yymsg_alloc
1057 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1058 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
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. */
1068 while ((*yyp = *yyformat) != '\0')
1069 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1071 yyp += yytnamerr (yyp, yyarg[yyi++]);
1082 #endif /* YYERROR_VERBOSE */
1084 /*-----------------------------------------------.
1085 | Release the memory associated to this symbol. |
1086 `-----------------------------------------------*/
1089 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, struct parse_args *arg)
1095 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1097 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1099 YY_IGNORE_MAYBE_UNINITIALIZED_END
1110 yyparse (struct parse_args *arg)
1112 /* The lookahead symbol. */
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);
1122 /* Number of syntax errors so far. */
1126 /* Number of tokens to shift before error messages enabled. */
1129 /* The stacks and their tools:
1130 'yyss': related to states.
1131 'yyvs': related to semantic values.
1133 Refer to the stacks through separate pointers, to allow yyoverflow
1134 to reallocate them elsewhere. */
1136 /* The state stack. */
1137 yytype_int16 yyssa[YYINITDEPTH];
1139 yytype_int16 *yyssp;
1141 /* The semantic value stack. */
1142 YYSTYPE yyvsa[YYINITDEPTH];
1146 YYSIZE_T yystacksize;
1150 /* Lookahead token as an internal (translated) token number. */
1152 /* The variables used to return semantic value and location from the
1157 /* Buffer for error messages, and its allocated size. */
1159 char *yymsg = yymsgbuf;
1160 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1163 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1165 /* The number of symbols on the RHS of the reduced rule.
1166 Keep to zero when no symbol should be popped. */
1169 yyssp = yyss = yyssa;
1170 yyvsp = yyvs = yyvsa;
1171 yystacksize = YYINITDEPTH;
1173 YYDPRINTF ((stderr, "Starting parse\n"));
1178 yychar = YYEMPTY; /* Cause a token to be read. */
1181 /*------------------------------------------------------------.
1182 | yynewstate -- Push a new state, which is found in yystate. |
1183 `------------------------------------------------------------*/
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. */
1192 if (yyss + yystacksize - 1 <= yyssp)
1194 /* Get the current used size of the three stacks, in elements. */
1195 YYSIZE_T yysize = yyssp - yyss + 1;
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
1202 YYSTYPE *yyvs1 = yyvs;
1203 yytype_int16 *yyss1 = yyss;
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),
1217 #else /* no yyoverflow */
1218 # ifndef YYSTACK_RELOCATE
1219 goto yyexhaustedlab;
1221 /* Extend the stack our own way. */
1222 if (YYMAXDEPTH <= yystacksize)
1223 goto yyexhaustedlab;
1225 if (YYMAXDEPTH < yystacksize)
1226 yystacksize = YYMAXDEPTH;
1229 yytype_int16 *yyss1 = yyss;
1230 union yyalloc *yyptr =
1231 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1233 goto yyexhaustedlab;
1234 YYSTACK_RELOCATE (yyss_alloc, yyss);
1235 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1236 # undef YYSTACK_RELOCATE
1238 YYSTACK_FREE (yyss1);
1241 #endif /* no yyoverflow */
1243 yyssp = yyss + yysize - 1;
1244 yyvsp = yyvs + yysize - 1;
1246 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1247 (unsigned long int) yystacksize));
1249 if (yyss + yystacksize - 1 <= yyssp)
1253 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1255 if (yystate == YYFINAL)
1265 /* Do appropriate processing given the current state. Read a
1266 lookahead token if we need one and don't already have one. */
1268 /* First try to decide what to do without reference to lookahead token. */
1269 yyn = yypact[yystate];
1270 if (yypact_value_is_default (yyn))
1273 /* Not known => get a lookahead token if don't already have one. */
1275 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1276 if (yychar == YYEMPTY)
1278 YYDPRINTF ((stderr, "Reading a token: "));
1279 yychar = yylex (&yylval, arg);
1282 if (yychar <= YYEOF)
1284 yychar = yytoken = YYEOF;
1285 YYDPRINTF ((stderr, "Now at end of input.\n"));
1289 yytoken = YYTRANSLATE (yychar);
1290 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1293 /* If the proper action on seeing token YYTOKEN is to reduce or to
1294 detect an error, take that action. */
1296 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1301 if (yytable_value_is_error (yyn))
1307 /* Count tokens shifted since error; after three, turn off error
1312 /* Shift the lookahead token. */
1313 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1315 /* Discard the shifted token. */
1319 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1321 YY_IGNORE_MAYBE_UNINITIALIZED_END
1326 /*-----------------------------------------------------------.
1327 | yydefault -- do the default action for the current state. |
1328 `-----------------------------------------------------------*/
1330 yyn = yydefact[yystate];
1336 /*-----------------------------.
1337 | yyreduce -- Do a reduction. |
1338 `-----------------------------*/
1340 /* yyn is the number of a rule to reduce with. */
1343 /* If YYLEN is nonzero, implement the default value of the action:
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];
1354 YY_REDUCE_PRINT (yyn);
1358 #line 153 "plural.y" /* yacc.c:1646 */
1360 if ((yyvsp[0].exp) == NULL)
1362 arg->res = (yyvsp[0].exp);
1364 #line 1365 "plural.c" /* yacc.c:1646 */
1368 #line 161 "plural.y" /* yacc.c:1646 */
1370 (yyval.exp) = new_exp_3 (qmop, (yyvsp[-4].exp), (yyvsp[-2].exp), (yyvsp[0].exp));
1372 #line 1373 "plural.c" /* yacc.c:1646 */
1376 #line 165 "plural.y" /* yacc.c:1646 */
1378 (yyval.exp) = new_exp_2 (lor, (yyvsp[-2].exp), (yyvsp[0].exp));
1380 #line 1381 "plural.c" /* yacc.c:1646 */
1384 #line 169 "plural.y" /* yacc.c:1646 */
1386 (yyval.exp) = new_exp_2 (land, (yyvsp[-2].exp), (yyvsp[0].exp));
1388 #line 1389 "plural.c" /* yacc.c:1646 */
1392 #line 173 "plural.y" /* yacc.c:1646 */
1394 (yyval.exp) = new_exp_2 ((yyvsp[-1].op), (yyvsp[-2].exp), (yyvsp[0].exp));
1396 #line 1397 "plural.c" /* yacc.c:1646 */
1400 #line 177 "plural.y" /* yacc.c:1646 */
1402 (yyval.exp) = new_exp_2 ((yyvsp[-1].op), (yyvsp[-2].exp), (yyvsp[0].exp));
1404 #line 1405 "plural.c" /* yacc.c:1646 */
1408 #line 181 "plural.y" /* yacc.c:1646 */
1410 (yyval.exp) = new_exp_2 ((yyvsp[-1].op), (yyvsp[-2].exp), (yyvsp[0].exp));
1412 #line 1413 "plural.c" /* yacc.c:1646 */
1416 #line 185 "plural.y" /* yacc.c:1646 */
1418 (yyval.exp) = new_exp_2 ((yyvsp[-1].op), (yyvsp[-2].exp), (yyvsp[0].exp));
1420 #line 1421 "plural.c" /* yacc.c:1646 */
1424 #line 189 "plural.y" /* yacc.c:1646 */
1426 (yyval.exp) = new_exp_1 (lnot, (yyvsp[0].exp));
1428 #line 1429 "plural.c" /* yacc.c:1646 */
1432 #line 193 "plural.y" /* yacc.c:1646 */
1434 (yyval.exp) = new_exp_0 (var);
1436 #line 1437 "plural.c" /* yacc.c:1646 */
1440 #line 197 "plural.y" /* yacc.c:1646 */
1442 if (((yyval.exp) = new_exp_0 (num)) != NULL)
1443 (yyval.exp)->val.num = (yyvsp[0].num);
1445 #line 1446 "plural.c" /* yacc.c:1646 */
1449 #line 202 "plural.y" /* yacc.c:1646 */
1451 (yyval.exp) = (yyvsp[-1].exp);
1453 #line 1454 "plural.c" /* yacc.c:1646 */
1457 #line 1458 "plural.c" /* yacc.c:1646 */
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);
1475 YY_STACK_PRINT (yyss, yyssp);
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. */
1485 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1486 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1487 yystate = yytable[yystate];
1489 yystate = yydefgoto[yyn - YYNTOKENS];
1494 /*--------------------------------------.
1495 | yyerrlab -- here on detecting error. |
1496 `--------------------------------------*/
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);
1502 /* If not already recovering from an error, report this error. */
1506 #if ! YYERROR_VERBOSE
1507 yyerror (arg, YY_("syntax error"));
1509 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1512 char const *yymsgp = YY_("syntax error");
1513 int yysyntax_error_status;
1514 yysyntax_error_status = YYSYNTAX_ERROR;
1515 if (yysyntax_error_status == 0)
1517 else if (yysyntax_error_status == 1)
1519 if (yymsg != yymsgbuf)
1520 YYSTACK_FREE (yymsg);
1521 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1525 yymsg_alloc = sizeof yymsgbuf;
1526 yysyntax_error_status = 2;
1530 yysyntax_error_status = YYSYNTAX_ERROR;
1534 yyerror (arg, yymsgp);
1535 if (yysyntax_error_status == 2)
1536 goto yyexhaustedlab;
1538 # undef YYSYNTAX_ERROR
1544 if (yyerrstatus == 3)
1546 /* If just tried and failed to reuse lookahead token after an
1547 error, discard it. */
1549 if (yychar <= YYEOF)
1551 /* Return failure if at end of input. */
1552 if (yychar == YYEOF)
1557 yydestruct ("Error: discarding",
1558 yytoken, &yylval, arg);
1563 /* Else will try to reuse lookahead token after shifting the error
1568 /*---------------------------------------------------.
1569 | yyerrorlab -- error raised explicitly by YYERROR. |
1570 `---------------------------------------------------*/
1573 /* Pacify compilers like GCC when the user code never invokes
1574 YYERROR and the label yyerrorlab therefore never appears in user
1576 if (/*CONSTCOND*/ 0)
1579 /* Do not reclaim the symbols of the rule whose action triggered
1583 YY_STACK_PRINT (yyss, yyssp);
1588 /*-------------------------------------------------------------.
1589 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1590 `-------------------------------------------------------------*/
1592 yyerrstatus = 3; /* Each real token shifted decrements this. */
1596 yyn = yypact[yystate];
1597 if (!yypact_value_is_default (yyn))
1600 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1608 /* Pop the current state because it cannot handle the error token. */
1613 yydestruct ("Error: popping",
1614 yystos[yystate], yyvsp, arg);
1617 YY_STACK_PRINT (yyss, yyssp);
1620 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1622 YY_IGNORE_MAYBE_UNINITIALIZED_END
1625 /* Shift the error token. */
1626 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1632 /*-------------------------------------.
1633 | yyacceptlab -- YYACCEPT comes here. |
1634 `-------------------------------------*/
1639 /*-----------------------------------.
1640 | yyabortlab -- YYABORT comes here. |
1641 `-----------------------------------*/
1646 #if !defined yyoverflow || YYERROR_VERBOSE
1647 /*-------------------------------------------------.
1648 | yyexhaustedlab -- memory exhaustion comes here. |
1649 `-------------------------------------------------*/
1651 yyerror (arg, YY_("memory exhausted"));
1657 if (yychar != YYEMPTY)
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);
1665 /* Do not reclaim the symbols of the rule whose action triggered
1666 this YYABORT or YYACCEPT. */
1668 YY_STACK_PRINT (yyss, yyssp);
1669 while (yyssp != yyss)
1671 yydestruct ("Cleanup: popping",
1672 yystos[*yyssp], yyvsp, arg);
1677 YYSTACK_FREE (yyss);
1680 if (yymsg != yymsgbuf)
1681 YYSTACK_FREE (yymsg);
1685 #line 207 "plural.y" /* yacc.c:1906 */
1690 FREE_EXPRESSION (struct expression *exp)
1695 /* Handle the recursive case. */
1699 FREE_EXPRESSION (exp->val.args[2]);
1702 FREE_EXPRESSION (exp->val.args[1]);
1705 FREE_EXPRESSION (exp->val.args[0]);
1716 yylex (YYSTYPE *lval, struct parse_args *arg)
1718 const char *exp = arg->cp;
1729 if (exp[0] != ' ' && exp[0] != '\t')
1738 case '0': case '1': case '2': case '3': case '4':
1739 case '5': case '6': case '7': case '8': case '9':
1741 unsigned long int n = result - '0';
1742 while (exp[0] >= '0' && exp[0] <= '9')
1768 lval->op = not_equal;
1775 if (exp[0] == result)
1785 lval->op = less_or_equal;
1788 lval->op = less_than;
1796 lval->op = greater_or_equal;
1799 lval->op = greater_than;
1833 /* Nothing, just return the character. */
1839 /* Be safe and let the user call this function again. */
1859 yyerror (struct parse_args *arg, const char *str)
1861 /* Do nothing. We don't print error messages here. */