1 
2 /*  A Bison parser, made from plural.y
3     by GNU Bison version 1.28  */
4 
5 #define YYBISON 1  /* Identify Bison output.  */
6 
7 #define yyparse __gettextparse
8 #define yylex __gettextlex
9 #define yyerror __gettexterror
10 #define yylval __gettextlval
11 #define yychar __gettextchar
12 #define yydebug __gettextdebug
13 #define yynerrs __gettextnerrs
14 #define	EQUOP2	257
15 #define	CMPOP2	258
16 #define	ADDOP2	259
17 #define	MULOP2	260
18 #define	NUMBER	261
19 
20 #line 1 "plural.y"
21 
22 /* Expression parsing for plural form selection.
23    Copyright (C) 2000, 2001 Free Software Foundation, Inc.
24    Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
25 
26    This program is free software; you can redistribute it and/or modify it
27    under the terms of the GNU Library General Public License as published
28    by the Free Software Foundation; either version 2, or (at your option)
29    any later version.
30 
31    This program is distributed in the hope that it will be useful,
32    but WITHOUT ANY WARRANTY; without even the implied warranty of
33    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
34    Library General Public License for more details.
35 
36    You should have received a copy of the GNU Library General Public
37    License along with this program; if not, write to the Free Software
38    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
39    USA.  */
40 
41 /* The bison generated parser uses alloca.  AIX 3 forces us to put this
42    declaration at the beginning of the file.  The declaration in bison's
43    skeleton file comes too late.  This must come before <config.h>
44    because <config.h> may include arbitrary system headers.  */
45 #if defined _AIX && !defined __GNUC__
46  #pragma alloca
47 #endif
48 
49 #ifdef HAVE_CONFIG_H
50 # include <config.h>
51 #endif
52 
53 #include <stdlib.h>
54 #include "gettextP.h"
55 
56 /* Names for the libintl functions are a problem.  They must not clash
57    with existing names and they should follow ANSI C.  But this source
58    code is also used in GNU C Library where the names have a __
59    prefix.  So we have to make a difference here.  */
60 #ifdef _LIBC
61 # define FREE_EXPRESSION __gettext_free_exp
62 #else
63 # define FREE_EXPRESSION gettext_free_exp__
64 # define __gettextparse gettextparse__
65 #endif
66 
67 #define YYLEX_PARAM	&((struct parse_args *) arg)->cp
68 #define YYPARSE_PARAM	arg
69 
70 #line 53 "plural.y"
71 typedef union {
72   unsigned long int num;
73   enum operator op;
74   struct expression *exp;
75 } YYSTYPE;
76 #line 59 "plural.y"
77 
78 /* Prototypes for local functions.  */
79 static struct expression *new_exp PARAMS ((int nargs, enum operator op,
80 					   struct expression * const *args));
81 static inline struct expression *new_exp_0 PARAMS ((enum operator op));
82 static inline struct expression *new_exp_1 PARAMS ((enum operator op,
83 						   struct expression *right));
84 static struct expression *new_exp_2 PARAMS ((enum operator op,
85 					     struct expression *left,
86 					     struct expression *right));
87 static inline struct expression *new_exp_3 PARAMS ((enum operator op,
88 						   struct expression *bexp,
89 						   struct expression *tbranch,
90 						   struct expression *fbranch));
91 static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
92 static void yyerror PARAMS ((const char *str));
93 
94 /* Allocation of expressions.  */
95 
96 static struct expression *
new_exp(nargs,op,args)97 new_exp (nargs, op, args)
98      int nargs;
99      enum operator op;
100      struct expression * const *args;
101 {
102   int i;
103   struct expression *newp;
104 
105   /* If any of the argument could not be malloc'ed, just return NULL.  */
106   for (i = nargs - 1; i >= 0; i--)
107     if (args[i] == NULL)
108       goto fail;
109 
110   /* Allocate a new expression.  */
111   newp = (struct expression *) malloc (sizeof (*newp));
112   if (newp != NULL)
113     {
114       newp->nargs = nargs;
115       newp->operation = op;
116       for (i = nargs - 1; i >= 0; i--)
117 	newp->val.args[i] = args[i];
118       return newp;
119     }
120 
121  fail:
122   for (i = nargs - 1; i >= 0; i--)
123     FREE_EXPRESSION (args[i]);
124 
125   return NULL;
126 }
127 
128 static inline struct expression *
new_exp_0(op)129 new_exp_0 (op)
130      enum operator op;
131 {
132   return new_exp (0, op, NULL);
133 }
134 
135 static inline struct expression *
new_exp_1(op,right)136 new_exp_1 (op, right)
137      enum operator op;
138      struct expression *right;
139 {
140   struct expression *args[1];
141 
142   args[0] = right;
143   return new_exp (1, op, args);
144 }
145 
146 static struct expression *
new_exp_2(op,left,right)147 new_exp_2 (op, left, right)
148      enum operator op;
149      struct expression *left;
150      struct expression *right;
151 {
152   struct expression *args[2];
153 
154   args[0] = left;
155   args[1] = right;
156   return new_exp (2, op, args);
157 }
158 
159 static inline struct expression *
new_exp_3(op,bexp,tbranch,fbranch)160 new_exp_3 (op, bexp, tbranch, fbranch)
161      enum operator op;
162      struct expression *bexp;
163      struct expression *tbranch;
164      struct expression *fbranch;
165 {
166   struct expression *args[3];
167 
168   args[0] = bexp;
169   args[1] = tbranch;
170   args[2] = fbranch;
171   return new_exp (3, op, args);
172 }
173 
174 #include <stdio.h>
175 
176 #ifndef __cplusplus
177 #ifndef __STDC__
178 #define const
179 #endif
180 #endif
181 
182 
183 
184 #define	YYFINAL		27
185 #define	YYFLAG		-32768
186 #define	YYNTBASE	16
187 
188 #define YYTRANSLATE(x) ((unsigned)(x) <= 261 ? yytranslate[x] : 18)
189 
190 static const char yytranslate[] = {     0,
191      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
192      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
193      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
194      2,     2,    10,     2,     2,     2,     2,     5,     2,    14,
195     15,     2,     2,     2,     2,     2,     2,     2,     2,     2,
196      2,     2,     2,     2,     2,     2,     2,    12,     2,     2,
197      2,     2,     3,     2,     2,     2,     2,     2,     2,     2,
198      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
199      2,     2,     2,     2,     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,    13,
202      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
203      2,     2,     2,     4,     2,     2,     2,     2,     2,     2,
204      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
205      2,     2,     2,     2,     2,     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,     1,     6,     7,     8,     9,
217     11
218 };
219 
220 #if YYDEBUG != 0
221 static const short yyprhs[] = {     0,
222      0,     2,     8,    12,    16,    20,    24,    28,    32,    35,
223     37,    39
224 };
225 
226 static const short yyrhs[] = {    17,
227      0,    17,     3,    17,    12,    17,     0,    17,     4,    17,
228      0,    17,     5,    17,     0,    17,     6,    17,     0,    17,
229      7,    17,     0,    17,     8,    17,     0,    17,     9,    17,
230      0,    10,    17,     0,    13,     0,    11,     0,    14,    17,
231     15,     0
232 };
233 
234 #endif
235 
236 #if YYDEBUG != 0
237 static const short yyrline[] = { 0,
238    178,   186,   190,   194,   198,   202,   206,   210,   214,   218,
239    222,   227
240 };
241 #endif
242 
243 
244 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
245 
246 static const char * const yytname[] = {   "$","error","$undefined.","'?'","'|'",
247 "'&'","EQUOP2","CMPOP2","ADDOP2","MULOP2","'!'","NUMBER","':'","'n'","'('","')'",
248 "start","exp", NULL
249 };
250 #endif
251 
252 static const short yyr1[] = {     0,
253     16,    17,    17,    17,    17,    17,    17,    17,    17,    17,
254     17,    17
255 };
256 
257 static const short yyr2[] = {     0,
258      1,     5,     3,     3,     3,     3,     3,     3,     2,     1,
259      1,     3
260 };
261 
262 static const short yydefact[] = {     0,
263      0,    11,    10,     0,     1,     9,     0,     0,     0,     0,
264      0,     0,     0,     0,    12,     0,     3,     4,     5,     6,
265      7,     8,     0,     2,     0,     0,     0
266 };
267 
268 static const short yydefgoto[] = {    25,
269      5
270 };
271 
272 static const short yypact[] = {    -9,
273     -9,-32768,-32768,    -9,    34,-32768,    11,    -9,    -9,    -9,
274     -9,    -9,    -9,    -9,-32768,    24,    39,    43,    16,    26,
275     -3,-32768,    -9,    34,    21,    53,-32768
276 };
277 
278 static const short yypgoto[] = {-32768,
279     -1
280 };
281 
282 
283 #define	YYLAST		53
284 
285 
286 static const short yytable[] = {     6,
287      1,     2,     7,     3,     4,    14,    16,    17,    18,    19,
288     20,    21,    22,     8,     9,    10,    11,    12,    13,    14,
289     26,    24,    12,    13,    14,    15,     8,     9,    10,    11,
290     12,    13,    14,    13,    14,    23,     8,     9,    10,    11,
291     12,    13,    14,    10,    11,    12,    13,    14,    11,    12,
292     13,    14,    27
293 };
294 
295 static const short yycheck[] = {     1,
296     10,    11,     4,    13,    14,     9,     8,     9,    10,    11,
297     12,    13,    14,     3,     4,     5,     6,     7,     8,     9,
298      0,    23,     7,     8,     9,    15,     3,     4,     5,     6,
299      7,     8,     9,     8,     9,    12,     3,     4,     5,     6,
300      7,     8,     9,     5,     6,     7,     8,     9,     6,     7,
301      8,     9,     0
302 };
303 #define YYPURE 1
304 
305 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
306 #line 3 "/home/haible/gnu/arch/linuxlibc6/share/bison.simple"
307 /* This file comes from bison-1.28.  */
308 
309 /* Skeleton output parser for bison,
310    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
311 
312    This program is free software; you can redistribute it and/or modify
313    it under the terms of the GNU General Public License as published by
314    the Free Software Foundation; either version 2, or (at your option)
315    any later version.
316 
317    This program is distributed in the hope that it will be useful,
318    but WITHOUT ANY WARRANTY; without even the implied warranty of
319    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
320    GNU General Public License for more details.
321 
322    You should have received a copy of the GNU General Public License
323    along with this program; if not, write to the Free Software
324    Foundation, Inc., 59 Temple Place - Suite 330,
325    Boston, MA 02111-1307, USA.  */
326 
327 /* As a special exception, when this file is copied by Bison into a
328    Bison output file, you may use that output file without restriction.
329    This special exception was added by the Free Software Foundation
330    in version 1.24 of Bison.  */
331 
332 /* This is the parser code that is written into each bison parser
333   when the %semantic_parser declaration is not specified in the grammar.
334   It was written by Richard Stallman by simplifying the hairy parser
335   used when %semantic_parser is specified.  */
336 
337 #ifndef YYSTACK_USE_ALLOCA
338 #ifdef alloca
339 #define YYSTACK_USE_ALLOCA
340 #else /* alloca not defined */
341 #ifdef __GNUC__
342 #define YYSTACK_USE_ALLOCA
343 #define alloca __builtin_alloca
344 #else /* not GNU C.  */
345 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
346 #define YYSTACK_USE_ALLOCA
347 #include <alloca.h>
348 #else /* not sparc */
349 /* We think this test detects Watcom and Microsoft C.  */
350 /* This used to test MSDOS, but that is a bad idea
351    since that symbol is in the user namespace.  */
352 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
353 #if 0 /* No need for malloc.h, which pollutes the namespace;
354 	 instead, just don't use alloca.  */
355 #include <malloc.h>
356 #endif
357 #else /* not MSDOS, or __TURBOC__ */
358 #if defined(_AIX)
359 /* I don't know what this was needed for, but it pollutes the namespace.
360    So I turned it off.   rms, 2 May 1997.  */
361 /* #include <malloc.h>  */
362  #pragma alloca
363 #define YYSTACK_USE_ALLOCA
364 #else /* not MSDOS, or __TURBOC__, or _AIX */
365 #if 0
366 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
367 		 and on HPUX 10.  Eventually we can turn this on.  */
368 #define YYSTACK_USE_ALLOCA
369 #define alloca __builtin_alloca
370 #endif /* __hpux */
371 #endif
372 #endif /* not _AIX */
373 #endif /* not MSDOS, or __TURBOC__ */
374 #endif /* not sparc */
375 #endif /* not GNU C */
376 #endif /* alloca not defined */
377 #endif /* YYSTACK_USE_ALLOCA not defined */
378 
379 #ifdef YYSTACK_USE_ALLOCA
380 #define YYSTACK_ALLOC alloca
381 #else
382 #define YYSTACK_ALLOC malloc
383 #endif
384 
385 /* Note: there must be only one dollar sign in this file.
386    It is replaced by the list of actions, each action
387    as one case of the switch.  */
388 
389 #define yyerrok		(yyerrstatus = 0)
390 #define yyclearin	(yychar = YYEMPTY)
391 #define YYEMPTY		-2
392 #define YYEOF		0
393 #define YYACCEPT	goto yyacceptlab
394 #define YYABORT 	goto yyabortlab
395 #define YYERROR		goto yyerrlab1
396 /* Like YYERROR except do call yyerror.
397    This remains here temporarily to ease the
398    transition to the new meaning of YYERROR, for GCC.
399    Once GCC version 2 has supplanted version 1, this can go.  */
400 #define YYFAIL		goto yyerrlab
401 #define YYRECOVERING()  (!!yyerrstatus)
402 #define YYBACKUP(token, value) \
403 do								\
404   if (yychar == YYEMPTY && yylen == 1)				\
405     { yychar = (token), yylval = (value);			\
406       yychar1 = YYTRANSLATE (yychar);				\
407       YYPOPSTACK;						\
408       goto yybackup;						\
409     }								\
410   else								\
411     { yyerror ("syntax error: cannot back up"); YYERROR; }	\
412 while (0)
413 
414 #define YYTERROR	1
415 #define YYERRCODE	256
416 
417 #ifndef YYPURE
418 #define YYLEX		yylex()
419 #endif
420 
421 #ifdef YYPURE
422 #ifdef YYLSP_NEEDED
423 #ifdef YYLEX_PARAM
424 #define YYLEX		yylex(&yylval, &yylloc, YYLEX_PARAM)
425 #else
426 #define YYLEX		yylex(&yylval, &yylloc)
427 #endif
428 #else /* not YYLSP_NEEDED */
429 #ifdef YYLEX_PARAM
430 #define YYLEX		yylex(&yylval, YYLEX_PARAM)
431 #else
432 #define YYLEX		yylex(&yylval)
433 #endif
434 #endif /* not YYLSP_NEEDED */
435 #endif
436 
437 /* If nonreentrant, generate the variables here */
438 
439 #ifndef YYPURE
440 
441 int	yychar;			/*  the lookahead symbol		*/
442 YYSTYPE	yylval;			/*  the semantic value of the		*/
443 				/*  lookahead symbol			*/
444 
445 #ifdef YYLSP_NEEDED
446 YYLTYPE yylloc;			/*  location data for the lookahead	*/
447 				/*  symbol				*/
448 #endif
449 
450 int yynerrs;			/*  number of parse errors so far       */
451 #endif  /* not YYPURE */
452 
453 #if YYDEBUG != 0
454 int yydebug;			/*  nonzero means print parse trace	*/
455 /* Since this is uninitialized, it does not stop multiple parsers
456    from coexisting.  */
457 #endif
458 
459 /*  YYINITDEPTH indicates the initial size of the parser's stacks	*/
460 
461 #ifndef	YYINITDEPTH
462 #define YYINITDEPTH 200
463 #endif
464 
465 /*  YYMAXDEPTH is the maximum size the stacks can grow to
466     (effective only if the built-in stack extension method is used).  */
467 
468 #if YYMAXDEPTH == 0
469 #undef YYMAXDEPTH
470 #endif
471 
472 #ifndef YYMAXDEPTH
473 #define YYMAXDEPTH 10000
474 #endif
475 
476 /* Define __yy_memcpy.  Note that the size argument
477    should be passed with type unsigned int, because that is what the non-GCC
478    definitions require.  With GCC, __builtin_memcpy takes an arg
479    of type size_t, but it can handle unsigned int.  */
480 
481 #if __GNUC__ > 1		/* GNU C and GNU C++ define this.  */
482 #define __yy_memcpy(TO,FROM,COUNT)	__builtin_memcpy(TO,FROM,COUNT)
483 #else				/* not GNU C or C++ */
484 #ifndef __cplusplus
485 
486 /* This is the most reliable way to avoid incompatibilities
487    in available built-in functions on various systems.  */
488 static void
__yy_memcpy(to,from,count)489 __yy_memcpy (to, from, count)
490      char *to;
491      char *from;
492      unsigned int count;
493 {
494   register char *f = from;
495   register char *t = to;
496   register int i = count;
497 
498   while (i-- > 0)
499     *t++ = *f++;
500 }
501 
502 #else /* __cplusplus */
503 
504 /* This is the most reliable way to avoid incompatibilities
505    in available built-in functions on various systems.  */
506 static void
__yy_memcpy(char * to,char * from,unsigned int count)507 __yy_memcpy (char *to, char *from, unsigned int count)
508 {
509   register char *t = to;
510   register char *f = from;
511   register int i = count;
512 
513   while (i-- > 0)
514     *t++ = *f++;
515 }
516 
517 #endif
518 #endif
519 
520 #line 217 "/home/haible/gnu/arch/linuxlibc6/share/bison.simple"
521 
522 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
523    into yyparse.  The argument should have type void *.
524    It should actually point to an object.
525    Grammar actions can access the variable by casting it
526    to the proper pointer type.  */
527 
528 #ifdef YYPARSE_PARAM
529 #ifdef __cplusplus
530 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
531 #define YYPARSE_PARAM_DECL
532 #else /* not __cplusplus */
533 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
534 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
535 #endif /* not __cplusplus */
536 #else /* not YYPARSE_PARAM */
537 #define YYPARSE_PARAM_ARG
538 #define YYPARSE_PARAM_DECL
539 #endif /* not YYPARSE_PARAM */
540 
541 /* Prevent warning if -Wstrict-prototypes.  */
542 #ifdef __GNUC__
543 #ifdef YYPARSE_PARAM
544 int yyparse (void *);
545 #else
546 int yyparse (void);
547 #endif
548 #endif
549 
550 int
yyparse(YYPARSE_PARAM_ARG)551 yyparse(YYPARSE_PARAM_ARG)
552      YYPARSE_PARAM_DECL
553 {
554   register int yystate;
555   register int yyn;
556   register short *yyssp;
557   register YYSTYPE *yyvsp;
558   int yyerrstatus;	/*  number of tokens to shift before error messages enabled */
559   int yychar1 = 0;		/*  lookahead token as an internal (translated) token number */
560 
561   short	yyssa[YYINITDEPTH];	/*  the state stack			*/
562   YYSTYPE yyvsa[YYINITDEPTH];	/*  the semantic value stack		*/
563 
564   short *yyss = yyssa;		/*  refer to the stacks thru separate pointers */
565   YYSTYPE *yyvs = yyvsa;	/*  to allow yyoverflow to reallocate them elsewhere */
566 
567 #ifdef YYLSP_NEEDED
568   YYLTYPE yylsa[YYINITDEPTH];	/*  the location stack			*/
569   YYLTYPE *yyls = yylsa;
570   YYLTYPE *yylsp;
571 
572 #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
573 #else
574 #define YYPOPSTACK   (yyvsp--, yyssp--)
575 #endif
576 
577   int yystacksize = YYINITDEPTH;
578   int yyfree_stacks = 0;
579 
580 #ifdef YYPURE
581   int yychar;
582   YYSTYPE yylval;
583   int yynerrs;
584 #ifdef YYLSP_NEEDED
585   YYLTYPE yylloc;
586 #endif
587 #endif
588 
589   YYSTYPE yyval;		/*  the variable used to return		*/
590 				/*  semantic values from the action	*/
591 				/*  routines				*/
592 
593   int yylen;
594 
595 #if YYDEBUG != 0
596   if (yydebug)
597     fprintf(stderr, "Starting parse\n");
598 #endif
599 
600   yystate = 0;
601   yyerrstatus = 0;
602   yynerrs = 0;
603   yychar = YYEMPTY;		/* Cause a token to be read.  */
604 
605   /* Initialize stack pointers.
606      Waste one element of value and location stack
607      so that they stay on the same level as the state stack.
608      The wasted elements are never initialized.  */
609 
610   yyssp = yyss - 1;
611   yyvsp = yyvs;
612 #ifdef YYLSP_NEEDED
613   yylsp = yyls;
614 #endif
615 
616 /* Push a new state, which is found in  yystate  .  */
617 /* In all cases, when you get here, the value and location stacks
618    have just been pushed. so pushing a state here evens the stacks.  */
619 yynewstate:
620 
621   *++yyssp = yystate;
622 
623   if (yyssp >= yyss + yystacksize - 1)
624     {
625       /* Give user a chance to reallocate the stack */
626       /* Use copies of these so that the &'s don't force the real ones into memory. */
627       YYSTYPE *yyvs1 = yyvs;
628       short *yyss1 = yyss;
629 #ifdef YYLSP_NEEDED
630       YYLTYPE *yyls1 = yyls;
631 #endif
632 
633       /* Get the current used size of the three stacks, in elements.  */
634       int size = yyssp - yyss + 1;
635 
636 #ifdef yyoverflow
637       /* Each stack pointer address is followed by the size of
638 	 the data in use in that stack, in bytes.  */
639 #ifdef YYLSP_NEEDED
640       /* This used to be a conditional around just the two extra args,
641 	 but that might be undefined if yyoverflow is a macro.  */
642       yyoverflow("parser stack overflow",
643 		 &yyss1, size * sizeof (*yyssp),
644 		 &yyvs1, size * sizeof (*yyvsp),
645 		 &yyls1, size * sizeof (*yylsp),
646 		 &yystacksize);
647 #else
648       yyoverflow("parser stack overflow",
649 		 &yyss1, size * sizeof (*yyssp),
650 		 &yyvs1, size * sizeof (*yyvsp),
651 		 &yystacksize);
652 #endif
653 
654       yyss = yyss1; yyvs = yyvs1;
655 #ifdef YYLSP_NEEDED
656       yyls = yyls1;
657 #endif
658 #else /* no yyoverflow */
659       /* Extend the stack our own way.  */
660       if (yystacksize >= YYMAXDEPTH)
661 	{
662 	  yyerror("parser stack overflow");
663 	  if (yyfree_stacks)
664 	    {
665 	      free (yyss);
666 	      free (yyvs);
667 #ifdef YYLSP_NEEDED
668 	      free (yyls);
669 #endif
670 	    }
671 	  return 2;
672 	}
673       yystacksize *= 2;
674       if (yystacksize > YYMAXDEPTH)
675 	yystacksize = YYMAXDEPTH;
676 #ifndef YYSTACK_USE_ALLOCA
677       yyfree_stacks = 1;
678 #endif
679       yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
680       __yy_memcpy ((char *)yyss, (char *)yyss1,
681 		   size * (unsigned int) sizeof (*yyssp));
682       yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
683       __yy_memcpy ((char *)yyvs, (char *)yyvs1,
684 		   size * (unsigned int) sizeof (*yyvsp));
685 #ifdef YYLSP_NEEDED
686       yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
687       __yy_memcpy ((char *)yyls, (char *)yyls1,
688 		   size * (unsigned int) sizeof (*yylsp));
689 #endif
690 #endif /* no yyoverflow */
691 
692       yyssp = yyss + size - 1;
693       yyvsp = yyvs + size - 1;
694 #ifdef YYLSP_NEEDED
695       yylsp = yyls + size - 1;
696 #endif
697 
698 #if YYDEBUG != 0
699       if (yydebug)
700 	fprintf(stderr, "Stack size increased to %d\n", yystacksize);
701 #endif
702 
703       if (yyssp >= yyss + yystacksize - 1)
704 	YYABORT;
705     }
706 
707 #if YYDEBUG != 0
708   if (yydebug)
709     fprintf(stderr, "Entering state %d\n", yystate);
710 #endif
711 
712   goto yybackup;
713  yybackup:
714 
715 /* Do appropriate processing given the current state.  */
716 /* Read a lookahead token if we need one and don't already have one.  */
717 /* yyresume: */
718 
719   /* First try to decide what to do without reference to lookahead token.  */
720 
721   yyn = yypact[yystate];
722   if (yyn == YYFLAG)
723     goto yydefault;
724 
725   /* Not known => get a lookahead token if don't already have one.  */
726 
727   /* yychar is either YYEMPTY or YYEOF
728      or a valid token in external form.  */
729 
730   if (yychar == YYEMPTY)
731     {
732 #if YYDEBUG != 0
733       if (yydebug)
734 	fprintf(stderr, "Reading a token: ");
735 #endif
736       yychar = YYLEX;
737     }
738 
739   /* Convert token to internal form (in yychar1) for indexing tables with */
740 
741   if (yychar <= 0)		/* This means end of input. */
742     {
743       yychar1 = 0;
744       yychar = YYEOF;		/* Don't call YYLEX any more */
745 
746 #if YYDEBUG != 0
747       if (yydebug)
748 	fprintf(stderr, "Now at end of input.\n");
749 #endif
750     }
751   else
752     {
753       yychar1 = YYTRANSLATE(yychar);
754 
755 #if YYDEBUG != 0
756       if (yydebug)
757 	{
758 	  fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
759 	  /* Give the individual parser a way to print the precise meaning
760 	     of a token, for further debugging info.  */
761 #ifdef YYPRINT
762 	  YYPRINT (stderr, yychar, yylval);
763 #endif
764 	  fprintf (stderr, ")\n");
765 	}
766 #endif
767     }
768 
769   yyn += yychar1;
770   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
771     goto yydefault;
772 
773   yyn = yytable[yyn];
774 
775   /* yyn is what to do for this token type in this state.
776      Negative => reduce, -yyn is rule number.
777      Positive => shift, yyn is new state.
778        New state is final state => don't bother to shift,
779        just return success.
780      0, or most negative number => error.  */
781 
782   if (yyn < 0)
783     {
784       if (yyn == YYFLAG)
785 	goto yyerrlab;
786       yyn = -yyn;
787       goto yyreduce;
788     }
789   else if (yyn == 0)
790     goto yyerrlab;
791 
792   if (yyn == YYFINAL)
793     YYACCEPT;
794 
795   /* Shift the lookahead token.  */
796 
797 #if YYDEBUG != 0
798   if (yydebug)
799     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
800 #endif
801 
802   /* Discard the token being shifted unless it is eof.  */
803   if (yychar != YYEOF)
804     yychar = YYEMPTY;
805 
806   *++yyvsp = yylval;
807 #ifdef YYLSP_NEEDED
808   *++yylsp = yylloc;
809 #endif
810 
811   /* count tokens shifted since error; after three, turn off error status.  */
812   if (yyerrstatus) yyerrstatus--;
813 
814   yystate = yyn;
815   goto yynewstate;
816 
817 /* Do the default action for the current state.  */
818 yydefault:
819 
820   yyn = yydefact[yystate];
821   if (yyn == 0)
822     goto yyerrlab;
823 
824 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
825 yyreduce:
826   yylen = yyr2[yyn];
827   if (yylen > 0)
828     yyval = yyvsp[1-yylen]; /* implement default value of the action */
829 
830 #if YYDEBUG != 0
831   if (yydebug)
832     {
833       int i;
834 
835       fprintf (stderr, "Reducing via rule %d (line %d), ",
836 	       yyn, yyrline[yyn]);
837 
838       /* Print the symbols being reduced, and their result.  */
839       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
840 	fprintf (stderr, "%s ", yytname[yyrhs[i]]);
841       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
842     }
843 #endif
844 
845 
846   switch (yyn) {
847 
848 case 1:
849 #line 179 "plural.y"
850 {
851 	    if (yyvsp[0].exp == NULL)
852 	      YYABORT;
853 	    ((struct parse_args *) arg)->res = yyvsp[0].exp;
854 	  ;
855     break;}
856 case 2:
857 #line 187 "plural.y"
858 {
859 	    yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp);
860 	  ;
861     break;}
862 case 3:
863 #line 191 "plural.y"
864 {
865 	    yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp);
866 	  ;
867     break;}
868 case 4:
869 #line 195 "plural.y"
870 {
871 	    yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp);
872 	  ;
873     break;}
874 case 5:
875 #line 199 "plural.y"
876 {
877 	    yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
878 	  ;
879     break;}
880 case 6:
881 #line 203 "plural.y"
882 {
883 	    yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
884 	  ;
885     break;}
886 case 7:
887 #line 207 "plural.y"
888 {
889 	    yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
890 	  ;
891     break;}
892 case 8:
893 #line 211 "plural.y"
894 {
895 	    yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
896 	  ;
897     break;}
898 case 9:
899 #line 215 "plural.y"
900 {
901 	    yyval.exp = new_exp_1 (lnot, yyvsp[0].exp);
902 	  ;
903     break;}
904 case 10:
905 #line 219 "plural.y"
906 {
907 	    yyval.exp = new_exp_0 (var);
908 	  ;
909     break;}
910 case 11:
911 #line 223 "plural.y"
912 {
913 	    if ((yyval.exp = new_exp_0 (num)) != NULL)
914 	      yyval.exp->val.num = yyvsp[0].num;
915 	  ;
916     break;}
917 case 12:
918 #line 228 "plural.y"
919 {
920 	    yyval.exp = yyvsp[-1].exp;
921 	  ;
922     break;}
923 }
924    /* the action file gets copied in in place of this dollarsign */
925 #line 543 "/home/haible/gnu/arch/linuxlibc6/share/bison.simple"
926 
927   yyvsp -= yylen;
928   yyssp -= yylen;
929 #ifdef YYLSP_NEEDED
930   yylsp -= yylen;
931 #endif
932 
933 #if YYDEBUG != 0
934   if (yydebug)
935     {
936       short *ssp1 = yyss - 1;
937       fprintf (stderr, "state stack now");
938       while (ssp1 != yyssp)
939 	fprintf (stderr, " %d", *++ssp1);
940       fprintf (stderr, "\n");
941     }
942 #endif
943 
944   *++yyvsp = yyval;
945 
946 #ifdef YYLSP_NEEDED
947   yylsp++;
948   if (yylen == 0)
949     {
950       yylsp->first_line = yylloc.first_line;
951       yylsp->first_column = yylloc.first_column;
952       yylsp->last_line = (yylsp-1)->last_line;
953       yylsp->last_column = (yylsp-1)->last_column;
954       yylsp->text = 0;
955     }
956   else
957     {
958       yylsp->last_line = (yylsp+yylen-1)->last_line;
959       yylsp->last_column = (yylsp+yylen-1)->last_column;
960     }
961 #endif
962 
963   /* Now "shift" the result of the reduction.
964      Determine what state that goes to,
965      based on the state we popped back to
966      and the rule number reduced by.  */
967 
968   yyn = yyr1[yyn];
969 
970   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
971   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
972     yystate = yytable[yystate];
973   else
974     yystate = yydefgoto[yyn - YYNTBASE];
975 
976   goto yynewstate;
977 
978 yyerrlab:   /* here on detecting error */
979 
980   if (! yyerrstatus)
981     /* If not already recovering from an error, report this error.  */
982     {
983       ++yynerrs;
984 
985 #ifdef YYERROR_VERBOSE
986       yyn = yypact[yystate];
987 
988       if (yyn > YYFLAG && yyn < YYLAST)
989 	{
990 	  int size = 0;
991 	  char *msg;
992 	  int x, count;
993 
994 	  count = 0;
995 	  /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
996 	  for (x = (yyn < 0 ? -yyn : 0);
997 	       x < (sizeof(yytname) / sizeof(char *)); x++)
998 	    if (yycheck[x + yyn] == x)
999 	      size += strlen(yytname[x]) + 15, count++;
1000 	  msg = (char *) malloc(size + 15);
1001 	  if (msg != 0)
1002 	    {
1003 	      strcpy(msg, "parse error");
1004 
1005 	      if (count < 5)
1006 		{
1007 		  count = 0;
1008 		  for (x = (yyn < 0 ? -yyn : 0);
1009 		       x < (sizeof(yytname) / sizeof(char *)); x++)
1010 		    if (yycheck[x + yyn] == x)
1011 		      {
1012 			strcat(msg, count == 0 ? ", expecting `" : " or `");
1013 			strcat(msg, yytname[x]);
1014 			strcat(msg, "'");
1015 			count++;
1016 		      }
1017 		}
1018 	      yyerror(msg);
1019 	      free(msg);
1020 	    }
1021 	  else
1022 	    yyerror ("parse error; also virtual memory exceeded");
1023 	}
1024       else
1025 #endif /* YYERROR_VERBOSE */
1026 	yyerror("parse error");
1027     }
1028 
1029   goto yyerrlab1;
1030 yyerrlab1:   /* here on error raised explicitly by an action */
1031 
1032   if (yyerrstatus == 3)
1033     {
1034       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
1035 
1036       /* return failure if at end of input */
1037       if (yychar == YYEOF)
1038 	YYABORT;
1039 
1040 #if YYDEBUG != 0
1041       if (yydebug)
1042 	fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1043 #endif
1044 
1045       yychar = YYEMPTY;
1046     }
1047 
1048   /* Else will try to reuse lookahead token
1049      after shifting the error token.  */
1050 
1051   yyerrstatus = 3;		/* Each real token shifted decrements this */
1052 
1053   goto yyerrhandle;
1054 
1055 yyerrdefault:  /* current state does not do anything special for the error token. */
1056 
1057 #if 0
1058   /* This is wrong; only states that explicitly want error tokens
1059      should shift them.  */
1060   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
1061   if (yyn) goto yydefault;
1062 #endif
1063 
1064 yyerrpop:   /* pop the current state because it cannot handle the error token */
1065 
1066   if (yyssp == yyss) YYABORT;
1067   yyvsp--;
1068   yystate = *--yyssp;
1069 #ifdef YYLSP_NEEDED
1070   yylsp--;
1071 #endif
1072 
1073 #if YYDEBUG != 0
1074   if (yydebug)
1075     {
1076       short *ssp1 = yyss - 1;
1077       fprintf (stderr, "Error: state stack now");
1078       while (ssp1 != yyssp)
1079 	fprintf (stderr, " %d", *++ssp1);
1080       fprintf (stderr, "\n");
1081     }
1082 #endif
1083 
1084 yyerrhandle:
1085 
1086   yyn = yypact[yystate];
1087   if (yyn == YYFLAG)
1088     goto yyerrdefault;
1089 
1090   yyn += YYTERROR;
1091   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1092     goto yyerrdefault;
1093 
1094   yyn = yytable[yyn];
1095   if (yyn < 0)
1096     {
1097       if (yyn == YYFLAG)
1098 	goto yyerrpop;
1099       yyn = -yyn;
1100       goto yyreduce;
1101     }
1102   else if (yyn == 0)
1103     goto yyerrpop;
1104 
1105   if (yyn == YYFINAL)
1106     YYACCEPT;
1107 
1108 #if YYDEBUG != 0
1109   if (yydebug)
1110     fprintf(stderr, "Shifting error token, ");
1111 #endif
1112 
1113   *++yyvsp = yylval;
1114 #ifdef YYLSP_NEEDED
1115   *++yylsp = yylloc;
1116 #endif
1117 
1118   yystate = yyn;
1119   goto yynewstate;
1120 
1121  yyacceptlab:
1122   /* YYACCEPT comes here.  */
1123   if (yyfree_stacks)
1124     {
1125       free (yyss);
1126       free (yyvs);
1127 #ifdef YYLSP_NEEDED
1128       free (yyls);
1129 #endif
1130     }
1131   return 0;
1132 
1133  yyabortlab:
1134   /* YYABORT comes here.  */
1135   if (yyfree_stacks)
1136     {
1137       free (yyss);
1138       free (yyvs);
1139 #ifdef YYLSP_NEEDED
1140       free (yyls);
1141 #endif
1142     }
1143   return 1;
1144 }
1145 #line 233 "plural.y"
1146 
1147 
1148 void
1149 internal_function
FREE_EXPRESSION(exp)1150 FREE_EXPRESSION (exp)
1151      struct expression *exp;
1152 {
1153   if (exp == NULL)
1154     return;
1155 
1156   /* Handle the recursive case.  */
1157   switch (exp->nargs)
1158     {
1159     case 3:
1160       FREE_EXPRESSION (exp->val.args[2]);
1161       /* FALLTHROUGH */
1162     case 2:
1163       FREE_EXPRESSION (exp->val.args[1]);
1164       /* FALLTHROUGH */
1165     case 1:
1166       FREE_EXPRESSION (exp->val.args[0]);
1167       /* FALLTHROUGH */
1168     default:
1169       break;
1170     }
1171 
1172   free (exp);
1173 }
1174 
1175 
1176 static int
yylex(lval,pexp)1177 yylex (lval, pexp)
1178      YYSTYPE *lval;
1179      const char **pexp;
1180 {
1181   const char *exp = *pexp;
1182   int result;
1183 
1184   while (1)
1185     {
1186       if (exp[0] == '\0')
1187 	{
1188 	  *pexp = exp;
1189 	  return YYEOF;
1190 	}
1191 
1192       if (exp[0] != ' ' && exp[0] != '\t')
1193 	break;
1194 
1195       ++exp;
1196     }
1197 
1198   result = *exp++;
1199   switch (result)
1200     {
1201     case '0': case '1': case '2': case '3': case '4':
1202     case '5': case '6': case '7': case '8': case '9':
1203       {
1204 	unsigned long int n = result - '0';
1205 	while (exp[0] >= '0' && exp[0] <= '9')
1206 	  {
1207 	    n *= 10;
1208 	    n += exp[0] - '0';
1209 	    ++exp;
1210 	  }
1211 	lval->num = n;
1212 	result = NUMBER;
1213       }
1214       break;
1215 
1216     case '=':
1217       if (exp[0] == '=')
1218 	{
1219 	  ++exp;
1220 	  lval->op = equal;
1221 	  result = EQUOP2;
1222 	}
1223       else
1224 	result = YYERRCODE;
1225       break;
1226 
1227     case '!':
1228       if (exp[0] == '=')
1229 	{
1230 	  ++exp;
1231 	  lval->op = not_equal;
1232 	  result = EQUOP2;
1233 	}
1234       break;
1235 
1236     case '&':
1237     case '|':
1238       if (exp[0] == result)
1239 	++exp;
1240       else
1241 	result = YYERRCODE;
1242       break;
1243 
1244     case '<':
1245       if (exp[0] == '=')
1246 	{
1247 	  ++exp;
1248 	  lval->op = less_or_equal;
1249 	}
1250       else
1251 	lval->op = less_than;
1252       result = CMPOP2;
1253       break;
1254 
1255     case '>':
1256       if (exp[0] == '=')
1257 	{
1258 	  ++exp;
1259 	  lval->op = greater_or_equal;
1260 	}
1261       else
1262 	lval->op = greater_than;
1263       result = CMPOP2;
1264       break;
1265 
1266     case '*':
1267       lval->op = mult;
1268       result = MULOP2;
1269       break;
1270 
1271     case '/':
1272       lval->op = divide;
1273       result = MULOP2;
1274       break;
1275 
1276     case '%':
1277       lval->op = module;
1278       result = MULOP2;
1279       break;
1280 
1281     case '+':
1282       lval->op = plus;
1283       result = ADDOP2;
1284       break;
1285 
1286     case '-':
1287       lval->op = minus;
1288       result = ADDOP2;
1289       break;
1290 
1291     case 'n':
1292     case '?':
1293     case ':':
1294     case '(':
1295     case ')':
1296       /* Nothing, just return the character.  */
1297       break;
1298 
1299     case ';':
1300     case '\n':
1301     case '\0':
1302       /* Be safe and let the user call this function again.  */
1303       --exp;
1304       result = YYEOF;
1305       break;
1306 
1307     default:
1308       result = YYERRCODE;
1309 #if YYDEBUG != 0
1310       --exp;
1311 #endif
1312       break;
1313     }
1314 
1315   *pexp = exp;
1316 
1317   return result;
1318 }
1319 
1320 
1321 static void
yyerror(str)1322 yyerror (str)
1323      const char *str;
1324 {
1325   /* Do nothing.  We don't print error messages here.  */
1326 }
1327