1
/* A Bison parser, made by GNU Bison 1.875d. */
3
/* Skeleton parser for Yacc-like parsing with Bison,
4
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place - Suite 330,
19
Boston, MA 02111-1307, USA. */
21
/* As a special exception, when this file is copied by Bison into a
22
Bison output file, you may use that output file without restriction.
23
This special exception was added by the Free Software Foundation
24
in version 1.24 of Bison. */
26
/* Written by Richard Stallman by simplifying the original so called
27
``semantic'' parser. */
29
/* All symbols defined below should begin with yy or YY, to avoid
30
infringing on user name space. This should be done even for local
31
variables, as they might otherwise be expanded by user macros.
32
There are some unavoidable exceptions within include files to
33
define necessary library symbols; they are noted "INFRINGES ON
34
USER NAME SPACE" below. */
36
/* Identify Bison output. */
40
#define YYSKELETON_NAME "yacc.c"
45
/* Using locations. */
46
#define YYLSP_NEEDED 0
48
/* If NAME_PREFIX is specified substitute the variables and functions
50
#define yyparse __gettextparse
51
#define yylex __gettextlex
52
#define yyerror __gettexterror
53
#define yylval __gettextlval
54
#define yychar __gettextchar
55
#define yydebug __gettextdebug
56
#define yynerrs __gettextnerrs
62
/* Put the tokens into the symbol table, so that GDB and other debuggers
81
/* Copy the first part of user declarations. */
84
/* Expression parsing for plural form selection.
85
Copyright (C) 2000, 2001 Free Software Foundation, Inc.
86
Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
88
This program is free software; you can redistribute it and/or modify it
89
under the terms of the GNU Library General Public License as published
90
by the Free Software Foundation; either version 2, or (at your option)
93
This program is distributed in the hope that it will be useful,
94
but WITHOUT ANY WARRANTY; without even the implied warranty of
95
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
96
Library General Public License for more details.
98
You should have received a copy of the GNU Library General Public
99
License along with this program; if not, write to the Free Software
100
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
103
/* The bison generated parser uses alloca. AIX 3 forces us to put this
104
declaration at the beginning of the file. The declaration in bison's
105
skeleton file comes too late. This must come before <config.h>
106
because <config.h> may include arbitrary system headers. */
107
#if defined _AIX && !defined __GNUC__
116
#include "gettextP.h"
118
/* Names for the libintl functions are a problem. They must not clash
119
with existing names and they should follow ANSI C. But this source
120
code is also used in GNU C Library where the names have a __
121
prefix. So we have to make a difference here. */
123
# define FREE_EXPRESSION __gettext_free_exp
125
# define FREE_EXPRESSION gettext_free_exp__
126
# define __gettextparse gettextparse__
129
#define YYLEX_PARAM &((struct parse_args *) arg)->cp
130
#define YYPARSE_PARAM arg
133
/* Enabling traces. */
138
/* Enabling verbose error messages. */
139
#ifdef YYERROR_VERBOSE
140
# undef YYERROR_VERBOSE
141
# define YYERROR_VERBOSE 1
143
# define YYERROR_VERBOSE 0
146
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
148
typedef union YYSTYPE {
149
unsigned long int num;
151
struct expression *exp;
153
/* Line 191 of yacc.c. */
155
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
156
# define YYSTYPE_IS_DECLARED 1
157
# define YYSTYPE_IS_TRIVIAL 1
162
/* Copy the second part of user declarations. */
165
/* Prototypes for local functions. */
166
static struct expression *new_exp PARAMS ((int nargs, enum operator op,
167
struct expression * const *args));
168
static inline struct expression *new_exp_0 PARAMS ((enum operator op));
169
static inline struct expression *new_exp_1 PARAMS ((enum operator op,
170
struct expression *right));
171
static struct expression *new_exp_2 PARAMS ((enum operator op,
172
struct expression *left,
173
struct expression *right));
174
static inline struct expression *new_exp_3 PARAMS ((enum operator op,
175
struct expression *bexp,
176
struct expression *tbranch,
177
struct expression *fbranch));
178
static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
179
static void yyerror PARAMS ((const char *str));
181
/* Allocation of expressions. */
183
static struct expression *
184
new_exp (nargs, op, args)
187
struct expression * const *args;
190
struct expression *newp;
192
/* If any of the argument could not be malloc'ed, just return NULL. */
193
for (i = nargs - 1; i >= 0; i--)
197
/* Allocate a new expression. */
198
newp = (struct expression *) malloc (sizeof (*newp));
202
newp->operation = op;
203
for (i = nargs - 1; i >= 0; i--)
204
newp->val.args[i] = args[i];
209
for (i = nargs - 1; i >= 0; i--)
210
FREE_EXPRESSION (args[i]);
215
static inline struct expression *
219
return new_exp (0, op, NULL);
222
static inline struct expression *
223
new_exp_1 (op, right)
225
struct expression *right;
227
struct expression *args[1];
230
return new_exp (1, op, args);
233
static struct expression *
234
new_exp_2 (op, left, right)
236
struct expression *left;
237
struct expression *right;
239
struct expression *args[2];
243
return new_exp (2, op, args);
246
static inline struct expression *
247
new_exp_3 (op, bexp, tbranch, fbranch)
249
struct expression *bexp;
250
struct expression *tbranch;
251
struct expression *fbranch;
253
struct expression *args[3];
258
return new_exp (3, op, args);
263
/* Line 214 of yacc.c. */
266
#if ! defined (yyoverflow) || YYERROR_VERBOSE
272
# define YYMALLOC malloc
275
/* The parser invokes alloca or malloc; define the necessary symbols. */
277
# ifdef YYSTACK_USE_ALLOCA
278
# if YYSTACK_USE_ALLOCA
279
# define YYSTACK_ALLOC alloca
282
# if defined (alloca) || defined (_ALLOCA_H)
283
# define YYSTACK_ALLOC alloca
286
# define YYSTACK_ALLOC __builtin_alloca
291
# ifdef YYSTACK_ALLOC
292
/* Pacify GCC's `empty if-body' warning. */
293
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
295
# if defined (__STDC__) || defined (__cplusplus)
296
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
297
# define YYSIZE_T size_t
299
# define YYSTACK_ALLOC YYMALLOC
300
# define YYSTACK_FREE YYFREE
302
#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
305
#if (! defined (yyoverflow) \
306
&& (! defined (__cplusplus) \
307
|| (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
309
/* A type that is properly aligned for any stack member. */
316
/* The size of the maximum gap between one aligned stack and the next. */
317
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
319
/* The size of an array large to enough to hold all stacks, each with
321
# define YYSTACK_BYTES(N) \
322
((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
323
+ YYSTACK_GAP_MAXIMUM)
325
/* Copy COUNT objects from FROM to TO. The source and destination do
328
# if defined (__GNUC__) && 1 < __GNUC__
329
# define YYCOPY(To, From, Count) \
330
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
332
# define YYCOPY(To, From, Count) \
335
register YYSIZE_T yyi; \
336
for (yyi = 0; yyi < (Count); yyi++) \
337
(To)[yyi] = (From)[yyi]; \
343
/* Relocate STACK from its old location to the new one. The
344
local variables YYSIZE and YYSTACKSIZE give the old and new number of
345
elements in the stack, and YYPTR gives the new location of the
346
stack. Advance YYPTR to a properly aligned location for the next
348
# define YYSTACK_RELOCATE(Stack) \
351
YYSIZE_T yynewbytes; \
352
YYCOPY (&yyptr->Stack, Stack, yysize); \
353
Stack = &yyptr->Stack; \
354
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
355
yyptr += yynewbytes / sizeof (*yyptr); \
361
#if defined (__STDC__) || defined (__cplusplus)
362
typedef signed char yysigned_char;
364
typedef short int yysigned_char;
367
/* YYFINAL -- State number of the termination state. */
369
/* YYLAST -- Last index in YYTABLE. */
372
/* YYNTOKENS -- Number of terminals. */
374
/* YYNNTS -- Number of nonterminals. */
376
/* YYNRULES -- Number of rules. */
378
/* YYNRULES -- Number of states. */
381
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
383
#define YYMAXUTOK 262
385
#define YYTRANSLATE(YYX) \
386
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
388
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
389
static const unsigned char yytranslate[] =
391
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
392
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
393
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
394
2, 2, 2, 10, 2, 2, 2, 2, 5, 2,
395
14, 15, 2, 2, 2, 2, 2, 2, 2, 2,
396
2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
397
2, 2, 2, 3, 2, 2, 2, 2, 2, 2,
398
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
399
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
400
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
401
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
402
13, 2, 2, 2, 2, 2, 2, 2, 2, 2,
403
2, 2, 2, 2, 4, 2, 2, 2, 2, 2,
404
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
405
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
406
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
407
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
408
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
409
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
410
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
411
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
412
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
413
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
414
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
415
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
416
2, 2, 2, 2, 2, 2, 1, 2, 6, 7,
421
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
423
static const unsigned char yyprhs[] =
425
0, 0, 3, 5, 11, 15, 19, 23, 27, 31,
429
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
430
static const yysigned_char yyrhs[] =
432
17, 0, -1, 18, -1, 18, 3, 18, 12, 18,
433
-1, 18, 4, 18, -1, 18, 5, 18, -1, 18,
434
6, 18, -1, 18, 7, 18, -1, 18, 8, 18,
435
-1, 18, 9, 18, -1, 10, 18, -1, 13, -1,
436
11, -1, 14, 18, 15, -1
439
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
440
static const unsigned char yyrline[] =
442
0, 178, 178, 186, 190, 194, 198, 202, 206, 210,
447
#if YYDEBUG || YYERROR_VERBOSE
448
/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
449
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
450
static const char *const yytname[] =
452
"$end", "error", "$undefined", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
453
"ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
454
"$accept", "start", "exp", 0
459
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
461
static const unsigned short int yytoknum[] =
463
0, 256, 257, 63, 124, 38, 258, 259, 260, 261,
464
33, 262, 58, 110, 40, 41
468
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
469
static const unsigned char yyr1[] =
471
0, 16, 17, 18, 18, 18, 18, 18, 18, 18,
475
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
476
static const unsigned char yyr2[] =
478
0, 2, 1, 5, 3, 3, 3, 3, 3, 3,
482
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
483
STATE-NUM when YYTABLE doesn't specify something else to do. Zero
484
means the default is an error. */
485
static const unsigned char yydefact[] =
487
0, 0, 12, 11, 0, 0, 2, 10, 0, 1,
488
0, 0, 0, 0, 0, 0, 0, 13, 0, 4,
492
/* YYDEFGOTO[NTERM-NUM]. */
493
static const yysigned_char yydefgoto[] =
498
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
500
#define YYPACT_NINF -10
501
static const yysigned_char yypact[] =
503
-9, -9, -10, -10, -9, 8, 36, -10, 13, -10,
504
-9, -9, -9, -9, -9, -9, -9, -10, 26, 41,
505
45, 18, -2, 14, -10, -9, 36
508
/* YYPGOTO[NTERM-NUM]. */
509
static const yysigned_char yypgoto[] =
514
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
515
positive, shift that token. If negative, reduce the rule which
516
number is the opposite. If zero, do what YYDEFACT says.
517
If YYTABLE_NINF, syntax error. */
518
#define YYTABLE_NINF -1
519
static const unsigned char yytable[] =
521
7, 1, 2, 8, 3, 4, 15, 16, 9, 18,
522
19, 20, 21, 22, 23, 24, 10, 11, 12, 13,
523
14, 15, 16, 16, 26, 14, 15, 16, 17, 10,
524
11, 12, 13, 14, 15, 16, 0, 0, 25, 10,
525
11, 12, 13, 14, 15, 16, 12, 13, 14, 15,
529
static const yysigned_char yycheck[] =
531
1, 10, 11, 4, 13, 14, 8, 9, 0, 10,
532
11, 12, 13, 14, 15, 16, 3, 4, 5, 6,
533
7, 8, 9, 9, 25, 7, 8, 9, 15, 3,
534
4, 5, 6, 7, 8, 9, -1, -1, 12, 3,
535
4, 5, 6, 7, 8, 9, 5, 6, 7, 8,
539
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
540
symbol of state STATE-NUM. */
541
static const unsigned char yystos[] =
543
0, 10, 11, 13, 14, 17, 18, 18, 18, 0,
544
3, 4, 5, 6, 7, 8, 9, 15, 18, 18,
545
18, 18, 18, 18, 18, 12, 18
548
#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
549
# define YYSIZE_T __SIZE_TYPE__
551
#if ! defined (YYSIZE_T) && defined (size_t)
552
# define YYSIZE_T size_t
554
#if ! defined (YYSIZE_T)
555
# if defined (__STDC__) || defined (__cplusplus)
556
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
557
# define YYSIZE_T size_t
560
#if ! defined (YYSIZE_T)
561
# define YYSIZE_T unsigned int
564
#define yyerrok (yyerrstatus = 0)
565
#define yyclearin (yychar = YYEMPTY)
569
#define YYACCEPT goto yyacceptlab
570
#define YYABORT goto yyabortlab
571
#define YYERROR goto yyerrorlab
574
/* Like YYERROR except do call yyerror. This remains here temporarily
575
to ease the transition to the new meaning of YYERROR, for GCC.
576
Once GCC version 2 has supplanted version 1, this can go. */
578
#define YYFAIL goto yyerrlab
580
#define YYRECOVERING() (!!yyerrstatus)
582
#define YYBACKUP(Token, Value) \
584
if (yychar == YYEMPTY && yylen == 1) \
588
yytoken = YYTRANSLATE (yychar); \
594
yyerror ("syntax error: cannot back up");\
600
#define YYERRCODE 256
602
/* YYLLOC_DEFAULT -- Compute the default location (before the actions
605
#ifndef YYLLOC_DEFAULT
606
# define YYLLOC_DEFAULT(Current, Rhs, N) \
607
((Current).first_line = (Rhs)[1].first_line, \
608
(Current).first_column = (Rhs)[1].first_column, \
609
(Current).last_line = (Rhs)[N].last_line, \
610
(Current).last_column = (Rhs)[N].last_column)
613
/* YYLEX -- calling `yylex' with the right arguments. */
616
# define YYLEX yylex (&yylval, YYLEX_PARAM)
618
# define YYLEX yylex (&yylval)
621
/* Enable debugging if requested. */
625
# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
626
# define YYFPRINTF fprintf
629
# define YYDPRINTF(Args) \
635
# define YYDSYMPRINT(Args) \
641
# define YYDSYMPRINTF(Title, Token, Value, Location) \
645
YYFPRINTF (stderr, "%s ", Title); \
646
yysymprint (stderr, \
648
YYFPRINTF (stderr, "\n"); \
652
/*------------------------------------------------------------------.
653
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
655
`------------------------------------------------------------------*/
657
#if defined (__STDC__) || defined (__cplusplus)
659
yy_stack_print (short int *bottom, short int *top)
662
yy_stack_print (bottom, top)
667
YYFPRINTF (stderr, "Stack now");
668
for (/* Nothing. */; bottom <= top; ++bottom)
669
YYFPRINTF (stderr, " %d", *bottom);
670
YYFPRINTF (stderr, "\n");
673
# define YY_STACK_PRINT(Bottom, Top) \
676
yy_stack_print ((Bottom), (Top)); \
680
/*------------------------------------------------.
681
| Report that the YYRULE is going to be reduced. |
682
`------------------------------------------------*/
684
#if defined (__STDC__) || defined (__cplusplus)
686
yy_reduce_print (int yyrule)
689
yy_reduce_print (yyrule)
694
unsigned int yylno = yyrline[yyrule];
695
YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
697
/* Print the symbols being reduced, and their result. */
698
for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
699
YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
700
YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
703
# define YY_REDUCE_PRINT(Rule) \
706
yy_reduce_print (Rule); \
709
/* Nonzero means print parse trace. It is left uninitialized so that
710
multiple parsers can coexist. */
713
# define YYDPRINTF(Args)
714
# define YYDSYMPRINT(Args)
715
# define YYDSYMPRINTF(Title, Token, Value, Location)
716
# define YY_STACK_PRINT(Bottom, Top)
717
# define YY_REDUCE_PRINT(Rule)
718
#endif /* !YYDEBUG */
721
/* YYINITDEPTH -- initial size of the parser's stacks. */
723
# define YYINITDEPTH 200
726
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
727
if the built-in stack extension method is used).
729
Do not make this value too large; the results are undefined if
730
SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
731
evaluated with infinite-precision integer arithmetic. */
733
#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0
738
# define YYMAXDEPTH 10000
746
# if defined (__GLIBC__) && defined (_STRING_H)
747
# define yystrlen strlen
749
/* Return the length of YYSTR. */
751
# if defined (__STDC__) || defined (__cplusplus)
752
yystrlen (const char *yystr)
758
register const char *yys = yystr;
760
while (*yys++ != '\0')
763
return yys - yystr - 1;
769
# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
770
# define yystpcpy stpcpy
772
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
775
# if defined (__STDC__) || defined (__cplusplus)
776
yystpcpy (char *yydest, const char *yysrc)
778
yystpcpy (yydest, yysrc)
783
register char *yyd = yydest;
784
register const char *yys = yysrc;
786
while ((*yyd++ = *yys++) != '\0')
794
#endif /* !YYERROR_VERBOSE */
799
/*--------------------------------.
800
| Print this symbol on YYOUTPUT. |
801
`--------------------------------*/
803
#if defined (__STDC__) || defined (__cplusplus)
805
yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
808
yysymprint (yyoutput, yytype, yyvaluep)
814
/* Pacify ``unused variable'' warnings. */
817
if (yytype < YYNTOKENS)
819
YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
821
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
825
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
832
YYFPRINTF (yyoutput, ")");
835
#endif /* ! YYDEBUG */
836
/*-----------------------------------------------.
837
| Release the memory associated to this symbol. |
838
`-----------------------------------------------*/
840
#if defined (__STDC__) || defined (__cplusplus)
842
yydestruct (int yytype, YYSTYPE *yyvaluep)
845
yydestruct (yytype, yyvaluep)
850
/* Pacify ``unused variable'' warnings. */
862
/* Prevent warnings from -Wmissing-prototypes. */
865
# if defined (__STDC__) || defined (__cplusplus)
866
int yyparse (void *YYPARSE_PARAM);
870
#else /* ! YYPARSE_PARAM */
871
#if defined (__STDC__) || defined (__cplusplus)
876
#endif /* ! YYPARSE_PARAM */
888
# if defined (__STDC__) || defined (__cplusplus)
889
int yyparse (void *YYPARSE_PARAM)
891
int yyparse (YYPARSE_PARAM)
894
#else /* ! YYPARSE_PARAM */
895
#if defined (__STDC__) || defined (__cplusplus)
905
/* The lookahead symbol. */
908
/* The semantic value of the lookahead symbol. */
911
/* Number of syntax errors so far. */
914
register int yystate;
917
/* Number of tokens to shift before error messages enabled. */
919
/* Lookahead token as an internal (translated) token number. */
922
/* Three stacks and their tools:
923
`yyss': related to states,
924
`yyvs': related to semantic values,
925
`yyls': related to locations.
927
Refer to the stacks thru separate pointers, to allow yyoverflow
928
to reallocate them elsewhere. */
930
/* The state stack. */
931
short int yyssa[YYINITDEPTH];
932
short int *yyss = yyssa;
933
register short int *yyssp;
935
/* The semantic value stack. */
936
YYSTYPE yyvsa[YYINITDEPTH];
937
YYSTYPE *yyvs = yyvsa;
938
register YYSTYPE *yyvsp;
942
#define YYPOPSTACK (yyvsp--, yyssp--)
944
YYSIZE_T yystacksize = YYINITDEPTH;
946
/* The variables used to return semantic value and location from the
951
/* When reducing, the number of symbols on the RHS of the reduced
955
YYDPRINTF ((stderr, "Starting parse\n"));
960
yychar = YYEMPTY; /* Cause a token to be read. */
962
/* Initialize stack pointers.
963
Waste one element of value and location stack
964
so that they stay on the same level as the state stack.
965
The wasted elements are never initialized. */
973
/*------------------------------------------------------------.
974
| yynewstate -- Push a new state, which is found in yystate. |
975
`------------------------------------------------------------*/
977
/* In all cases, when you get here, the value and location stacks
978
have just been pushed. so pushing a state here evens the stacks.
985
if (yyss + yystacksize - 1 <= yyssp)
987
/* Get the current used size of the three stacks, in elements. */
988
YYSIZE_T yysize = yyssp - yyss + 1;
992
/* Give user a chance to reallocate the stack. Use copies of
993
these so that the &'s don't force the real ones into
995
YYSTYPE *yyvs1 = yyvs;
996
short int *yyss1 = yyss;
999
/* Each stack pointer address is followed by the size of the
1000
data in use in that stack, in bytes. This used to be a
1001
conditional around just the two extra args, but that might
1002
be undefined if yyoverflow is a macro. */
1003
yyoverflow ("parser stack overflow",
1004
&yyss1, yysize * sizeof (*yyssp),
1005
&yyvs1, yysize * sizeof (*yyvsp),
1012
#else /* no yyoverflow */
1013
# ifndef YYSTACK_RELOCATE
1016
/* Extend the stack our own way. */
1017
if (YYMAXDEPTH <= yystacksize)
1020
if (YYMAXDEPTH < yystacksize)
1021
yystacksize = YYMAXDEPTH;
1024
short int *yyss1 = yyss;
1025
union yyalloc *yyptr =
1026
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1029
YYSTACK_RELOCATE (yyss);
1030
YYSTACK_RELOCATE (yyvs);
1032
# undef YYSTACK_RELOCATE
1034
YYSTACK_FREE (yyss1);
1037
#endif /* no yyoverflow */
1039
yyssp = yyss + yysize - 1;
1040
yyvsp = yyvs + yysize - 1;
1043
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1044
(unsigned long int) yystacksize));
1046
if (yyss + yystacksize - 1 <= yyssp)
1050
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1059
/* Do appropriate processing given the current state. */
1060
/* Read a lookahead token if we need one and don't already have one. */
1063
/* First try to decide what to do without reference to lookahead token. */
1065
yyn = yypact[yystate];
1066
if (yyn == YYPACT_NINF)
1069
/* Not known => get a lookahead token if don't already have one. */
1071
/* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1072
if (yychar == YYEMPTY)
1074
YYDPRINTF ((stderr, "Reading a token: "));
1078
if (yychar <= YYEOF)
1080
yychar = yytoken = YYEOF;
1081
YYDPRINTF ((stderr, "Now at end of input.\n"));
1085
yytoken = YYTRANSLATE (yychar);
1086
YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
1089
/* If the proper action on seeing token YYTOKEN is to reduce or to
1090
detect an error, take that action. */
1092
if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1097
if (yyn == 0 || yyn == YYTABLE_NINF)
1106
/* Shift the lookahead token. */
1107
YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
1109
/* Discard the token being shifted unless it is eof. */
1110
if (yychar != YYEOF)
1116
/* Count tokens shifted since error; after three, turn off error
1125
/*-----------------------------------------------------------.
1126
| yydefault -- do the default action for the current state. |
1127
`-----------------------------------------------------------*/
1129
yyn = yydefact[yystate];
1135
/*-----------------------------.
1136
| yyreduce -- Do a reduction. |
1137
`-----------------------------*/
1139
/* yyn is the number of a rule to reduce with. */
1142
/* If YYLEN is nonzero, implement the default value of the action:
1145
Otherwise, the following line sets YYVAL to garbage.
1146
This behavior is undocumented and Bison
1147
users should not rely upon it. Assigning to YYVAL
1148
unconditionally makes the parser a bit smaller, and it avoids a
1149
GCC warning that YYVAL may be used uninitialized. */
1150
yyval = yyvsp[1-yylen];
1153
YY_REDUCE_PRINT (yyn);
1157
#line 179 "plural.y"
1159
if (yyvsp[0].exp == NULL)
1161
((struct parse_args *) arg)->res = yyvsp[0].exp;
1166
#line 187 "plural.y"
1168
yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp);
1173
#line 191 "plural.y"
1175
yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp);
1180
#line 195 "plural.y"
1182
yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp);
1187
#line 199 "plural.y"
1189
yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1194
#line 203 "plural.y"
1196
yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1201
#line 207 "plural.y"
1203
yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1208
#line 211 "plural.y"
1210
yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1215
#line 215 "plural.y"
1217
yyval.exp = new_exp_1 (lnot, yyvsp[0].exp);
1222
#line 219 "plural.y"
1224
yyval.exp = new_exp_0 (var);
1229
#line 223 "plural.y"
1231
if ((yyval.exp = new_exp_0 (num)) != NULL)
1232
yyval.exp->val.num = yyvsp[0].num;
1237
#line 228 "plural.y"
1239
yyval.exp = yyvsp[-1].exp;
1246
/* Line 1010 of yacc.c. */
1247
#line 1248 "plural.c"
1253
YY_STACK_PRINT (yyss, yyssp);
1258
/* Now `shift' the result of the reduction. Determine what state
1259
that goes to, based on the state we popped back to and the rule
1260
number reduced by. */
1264
yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1265
if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1266
yystate = yytable[yystate];
1268
yystate = yydefgoto[yyn - YYNTOKENS];
1273
/*------------------------------------.
1274
| yyerrlab -- here on detecting error |
1275
`------------------------------------*/
1277
/* If not already recovering from an error, report this error. */
1282
yyn = yypact[yystate];
1284
if (YYPACT_NINF < yyn && yyn < YYLAST)
1286
YYSIZE_T yysize = 0;
1287
int yytype = YYTRANSLATE (yychar);
1288
const char* yyprefix;
1292
/* Start YYX at -YYN if negative to avoid negative indexes in
1294
int yyxbegin = yyn < 0 ? -yyn : 0;
1296
/* Stay within bounds of both yycheck and yytname. */
1297
int yychecklim = YYLAST - yyn;
1298
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1301
yyprefix = ", expecting ";
1302
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1303
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1305
yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
1313
yysize += (sizeof ("syntax error, unexpected ")
1314
+ yystrlen (yytname[yytype]));
1315
yymsg = (char *) YYSTACK_ALLOC (yysize);
1318
char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
1319
yyp = yystpcpy (yyp, yytname[yytype]);
1323
yyprefix = ", expecting ";
1324
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1325
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1327
yyp = yystpcpy (yyp, yyprefix);
1328
yyp = yystpcpy (yyp, yytname[yyx]);
1333
YYSTACK_FREE (yymsg);
1336
yyerror ("syntax error; also virtual memory exhausted");
1339
#endif /* YYERROR_VERBOSE */
1340
yyerror ("syntax error");
1345
if (yyerrstatus == 3)
1347
/* If just tried and failed to reuse lookahead token after an
1348
error, discard it. */
1350
if (yychar <= YYEOF)
1352
/* If at end of input, pop the error token,
1353
then the rest of the stack, then return failure. */
1354
if (yychar == YYEOF)
1360
YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1361
yydestruct (yystos[*yyssp], yyvsp);
1366
YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
1367
yydestruct (yytoken, &yylval);
1373
/* Else will try to reuse lookahead token after shifting the error
1378
/*---------------------------------------------------.
1379
| yyerrorlab -- error raised explicitly by YYERROR. |
1380
`---------------------------------------------------*/
1384
/* Pacify GCC when the user code never invokes YYERROR and the label
1385
yyerrorlab therefore never appears in user code. */
1396
/*-------------------------------------------------------------.
1397
| yyerrlab1 -- common code for both syntax error and YYERROR. |
1398
`-------------------------------------------------------------*/
1400
yyerrstatus = 3; /* Each real token shifted decrements this. */
1404
yyn = yypact[yystate];
1405
if (yyn != YYPACT_NINF)
1408
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1416
/* Pop the current state because it cannot handle the error token. */
1420
YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1421
yydestruct (yystos[yystate], yyvsp);
1424
YY_STACK_PRINT (yyss, yyssp);
1430
YYDPRINTF ((stderr, "Shifting error token, "));
1439
/*-------------------------------------.
1440
| yyacceptlab -- YYACCEPT comes here. |
1441
`-------------------------------------*/
1446
/*-----------------------------------.
1447
| yyabortlab -- YYABORT comes here. |
1448
`-----------------------------------*/
1454
/*----------------------------------------------.
1455
| yyoverflowlab -- parser overflow comes here. |
1456
`----------------------------------------------*/
1458
yyerror ("parser stack overflow");
1466
YYSTACK_FREE (yyss);
1472
#line 233 "plural.y"
1477
FREE_EXPRESSION (exp)
1478
struct expression *exp;
1483
/* Handle the recursive case. */
1487
FREE_EXPRESSION (exp->val.args[2]);
1490
FREE_EXPRESSION (exp->val.args[1]);
1493
FREE_EXPRESSION (exp->val.args[0]);
1508
const char *exp = *pexp;
1519
if (exp[0] != ' ' && exp[0] != '\t')
1528
case '0': case '1': case '2': case '3': case '4':
1529
case '5': case '6': case '7': case '8': case '9':
1531
unsigned long int n = result - '0';
1532
while (exp[0] >= '0' && exp[0] <= '9')
1558
lval->op = not_equal;
1565
if (exp[0] == result)
1575
lval->op = less_or_equal;
1578
lval->op = less_than;
1586
lval->op = greater_or_equal;
1589
lval->op = greater_than;
1623
/* Nothing, just return the character. */
1629
/* Be safe and let the user call this function again. */
1652
/* Do nothing. We don't print error messages here. */