1 /* A Bison parser, made from plural.y
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
21 /* Expression parsing for plural form selection.
22 Copyright (C) 2000, 2001 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)
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
40 /* The bison generated parser uses alloca. AIX 3 forces us to put this
41 declaration at the beginning of the file. The declaration in bison's
42 skeleton file comes too late. This must come before <config.h>
43 because <config.h> may include arbitrary system headers. */
44 #if defined _AIX && !defined __GNUC__
55 /* Names for the libintl functions are a problem. They must not clash
56 with existing names and they should follow ANSI C. But this source
57 code is also used in GNU C Library where the names have a __
58 prefix. So we have to make a difference here. */
60 # define FREE_EXPRESSION __gettext_free_exp
62 # define FREE_EXPRESSION gettext_free_exp__
63 # define __gettextparse gettextparse__
66 #define YYLEX_PARAM &((struct parse_args *) arg)->cp
67 #define YYPARSE_PARAM arg
72 unsigned long int num;
74 struct expression *exp;
76 # define YYSTYPE yystype
77 # define YYSTYPE_IS_TRIVIAL 1
81 /* Prototypes for local functions. */
82 static struct expression *new_exp PARAMS ((int nargs, enum operator op,
83 struct expression * const *args));
84 static inline struct expression *new_exp_0 PARAMS ((enum operator op));
85 static inline struct expression *new_exp_1 PARAMS ((enum operator op,
86 struct expression *right));
87 static struct expression *new_exp_2 PARAMS ((enum operator op,
88 struct expression *left,
89 struct expression *right));
90 static inline struct expression *new_exp_3 PARAMS ((enum operator op,
91 struct expression *bexp,
92 struct expression *tbranch,
93 struct expression *fbranch));
94 static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
95 static void yyerror PARAMS ((const char *str));
97 /* Allocation of expressions. */
99 static struct expression *
100 new_exp (nargs, op, args)
103 struct expression * const *args;
106 struct expression *newp;
108 /* If any of the argument could not be malloc'ed, just return NULL. */
109 for (i = nargs - 1; i >= 0; i--)
113 /* Allocate a new expression. */
114 newp = (struct expression *) malloc (sizeof (*newp));
118 newp->operation = op;
119 for (i = nargs - 1; i >= 0; i--)
120 newp->val.args[i] = args[i];
125 for (i = nargs - 1; i >= 0; i--)
126 FREE_EXPRESSION (args[i]);
131 static inline struct expression *
135 return new_exp (0, op, NULL);
138 static inline struct expression *
139 new_exp_1 (op, right)
141 struct expression *right;
143 struct expression *args[1];
146 return new_exp (1, op, args);
149 static struct expression *
150 new_exp_2 (op, left, right)
152 struct expression *left;
153 struct expression *right;
155 struct expression *args[2];
159 return new_exp (2, op, args);
162 static inline struct expression *
163 new_exp_3 (op, bexp, tbranch, fbranch)
165 struct expression *bexp;
166 struct expression *tbranch;
167 struct expression *fbranch;
169 struct expression *args[3];
174 return new_exp (3, op, args);
184 #define YYFLAG -32768
187 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
188 #define YYTRANSLATE(x) ((unsigned)(x) <= 261 ? yytranslate[x] : 18)
190 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
191 static const char yytranslate[] =
193 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
194 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
195 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
196 2, 2, 2, 10, 2, 2, 2, 2, 5, 2,
197 14, 15, 2, 2, 2, 2, 2, 2, 2, 2,
198 2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
199 2, 2, 2, 3, 2, 2, 2, 2, 2, 2,
200 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
201 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
202 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
203 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
204 13, 2, 2, 2, 2, 2, 2, 2, 2, 2,
205 2, 2, 2, 2, 4, 2, 2, 2, 2, 2,
206 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
207 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
208 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
209 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
210 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
211 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
212 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
213 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
214 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
215 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
216 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
217 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
218 2, 2, 2, 2, 2, 2, 1, 6, 7, 8,
223 static const short yyprhs[] =
225 0, 0, 2, 8, 12, 16, 20, 24, 28, 32,
228 static const short yyrhs[] =
230 17, 0, 17, 3, 17, 12, 17, 0, 17, 4,
231 17, 0, 17, 5, 17, 0, 17, 6, 17, 0,
232 17, 7, 17, 0, 17, 8, 17, 0, 17, 9,
233 17, 0, 10, 17, 0, 13, 0, 11, 0, 14,
240 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
241 static const short yyrline[] =
243 0, 178, 186, 190, 194, 198, 202, 206, 210, 214,
249 #if (YYDEBUG) || defined YYERROR_VERBOSE
251 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
252 static const char *const yytname[] =
254 "$", "error", "$undefined.", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
255 "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
260 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
261 static const short yyr1[] =
263 0, 16, 17, 17, 17, 17, 17, 17, 17, 17,
267 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
268 static const short yyr2[] =
270 0, 1, 5, 3, 3, 3, 3, 3, 3, 2,
274 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
275 doesn't specify something else to do. Zero means the default is an
277 static const short yydefact[] =
279 0, 0, 11, 10, 0, 1, 9, 0, 0, 0,
280 0, 0, 0, 0, 0, 12, 0, 3, 4, 5,
281 6, 7, 8, 0, 2, 0, 0, 0
284 static const short yydefgoto[] =
289 static const short yypact[] =
291 -9, -9,-32768,-32768, -9, 34,-32768, 11, -9, -9,
292 -9, -9, -9, -9, -9,-32768, 24, 39, 43, 16,
293 26, -3,-32768, -9, 34, 21, 53,-32768
296 static const short yypgoto[] =
305 static const short yytable[] =
307 6, 1, 2, 7, 3, 4, 14, 16, 17, 18,
308 19, 20, 21, 22, 8, 9, 10, 11, 12, 13,
309 14, 26, 24, 12, 13, 14, 15, 8, 9, 10,
310 11, 12, 13, 14, 13, 14, 23, 8, 9, 10,
311 11, 12, 13, 14, 10, 11, 12, 13, 14, 11,
315 static const short yycheck[] =
317 1, 10, 11, 4, 13, 14, 9, 8, 9, 10,
318 11, 12, 13, 14, 3, 4, 5, 6, 7, 8,
319 9, 0, 23, 7, 8, 9, 15, 3, 4, 5,
320 6, 7, 8, 9, 8, 9, 12, 3, 4, 5,
321 6, 7, 8, 9, 5, 6, 7, 8, 9, 6,
326 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
327 #line 3 "/sw/share/bison/bison.simple"
329 /* Skeleton output parser for bison,
331 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
334 This program is free software; you can redistribute it and/or modify
335 it under the terms of the GNU General Public License as published by
336 the Free Software Foundation; either version 2, or (at your option)
339 This program is distributed in the hope that it will be useful,
340 but WITHOUT ANY WARRANTY; without even the implied warranty of
341 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
342 GNU General Public License for more details.
344 You should have received a copy of the GNU General Public License
345 along with this program; if not, write to the Free Software
346 Foundation, Inc., 59 Temple Place - Suite 330,
347 Boston, MA 02111-1307, USA. */
349 /* As a special exception, when this file is copied by Bison into a
350 Bison output file, you may use that output file without restriction.
351 This special exception was added by the Free Software Foundation
352 in version 1.24 of Bison. */
354 /* This is the parser code that is written into each bison parser when
355 the %semantic_parser declaration is not specified in the grammar.
356 It was written by Richard Stallman by simplifying the hairy parser
357 used when %semantic_parser is specified. */
359 /* All symbols defined below should begin with yy or YY, to avoid
360 infringing on user name space. This should be done even for local
361 variables, as they might otherwise be expanded by user macros.
362 There are some unavoidable exceptions within include files to
363 define necessary library symbols; they are noted "INFRINGES ON
364 USER NAME SPACE" below. */
366 #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
368 /* The parser invokes alloca or malloc; define the necessary symbols. */
370 # if YYSTACK_USE_ALLOCA
371 # define YYSTACK_ALLOC alloca
373 # ifndef YYSTACK_USE_ALLOCA
374 # if defined (alloca) || defined (_ALLOCA_H)
375 # define YYSTACK_ALLOC alloca
378 # define YYSTACK_ALLOC __builtin_alloca
384 # ifdef YYSTACK_ALLOC
385 /* Pacify GCC's `empty if-body' warning. */
386 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
388 # if defined (__STDC__) || defined (__cplusplus)
389 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
390 # define YYSIZE_T size_t
392 # define YYSTACK_ALLOC malloc
393 # define YYSTACK_FREE free
395 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
398 #if (! defined (yyoverflow) \
399 && (! defined (__cplusplus) \
400 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
402 /* A type that is properly aligned for any stack member. */
412 /* The size of the maximum gap between one aligned stack and the next. */
413 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
415 /* The size of an array large to enough to hold all stacks, each with
418 # define YYSTACK_BYTES(N) \
419 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
420 + 2 * YYSTACK_GAP_MAX)
422 # define YYSTACK_BYTES(N) \
423 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
427 /* Copy COUNT objects from FROM to TO. The source and destination do
431 # define YYCOPY(To, From, Count) \
432 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
434 # define YYCOPY(To, From, Count) \
437 register YYSIZE_T yyi; \
438 for (yyi = 0; yyi < (Count); yyi++) \
439 (To)[yyi] = (From)[yyi]; \
445 /* Relocate STACK from its old location to the new one. The
446 local variables YYSIZE and YYSTACKSIZE give the old and new number of
447 elements in the stack, and YYPTR gives the new location of the
448 stack. Advance YYPTR to a properly aligned location for the next
450 # define YYSTACK_RELOCATE(Stack) \
453 YYSIZE_T yynewbytes; \
454 YYCOPY (&yyptr->Stack, Stack, yysize); \
455 Stack = &yyptr->Stack; \
456 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
457 yyptr += yynewbytes / sizeof (*yyptr); \
464 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
465 # define YYSIZE_T __SIZE_TYPE__
467 #if ! defined (YYSIZE_T) && defined (size_t)
468 # define YYSIZE_T size_t
470 #if ! defined (YYSIZE_T)
471 # if defined (__STDC__) || defined (__cplusplus)
472 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
473 # define YYSIZE_T size_t
476 #if ! defined (YYSIZE_T)
477 # define YYSIZE_T unsigned int
480 #define yyerrok (yyerrstatus = 0)
481 #define yyclearin (yychar = YYEMPTY)
484 #define YYACCEPT goto yyacceptlab
485 #define YYABORT goto yyabortlab
486 #define YYERROR goto yyerrlab1
487 /* Like YYERROR except do call yyerror. This remains here temporarily
488 to ease the transition to the new meaning of YYERROR, for GCC.
489 Once GCC version 2 has supplanted version 1, this can go. */
490 #define YYFAIL goto yyerrlab
491 #define YYRECOVERING() (!!yyerrstatus)
492 #define YYBACKUP(Token, Value) \
494 if (yychar == YYEMPTY && yylen == 1) \
498 yychar1 = YYTRANSLATE (yychar); \
504 yyerror ("syntax error: cannot back up"); \
510 #define YYERRCODE 256
513 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
516 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
517 first token. By default, to implement support for ranges, extend
518 its range to the last symbol. */
520 #ifndef YYLLOC_DEFAULT
521 # define YYLLOC_DEFAULT(Current, Rhs, N) \
522 Current.last_line = Rhs[N].last_line; \
523 Current.last_column = Rhs[N].last_column;
527 /* YYLEX -- calling `yylex' with the right arguments. */
532 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
534 # define YYLEX yylex (&yylval, &yylloc)
536 # else /* !YYLSP_NEEDED */
538 # define YYLEX yylex (&yylval, YYLEX_PARAM)
540 # define YYLEX yylex (&yylval)
542 # endif /* !YYLSP_NEEDED */
544 # define YYLEX yylex ()
548 /* Enable debugging if requested. */
552 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
553 # define YYFPRINTF fprintf
556 # define YYDPRINTF(Args) \
561 /* Nonzero means print parse trace. It is left uninitialized so that
562 multiple parsers can coexist. */
565 # define YYDPRINTF(Args)
566 #endif /* !YYDEBUG */
568 /* YYINITDEPTH -- initial size of the parser's stacks. */
570 # define YYINITDEPTH 200
573 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
574 if the built-in stack extension method is used).
576 Do not make this value too large; the results are undefined if
577 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
578 evaluated with infinite-precision integer arithmetic. */
585 # define YYMAXDEPTH 10000
588 #ifdef YYERROR_VERBOSE
591 # if defined (__GLIBC__) && defined (_STRING_H)
592 # define yystrlen strlen
594 /* Return the length of YYSTR. */
596 # if defined (__STDC__) || defined (__cplusplus)
597 yystrlen (const char *yystr)
603 register const char *yys = yystr;
605 while (*yys++ != '\0')
608 return yys - yystr - 1;
614 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
615 # define yystpcpy stpcpy
617 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
620 # if defined (__STDC__) || defined (__cplusplus)
621 yystpcpy (char *yydest, const char *yysrc)
623 yystpcpy (yydest, yysrc)
628 register char *yyd = yydest;
629 register const char *yys = yysrc;
631 while ((*yyd++ = *yys++) != '\0')
640 #line 315 "/sw/share/bison/bison.simple"
643 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
644 into yyparse. The argument should have type void *.
645 It should actually point to an object.
646 Grammar actions can access the variable by casting it
647 to the proper pointer type. */
650 # if defined (__STDC__) || defined (__cplusplus)
651 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
652 # define YYPARSE_PARAM_DECL
654 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
655 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
657 #else /* !YYPARSE_PARAM */
658 # define YYPARSE_PARAM_ARG
659 # define YYPARSE_PARAM_DECL
660 #endif /* !YYPARSE_PARAM */
662 /* Prevent warning if -Wstrict-prototypes. */
664 # ifdef YYPARSE_PARAM
665 int yyparse (void *);
671 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
672 variables are global, or local to YYPARSE. */
674 #define YY_DECL_NON_LSP_VARIABLES \
675 /* The lookahead symbol. */ \
678 /* The semantic value of the lookahead symbol. */ \
681 /* Number of parse errors so far. */ \
685 # define YY_DECL_VARIABLES \
686 YY_DECL_NON_LSP_VARIABLES \
688 /* Location data for the lookahead symbol. */ \
691 # define YY_DECL_VARIABLES \
692 YY_DECL_NON_LSP_VARIABLES
696 /* If nonreentrant, generate the variables here. */
703 yyparse (YYPARSE_PARAM_ARG)
706 /* If reentrant, generate the variables here. */
711 register int yystate;
714 /* Number of tokens to shift before error messages enabled. */
716 /* Lookahead token as an internal (translated) token number. */
719 /* Three stacks and their tools:
720 `yyss': related to states,
721 `yyvs': related to semantic values,
722 `yyls': related to locations.
724 Refer to the stacks thru separate pointers, to allow yyoverflow
725 to reallocate them elsewhere. */
727 /* The state stack. */
728 short yyssa[YYINITDEPTH];
730 register short *yyssp;
732 /* The semantic value stack. */
733 YYSTYPE yyvsa[YYINITDEPTH];
734 YYSTYPE *yyvs = yyvsa;
735 register YYSTYPE *yyvsp;
738 /* The location stack. */
739 YYLTYPE yylsa[YYINITDEPTH];
740 YYLTYPE *yyls = yylsa;
745 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
747 # define YYPOPSTACK (yyvsp--, yyssp--)
750 YYSIZE_T yystacksize = YYINITDEPTH;
753 /* The variables used to return semantic value and location from the
760 /* When reducing, the number of symbols on the RHS of the reduced
764 YYDPRINTF ((stderr, "Starting parse\n"));
769 yychar = YYEMPTY; /* Cause a token to be read. */
771 /* Initialize stack pointers.
772 Waste one element of value and location stack
773 so that they stay on the same level as the state stack.
774 The wasted elements are never initialized. */
783 /*------------------------------------------------------------.
784 | yynewstate -- Push a new state, which is found in yystate. |
785 `------------------------------------------------------------*/
787 /* In all cases, when you get here, the value and location stacks
788 have just been pushed. so pushing a state here evens the stacks.
795 if (yyssp >= yyss + yystacksize - 1)
797 /* Get the current used size of the three stacks, in elements. */
798 YYSIZE_T yysize = yyssp - yyss + 1;
802 /* Give user a chance to reallocate the stack. Use copies of
803 these so that the &'s don't force the real ones into
805 YYSTYPE *yyvs1 = yyvs;
808 /* Each stack pointer address is followed by the size of the
809 data in use in that stack, in bytes. */
811 YYLTYPE *yyls1 = yyls;
812 /* This used to be a conditional around just the two extra args,
813 but that might be undefined if yyoverflow is a macro. */
814 yyoverflow ("parser stack overflow",
815 &yyss1, yysize * sizeof (*yyssp),
816 &yyvs1, yysize * sizeof (*yyvsp),
817 &yyls1, yysize * sizeof (*yylsp),
821 yyoverflow ("parser stack overflow",
822 &yyss1, yysize * sizeof (*yyssp),
823 &yyvs1, yysize * sizeof (*yyvsp),
829 #else /* no yyoverflow */
830 # ifndef YYSTACK_RELOCATE
833 /* Extend the stack our own way. */
834 if (yystacksize >= YYMAXDEPTH)
837 if (yystacksize > YYMAXDEPTH)
838 yystacksize = YYMAXDEPTH;
842 union yyalloc *yyptr =
843 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
846 YYSTACK_RELOCATE (yyss);
847 YYSTACK_RELOCATE (yyvs);
849 YYSTACK_RELOCATE (yyls);
851 # undef YYSTACK_RELOCATE
853 YYSTACK_FREE (yyss1);
856 #endif /* no yyoverflow */
858 yyssp = yyss + yysize - 1;
859 yyvsp = yyvs + yysize - 1;
861 yylsp = yyls + yysize - 1;
864 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
865 (unsigned long int) yystacksize));
867 if (yyssp >= yyss + yystacksize - 1)
871 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
881 /* Do appropriate processing given the current state. */
882 /* Read a lookahead token if we need one and don't already have one. */
885 /* First try to decide what to do without reference to lookahead token. */
887 yyn = yypact[yystate];
891 /* Not known => get a lookahead token if don't already have one. */
893 /* yychar is either YYEMPTY or YYEOF
894 or a valid token in external form. */
896 if (yychar == YYEMPTY)
898 YYDPRINTF ((stderr, "Reading a token: "));
902 /* Convert token to internal form (in yychar1) for indexing tables with */
904 if (yychar <= 0) /* This means end of input. */
907 yychar = YYEOF; /* Don't call YYLEX any more */
909 YYDPRINTF ((stderr, "Now at end of input.\n"));
913 yychar1 = YYTRANSLATE (yychar);
916 /* We have to keep this `#if YYDEBUG', since we use variables
917 which are defined only if `YYDEBUG' is set. */
920 YYFPRINTF (stderr, "Next token is %d (%s",
921 yychar, yytname[yychar1]);
922 /* Give the individual parser a way to print the precise
923 meaning of a token, for further debugging info. */
925 YYPRINT (stderr, yychar, yylval);
927 YYFPRINTF (stderr, ")\n");
933 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
938 /* yyn is what to do for this token type in this state.
939 Negative => reduce, -yyn is rule number.
940 Positive => shift, yyn is new state.
941 New state is final state => don't bother to shift,
943 0, or most negative number => error. */
958 /* Shift the lookahead token. */
959 YYDPRINTF ((stderr, "Shifting token %d (%s), ",
960 yychar, yytname[yychar1]));
962 /* Discard the token being shifted unless it is eof. */
971 /* Count tokens shifted since error; after three, turn off error
980 /*-----------------------------------------------------------.
981 | yydefault -- do the default action for the current state. |
982 `-----------------------------------------------------------*/
984 yyn = yydefact[yystate];
990 /*-----------------------------.
991 | yyreduce -- Do a reduction. |
992 `-----------------------------*/
994 /* yyn is the number of a rule to reduce with. */
997 /* If YYLEN is nonzero, implement the default value of the action:
1000 Otherwise, the following line sets YYVAL to the semantic value of
1001 the lookahead token. This behavior is undocumented and Bison
1002 users should not rely upon it. Assigning to YYVAL
1003 unconditionally makes the parser a bit smaller, and it avoids a
1004 GCC warning that YYVAL may be used uninitialized. */
1005 yyval = yyvsp[1-yylen];
1008 /* Similarly for the default location. Let the user run additional
1009 commands if for instance locations are ranges. */
1010 yyloc = yylsp[1-yylen];
1011 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1015 /* We have to keep this `#if YYDEBUG', since we use variables which
1016 are defined only if `YYDEBUG' is set. */
1021 YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
1024 /* Print the symbols being reduced, and their result. */
1025 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
1026 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
1027 YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1034 #line 179 "plural.y"
1036 if (yyvsp[0].exp == NULL)
1038 ((struct parse_args *) arg)->res = yyvsp[0].exp;
1042 #line 187 "plural.y"
1044 yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp);
1048 #line 191 "plural.y"
1050 yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp);
1054 #line 195 "plural.y"
1056 yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp);
1060 #line 199 "plural.y"
1062 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1066 #line 203 "plural.y"
1068 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1072 #line 207 "plural.y"
1074 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1078 #line 211 "plural.y"
1080 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1084 #line 215 "plural.y"
1086 yyval.exp = new_exp_1 (lnot, yyvsp[0].exp);
1090 #line 219 "plural.y"
1092 yyval.exp = new_exp_0 (var);
1096 #line 223 "plural.y"
1098 if ((yyval.exp = new_exp_0 (num)) != NULL)
1099 yyval.exp->val.num = yyvsp[0].num;
1103 #line 228 "plural.y"
1105 yyval.exp = yyvsp[-1].exp;
1110 #line 705 "/sw/share/bison/bison.simple"
1122 short *yyssp1 = yyss - 1;
1123 YYFPRINTF (stderr, "state stack now");
1124 while (yyssp1 != yyssp)
1125 YYFPRINTF (stderr, " %d", *++yyssp1);
1126 YYFPRINTF (stderr, "\n");
1135 /* Now `shift' the result of the reduction. Determine what state
1136 that goes to, based on the state we popped back to and the rule
1137 number reduced by. */
1141 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1142 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1143 yystate = yytable[yystate];
1145 yystate = yydefgoto[yyn - YYNTBASE];
1150 /*------------------------------------.
1151 | yyerrlab -- here on detecting error |
1152 `------------------------------------*/
1154 /* If not already recovering from an error, report this error. */
1159 #ifdef YYERROR_VERBOSE
1160 yyn = yypact[yystate];
1162 if (yyn > YYFLAG && yyn < YYLAST)
1164 YYSIZE_T yysize = 0;
1169 /* Start YYX at -YYN if negative to avoid negative indexes in
1171 for (yyx = yyn < 0 ? -yyn : 0;
1172 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1173 if (yycheck[yyx + yyn] == yyx)
1174 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1175 yysize += yystrlen ("parse error, unexpected ") + 1;
1176 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
1177 yymsg = (char *) YYSTACK_ALLOC (yysize);
1180 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
1181 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
1186 for (yyx = yyn < 0 ? -yyn : 0;
1187 yyx < (int) (sizeof (yytname) / sizeof (char *));
1189 if (yycheck[yyx + yyn] == yyx)
1191 const char *yyq = ! yycount ? ", expecting " : " or ";
1192 yyp = yystpcpy (yyp, yyq);
1193 yyp = yystpcpy (yyp, yytname[yyx]);
1198 YYSTACK_FREE (yymsg);
1201 yyerror ("parse error; also virtual memory exhausted");
1204 #endif /* defined (YYERROR_VERBOSE) */
1205 yyerror ("parse error");
1210 /*--------------------------------------------------.
1211 | yyerrlab1 -- error raised explicitly by an action |
1212 `--------------------------------------------------*/
1214 if (yyerrstatus == 3)
1216 /* If just tried and failed to reuse lookahead token after an
1217 error, discard it. */
1219 /* return failure if at end of input */
1220 if (yychar == YYEOF)
1222 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
1223 yychar, yytname[yychar1]));
1227 /* Else will try to reuse lookahead token after shifting the error
1230 yyerrstatus = 3; /* Each real token shifted decrements this */
1235 /*-------------------------------------------------------------------.
1236 | yyerrdefault -- current state does not do anything special for the |
1238 `-------------------------------------------------------------------*/
1241 /* This is wrong; only states that explicitly want error tokens
1242 should shift them. */
1244 /* If its default is to accept any token, ok. Otherwise pop it. */
1245 yyn = yydefact[yystate];
1251 /*---------------------------------------------------------------.
1252 | yyerrpop -- pop the current state because it cannot handle the |
1254 `---------------------------------------------------------------*/
1267 short *yyssp1 = yyss - 1;
1268 YYFPRINTF (stderr, "Error: state stack now");
1269 while (yyssp1 != yyssp)
1270 YYFPRINTF (stderr, " %d", *++yyssp1);
1271 YYFPRINTF (stderr, "\n");
1279 yyn = yypact[yystate];
1284 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1301 YYDPRINTF ((stderr, "Shifting error token, "));
1312 /*-------------------------------------.
1313 | yyacceptlab -- YYACCEPT comes here. |
1314 `-------------------------------------*/
1319 /*-----------------------------------.
1320 | yyabortlab -- YYABORT comes here. |
1321 `-----------------------------------*/
1326 /*---------------------------------------------.
1327 | yyoverflowab -- parser overflow comes here. |
1328 `---------------------------------------------*/
1330 yyerror ("parser stack overflow");
1337 YYSTACK_FREE (yyss);
1341 #line 233 "plural.y"
1346 FREE_EXPRESSION (exp)
1347 struct expression *exp;
1352 /* Handle the recursive case. */
1356 FREE_EXPRESSION (exp->val.args[2]);
1359 FREE_EXPRESSION (exp->val.args[1]);
1362 FREE_EXPRESSION (exp->val.args[0]);
1377 const char *exp = *pexp;
1388 if (exp[0] != ' ' && exp[0] != '\t')
1397 case '0': case '1': case '2': case '3': case '4':
1398 case '5': case '6': case '7': case '8': case '9':
1400 unsigned long int n = result - '0';
1401 while (exp[0] >= '0' && exp[0] <= '9')
1427 lval->op = not_equal;
1434 if (exp[0] == result)
1444 lval->op = less_or_equal;
1447 lval->op = less_than;
1455 lval->op = greater_or_equal;
1458 lval->op = greater_than;
1492 /* Nothing, just return the character. */
1498 /* Be safe and let the user call this function again. */
1521 /* Do nothing. We don't print error messages here. */