* sysdeps/unix/sysv/linux/ia64/ioperm.c: Don't include kernel
[glibc/pb-stable.git] / intl / plural.c
blobc3eeaebb05b884d31d7100f74677bd0b20f5a842
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 NUMBER 257
16 #line 1 "plural.y"
18 /* Expression parsing for plural form selection.
19 Copyright (C) 2000, 2001 Free Software Foundation, Inc.
20 Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
22 The GNU C Library is free software; you can redistribute it and/or
23 modify it under the terms of the GNU Library General Public License as
24 published by the Free Software Foundation; either version 2 of the
25 License, or (at your option) any later version.
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Library General Public License for more details.
32 You should have received a copy of the GNU Library General Public
33 License along with the GNU C Library; see the file COPYING.LIB. If not,
34 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
35 Boston, MA 02111-1307, USA. */
37 #ifdef HAVE_CONFIG_H
38 # include <config.h>
39 #endif
41 #include <stdarg.h>
42 #include <stdlib.h>
43 #include "gettext.h"
44 #include "gettextP.h"
46 #define YYLEX_PARAM &((struct parse_args *) arg)->cp
47 #define YYPARSE_PARAM arg
49 #line 36 "plural.y"
50 typedef union {
51 unsigned long int num;
52 struct expression *exp;
53 } YYSTYPE;
54 #line 41 "plural.y"
56 /* Prototypes for local functions. */
57 static struct expression *new_exp (enum operator op, int n, ...);
58 static int yylex (YYSTYPE *lval, const char **pexp);
59 static void yyerror (const char *str);
60 #include <stdio.h>
62 #ifndef __cplusplus
63 #ifndef __STDC__
64 #define const
65 #endif
66 #endif
70 #define YYFINAL 31
71 #define YYFLAG -32768
72 #define YYNTBASE 18
74 #define YYTRANSLATE(x) ((unsigned)(x) <= 257 ? yytranslate[x] : 20)
76 static const char yytranslate[] = { 0,
77 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
78 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
79 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
80 2, 2, 7, 2, 2, 2, 12, 5, 2, 16,
81 17, 10, 8, 2, 9, 2, 11, 2, 2, 2,
82 2, 2, 2, 2, 2, 2, 2, 14, 2, 2,
83 6, 2, 3, 2, 2, 2, 2, 2, 2, 2,
84 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
85 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
86 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
87 2, 2, 2, 2, 2, 2, 2, 2, 2, 15,
88 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
89 2, 2, 2, 4, 2, 2, 2, 2, 2, 2,
90 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
91 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
92 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
93 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
94 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
95 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
96 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
97 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
98 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
99 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
100 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
101 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
102 2, 2, 2, 2, 2, 1, 13
105 #if YYDEBUG != 0
106 static const short yyprhs[] = { 0,
107 0, 2, 8, 12, 16, 20, 24, 28, 32, 36,
108 40, 44, 46, 48
111 static const short yyrhs[] = { 19,
112 0, 19, 3, 19, 14, 19, 0, 19, 4, 19,
113 0, 19, 5, 19, 0, 19, 6, 19, 0, 19,
114 7, 19, 0, 19, 8, 19, 0, 19, 9, 19,
115 0, 19, 10, 19, 0, 19, 11, 19, 0, 19,
116 12, 19, 0, 15, 0, 13, 0, 16, 19, 17,
120 #endif
122 #if YYDEBUG != 0
123 static const short yyrline[] = { 0,
124 59, 65, 70, 75, 80, 85, 90, 95, 100, 105,
125 110, 115, 120, 126
127 #endif
130 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
132 static const char * const yytname[] = { "$","error","$undefined.","'?'","'|'",
133 "'&'","'='","'!'","'+'","'-'","'*'","'/'","'%'","NUMBER","':'","'n'","'('","')'",
134 "start","exp", NULL
136 #endif
138 static const short yyr1[] = { 0,
139 18, 19, 19, 19, 19, 19, 19, 19, 19, 19,
140 19, 19, 19, 19
143 static const short yyr2[] = { 0,
144 1, 5, 3, 3, 3, 3, 3, 3, 3, 3,
145 3, 1, 1, 3
148 static const short yydefact[] = { 0,
149 13, 12, 0, 1, 0, 0, 0, 0, 0, 0,
150 0, 0, 0, 0, 0, 14, 0, 3, 4, 5,
151 6, 7, 8, 9, 10, 11, 0, 2, 0, 0,
155 static const short yydefgoto[] = { 29,
159 static const short yypact[] = { 58,
160 -32768,-32768, 58, 37, 10, 58, 58, 58, 58, 58,
161 58, 58, 58, 58, 58,-32768, 25, 45, 52, 57,
162 57, 65, 65,-32768,-32768,-32768, 58, 37, 1, 2,
163 -32768
166 static const short yypgoto[] = {-32768,
171 #define YYLAST 77
174 static const short yytable[] = { 5,
175 30, 31, 17, 18, 19, 20, 21, 22, 23, 24,
176 25, 26, 6, 7, 8, 9, 10, 11, 12, 13,
177 14, 15, 0, 28, 0, 0, 16, 6, 7, 8,
178 9, 10, 11, 12, 13, 14, 15, 0, 27, 6,
179 7, 8, 9, 10, 11, 12, 13, 14, 15, 8,
180 9, 10, 11, 12, 13, 14, 15, 9, 10, 11,
181 12, 13, 14, 15, 11, 12, 13, 14, 15, 0,
182 1, 0, 2, 3, 13, 14, 15
185 static const short yycheck[] = { 3,
186 0, 0, 6, 7, 8, 9, 10, 11, 12, 13,
187 14, 15, 3, 4, 5, 6, 7, 8, 9, 10,
188 11, 12, -1, 27, -1, -1, 17, 3, 4, 5,
189 6, 7, 8, 9, 10, 11, 12, -1, 14, 3,
190 4, 5, 6, 7, 8, 9, 10, 11, 12, 5,
191 6, 7, 8, 9, 10, 11, 12, 6, 7, 8,
192 9, 10, 11, 12, 8, 9, 10, 11, 12, -1,
193 13, -1, 15, 16, 10, 11, 12
195 #define YYPURE 1
197 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
198 #line 3 "/usr/lib/bison.simple"
199 /* This file comes from bison-1.28. */
201 /* Skeleton output parser for bison,
202 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
204 This program is free software; you can redistribute it and/or modify
205 it under the terms of the GNU General Public License as published by
206 the Free Software Foundation; either version 2, or (at your option)
207 any later version.
209 This program is distributed in the hope that it will be useful,
210 but WITHOUT ANY WARRANTY; without even the implied warranty of
211 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
212 GNU General Public License for more details.
214 You should have received a copy of the GNU General Public License
215 along with this program; if not, write to the Free Software
216 Foundation, Inc., 59 Temple Place - Suite 330,
217 Boston, MA 02111-1307, USA. */
219 /* As a special exception, when this file is copied by Bison into a
220 Bison output file, you may use that output file without restriction.
221 This special exception was added by the Free Software Foundation
222 in version 1.24 of Bison. */
224 /* This is the parser code that is written into each bison parser
225 when the %semantic_parser declaration is not specified in the grammar.
226 It was written by Richard Stallman by simplifying the hairy parser
227 used when %semantic_parser is specified. */
229 #ifndef YYSTACK_USE_ALLOCA
230 #ifdef alloca
231 #define YYSTACK_USE_ALLOCA
232 #else /* alloca not defined */
233 #ifdef __GNUC__
234 #define YYSTACK_USE_ALLOCA
235 #define alloca __builtin_alloca
236 #else /* not GNU C. */
237 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
238 #define YYSTACK_USE_ALLOCA
239 #include <alloca.h>
240 #else /* not sparc */
241 /* We think this test detects Watcom and Microsoft C. */
242 /* This used to test MSDOS, but that is a bad idea
243 since that symbol is in the user namespace. */
244 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
245 #if 0 /* No need for malloc.h, which pollutes the namespace;
246 instead, just don't use alloca. */
247 #include <malloc.h>
248 #endif
249 #else /* not MSDOS, or __TURBOC__ */
250 #if defined(_AIX)
251 /* I don't know what this was needed for, but it pollutes the namespace.
252 So I turned it off. rms, 2 May 1997. */
253 /* #include <malloc.h> */
254 #pragma alloca
255 #define YYSTACK_USE_ALLOCA
256 #else /* not MSDOS, or __TURBOC__, or _AIX */
257 #if 0
258 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
259 and on HPUX 10. Eventually we can turn this on. */
260 #define YYSTACK_USE_ALLOCA
261 #define alloca __builtin_alloca
262 #endif /* __hpux */
263 #endif
264 #endif /* not _AIX */
265 #endif /* not MSDOS, or __TURBOC__ */
266 #endif /* not sparc */
267 #endif /* not GNU C */
268 #endif /* alloca not defined */
269 #endif /* YYSTACK_USE_ALLOCA not defined */
271 #ifdef YYSTACK_USE_ALLOCA
272 #define YYSTACK_ALLOC alloca
273 #else
274 #define YYSTACK_ALLOC malloc
275 #endif
277 /* Note: there must be only one dollar sign in this file.
278 It is replaced by the list of actions, each action
279 as one case of the switch. */
281 #define yyerrok (yyerrstatus = 0)
282 #define yyclearin (yychar = YYEMPTY)
283 #define YYEMPTY -2
284 #define YYEOF 0
285 #define YYACCEPT goto yyacceptlab
286 #define YYABORT goto yyabortlab
287 #define YYERROR goto yyerrlab1
288 /* Like YYERROR except do call yyerror.
289 This remains here temporarily to ease the
290 transition to the new meaning of YYERROR, for GCC.
291 Once GCC version 2 has supplanted version 1, this can go. */
292 #define YYFAIL goto yyerrlab
293 #define YYRECOVERING() (!!yyerrstatus)
294 #define YYBACKUP(token, value) \
295 do \
296 if (yychar == YYEMPTY && yylen == 1) \
297 { yychar = (token), yylval = (value); \
298 yychar1 = YYTRANSLATE (yychar); \
299 YYPOPSTACK; \
300 goto yybackup; \
302 else \
303 { yyerror ("syntax error: cannot back up"); YYERROR; } \
304 while (0)
306 #define YYTERROR 1
307 #define YYERRCODE 256
309 #ifndef YYPURE
310 #define YYLEX yylex()
311 #endif
313 #ifdef YYPURE
314 #ifdef YYLSP_NEEDED
315 #ifdef YYLEX_PARAM
316 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
317 #else
318 #define YYLEX yylex(&yylval, &yylloc)
319 #endif
320 #else /* not YYLSP_NEEDED */
321 #ifdef YYLEX_PARAM
322 #define YYLEX yylex(&yylval, YYLEX_PARAM)
323 #else
324 #define YYLEX yylex(&yylval)
325 #endif
326 #endif /* not YYLSP_NEEDED */
327 #endif
329 /* If nonreentrant, generate the variables here */
331 #ifndef YYPURE
333 int yychar; /* the lookahead symbol */
334 YYSTYPE yylval; /* the semantic value of the */
335 /* lookahead symbol */
337 #ifdef YYLSP_NEEDED
338 YYLTYPE yylloc; /* location data for the lookahead */
339 /* symbol */
340 #endif
342 int yynerrs; /* number of parse errors so far */
343 #endif /* not YYPURE */
345 #if YYDEBUG != 0
346 int yydebug; /* nonzero means print parse trace */
347 /* Since this is uninitialized, it does not stop multiple parsers
348 from coexisting. */
349 #endif
351 /* YYINITDEPTH indicates the initial size of the parser's stacks */
353 #ifndef YYINITDEPTH
354 #define YYINITDEPTH 200
355 #endif
357 /* YYMAXDEPTH is the maximum size the stacks can grow to
358 (effective only if the built-in stack extension method is used). */
360 #if YYMAXDEPTH == 0
361 #undef YYMAXDEPTH
362 #endif
364 #ifndef YYMAXDEPTH
365 #define YYMAXDEPTH 10000
366 #endif
368 /* Define __yy_memcpy. Note that the size argument
369 should be passed with type unsigned int, because that is what the non-GCC
370 definitions require. With GCC, __builtin_memcpy takes an arg
371 of type size_t, but it can handle unsigned int. */
373 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
374 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
375 #else /* not GNU C or C++ */
376 #ifndef __cplusplus
378 /* This is the most reliable way to avoid incompatibilities
379 in available built-in functions on various systems. */
380 static void
381 __yy_memcpy (to, from, count)
382 char *to;
383 char *from;
384 unsigned int count;
386 register char *f = from;
387 register char *t = to;
388 register int i = count;
390 while (i-- > 0)
391 *t++ = *f++;
394 #else /* __cplusplus */
396 /* This is the most reliable way to avoid incompatibilities
397 in available built-in functions on various systems. */
398 static void
399 __yy_memcpy (char *to, char *from, unsigned int count)
401 register char *t = to;
402 register char *f = from;
403 register int i = count;
405 while (i-- > 0)
406 *t++ = *f++;
409 #endif
410 #endif
412 #line 217 "/usr/lib/bison.simple"
414 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
415 into yyparse. The argument should have type void *.
416 It should actually point to an object.
417 Grammar actions can access the variable by casting it
418 to the proper pointer type. */
420 #ifdef YYPARSE_PARAM
421 #ifdef __cplusplus
422 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
423 #define YYPARSE_PARAM_DECL
424 #else /* not __cplusplus */
425 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
426 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
427 #endif /* not __cplusplus */
428 #else /* not YYPARSE_PARAM */
429 #define YYPARSE_PARAM_ARG
430 #define YYPARSE_PARAM_DECL
431 #endif /* not YYPARSE_PARAM */
433 /* Prevent warning if -Wstrict-prototypes. */
434 #ifdef __GNUC__
435 #ifdef YYPARSE_PARAM
436 int yyparse (void *);
437 #else
438 int yyparse (void);
439 #endif
440 #endif
443 yyparse(YYPARSE_PARAM_ARG)
444 YYPARSE_PARAM_DECL
446 register int yystate;
447 register int yyn;
448 register short *yyssp;
449 register YYSTYPE *yyvsp;
450 int yyerrstatus; /* number of tokens to shift before error messages enabled */
451 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
453 short yyssa[YYINITDEPTH]; /* the state stack */
454 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
456 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
457 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
459 #ifdef YYLSP_NEEDED
460 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
461 YYLTYPE *yyls = yylsa;
462 YYLTYPE *yylsp;
464 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
465 #else
466 #define YYPOPSTACK (yyvsp--, yyssp--)
467 #endif
469 int yystacksize = YYINITDEPTH;
470 int yyfree_stacks = 0;
472 #ifdef YYPURE
473 int yychar;
474 YYSTYPE yylval;
475 int yynerrs;
476 #ifdef YYLSP_NEEDED
477 YYLTYPE yylloc;
478 #endif
479 #endif
481 YYSTYPE yyval; /* the variable used to return */
482 /* semantic values from the action */
483 /* routines */
485 int yylen;
487 #if YYDEBUG != 0
488 if (yydebug)
489 fprintf(stderr, "Starting parse\n");
490 #endif
492 yystate = 0;
493 yyerrstatus = 0;
494 yynerrs = 0;
495 yychar = YYEMPTY; /* Cause a token to be read. */
497 /* Initialize stack pointers.
498 Waste one element of value and location stack
499 so that they stay on the same level as the state stack.
500 The wasted elements are never initialized. */
502 yyssp = yyss - 1;
503 yyvsp = yyvs;
504 #ifdef YYLSP_NEEDED
505 yylsp = yyls;
506 #endif
508 /* Push a new state, which is found in yystate . */
509 /* In all cases, when you get here, the value and location stacks
510 have just been pushed. so pushing a state here evens the stacks. */
511 yynewstate:
513 *++yyssp = yystate;
515 if (yyssp >= yyss + yystacksize - 1)
517 /* Give user a chance to reallocate the stack */
518 /* Use copies of these so that the &'s don't force the real ones into memory. */
519 YYSTYPE *yyvs1 = yyvs;
520 short *yyss1 = yyss;
521 #ifdef YYLSP_NEEDED
522 YYLTYPE *yyls1 = yyls;
523 #endif
525 /* Get the current used size of the three stacks, in elements. */
526 int size = yyssp - yyss + 1;
528 #ifdef yyoverflow
529 /* Each stack pointer address is followed by the size of
530 the data in use in that stack, in bytes. */
531 #ifdef YYLSP_NEEDED
532 /* This used to be a conditional around just the two extra args,
533 but that might be undefined if yyoverflow is a macro. */
534 yyoverflow("parser stack overflow",
535 &yyss1, size * sizeof (*yyssp),
536 &yyvs1, size * sizeof (*yyvsp),
537 &yyls1, size * sizeof (*yylsp),
538 &yystacksize);
539 #else
540 yyoverflow("parser stack overflow",
541 &yyss1, size * sizeof (*yyssp),
542 &yyvs1, size * sizeof (*yyvsp),
543 &yystacksize);
544 #endif
546 yyss = yyss1; yyvs = yyvs1;
547 #ifdef YYLSP_NEEDED
548 yyls = yyls1;
549 #endif
550 #else /* no yyoverflow */
551 /* Extend the stack our own way. */
552 if (yystacksize >= YYMAXDEPTH)
554 yyerror("parser stack overflow");
555 if (yyfree_stacks)
557 free (yyss);
558 free (yyvs);
559 #ifdef YYLSP_NEEDED
560 free (yyls);
561 #endif
563 return 2;
565 yystacksize *= 2;
566 if (yystacksize > YYMAXDEPTH)
567 yystacksize = YYMAXDEPTH;
568 #ifndef YYSTACK_USE_ALLOCA
569 yyfree_stacks = 1;
570 #endif
571 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
572 __yy_memcpy ((char *)yyss, (char *)yyss1,
573 size * (unsigned int) sizeof (*yyssp));
574 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
575 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
576 size * (unsigned int) sizeof (*yyvsp));
577 #ifdef YYLSP_NEEDED
578 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
579 __yy_memcpy ((char *)yyls, (char *)yyls1,
580 size * (unsigned int) sizeof (*yylsp));
581 #endif
582 #endif /* no yyoverflow */
584 yyssp = yyss + size - 1;
585 yyvsp = yyvs + size - 1;
586 #ifdef YYLSP_NEEDED
587 yylsp = yyls + size - 1;
588 #endif
590 #if YYDEBUG != 0
591 if (yydebug)
592 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
593 #endif
595 if (yyssp >= yyss + yystacksize - 1)
596 YYABORT;
599 #if YYDEBUG != 0
600 if (yydebug)
601 fprintf(stderr, "Entering state %d\n", yystate);
602 #endif
604 goto yybackup;
605 yybackup:
607 /* Do appropriate processing given the current state. */
608 /* Read a lookahead token if we need one and don't already have one. */
609 /* yyresume: */
611 /* First try to decide what to do without reference to lookahead token. */
613 yyn = yypact[yystate];
614 if (yyn == YYFLAG)
615 goto yydefault;
617 /* Not known => get a lookahead token if don't already have one. */
619 /* yychar is either YYEMPTY or YYEOF
620 or a valid token in external form. */
622 if (yychar == YYEMPTY)
624 #if YYDEBUG != 0
625 if (yydebug)
626 fprintf(stderr, "Reading a token: ");
627 #endif
628 yychar = YYLEX;
631 /* Convert token to internal form (in yychar1) for indexing tables with */
633 if (yychar <= 0) /* This means end of input. */
635 yychar1 = 0;
636 yychar = YYEOF; /* Don't call YYLEX any more */
638 #if YYDEBUG != 0
639 if (yydebug)
640 fprintf(stderr, "Now at end of input.\n");
641 #endif
643 else
645 yychar1 = YYTRANSLATE(yychar);
647 #if YYDEBUG != 0
648 if (yydebug)
650 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
651 /* Give the individual parser a way to print the precise meaning
652 of a token, for further debugging info. */
653 #ifdef YYPRINT
654 YYPRINT (stderr, yychar, yylval);
655 #endif
656 fprintf (stderr, ")\n");
658 #endif
661 yyn += yychar1;
662 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
663 goto yydefault;
665 yyn = yytable[yyn];
667 /* yyn is what to do for this token type in this state.
668 Negative => reduce, -yyn is rule number.
669 Positive => shift, yyn is new state.
670 New state is final state => don't bother to shift,
671 just return success.
672 0, or most negative number => error. */
674 if (yyn < 0)
676 if (yyn == YYFLAG)
677 goto yyerrlab;
678 yyn = -yyn;
679 goto yyreduce;
681 else if (yyn == 0)
682 goto yyerrlab;
684 if (yyn == YYFINAL)
685 YYACCEPT;
687 /* Shift the lookahead token. */
689 #if YYDEBUG != 0
690 if (yydebug)
691 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
692 #endif
694 /* Discard the token being shifted unless it is eof. */
695 if (yychar != YYEOF)
696 yychar = YYEMPTY;
698 *++yyvsp = yylval;
699 #ifdef YYLSP_NEEDED
700 *++yylsp = yylloc;
701 #endif
703 /* count tokens shifted since error; after three, turn off error status. */
704 if (yyerrstatus) yyerrstatus--;
706 yystate = yyn;
707 goto yynewstate;
709 /* Do the default action for the current state. */
710 yydefault:
712 yyn = yydefact[yystate];
713 if (yyn == 0)
714 goto yyerrlab;
716 /* Do a reduction. yyn is the number of a rule to reduce with. */
717 yyreduce:
718 yylen = yyr2[yyn];
719 if (yylen > 0)
720 yyval = yyvsp[1-yylen]; /* implement default value of the action */
722 #if YYDEBUG != 0
723 if (yydebug)
725 int i;
727 fprintf (stderr, "Reducing via rule %d (line %d), ",
728 yyn, yyrline[yyn]);
730 /* Print the symbols being reduced, and their result. */
731 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
732 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
733 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
735 #endif
738 switch (yyn) {
740 case 1:
741 #line 60 "plural.y"
743 ((struct parse_args *) arg)->res = yyvsp[0].exp;
745 break;}
746 case 2:
747 #line 66 "plural.y"
749 if ((yyval.exp = new_exp (qmop, 3, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp)) == NULL)
750 YYABORT
752 break;}
753 case 3:
754 #line 71 "plural.y"
756 if ((yyval.exp = new_exp (lor, 2, yyvsp[-2].exp, yyvsp[0].exp)) == NULL)
757 YYABORT
759 break;}
760 case 4:
761 #line 76 "plural.y"
763 if ((yyval.exp = new_exp (land, 2, yyvsp[-2].exp, yyvsp[0].exp)) == NULL)
764 YYABORT
766 break;}
767 case 5:
768 #line 81 "plural.y"
770 if ((yyval.exp = new_exp (equal, 2, yyvsp[-2].exp, yyvsp[0].exp)) == NULL)
771 YYABORT
773 break;}
774 case 6:
775 #line 86 "plural.y"
777 if ((yyval.exp = new_exp (not_equal, 2, yyvsp[-2].exp, yyvsp[0].exp)) == NULL)
778 YYABORT
780 break;}
781 case 7:
782 #line 91 "plural.y"
784 if ((yyval.exp = new_exp (plus, 2, yyvsp[-2].exp, yyvsp[0].exp)) == NULL)
785 YYABORT
787 break;}
788 case 8:
789 #line 96 "plural.y"
791 if ((yyval.exp = new_exp (minus, 2, yyvsp[-2].exp, yyvsp[0].exp)) == NULL)
792 YYABORT
794 break;}
795 case 9:
796 #line 101 "plural.y"
798 if ((yyval.exp = new_exp (mult, 2, yyvsp[-2].exp, yyvsp[0].exp)) == NULL)
799 YYABORT
801 break;}
802 case 10:
803 #line 106 "plural.y"
805 if ((yyval.exp = new_exp (divide, 2, yyvsp[-2].exp, yyvsp[0].exp)) == NULL)
806 YYABORT
808 break;}
809 case 11:
810 #line 111 "plural.y"
812 if ((yyval.exp = new_exp (module, 2, yyvsp[-2].exp, yyvsp[0].exp)) == NULL)
813 YYABORT
815 break;}
816 case 12:
817 #line 116 "plural.y"
819 if ((yyval.exp = new_exp (var, 0)) == NULL)
820 YYABORT
822 break;}
823 case 13:
824 #line 121 "plural.y"
826 if ((yyval.exp = new_exp (num, 0)) == NULL)
827 YYABORT;
828 yyval.exp->val.num = yyvsp[0].num
830 break;}
831 case 14:
832 #line 127 "plural.y"
834 yyval.exp = yyvsp[-1].exp
836 break;}
838 /* the action file gets copied in in place of this dollarsign */
839 #line 543 "/usr/lib/bison.simple"
841 yyvsp -= yylen;
842 yyssp -= yylen;
843 #ifdef YYLSP_NEEDED
844 yylsp -= yylen;
845 #endif
847 #if YYDEBUG != 0
848 if (yydebug)
850 short *ssp1 = yyss - 1;
851 fprintf (stderr, "state stack now");
852 while (ssp1 != yyssp)
853 fprintf (stderr, " %d", *++ssp1);
854 fprintf (stderr, "\n");
856 #endif
858 *++yyvsp = yyval;
860 #ifdef YYLSP_NEEDED
861 yylsp++;
862 if (yylen == 0)
864 yylsp->first_line = yylloc.first_line;
865 yylsp->first_column = yylloc.first_column;
866 yylsp->last_line = (yylsp-1)->last_line;
867 yylsp->last_column = (yylsp-1)->last_column;
868 yylsp->text = 0;
870 else
872 yylsp->last_line = (yylsp+yylen-1)->last_line;
873 yylsp->last_column = (yylsp+yylen-1)->last_column;
875 #endif
877 /* Now "shift" the result of the reduction.
878 Determine what state that goes to,
879 based on the state we popped back to
880 and the rule number reduced by. */
882 yyn = yyr1[yyn];
884 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
885 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
886 yystate = yytable[yystate];
887 else
888 yystate = yydefgoto[yyn - YYNTBASE];
890 goto yynewstate;
892 yyerrlab: /* here on detecting error */
894 if (! yyerrstatus)
895 /* If not already recovering from an error, report this error. */
897 ++yynerrs;
899 #ifdef YYERROR_VERBOSE
900 yyn = yypact[yystate];
902 if (yyn > YYFLAG && yyn < YYLAST)
904 int size = 0;
905 char *msg;
906 int x, count;
908 count = 0;
909 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
910 for (x = (yyn < 0 ? -yyn : 0);
911 x < (sizeof(yytname) / sizeof(char *)); x++)
912 if (yycheck[x + yyn] == x)
913 size += strlen(yytname[x]) + 15, count++;
914 msg = (char *) malloc(size + 15);
915 if (msg != 0)
917 strcpy(msg, "parse error");
919 if (count < 5)
921 count = 0;
922 for (x = (yyn < 0 ? -yyn : 0);
923 x < (sizeof(yytname) / sizeof(char *)); x++)
924 if (yycheck[x + yyn] == x)
926 strcat(msg, count == 0 ? ", expecting `" : " or `");
927 strcat(msg, yytname[x]);
928 strcat(msg, "'");
929 count++;
932 yyerror(msg);
933 free(msg);
935 else
936 yyerror ("parse error; also virtual memory exceeded");
938 else
939 #endif /* YYERROR_VERBOSE */
940 yyerror("parse error");
943 goto yyerrlab1;
944 yyerrlab1: /* here on error raised explicitly by an action */
946 if (yyerrstatus == 3)
948 /* if just tried and failed to reuse lookahead token after an error, discard it. */
950 /* return failure if at end of input */
951 if (yychar == YYEOF)
952 YYABORT;
954 #if YYDEBUG != 0
955 if (yydebug)
956 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
957 #endif
959 yychar = YYEMPTY;
962 /* Else will try to reuse lookahead token
963 after shifting the error token. */
965 yyerrstatus = 3; /* Each real token shifted decrements this */
967 goto yyerrhandle;
969 yyerrdefault: /* current state does not do anything special for the error token. */
971 #if 0
972 /* This is wrong; only states that explicitly want error tokens
973 should shift them. */
974 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
975 if (yyn) goto yydefault;
976 #endif
978 yyerrpop: /* pop the current state because it cannot handle the error token */
980 if (yyssp == yyss) YYABORT;
981 yyvsp--;
982 yystate = *--yyssp;
983 #ifdef YYLSP_NEEDED
984 yylsp--;
985 #endif
987 #if YYDEBUG != 0
988 if (yydebug)
990 short *ssp1 = yyss - 1;
991 fprintf (stderr, "Error: state stack now");
992 while (ssp1 != yyssp)
993 fprintf (stderr, " %d", *++ssp1);
994 fprintf (stderr, "\n");
996 #endif
998 yyerrhandle:
1000 yyn = yypact[yystate];
1001 if (yyn == YYFLAG)
1002 goto yyerrdefault;
1004 yyn += YYTERROR;
1005 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1006 goto yyerrdefault;
1008 yyn = yytable[yyn];
1009 if (yyn < 0)
1011 if (yyn == YYFLAG)
1012 goto yyerrpop;
1013 yyn = -yyn;
1014 goto yyreduce;
1016 else if (yyn == 0)
1017 goto yyerrpop;
1019 if (yyn == YYFINAL)
1020 YYACCEPT;
1022 #if YYDEBUG != 0
1023 if (yydebug)
1024 fprintf(stderr, "Shifting error token, ");
1025 #endif
1027 *++yyvsp = yylval;
1028 #ifdef YYLSP_NEEDED
1029 *++yylsp = yylloc;
1030 #endif
1032 yystate = yyn;
1033 goto yynewstate;
1035 yyacceptlab:
1036 /* YYACCEPT comes here. */
1037 if (yyfree_stacks)
1039 free (yyss);
1040 free (yyvs);
1041 #ifdef YYLSP_NEEDED
1042 free (yyls);
1043 #endif
1045 return 0;
1047 yyabortlab:
1048 /* YYABORT comes here. */
1049 if (yyfree_stacks)
1051 free (yyss);
1052 free (yyvs);
1053 #ifdef YYLSP_NEEDED
1054 free (yyls);
1055 #endif
1057 return 1;
1059 #line 132 "plural.y"
1062 static struct expression *
1063 new_exp (enum operator op, int n, ...)
1065 struct expression *newp = (struct expression *) calloc (1, sizeof (*newp));
1066 va_list va;
1068 va_start (va, n);
1070 if (newp == NULL)
1071 while (n-- > 0)
1072 __gettext_free_exp (va_arg (va, struct expression *));
1073 else
1075 newp->operation = op;
1076 if (n > 0)
1078 newp->val.args3.bexp = va_arg (va, struct expression *);
1079 newp->val.args3.tbranch = va_arg (va, struct expression *);
1081 if (n > 2)
1082 newp->val.args3.fbranch = va_arg (va, struct expression *);
1084 if (newp->val.args3.bexp == NULL
1085 || newp->val.args3.tbranch == NULL
1086 || (n > 2 && newp->val.args3.fbranch == NULL))
1088 __gettext_free_exp (newp);
1089 newp = NULL;
1094 va_end (va);
1096 return newp;
1099 void
1100 internal_function
1101 __gettext_free_exp (struct expression *exp)
1103 if (exp == NULL)
1104 return;
1106 /* Handle the recursive case. */
1107 switch (exp->operation)
1109 case qmop:
1110 __gettext_free_exp (exp->val.args3.fbranch);
1111 /* FALLTHROUGH */
1113 case mult:
1114 case divide:
1115 case module:
1116 case plus:
1117 case minus:
1118 case equal:
1119 case not_equal:
1120 case land:
1121 case lor:
1122 __gettext_free_exp (exp->val.args2.right);
1123 __gettext_free_exp (exp->val.args2.left);
1124 break;
1126 default:
1127 break;
1130 free (exp);
1134 static int
1135 yylex (YYSTYPE *lval, const char **pexp)
1137 const char *exp = *pexp;
1138 int result;
1140 while (1)
1142 if (exp[0] == '\\' && exp[1] == '\n')
1144 exp += 2;
1145 continue;
1148 if (exp[0] == '\0')
1150 *pexp = exp;
1151 return YYEOF;
1154 if (exp[0] != ' ' && exp[0] != '\t')
1155 break;
1157 ++exp;
1160 result = *exp++;
1161 switch (result)
1163 case '0': case '1': case '2': case '3': case '4':
1164 case '5': case '6': case '7': case '8': case '9':
1166 unsigned long int n = result - '0';
1167 while (exp[0] >= '0' && exp[0] <= '9')
1169 n *= 10;
1170 n += exp[0] - '0';
1171 ++exp;
1173 lval->num = n;
1174 result = NUMBER;
1176 break;
1178 case '=':
1179 case '!':
1180 if (exp[0] == '=')
1181 ++exp;
1182 else
1183 result = YYERRCODE;
1184 break;
1186 case '&':
1187 case '|':
1188 if (exp[0] == result)
1189 ++exp;
1190 else
1191 result = YYERRCODE;
1192 break;
1194 case 'n':
1195 case '*':
1196 case '/':
1197 case '%':
1198 case '+':
1199 case '-':
1200 case '?':
1201 case ':':
1202 case '(':
1203 case ')':
1204 /* Nothing, just return the character. */
1205 break;
1207 case ';':
1208 case '\n':
1209 case '\0':
1210 /* Be safe and let the user call this function again. */
1211 --exp;
1212 result = YYEOF;
1213 break;
1215 default:
1216 result = YYERRCODE;
1217 #if YYDEBUG != 0
1218 --exp;
1219 #endif
1220 break;
1223 *pexp = exp;
1225 return result;
1229 static void
1230 yyerror (const char *str)
1232 /* Do nothing. We don't print error messages here. */