Removed old code for antuqie version of savedir().
[findutils.git] / intl / plural.c
blob100009cbb1f32263f7b08b53b42276505cf70be3
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
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
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
48 #ifdef HAVE_CONFIG_H
49 # include <config.h>
50 #endif
52 #include <stdlib.h>
53 #include "gettextP.h"
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
66 #define YYLEX_PARAM &((struct parse_args *) arg)->cp
67 #define YYPARSE_PARAM arg
69 #line 52 "plural.y"
70 typedef union {
71 unsigned long int num;
72 enum operator op;
73 struct expression *exp;
74 } YYSTYPE;
75 #line 58 "plural.y"
77 /* Prototypes for local functions. */
78 static struct expression *new_exp PARAMS ((int nargs, enum operator op,
79 struct expression * const *args));
80 static inline struct expression *new_exp_0 PARAMS ((enum operator op));
81 static inline struct expression *new_exp_1 PARAMS ((enum operator op,
82 struct expression *right));
83 static struct expression *new_exp_2 PARAMS ((enum operator op,
84 struct expression *left,
85 struct expression *right));
86 static inline struct expression *new_exp_3 PARAMS ((enum operator op,
87 struct expression *bexp,
88 struct expression *tbranch,
89 struct expression *fbranch));
90 static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
91 static void yyerror PARAMS ((const char *str));
93 /* Allocation of expressions. */
95 static struct expression *
96 new_exp (nargs, op, args)
97 int nargs;
98 enum operator op;
99 struct expression * const *args;
101 int i;
102 struct expression *newp;
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;
109 /* Allocate a new expression. */
110 newp = (struct expression *) malloc (sizeof (*newp));
111 if (newp != NULL)
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;
120 fail:
121 for (i = nargs - 1; i >= 0; i--)
122 FREE_EXPRESSION (args[i]);
124 return NULL;
127 static inline struct expression *
128 new_exp_0 (op)
129 enum operator op;
131 return new_exp (0, op, NULL);
134 static inline struct expression *
135 new_exp_1 (op, right)
136 enum operator op;
137 struct expression *right;
139 struct expression *args[1];
141 args[0] = right;
142 return new_exp (1, op, args);
145 static struct expression *
146 new_exp_2 (op, left, right)
147 enum operator op;
148 struct expression *left;
149 struct expression *right;
151 struct expression *args[2];
153 args[0] = left;
154 args[1] = right;
155 return new_exp (2, op, args);
158 static inline struct expression *
159 new_exp_3 (op, bexp, tbranch, fbranch)
160 enum operator op;
161 struct expression *bexp;
162 struct expression *tbranch;
163 struct expression *fbranch;
165 struct expression *args[3];
167 args[0] = bexp;
168 args[1] = tbranch;
169 args[2] = fbranch;
170 return new_exp (3, op, args);
173 #include <stdio.h>
175 #ifndef __cplusplus
176 #ifndef __STDC__
177 #define const
178 #endif
179 #endif
183 #define YYFINAL 27
184 #define YYFLAG -32768
185 #define YYNTBASE 16
187 #define YYTRANSLATE(x) ((unsigned)(x) <= 261 ? yytranslate[x] : 18)
189 static 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,
219 #if YYDEBUG != 0
220 static const short yyprhs[] = { 0,
221 0, 2, 8, 12, 16, 20, 24, 28, 32, 35,
222 37, 39
225 static 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
233 #endif
235 #if YYDEBUG != 0
236 static const short yyrline[] = { 0,
237 177, 185, 189, 193, 197, 201, 205, 209, 213, 217,
238 221, 226
240 #endif
243 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
245 static const char * const yytname[] = { "$","error","$undefined.","'?'","'|'",
246 "'&'","EQUOP2","CMPOP2","ADDOP2","MULOP2","'!'","NUMBER","':'","'n'","'('","')'",
247 "start","exp", NULL
249 #endif
251 static const short yyr1[] = { 0,
252 16, 17, 17, 17, 17, 17, 17, 17, 17, 17,
253 17, 17
256 static const short yyr2[] = { 0,
257 1, 5, 3, 3, 3, 3, 3, 3, 2, 1,
258 1, 3
261 static 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
267 static const short yydefgoto[] = { 25,
271 static 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
277 static const short yypgoto[] = {-32768,
282 #define YYLAST 53
285 static 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
294 static 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
302 #define YYPURE 1
304 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
305 #line 3 "/usr/share/bison/bison.simple"
306 /* This file comes from bison-1.28. */
308 /* Skeleton output parser for bison,
309 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
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.
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.
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., 51 Franklin Street, Fifth Floor,
324 Boston, MA 02110-1301, USA. */
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. */
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. */
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 */
378 #ifdef YYSTACK_USE_ALLOCA
379 #define YYSTACK_ALLOC alloca
380 #else
381 #define YYSTACK_ALLOC malloc
382 #endif
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. */
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) \
402 do \
403 if (yychar == YYEMPTY && yylen == 1) \
404 { yychar = (token), yylval = (value); \
405 yychar1 = YYTRANSLATE (yychar); \
406 YYPOPSTACK; \
407 goto yybackup; \
409 else \
410 { yyerror ("syntax error: cannot back up"); YYERROR; } \
411 while (0)
413 #define YYTERROR 1
414 #define YYERRCODE 256
416 #ifndef YYPURE
417 #define YYLEX yylex()
418 #endif
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
436 /* If nonreentrant, generate the variables here */
438 #ifndef YYPURE
440 int yychar; /* the lookahead symbol */
441 YYSTYPE yylval; /* the semantic value of the */
442 /* lookahead symbol */
444 #ifdef YYLSP_NEEDED
445 YYLTYPE yylloc; /* location data for the lookahead */
446 /* symbol */
447 #endif
449 int yynerrs; /* number of parse errors so far */
450 #endif /* not YYPURE */
452 #if YYDEBUG != 0
453 int yydebug; /* nonzero means print parse trace */
454 /* Since this is uninitialized, it does not stop multiple parsers
455 from coexisting. */
456 #endif
458 /* YYINITDEPTH indicates the initial size of the parser's stacks */
460 #ifndef YYINITDEPTH
461 #define YYINITDEPTH 200
462 #endif
464 /* YYMAXDEPTH is the maximum size the stacks can grow to
465 (effective only if the built-in stack extension method is used). */
467 #if YYMAXDEPTH == 0
468 #undef YYMAXDEPTH
469 #endif
471 #ifndef YYMAXDEPTH
472 #define YYMAXDEPTH 10000
473 #endif
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. */
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
485 /* This is the most reliable way to avoid incompatibilities
486 in available built-in functions on various systems. */
487 static void
488 __yy_memcpy (to, from, count)
489 char *to;
490 char *from;
491 unsigned int count;
493 register char *f = from;
494 register char *t = to;
495 register int i = count;
497 while (i-- > 0)
498 *t++ = *f++;
501 #else /* __cplusplus */
503 /* This is the most reliable way to avoid incompatibilities
504 in available built-in functions on various systems. */
505 static void
506 __yy_memcpy (char *to, char *from, unsigned int count)
508 register char *t = to;
509 register char *f = from;
510 register int i = count;
512 while (i-- > 0)
513 *t++ = *f++;
516 #endif
517 #endif
519 #line 217 "/usr/share/bison/bison.simple"
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. */
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 */
540 /* Prevent warning if -Wstrict-prototypes. */
541 #ifdef __GNUC__
542 #ifdef YYPARSE_PARAM
543 int yyparse (void *);
544 #else
545 int yyparse (void);
546 #endif
547 #endif
550 yyparse(YYPARSE_PARAM_ARG)
551 YYPARSE_PARAM_DECL
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 */
560 short yyssa[YYINITDEPTH]; /* the state stack */
561 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
563 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
564 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
566 #ifdef YYLSP_NEEDED
567 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
568 YYLTYPE *yyls = yylsa;
569 YYLTYPE *yylsp;
571 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
572 #else
573 #define YYPOPSTACK (yyvsp--, yyssp--)
574 #endif
576 int yystacksize = YYINITDEPTH;
577 int yyfree_stacks = 0;
579 #ifdef YYPURE
580 int yychar;
581 YYSTYPE yylval;
582 int yynerrs;
583 #ifdef YYLSP_NEEDED
584 YYLTYPE yylloc;
585 #endif
586 #endif
588 YYSTYPE yyval; /* the variable used to return */
589 /* semantic values from the action */
590 /* routines */
592 int yylen;
594 #if YYDEBUG != 0
595 if (yydebug)
596 fprintf(stderr, "Starting parse\n");
597 #endif
599 yystate = 0;
600 yyerrstatus = 0;
601 yynerrs = 0;
602 yychar = YYEMPTY; /* Cause a token to be read. */
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. */
609 yyssp = yyss - 1;
610 yyvsp = yyvs;
611 #ifdef YYLSP_NEEDED
612 yylsp = yyls;
613 #endif
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. */
618 yynewstate:
620 *++yyssp = yystate;
622 if (yyssp >= yyss + yystacksize - 1)
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
632 /* Get the current used size of the three stacks, in elements. */
633 int size = yyssp - yyss + 1;
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
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)
661 yyerror("parser stack overflow");
662 if (yyfree_stacks)
664 free (yyss);
665 free (yyvs);
666 #ifdef YYLSP_NEEDED
667 free (yyls);
668 #endif
670 return 2;
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 */
691 yyssp = yyss + size - 1;
692 yyvsp = yyvs + size - 1;
693 #ifdef YYLSP_NEEDED
694 yylsp = yyls + size - 1;
695 #endif
697 #if YYDEBUG != 0
698 if (yydebug)
699 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
700 #endif
702 if (yyssp >= yyss + yystacksize - 1)
703 YYABORT;
706 #if YYDEBUG != 0
707 if (yydebug)
708 fprintf(stderr, "Entering state %d\n", yystate);
709 #endif
711 goto yybackup;
712 yybackup:
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: */
718 /* First try to decide what to do without reference to lookahead token. */
720 yyn = yypact[yystate];
721 if (yyn == YYFLAG)
722 goto yydefault;
724 /* Not known => get a lookahead token if don't already have one. */
726 /* yychar is either YYEMPTY or YYEOF
727 or a valid token in external form. */
729 if (yychar == YYEMPTY)
731 #if YYDEBUG != 0
732 if (yydebug)
733 fprintf(stderr, "Reading a token: ");
734 #endif
735 yychar = YYLEX;
738 /* Convert token to internal form (in yychar1) for indexing tables with */
740 if (yychar <= 0) /* This means end of input. */
742 yychar1 = 0;
743 yychar = YYEOF; /* Don't call YYLEX any more */
745 #if YYDEBUG != 0
746 if (yydebug)
747 fprintf(stderr, "Now at end of input.\n");
748 #endif
750 else
752 yychar1 = YYTRANSLATE(yychar);
754 #if YYDEBUG != 0
755 if (yydebug)
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");
765 #endif
768 yyn += yychar1;
769 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
770 goto yydefault;
772 yyn = yytable[yyn];
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. */
781 if (yyn < 0)
783 if (yyn == YYFLAG)
784 goto yyerrlab;
785 yyn = -yyn;
786 goto yyreduce;
788 else if (yyn == 0)
789 goto yyerrlab;
791 if (yyn == YYFINAL)
792 YYACCEPT;
794 /* Shift the lookahead token. */
796 #if YYDEBUG != 0
797 if (yydebug)
798 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
799 #endif
801 /* Discard the token being shifted unless it is eof. */
802 if (yychar != YYEOF)
803 yychar = YYEMPTY;
805 *++yyvsp = yylval;
806 #ifdef YYLSP_NEEDED
807 *++yylsp = yylloc;
808 #endif
810 /* count tokens shifted since error; after three, turn off error status. */
811 if (yyerrstatus) yyerrstatus--;
813 yystate = yyn;
814 goto yynewstate;
816 /* Do the default action for the current state. */
817 yydefault:
819 yyn = yydefact[yystate];
820 if (yyn == 0)
821 goto yyerrlab;
823 /* Do a reduction. yyn is the number of a rule to reduce with. */
824 yyreduce:
825 yylen = yyr2[yyn];
826 if (yylen > 0)
827 yyval = yyvsp[1-yylen]; /* implement default value of the action */
829 #if YYDEBUG != 0
830 if (yydebug)
832 int i;
834 fprintf (stderr, "Reducing via rule %d (line %d), ",
835 yyn, yyrline[yyn]);
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]]);
842 #endif
845 switch (yyn) {
847 case 1:
848 #line 178 "plural.y"
850 if (yyvsp[0].exp == NULL)
851 YYABORT;
852 ((struct parse_args *) arg)->res = yyvsp[0].exp;
854 break;}
855 case 2:
856 #line 186 "plural.y"
858 yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp);
860 break;}
861 case 3:
862 #line 190 "plural.y"
864 yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp);
866 break;}
867 case 4:
868 #line 194 "plural.y"
870 yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp);
872 break;}
873 case 5:
874 #line 198 "plural.y"
876 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
878 break;}
879 case 6:
880 #line 202 "plural.y"
882 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
884 break;}
885 case 7:
886 #line 206 "plural.y"
888 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
890 break;}
891 case 8:
892 #line 210 "plural.y"
894 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
896 break;}
897 case 9:
898 #line 214 "plural.y"
900 yyval.exp = new_exp_1 (lnot, yyvsp[0].exp);
902 break;}
903 case 10:
904 #line 218 "plural.y"
906 yyval.exp = new_exp_0 (var);
908 break;}
909 case 11:
910 #line 222 "plural.y"
912 if ((yyval.exp = new_exp_0 (num)) != NULL)
913 yyval.exp->val.num = yyvsp[0].num;
915 break;}
916 case 12:
917 #line 227 "plural.y"
919 yyval.exp = yyvsp[-1].exp;
921 break;}
923 /* the action file gets copied in in place of this dollarsign */
924 #line 543 "/usr/share/bison/bison.simple"
926 yyvsp -= yylen;
927 yyssp -= yylen;
928 #ifdef YYLSP_NEEDED
929 yylsp -= yylen;
930 #endif
932 #if YYDEBUG != 0
933 if (yydebug)
935 short *ssp1 = yyss - 1;
936 fprintf (stderr, "state stack now");
937 while (ssp1 != yyssp)
938 fprintf (stderr, " %d", *++ssp1);
939 fprintf (stderr, "\n");
941 #endif
943 *++yyvsp = yyval;
945 #ifdef YYLSP_NEEDED
946 yylsp++;
947 if (yylen == 0)
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;
955 else
957 yylsp->last_line = (yylsp+yylen-1)->last_line;
958 yylsp->last_column = (yylsp+yylen-1)->last_column;
960 #endif
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. */
967 yyn = yyr1[yyn];
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];
975 goto yynewstate;
977 yyerrlab: /* here on detecting error */
979 if (! yyerrstatus)
980 /* If not already recovering from an error, report this error. */
982 ++yynerrs;
984 #ifdef YYERROR_VERBOSE
985 yyn = yypact[yystate];
987 if (yyn > YYFLAG && yyn < YYLAST)
989 int size = 0;
990 char *msg;
991 int x, count;
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)
1002 strcpy(msg, "parse error");
1004 if (count < 5)
1006 count = 0;
1007 for (x = (yyn < 0 ? -yyn : 0);
1008 x < (sizeof(yytname) / sizeof(char *)); x++)
1009 if (yycheck[x + yyn] == x)
1011 strcat(msg, count == 0 ? ", expecting `" : " or `");
1012 strcat(msg, yytname[x]);
1013 strcat(msg, "'");
1014 count++;
1017 yyerror(msg);
1018 free(msg);
1020 else
1021 yyerror ("parse error; also virtual memory exceeded");
1023 else
1024 #endif /* YYERROR_VERBOSE */
1025 yyerror("parse error");
1028 goto yyerrlab1;
1029 yyerrlab1: /* here on error raised explicitly by an action */
1031 if (yyerrstatus == 3)
1033 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1035 /* return failure if at end of input */
1036 if (yychar == YYEOF)
1037 YYABORT;
1039 #if YYDEBUG != 0
1040 if (yydebug)
1041 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1042 #endif
1044 yychar = YYEMPTY;
1047 /* Else will try to reuse lookahead token
1048 after shifting the error token. */
1050 yyerrstatus = 3; /* Each real token shifted decrements this */
1052 goto yyerrhandle;
1054 yyerrdefault: /* current state does not do anything special for the error token. */
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
1063 yyerrpop: /* pop the current state because it cannot handle the error token */
1065 if (yyssp == yyss) YYABORT;
1066 yyvsp--;
1067 yystate = *--yyssp;
1068 #ifdef YYLSP_NEEDED
1069 yylsp--;
1070 #endif
1072 #if YYDEBUG != 0
1073 if (yydebug)
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");
1081 #endif
1083 yyerrhandle:
1085 yyn = yypact[yystate];
1086 if (yyn == YYFLAG)
1087 goto yyerrdefault;
1089 yyn += YYTERROR;
1090 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1091 goto yyerrdefault;
1093 yyn = yytable[yyn];
1094 if (yyn < 0)
1096 if (yyn == YYFLAG)
1097 goto yyerrpop;
1098 yyn = -yyn;
1099 goto yyreduce;
1101 else if (yyn == 0)
1102 goto yyerrpop;
1104 if (yyn == YYFINAL)
1105 YYACCEPT;
1107 #if YYDEBUG != 0
1108 if (yydebug)
1109 fprintf(stderr, "Shifting error token, ");
1110 #endif
1112 *++yyvsp = yylval;
1113 #ifdef YYLSP_NEEDED
1114 *++yylsp = yylloc;
1115 #endif
1117 yystate = yyn;
1118 goto yynewstate;
1120 yyacceptlab:
1121 /* YYACCEPT comes here. */
1122 if (yyfree_stacks)
1124 free (yyss);
1125 free (yyvs);
1126 #ifdef YYLSP_NEEDED
1127 free (yyls);
1128 #endif
1130 return 0;
1132 yyabortlab:
1133 /* YYABORT comes here. */
1134 if (yyfree_stacks)
1136 free (yyss);
1137 free (yyvs);
1138 #ifdef YYLSP_NEEDED
1139 free (yyls);
1140 #endif
1142 return 1;
1144 #line 232 "plural.y"
1147 void
1148 internal_function
1149 FREE_EXPRESSION (exp)
1150 struct expression *exp;
1152 if (exp == NULL)
1153 return;
1155 /* Handle the recursive case. */
1156 switch (exp->nargs)
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;
1171 free (exp);
1175 static int
1176 yylex (lval, pexp)
1177 YYSTYPE *lval;
1178 const char **pexp;
1180 const char *exp = *pexp;
1181 int result;
1183 while (1)
1185 if (exp[0] == '\0')
1187 *pexp = exp;
1188 return YYEOF;
1191 if (exp[0] != ' ' && exp[0] != '\t')
1192 break;
1194 ++exp;
1197 result = *exp++;
1198 switch (result)
1200 case '0': case '1': case '2': case '3': case '4':
1201 case '5': case '6': case '7': case '8': case '9':
1203 unsigned long int n = result - '0';
1204 while (exp[0] >= '0' && exp[0] <= '9')
1206 n *= 10;
1207 n += exp[0] - '0';
1208 ++exp;
1210 lval->num = n;
1211 result = NUMBER;
1213 break;
1215 case '=':
1216 if (exp[0] == '=')
1218 ++exp;
1219 lval->op = equal;
1220 result = EQUOP2;
1222 else
1223 result = YYERRCODE;
1224 break;
1226 case '!':
1227 if (exp[0] == '=')
1229 ++exp;
1230 lval->op = not_equal;
1231 result = EQUOP2;
1233 break;
1235 case '&':
1236 case '|':
1237 if (exp[0] == result)
1238 ++exp;
1239 else
1240 result = YYERRCODE;
1241 break;
1243 case '<':
1244 if (exp[0] == '=')
1246 ++exp;
1247 lval->op = less_or_equal;
1249 else
1250 lval->op = less_than;
1251 result = CMPOP2;
1252 break;
1254 case '>':
1255 if (exp[0] == '=')
1257 ++exp;
1258 lval->op = greater_or_equal;
1260 else
1261 lval->op = greater_than;
1262 result = CMPOP2;
1263 break;
1265 case '*':
1266 lval->op = mult;
1267 result = MULOP2;
1268 break;
1270 case '/':
1271 lval->op = divide;
1272 result = MULOP2;
1273 break;
1275 case '%':
1276 lval->op = module;
1277 result = MULOP2;
1278 break;
1280 case '+':
1281 lval->op = plus;
1282 result = ADDOP2;
1283 break;
1285 case '-':
1286 lval->op = minus;
1287 result = ADDOP2;
1288 break;
1290 case 'n':
1291 case '?':
1292 case ':':
1293 case '(':
1294 case ')':
1295 /* Nothing, just return the character. */
1296 break;
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;
1306 default:
1307 result = YYERRCODE;
1308 #if YYDEBUG != 0
1309 --exp;
1310 #endif
1311 break;
1314 *pexp = exp;
1316 return result;
1320 static void
1321 yyerror (str)
1322 const char *str;
1324 /* Do nothing. We don't print error messages here. */