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