source: vendor/glibc/current/intl/plural.c

Last change on this file was 1836, checked in by bird, 20 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 37.3 KB
Line 
1/* A Bison parser, made from plural.y
2 by GNU bison 1.35. */
3
4#define YYBISON 1 /* Identify Bison output. */
5
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
18
19#line 1 "plural.y"
20
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.
25
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.
30
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.
35
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. */
40
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
51
52#include <stddef.h>
53#include <stdlib.h>
54#include <string.h>
55#include "plural-exp.h"
56
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
62
63#define YYLEX_PARAM &((struct parse_args *) arg)->cp
64#define YYPARSE_PARAM arg
65
66#line 49 "plural.y"
67#ifndef YYSTYPE
68typedef 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"
77
78/* Prototypes for local functions. */
79static struct expression *new_exp PARAMS ((int nargs, enum operator op,
80 struct expression * const *args));
81static inline struct expression *new_exp_0 PARAMS ((enum operator op));
82static inline struct expression *new_exp_1 PARAMS ((enum operator op,
83 struct expression *right));
84static struct expression *new_exp_2 PARAMS ((enum operator op,
85 struct expression *left,
86 struct expression *right));
87static inline struct expression *new_exp_3 PARAMS ((enum operator op,
88 struct expression *bexp,
89 struct expression *tbranch,
90 struct expression *fbranch));
91static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
92static void yyerror PARAMS ((const char *str));
93
94/* Allocation of expressions. */
95
96static struct expression *
97new_exp (nargs, op, args)
98 int nargs;
99 enum operator op;
100 struct expression * const *args;
101{
102 int i;
103 struct expression *newp;
104
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;
109
110 /* Allocate a new expression. */
111 newp = (struct expression *) malloc (sizeof (*newp));
112 if (newp != NULL)
113 {
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;
119 }
120
121 fail:
122 for (i = nargs - 1; i >= 0; i--)
123 FREE_EXPRESSION (args[i]);
124
125 return NULL;
126}
127
128static inline struct expression *
129new_exp_0 (op)
130 enum operator op;
131{
132 return new_exp (0, op, NULL);
133}
134
135static inline struct expression *
136new_exp_1 (op, right)
137 enum operator op;
138 struct expression *right;
139{
140 struct expression *args[1];
141
142 args[0] = right;
143 return new_exp (1, op, args);
144}
145
146static struct expression *
147new_exp_2 (op, left, right)
148 enum operator op;
149 struct expression *left;
150 struct expression *right;
151{
152 struct expression *args[2];
153
154 args[0] = left;
155 args[1] = right;
156 return new_exp (2, op, args);
157}
158
159static inline struct expression *
160new_exp_3 (op, bexp, tbranch, fbranch)
161 enum operator op;
162 struct expression *bexp;
163 struct expression *tbranch;
164 struct expression *fbranch;
165{
166 struct expression *args[3];
167
168 args[0] = bexp;
169 args[1] = tbranch;
170 args[2] = fbranch;
171 return new_exp (3, op, args);
172}
173
174#ifndef YYDEBUG
175# define YYDEBUG 0
176#endif
177
178
179
180#define YYFINAL 27
181#define YYFLAG -32768
182#define YYNTBASE 16
183
184/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
185#define YYTRANSLATE(x) ((unsigned)(x) <= 261 ? yytranslate[x] : 18)
186
187/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
188static const char yytranslate[] =
189{
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
217};
218
219#if YYDEBUG
220static const short yyprhs[] =
221{
222 0, 0, 2, 8, 12, 16, 20, 24, 28, 32,
223 35, 37, 39
224};
225static const short yyrhs[] =
226{
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
232};
233
234#endif
235
236#if YYDEBUG
237/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
238static const short yyrline[] =
239{
240 0, 174, 182, 186, 190, 194, 198, 202, 206, 210,
241 214, 218, 223
242};
243#endif
244
245
246#if (YYDEBUG) || defined YYERROR_VERBOSE
247
248/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
249static const char *const yytname[] =
250{
251 "$", "error", "$undefined.", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
252 "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
253 "start", "exp", 0
254};
255#endif
256
257/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
258static const short yyr1[] =
259{
260 0, 16, 17, 17, 17, 17, 17, 17, 17, 17,
261 17, 17, 17
262};
263
264/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
265static const short yyr2[] =
266{
267 0, 1, 5, 3, 3, 3, 3, 3, 3, 2,
268 1, 1, 3
269};
270
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. */
274static const short yydefact[] =
275{
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
279};
280
281static const short yydefgoto[] =
282{
283 25, 5
284};
285
286static const short yypact[] =
287{
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
291};
292
293static const short yypgoto[] =
294{
295 -32768, -1
296};
297
298
299#define YYLAST 53
300
301
302static const short yytable[] =
303{
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
310};
311
312static const short yycheck[] =
313{
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
320};
321#define YYPURE 1
322
323/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
324#line 3 "/castro/street/H-alpha-linux/share/bison/bison.simple"
325
326/* Skeleton output parser for bison,
327
328 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
329 Foundation, Inc.
330
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.
335
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.
340
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. */
345
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. */
350
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. */
355
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. */
362
363#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
364
365/* The parser invokes alloca or malloc; define the necessary symbols. */
366
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
380
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) */
393
394
395#if (! defined (yyoverflow) \
396 && (! defined (__cplusplus) \
397 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
398
399/* A type that is properly aligned for any stack member. */
400union yyalloc
401{
402 short yyss;
403 YYSTYPE yyvs;
404# if YYLSP_NEEDED
405 YYLTYPE yyls;
406# endif
407};
408
409/* The size of the maximum gap between one aligned stack and the next. */
410# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
411
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
423
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 \
433 { \
434 register YYSIZE_T yyi; \
435 for (yyi = 0; yyi < (Count); yyi++) \
436 (To)[yyi] = (From)[yyi]; \
437 } \
438 while (0)
439# endif
440# endif
441
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 \
449 { \
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); \
455 } \
456 while (0)
457
458#endif
459
460
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
476
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) \
490do \
491 if (yychar == YYEMPTY && yylen == 1) \
492 { \
493 yychar = (Token); \
494 yylval = (Value); \
495 yychar1 = YYTRANSLATE (yychar); \
496 YYPOPSTACK; \
497 goto yybackup; \
498 } \
499 else \
500 { \
501 yyerror ("syntax error: cannot back up"); \
502 YYERROR; \
503 } \
504while (0)
505
506#define YYTERROR 1
507#define YYERRCODE 256
508
509
510/* YYLLOC_DEFAULT -- Compute the default location (before the actions
511 are run).
512
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. */
516
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
522
523
524/* YYLEX -- calling `yylex' with the right arguments. */
525
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 */
543
544
545/* Enable debugging if requested. */
546#if YYDEBUG
547
548# ifndef YYFPRINTF
549# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
550# define YYFPRINTF fprintf
551# endif
552
553# define YYDPRINTF(Args) \
554do { \
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. */
560int yydebug;
561#else /* !YYDEBUG */
562# define YYDPRINTF(Args)
563#endif /* !YYDEBUG */
564
565/* YYINITDEPTH -- initial size of the parser's stacks. */
566#ifndef YYINITDEPTH
567# define YYINITDEPTH 200
568#endif
569
570/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
571 if the built-in stack extension method is used).
572
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. */
576
577#if YYMAXDEPTH == 0
578# undef YYMAXDEPTH
579#endif
580
581#ifndef YYMAXDEPTH
582# define YYMAXDEPTH 10000
583#endif
584
585
586#ifdef YYERROR_VERBOSE
587
588# ifndef yystrlen
589# if defined (__GLIBC__) && defined (_STRING_H)
590# define yystrlen strlen
591# else
592/* Return the length of YYSTR. */
593static YYSIZE_T
594# if defined (__STDC__) || defined (__cplusplus)
595yystrlen (const char *yystr)
596# else
597yystrlen (yystr)
598 const char *yystr;
599# endif
600{
601 register const char *yys = yystr;
602
603 while (*yys++ != '\0')
604 continue;
605
606 return yys - yystr - 1;
607}
608# endif
609# endif
610
611# ifndef yystpcpy
612# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
613# define yystpcpy stpcpy
614# else
615/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
616 YYDEST. */
617static char *
618# if defined (__STDC__) || defined (__cplusplus)
619yystpcpy (char *yydest, const char *yysrc)
620# else
621yystpcpy (yydest, yysrc)
622 char *yydest;
623 const char *yysrc;
624# endif
625{
626 register char *yyd = yydest;
627 register const char *yys = yysrc;
628
629 while ((*yyd++ = *yys++) != '\0')
630 continue;
631
632 return yyd - 1;
633}
634# endif
635# endif
636#endif
637
638
639#line 315 "/castro/street/H-alpha-linux/share/bison/bison.simple"
640
641
642/* The user can define YYPARSE_PARAM as the name of an argument to be passed
643 into yyparse. The argument should have type void *.
644 It should actually point to an object.
645 Grammar actions can access the variable by casting it
646 to the proper pointer type. */
647
648#ifdef YYPARSE_PARAM
649# if defined (__STDC__) || defined (__cplusplus)
650# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
651# define YYPARSE_PARAM_DECL
652# else
653# define YYPARSE_PARAM_ARG YYPARSE_PARAM
654# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
655# endif
656#else /* !YYPARSE_PARAM */
657# define YYPARSE_PARAM_ARG
658# define YYPARSE_PARAM_DECL
659#endif /* !YYPARSE_PARAM */
660
661/* Prevent warning if -Wstrict-prototypes. */
662#ifdef __GNUC__
663# ifdef YYPARSE_PARAM
664int yyparse (void *);
665# else
666int yyparse (void);
667# endif
668#endif
669
670/* YY_DECL_VARIABLES -- depending whether we use a pure parser,
671 variables are global, or local to YYPARSE. */
672
673#define YY_DECL_NON_LSP_VARIABLES \
674/* The lookahead symbol. */ \
675int yychar; \
676 \
677/* The semantic value of the lookahead symbol. */ \
678YYSTYPE yylval; \
679 \
680/* Number of parse errors so far. */ \
681int yynerrs;
682
683#if YYLSP_NEEDED
684# define YY_DECL_VARIABLES \
685YY_DECL_NON_LSP_VARIABLES \
686 \
687/* Location data for the lookahead symbol. */ \
688YYLTYPE yylloc;
689#else
690# define YY_DECL_VARIABLES \
691YY_DECL_NON_LSP_VARIABLES
692#endif
693
694
695/* If nonreentrant, generate the variables here. */
696
697#if !YYPURE
698YY_DECL_VARIABLES
699#endif /* !YYPURE */
700
701int
702yyparse (YYPARSE_PARAM_ARG)
703 YYPARSE_PARAM_DECL
704{
705 /* If reentrant, generate the variables here. */
706#if YYPURE
707 YY_DECL_VARIABLES
708#endif /* !YYPURE */
709
710 register int yystate;
711 register int yyn;
712 int yyresult;
713 /* Number of tokens to shift before error messages enabled. */
714 int yyerrstatus;
715 /* Lookahead token as an internal (translated) token number. */
716 int yychar1 = 0;
717
718 /* Three stacks and their tools:
719 `yyss': related to states,
720 `yyvs': related to semantic values,
721 `yyls': related to locations.
722
723 Refer to the stacks thru separate pointers, to allow yyoverflow
724 to reallocate them elsewhere. */
725
726 /* The state stack. */
727 short yyssa[YYINITDEPTH];
728 short *yyss = yyssa;
729 register short *yyssp;
730
731 /* The semantic value stack. */
732 YYSTYPE yyvsa[YYINITDEPTH];
733 YYSTYPE *yyvs = yyvsa;
734 register YYSTYPE *yyvsp;
735
736#if YYLSP_NEEDED
737 /* The location stack. */
738 YYLTYPE yylsa[YYINITDEPTH];
739 YYLTYPE *yyls = yylsa;
740 YYLTYPE *yylsp;
741#endif
742
743#if YYLSP_NEEDED
744# define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
745#else
746# define YYPOPSTACK (yyvsp--, yyssp--)
747#endif
748
749 YYSIZE_T yystacksize = YYINITDEPTH;
750
751
752 /* The variables used to return semantic value and location from the
753 action routines. */
754 YYSTYPE yyval;
755#if YYLSP_NEEDED
756 YYLTYPE yyloc;
757#endif
758
759 /* When reducing, the number of symbols on the RHS of the reduced
760 rule. */
761 int yylen;
762
763 YYDPRINTF ((stderr, "Starting parse\n"));
764
765 yystate = 0;
766 yyerrstatus = 0;
767 yynerrs = 0;
768 yychar = YYEMPTY; /* Cause a token to be read. */
769
770 /* Initialize stack pointers.
771 Waste one element of value and location stack
772 so that they stay on the same level as the state stack.
773 The wasted elements are never initialized. */
774
775 yyssp = yyss;
776 yyvsp = yyvs;
777#if YYLSP_NEEDED
778 yylsp = yyls;
779#endif
780 goto yysetstate;
781
782/*------------------------------------------------------------.
783| yynewstate -- Push a new state, which is found in yystate. |
784`------------------------------------------------------------*/
785 yynewstate:
786 /* In all cases, when you get here, the value and location stacks
787 have just been pushed. so pushing a state here evens the stacks.
788 */
789 yyssp++;
790
791 yysetstate:
792 *yyssp = yystate;
793
794 if (yyssp >= yyss + yystacksize - 1)
795 {
796 /* Get the current used size of the three stacks, in elements. */
797 YYSIZE_T yysize = yyssp - yyss + 1;
798
799#ifdef yyoverflow
800 {
801 /* Give user a chance to reallocate the stack. Use copies of
802 these so that the &'s don't force the real ones into
803 memory. */
804 YYSTYPE *yyvs1 = yyvs;
805 short *yyss1 = yyss;
806
807 /* Each stack pointer address is followed by the size of the
808 data in use in that stack, in bytes. */
809# if YYLSP_NEEDED
810 YYLTYPE *yyls1 = yyls;
811 /* This used to be a conditional around just the two extra args,
812 but that might be undefined if yyoverflow is a macro. */
813 yyoverflow ("parser stack overflow",
814 &yyss1, yysize * sizeof (*yyssp),
815 &yyvs1, yysize * sizeof (*yyvsp),
816 &yyls1, yysize * sizeof (*yylsp),
817 &yystacksize);
818 yyls = yyls1;
819# else
820 yyoverflow ("parser stack overflow",
821 &yyss1, yysize * sizeof (*yyssp),
822 &yyvs1, yysize * sizeof (*yyvsp),
823 &yystacksize);
824# endif
825 yyss = yyss1;
826 yyvs = yyvs1;
827 }
828#else /* no yyoverflow */
829# ifndef YYSTACK_RELOCATE
830 goto yyoverflowlab;
831# else
832 /* Extend the stack our own way. */
833 if (yystacksize >= YYMAXDEPTH)
834 goto yyoverflowlab;
835 yystacksize *= 2;
836 if (yystacksize > YYMAXDEPTH)
837 yystacksize = YYMAXDEPTH;
838
839 {
840 short *yyss1 = yyss;
841 union yyalloc *yyptr =
842 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
843 if (! yyptr)
844 goto yyoverflowlab;
845 YYSTACK_RELOCATE (yyss);
846 YYSTACK_RELOCATE (yyvs);
847# if YYLSP_NEEDED
848 YYSTACK_RELOCATE (yyls);
849# endif
850# undef YYSTACK_RELOCATE
851 if (yyss1 != yyssa)
852 YYSTACK_FREE (yyss1);
853 }
854# endif
855#endif /* no yyoverflow */
856
857 yyssp = yyss + yysize - 1;
858 yyvsp = yyvs + yysize - 1;
859#if YYLSP_NEEDED
860 yylsp = yyls + yysize - 1;
861#endif
862
863 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
864 (unsigned long int) yystacksize));
865
866 if (yyssp >= yyss + yystacksize - 1)
867 YYABORT;
868 }
869
870 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
871
872 goto yybackup;
873
874
875/*-----------.
876| yybackup. |
877`-----------*/
878yybackup:
879
880/* Do appropriate processing given the current state. */
881/* Read a lookahead token if we need one and don't already have one. */
882/* yyresume: */
883
884 /* First try to decide what to do without reference to lookahead token. */
885
886 yyn = yypact[yystate];
887 if (yyn == YYFLAG)
888 goto yydefault;
889
890 /* Not known => get a lookahead token if don't already have one. */
891
892 /* yychar is either YYEMPTY or YYEOF
893 or a valid token in external form. */
894
895 if (yychar == YYEMPTY)
896 {
897 YYDPRINTF ((stderr, "Reading a token: "));
898 yychar = YYLEX;
899 }
900
901 /* Convert token to internal form (in yychar1) for indexing tables with */
902
903 if (yychar <= 0) /* This means end of input. */
904 {
905 yychar1 = 0;
906 yychar = YYEOF; /* Don't call YYLEX any more */
907
908 YYDPRINTF ((stderr, "Now at end of input.\n"));
909 }
910 else
911 {
912 yychar1 = YYTRANSLATE (yychar);
913
914#if YYDEBUG
915 /* We have to keep this `#if YYDEBUG', since we use variables
916 which are defined only if `YYDEBUG' is set. */
917 if (yydebug)
918 {
919 YYFPRINTF (stderr, "Next token is %d (%s",
920 yychar, yytname[yychar1]);
921 /* Give the individual parser a way to print the precise
922 meaning of a token, for further debugging info. */
923# ifdef YYPRINT
924 YYPRINT (stderr, yychar, yylval);
925# endif
926 YYFPRINTF (stderr, ")\n");
927 }
928#endif
929 }
930
931 yyn += yychar1;
932 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
933 goto yydefault;
934
935 yyn = yytable[yyn];
936
937 /* yyn is what to do for this token type in this state.
938 Negative => reduce, -yyn is rule number.
939 Positive => shift, yyn is new state.
940 New state is final state => don't bother to shift,
941 just return success.
942 0, or most negative number => error. */
943
944 if (yyn < 0)
945 {
946 if (yyn == YYFLAG)
947 goto yyerrlab;
948 yyn = -yyn;
949 goto yyreduce;
950 }
951 else if (yyn == 0)
952 goto yyerrlab;
953
954 if (yyn == YYFINAL)
955 YYACCEPT;
956
957 /* Shift the lookahead token. */
958 YYDPRINTF ((stderr, "Shifting token %d (%s), ",
959 yychar, yytname[yychar1]));
960
961 /* Discard the token being shifted unless it is eof. */
962 if (yychar != YYEOF)
963 yychar = YYEMPTY;
964
965 *++yyvsp = yylval;
966#if YYLSP_NEEDED
967 *++yylsp = yylloc;
968#endif
969
970 /* Count tokens shifted since error; after three, turn off error
971 status. */
972 if (yyerrstatus)
973 yyerrstatus--;
974
975 yystate = yyn;
976 goto yynewstate;
977
978
979/*-----------------------------------------------------------.
980| yydefault -- do the default action for the current state. |
981`-----------------------------------------------------------*/
982yydefault:
983 yyn = yydefact[yystate];
984 if (yyn == 0)
985 goto yyerrlab;
986 goto yyreduce;
987
988
989/*-----------------------------.
990| yyreduce -- Do a reduction. |
991`-----------------------------*/
992yyreduce:
993 /* yyn is the number of a rule to reduce with. */
994 yylen = yyr2[yyn];
995
996 /* If YYLEN is nonzero, implement the default value of the action:
997 `$$ = $1'.
998
999 Otherwise, the following line sets YYVAL to the semantic value of
1000 the lookahead token. This behavior is undocumented and Bison
1001 users should not rely upon it. Assigning to YYVAL
1002 unconditionally makes the parser a bit smaller, and it avoids a
1003 GCC warning that YYVAL may be used uninitialized. */
1004 yyval = yyvsp[1-yylen];
1005
1006#if YYLSP_NEEDED
1007 /* Similarly for the default location. Let the user run additional
1008 commands if for instance locations are ranges. */
1009 yyloc = yylsp[1-yylen];
1010 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1011#endif
1012
1013#if YYDEBUG
1014 /* We have to keep this `#if YYDEBUG', since we use variables which
1015 are defined only if `YYDEBUG' is set. */
1016 if (yydebug)
1017 {
1018 int yyi;
1019
1020 YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
1021 yyn, yyrline[yyn]);
1022
1023 /* Print the symbols being reduced, and their result. */
1024 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
1025 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
1026 YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1027 }
1028#endif
1029
1030 switch (yyn) {
1031
1032case 1:
1033#line 175 "plural.y"
1034{
1035 if (yyvsp[0].exp == NULL)
1036 YYABORT;
1037 ((struct parse_args *) arg)->res = yyvsp[0].exp;
1038 }
1039 break;
1040case 2:
1041#line 183 "plural.y"
1042{
1043 yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp);
1044 }
1045 break;
1046case 3:
1047#line 187 "plural.y"
1048{
1049 yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp);
1050 }
1051 break;
1052case 4:
1053#line 191 "plural.y"
1054{
1055 yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp);
1056 }
1057 break;
1058case 5:
1059#line 195 "plural.y"
1060{
1061 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1062 }
1063 break;
1064case 6:
1065#line 199 "plural.y"
1066{
1067 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1068 }
1069 break;
1070case 7:
1071#line 203 "plural.y"
1072{
1073 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1074 }
1075 break;
1076case 8:
1077#line 207 "plural.y"
1078{
1079 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1080 }
1081 break;
1082case 9:
1083#line 211 "plural.y"
1084{
1085 yyval.exp = new_exp_1 (lnot, yyvsp[0].exp);
1086 }
1087 break;
1088case 10:
1089#line 215 "plural.y"
1090{
1091 yyval.exp = new_exp_0 (var);
1092 }
1093 break;
1094case 11:
1095#line 219 "plural.y"
1096{
1097 if ((yyval.exp = new_exp_0 (num)) != NULL)
1098 yyval.exp->val.num = yyvsp[0].num;
1099 }
1100 break;
1101case 12:
1102#line 224 "plural.y"
1103{
1104 yyval.exp = yyvsp[-1].exp;
1105 }
1106 break;
1107}
1108
1109#line 705 "/castro/street/H-alpha-linux/share/bison/bison.simple"
1110
1111
1112
1113 yyvsp -= yylen;
1114 yyssp -= yylen;
1115#if YYLSP_NEEDED
1116 yylsp -= yylen;
1117#endif
1118
1119#if YYDEBUG
1120 if (yydebug)
1121 {
1122 short *yyssp1 = yyss - 1;
1123 YYFPRINTF (stderr, "state stack now");
1124 while (yyssp1 != yyssp)
1125 YYFPRINTF (stderr, " %d", *++yyssp1);
1126 YYFPRINTF (stderr, "\n");
1127 }
1128#endif
1129
1130 *++yyvsp = yyval;
1131#if YYLSP_NEEDED
1132 *++yylsp = yyloc;
1133#endif
1134
1135 /* Now `shift' the result of the reduction. Determine what state
1136 that goes to, based on the state we popped back to and the rule
1137 number reduced by. */
1138
1139 yyn = yyr1[yyn];
1140
1141 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1142 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1143 yystate = yytable[yystate];
1144 else
1145 yystate = yydefgoto[yyn - YYNTBASE];
1146
1147 goto yynewstate;
1148
1149
1150/*------------------------------------.
1151| yyerrlab -- here on detecting error |
1152`------------------------------------*/
1153yyerrlab:
1154 /* If not already recovering from an error, report this error. */
1155 if (!yyerrstatus)
1156 {
1157 ++yynerrs;
1158
1159#ifdef YYERROR_VERBOSE
1160 yyn = yypact[yystate];
1161
1162 if (yyn > YYFLAG && yyn < YYLAST)
1163 {
1164 YYSIZE_T yysize = 0;
1165 char *yymsg;
1166 int yyx, yycount;
1167
1168 yycount = 0;
1169 /* Start YYX at -YYN if negative to avoid negative indexes in
1170 YYCHECK. */
1171 for (yyx = yyn < 0 ? -yyn : 0;
1172 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1173 if (yycheck[yyx + yyn] == yyx)
1174 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1175 yysize += yystrlen ("parse error, unexpected ") + 1;
1176 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
1177 yymsg = (char *) YYSTACK_ALLOC (yysize);
1178 if (yymsg != 0)
1179 {
1180 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
1181 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
1182
1183 if (yycount < 5)
1184 {
1185 yycount = 0;
1186 for (yyx = yyn < 0 ? -yyn : 0;
1187 yyx < (int) (sizeof (yytname) / sizeof (char *));
1188 yyx++)
1189 if (yycheck[yyx + yyn] == yyx)
1190 {
1191 const char *yyq = ! yycount ? ", expecting " : " or ";
1192 yyp = yystpcpy (yyp, yyq);
1193 yyp = yystpcpy (yyp, yytname[yyx]);
1194 yycount++;
1195 }
1196 }
1197 yyerror (yymsg);
1198 YYSTACK_FREE (yymsg);
1199 }
1200 else
1201 yyerror ("parse error; also virtual memory exhausted");
1202 }
1203 else
1204#endif /* defined (YYERROR_VERBOSE) */
1205 yyerror ("parse error");
1206 }
1207 goto yyerrlab1;
1208
1209
1210/*--------------------------------------------------.
1211| yyerrlab1 -- error raised explicitly by an action |
1212`--------------------------------------------------*/
1213yyerrlab1:
1214 if (yyerrstatus == 3)
1215 {
1216 /* If just tried and failed to reuse lookahead token after an
1217 error, discard it. */
1218
1219 /* return failure if at end of input */
1220 if (yychar == YYEOF)
1221 YYABORT;
1222 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
1223 yychar, yytname[yychar1]));
1224 yychar = YYEMPTY;
1225 }
1226
1227 /* Else will try to reuse lookahead token after shifting the error
1228 token. */
1229
1230 yyerrstatus = 3; /* Each real token shifted decrements this */
1231
1232 goto yyerrhandle;
1233
1234
1235/*-------------------------------------------------------------------.
1236| yyerrdefault -- current state does not do anything special for the |
1237| error token. |
1238`-------------------------------------------------------------------*/
1239yyerrdefault:
1240#if 0
1241 /* This is wrong; only states that explicitly want error tokens
1242 should shift them. */
1243
1244 /* If its default is to accept any token, ok. Otherwise pop it. */
1245 yyn = yydefact[yystate];
1246 if (yyn)
1247 goto yydefault;
1248#endif
1249
1250
1251/*---------------------------------------------------------------.
1252| yyerrpop -- pop the current state because it cannot handle the |
1253| error token |
1254`---------------------------------------------------------------*/
1255yyerrpop:
1256 if (yyssp == yyss)
1257 YYABORT;
1258 yyvsp--;
1259 yystate = *--yyssp;
1260#if YYLSP_NEEDED
1261 yylsp--;
1262#endif
1263
1264#if YYDEBUG
1265 if (yydebug)
1266 {
1267 short *yyssp1 = yyss - 1;
1268 YYFPRINTF (stderr, "Error: state stack now");
1269 while (yyssp1 != yyssp)
1270 YYFPRINTF (stderr, " %d", *++yyssp1);
1271 YYFPRINTF (stderr, "\n");
1272 }
1273#endif
1274
1275/*--------------.
1276| yyerrhandle. |
1277`--------------*/
1278yyerrhandle:
1279 yyn = yypact[yystate];
1280 if (yyn == YYFLAG)
1281 goto yyerrdefault;
1282
1283 yyn += YYTERROR;
1284 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1285 goto yyerrdefault;
1286
1287 yyn = yytable[yyn];
1288 if (yyn < 0)
1289 {
1290 if (yyn == YYFLAG)
1291 goto yyerrpop;
1292 yyn = -yyn;
1293 goto yyreduce;
1294 }
1295 else if (yyn == 0)
1296 goto yyerrpop;
1297
1298 if (yyn == YYFINAL)
1299 YYACCEPT;
1300
1301 YYDPRINTF ((stderr, "Shifting error token, "));
1302
1303 *++yyvsp = yylval;
1304#if YYLSP_NEEDED
1305 *++yylsp = yylloc;
1306#endif
1307
1308 yystate = yyn;
1309 goto yynewstate;
1310
1311
1312/*-------------------------------------.
1313| yyacceptlab -- YYACCEPT comes here. |
1314`-------------------------------------*/
1315yyacceptlab:
1316 yyresult = 0;
1317 goto yyreturn;
1318
1319/*-----------------------------------.
1320| yyabortlab -- YYABORT comes here. |
1321`-----------------------------------*/
1322yyabortlab:
1323 yyresult = 1;
1324 goto yyreturn;
1325
1326/*---------------------------------------------.
1327| yyoverflowab -- parser overflow comes here. |
1328`---------------------------------------------*/
1329yyoverflowlab:
1330 yyerror ("parser stack overflow");
1331 yyresult = 2;
1332 /* Fall through. */
1333
1334yyreturn:
1335#ifndef yyoverflow
1336 if (yyss != yyssa)
1337 YYSTACK_FREE (yyss);
1338#endif
1339 return yyresult;
1340}
1341#line 229 "plural.y"
1342
1343
1344void
1345internal_function
1346FREE_EXPRESSION (exp)
1347 struct expression *exp;
1348{
1349 if (exp == NULL)
1350 return;
1351
1352 /* Handle the recursive case. */
1353 switch (exp->nargs)
1354 {
1355 case 3:
1356 FREE_EXPRESSION (exp->val.args[2]);
1357 /* FALLTHROUGH */
1358 case 2:
1359 FREE_EXPRESSION (exp->val.args[1]);
1360 /* FALLTHROUGH */
1361 case 1:
1362 FREE_EXPRESSION (exp->val.args[0]);
1363 /* FALLTHROUGH */
1364 default:
1365 break;
1366 }
1367
1368 free (exp);
1369}
1370
1371
1372static int
1373yylex (lval, pexp)
1374 YYSTYPE *lval;
1375 const char **pexp;
1376{
1377 const char *exp = *pexp;
1378 int result;
1379
1380 while (1)
1381 {
1382 if (exp[0] == '\0')
1383 {
1384 *pexp = exp;
1385 return YYEOF;
1386 }
1387
1388 if (exp[0] != ' ' && exp[0] != '\t')
1389 break;
1390
1391 ++exp;
1392 }
1393
1394 result = *exp++;
1395 switch (result)
1396 {
1397 case '0': case '1': case '2': case '3': case '4':
1398 case '5': case '6': case '7': case '8': case '9':
1399 {
1400 unsigned long int n = result - '0';
1401 while (exp[0] >= '0' && exp[0] <= '9')
1402 {
1403 n *= 10;
1404 n += exp[0] - '0';
1405 ++exp;
1406 }
1407 lval->num = n;
1408 result = NUMBER;
1409 }
1410 break;
1411
1412 case '=':
1413 if (exp[0] == '=')
1414 {
1415 ++exp;
1416 lval->op = equal;
1417 result = EQUOP2;
1418 }
1419 else
1420 result = YYERRCODE;
1421 break;
1422
1423 case '!':
1424 if (exp[0] == '=')
1425 {
1426 ++exp;
1427 lval->op = not_equal;
1428 result = EQUOP2;
1429 }
1430 break;
1431
1432 case '&':
1433 case '|':
1434 if (exp[0] == result)
1435 ++exp;
1436 else
1437 result = YYERRCODE;
1438 break;
1439
1440 case '<':
1441 if (exp[0] == '=')
1442 {
1443 ++exp;
1444 lval->op = less_or_equal;
1445 }
1446 else
1447 lval->op = less_than;
1448 result = CMPOP2;
1449 break;
1450
1451 case '>':
1452 if (exp[0] == '=')
1453 {
1454 ++exp;
1455 lval->op = greater_or_equal;
1456 }
1457 else
1458 lval->op = greater_than;
1459 result = CMPOP2;
1460 break;
1461
1462 case '*':
1463 lval->op = mult;
1464 result = MULOP2;
1465 break;
1466
1467 case '/':
1468 lval->op = divide;
1469 result = MULOP2;
1470 break;
1471
1472 case '%':
1473 lval->op = module;
1474 result = MULOP2;
1475 break;
1476
1477 case '+':
1478 lval->op = plus;
1479 result = ADDOP2;
1480 break;
1481
1482 case '-':
1483 lval->op = minus;
1484 result = ADDOP2;
1485 break;
1486
1487 case 'n':
1488 case '?':
1489 case ':':
1490 case '(':
1491 case ')':
1492 /* Nothing, just return the character. */
1493 break;
1494
1495 case ';':
1496 case '\n':
1497 case '\0':
1498 /* Be safe and let the user call this function again. */
1499 --exp;
1500 result = YYEOF;
1501 break;
1502
1503 default:
1504 result = YYERRCODE;
1505#if YYDEBUG != 0
1506 --exp;
1507#endif
1508 break;
1509 }
1510
1511 *pexp = exp;
1512
1513 return result;
1514}
1515
1516
1517static void
1518yyerror (str)
1519 const char *str;
1520{
1521 /* Do nothing. We don't print error messages here. */
1522}
Note: See TracBrowser for help on using the repository browser.