* config/xtensa/linux.h (TARGET_OS_CPP_BUILTINS): Remove definition of
[official-gcc.git] / gcc / intl / plural.c
blob7d7e6af7de1edf04e6fd3f292d4a1016ed836f7f
2 /* A Bison parser, made from plural.y
3 by GNU Bison version 1.28 */
5 #define YYBISON 1 /* Identify Bison output. */
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
20 #line 1 "plural.y"
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.
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.
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.
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. */
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
49 #ifdef HAVE_CONFIG_H
50 # include <config.h>
51 #endif
53 #include <stdlib.h>
54 #include "gettextP.h"
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
67 #define YYLEX_PARAM &((struct parse_args *) arg)->cp
68 #define YYPARSE_PARAM arg
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"
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));
94 /* Allocation of expressions. */
96 static struct expression *
97 new_exp (nargs, op, args)
98 int nargs;
99 enum operator op;
100 struct expression * const *args;
102 int i;
103 struct expression *newp;
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;
110 /* Allocate a new expression. */
111 newp = (struct expression *) malloc (sizeof (*newp));
112 if (newp != NULL)
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;
121 fail:
122 for (i = nargs - 1; i >= 0; i--)
123 FREE_EXPRESSION (args[i]);
125 return NULL;
128 static inline struct expression *
129 new_exp_0 (op)
130 enum operator op;
132 return new_exp (0, op, NULL);
135 static inline struct expression *
136 new_exp_1 (op, right)
137 enum operator op;
138 struct expression *right;
140 struct expression *args[1];
142 args[0] = right;
143 return new_exp (1, op, args);
146 static struct expression *
147 new_exp_2 (op, left, right)
148 enum operator op;
149 struct expression *left;
150 struct expression *right;
152 struct expression *args[2];
154 args[0] = left;
155 args[1] = right;
156 return new_exp (2, op, args);
159 static inline struct expression *
160 new_exp_3 (op, bexp, tbranch, fbranch)
161 enum operator op;
162 struct expression *bexp;
163 struct expression *tbranch;
164 struct expression *fbranch;
166 struct expression *args[3];
168 args[0] = bexp;
169 args[1] = tbranch;
170 args[2] = fbranch;
171 return new_exp (3, op, args);
174 #include <stdio.h>
176 #ifndef __cplusplus
177 #ifndef __STDC__
178 #define const
179 #endif
180 #endif
184 #define YYFINAL 27
185 #define YYFLAG -32768
186 #define YYNTBASE 16
188 #define YYTRANSLATE(x) ((unsigned)(x) <= 261 ? yytranslate[x] : 18)
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,
220 #if YYDEBUG != 0
221 static const short yyprhs[] = { 0,
222 0, 2, 8, 12, 16, 20, 24, 28, 32, 35,
223 37, 39
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
234 #endif
236 #if YYDEBUG != 0
237 static const short yyrline[] = { 0,
238 178, 186, 190, 194, 198, 202, 206, 210, 214, 218,
239 222, 227
241 #endif
244 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
246 static const char * const yytname[] = { "$","error","$undefined.","'?'","'|'",
247 "'&'","EQUOP2","CMPOP2","ADDOP2","MULOP2","'!'","NUMBER","':'","'n'","'('","')'",
248 "start","exp", NULL
250 #endif
252 static const short yyr1[] = { 0,
253 16, 17, 17, 17, 17, 17, 17, 17, 17, 17,
254 17, 17
257 static const short yyr2[] = { 0,
258 1, 5, 3, 3, 3, 3, 3, 3, 2, 1,
259 1, 3
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
268 static const short yydefgoto[] = { 25,
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
278 static const short yypgoto[] = {-32768,
283 #define YYLAST 53
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
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
303 #define YYPURE 1
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. */
309 /* Skeleton output parser for bison,
310 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
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.
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.
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. */
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. */
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. */
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 */
379 #ifdef YYSTACK_USE_ALLOCA
380 #define YYSTACK_ALLOC alloca
381 #else
382 #define YYSTACK_ALLOC malloc
383 #endif
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. */
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; \
410 else \
411 { yyerror ("syntax error: cannot back up"); YYERROR; } \
412 while (0)
414 #define YYTERROR 1
415 #define YYERRCODE 256
417 #ifndef YYPURE
418 #define YYLEX yylex()
419 #endif
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
437 /* If nonreentrant, generate the variables here */
439 #ifndef YYPURE
441 int yychar; /* the lookahead symbol */
442 YYSTYPE yylval; /* the semantic value of the */
443 /* lookahead symbol */
445 #ifdef YYLSP_NEEDED
446 YYLTYPE yylloc; /* location data for the lookahead */
447 /* symbol */
448 #endif
450 int yynerrs; /* number of parse errors so far */
451 #endif /* not YYPURE */
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
459 /* YYINITDEPTH indicates the initial size of the parser's stacks */
461 #ifndef YYINITDEPTH
462 #define YYINITDEPTH 200
463 #endif
465 /* YYMAXDEPTH is the maximum size the stacks can grow to
466 (effective only if the built-in stack extension method is used). */
468 #if YYMAXDEPTH == 0
469 #undef YYMAXDEPTH
470 #endif
472 #ifndef YYMAXDEPTH
473 #define YYMAXDEPTH 10000
474 #endif
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. */
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
486 /* This is the most reliable way to avoid incompatibilities
487 in available built-in functions on various systems. */
488 static void
489 __yy_memcpy (to, from, count)
490 char *to;
491 char *from;
492 unsigned int count;
494 register char *f = from;
495 register char *t = to;
496 register int i = count;
498 while (i-- > 0)
499 *t++ = *f++;
502 #else /* __cplusplus */
504 /* This is the most reliable way to avoid incompatibilities
505 in available built-in functions on various systems. */
506 static void
507 __yy_memcpy (char *to, char *from, unsigned int count)
509 register char *t = to;
510 register char *f = from;
511 register int i = count;
513 while (i-- > 0)
514 *t++ = *f++;
517 #endif
518 #endif
520 #line 217 "/home/haible/gnu/arch/linuxlibc6/share/bison.simple"
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. */
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 */
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
551 yyparse(YYPARSE_PARAM_ARG)
552 YYPARSE_PARAM_DECL
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 */
561 short yyssa[YYINITDEPTH]; /* the state stack */
562 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
564 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
565 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
567 #ifdef YYLSP_NEEDED
568 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
569 YYLTYPE *yyls = yylsa;
570 YYLTYPE *yylsp;
572 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
573 #else
574 #define YYPOPSTACK (yyvsp--, yyssp--)
575 #endif
577 int yystacksize = YYINITDEPTH;
578 int yyfree_stacks = 0;
580 #ifdef YYPURE
581 int yychar;
582 YYSTYPE yylval;
583 int yynerrs;
584 #ifdef YYLSP_NEEDED
585 YYLTYPE yylloc;
586 #endif
587 #endif
589 YYSTYPE yyval; /* the variable used to return */
590 /* semantic values from the action */
591 /* routines */
593 int yylen;
595 #if YYDEBUG != 0
596 if (yydebug)
597 fprintf(stderr, "Starting parse\n");
598 #endif
600 yystate = 0;
601 yyerrstatus = 0;
602 yynerrs = 0;
603 yychar = YYEMPTY; /* Cause a token to be read. */
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. */
610 yyssp = yyss - 1;
611 yyvsp = yyvs;
612 #ifdef YYLSP_NEEDED
613 yylsp = yyls;
614 #endif
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:
621 *++yyssp = yystate;
623 if (yyssp >= yyss + yystacksize - 1)
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
633 /* Get the current used size of the three stacks, in elements. */
634 int size = yyssp - yyss + 1;
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
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)
662 yyerror("parser stack overflow");
663 if (yyfree_stacks)
665 free (yyss);
666 free (yyvs);
667 #ifdef YYLSP_NEEDED
668 free (yyls);
669 #endif
671 return 2;
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 */
692 yyssp = yyss + size - 1;
693 yyvsp = yyvs + size - 1;
694 #ifdef YYLSP_NEEDED
695 yylsp = yyls + size - 1;
696 #endif
698 #if YYDEBUG != 0
699 if (yydebug)
700 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
701 #endif
703 if (yyssp >= yyss + yystacksize - 1)
704 YYABORT;
707 #if YYDEBUG != 0
708 if (yydebug)
709 fprintf(stderr, "Entering state %d\n", yystate);
710 #endif
712 goto yybackup;
713 yybackup:
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: */
719 /* First try to decide what to do without reference to lookahead token. */
721 yyn = yypact[yystate];
722 if (yyn == YYFLAG)
723 goto yydefault;
725 /* Not known => get a lookahead token if don't already have one. */
727 /* yychar is either YYEMPTY or YYEOF
728 or a valid token in external form. */
730 if (yychar == YYEMPTY)
732 #if YYDEBUG != 0
733 if (yydebug)
734 fprintf(stderr, "Reading a token: ");
735 #endif
736 yychar = YYLEX;
739 /* Convert token to internal form (in yychar1) for indexing tables with */
741 if (yychar <= 0) /* This means end of input. */
743 yychar1 = 0;
744 yychar = YYEOF; /* Don't call YYLEX any more */
746 #if YYDEBUG != 0
747 if (yydebug)
748 fprintf(stderr, "Now at end of input.\n");
749 #endif
751 else
753 yychar1 = YYTRANSLATE(yychar);
755 #if YYDEBUG != 0
756 if (yydebug)
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");
766 #endif
769 yyn += yychar1;
770 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
771 goto yydefault;
773 yyn = yytable[yyn];
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. */
782 if (yyn < 0)
784 if (yyn == YYFLAG)
785 goto yyerrlab;
786 yyn = -yyn;
787 goto yyreduce;
789 else if (yyn == 0)
790 goto yyerrlab;
792 if (yyn == YYFINAL)
793 YYACCEPT;
795 /* Shift the lookahead token. */
797 #if YYDEBUG != 0
798 if (yydebug)
799 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
800 #endif
802 /* Discard the token being shifted unless it is eof. */
803 if (yychar != YYEOF)
804 yychar = YYEMPTY;
806 *++yyvsp = yylval;
807 #ifdef YYLSP_NEEDED
808 *++yylsp = yylloc;
809 #endif
811 /* count tokens shifted since error; after three, turn off error status. */
812 if (yyerrstatus) yyerrstatus--;
814 yystate = yyn;
815 goto yynewstate;
817 /* Do the default action for the current state. */
818 yydefault:
820 yyn = yydefact[yystate];
821 if (yyn == 0)
822 goto yyerrlab;
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 */
830 #if YYDEBUG != 0
831 if (yydebug)
833 int i;
835 fprintf (stderr, "Reducing via rule %d (line %d), ",
836 yyn, yyrline[yyn]);
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]]);
843 #endif
846 switch (yyn) {
848 case 1:
849 #line 179 "plural.y"
851 if (yyvsp[0].exp == NULL)
852 YYABORT;
853 ((struct parse_args *) arg)->res = yyvsp[0].exp;
855 break;}
856 case 2:
857 #line 187 "plural.y"
859 yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp);
861 break;}
862 case 3:
863 #line 191 "plural.y"
865 yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp);
867 break;}
868 case 4:
869 #line 195 "plural.y"
871 yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp);
873 break;}
874 case 5:
875 #line 199 "plural.y"
877 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
879 break;}
880 case 6:
881 #line 203 "plural.y"
883 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
885 break;}
886 case 7:
887 #line 207 "plural.y"
889 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
891 break;}
892 case 8:
893 #line 211 "plural.y"
895 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
897 break;}
898 case 9:
899 #line 215 "plural.y"
901 yyval.exp = new_exp_1 (lnot, yyvsp[0].exp);
903 break;}
904 case 10:
905 #line 219 "plural.y"
907 yyval.exp = new_exp_0 (var);
909 break;}
910 case 11:
911 #line 223 "plural.y"
913 if ((yyval.exp = new_exp_0 (num)) != NULL)
914 yyval.exp->val.num = yyvsp[0].num;
916 break;}
917 case 12:
918 #line 228 "plural.y"
920 yyval.exp = yyvsp[-1].exp;
922 break;}
924 /* the action file gets copied in in place of this dollarsign */
925 #line 543 "/home/haible/gnu/arch/linuxlibc6/share/bison.simple"
927 yyvsp -= yylen;
928 yyssp -= yylen;
929 #ifdef YYLSP_NEEDED
930 yylsp -= yylen;
931 #endif
933 #if YYDEBUG != 0
934 if (yydebug)
936 short *ssp1 = yyss - 1;
937 fprintf (stderr, "state stack now");
938 while (ssp1 != yyssp)
939 fprintf (stderr, " %d", *++ssp1);
940 fprintf (stderr, "\n");
942 #endif
944 *++yyvsp = yyval;
946 #ifdef YYLSP_NEEDED
947 yylsp++;
948 if (yylen == 0)
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;
956 else
958 yylsp->last_line = (yylsp+yylen-1)->last_line;
959 yylsp->last_column = (yylsp+yylen-1)->last_column;
961 #endif
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. */
968 yyn = yyr1[yyn];
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];
976 goto yynewstate;
978 yyerrlab: /* here on detecting error */
980 if (! yyerrstatus)
981 /* If not already recovering from an error, report this error. */
983 ++yynerrs;
985 #ifdef YYERROR_VERBOSE
986 yyn = yypact[yystate];
988 if (yyn > YYFLAG && yyn < YYLAST)
990 int size = 0;
991 char *msg;
992 int x, count;
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)
1003 strcpy(msg, "parse error");
1005 if (count < 5)
1007 count = 0;
1008 for (x = (yyn < 0 ? -yyn : 0);
1009 x < (sizeof(yytname) / sizeof(char *)); x++)
1010 if (yycheck[x + yyn] == x)
1012 strcat(msg, count == 0 ? ", expecting `" : " or `");
1013 strcat(msg, yytname[x]);
1014 strcat(msg, "'");
1015 count++;
1018 yyerror(msg);
1019 free(msg);
1021 else
1022 yyerror ("parse error; also virtual memory exceeded");
1024 else
1025 #endif /* YYERROR_VERBOSE */
1026 yyerror("parse error");
1029 goto yyerrlab1;
1030 yyerrlab1: /* here on error raised explicitly by an action */
1032 if (yyerrstatus == 3)
1034 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1036 /* return failure if at end of input */
1037 if (yychar == YYEOF)
1038 YYABORT;
1040 #if YYDEBUG != 0
1041 if (yydebug)
1042 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1043 #endif
1045 yychar = YYEMPTY;
1048 /* Else will try to reuse lookahead token
1049 after shifting the error token. */
1051 yyerrstatus = 3; /* Each real token shifted decrements this */
1053 goto yyerrhandle;
1055 yyerrdefault: /* current state does not do anything special for the error token. */
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
1064 yyerrpop: /* pop the current state because it cannot handle the error token */
1066 if (yyssp == yyss) YYABORT;
1067 yyvsp--;
1068 yystate = *--yyssp;
1069 #ifdef YYLSP_NEEDED
1070 yylsp--;
1071 #endif
1073 #if YYDEBUG != 0
1074 if (yydebug)
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");
1082 #endif
1084 yyerrhandle:
1086 yyn = yypact[yystate];
1087 if (yyn == YYFLAG)
1088 goto yyerrdefault;
1090 yyn += YYTERROR;
1091 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1092 goto yyerrdefault;
1094 yyn = yytable[yyn];
1095 if (yyn < 0)
1097 if (yyn == YYFLAG)
1098 goto yyerrpop;
1099 yyn = -yyn;
1100 goto yyreduce;
1102 else if (yyn == 0)
1103 goto yyerrpop;
1105 if (yyn == YYFINAL)
1106 YYACCEPT;
1108 #if YYDEBUG != 0
1109 if (yydebug)
1110 fprintf(stderr, "Shifting error token, ");
1111 #endif
1113 *++yyvsp = yylval;
1114 #ifdef YYLSP_NEEDED
1115 *++yylsp = yylloc;
1116 #endif
1118 yystate = yyn;
1119 goto yynewstate;
1121 yyacceptlab:
1122 /* YYACCEPT comes here. */
1123 if (yyfree_stacks)
1125 free (yyss);
1126 free (yyvs);
1127 #ifdef YYLSP_NEEDED
1128 free (yyls);
1129 #endif
1131 return 0;
1133 yyabortlab:
1134 /* YYABORT comes here. */
1135 if (yyfree_stacks)
1137 free (yyss);
1138 free (yyvs);
1139 #ifdef YYLSP_NEEDED
1140 free (yyls);
1141 #endif
1143 return 1;
1145 #line 233 "plural.y"
1148 void
1149 internal_function
1150 FREE_EXPRESSION (exp)
1151 struct expression *exp;
1153 if (exp == NULL)
1154 return;
1156 /* Handle the recursive case. */
1157 switch (exp->nargs)
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;
1172 free (exp);
1176 static int
1177 yylex (lval, pexp)
1178 YYSTYPE *lval;
1179 const char **pexp;
1181 const char *exp = *pexp;
1182 int result;
1184 while (1)
1186 if (exp[0] == '\0')
1188 *pexp = exp;
1189 return YYEOF;
1192 if (exp[0] != ' ' && exp[0] != '\t')
1193 break;
1195 ++exp;
1198 result = *exp++;
1199 switch (result)
1201 case '0': case '1': case '2': case '3': case '4':
1202 case '5': case '6': case '7': case '8': case '9':
1204 unsigned long int n = result - '0';
1205 while (exp[0] >= '0' && exp[0] <= '9')
1207 n *= 10;
1208 n += exp[0] - '0';
1209 ++exp;
1211 lval->num = n;
1212 result = NUMBER;
1214 break;
1216 case '=':
1217 if (exp[0] == '=')
1219 ++exp;
1220 lval->op = equal;
1221 result = EQUOP2;
1223 else
1224 result = YYERRCODE;
1225 break;
1227 case '!':
1228 if (exp[0] == '=')
1230 ++exp;
1231 lval->op = not_equal;
1232 result = EQUOP2;
1234 break;
1236 case '&':
1237 case '|':
1238 if (exp[0] == result)
1239 ++exp;
1240 else
1241 result = YYERRCODE;
1242 break;
1244 case '<':
1245 if (exp[0] == '=')
1247 ++exp;
1248 lval->op = less_or_equal;
1250 else
1251 lval->op = less_than;
1252 result = CMPOP2;
1253 break;
1255 case '>':
1256 if (exp[0] == '=')
1258 ++exp;
1259 lval->op = greater_or_equal;
1261 else
1262 lval->op = greater_than;
1263 result = CMPOP2;
1264 break;
1266 case '*':
1267 lval->op = mult;
1268 result = MULOP2;
1269 break;
1271 case '/':
1272 lval->op = divide;
1273 result = MULOP2;
1274 break;
1276 case '%':
1277 lval->op = module;
1278 result = MULOP2;
1279 break;
1281 case '+':
1282 lval->op = plus;
1283 result = ADDOP2;
1284 break;
1286 case '-':
1287 lval->op = minus;
1288 result = ADDOP2;
1289 break;
1291 case 'n':
1292 case '?':
1293 case ':':
1294 case '(':
1295 case ')':
1296 /* Nothing, just return the character. */
1297 break;
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;
1307 default:
1308 result = YYERRCODE;
1309 #if YYDEBUG != 0
1310 --exp;
1311 #endif
1312 break;
1315 *pexp = exp;
1317 return result;
1320 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
1321 #define __attribute__(x)
1322 #endif
1324 static void
1325 yyerror (str)
1326 const char *str __attribute__ ((__unused__));
1328 /* Do nothing. We don't print error messages here. */