bug 771: Remember whether navigation was requested by user
[elinks/kon.git] / src / intl / gettext / plural.c
blob62819f348b8793a7a044a7d5cb3c2a3b236aaf76
1 /* A Bison parser, made by GNU Bison 1.875. */
3 /* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
26 /* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
29 /* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
36 /* Identify Bison output. */
37 #define YYBISON 1
39 /* Skeleton name. */
40 #define YYSKELETON_NAME "yacc.c"
42 /* Pure parsers. */
43 #define YYPURE 1
45 /* Using locations. */
46 #define YYLSP_NEEDED 0
48 /* If NAME_PREFIX is specified substitute the variables and functions
49 names. */
50 #define yyparse gettext__parse
51 #define yylex gettext__lex
52 #define yyerror gettext__error
53 #define yylval gettext__lval
54 #define yychar gettext__char
55 #define yydebug gettext__debug
56 #define yynerrs gettext__nerrs
59 /* Tokens. */
60 #ifndef YYTOKENTYPE
61 # define YYTOKENTYPE
62 /* Put the tokens into the symbol table, so that GDB and other debuggers
63 know about them. */
64 enum yytokentype {
65 EQUOP2 = 258,
66 CMPOP2 = 259,
67 ADDOP2 = 260,
68 MULOP2 = 261,
69 NUMBER = 262
71 #endif
72 #define EQUOP2 258
73 #define CMPOP2 259
74 #define ADDOP2 260
75 #define MULOP2 261
76 #define NUMBER 262
81 /* Copy the first part of user declarations. */
82 #line 1 "plural.y"
84 /* Expression parsing for plural form selection.
85 Copyright (C) 2000, 2001 Free Software Foundation, Inc.
86 Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
88 This program is free software; you can redistribute it and/or modify
89 it under the terms of the GNU General Public License as published by
90 the Free Software Foundation; either version 2, or (at your option)
91 any later version.
93 This program is distributed in the hope that it will be useful,
94 but WITHOUT ANY WARRANTY; without even the implied warranty of
95 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
96 GNU General Public License for more details.
98 You should have received a copy of the GNU General Public License
99 along with this program; if not, write to the Free Software Foundation,
100 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
102 /* The bison generated parser uses alloca. AIX 3 forces us to put this
103 declaration at the beginning of the file. The declaration in bison's
104 skeleton file comes too late. This must come before <config.h>
105 because <config.h> may include arbitrary system headers. */
106 #if defined _AIX && !defined __GNUC__
107 #pragma alloca
108 #endif
110 #ifdef HAVE_CONFIG_H
111 # include <config.h>
112 #endif
114 #include <stdlib.h>
115 #include "intl/gettext/gettextP.h"
117 #define YYLEX_PARAM &((struct parse_args *) arg)->cp
118 #define YYPARSE_PARAM arg
121 /* Enabling traces. */
122 #ifndef YYDEBUG
123 # define YYDEBUG 0
124 #endif
126 /* Enabling verbose error messages. */
127 #ifdef YYERROR_VERBOSE
128 # undef YYERROR_VERBOSE
129 # define YYERROR_VERBOSE 1
130 #else
131 # define YYERROR_VERBOSE 0
132 #endif
134 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
135 #line 41 "plural.y"
136 typedef union YYSTYPE {
137 unsigned long int num;
138 enum operator op;
139 struct expression *exp;
140 } YYSTYPE;
141 /* Line 191 of yacc.c. */
142 #line 142 "plural.c"
143 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
144 # define YYSTYPE_IS_DECLARED 1
145 # define YYSTYPE_IS_TRIVIAL 1
146 #endif
150 /* Copy the second part of user declarations. */
151 #line 47 "plural.y"
153 /* Prototypes for local functions. */
154 static struct expression *new_exp(int nargs, enum operator op,
155 struct expression * const *args);
156 static inline struct expression *new_exp_0(enum operator op);
157 static inline struct expression *new_exp_1(enum operator op,
158 struct expression *right);
159 static struct expression *new_exp_2(enum operator op,
160 struct expression *left,
161 struct expression *right);
162 static inline struct expression *new_exp_3(enum operator op,
163 struct expression *bexp,
164 struct expression *tbranch,
165 struct expression *fbranch);
166 static int yylex(YYSTYPE *lval, const unsigned char **pexp);
167 static void yyerror(const unsigned char *str);
169 /* Allocation of expressions. */
171 static struct expression *
172 new_exp(int nargs, enum operator op, struct expression * const *args)
174 int i;
175 struct expression *newp;
177 /* If any of the argument could not be malloc'ed, just return NULL. */
178 for (i = nargs - 1; i >= 0; i--)
179 if (args[i] == NULL)
180 goto fail;
182 /* Allocate a new expression. */
183 newp = (struct expression *) malloc (sizeof (*newp));
184 if (newp != NULL)
186 newp->nargs = nargs;
187 newp->operation = op;
188 for (i = nargs - 1; i >= 0; i--)
189 newp->val.args[i] = args[i];
190 return newp;
193 fail:
194 for (i = nargs - 1; i >= 0; i--)
195 gettext_free_exp__ (args[i]);
197 return NULL;
200 static inline struct expression *
201 new_exp_0(enum operator op)
203 return new_exp (0, op, NULL);
206 static inline struct expression *
207 new_exp_1(enum operator op, struct expression *right)
209 struct expression *args[1];
211 args[0] = right;
212 return new_exp (1, op, args);
215 static struct expression *
216 new_exp_2(enum operator op, struct expression *left, struct expression *right)
218 struct expression *args[2];
220 args[0] = left;
221 args[1] = right;
222 return new_exp (2, op, args);
225 static inline struct expression *
226 new_exp_3(enum operator op, struct expression *bexp, struct expression *tbranch,
227 struct expression *fbranch)
229 struct expression *args[3];
231 args[0] = bexp;
232 args[1] = tbranch;
233 args[2] = fbranch;
234 return new_exp (3, op, args);
239 /* Line 214 of yacc.c. */
240 #line 240 "plural.c"
242 #if ! defined (yyoverflow) || YYERROR_VERBOSE
244 /* The parser invokes alloca or malloc; define the necessary symbols. */
246 # if YYSTACK_USE_ALLOCA
247 # define YYSTACK_ALLOC alloca
248 # else
249 # ifndef YYSTACK_USE_ALLOCA
250 # if defined (alloca) || defined (_ALLOCA_H)
251 # define YYSTACK_ALLOC alloca
252 # else
253 # ifdef __GNUC__
254 # define YYSTACK_ALLOC __builtin_alloca
255 # endif
256 # endif
257 # endif
258 # endif
260 # ifdef YYSTACK_ALLOC
261 /* Pacify GCC's `empty if-body' warning. */
262 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
263 # else
264 # if defined (__STDC__) || defined (__cplusplus)
265 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
266 # define YYSIZE_T size_t
267 # endif
268 # define YYSTACK_ALLOC malloc
269 # define YYSTACK_FREE free
270 # endif
271 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
274 #if (! defined (yyoverflow) \
275 && (! defined (__cplusplus) \
276 || (YYSTYPE_IS_TRIVIAL)))
278 /* A type that is properly aligned for any stack member. */
279 union yyalloc
281 short yyss;
282 YYSTYPE yyvs;
285 /* The size of the maximum gap between one aligned stack and the next. */
286 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
288 /* The size of an array large to enough to hold all stacks, each with
289 N elements. */
290 # define YYSTACK_BYTES(N) \
291 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
292 + YYSTACK_GAP_MAXIMUM)
294 /* Copy COUNT objects from FROM to TO. The source and destination do
295 not overlap. */
296 # ifndef YYCOPY
297 # if 1 < __GNUC__
298 # define YYCOPY(To, From, Count) \
299 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
300 # else
301 # define YYCOPY(To, From, Count) \
302 do \
304 register YYSIZE_T yyi; \
305 for (yyi = 0; yyi < (Count); yyi++) \
306 (To)[yyi] = (From)[yyi]; \
308 while (0)
309 # endif
310 # endif
312 /* Relocate STACK from its old location to the new one. The
313 local variables YYSIZE and YYSTACKSIZE give the old and new number of
314 elements in the stack, and YYPTR gives the new location of the
315 stack. Advance YYPTR to a properly aligned location for the next
316 stack. */
317 # define YYSTACK_RELOCATE(Stack) \
318 do \
320 YYSIZE_T yynewbytes; \
321 YYCOPY (&yyptr->Stack, Stack, yysize); \
322 Stack = &yyptr->Stack; \
323 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
324 yyptr += yynewbytes / sizeof (*yyptr); \
326 while (0)
328 #endif
330 #if defined (__STDC__) || defined (__cplusplus)
331 typedef signed char yysigned_char;
332 #else
333 typedef short yysigned_char;
334 #endif
336 /* YYFINAL -- State number of the termination state. */
337 #define YYFINAL 9
338 /* YYLAST -- Last index in YYTABLE. */
339 #define YYLAST 54
341 /* YYNTOKENS -- Number of terminals. */
342 #define YYNTOKENS 16
343 /* YYNNTS -- Number of nonterminals. */
344 #define YYNNTS 3
345 /* YYNRULES -- Number of rules. */
346 #define YYNRULES 13
347 /* YYNRULES -- Number of states. */
348 #define YYNSTATES 27
350 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
351 #define YYUNDEFTOK 2
352 #define YYMAXUTOK 262
354 #define YYTRANSLATE(YYX) \
355 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
357 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
358 static const unsigned char yytranslate[] =
360 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
361 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
362 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
363 2, 2, 2, 10, 2, 2, 2, 2, 5, 2,
364 14, 15, 2, 2, 2, 2, 2, 2, 2, 2,
365 2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
366 2, 2, 2, 3, 2, 2, 2, 2, 2, 2,
367 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
368 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
369 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
370 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
371 13, 2, 2, 2, 2, 2, 2, 2, 2, 2,
372 2, 2, 2, 2, 4, 2, 2, 2, 2, 2,
373 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
374 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
375 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
376 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
377 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
378 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
379 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
380 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
381 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
382 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
383 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
384 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
385 2, 2, 2, 2, 2, 2, 1, 2, 6, 7,
386 8, 9, 11
389 #if YYDEBUG
390 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
391 YYRHS. */
392 static const unsigned char yyprhs[] =
394 0, 0, 3, 5, 11, 15, 19, 23, 27, 31,
395 35, 38, 40, 42
398 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
399 static const yysigned_char yyrhs[] =
401 17, 0, -1, 18, -1, 18, 3, 18, 12, 18,
402 -1, 18, 4, 18, -1, 18, 5, 18, -1, 18,
403 6, 18, -1, 18, 7, 18, -1, 18, 8, 18,
404 -1, 18, 9, 18, -1, 10, 18, -1, 13, -1,
405 11, -1, 14, 18, 15, -1
408 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
409 static const unsigned char yyrline[] =
411 0, 154, 154, 162, 166, 170, 174, 178, 182, 186,
412 190, 194, 198, 203
414 #endif
416 #if YYDEBUG || YYERROR_VERBOSE
417 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
418 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
419 static const char *const yytname[] =
421 "$end", "error", "$undefined", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
422 "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
423 "$accept", "start", "exp", 0
425 #endif
427 # ifdef YYPRINT
428 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
429 token YYLEX-NUM. */
430 static const unsigned short yytoknum[] =
432 0, 256, 257, 63, 124, 38, 258, 259, 260, 261,
433 33, 262, 58, 110, 40, 41
435 # endif
437 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
438 static const unsigned char yyr1[] =
440 0, 16, 17, 18, 18, 18, 18, 18, 18, 18,
441 18, 18, 18, 18
444 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
445 static const unsigned char yyr2[] =
447 0, 2, 1, 5, 3, 3, 3, 3, 3, 3,
448 2, 1, 1, 3
451 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
452 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
453 means the default is an error. */
454 static const unsigned char yydefact[] =
456 0, 0, 12, 11, 0, 0, 2, 10, 0, 1,
457 0, 0, 0, 0, 0, 0, 0, 13, 0, 4,
458 5, 6, 7, 8, 9, 0, 3
461 /* YYDEFGOTO[NTERM-NUM]. */
462 static const yysigned_char yydefgoto[] =
464 -1, 5, 6
467 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
468 STATE-NUM. */
469 #define YYPACT_NINF -10
470 static const yysigned_char yypact[] =
472 -9, -9, -10, -10, -9, 8, 36, -10, 13, -10,
473 -9, -9, -9, -9, -9, -9, -9, -10, 26, 41,
474 45, 18, -2, 14, -10, -9, 36
477 /* YYPGOTO[NTERM-NUM]. */
478 static const yysigned_char yypgoto[] =
480 -10, -10, -1
483 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
484 positive, shift that token. If negative, reduce the rule which
485 number is the opposite. If zero, do what YYDEFACT says.
486 If YYTABLE_NINF, syntax error. */
487 #define YYTABLE_NINF -1
488 static const unsigned char yytable[] =
490 7, 1, 2, 8, 3, 4, 15, 16, 9, 18,
491 19, 20, 21, 22, 23, 24, 10, 11, 12, 13,
492 14, 15, 16, 16, 26, 14, 15, 16, 17, 10,
493 11, 12, 13, 14, 15, 16, 0, 0, 25, 10,
494 11, 12, 13, 14, 15, 16, 12, 13, 14, 15,
495 16, 13, 14, 15, 16
498 static const yysigned_char yycheck[] =
500 1, 10, 11, 4, 13, 14, 8, 9, 0, 10,
501 11, 12, 13, 14, 15, 16, 3, 4, 5, 6,
502 7, 8, 9, 9, 25, 7, 8, 9, 15, 3,
503 4, 5, 6, 7, 8, 9, -1, -1, 12, 3,
504 4, 5, 6, 7, 8, 9, 5, 6, 7, 8,
505 9, 6, 7, 8, 9
508 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
509 symbol of state STATE-NUM. */
510 static const unsigned char yystos[] =
512 0, 10, 11, 13, 14, 17, 18, 18, 18, 0,
513 3, 4, 5, 6, 7, 8, 9, 15, 18, 18,
514 18, 18, 18, 18, 18, 12, 18
517 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
518 # define YYSIZE_T __SIZE_TYPE__
519 #endif
520 #if ! defined (YYSIZE_T) && defined (size_t)
521 # define YYSIZE_T size_t
522 #endif
523 #if ! defined (YYSIZE_T)
524 # if defined (__STDC__) || defined (__cplusplus)
525 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
526 # define YYSIZE_T size_t
527 # endif
528 #endif
529 #if ! defined (YYSIZE_T)
530 # define YYSIZE_T unsigned int
531 #endif
533 #define yyerrok (yyerrstatus = 0)
534 #define yyclearin (yychar = YYEMPTY)
535 #define YYEMPTY (-2)
536 #define YYEOF 0
538 #define YYACCEPT goto yyacceptlab
539 #define YYABORT goto yyabortlab
540 #define YYERROR goto yyerrlab1
542 /* Like YYERROR except do call yyerror. This remains here temporarily
543 to ease the transition to the new meaning of YYERROR, for GCC.
544 Once GCC version 2 has supplanted version 1, this can go. */
546 #define YYFAIL goto yyerrlab
548 #define YYRECOVERING() (!!yyerrstatus)
550 #define YYBACKUP(Token, Value) \
551 do \
552 if (yychar == YYEMPTY && yylen == 1) \
554 yychar = (Token); \
555 yylval = (Value); \
556 yytoken = YYTRANSLATE (yychar); \
557 YYPOPSTACK; \
558 goto yybackup; \
560 else \
562 yyerror ("syntax error: cannot back up");\
563 YYERROR; \
565 while (0)
567 #define YYTERROR 1
568 #define YYERRCODE 256
570 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
571 are run). */
573 #ifndef YYLLOC_DEFAULT
574 # define YYLLOC_DEFAULT(Current, Rhs, N) \
575 Current.first_line = Rhs[1].first_line; \
576 Current.first_column = Rhs[1].first_column; \
577 Current.last_line = Rhs[N].last_line; \
578 Current.last_column = Rhs[N].last_column;
579 #endif
581 /* YYLEX -- calling `yylex' with the right arguments. */
583 #ifdef YYLEX_PARAM
584 # define YYLEX yylex (&yylval, YYLEX_PARAM)
585 #else
586 # define YYLEX yylex (&yylval)
587 #endif
589 /* Enable debugging if requested. */
590 #if YYDEBUG
592 # ifndef YYFPRINTF
593 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
594 # define YYFPRINTF fprintf
595 # endif
597 # define YYDPRINTF(Args) \
598 do { \
599 if (yydebug) \
600 YYFPRINTF Args; \
601 } while (0)
603 # define YYDSYMPRINT(Args) \
604 do { \
605 if (yydebug) \
606 yysymprint Args; \
607 } while (0)
609 # define YYDSYMPRINTF(Title, Token, Value, Location) \
610 do { \
611 if (yydebug) \
613 YYFPRINTF (stderr, "%s ", Title); \
614 yysymprint (stderr, \
615 Token, Value); \
616 YYFPRINTF (stderr, "\n"); \
618 } while (0)
620 /*------------------------------------------------------------------.
621 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
622 | TOP (cinluded). |
623 `------------------------------------------------------------------*/
625 #if defined (__STDC__) || defined (__cplusplus)
626 static void
627 yy_stack_print (short *bottom, short *top)
628 #else
629 static void
630 yy_stack_print (bottom, top)
631 short *bottom;
632 short *top;
633 #endif
635 YYFPRINTF (stderr, "Stack now");
636 for (/* Nothing. */; bottom <= top; ++bottom)
637 YYFPRINTF (stderr, " %d", *bottom);
638 YYFPRINTF (stderr, "\n");
641 # define YY_STACK_PRINT(Bottom, Top) \
642 do { \
643 if (yydebug) \
644 yy_stack_print ((Bottom), (Top)); \
645 } while (0)
648 /*------------------------------------------------.
649 | Report that the YYRULE is going to be reduced. |
650 `------------------------------------------------*/
652 #if defined (__STDC__) || defined (__cplusplus)
653 static void
654 yy_reduce_print (int yyrule)
655 #else
656 static void
657 yy_reduce_print (yyrule)
658 int yyrule;
659 #endif
661 int yyi;
662 unsigned int yylineno = yyrline[yyrule];
663 YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
664 yyrule - 1, yylineno);
665 /* Print the symbols being reduced, and their result. */
666 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
667 YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
668 YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
671 # define YY_REDUCE_PRINT(Rule) \
672 do { \
673 if (yydebug) \
674 yy_reduce_print (Rule); \
675 } while (0)
677 /* Nonzero means print parse trace. It is left uninitialized so that
678 multiple parsers can coexist. */
679 int yydebug;
680 #else /* !YYDEBUG */
681 # define YYDPRINTF(Args)
682 # define YYDSYMPRINT(Args)
683 # define YYDSYMPRINTF(Title, Token, Value, Location)
684 # define YY_STACK_PRINT(Bottom, Top)
685 # define YY_REDUCE_PRINT(Rule)
686 #endif /* !YYDEBUG */
689 /* YYINITDEPTH -- initial size of the parser's stacks. */
690 #ifndef YYINITDEPTH
691 # define YYINITDEPTH 200
692 #endif
694 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
695 if the built-in stack extension method is used).
697 Do not make this value too large; the results are undefined if
698 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
699 evaluated with infinite-precision integer arithmetic. */
701 #if YYMAXDEPTH == 0
702 # undef YYMAXDEPTH
703 #endif
705 #ifndef YYMAXDEPTH
706 # define YYMAXDEPTH 10000
707 #endif
711 #if YYERROR_VERBOSE
713 # ifndef yystrlen
714 # if defined (__GLIBC__) && defined (_STRING_H)
715 # define yystrlen strlen
716 # else
717 /* Return the length of YYSTR. */
718 static YYSIZE_T
719 # if defined (__STDC__) || defined (__cplusplus)
720 yystrlen (const char *yystr)
721 # else
722 yystrlen (yystr)
723 const char *yystr;
724 # endif
726 register const char *yys = yystr;
728 while (*yys++ != '\0')
729 continue;
731 return yys - yystr - 1;
733 # endif
734 # endif
736 # ifndef yystpcpy
737 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
738 # define yystpcpy stpcpy
739 # else
740 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
741 YYDEST. */
742 static char *
743 # if defined (__STDC__) || defined (__cplusplus)
744 yystpcpy (char *yydest, const char *yysrc)
745 # else
746 yystpcpy (yydest, yysrc)
747 char *yydest;
748 const char *yysrc;
749 # endif
751 register char *yyd = yydest;
752 register const char *yys = yysrc;
754 while ((*yyd++ = *yys++) != '\0')
755 continue;
757 return yyd - 1;
759 # endif
760 # endif
762 #endif /* !YYERROR_VERBOSE */
766 #if YYDEBUG
767 /*--------------------------------.
768 | Print this symbol on YYOUTPUT. |
769 `--------------------------------*/
771 #if defined (__STDC__) || defined (__cplusplus)
772 static void
773 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
774 #else
775 static void
776 yysymprint (yyoutput, yytype, yyvaluep)
777 FILE *yyoutput;
778 int yytype;
779 YYSTYPE *yyvaluep;
780 #endif
782 /* Pacify ``unused variable'' warnings. */
783 (void) yyvaluep;
785 if (yytype < YYNTOKENS)
787 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
788 # ifdef YYPRINT
789 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
790 # endif
792 else
793 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
795 switch (yytype)
797 default:
798 break;
800 YYFPRINTF (yyoutput, ")");
803 #endif /* ! YYDEBUG */
804 /*-----------------------------------------------.
805 | Release the memory associated to this symbol. |
806 `-----------------------------------------------*/
808 #if defined (__STDC__) || defined (__cplusplus)
809 static void
810 yydestruct (int yytype, YYSTYPE *yyvaluep)
811 #else
812 static void
813 yydestruct (yytype, yyvaluep)
814 int yytype;
815 YYSTYPE *yyvaluep;
816 #endif
818 /* Pacify ``unused variable'' warnings. */
819 (void) yyvaluep;
821 switch (yytype)
824 default:
825 break;
830 /* Prevent warnings from -Wmissing-prototypes. */
832 #ifdef YYPARSE_PARAM
833 # if defined (__STDC__) || defined (__cplusplus)
834 int yyparse (void *YYPARSE_PARAM);
835 # else
836 int yyparse ();
837 # endif
838 #else /* ! YYPARSE_PARAM */
839 #if defined (__STDC__) || defined (__cplusplus)
840 int yyparse (void);
841 #else
842 int yyparse ();
843 #endif
844 #endif /* ! YYPARSE_PARAM */
851 /*----------.
852 | yyparse. |
853 `----------*/
855 #ifdef YYPARSE_PARAM
856 # if defined (__STDC__) || defined (__cplusplus)
857 int yyparse (void *YYPARSE_PARAM)
858 # else
859 int yyparse (YYPARSE_PARAM)
860 void *YYPARSE_PARAM;
861 # endif
862 #else /* ! YYPARSE_PARAM */
863 #if defined (__STDC__) || defined (__cplusplus)
865 yyparse (void)
866 #else
868 yyparse ()
870 #endif
871 #endif
873 /* The lookahead symbol. */
874 int yychar;
876 /* The semantic value of the lookahead symbol. */
877 YYSTYPE yylval;
879 /* Number of syntax errors so far. */
880 int yynerrs;
882 register int yystate;
883 register int yyn;
884 int yyresult;
885 /* Number of tokens to shift before error messages enabled. */
886 int yyerrstatus;
887 /* Lookahead token as an internal (translated) token number. */
888 int yytoken = 0;
890 /* Three stacks and their tools:
891 `yyss': related to states,
892 `yyvs': related to semantic values,
893 `yyls': related to locations.
895 Refer to the stacks thru separate pointers, to allow yyoverflow
896 to reallocate them elsewhere. */
898 /* The state stack. */
899 short yyssa[YYINITDEPTH];
900 short *yyss = yyssa;
901 register short *yyssp;
903 /* The semantic value stack. */
904 YYSTYPE yyvsa[YYINITDEPTH];
905 YYSTYPE *yyvs = yyvsa;
906 register YYSTYPE *yyvsp;
910 #define YYPOPSTACK (yyvsp--, yyssp--)
912 YYSIZE_T yystacksize = YYINITDEPTH;
914 /* The variables used to return semantic value and location from the
915 action routines. */
916 YYSTYPE yyval;
919 /* When reducing, the number of symbols on the RHS of the reduced
920 rule. */
921 int yylen;
923 YYDPRINTF ((stderr, "Starting parse\n"));
925 yystate = 0;
926 yyerrstatus = 0;
927 yynerrs = 0;
928 yychar = YYEMPTY; /* Cause a token to be read. */
930 /* Initialize stack pointers.
931 Waste one element of value and location stack
932 so that they stay on the same level as the state stack.
933 The wasted elements are never initialized. */
935 yyssp = yyss;
936 yyvsp = yyvs;
938 goto yysetstate;
940 /*------------------------------------------------------------.
941 | yynewstate -- Push a new state, which is found in yystate. |
942 `------------------------------------------------------------*/
943 yynewstate:
944 /* In all cases, when you get here, the value and location stacks
945 have just been pushed. so pushing a state here evens the stacks.
947 yyssp++;
949 yysetstate:
950 *yyssp = yystate;
952 if (yyss + yystacksize - 1 <= yyssp)
954 /* Get the current used size of the three stacks, in elements. */
955 YYSIZE_T yysize = yyssp - yyss + 1;
957 #ifdef yyoverflow
959 /* Give user a chance to reallocate the stack. Use copies of
960 these so that the &'s don't force the real ones into
961 memory. */
962 YYSTYPE *yyvs1 = yyvs;
963 short *yyss1 = yyss;
966 /* Each stack pointer address is followed by the size of the
967 data in use in that stack, in bytes. This used to be a
968 conditional around just the two extra args, but that might
969 be undefined if yyoverflow is a macro. */
970 yyoverflow ("parser stack overflow",
971 &yyss1, yysize * sizeof (*yyssp),
972 &yyvs1, yysize * sizeof (*yyvsp),
974 &yystacksize);
976 yyss = yyss1;
977 yyvs = yyvs1;
979 #else /* no yyoverflow */
980 # ifndef YYSTACK_RELOCATE
981 goto yyoverflowlab;
982 # else
983 /* Extend the stack our own way. */
984 if (YYMAXDEPTH <= yystacksize)
985 goto yyoverflowlab;
986 yystacksize *= 2;
987 if (YYMAXDEPTH < yystacksize)
988 yystacksize = YYMAXDEPTH;
991 short *yyss1 = yyss;
992 union yyalloc *yyptr =
993 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
994 if (! yyptr)
995 goto yyoverflowlab;
996 YYSTACK_RELOCATE (yyss);
997 YYSTACK_RELOCATE (yyvs);
999 # undef YYSTACK_RELOCATE
1000 if (yyss1 != yyssa)
1001 YYSTACK_FREE (yyss1);
1003 # endif
1004 #endif /* no yyoverflow */
1006 yyssp = yyss + yysize - 1;
1007 yyvsp = yyvs + yysize - 1;
1010 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1011 (unsigned long int) yystacksize));
1013 if (yyss + yystacksize - 1 <= yyssp)
1014 YYABORT;
1017 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1019 goto yybackup;
1021 /*-----------.
1022 | yybackup. |
1023 `-----------*/
1024 yybackup:
1026 /* Do appropriate processing given the current state. */
1027 /* Read a lookahead token if we need one and don't already have one. */
1028 /* yyresume: */
1030 /* First try to decide what to do without reference to lookahead token. */
1032 yyn = yypact[yystate];
1033 if (yyn == YYPACT_NINF)
1034 goto yydefault;
1036 /* Not known => get a lookahead token if don't already have one. */
1038 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1039 if (yychar == YYEMPTY)
1041 YYDPRINTF ((stderr, "Reading a token: "));
1042 yychar = YYLEX;
1045 if (yychar <= YYEOF)
1047 yychar = yytoken = YYEOF;
1048 YYDPRINTF ((stderr, "Now at end of input.\n"));
1050 else
1052 yytoken = YYTRANSLATE (yychar);
1053 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
1056 /* If the proper action on seeing token YYTOKEN is to reduce or to
1057 detect an error, take that action. */
1058 yyn += yytoken;
1059 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1060 goto yydefault;
1061 yyn = yytable[yyn];
1062 if (yyn <= 0)
1064 if (yyn == 0 || yyn == YYTABLE_NINF)
1065 goto yyerrlab;
1066 yyn = -yyn;
1067 goto yyreduce;
1070 if (yyn == YYFINAL)
1071 YYACCEPT;
1073 /* Shift the lookahead token. */
1074 YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
1076 /* Discard the token being shifted unless it is eof. */
1077 if (yychar != YYEOF)
1078 yychar = YYEMPTY;
1080 *++yyvsp = yylval;
1083 /* Count tokens shifted since error; after three, turn off error
1084 status. */
1085 if (yyerrstatus)
1086 yyerrstatus--;
1088 yystate = yyn;
1089 goto yynewstate;
1092 /*-----------------------------------------------------------.
1093 | yydefault -- do the default action for the current state. |
1094 `-----------------------------------------------------------*/
1095 yydefault:
1096 yyn = yydefact[yystate];
1097 if (yyn == 0)
1098 goto yyerrlab;
1099 goto yyreduce;
1102 /*-----------------------------.
1103 | yyreduce -- Do a reduction. |
1104 `-----------------------------*/
1105 yyreduce:
1106 /* yyn is the number of a rule to reduce with. */
1107 yylen = yyr2[yyn];
1109 /* If YYLEN is nonzero, implement the default value of the action:
1110 `$$ = $1'.
1112 Otherwise, the following line sets YYVAL to garbage.
1113 This behavior is undocumented and Bison
1114 users should not rely upon it. Assigning to YYVAL
1115 unconditionally makes the parser a bit smaller, and it avoids a
1116 GCC warning that YYVAL may be used uninitialized. */
1117 yyval = yyvsp[1-yylen];
1120 YY_REDUCE_PRINT (yyn);
1121 switch (yyn)
1123 case 2:
1124 #line 155 "plural.y"
1126 if (yyvsp[0].exp == NULL)
1127 YYABORT;
1128 ((struct parse_args *) arg)->res = yyvsp[0].exp;
1130 break;
1132 case 3:
1133 #line 163 "plural.y"
1135 yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp);
1137 break;
1139 case 4:
1140 #line 167 "plural.y"
1142 yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp);
1144 break;
1146 case 5:
1147 #line 171 "plural.y"
1149 yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp);
1151 break;
1153 case 6:
1154 #line 175 "plural.y"
1156 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1158 break;
1160 case 7:
1161 #line 179 "plural.y"
1163 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1165 break;
1167 case 8:
1168 #line 183 "plural.y"
1170 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1172 break;
1174 case 9:
1175 #line 187 "plural.y"
1177 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1179 break;
1181 case 10:
1182 #line 191 "plural.y"
1184 yyval.exp = new_exp_1 (lnot, yyvsp[0].exp);
1186 break;
1188 case 11:
1189 #line 195 "plural.y"
1191 yyval.exp = new_exp_0 (var);
1193 break;
1195 case 12:
1196 #line 199 "plural.y"
1198 if ((yyval.exp = new_exp_0 (num)) != NULL)
1199 yyval.exp->val.num = yyvsp[0].num;
1201 break;
1203 case 13:
1204 #line 204 "plural.y"
1206 yyval.exp = yyvsp[-1].exp;
1208 break;
1213 /* Line 991 of yacc.c. */
1214 #line 1214 "plural.c"
1216 yyvsp -= yylen;
1217 yyssp -= yylen;
1220 YY_STACK_PRINT (yyss, yyssp);
1222 *++yyvsp = yyval;
1225 /* Now `shift' the result of the reduction. Determine what state
1226 that goes to, based on the state we popped back to and the rule
1227 number reduced by. */
1229 yyn = yyr1[yyn];
1231 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1232 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1233 yystate = yytable[yystate];
1234 else
1235 yystate = yydefgoto[yyn - YYNTOKENS];
1237 goto yynewstate;
1240 /*------------------------------------.
1241 | yyerrlab -- here on detecting error |
1242 `------------------------------------*/
1243 yyerrlab:
1244 /* If not already recovering from an error, report this error. */
1245 if (!yyerrstatus)
1247 ++yynerrs;
1248 #if YYERROR_VERBOSE
1249 yyn = yypact[yystate];
1251 if (YYPACT_NINF < yyn && yyn < YYLAST)
1253 YYSIZE_T yysize = 0;
1254 int yytype = YYTRANSLATE (yychar);
1255 char *yymsg;
1256 int yyx, yycount;
1258 yycount = 0;
1259 /* Start YYX at -YYN if negative to avoid negative indexes in
1260 YYCHECK. */
1261 for (yyx = yyn < 0 ? -yyn : 0;
1262 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1263 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1264 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1265 yysize += yystrlen ("syntax error, unexpected ") + 1;
1266 yysize += yystrlen (yytname[yytype]);
1267 yymsg = (char *) YYSTACK_ALLOC (yysize);
1268 if (yymsg != 0)
1270 char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
1271 yyp = yystpcpy (yyp, yytname[yytype]);
1273 if (yycount < 5)
1275 yycount = 0;
1276 for (yyx = yyn < 0 ? -yyn : 0;
1277 yyx < (int) (sizeof (yytname) / sizeof (char *));
1278 yyx++)
1279 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1281 const char *yyq = ! yycount ? ", expecting " : " or ";
1282 yyp = yystpcpy (yyp, yyq);
1283 yyp = yystpcpy (yyp, yytname[yyx]);
1284 yycount++;
1287 yyerror (yymsg);
1288 YYSTACK_FREE (yymsg);
1290 else
1291 yyerror ("syntax error; also virtual memory exhausted");
1293 else
1294 #endif /* YYERROR_VERBOSE */
1295 yyerror ("syntax error");
1300 if (yyerrstatus == 3)
1302 /* If just tried and failed to reuse lookahead token after an
1303 error, discard it. */
1305 /* Return failure if at end of input. */
1306 if (yychar == YYEOF)
1308 /* Pop the error token. */
1309 YYPOPSTACK;
1310 /* Pop the rest of the stack. */
1311 while (yyss < yyssp)
1313 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1314 yydestruct (yystos[*yyssp], yyvsp);
1315 YYPOPSTACK;
1317 YYABORT;
1320 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
1321 yydestruct (yytoken, &yylval);
1322 yychar = YYEMPTY;
1326 /* Else will try to reuse lookahead token after shifting the error
1327 token. */
1328 goto yyerrlab2;
1331 /*----------------------------------------------------.
1332 | yyerrlab1 -- error raised explicitly by an action. |
1333 `----------------------------------------------------*/
1334 yyerrlab1:
1336 /* Suppress GCC warning that yyerrlab1 is unused when no action
1337 invokes YYERROR. */
1338 #if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 + __GNUC_MINOR__)
1339 /* but it's harmful in C++ code
1340 * (gcc 3.2.1 complained about erroneous yylerrsp declaration) */
1341 # ifndef __cplusplus
1342 __attribute__ ((__unused__))
1343 # endif
1344 #endif
1347 goto yyerrlab2;
1350 /*---------------------------------------------------------------.
1351 | yyerrlab2 -- pop states until the error token can be shifted. |
1352 `---------------------------------------------------------------*/
1353 yyerrlab2:
1354 yyerrstatus = 3; /* Each real token shifted decrements this. */
1356 for (;;)
1358 yyn = yypact[yystate];
1359 if (yyn != YYPACT_NINF)
1361 yyn += YYTERROR;
1362 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1364 yyn = yytable[yyn];
1365 if (0 < yyn)
1366 break;
1370 /* Pop the current state because it cannot handle the error token. */
1371 if (yyssp == yyss)
1372 YYABORT;
1374 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1375 yydestruct (yystos[yystate], yyvsp);
1376 yyvsp--;
1377 yystate = *--yyssp;
1379 YY_STACK_PRINT (yyss, yyssp);
1382 if (yyn == YYFINAL)
1383 YYACCEPT;
1385 YYDPRINTF ((stderr, "Shifting error token, "));
1387 *++yyvsp = yylval;
1390 yystate = yyn;
1391 goto yynewstate;
1394 /*-------------------------------------.
1395 | yyacceptlab -- YYACCEPT comes here. |
1396 `-------------------------------------*/
1397 yyacceptlab:
1398 yyresult = 0;
1399 goto yyreturn;
1401 /*-----------------------------------.
1402 | yyabortlab -- YYABORT comes here. |
1403 `-----------------------------------*/
1404 yyabortlab:
1405 yyresult = 1;
1406 goto yyreturn;
1408 #ifndef yyoverflow
1409 /*----------------------------------------------.
1410 | yyoverflowlab -- parser overflow comes here. |
1411 `----------------------------------------------*/
1412 yyoverflowlab:
1413 yyerror ("parser stack overflow");
1414 yyresult = 2;
1415 /* Fall through. */
1416 #endif
1418 yyreturn:
1419 #ifndef yyoverflow
1420 if (yyss != yyssa)
1421 YYSTACK_FREE (yyss);
1422 #endif
1423 return yyresult;
1427 #line 209 "plural.y"
1430 void
1431 gettext_free_exp__(struct expression *exp)
1433 if (exp == NULL)
1434 return;
1436 /* Handle the recursive case. */
1437 switch (exp->nargs)
1439 case 3:
1440 gettext_free_exp__ (exp->val.args[2]);
1441 /* FALLTHROUGH */
1442 case 2:
1443 gettext_free_exp__ (exp->val.args[1]);
1444 /* FALLTHROUGH */
1445 case 1:
1446 gettext_free_exp__ (exp->val.args[0]);
1447 /* FALLTHROUGH */
1448 default:
1449 break;
1452 free (exp);
1456 static int
1457 yylex(YYSTYPE *lval, const unsigned char **pexp)
1459 const unsigned char *exp = *pexp;
1460 int result;
1462 while (1)
1464 if (exp[0] == '\0')
1466 *pexp = exp;
1467 return YYEOF;
1470 if (exp[0] != ' ' && exp[0] != '\t')
1471 break;
1473 ++exp;
1476 result = *exp++;
1477 switch (result)
1479 case '0': case '1': case '2': case '3': case '4':
1480 case '5': case '6': case '7': case '8': case '9':
1482 unsigned long int n = result - '0';
1483 while (exp[0] >= '0' && exp[0] <= '9')
1485 n *= 10;
1486 n += exp[0] - '0';
1487 ++exp;
1489 lval->num = n;
1490 result = NUMBER;
1492 break;
1494 case '=':
1495 if (exp[0] == '=')
1497 ++exp;
1498 lval->op = equal;
1499 result = EQUOP2;
1501 else
1502 result = YYERRCODE;
1503 break;
1505 case '!':
1506 if (exp[0] == '=')
1508 ++exp;
1509 lval->op = not_equal;
1510 result = EQUOP2;
1512 break;
1514 case '&':
1515 case '|':
1516 if (exp[0] == result)
1517 ++exp;
1518 else
1519 result = YYERRCODE;
1520 break;
1522 case '<':
1523 if (exp[0] == '=')
1525 ++exp;
1526 lval->op = less_or_equal;
1528 else
1529 lval->op = less_than;
1530 result = CMPOP2;
1531 break;
1533 case '>':
1534 if (exp[0] == '=')
1536 ++exp;
1537 lval->op = greater_or_equal;
1539 else
1540 lval->op = greater_than;
1541 result = CMPOP2;
1542 break;
1544 case '*':
1545 lval->op = mult;
1546 result = MULOP2;
1547 break;
1549 case '/':
1550 lval->op = divide;
1551 result = MULOP2;
1552 break;
1554 case '%':
1555 lval->op = module;
1556 result = MULOP2;
1557 break;
1559 case '+':
1560 lval->op = plus;
1561 result = ADDOP2;
1562 break;
1564 case '-':
1565 lval->op = minus;
1566 result = ADDOP2;
1567 break;
1569 case 'n':
1570 case '?':
1571 case ':':
1572 case '(':
1573 case ')':
1574 /* Nothing, just return the character. */
1575 break;
1577 case ';':
1578 case '\n':
1579 case '\0':
1580 /* Be safe and let the user call this function again. */
1581 --exp;
1582 result = YYEOF;
1583 break;
1585 default:
1586 result = YYERRCODE;
1587 #if YYDEBUG != 0
1588 --exp;
1589 #endif
1590 break;
1593 *pexp = exp;
1595 return result;
1599 static void
1600 yyerror(const unsigned char *str)
1602 /* Do nothing. We don't print error messages here. */