source: trunk/essentials/sys-apps/texinfo/intl/plural.c

Last change on this file was 2617, checked in by bird, 19 years ago

GNU Texinfo 4.8

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