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