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