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