* keyedit.c (menu_clean): Show "already minimized" rather than
[gnupg.git] / intl / plural.c
blob5f73b403f21a241f8095f4f93c4649036ba44807
1 /* A Bison parser, made from plural.y
2 by GNU bison 1.35. */
4 #define YYBISON 1 /* Identify Bison output. */
6 #define yyparse __gettextparse
7 #define yylex __gettextlex
8 #define yyerror __gettexterror
9 #define yylval __gettextlval
10 #define yychar __gettextchar
11 #define yydebug __gettextdebug
12 #define yynerrs __gettextnerrs
13 # define EQUOP2 257
14 # define CMPOP2 258
15 # define ADDOP2 259
16 # define MULOP2 260
17 # define NUMBER 261
19 #line 1 "plural.y"
21 /* Expression parsing for plural form selection.
22 Copyright (C) 2000-2001, 2003, 2005 Free Software Foundation, Inc.
23 Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
25 This program is free software; you can redistribute it and/or modify it
26 under the terms of the GNU Library General Public License as published
27 by the Free Software Foundation; either version 2, or (at your option)
28 any later version.
30 This program is distributed in the hope that it will be useful,
31 but WITHOUT ANY WARRANTY; without even the implied warranty of
32 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33 Library General Public License for more details.
35 You should have received a copy of the GNU Library General Public
36 License along with this program; if not, write to the Free Software
37 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
38 USA. */
40 /* For bison < 2.0, the bison generated parser uses alloca. AIX 3 forces us
41 to put this declaration at the beginning of the file. The declaration in
42 bison's skeleton file comes too late. This must come before <config.h>
43 because <config.h> may include arbitrary system headers.
44 This can go away once the AM_INTL_SUBDIR macro requires bison >= 2.0. */
45 #if defined _AIX && !defined __GNUC__
46 #pragma alloca
47 #endif
49 #ifdef HAVE_CONFIG_H
50 # include <config.h>
51 #endif
53 #include <stddef.h>
54 #include <stdlib.h>
55 #include <string.h>
56 #include "plural-exp.h"
58 /* The main function generated by the parser is called __gettextparse,
59 but we want it to be called PLURAL_PARSE. */
60 #ifndef _LIBC
61 # define __gettextparse PLURAL_PARSE
62 #endif
64 #define YYLEX_PARAM &((struct parse_args *) arg)->cp
65 #define YYPARSE_PARAM arg
67 #line 51 "plural.y"
68 #ifndef YYSTYPE
69 typedef union {
70 unsigned long int num;
71 enum operator op;
72 struct expression *exp;
73 } yystype;
74 # define YYSTYPE yystype
75 # define YYSTYPE_IS_TRIVIAL 1
76 #endif
77 #line 57 "plural.y"
79 /* Prototypes for local functions. */
80 static int yylex (YYSTYPE *lval, const char **pexp);
81 static void yyerror (const char *str);
83 /* Allocation of expressions. */
85 static struct expression *
86 new_exp (int nargs, enum operator op, struct expression * const *args)
88 int i;
89 struct expression *newp;
91 /* If any of the argument could not be malloc'ed, just return NULL. */
92 for (i = nargs - 1; i >= 0; i--)
93 if (args[i] == NULL)
94 goto fail;
96 /* Allocate a new expression. */
97 newp = (struct expression *) malloc (sizeof (*newp));
98 if (newp != NULL)
100 newp->nargs = nargs;
101 newp->operation = op;
102 for (i = nargs - 1; i >= 0; i--)
103 newp->val.args[i] = args[i];
104 return newp;
107 fail:
108 for (i = nargs - 1; i >= 0; i--)
109 FREE_EXPRESSION (args[i]);
111 return NULL;
114 static inline struct expression *
115 new_exp_0 (enum operator op)
117 return new_exp (0, op, NULL);
120 static inline struct expression *
121 new_exp_1 (enum operator op, struct expression *right)
123 struct expression *args[1];
125 args[0] = right;
126 return new_exp (1, op, args);
129 static struct expression *
130 new_exp_2 (enum operator op, struct expression *left, struct expression *right)
132 struct expression *args[2];
134 args[0] = left;
135 args[1] = right;
136 return new_exp (2, op, args);
139 static inline struct expression *
140 new_exp_3 (enum operator op, struct expression *bexp,
141 struct expression *tbranch, struct expression *fbranch)
143 struct expression *args[3];
145 args[0] = bexp;
146 args[1] = tbranch;
147 args[2] = fbranch;
148 return new_exp (3, op, args);
151 #ifndef YYDEBUG
152 # define YYDEBUG 0
153 #endif
157 #define YYFINAL 27
158 #define YYFLAG -32768
159 #define YYNTBASE 16
161 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
162 #define YYTRANSLATE(x) ((unsigned)(x) <= 261 ? yytranslate[x] : 18)
164 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
165 static const char yytranslate[] =
167 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
168 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
169 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
170 2, 2, 2, 10, 2, 2, 2, 2, 5, 2,
171 14, 15, 2, 2, 2, 2, 2, 2, 2, 2,
172 2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
173 2, 2, 2, 3, 2, 2, 2, 2, 2, 2,
174 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
175 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
176 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
177 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
178 13, 2, 2, 2, 2, 2, 2, 2, 2, 2,
179 2, 2, 2, 2, 4, 2, 2, 2, 2, 2,
180 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
181 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
182 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
183 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
184 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
185 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
186 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
187 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
188 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
189 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
190 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
191 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
192 2, 2, 2, 2, 2, 2, 1, 6, 7, 8,
193 9, 11
196 #if YYDEBUG
197 static const short yyprhs[] =
199 0, 0, 2, 8, 12, 16, 20, 24, 28, 32,
200 35, 37, 39
202 static const short yyrhs[] =
204 17, 0, 17, 3, 17, 12, 17, 0, 17, 4,
205 17, 0, 17, 5, 17, 0, 17, 6, 17, 0,
206 17, 7, 17, 0, 17, 8, 17, 0, 17, 9,
207 17, 0, 10, 17, 0, 13, 0, 11, 0, 14,
208 17, 15, 0
211 #endif
213 #if YYDEBUG
214 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
215 static const short yyrline[] =
217 0, 152, 160, 164, 168, 172, 176, 180, 184, 188,
218 192, 196, 201
220 #endif
223 #if (YYDEBUG) || defined YYERROR_VERBOSE
225 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
226 static const char *const yytname[] =
228 "$", "error", "$undefined.", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
229 "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
230 "start", "exp", 0
232 #endif
234 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
235 static const short yyr1[] =
237 0, 16, 17, 17, 17, 17, 17, 17, 17, 17,
238 17, 17, 17
241 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
242 static const short yyr2[] =
244 0, 1, 5, 3, 3, 3, 3, 3, 3, 2,
245 1, 1, 3
248 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
249 doesn't specify something else to do. Zero means the default is an
250 error. */
251 static const short yydefact[] =
253 0, 0, 11, 10, 0, 1, 9, 0, 0, 0,
254 0, 0, 0, 0, 0, 12, 0, 3, 4, 5,
255 6, 7, 8, 0, 2, 0, 0, 0
258 static const short yydefgoto[] =
260 25, 5
263 static const short yypact[] =
265 -9, -9,-32768,-32768, -9, 34,-32768, 11, -9, -9,
266 -9, -9, -9, -9, -9,-32768, 24, 39, 43, 16,
267 26, -3,-32768, -9, 34, 21, 53,-32768
270 static const short yypgoto[] =
272 -32768, -1
276 #define YYLAST 53
279 static const short yytable[] =
281 6, 1, 2, 7, 3, 4, 14, 16, 17, 18,
282 19, 20, 21, 22, 8, 9, 10, 11, 12, 13,
283 14, 26, 24, 12, 13, 14, 15, 8, 9, 10,
284 11, 12, 13, 14, 13, 14, 23, 8, 9, 10,
285 11, 12, 13, 14, 10, 11, 12, 13, 14, 11,
286 12, 13, 14, 27
289 static const short yycheck[] =
291 1, 10, 11, 4, 13, 14, 9, 8, 9, 10,
292 11, 12, 13, 14, 3, 4, 5, 6, 7, 8,
293 9, 0, 23, 7, 8, 9, 15, 3, 4, 5,
294 6, 7, 8, 9, 8, 9, 12, 3, 4, 5,
295 6, 7, 8, 9, 5, 6, 7, 8, 9, 6,
296 7, 8, 9, 0
298 #define YYPURE 1
300 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
301 #line 3 "bison.simple"
303 /* Skeleton output parser for bison,
305 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
306 Foundation, Inc.
308 This program is free software; you can redistribute it and/or modify
309 it under the terms of the GNU General Public License as published by
310 the Free Software Foundation; either version 2, or (at your option)
311 any later version.
313 This program is distributed in the hope that it will be useful,
314 but WITHOUT ANY WARRANTY; without even the implied warranty of
315 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
316 GNU General Public License for more details.
318 You should have received a copy of the GNU General Public License
319 along with this program; if not, write to the Free Software
320 Foundation, Inc., 59 Temple Place - Suite 330,
321 Boston, MA 02111-1307, USA. */
323 /* As a special exception, when this file is copied by Bison into a
324 Bison output file, you may use that output file without restriction.
325 This special exception was added by the Free Software Foundation
326 in version 1.24 of Bison. */
328 /* This is the parser code that is written into each bison parser when
329 the %semantic_parser declaration is not specified in the grammar.
330 It was written by Richard Stallman by simplifying the hairy parser
331 used when %semantic_parser is specified. */
333 /* All symbols defined below should begin with yy or YY, to avoid
334 infringing on user name space. This should be done even for local
335 variables, as they might otherwise be expanded by user macros.
336 There are some unavoidable exceptions within include files to
337 define necessary library symbols; they are noted "INFRINGES ON
338 USER NAME SPACE" below. */
340 #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
342 /* The parser invokes alloca or malloc; define the necessary symbols. */
344 # if YYSTACK_USE_ALLOCA
345 # define YYSTACK_ALLOC alloca
346 # else
347 # ifndef YYSTACK_USE_ALLOCA
348 # if defined (alloca) || defined (_ALLOCA_H)
349 # define YYSTACK_ALLOC alloca
350 # else
351 # ifdef __GNUC__
352 # define YYSTACK_ALLOC __builtin_alloca
353 # endif
354 # endif
355 # endif
356 # endif
358 # ifdef YYSTACK_ALLOC
359 /* Pacify GCC's `empty if-body' warning. */
360 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
361 # else
362 # if defined (__STDC__) || defined (__cplusplus)
363 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
364 # define YYSIZE_T size_t
365 # endif
366 # define YYSTACK_ALLOC malloc
367 # define YYSTACK_FREE free
368 # endif
369 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
372 #if (! defined (yyoverflow) \
373 && (! defined (__cplusplus) \
374 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
376 /* A type that is properly aligned for any stack member. */
377 union yyalloc
379 short yyss;
380 YYSTYPE yyvs;
381 # if YYLSP_NEEDED
382 YYLTYPE yyls;
383 # endif
386 /* The size of the maximum gap between one aligned stack and the next. */
387 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
389 /* The size of an array large to enough to hold all stacks, each with
390 N elements. */
391 # if YYLSP_NEEDED
392 # define YYSTACK_BYTES(N) \
393 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
394 + 2 * YYSTACK_GAP_MAX)
395 # else
396 # define YYSTACK_BYTES(N) \
397 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
398 + YYSTACK_GAP_MAX)
399 # endif
401 /* Copy COUNT objects from FROM to TO. The source and destination do
402 not overlap. */
403 # ifndef YYCOPY
404 # if 1 < __GNUC__
405 # define YYCOPY(To, From, Count) \
406 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
407 # else
408 # define YYCOPY(To, From, Count) \
409 do \
411 register YYSIZE_T yyi; \
412 for (yyi = 0; yyi < (Count); yyi++) \
413 (To)[yyi] = (From)[yyi]; \
415 while (0)
416 # endif
417 # endif
419 /* Relocate STACK from its old location to the new one. The
420 local variables YYSIZE and YYSTACKSIZE give the old and new number of
421 elements in the stack, and YYPTR gives the new location of the
422 stack. Advance YYPTR to a properly aligned location for the next
423 stack. */
424 # define YYSTACK_RELOCATE(Stack) \
425 do \
427 YYSIZE_T yynewbytes; \
428 YYCOPY (&yyptr->Stack, Stack, yysize); \
429 Stack = &yyptr->Stack; \
430 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
431 yyptr += yynewbytes / sizeof (*yyptr); \
433 while (0)
435 #endif
438 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
439 # define YYSIZE_T __SIZE_TYPE__
440 #endif
441 #if ! defined (YYSIZE_T) && defined (size_t)
442 # define YYSIZE_T size_t
443 #endif
444 #if ! defined (YYSIZE_T)
445 # if defined (__STDC__) || defined (__cplusplus)
446 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
447 # define YYSIZE_T size_t
448 # endif
449 #endif
450 #if ! defined (YYSIZE_T)
451 # define YYSIZE_T unsigned int
452 #endif
454 #define yyerrok (yyerrstatus = 0)
455 #define yyclearin (yychar = YYEMPTY)
456 #define YYEMPTY -2
457 #define YYEOF 0
458 #define YYACCEPT goto yyacceptlab
459 #define YYABORT goto yyabortlab
460 #define YYERROR goto yyerrlab1
461 /* Like YYERROR except do call yyerror. This remains here temporarily
462 to ease the transition to the new meaning of YYERROR, for GCC.
463 Once GCC version 2 has supplanted version 1, this can go. */
464 #define YYFAIL goto yyerrlab
465 #define YYRECOVERING() (!!yyerrstatus)
466 #define YYBACKUP(Token, Value) \
467 do \
468 if (yychar == YYEMPTY && yylen == 1) \
470 yychar = (Token); \
471 yylval = (Value); \
472 yychar1 = YYTRANSLATE (yychar); \
473 YYPOPSTACK; \
474 goto yybackup; \
476 else \
478 yyerror ("syntax error: cannot back up"); \
479 YYERROR; \
481 while (0)
483 #define YYTERROR 1
484 #define YYERRCODE 256
487 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
488 are run).
490 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
491 first token. By default, to implement support for ranges, extend
492 its range to the last symbol. */
494 #ifndef YYLLOC_DEFAULT
495 # define YYLLOC_DEFAULT(Current, Rhs, N) \
496 Current.last_line = Rhs[N].last_line; \
497 Current.last_column = Rhs[N].last_column;
498 #endif
501 /* YYLEX -- calling `yylex' with the right arguments. */
503 #if YYPURE
504 # if YYLSP_NEEDED
505 # ifdef YYLEX_PARAM
506 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
507 # else
508 # define YYLEX yylex (&yylval, &yylloc)
509 # endif
510 # else /* !YYLSP_NEEDED */
511 # ifdef YYLEX_PARAM
512 # define YYLEX yylex (&yylval, YYLEX_PARAM)
513 # else
514 # define YYLEX yylex (&yylval)
515 # endif
516 # endif /* !YYLSP_NEEDED */
517 #else /* !YYPURE */
518 # define YYLEX yylex ()
519 #endif /* !YYPURE */
522 /* Enable debugging if requested. */
523 #if YYDEBUG
525 # ifndef YYFPRINTF
526 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
527 # define YYFPRINTF fprintf
528 # endif
530 # define YYDPRINTF(Args) \
531 do { \
532 if (yydebug) \
533 YYFPRINTF Args; \
534 } while (0)
535 /* Nonzero means print parse trace. It is left uninitialized so that
536 multiple parsers can coexist. */
537 int yydebug;
538 #else /* !YYDEBUG */
539 # define YYDPRINTF(Args)
540 #endif /* !YYDEBUG */
542 /* YYINITDEPTH -- initial size of the parser's stacks. */
543 #ifndef YYINITDEPTH
544 # define YYINITDEPTH 200
545 #endif
547 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
548 if the built-in stack extension method is used).
550 Do not make this value too large; the results are undefined if
551 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
552 evaluated with infinite-precision integer arithmetic. */
554 #if YYMAXDEPTH == 0
555 # undef YYMAXDEPTH
556 #endif
558 #ifndef YYMAXDEPTH
559 # define YYMAXDEPTH 10000
560 #endif
562 #ifdef YYERROR_VERBOSE
564 # ifndef yystrlen
565 # if defined (__GLIBC__) && defined (_STRING_H)
566 # define yystrlen strlen
567 # else
568 /* Return the length of YYSTR. */
569 static YYSIZE_T
570 # if defined (__STDC__) || defined (__cplusplus)
571 yystrlen (const char *yystr)
572 # else
573 yystrlen (yystr)
574 const char *yystr;
575 # endif
577 register const char *yys = yystr;
579 while (*yys++ != '\0')
580 continue;
582 return yys - yystr - 1;
584 # endif
585 # endif
587 # ifndef yystpcpy
588 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
589 # define yystpcpy stpcpy
590 # else
591 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
592 YYDEST. */
593 static char *
594 # if defined (__STDC__) || defined (__cplusplus)
595 yystpcpy (char *yydest, const char *yysrc)
596 # else
597 yystpcpy (yydest, yysrc)
598 char *yydest;
599 const char *yysrc;
600 # endif
602 register char *yyd = yydest;
603 register const char *yys = yysrc;
605 while ((*yyd++ = *yys++) != '\0')
606 continue;
608 return yyd - 1;
610 # endif
611 # endif
612 #endif
614 #line 315 "bison.simple"
617 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
618 into yyparse. The argument should have type void *.
619 It should actually point to an object.
620 Grammar actions can access the variable by casting it
621 to the proper pointer type. */
623 #ifdef YYPARSE_PARAM
624 # if defined (__STDC__) || defined (__cplusplus)
625 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
626 # define YYPARSE_PARAM_DECL
627 # else
628 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
629 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
630 # endif
631 #else /* !YYPARSE_PARAM */
632 # define YYPARSE_PARAM_ARG
633 # define YYPARSE_PARAM_DECL
634 #endif /* !YYPARSE_PARAM */
636 /* Prevent warning if -Wstrict-prototypes. */
637 #ifdef __GNUC__
638 # ifdef YYPARSE_PARAM
639 int yyparse (void *);
640 # else
641 int yyparse (void);
642 # endif
643 #endif
645 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
646 variables are global, or local to YYPARSE. */
648 #define YY_DECL_NON_LSP_VARIABLES \
649 /* The lookahead symbol. */ \
650 int yychar; \
652 /* The semantic value of the lookahead symbol. */ \
653 YYSTYPE yylval; \
655 /* Number of parse errors so far. */ \
656 int yynerrs;
658 #if YYLSP_NEEDED
659 # define YY_DECL_VARIABLES \
660 YY_DECL_NON_LSP_VARIABLES \
662 /* Location data for the lookahead symbol. */ \
663 YYLTYPE yylloc;
664 #else
665 # define YY_DECL_VARIABLES \
666 YY_DECL_NON_LSP_VARIABLES
667 #endif
670 /* If nonreentrant, generate the variables here. */
672 #if !YYPURE
673 YY_DECL_VARIABLES
674 #endif /* !YYPURE */
677 yyparse (YYPARSE_PARAM_ARG)
678 YYPARSE_PARAM_DECL
680 /* If reentrant, generate the variables here. */
681 #if YYPURE
682 YY_DECL_VARIABLES
683 #endif /* !YYPURE */
685 register int yystate;
686 register int yyn;
687 int yyresult;
688 /* Number of tokens to shift before error messages enabled. */
689 int yyerrstatus;
690 /* Lookahead token as an internal (translated) token number. */
691 int yychar1 = 0;
693 /* Three stacks and their tools:
694 `yyss': related to states,
695 `yyvs': related to semantic values,
696 `yyls': related to locations.
698 Refer to the stacks thru separate pointers, to allow yyoverflow
699 to reallocate them elsewhere. */
701 /* The state stack. */
702 short yyssa[YYINITDEPTH];
703 short *yyss = yyssa;
704 register short *yyssp;
706 /* The semantic value stack. */
707 YYSTYPE yyvsa[YYINITDEPTH];
708 YYSTYPE *yyvs = yyvsa;
709 register YYSTYPE *yyvsp;
711 #if YYLSP_NEEDED
712 /* The location stack. */
713 YYLTYPE yylsa[YYINITDEPTH];
714 YYLTYPE *yyls = yylsa;
715 YYLTYPE *yylsp;
716 #endif
718 #if YYLSP_NEEDED
719 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
720 #else
721 # define YYPOPSTACK (yyvsp--, yyssp--)
722 #endif
724 YYSIZE_T yystacksize = YYINITDEPTH;
727 /* The variables used to return semantic value and location from the
728 action routines. */
729 YYSTYPE yyval;
730 #if YYLSP_NEEDED
731 YYLTYPE yyloc;
732 #endif
734 /* When reducing, the number of symbols on the RHS of the reduced
735 rule. */
736 int yylen;
738 YYDPRINTF ((stderr, "Starting parse\n"));
740 yystate = 0;
741 yyerrstatus = 0;
742 yynerrs = 0;
743 yychar = YYEMPTY; /* Cause a token to be read. */
745 /* Initialize stack pointers.
746 Waste one element of value and location stack
747 so that they stay on the same level as the state stack.
748 The wasted elements are never initialized. */
750 yyssp = yyss;
751 yyvsp = yyvs;
752 #if YYLSP_NEEDED
753 yylsp = yyls;
754 #endif
755 goto yysetstate;
757 /*------------------------------------------------------------.
758 | yynewstate -- Push a new state, which is found in yystate. |
759 `------------------------------------------------------------*/
760 yynewstate:
761 /* In all cases, when you get here, the value and location stacks
762 have just been pushed. so pushing a state here evens the stacks.
764 yyssp++;
766 yysetstate:
767 *yyssp = yystate;
769 if (yyssp >= yyss + yystacksize - 1)
771 /* Get the current used size of the three stacks, in elements. */
772 YYSIZE_T yysize = yyssp - yyss + 1;
774 #ifdef yyoverflow
776 /* Give user a chance to reallocate the stack. Use copies of
777 these so that the &'s don't force the real ones into
778 memory. */
779 YYSTYPE *yyvs1 = yyvs;
780 short *yyss1 = yyss;
782 /* Each stack pointer address is followed by the size of the
783 data in use in that stack, in bytes. */
784 # if YYLSP_NEEDED
785 YYLTYPE *yyls1 = yyls;
786 /* This used to be a conditional around just the two extra args,
787 but that might be undefined if yyoverflow is a macro. */
788 yyoverflow ("parser stack overflow",
789 &yyss1, yysize * sizeof (*yyssp),
790 &yyvs1, yysize * sizeof (*yyvsp),
791 &yyls1, yysize * sizeof (*yylsp),
792 &yystacksize);
793 yyls = yyls1;
794 # else
795 yyoverflow ("parser stack overflow",
796 &yyss1, yysize * sizeof (*yyssp),
797 &yyvs1, yysize * sizeof (*yyvsp),
798 &yystacksize);
799 # endif
800 yyss = yyss1;
801 yyvs = yyvs1;
803 #else /* no yyoverflow */
804 # ifndef YYSTACK_RELOCATE
805 goto yyoverflowlab;
806 # else
807 /* Extend the stack our own way. */
808 if (yystacksize >= YYMAXDEPTH)
809 goto yyoverflowlab;
810 yystacksize *= 2;
811 if (yystacksize > YYMAXDEPTH)
812 yystacksize = YYMAXDEPTH;
815 short *yyss1 = yyss;
816 union yyalloc *yyptr =
817 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
818 if (! yyptr)
819 goto yyoverflowlab;
820 YYSTACK_RELOCATE (yyss);
821 YYSTACK_RELOCATE (yyvs);
822 # if YYLSP_NEEDED
823 YYSTACK_RELOCATE (yyls);
824 # endif
825 # undef YYSTACK_RELOCATE
826 if (yyss1 != yyssa)
827 YYSTACK_FREE (yyss1);
829 # endif
830 #endif /* no yyoverflow */
832 yyssp = yyss + yysize - 1;
833 yyvsp = yyvs + yysize - 1;
834 #if YYLSP_NEEDED
835 yylsp = yyls + yysize - 1;
836 #endif
838 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
839 (unsigned long int) yystacksize));
841 if (yyssp >= yyss + yystacksize - 1)
842 YYABORT;
845 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
847 goto yybackup;
850 /*-----------.
851 | yybackup. |
852 `-----------*/
853 yybackup:
855 /* Do appropriate processing given the current state. */
856 /* Read a lookahead token if we need one and don't already have one. */
857 /* yyresume: */
859 /* First try to decide what to do without reference to lookahead token. */
861 yyn = yypact[yystate];
862 if (yyn == YYFLAG)
863 goto yydefault;
865 /* Not known => get a lookahead token if don't already have one. */
867 /* yychar is either YYEMPTY or YYEOF
868 or a valid token in external form. */
870 if (yychar == YYEMPTY)
872 YYDPRINTF ((stderr, "Reading a token: "));
873 yychar = YYLEX;
876 /* Convert token to internal form (in yychar1) for indexing tables with */
878 if (yychar <= 0) /* This means end of input. */
880 yychar1 = 0;
881 yychar = YYEOF; /* Don't call YYLEX any more */
883 YYDPRINTF ((stderr, "Now at end of input.\n"));
885 else
887 yychar1 = YYTRANSLATE (yychar);
889 #if YYDEBUG
890 /* We have to keep this `#if YYDEBUG', since we use variables
891 which are defined only if `YYDEBUG' is set. */
892 if (yydebug)
894 YYFPRINTF (stderr, "Next token is %d (%s",
895 yychar, yytname[yychar1]);
896 /* Give the individual parser a way to print the precise
897 meaning of a token, for further debugging info. */
898 # ifdef YYPRINT
899 YYPRINT (stderr, yychar, yylval);
900 # endif
901 YYFPRINTF (stderr, ")\n");
903 #endif
906 yyn += yychar1;
907 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
908 goto yydefault;
910 yyn = yytable[yyn];
912 /* yyn is what to do for this token type in this state.
913 Negative => reduce, -yyn is rule number.
914 Positive => shift, yyn is new state.
915 New state is final state => don't bother to shift,
916 just return success.
917 0, or most negative number => error. */
919 if (yyn < 0)
921 if (yyn == YYFLAG)
922 goto yyerrlab;
923 yyn = -yyn;
924 goto yyreduce;
926 else if (yyn == 0)
927 goto yyerrlab;
929 if (yyn == YYFINAL)
930 YYACCEPT;
932 /* Shift the lookahead token. */
933 YYDPRINTF ((stderr, "Shifting token %d (%s), ",
934 yychar, yytname[yychar1]));
936 /* Discard the token being shifted unless it is eof. */
937 if (yychar != YYEOF)
938 yychar = YYEMPTY;
940 *++yyvsp = yylval;
941 #if YYLSP_NEEDED
942 *++yylsp = yylloc;
943 #endif
945 /* Count tokens shifted since error; after three, turn off error
946 status. */
947 if (yyerrstatus)
948 yyerrstatus--;
950 yystate = yyn;
951 goto yynewstate;
954 /*-----------------------------------------------------------.
955 | yydefault -- do the default action for the current state. |
956 `-----------------------------------------------------------*/
957 yydefault:
958 yyn = yydefact[yystate];
959 if (yyn == 0)
960 goto yyerrlab;
961 goto yyreduce;
964 /*-----------------------------.
965 | yyreduce -- Do a reduction. |
966 `-----------------------------*/
967 yyreduce:
968 /* yyn is the number of a rule to reduce with. */
969 yylen = yyr2[yyn];
971 /* If YYLEN is nonzero, implement the default value of the action:
972 `$$ = $1'.
974 Otherwise, the following line sets YYVAL to the semantic value of
975 the lookahead token. This behavior is undocumented and Bison
976 users should not rely upon it. Assigning to YYVAL
977 unconditionally makes the parser a bit smaller, and it avoids a
978 GCC warning that YYVAL may be used uninitialized. */
979 yyval = yyvsp[1-yylen];
981 #if YYLSP_NEEDED
982 /* Similarly for the default location. Let the user run additional
983 commands if for instance locations are ranges. */
984 yyloc = yylsp[1-yylen];
985 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
986 #endif
988 #if YYDEBUG
989 /* We have to keep this `#if YYDEBUG', since we use variables which
990 are defined only if `YYDEBUG' is set. */
991 if (yydebug)
993 int yyi;
995 YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
996 yyn, yyrline[yyn]);
998 /* Print the symbols being reduced, and their result. */
999 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
1000 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
1001 YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1003 #endif
1005 switch (yyn) {
1007 case 1:
1008 #line 153 "plural.y"
1010 if (yyvsp[0].exp == NULL)
1011 YYABORT;
1012 ((struct parse_args *) arg)->res = yyvsp[0].exp;
1014 break;
1015 case 2:
1016 #line 161 "plural.y"
1018 yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp);
1020 break;
1021 case 3:
1022 #line 165 "plural.y"
1024 yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp);
1026 break;
1027 case 4:
1028 #line 169 "plural.y"
1030 yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp);
1032 break;
1033 case 5:
1034 #line 173 "plural.y"
1036 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1038 break;
1039 case 6:
1040 #line 177 "plural.y"
1042 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1044 break;
1045 case 7:
1046 #line 181 "plural.y"
1048 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1050 break;
1051 case 8:
1052 #line 185 "plural.y"
1054 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1056 break;
1057 case 9:
1058 #line 189 "plural.y"
1060 yyval.exp = new_exp_1 (lnot, yyvsp[0].exp);
1062 break;
1063 case 10:
1064 #line 193 "plural.y"
1066 yyval.exp = new_exp_0 (var);
1068 break;
1069 case 11:
1070 #line 197 "plural.y"
1072 if ((yyval.exp = new_exp_0 (num)) != NULL)
1073 yyval.exp->val.num = yyvsp[0].num;
1075 break;
1076 case 12:
1077 #line 202 "plural.y"
1079 yyval.exp = yyvsp[-1].exp;
1081 break;
1084 #line 705 "bison.simple"
1087 yyvsp -= yylen;
1088 yyssp -= yylen;
1089 #if YYLSP_NEEDED
1090 yylsp -= yylen;
1091 #endif
1093 #if YYDEBUG
1094 if (yydebug)
1096 short *yyssp1 = yyss - 1;
1097 YYFPRINTF (stderr, "state stack now");
1098 while (yyssp1 != yyssp)
1099 YYFPRINTF (stderr, " %d", *++yyssp1);
1100 YYFPRINTF (stderr, "\n");
1102 #endif
1104 *++yyvsp = yyval;
1105 #if YYLSP_NEEDED
1106 *++yylsp = yyloc;
1107 #endif
1109 /* Now `shift' the result of the reduction. Determine what state
1110 that goes to, based on the state we popped back to and the rule
1111 number reduced by. */
1113 yyn = yyr1[yyn];
1115 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1116 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1117 yystate = yytable[yystate];
1118 else
1119 yystate = yydefgoto[yyn - YYNTBASE];
1121 goto yynewstate;
1124 /*------------------------------------.
1125 | yyerrlab -- here on detecting error |
1126 `------------------------------------*/
1127 yyerrlab:
1128 /* If not already recovering from an error, report this error. */
1129 if (!yyerrstatus)
1131 ++yynerrs;
1133 #ifdef YYERROR_VERBOSE
1134 yyn = yypact[yystate];
1136 if (yyn > YYFLAG && yyn < YYLAST)
1138 YYSIZE_T yysize = 0;
1139 char *yymsg;
1140 int yyx, yycount;
1142 yycount = 0;
1143 /* Start YYX at -YYN if negative to avoid negative indexes in
1144 YYCHECK. */
1145 for (yyx = yyn < 0 ? -yyn : 0;
1146 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1147 if (yycheck[yyx + yyn] == yyx)
1148 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1149 yysize += yystrlen ("parse error, unexpected ") + 1;
1150 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
1151 yymsg = (char *) YYSTACK_ALLOC (yysize);
1152 if (yymsg != 0)
1154 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
1155 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
1157 if (yycount < 5)
1159 yycount = 0;
1160 for (yyx = yyn < 0 ? -yyn : 0;
1161 yyx < (int) (sizeof (yytname) / sizeof (char *));
1162 yyx++)
1163 if (yycheck[yyx + yyn] == yyx)
1165 const char *yyq = ! yycount ? ", expecting " : " or ";
1166 yyp = yystpcpy (yyp, yyq);
1167 yyp = yystpcpy (yyp, yytname[yyx]);
1168 yycount++;
1171 yyerror (yymsg);
1172 YYSTACK_FREE (yymsg);
1174 else
1175 yyerror ("parse error; also virtual memory exhausted");
1177 else
1178 #endif /* defined (YYERROR_VERBOSE) */
1179 yyerror ("parse error");
1181 goto yyerrlab1;
1184 /*--------------------------------------------------.
1185 | yyerrlab1 -- error raised explicitly by an action |
1186 `--------------------------------------------------*/
1187 yyerrlab1:
1188 if (yyerrstatus == 3)
1190 /* If just tried and failed to reuse lookahead token after an
1191 error, discard it. */
1193 /* return failure if at end of input */
1194 if (yychar == YYEOF)
1195 YYABORT;
1196 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
1197 yychar, yytname[yychar1]));
1198 yychar = YYEMPTY;
1201 /* Else will try to reuse lookahead token after shifting the error
1202 token. */
1204 yyerrstatus = 3; /* Each real token shifted decrements this */
1206 goto yyerrhandle;
1209 /*-------------------------------------------------------------------.
1210 | yyerrdefault -- current state does not do anything special for the |
1211 | error token. |
1212 `-------------------------------------------------------------------*/
1213 yyerrdefault:
1214 #if 0
1215 /* This is wrong; only states that explicitly want error tokens
1216 should shift them. */
1218 /* If its default is to accept any token, ok. Otherwise pop it. */
1219 yyn = yydefact[yystate];
1220 if (yyn)
1221 goto yydefault;
1222 #endif
1225 /*---------------------------------------------------------------.
1226 | yyerrpop -- pop the current state because it cannot handle the |
1227 | error token |
1228 `---------------------------------------------------------------*/
1229 yyerrpop:
1230 if (yyssp == yyss)
1231 YYABORT;
1232 yyvsp--;
1233 yystate = *--yyssp;
1234 #if YYLSP_NEEDED
1235 yylsp--;
1236 #endif
1238 #if YYDEBUG
1239 if (yydebug)
1241 short *yyssp1 = yyss - 1;
1242 YYFPRINTF (stderr, "Error: state stack now");
1243 while (yyssp1 != yyssp)
1244 YYFPRINTF (stderr, " %d", *++yyssp1);
1245 YYFPRINTF (stderr, "\n");
1247 #endif
1249 /*--------------.
1250 | yyerrhandle. |
1251 `--------------*/
1252 yyerrhandle:
1253 yyn = yypact[yystate];
1254 if (yyn == YYFLAG)
1255 goto yyerrdefault;
1257 yyn += YYTERROR;
1258 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1259 goto yyerrdefault;
1261 yyn = yytable[yyn];
1262 if (yyn < 0)
1264 if (yyn == YYFLAG)
1265 goto yyerrpop;
1266 yyn = -yyn;
1267 goto yyreduce;
1269 else if (yyn == 0)
1270 goto yyerrpop;
1272 if (yyn == YYFINAL)
1273 YYACCEPT;
1275 YYDPRINTF ((stderr, "Shifting error token, "));
1277 *++yyvsp = yylval;
1278 #if YYLSP_NEEDED
1279 *++yylsp = yylloc;
1280 #endif
1282 yystate = yyn;
1283 goto yynewstate;
1286 /*-------------------------------------.
1287 | yyacceptlab -- YYACCEPT comes here. |
1288 `-------------------------------------*/
1289 yyacceptlab:
1290 yyresult = 0;
1291 goto yyreturn;
1293 /*-----------------------------------.
1294 | yyabortlab -- YYABORT comes here. |
1295 `-----------------------------------*/
1296 yyabortlab:
1297 yyresult = 1;
1298 goto yyreturn;
1300 /*---------------------------------------------.
1301 | yyoverflowab -- parser overflow comes here. |
1302 `---------------------------------------------*/
1303 yyoverflowlab:
1304 yyerror ("parser stack overflow");
1305 yyresult = 2;
1306 /* Fall through. */
1308 yyreturn:
1309 #ifndef yyoverflow
1310 if (yyss != yyssa)
1311 YYSTACK_FREE (yyss);
1312 #endif
1313 return yyresult;
1315 #line 207 "plural.y"
1318 void
1319 internal_function
1320 FREE_EXPRESSION (struct expression *exp)
1322 if (exp == NULL)
1323 return;
1325 /* Handle the recursive case. */
1326 switch (exp->nargs)
1328 case 3:
1329 FREE_EXPRESSION (exp->val.args[2]);
1330 /* FALLTHROUGH */
1331 case 2:
1332 FREE_EXPRESSION (exp->val.args[1]);
1333 /* FALLTHROUGH */
1334 case 1:
1335 FREE_EXPRESSION (exp->val.args[0]);
1336 /* FALLTHROUGH */
1337 default:
1338 break;
1341 free (exp);
1345 static int
1346 yylex (YYSTYPE *lval, const char **pexp)
1348 const char *exp = *pexp;
1349 int result;
1351 while (1)
1353 if (exp[0] == '\0')
1355 *pexp = exp;
1356 return YYEOF;
1359 if (exp[0] != ' ' && exp[0] != '\t')
1360 break;
1362 ++exp;
1365 result = *exp++;
1366 switch (result)
1368 case '0': case '1': case '2': case '3': case '4':
1369 case '5': case '6': case '7': case '8': case '9':
1371 unsigned long int n = result - '0';
1372 while (exp[0] >= '0' && exp[0] <= '9')
1374 n *= 10;
1375 n += exp[0] - '0';
1376 ++exp;
1378 lval->num = n;
1379 result = NUMBER;
1381 break;
1383 case '=':
1384 if (exp[0] == '=')
1386 ++exp;
1387 lval->op = equal;
1388 result = EQUOP2;
1390 else
1391 result = YYERRCODE;
1392 break;
1394 case '!':
1395 if (exp[0] == '=')
1397 ++exp;
1398 lval->op = not_equal;
1399 result = EQUOP2;
1401 break;
1403 case '&':
1404 case '|':
1405 if (exp[0] == result)
1406 ++exp;
1407 else
1408 result = YYERRCODE;
1409 break;
1411 case '<':
1412 if (exp[0] == '=')
1414 ++exp;
1415 lval->op = less_or_equal;
1417 else
1418 lval->op = less_than;
1419 result = CMPOP2;
1420 break;
1422 case '>':
1423 if (exp[0] == '=')
1425 ++exp;
1426 lval->op = greater_or_equal;
1428 else
1429 lval->op = greater_than;
1430 result = CMPOP2;
1431 break;
1433 case '*':
1434 lval->op = mult;
1435 result = MULOP2;
1436 break;
1438 case '/':
1439 lval->op = divide;
1440 result = MULOP2;
1441 break;
1443 case '%':
1444 lval->op = module;
1445 result = MULOP2;
1446 break;
1448 case '+':
1449 lval->op = plus;
1450 result = ADDOP2;
1451 break;
1453 case '-':
1454 lval->op = minus;
1455 result = ADDOP2;
1456 break;
1458 case 'n':
1459 case '?':
1460 case ':':
1461 case '(':
1462 case ')':
1463 /* Nothing, just return the character. */
1464 break;
1466 case ';':
1467 case '\n':
1468 case '\0':
1469 /* Be safe and let the user call this function again. */
1470 --exp;
1471 result = YYEOF;
1472 break;
1474 default:
1475 result = YYERRCODE;
1476 #if YYDEBUG != 0
1477 --exp;
1478 #endif
1479 break;
1482 *pexp = exp;
1484 return result;
1488 static void
1489 yyerror (const char *str)
1491 /* Do nothing. We don't print error messages here. */