1 /* A Bison parser, made by GNU Bison 1.875a. */
3 /* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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)
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. */
40 #define YYSKELETON_NAME "yacc.c"
45 /* Using locations. */
46 #define YYLSP_NEEDED 0
48 /* If NAME_PREFIX is specified substitute the variables and functions
50 #define yyparse __gettextparse
51 #define yylex __gettextlex
52 #define yyerror __gettexterror
53 #define yylval __gettextlval
54 #define yychar __gettextchar
55 #define yydebug __gettextdebug
56 #define yynerrs __gettextnerrs
62 /* Put the tokens into the symbol table, so that GDB and other debuggers
81 /* Copy the first part of user declarations. */
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 it
89 under the terms of the GNU Library General Public License as published
90 by the Free Software Foundation; either version 2, or (at your option)
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 GNU
96 Library General Public License for more details.
98 You should have received a copy of the GNU Library General Public
99 License along with this program; if not, write to the Free Software
100 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
103 /* The bison generated parser uses alloca. AIX 3 forces us to put this
104 declaration at the beginning of the file. The declaration in bison's
105 skeleton file comes too late. This must come before <config.h>
106 because <config.h> may include arbitrary system headers. */
107 #if defined _AIX && !defined __GNUC__
116 #include "gettextP.h"
118 /* Names for the libintl functions are a problem. They must not clash
119 with existing names and they should follow ANSI C. But this source
120 code is also used in GNU C Library where the names have a __
121 prefix. So we have to make a difference here. */
123 # define FREE_EXPRESSION __gettext_free_exp
125 # define FREE_EXPRESSION gettext_free_exp__
126 # define __gettextparse gettextparse__
129 #define YYLEX_PARAM &((struct parse_args *) arg)->cp
130 #define YYPARSE_PARAM arg
133 /* Enabling traces. */
138 /* Enabling verbose error messages. */
139 #ifdef YYERROR_VERBOSE
140 # undef YYERROR_VERBOSE
141 # define YYERROR_VERBOSE 1
143 # define YYERROR_VERBOSE 0
146 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
148 typedef union YYSTYPE {
149 unsigned long int num;
151 struct expression *exp;
153 /* Line 191 of yacc.c. */
155 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
156 # define YYSTYPE_IS_DECLARED 1
157 # define YYSTYPE_IS_TRIVIAL 1
162 /* Copy the second part of user declarations. */
165 /* Prototypes for local functions. */
166 static struct expression *new_exp PARAMS ((int nargs, enum operator op,
167 struct expression * const *args));
168 static inline struct expression *new_exp_0 PARAMS ((enum operator op));
169 static inline struct expression *new_exp_1 PARAMS ((enum operator op,
170 struct expression *right));
171 static struct expression *new_exp_2 PARAMS ((enum operator op,
172 struct expression *left,
173 struct expression *right));
174 static inline struct expression *new_exp_3 PARAMS ((enum operator op,
175 struct expression *bexp,
176 struct expression *tbranch,
177 struct expression *fbranch));
178 static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
179 static void yyerror PARAMS ((const char *str));
181 /* Allocation of expressions. */
183 static struct expression *
184 new_exp (nargs, op, args)
187 struct expression * const *args;
190 struct expression *newp;
192 /* If any of the argument could not be malloc'ed, just return NULL. */
193 for (i = nargs - 1; i >= 0; i--)
197 /* Allocate a new expression. */
198 newp = (struct expression *) malloc (sizeof (*newp));
202 newp->operation = op;
203 for (i = nargs - 1; i >= 0; i--)
204 newp->val.args[i] = args[i];
209 for (i = nargs - 1; i >= 0; i--)
210 FREE_EXPRESSION (args[i]);
215 static inline struct expression *
219 return new_exp (0, op, NULL);
222 static inline struct expression *
223 new_exp_1 (op, right)
225 struct expression *right;
227 struct expression *args[1];
230 return new_exp (1, op, args);
233 static struct expression *
234 new_exp_2 (op, left, right)
236 struct expression *left;
237 struct expression *right;
239 struct expression *args[2];
243 return new_exp (2, op, args);
246 static inline struct expression *
247 new_exp_3 (op, bexp, tbranch, fbranch)
249 struct expression *bexp;
250 struct expression *tbranch;
251 struct expression *fbranch;
253 struct expression *args[3];
258 return new_exp (3, op, args);
263 /* Line 214 of yacc.c. */
266 #if ! defined (yyoverflow) || YYERROR_VERBOSE
268 /* The parser invokes alloca or malloc; define the necessary symbols. */
270 # if YYSTACK_USE_ALLOCA
271 # define YYSTACK_ALLOC alloca
273 # ifndef YYSTACK_USE_ALLOCA
274 # if defined (alloca) || defined (_ALLOCA_H)
275 # define YYSTACK_ALLOC alloca
278 # define YYSTACK_ALLOC __builtin_alloca
284 # ifdef YYSTACK_ALLOC
285 /* Pacify GCC's `empty if-body' warning. */
286 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
288 # if defined (__STDC__) || defined (__cplusplus)
289 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
290 # define YYSIZE_T size_t
292 # define YYSTACK_ALLOC malloc
293 # define YYSTACK_FREE free
295 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
298 #if (! defined (yyoverflow) \
299 && (! defined (__cplusplus) \
300 || (YYSTYPE_IS_TRIVIAL)))
302 /* A type that is properly aligned for any stack member. */
309 /* The size of the maximum gap between one aligned stack and the next. */
310 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
312 /* The size of an array large to enough to hold all stacks, each with
314 # define YYSTACK_BYTES(N) \
315 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
316 + YYSTACK_GAP_MAXIMUM)
318 /* Copy COUNT objects from FROM to TO. The source and destination do
322 # define YYCOPY(To, From, Count) \
323 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
325 # define YYCOPY(To, From, Count) \
328 register YYSIZE_T yyi; \
329 for (yyi = 0; yyi < (Count); yyi++) \
330 (To)[yyi] = (From)[yyi]; \
336 /* Relocate STACK from its old location to the new one. The
337 local variables YYSIZE and YYSTACKSIZE give the old and new number of
338 elements in the stack, and YYPTR gives the new location of the
339 stack. Advance YYPTR to a properly aligned location for the next
341 # define YYSTACK_RELOCATE(Stack) \
344 YYSIZE_T yynewbytes; \
345 YYCOPY (&yyptr->Stack, Stack, yysize); \
346 Stack = &yyptr->Stack; \
347 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
348 yyptr += yynewbytes / sizeof (*yyptr); \
354 #if defined (__STDC__) || defined (__cplusplus)
355 typedef signed char yysigned_char;
357 typedef short yysigned_char;
360 /* YYFINAL -- State number of the termination state. */
362 /* YYLAST -- Last index in YYTABLE. */
365 /* YYNTOKENS -- Number of terminals. */
367 /* YYNNTS -- Number of nonterminals. */
369 /* YYNRULES -- Number of rules. */
371 /* YYNRULES -- Number of states. */
374 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
376 #define YYMAXUTOK 262
378 #define YYTRANSLATE(YYX) \
379 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
381 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
382 static const unsigned char yytranslate[] =
384 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
385 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
386 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
387 2, 2, 2, 10, 2, 2, 2, 2, 5, 2,
388 14, 15, 2, 2, 2, 2, 2, 2, 2, 2,
389 2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
390 2, 2, 2, 3, 2, 2, 2, 2, 2, 2,
391 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
392 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
393 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
394 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
395 13, 2, 2, 2, 2, 2, 2, 2, 2, 2,
396 2, 2, 2, 2, 4, 2, 2, 2, 2, 2,
397 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
398 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
399 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
400 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
401 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
402 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
403 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
404 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
405 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
406 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
407 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
408 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
409 2, 2, 2, 2, 2, 2, 1, 2, 6, 7,
414 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
416 static const unsigned char yyprhs[] =
418 0, 0, 3, 5, 11, 15, 19, 23, 27, 31,
422 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
423 static const yysigned_char yyrhs[] =
425 17, 0, -1, 18, -1, 18, 3, 18, 12, 18,
426 -1, 18, 4, 18, -1, 18, 5, 18, -1, 18,
427 6, 18, -1, 18, 7, 18, -1, 18, 8, 18,
428 -1, 18, 9, 18, -1, 10, 18, -1, 13, -1,
429 11, -1, 14, 18, 15, -1
432 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
433 static const unsigned char yyrline[] =
435 0, 178, 178, 186, 190, 194, 198, 202, 206, 210,
440 #if YYDEBUG || YYERROR_VERBOSE
441 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
442 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
443 static const char *const yytname[] =
445 "$end", "error", "$undefined", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
446 "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
447 "$accept", "start", "exp", 0
452 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
454 static const unsigned short yytoknum[] =
456 0, 256, 257, 63, 124, 38, 258, 259, 260, 261,
457 33, 262, 58, 110, 40, 41
461 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
462 static const unsigned char yyr1[] =
464 0, 16, 17, 18, 18, 18, 18, 18, 18, 18,
468 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
469 static const unsigned char yyr2[] =
471 0, 2, 1, 5, 3, 3, 3, 3, 3, 3,
475 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
476 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
477 means the default is an error. */
478 static const unsigned char yydefact[] =
480 0, 0, 12, 11, 0, 0, 2, 10, 0, 1,
481 0, 0, 0, 0, 0, 0, 0, 13, 0, 4,
485 /* YYDEFGOTO[NTERM-NUM]. */
486 static const yysigned_char yydefgoto[] =
491 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
493 #define YYPACT_NINF -10
494 static const yysigned_char yypact[] =
496 -9, -9, -10, -10, -9, 8, 36, -10, 13, -10,
497 -9, -9, -9, -9, -9, -9, -9, -10, 26, 41,
498 45, 18, -2, 14, -10, -9, 36
501 /* YYPGOTO[NTERM-NUM]. */
502 static const yysigned_char yypgoto[] =
507 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
508 positive, shift that token. If negative, reduce the rule which
509 number is the opposite. If zero, do what YYDEFACT says.
510 If YYTABLE_NINF, syntax error. */
511 #define YYTABLE_NINF -1
512 static const unsigned char yytable[] =
514 7, 1, 2, 8, 3, 4, 15, 16, 9, 18,
515 19, 20, 21, 22, 23, 24, 10, 11, 12, 13,
516 14, 15, 16, 16, 26, 14, 15, 16, 17, 10,
517 11, 12, 13, 14, 15, 16, 0, 0, 25, 10,
518 11, 12, 13, 14, 15, 16, 12, 13, 14, 15,
522 static const yysigned_char yycheck[] =
524 1, 10, 11, 4, 13, 14, 8, 9, 0, 10,
525 11, 12, 13, 14, 15, 16, 3, 4, 5, 6,
526 7, 8, 9, 9, 25, 7, 8, 9, 15, 3,
527 4, 5, 6, 7, 8, 9, -1, -1, 12, 3,
528 4, 5, 6, 7, 8, 9, 5, 6, 7, 8,
532 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
533 symbol of state STATE-NUM. */
534 static const unsigned char yystos[] =
536 0, 10, 11, 13, 14, 17, 18, 18, 18, 0,
537 3, 4, 5, 6, 7, 8, 9, 15, 18, 18,
538 18, 18, 18, 18, 18, 12, 18
541 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
542 # define YYSIZE_T __SIZE_TYPE__
544 #if ! defined (YYSIZE_T) && defined (size_t)
545 # define YYSIZE_T size_t
547 #if ! defined (YYSIZE_T)
548 # if defined (__STDC__) || defined (__cplusplus)
549 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
550 # define YYSIZE_T size_t
553 #if ! defined (YYSIZE_T)
554 # define YYSIZE_T unsigned int
557 #define yyerrok (yyerrstatus = 0)
558 #define yyclearin (yychar = YYEMPTY)
562 #define YYACCEPT goto yyacceptlab
563 #define YYABORT goto yyabortlab
564 #define YYERROR goto yyerrlab1
567 /* Like YYERROR except do call yyerror. This remains here temporarily
568 to ease the transition to the new meaning of YYERROR, for GCC.
569 Once GCC version 2 has supplanted version 1, this can go. */
571 #define YYFAIL goto yyerrlab
573 #define YYRECOVERING() (!!yyerrstatus)
575 #define YYBACKUP(Token, Value) \
577 if (yychar == YYEMPTY && yylen == 1) \
581 yytoken = YYTRANSLATE (yychar); \
587 yyerror ("syntax error: cannot back up");\
593 #define YYERRCODE 256
595 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
598 #ifndef YYLLOC_DEFAULT
599 # define YYLLOC_DEFAULT(Current, Rhs, N) \
600 Current.first_line = Rhs[1].first_line; \
601 Current.first_column = Rhs[1].first_column; \
602 Current.last_line = Rhs[N].last_line; \
603 Current.last_column = Rhs[N].last_column;
606 /* YYLEX -- calling `yylex' with the right arguments. */
609 # define YYLEX yylex (&yylval, YYLEX_PARAM)
611 # define YYLEX yylex (&yylval)
614 /* Enable debugging if requested. */
618 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
619 # define YYFPRINTF fprintf
622 # define YYDPRINTF(Args) \
628 # define YYDSYMPRINT(Args) \
634 # define YYDSYMPRINTF(Title, Token, Value, Location) \
638 YYFPRINTF (stderr, "%s ", Title); \
639 yysymprint (stderr, \
641 YYFPRINTF (stderr, "\n"); \
645 /*------------------------------------------------------------------.
646 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
648 `------------------------------------------------------------------*/
650 #if defined (__STDC__) || defined (__cplusplus)
652 yy_stack_print (short *bottom, short *top)
655 yy_stack_print (bottom, top)
660 YYFPRINTF (stderr, "Stack now");
661 for (/* Nothing. */; bottom <= top; ++bottom)
662 YYFPRINTF (stderr, " %d", *bottom);
663 YYFPRINTF (stderr, "\n");
666 # define YY_STACK_PRINT(Bottom, Top) \
669 yy_stack_print ((Bottom), (Top)); \
673 /*------------------------------------------------.
674 | Report that the YYRULE is going to be reduced. |
675 `------------------------------------------------*/
677 #if defined (__STDC__) || defined (__cplusplus)
679 yy_reduce_print (int yyrule)
682 yy_reduce_print (yyrule)
687 unsigned int yylineno = yyrline[yyrule];
688 YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
689 yyrule - 1, yylineno);
690 /* Print the symbols being reduced, and their result. */
691 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
692 YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
693 YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
696 # define YY_REDUCE_PRINT(Rule) \
699 yy_reduce_print (Rule); \
702 /* Nonzero means print parse trace. It is left uninitialized so that
703 multiple parsers can coexist. */
706 # define YYDPRINTF(Args)
707 # define YYDSYMPRINT(Args)
708 # define YYDSYMPRINTF(Title, Token, Value, Location)
709 # define YY_STACK_PRINT(Bottom, Top)
710 # define YY_REDUCE_PRINT(Rule)
711 #endif /* !YYDEBUG */
714 /* YYINITDEPTH -- initial size of the parser's stacks. */
716 # define YYINITDEPTH 200
719 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
720 if the built-in stack extension method is used).
722 Do not make this value too large; the results are undefined if
723 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
724 evaluated with infinite-precision integer arithmetic. */
731 # define YYMAXDEPTH 10000
739 # if defined (__GLIBC__) && defined (_STRING_H)
740 # define yystrlen strlen
742 /* Return the length of YYSTR. */
744 # if defined (__STDC__) || defined (__cplusplus)
745 yystrlen (const char *yystr)
751 register const char *yys = yystr;
753 while (*yys++ != '\0')
756 return yys - yystr - 1;
762 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
763 # define yystpcpy stpcpy
765 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
768 # if defined (__STDC__) || defined (__cplusplus)
769 yystpcpy (char *yydest, const char *yysrc)
771 yystpcpy (yydest, yysrc)
776 register char *yyd = yydest;
777 register const char *yys = yysrc;
779 while ((*yyd++ = *yys++) != '\0')
787 #endif /* !YYERROR_VERBOSE */
792 /*--------------------------------.
793 | Print this symbol on YYOUTPUT. |
794 `--------------------------------*/
796 #if defined (__STDC__) || defined (__cplusplus)
798 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
801 yysymprint (yyoutput, yytype, yyvaluep)
807 /* Pacify ``unused variable'' warnings. */
810 if (yytype < YYNTOKENS)
812 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
814 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
818 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
825 YYFPRINTF (yyoutput, ")");
828 #endif /* ! YYDEBUG */
829 /*-----------------------------------------------.
830 | Release the memory associated to this symbol. |
831 `-----------------------------------------------*/
833 #if defined (__STDC__) || defined (__cplusplus)
835 yydestruct (int yytype, YYSTYPE *yyvaluep)
838 yydestruct (yytype, yyvaluep)
843 /* Pacify ``unused variable'' warnings. */
855 /* Prevent warnings from -Wmissing-prototypes. */
858 # if defined (__STDC__) || defined (__cplusplus)
859 int yyparse (void *YYPARSE_PARAM);
863 #else /* ! YYPARSE_PARAM */
864 #if defined (__STDC__) || defined (__cplusplus)
869 #endif /* ! YYPARSE_PARAM */
881 # if defined (__STDC__) || defined (__cplusplus)
882 int yyparse (void *YYPARSE_PARAM)
884 int yyparse (YYPARSE_PARAM)
887 #else /* ! YYPARSE_PARAM */
888 #if defined (__STDC__) || defined (__cplusplus)
898 /* The lookahead symbol. */
901 /* The semantic value of the lookahead symbol. */
904 /* Number of syntax errors so far. */
907 register int yystate;
910 /* Number of tokens to shift before error messages enabled. */
912 /* Lookahead token as an internal (translated) token number. */
915 /* Three stacks and their tools:
916 `yyss': related to states,
917 `yyvs': related to semantic values,
918 `yyls': related to locations.
920 Refer to the stacks thru separate pointers, to allow yyoverflow
921 to reallocate them elsewhere. */
923 /* The state stack. */
924 short yyssa[YYINITDEPTH];
926 register short *yyssp;
928 /* The semantic value stack. */
929 YYSTYPE yyvsa[YYINITDEPTH];
930 YYSTYPE *yyvs = yyvsa;
931 register YYSTYPE *yyvsp;
935 #define YYPOPSTACK (yyvsp--, yyssp--)
937 YYSIZE_T yystacksize = YYINITDEPTH;
939 /* The variables used to return semantic value and location from the
944 /* When reducing, the number of symbols on the RHS of the reduced
948 YYDPRINTF ((stderr, "Starting parse\n"));
953 yychar = YYEMPTY; /* Cause a token to be read. */
955 /* Initialize stack pointers.
956 Waste one element of value and location stack
957 so that they stay on the same level as the state stack.
958 The wasted elements are never initialized. */
965 /*------------------------------------------------------------.
966 | yynewstate -- Push a new state, which is found in yystate. |
967 `------------------------------------------------------------*/
969 /* In all cases, when you get here, the value and location stacks
970 have just been pushed. so pushing a state here evens the stacks.
977 if (yyss + yystacksize - 1 <= yyssp)
979 /* Get the current used size of the three stacks, in elements. */
980 YYSIZE_T yysize = yyssp - yyss + 1;
984 /* Give user a chance to reallocate the stack. Use copies of
985 these so that the &'s don't force the real ones into
987 YYSTYPE *yyvs1 = yyvs;
991 /* Each stack pointer address is followed by the size of the
992 data in use in that stack, in bytes. This used to be a
993 conditional around just the two extra args, but that might
994 be undefined if yyoverflow is a macro. */
995 yyoverflow ("parser stack overflow",
996 &yyss1, yysize * sizeof (*yyssp),
997 &yyvs1, yysize * sizeof (*yyvsp),
1004 #else /* no yyoverflow */
1005 # ifndef YYSTACK_RELOCATE
1008 /* Extend the stack our own way. */
1009 if (YYMAXDEPTH <= yystacksize)
1012 if (YYMAXDEPTH < yystacksize)
1013 yystacksize = YYMAXDEPTH;
1016 short *yyss1 = yyss;
1017 union yyalloc *yyptr =
1018 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1021 YYSTACK_RELOCATE (yyss);
1022 YYSTACK_RELOCATE (yyvs);
1024 # undef YYSTACK_RELOCATE
1026 YYSTACK_FREE (yyss1);
1029 #endif /* no yyoverflow */
1031 yyssp = yyss + yysize - 1;
1032 yyvsp = yyvs + yysize - 1;
1035 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1036 (unsigned long int) yystacksize));
1038 if (yyss + yystacksize - 1 <= yyssp)
1042 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1051 /* Do appropriate processing given the current state. */
1052 /* Read a lookahead token if we need one and don't already have one. */
1055 /* First try to decide what to do without reference to lookahead token. */
1057 yyn = yypact[yystate];
1058 if (yyn == YYPACT_NINF)
1061 /* Not known => get a lookahead token if don't already have one. */
1063 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1064 if (yychar == YYEMPTY)
1066 YYDPRINTF ((stderr, "Reading a token: "));
1070 if (yychar <= YYEOF)
1072 yychar = yytoken = YYEOF;
1073 YYDPRINTF ((stderr, "Now at end of input.\n"));
1077 yytoken = YYTRANSLATE (yychar);
1078 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
1081 /* If the proper action on seeing token YYTOKEN is to reduce or to
1082 detect an error, take that action. */
1084 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1089 if (yyn == 0 || yyn == YYTABLE_NINF)
1098 /* Shift the lookahead token. */
1099 YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
1101 /* Discard the token being shifted unless it is eof. */
1102 if (yychar != YYEOF)
1108 /* Count tokens shifted since error; after three, turn off error
1117 /*-----------------------------------------------------------.
1118 | yydefault -- do the default action for the current state. |
1119 `-----------------------------------------------------------*/
1121 yyn = yydefact[yystate];
1127 /*-----------------------------.
1128 | yyreduce -- Do a reduction. |
1129 `-----------------------------*/
1131 /* yyn is the number of a rule to reduce with. */
1134 /* If YYLEN is nonzero, implement the default value of the action:
1137 Otherwise, the following line sets YYVAL to garbage.
1138 This behavior is undocumented and Bison
1139 users should not rely upon it. Assigning to YYVAL
1140 unconditionally makes the parser a bit smaller, and it avoids a
1141 GCC warning that YYVAL may be used uninitialized. */
1142 yyval = yyvsp[1-yylen];
1145 YY_REDUCE_PRINT (yyn);
1149 #line 179 "plural.y"
1151 if (yyvsp[0].exp == NULL)
1153 ((struct parse_args *) arg)->res = yyvsp[0].exp;
1158 #line 187 "plural.y"
1160 yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp);
1165 #line 191 "plural.y"
1167 yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp);
1172 #line 195 "plural.y"
1174 yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp);
1179 #line 199 "plural.y"
1181 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1186 #line 203 "plural.y"
1188 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1193 #line 207 "plural.y"
1195 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1200 #line 211 "plural.y"
1202 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1207 #line 215 "plural.y"
1209 yyval.exp = new_exp_1 (lnot, yyvsp[0].exp);
1214 #line 219 "plural.y"
1216 yyval.exp = new_exp_0 (var);
1221 #line 223 "plural.y"
1223 if ((yyval.exp = new_exp_0 (num)) != NULL)
1224 yyval.exp->val.num = yyvsp[0].num;
1229 #line 228 "plural.y"
1231 yyval.exp = yyvsp[-1].exp;
1238 /* Line 999 of yacc.c. */
1239 #line 1240 "plural.c"
1245 YY_STACK_PRINT (yyss, yyssp);
1250 /* Now `shift' the result of the reduction. Determine what state
1251 that goes to, based on the state we popped back to and the rule
1252 number reduced by. */
1256 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1257 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1258 yystate = yytable[yystate];
1260 yystate = yydefgoto[yyn - YYNTOKENS];
1265 /*------------------------------------.
1266 | yyerrlab -- here on detecting error |
1267 `------------------------------------*/
1269 /* If not already recovering from an error, report this error. */
1274 yyn = yypact[yystate];
1276 if (YYPACT_NINF < yyn && yyn < YYLAST)
1278 YYSIZE_T yysize = 0;
1279 int yytype = YYTRANSLATE (yychar);
1284 /* Start YYX at -YYN if negative to avoid negative indexes in
1286 for (yyx = yyn < 0 ? -yyn : 0;
1287 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1288 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1289 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1290 yysize += yystrlen ("syntax error, unexpected ") + 1;
1291 yysize += yystrlen (yytname[yytype]);
1292 yymsg = (char *) YYSTACK_ALLOC (yysize);
1295 char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
1296 yyp = yystpcpy (yyp, yytname[yytype]);
1301 for (yyx = yyn < 0 ? -yyn : 0;
1302 yyx < (int) (sizeof (yytname) / sizeof (char *));
1304 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1306 const char *yyq = ! yycount ? ", expecting " : " or ";
1307 yyp = yystpcpy (yyp, yyq);
1308 yyp = yystpcpy (yyp, yytname[yyx]);
1313 YYSTACK_FREE (yymsg);
1316 yyerror ("syntax error; also virtual memory exhausted");
1319 #endif /* YYERROR_VERBOSE */
1320 yyerror ("syntax error");
1325 if (yyerrstatus == 3)
1327 /* If just tried and failed to reuse lookahead token after an
1328 error, discard it. */
1330 /* Return failure if at end of input. */
1331 if (yychar == YYEOF)
1333 /* Pop the error token. */
1335 /* Pop the rest of the stack. */
1336 while (yyss < yyssp)
1338 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1339 yydestruct (yystos[*yyssp], yyvsp);
1345 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
1346 yydestruct (yytoken, &yylval);
1351 /* Else will try to reuse lookahead token after shifting the error
1356 /*----------------------------------------------------.
1357 | yyerrlab1 -- error raised explicitly by an action. |
1358 `----------------------------------------------------*/
1360 yyerrstatus = 3; /* Each real token shifted decrements this. */
1364 yyn = yypact[yystate];
1365 if (yyn != YYPACT_NINF)
1368 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1376 /* Pop the current state because it cannot handle the error token. */
1380 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1381 yydestruct (yystos[yystate], yyvsp);
1385 YY_STACK_PRINT (yyss, yyssp);
1391 YYDPRINTF ((stderr, "Shifting error token, "));
1400 /*-------------------------------------.
1401 | yyacceptlab -- YYACCEPT comes here. |
1402 `-------------------------------------*/
1407 /*-----------------------------------.
1408 | yyabortlab -- YYABORT comes here. |
1409 `-----------------------------------*/
1415 /*----------------------------------------------.
1416 | yyoverflowlab -- parser overflow comes here. |
1417 `----------------------------------------------*/
1419 yyerror ("parser stack overflow");
1427 YYSTACK_FREE (yyss);
1433 #line 233 "plural.y"
1438 FREE_EXPRESSION (exp)
1439 struct expression *exp;
1444 /* Handle the recursive case. */
1448 FREE_EXPRESSION (exp->val.args[2]);
1451 FREE_EXPRESSION (exp->val.args[1]);
1454 FREE_EXPRESSION (exp->val.args[0]);
1469 const char *exp = *pexp;
1480 if (exp[0] != ' ' && exp[0] != '\t')
1489 case '0': case '1': case '2': case '3': case '4':
1490 case '5': case '6': case '7': case '8': case '9':
1492 unsigned long int n = result - '0';
1493 while (exp[0] >= '0' && exp[0] <= '9')
1519 lval->op = not_equal;
1526 if (exp[0] == result)
1536 lval->op = less_or_equal;
1539 lval->op = less_than;
1547 lval->op = greater_or_equal;
1550 lval->op = greater_than;
1584 /* Nothing, just return the character. */
1590 /* Be safe and let the user call this function again. */
1613 /* Do nothing. We don't print error messages here. */