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