* posix/getconf.c: Update copyright year.
[glibc.git] / intl / plural.c
blob69c5597bbd54cb3c681d2d93057d0338dd409f5d
1 /* A Bison parser, made from plural.y
2 by GNU bison 1.35. */
4 #define YYBISON 1 /* Identify Bison output. */
6 #define yyparse __gettextparse
7 #define yylex __gettextlex
8 #define yyerror __gettexterror
9 #define yylval __gettextlval
10 #define yychar __gettextchar
11 #define yydebug __gettextdebug
12 #define yynerrs __gettextnerrs
13 # define EQUOP2 257
14 # define CMPOP2 258
15 # define ADDOP2 259
16 # define MULOP2 260
17 # define NUMBER 261
19 #line 1 "plural.y"
21 /* Expression parsing for plural form selection.
22 Copyright (C) 2000, 2001 Free Software Foundation, Inc.
23 This file is part of the GNU C Library.
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 Lesser General Public
28 License as published by the Free Software Foundation; either
29 version 2.1 of the 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 Lesser General Public License for more details.
36 You should have received a copy of the GNU Lesser General Public
37 License along with the GNU C Library; if not, write to the Free
38 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
39 02111-1307 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
48 #ifdef HAVE_CONFIG_H
49 # include <config.h>
50 #endif
52 #include <stddef.h>
53 #include <stdlib.h>
54 #include <string.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 #ifndef YYSTYPE
68 typedef union {
69 unsigned long int num;
70 enum operator op;
71 struct expression *exp;
72 } yystype;
73 # define YYSTYPE yystype
74 # define YYSTYPE_IS_TRIVIAL 1
75 #endif
76 #line 55 "plural.y"
78 /* Prototypes for local functions. */
79 static struct expression *new_exp PARAMS ((int nargs, enum operator op,
80 struct expression * const *args));
81 static inline struct expression *new_exp_0 PARAMS ((enum operator op));
82 static inline struct expression *new_exp_1 PARAMS ((enum operator op,
83 struct expression *right));
84 static struct expression *new_exp_2 PARAMS ((enum operator op,
85 struct expression *left,
86 struct expression *right));
87 static inline struct expression *new_exp_3 PARAMS ((enum operator op,
88 struct expression *bexp,
89 struct expression *tbranch,
90 struct expression *fbranch));
91 static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
92 static void yyerror PARAMS ((const char *str));
94 /* Allocation of expressions. */
96 static struct expression *
97 new_exp (nargs, op, args)
98 int nargs;
99 enum operator op;
100 struct expression * const *args;
102 int i;
103 struct expression *newp;
105 /* If any of the argument could not be malloc'ed, just return NULL. */
106 for (i = nargs - 1; i >= 0; i--)
107 if (args[i] == NULL)
108 goto fail;
110 /* Allocate a new expression. */
111 newp = (struct expression *) malloc (sizeof (*newp));
112 if (newp != NULL)
114 newp->nargs = nargs;
115 newp->operation = op;
116 for (i = nargs - 1; i >= 0; i--)
117 newp->val.args[i] = args[i];
118 return newp;
121 fail:
122 for (i = nargs - 1; i >= 0; i--)
123 FREE_EXPRESSION (args[i]);
125 return NULL;
128 static inline struct expression *
129 new_exp_0 (op)
130 enum operator op;
132 return new_exp (0, op, NULL);
135 static inline struct expression *
136 new_exp_1 (op, right)
137 enum operator op;
138 struct expression *right;
140 struct expression *args[1];
142 args[0] = right;
143 return new_exp (1, op, args);
146 static struct expression *
147 new_exp_2 (op, left, right)
148 enum operator op;
149 struct expression *left;
150 struct expression *right;
152 struct expression *args[2];
154 args[0] = left;
155 args[1] = right;
156 return new_exp (2, op, args);
159 static inline struct expression *
160 new_exp_3 (op, bexp, tbranch, fbranch)
161 enum operator op;
162 struct expression *bexp;
163 struct expression *tbranch;
164 struct expression *fbranch;
166 struct expression *args[3];
168 args[0] = bexp;
169 args[1] = tbranch;
170 args[2] = fbranch;
171 return new_exp (3, op, args);
174 #ifndef YYDEBUG
175 # define YYDEBUG 0
176 #endif
180 #define YYFINAL 27
181 #define YYFLAG -32768
182 #define YYNTBASE 16
184 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
185 #define YYTRANSLATE(x) ((unsigned)(x) <= 261 ? yytranslate[x] : 18)
187 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
188 static const char yytranslate[] =
190 0, 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, 10, 2, 2, 2, 2, 5, 2,
194 14, 15, 2, 2, 2, 2, 2, 2, 2, 2,
195 2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
196 2, 2, 2, 3, 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 13, 2, 2, 2, 2, 2, 2, 2, 2, 2,
202 2, 2, 2, 2, 4, 2, 2, 2, 2, 2,
203 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
204 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
205 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
206 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
207 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
208 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
209 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
210 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
211 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
212 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
213 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
214 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
215 2, 2, 2, 2, 2, 2, 1, 6, 7, 8,
216 9, 11
219 #if YYDEBUG
220 static const short yyprhs[] =
222 0, 0, 2, 8, 12, 16, 20, 24, 28, 32,
223 35, 37, 39
225 static const short yyrhs[] =
227 17, 0, 17, 3, 17, 12, 17, 0, 17, 4,
228 17, 0, 17, 5, 17, 0, 17, 6, 17, 0,
229 17, 7, 17, 0, 17, 8, 17, 0, 17, 9,
230 17, 0, 10, 17, 0, 13, 0, 11, 0, 14,
231 17, 15, 0
234 #endif
236 #if YYDEBUG
237 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
238 static const short yyrline[] =
240 0, 174, 182, 186, 190, 194, 198, 202, 206, 210,
241 214, 218, 223
243 #endif
246 #if (YYDEBUG) || defined YYERROR_VERBOSE
248 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
249 static const char *const yytname[] =
251 "$", "error", "$undefined.", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
252 "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
253 "start", "exp", 0
255 #endif
257 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
258 static const short yyr1[] =
260 0, 16, 17, 17, 17, 17, 17, 17, 17, 17,
261 17, 17, 17
264 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
265 static const short yyr2[] =
267 0, 1, 5, 3, 3, 3, 3, 3, 3, 2,
268 1, 1, 3
271 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
272 doesn't specify something else to do. Zero means the default is an
273 error. */
274 static const short yydefact[] =
276 0, 0, 11, 10, 0, 1, 9, 0, 0, 0,
277 0, 0, 0, 0, 0, 12, 0, 3, 4, 5,
278 6, 7, 8, 0, 2, 0, 0, 0
281 static const short yydefgoto[] =
283 25, 5
286 static const short yypact[] =
288 -9, -9,-32768,-32768, -9, 34,-32768, 11, -9, -9,
289 -9, -9, -9, -9, -9,-32768, 24, 39, 43, 16,
290 26, -3,-32768, -9, 34, 21, 53,-32768
293 static const short yypgoto[] =
295 -32768, -1
299 #define YYLAST 53
302 static const short yytable[] =
304 6, 1, 2, 7, 3, 4, 14, 16, 17, 18,
305 19, 20, 21, 22, 8, 9, 10, 11, 12, 13,
306 14, 26, 24, 12, 13, 14, 15, 8, 9, 10,
307 11, 12, 13, 14, 13, 14, 23, 8, 9, 10,
308 11, 12, 13, 14, 10, 11, 12, 13, 14, 11,
309 12, 13, 14, 27
312 static const short yycheck[] =
314 1, 10, 11, 4, 13, 14, 9, 8, 9, 10,
315 11, 12, 13, 14, 3, 4, 5, 6, 7, 8,
316 9, 0, 23, 7, 8, 9, 15, 3, 4, 5,
317 6, 7, 8, 9, 8, 9, 12, 3, 4, 5,
318 6, 7, 8, 9, 5, 6, 7, 8, 9, 6,
319 7, 8, 9, 0
321 #define YYPURE 1
323 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
324 #line 3 "/castro/street/H-alpha-linux/share/bison/bison.simple"
326 /* Skeleton output parser for bison,
328 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
329 Foundation, Inc.
331 This program is free software; you can redistribute it and/or modify
332 it under the terms of the GNU General Public License as published by
333 the Free Software Foundation; either version 2, or (at your option)
334 any later version.
336 This program is distributed in the hope that it will be useful,
337 but WITHOUT ANY WARRANTY; without even the implied warranty of
338 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
339 GNU General Public License for more details.
341 You should have received a copy of the GNU General Public License
342 along with this program; if not, write to the Free Software
343 Foundation, Inc., 59 Temple Place - Suite 330,
344 Boston, MA 02111-1307, USA. */
346 /* As a special exception, when this file is copied by Bison into a
347 Bison output file, you may use that output file without restriction.
348 This special exception was added by the Free Software Foundation
349 in version 1.24 of Bison. */
351 /* This is the parser code that is written into each bison parser when
352 the %semantic_parser declaration is not specified in the grammar.
353 It was written by Richard Stallman by simplifying the hairy parser
354 used when %semantic_parser is specified. */
356 /* All symbols defined below should begin with yy or YY, to avoid
357 infringing on user name space. This should be done even for local
358 variables, as they might otherwise be expanded by user macros.
359 There are some unavoidable exceptions within include files to
360 define necessary library symbols; they are noted "INFRINGES ON
361 USER NAME SPACE" below. */
363 #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
365 /* The parser invokes alloca or malloc; define the necessary symbols. */
367 # if YYSTACK_USE_ALLOCA
368 # define YYSTACK_ALLOC alloca
369 # else
370 # ifndef YYSTACK_USE_ALLOCA
371 # if defined (alloca) || defined (_ALLOCA_H)
372 # define YYSTACK_ALLOC alloca
373 # else
374 # ifdef __GNUC__
375 # define YYSTACK_ALLOC __builtin_alloca
376 # endif
377 # endif
378 # endif
379 # endif
381 # ifdef YYSTACK_ALLOC
382 /* Pacify GCC's `empty if-body' warning. */
383 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
384 # else
385 # if defined (__STDC__) || defined (__cplusplus)
386 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
387 # define YYSIZE_T size_t
388 # endif
389 # define YYSTACK_ALLOC malloc
390 # define YYSTACK_FREE free
391 # endif
392 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
395 #if (! defined (yyoverflow) \
396 && (! defined (__cplusplus) \
397 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
399 /* A type that is properly aligned for any stack member. */
400 union yyalloc
402 short yyss;
403 YYSTYPE yyvs;
404 # if YYLSP_NEEDED
405 YYLTYPE yyls;
406 # endif
409 /* The size of the maximum gap between one aligned stack and the next. */
410 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
412 /* The size of an array large to enough to hold all stacks, each with
413 N elements. */
414 # if YYLSP_NEEDED
415 # define YYSTACK_BYTES(N) \
416 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
417 + 2 * YYSTACK_GAP_MAX)
418 # else
419 # define YYSTACK_BYTES(N) \
420 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
421 + YYSTACK_GAP_MAX)
422 # endif
424 /* Copy COUNT objects from FROM to TO. The source and destination do
425 not overlap. */
426 # ifndef YYCOPY
427 # if 1 < __GNUC__
428 # define YYCOPY(To, From, Count) \
429 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
430 # else
431 # define YYCOPY(To, From, Count) \
432 do \
434 register YYSIZE_T yyi; \
435 for (yyi = 0; yyi < (Count); yyi++) \
436 (To)[yyi] = (From)[yyi]; \
438 while (0)
439 # endif
440 # endif
442 /* Relocate STACK from its old location to the new one. The
443 local variables YYSIZE and YYSTACKSIZE give the old and new number of
444 elements in the stack, and YYPTR gives the new location of the
445 stack. Advance YYPTR to a properly aligned location for the next
446 stack. */
447 # define YYSTACK_RELOCATE(Stack) \
448 do \
450 YYSIZE_T yynewbytes; \
451 YYCOPY (&yyptr->Stack, Stack, yysize); \
452 Stack = &yyptr->Stack; \
453 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
454 yyptr += yynewbytes / sizeof (*yyptr); \
456 while (0)
458 #endif
461 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
462 # define YYSIZE_T __SIZE_TYPE__
463 #endif
464 #if ! defined (YYSIZE_T) && defined (size_t)
465 # define YYSIZE_T size_t
466 #endif
467 #if ! defined (YYSIZE_T)
468 # if defined (__STDC__) || defined (__cplusplus)
469 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
470 # define YYSIZE_T size_t
471 # endif
472 #endif
473 #if ! defined (YYSIZE_T)
474 # define YYSIZE_T unsigned int
475 #endif
477 #define yyerrok (yyerrstatus = 0)
478 #define yyclearin (yychar = YYEMPTY)
479 #define YYEMPTY -2
480 #define YYEOF 0
481 #define YYACCEPT goto yyacceptlab
482 #define YYABORT goto yyabortlab
483 #define YYERROR goto yyerrlab1
484 /* Like YYERROR except do call yyerror. This remains here temporarily
485 to ease the transition to the new meaning of YYERROR, for GCC.
486 Once GCC version 2 has supplanted version 1, this can go. */
487 #define YYFAIL goto yyerrlab
488 #define YYRECOVERING() (!!yyerrstatus)
489 #define YYBACKUP(Token, Value) \
490 do \
491 if (yychar == YYEMPTY && yylen == 1) \
493 yychar = (Token); \
494 yylval = (Value); \
495 yychar1 = YYTRANSLATE (yychar); \
496 YYPOPSTACK; \
497 goto yybackup; \
499 else \
501 yyerror ("syntax error: cannot back up"); \
502 YYERROR; \
504 while (0)
506 #define YYTERROR 1
507 #define YYERRCODE 256
510 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
511 are run).
513 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
514 first token. By default, to implement support for ranges, extend
515 its range to the last symbol. */
517 #ifndef YYLLOC_DEFAULT
518 # define YYLLOC_DEFAULT(Current, Rhs, N) \
519 Current.last_line = Rhs[N].last_line; \
520 Current.last_column = Rhs[N].last_column;
521 #endif
524 /* YYLEX -- calling `yylex' with the right arguments. */
526 #if YYPURE
527 # if YYLSP_NEEDED
528 # ifdef YYLEX_PARAM
529 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
530 # else
531 # define YYLEX yylex (&yylval, &yylloc)
532 # endif
533 # else /* !YYLSP_NEEDED */
534 # ifdef YYLEX_PARAM
535 # define YYLEX yylex (&yylval, YYLEX_PARAM)
536 # else
537 # define YYLEX yylex (&yylval)
538 # endif
539 # endif /* !YYLSP_NEEDED */
540 #else /* !YYPURE */
541 # define YYLEX yylex ()
542 #endif /* !YYPURE */
545 /* Enable debugging if requested. */
546 #if YYDEBUG
548 # ifndef YYFPRINTF
549 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
550 # define YYFPRINTF fprintf
551 # endif
553 # define YYDPRINTF(Args) \
554 do { \
555 if (yydebug) \
556 YYFPRINTF Args; \
557 } while (0)
558 /* Nonzero means print parse trace. It is left uninitialized so that
559 multiple parsers can coexist. */
560 int yydebug;
561 #else /* !YYDEBUG */
562 # define YYDPRINTF(Args)
563 #endif /* !YYDEBUG */
565 /* YYINITDEPTH -- initial size of the parser's stacks. */
566 #ifndef YYINITDEPTH
567 # define YYINITDEPTH 200
568 #endif
570 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
571 if the built-in stack extension method is used).
573 Do not make this value too large; the results are undefined if
574 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
575 evaluated with infinite-precision integer arithmetic. */
577 #if YYMAXDEPTH == 0
578 # undef YYMAXDEPTH
579 #endif
581 #ifndef YYMAXDEPTH
582 # define YYMAXDEPTH 10000
583 #endif
585 #ifdef YYERROR_VERBOSE
587 # ifndef yystrlen
588 # if defined (__GLIBC__) && defined (_STRING_H)
589 # define yystrlen strlen
590 # else
591 /* Return the length of YYSTR. */
592 static YYSIZE_T
593 # if defined (__STDC__) || defined (__cplusplus)
594 yystrlen (const char *yystr)
595 # else
596 yystrlen (yystr)
597 const char *yystr;
598 # endif
600 register const char *yys = yystr;
602 while (*yys++ != '\0')
603 continue;
605 return yys - yystr - 1;
607 # endif
608 # endif
610 # ifndef yystpcpy
611 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
612 # define yystpcpy stpcpy
613 # else
614 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
615 YYDEST. */
616 static char *
617 # if defined (__STDC__) || defined (__cplusplus)
618 yystpcpy (char *yydest, const char *yysrc)
619 # else
620 yystpcpy (yydest, yysrc)
621 char *yydest;
622 const char *yysrc;
623 # endif
625 register char *yyd = yydest;
626 register const char *yys = yysrc;
628 while ((*yyd++ = *yys++) != '\0')
629 continue;
631 return yyd - 1;
633 # endif
634 # endif
635 #endif
637 #line 315 "/castro/street/H-alpha-linux/share/bison/bison.simple"
640 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
641 into yyparse. The argument should have type void *.
642 It should actually point to an object.
643 Grammar actions can access the variable by casting it
644 to the proper pointer type. */
646 #ifdef YYPARSE_PARAM
647 # if defined (__STDC__) || defined (__cplusplus)
648 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
649 # define YYPARSE_PARAM_DECL
650 # else
651 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
652 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
653 # endif
654 #else /* !YYPARSE_PARAM */
655 # define YYPARSE_PARAM_ARG
656 # define YYPARSE_PARAM_DECL
657 #endif /* !YYPARSE_PARAM */
659 /* Prevent warning if -Wstrict-prototypes. */
660 #ifdef __GNUC__
661 # ifdef YYPARSE_PARAM
662 int yyparse (void *);
663 # else
664 int yyparse (void);
665 # endif
666 #endif
668 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
669 variables are global, or local to YYPARSE. */
671 #define YY_DECL_NON_LSP_VARIABLES \
672 /* The lookahead symbol. */ \
673 int yychar; \
675 /* The semantic value of the lookahead symbol. */ \
676 YYSTYPE yylval; \
678 /* Number of parse errors so far. */ \
679 int yynerrs;
681 #if YYLSP_NEEDED
682 # define YY_DECL_VARIABLES \
683 YY_DECL_NON_LSP_VARIABLES \
685 /* Location data for the lookahead symbol. */ \
686 YYLTYPE yylloc;
687 #else
688 # define YY_DECL_VARIABLES \
689 YY_DECL_NON_LSP_VARIABLES
690 #endif
693 /* If nonreentrant, generate the variables here. */
695 #if !YYPURE
696 YY_DECL_VARIABLES
697 #endif /* !YYPURE */
700 yyparse (YYPARSE_PARAM_ARG)
701 YYPARSE_PARAM_DECL
703 /* If reentrant, generate the variables here. */
704 #if YYPURE
705 YY_DECL_VARIABLES
706 #endif /* !YYPURE */
708 register int yystate;
709 register int yyn;
710 int yyresult;
711 /* Number of tokens to shift before error messages enabled. */
712 int yyerrstatus;
713 /* Lookahead token as an internal (translated) token number. */
714 int yychar1 = 0;
716 /* Three stacks and their tools:
717 `yyss': related to states,
718 `yyvs': related to semantic values,
719 `yyls': related to locations.
721 Refer to the stacks thru separate pointers, to allow yyoverflow
722 to reallocate them elsewhere. */
724 /* The state stack. */
725 short yyssa[YYINITDEPTH];
726 short *yyss = yyssa;
727 register short *yyssp;
729 /* The semantic value stack. */
730 YYSTYPE yyvsa[YYINITDEPTH];
731 YYSTYPE *yyvs = yyvsa;
732 register YYSTYPE *yyvsp;
734 #if YYLSP_NEEDED
735 /* The location stack. */
736 YYLTYPE yylsa[YYINITDEPTH];
737 YYLTYPE *yyls = yylsa;
738 YYLTYPE *yylsp;
739 #endif
741 #if YYLSP_NEEDED
742 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
743 #else
744 # define YYPOPSTACK (yyvsp--, yyssp--)
745 #endif
747 YYSIZE_T yystacksize = YYINITDEPTH;
750 /* The variables used to return semantic value and location from the
751 action routines. */
752 YYSTYPE yyval;
753 #if YYLSP_NEEDED
754 YYLTYPE yyloc;
755 #endif
757 /* When reducing, the number of symbols on the RHS of the reduced
758 rule. */
759 int yylen;
761 YYDPRINTF ((stderr, "Starting parse\n"));
763 yystate = 0;
764 yyerrstatus = 0;
765 yynerrs = 0;
766 yychar = YYEMPTY; /* Cause a token to be read. */
768 /* Initialize stack pointers.
769 Waste one element of value and location stack
770 so that they stay on the same level as the state stack.
771 The wasted elements are never initialized. */
773 yyssp = yyss;
774 yyvsp = yyvs;
775 #if YYLSP_NEEDED
776 yylsp = yyls;
777 #endif
778 goto yysetstate;
780 /*------------------------------------------------------------.
781 | yynewstate -- Push a new state, which is found in yystate. |
782 `------------------------------------------------------------*/
783 yynewstate:
784 /* In all cases, when you get here, the value and location stacks
785 have just been pushed. so pushing a state here evens the stacks.
787 yyssp++;
789 yysetstate:
790 *yyssp = yystate;
792 if (yyssp >= yyss + yystacksize - 1)
794 /* Get the current used size of the three stacks, in elements. */
795 YYSIZE_T yysize = yyssp - yyss + 1;
797 #ifdef yyoverflow
799 /* Give user a chance to reallocate the stack. Use copies of
800 these so that the &'s don't force the real ones into
801 memory. */
802 YYSTYPE *yyvs1 = yyvs;
803 short *yyss1 = yyss;
805 /* Each stack pointer address is followed by the size of the
806 data in use in that stack, in bytes. */
807 # if YYLSP_NEEDED
808 YYLTYPE *yyls1 = yyls;
809 /* This used to be a conditional around just the two extra args,
810 but that might be undefined if yyoverflow is a macro. */
811 yyoverflow ("parser stack overflow",
812 &yyss1, yysize * sizeof (*yyssp),
813 &yyvs1, yysize * sizeof (*yyvsp),
814 &yyls1, yysize * sizeof (*yylsp),
815 &yystacksize);
816 yyls = yyls1;
817 # else
818 yyoverflow ("parser stack overflow",
819 &yyss1, yysize * sizeof (*yyssp),
820 &yyvs1, yysize * sizeof (*yyvsp),
821 &yystacksize);
822 # endif
823 yyss = yyss1;
824 yyvs = yyvs1;
826 #else /* no yyoverflow */
827 # ifndef YYSTACK_RELOCATE
828 goto yyoverflowlab;
829 # else
830 /* Extend the stack our own way. */
831 if (yystacksize >= YYMAXDEPTH)
832 goto yyoverflowlab;
833 yystacksize *= 2;
834 if (yystacksize > YYMAXDEPTH)
835 yystacksize = YYMAXDEPTH;
838 short *yyss1 = yyss;
839 union yyalloc *yyptr =
840 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
841 if (! yyptr)
842 goto yyoverflowlab;
843 YYSTACK_RELOCATE (yyss);
844 YYSTACK_RELOCATE (yyvs);
845 # if YYLSP_NEEDED
846 YYSTACK_RELOCATE (yyls);
847 # endif
848 # undef YYSTACK_RELOCATE
849 if (yyss1 != yyssa)
850 YYSTACK_FREE (yyss1);
852 # endif
853 #endif /* no yyoverflow */
855 yyssp = yyss + yysize - 1;
856 yyvsp = yyvs + yysize - 1;
857 #if YYLSP_NEEDED
858 yylsp = yyls + yysize - 1;
859 #endif
861 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
862 (unsigned long int) yystacksize));
864 if (yyssp >= yyss + yystacksize - 1)
865 YYABORT;
868 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
870 goto yybackup;
873 /*-----------.
874 | yybackup. |
875 `-----------*/
876 yybackup:
878 /* Do appropriate processing given the current state. */
879 /* Read a lookahead token if we need one and don't already have one. */
880 /* yyresume: */
882 /* First try to decide what to do without reference to lookahead token. */
884 yyn = yypact[yystate];
885 if (yyn == YYFLAG)
886 goto yydefault;
888 /* Not known => get a lookahead token if don't already have one. */
890 /* yychar is either YYEMPTY or YYEOF
891 or a valid token in external form. */
893 if (yychar == YYEMPTY)
895 YYDPRINTF ((stderr, "Reading a token: "));
896 yychar = YYLEX;
899 /* Convert token to internal form (in yychar1) for indexing tables with */
901 if (yychar <= 0) /* This means end of input. */
903 yychar1 = 0;
904 yychar = YYEOF; /* Don't call YYLEX any more */
906 YYDPRINTF ((stderr, "Now at end of input.\n"));
908 else
910 yychar1 = YYTRANSLATE (yychar);
912 #if YYDEBUG
913 /* We have to keep this `#if YYDEBUG', since we use variables
914 which are defined only if `YYDEBUG' is set. */
915 if (yydebug)
917 YYFPRINTF (stderr, "Next token is %d (%s",
918 yychar, yytname[yychar1]);
919 /* Give the individual parser a way to print the precise
920 meaning of a token, for further debugging info. */
921 # ifdef YYPRINT
922 YYPRINT (stderr, yychar, yylval);
923 # endif
924 YYFPRINTF (stderr, ")\n");
926 #endif
929 yyn += yychar1;
930 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
931 goto yydefault;
933 yyn = yytable[yyn];
935 /* yyn is what to do for this token type in this state.
936 Negative => reduce, -yyn is rule number.
937 Positive => shift, yyn is new state.
938 New state is final state => don't bother to shift,
939 just return success.
940 0, or most negative number => error. */
942 if (yyn < 0)
944 if (yyn == YYFLAG)
945 goto yyerrlab;
946 yyn = -yyn;
947 goto yyreduce;
949 else if (yyn == 0)
950 goto yyerrlab;
952 if (yyn == YYFINAL)
953 YYACCEPT;
955 /* Shift the lookahead token. */
956 YYDPRINTF ((stderr, "Shifting token %d (%s), ",
957 yychar, yytname[yychar1]));
959 /* Discard the token being shifted unless it is eof. */
960 if (yychar != YYEOF)
961 yychar = YYEMPTY;
963 *++yyvsp = yylval;
964 #if YYLSP_NEEDED
965 *++yylsp = yylloc;
966 #endif
968 /* Count tokens shifted since error; after three, turn off error
969 status. */
970 if (yyerrstatus)
971 yyerrstatus--;
973 yystate = yyn;
974 goto yynewstate;
977 /*-----------------------------------------------------------.
978 | yydefault -- do the default action for the current state. |
979 `-----------------------------------------------------------*/
980 yydefault:
981 yyn = yydefact[yystate];
982 if (yyn == 0)
983 goto yyerrlab;
984 goto yyreduce;
987 /*-----------------------------.
988 | yyreduce -- Do a reduction. |
989 `-----------------------------*/
990 yyreduce:
991 /* yyn is the number of a rule to reduce with. */
992 yylen = yyr2[yyn];
994 /* If YYLEN is nonzero, implement the default value of the action:
995 `$$ = $1'.
997 Otherwise, the following line sets YYVAL to the semantic value of
998 the lookahead token. This behavior is undocumented and Bison
999 users should not rely upon it. Assigning to YYVAL
1000 unconditionally makes the parser a bit smaller, and it avoids a
1001 GCC warning that YYVAL may be used uninitialized. */
1002 yyval = yyvsp[1-yylen];
1004 #if YYLSP_NEEDED
1005 /* Similarly for the default location. Let the user run additional
1006 commands if for instance locations are ranges. */
1007 yyloc = yylsp[1-yylen];
1008 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1009 #endif
1011 #if YYDEBUG
1012 /* We have to keep this `#if YYDEBUG', since we use variables which
1013 are defined only if `YYDEBUG' is set. */
1014 if (yydebug)
1016 int yyi;
1018 YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
1019 yyn, yyrline[yyn]);
1021 /* Print the symbols being reduced, and their result. */
1022 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
1023 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
1024 YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1026 #endif
1028 switch (yyn) {
1030 case 1:
1031 #line 175 "plural.y"
1033 if (yyvsp[0].exp == NULL)
1034 YYABORT;
1035 ((struct parse_args *) arg)->res = yyvsp[0].exp;
1037 break;
1038 case 2:
1039 #line 183 "plural.y"
1041 yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp);
1043 break;
1044 case 3:
1045 #line 187 "plural.y"
1047 yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp);
1049 break;
1050 case 4:
1051 #line 191 "plural.y"
1053 yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp);
1055 break;
1056 case 5:
1057 #line 195 "plural.y"
1059 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1061 break;
1062 case 6:
1063 #line 199 "plural.y"
1065 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1067 break;
1068 case 7:
1069 #line 203 "plural.y"
1071 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1073 break;
1074 case 8:
1075 #line 207 "plural.y"
1077 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1079 break;
1080 case 9:
1081 #line 211 "plural.y"
1083 yyval.exp = new_exp_1 (lnot, yyvsp[0].exp);
1085 break;
1086 case 10:
1087 #line 215 "plural.y"
1089 yyval.exp = new_exp_0 (var);
1091 break;
1092 case 11:
1093 #line 219 "plural.y"
1095 if ((yyval.exp = new_exp_0 (num)) != NULL)
1096 yyval.exp->val.num = yyvsp[0].num;
1098 break;
1099 case 12:
1100 #line 224 "plural.y"
1102 yyval.exp = yyvsp[-1].exp;
1104 break;
1107 #line 705 "/castro/street/H-alpha-linux/share/bison/bison.simple"
1110 yyvsp -= yylen;
1111 yyssp -= yylen;
1112 #if YYLSP_NEEDED
1113 yylsp -= yylen;
1114 #endif
1116 #if YYDEBUG
1117 if (yydebug)
1119 short *yyssp1 = yyss - 1;
1120 YYFPRINTF (stderr, "state stack now");
1121 while (yyssp1 != yyssp)
1122 YYFPRINTF (stderr, " %d", *++yyssp1);
1123 YYFPRINTF (stderr, "\n");
1125 #endif
1127 *++yyvsp = yyval;
1128 #if YYLSP_NEEDED
1129 *++yylsp = yyloc;
1130 #endif
1132 /* Now `shift' the result of the reduction. Determine what state
1133 that goes to, based on the state we popped back to and the rule
1134 number reduced by. */
1136 yyn = yyr1[yyn];
1138 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1139 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1140 yystate = yytable[yystate];
1141 else
1142 yystate = yydefgoto[yyn - YYNTBASE];
1144 goto yynewstate;
1147 /*------------------------------------.
1148 | yyerrlab -- here on detecting error |
1149 `------------------------------------*/
1150 yyerrlab:
1151 /* If not already recovering from an error, report this error. */
1152 if (!yyerrstatus)
1154 ++yynerrs;
1156 #ifdef YYERROR_VERBOSE
1157 yyn = yypact[yystate];
1159 if (yyn > YYFLAG && yyn < YYLAST)
1161 YYSIZE_T yysize = 0;
1162 char *yymsg;
1163 int yyx, yycount;
1165 yycount = 0;
1166 /* Start YYX at -YYN if negative to avoid negative indexes in
1167 YYCHECK. */
1168 for (yyx = yyn < 0 ? -yyn : 0;
1169 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1170 if (yycheck[yyx + yyn] == yyx)
1171 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1172 yysize += yystrlen ("parse error, unexpected ") + 1;
1173 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
1174 yymsg = (char *) YYSTACK_ALLOC (yysize);
1175 if (yymsg != 0)
1177 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
1178 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
1180 if (yycount < 5)
1182 yycount = 0;
1183 for (yyx = yyn < 0 ? -yyn : 0;
1184 yyx < (int) (sizeof (yytname) / sizeof (char *));
1185 yyx++)
1186 if (yycheck[yyx + yyn] == yyx)
1188 const char *yyq = ! yycount ? ", expecting " : " or ";
1189 yyp = yystpcpy (yyp, yyq);
1190 yyp = yystpcpy (yyp, yytname[yyx]);
1191 yycount++;
1194 yyerror (yymsg);
1195 YYSTACK_FREE (yymsg);
1197 else
1198 yyerror ("parse error; also virtual memory exhausted");
1200 else
1201 #endif /* defined (YYERROR_VERBOSE) */
1202 yyerror ("parse error");
1204 goto yyerrlab1;
1207 /*--------------------------------------------------.
1208 | yyerrlab1 -- error raised explicitly by an action |
1209 `--------------------------------------------------*/
1210 yyerrlab1:
1211 if (yyerrstatus == 3)
1213 /* If just tried and failed to reuse lookahead token after an
1214 error, discard it. */
1216 /* return failure if at end of input */
1217 if (yychar == YYEOF)
1218 YYABORT;
1219 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
1220 yychar, yytname[yychar1]));
1221 yychar = YYEMPTY;
1224 /* Else will try to reuse lookahead token after shifting the error
1225 token. */
1227 yyerrstatus = 3; /* Each real token shifted decrements this */
1229 goto yyerrhandle;
1232 /*-------------------------------------------------------------------.
1233 | yyerrdefault -- current state does not do anything special for the |
1234 | error token. |
1235 `-------------------------------------------------------------------*/
1236 yyerrdefault:
1237 #if 0
1238 /* This is wrong; only states that explicitly want error tokens
1239 should shift them. */
1241 /* If its default is to accept any token, ok. Otherwise pop it. */
1242 yyn = yydefact[yystate];
1243 if (yyn)
1244 goto yydefault;
1245 #endif
1248 /*---------------------------------------------------------------.
1249 | yyerrpop -- pop the current state because it cannot handle the |
1250 | error token |
1251 `---------------------------------------------------------------*/
1252 yyerrpop:
1253 if (yyssp == yyss)
1254 YYABORT;
1255 yyvsp--;
1256 yystate = *--yyssp;
1257 #if YYLSP_NEEDED
1258 yylsp--;
1259 #endif
1261 #if YYDEBUG
1262 if (yydebug)
1264 short *yyssp1 = yyss - 1;
1265 YYFPRINTF (stderr, "Error: state stack now");
1266 while (yyssp1 != yyssp)
1267 YYFPRINTF (stderr, " %d", *++yyssp1);
1268 YYFPRINTF (stderr, "\n");
1270 #endif
1272 /*--------------.
1273 | yyerrhandle. |
1274 `--------------*/
1275 yyerrhandle:
1276 yyn = yypact[yystate];
1277 if (yyn == YYFLAG)
1278 goto yyerrdefault;
1280 yyn += YYTERROR;
1281 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1282 goto yyerrdefault;
1284 yyn = yytable[yyn];
1285 if (yyn < 0)
1287 if (yyn == YYFLAG)
1288 goto yyerrpop;
1289 yyn = -yyn;
1290 goto yyreduce;
1292 else if (yyn == 0)
1293 goto yyerrpop;
1295 if (yyn == YYFINAL)
1296 YYACCEPT;
1298 YYDPRINTF ((stderr, "Shifting error token, "));
1300 *++yyvsp = yylval;
1301 #if YYLSP_NEEDED
1302 *++yylsp = yylloc;
1303 #endif
1305 yystate = yyn;
1306 goto yynewstate;
1309 /*-------------------------------------.
1310 | yyacceptlab -- YYACCEPT comes here. |
1311 `-------------------------------------*/
1312 yyacceptlab:
1313 yyresult = 0;
1314 goto yyreturn;
1316 /*-----------------------------------.
1317 | yyabortlab -- YYABORT comes here. |
1318 `-----------------------------------*/
1319 yyabortlab:
1320 yyresult = 1;
1321 goto yyreturn;
1323 /*---------------------------------------------.
1324 | yyoverflowab -- parser overflow comes here. |
1325 `---------------------------------------------*/
1326 yyoverflowlab:
1327 yyerror ("parser stack overflow");
1328 yyresult = 2;
1329 /* Fall through. */
1331 yyreturn:
1332 #ifndef yyoverflow
1333 if (yyss != yyssa)
1334 YYSTACK_FREE (yyss);
1335 #endif
1336 return yyresult;
1338 #line 229 "plural.y"
1341 void
1342 internal_function
1343 FREE_EXPRESSION (exp)
1344 struct expression *exp;
1346 if (exp == NULL)
1347 return;
1349 /* Handle the recursive case. */
1350 switch (exp->nargs)
1352 case 3:
1353 FREE_EXPRESSION (exp->val.args[2]);
1354 /* FALLTHROUGH */
1355 case 2:
1356 FREE_EXPRESSION (exp->val.args[1]);
1357 /* FALLTHROUGH */
1358 case 1:
1359 FREE_EXPRESSION (exp->val.args[0]);
1360 /* FALLTHROUGH */
1361 default:
1362 break;
1365 free (exp);
1369 static int
1370 yylex (lval, pexp)
1371 YYSTYPE *lval;
1372 const char **pexp;
1374 const char *exp = *pexp;
1375 int result;
1377 while (1)
1379 if (exp[0] == '\0')
1381 *pexp = exp;
1382 return YYEOF;
1385 if (exp[0] != ' ' && exp[0] != '\t')
1386 break;
1388 ++exp;
1391 result = *exp++;
1392 switch (result)
1394 case '0': case '1': case '2': case '3': case '4':
1395 case '5': case '6': case '7': case '8': case '9':
1397 unsigned long int n = result - '0';
1398 while (exp[0] >= '0' && exp[0] <= '9')
1400 n *= 10;
1401 n += exp[0] - '0';
1402 ++exp;
1404 lval->num = n;
1405 result = NUMBER;
1407 break;
1409 case '=':
1410 if (exp[0] == '=')
1412 ++exp;
1413 lval->op = equal;
1414 result = EQUOP2;
1416 else
1417 result = YYERRCODE;
1418 break;
1420 case '!':
1421 if (exp[0] == '=')
1423 ++exp;
1424 lval->op = not_equal;
1425 result = EQUOP2;
1427 break;
1429 case '&':
1430 case '|':
1431 if (exp[0] == result)
1432 ++exp;
1433 else
1434 result = YYERRCODE;
1435 break;
1437 case '<':
1438 if (exp[0] == '=')
1440 ++exp;
1441 lval->op = less_or_equal;
1443 else
1444 lval->op = less_than;
1445 result = CMPOP2;
1446 break;
1448 case '>':
1449 if (exp[0] == '=')
1451 ++exp;
1452 lval->op = greater_or_equal;
1454 else
1455 lval->op = greater_than;
1456 result = CMPOP2;
1457 break;
1459 case '*':
1460 lval->op = mult;
1461 result = MULOP2;
1462 break;
1464 case '/':
1465 lval->op = divide;
1466 result = MULOP2;
1467 break;
1469 case '%':
1470 lval->op = module;
1471 result = MULOP2;
1472 break;
1474 case '+':
1475 lval->op = plus;
1476 result = ADDOP2;
1477 break;
1479 case '-':
1480 lval->op = minus;
1481 result = ADDOP2;
1482 break;
1484 case 'n':
1485 case '?':
1486 case ':':
1487 case '(':
1488 case ')':
1489 /* Nothing, just return the character. */
1490 break;
1492 case ';':
1493 case '\n':
1494 case '\0':
1495 /* Be safe and let the user call this function again. */
1496 --exp;
1497 result = YYEOF;
1498 break;
1500 default:
1501 result = YYERRCODE;
1502 #if YYDEBUG != 0
1503 --exp;
1504 #endif
1505 break;
1508 *pexp = exp;
1510 return result;
1514 static void
1515 yyerror (str)
1516 const char *str;
1518 /* Do nothing. We don't print error messages here. */