1
/* A Bison parser, made by GNU Bison 1.875a. */
3
/* Skeleton parser for Yacc-like parsing with Bison,
4
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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. */
82
#line 1 "../../findutils/intl/plural.y"
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
89
it under the terms of the GNU General Public License as published by
90
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
96
GNU General Public License for more details.
98
You should have received a copy of the GNU General Public License
99
along with this program; if not, write to the Free Software Foundation,
100
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
102
/* The bison generated parser uses alloca. AIX 3 forces us to put this
103
declaration at the beginning of the file. The declaration in bison's
104
skeleton file comes too late. This must come before <config.h>
105
because <config.h> may include arbitrary system headers. */
106
#if defined _AIX && !defined __GNUC__
111
# include <gnulib/config.h>
113
# undef PACKAGE_VERSION
114
# undef PACKAGE_TARNAME
115
# undef PACKAGE_STRING
120
#include "gettextP.h"
122
/* Names for the libintl functions are a problem. They must not clash
123
with existing names and they should follow ANSI C. But this source
124
code is also used in GNU C Library where the names have a __
125
prefix. So we have to make a difference here. */
127
# define FREE_EXPRESSION __gettext_free_exp
129
# define FREE_EXPRESSION gettext_free_exp__
130
# define __gettextparse gettextparse__
133
#define YYLEX_PARAM &((struct parse_args *) arg)->cp
134
#define YYPARSE_PARAM arg
137
/* Enabling traces. */
142
/* Enabling verbose error messages. */
143
#ifdef YYERROR_VERBOSE
144
# undef YYERROR_VERBOSE
145
# define YYERROR_VERBOSE 1
147
# define YYERROR_VERBOSE 0
150
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
151
#line 57 "../../findutils/intl/plural.y"
152
typedef union YYSTYPE {
153
unsigned long int num;
155
struct expression *exp;
157
/* Line 191 of yacc.c. */
159
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
160
# define YYSTYPE_IS_DECLARED 1
161
# define YYSTYPE_IS_TRIVIAL 1
166
/* Copy the second part of user declarations. */
167
#line 63 "../../findutils/intl/plural.y"
169
/* Prototypes for local functions. */
170
static struct expression *new_exp PARAMS ((int nargs, enum operator op,
171
struct expression * const *args));
172
static inline struct expression *new_exp_0 PARAMS ((enum operator op));
173
static inline struct expression *new_exp_1 PARAMS ((enum operator op,
174
struct expression *right));
175
static struct expression *new_exp_2 PARAMS ((enum operator op,
176
struct expression *left,
177
struct expression *right));
178
static inline struct expression *new_exp_3 PARAMS ((enum operator op,
179
struct expression *bexp,
180
struct expression *tbranch,
181
struct expression *fbranch));
182
static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
183
static void yyerror PARAMS ((const char *str));
185
/* Allocation of expressions. */
187
static struct expression *
188
new_exp (nargs, op, args)
191
struct expression * const *args;
194
struct expression *newp;
196
/* If any of the argument could not be malloc'ed, just return NULL. */
197
for (i = nargs - 1; i >= 0; i--)
201
/* Allocate a new expression. */
202
newp = (struct expression *) malloc (sizeof (*newp));
206
newp->operation = op;
207
for (i = nargs - 1; i >= 0; i--)
208
newp->val.args[i] = args[i];
213
for (i = nargs - 1; i >= 0; i--)
214
FREE_EXPRESSION (args[i]);
219
static inline struct expression *
223
return new_exp (0, op, NULL);
226
static inline struct expression *
227
new_exp_1 (op, right)
229
struct expression *right;
231
struct expression *args[1];
234
return new_exp (1, op, args);
237
static struct expression *
238
new_exp_2 (op, left, right)
240
struct expression *left;
241
struct expression *right;
243
struct expression *args[2];
247
return new_exp (2, op, args);
250
static inline struct expression *
251
new_exp_3 (op, bexp, tbranch, fbranch)
253
struct expression *bexp;
254
struct expression *tbranch;
255
struct expression *fbranch;
257
struct expression *args[3];
262
return new_exp (3, op, args);
267
/* Line 214 of yacc.c. */
270
#if ! defined (yyoverflow) || YYERROR_VERBOSE
272
/* The parser invokes alloca or malloc; define the necessary symbols. */
274
# if YYSTACK_USE_ALLOCA
275
# define YYSTACK_ALLOC alloca
277
# ifndef YYSTACK_USE_ALLOCA
278
# if defined (alloca) || defined (_ALLOCA_H)
279
# define YYSTACK_ALLOC alloca
282
# define YYSTACK_ALLOC __builtin_alloca
288
# ifdef YYSTACK_ALLOC
289
/* Pacify GCC's `empty if-body' warning. */
290
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
292
# if defined (__STDC__) || defined (__cplusplus)
293
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
294
# define YYSIZE_T size_t
296
# define YYSTACK_ALLOC malloc
297
# define YYSTACK_FREE free
299
#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
302
#if (! defined (yyoverflow) \
303
&& (! defined (__cplusplus) \
304
|| (YYSTYPE_IS_TRIVIAL)))
306
/* A type that is properly aligned for any stack member. */
313
/* The size of the maximum gap between one aligned stack and the next. */
314
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
316
/* The size of an array large to enough to hold all stacks, each with
318
# define YYSTACK_BYTES(N) \
319
((N) * (sizeof (short) + sizeof (YYSTYPE)) \
320
+ YYSTACK_GAP_MAXIMUM)
322
/* Copy COUNT objects from FROM to TO. The source and destination do
326
# define YYCOPY(To, From, Count) \
327
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
329
# define YYCOPY(To, From, Count) \
332
register YYSIZE_T yyi; \
333
for (yyi = 0; yyi < (Count); yyi++) \
334
(To)[yyi] = (From)[yyi]; \
340
/* Relocate STACK from its old location to the new one. The
341
local variables YYSIZE and YYSTACKSIZE give the old and new number of
342
elements in the stack, and YYPTR gives the new location of the
343
stack. Advance YYPTR to a properly aligned location for the next
345
# define YYSTACK_RELOCATE(Stack) \
348
YYSIZE_T yynewbytes; \
349
YYCOPY (&yyptr->Stack, Stack, yysize); \
350
Stack = &yyptr->Stack; \
351
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
352
yyptr += yynewbytes / sizeof (*yyptr); \
358
#if defined (__STDC__) || defined (__cplusplus)
359
typedef signed char yysigned_char;
361
typedef short yysigned_char;
364
/* YYFINAL -- State number of the termination state. */
366
/* YYLAST -- Last index in YYTABLE. */
369
/* YYNTOKENS -- Number of terminals. */
371
/* YYNNTS -- Number of nonterminals. */
373
/* YYNRULES -- Number of rules. */
375
/* YYNRULES -- Number of states. */
378
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
380
#define YYMAXUTOK 262
382
#define YYTRANSLATE(YYX) \
383
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
385
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
386
static const unsigned char yytranslate[] =
388
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
389
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
390
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
391
2, 2, 2, 10, 2, 2, 2, 2, 5, 2,
392
14, 15, 2, 2, 2, 2, 2, 2, 2, 2,
393
2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
394
2, 2, 2, 3, 2, 2, 2, 2, 2, 2,
395
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
396
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
397
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
398
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
399
13, 2, 2, 2, 2, 2, 2, 2, 2, 2,
400
2, 2, 2, 2, 4, 2, 2, 2, 2, 2,
401
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
402
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
403
2, 2, 2, 2, 2, 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, 1, 2, 6, 7,
418
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
420
static const unsigned char yyprhs[] =
422
0, 0, 3, 5, 11, 15, 19, 23, 27, 31,
426
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
427
static const yysigned_char yyrhs[] =
429
17, 0, -1, 18, -1, 18, 3, 18, 12, 18,
430
-1, 18, 4, 18, -1, 18, 5, 18, -1, 18,
431
6, 18, -1, 18, 7, 18, -1, 18, 8, 18,
432
-1, 18, 9, 18, -1, 10, 18, -1, 13, -1,
433
11, -1, 14, 18, 15, -1
436
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
437
static const unsigned char yyrline[] =
439
0, 182, 182, 190, 194, 198, 202, 206, 210, 214,
444
#if YYDEBUG || YYERROR_VERBOSE
445
/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
446
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
447
static const char *const yytname[] =
449
"$end", "error", "$undefined", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
450
"ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
451
"$accept", "start", "exp", 0
456
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
458
static const unsigned short yytoknum[] =
460
0, 256, 257, 63, 124, 38, 258, 259, 260, 261,
461
33, 262, 58, 110, 40, 41
465
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
466
static const unsigned char yyr1[] =
468
0, 16, 17, 18, 18, 18, 18, 18, 18, 18,
472
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
473
static const unsigned char yyr2[] =
475
0, 2, 1, 5, 3, 3, 3, 3, 3, 3,
479
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
480
STATE-NUM when YYTABLE doesn't specify something else to do. Zero
481
means the default is an error. */
482
static const unsigned char yydefact[] =
484
0, 0, 12, 11, 0, 0, 2, 10, 0, 1,
485
0, 0, 0, 0, 0, 0, 0, 13, 0, 4,
489
/* YYDEFGOTO[NTERM-NUM]. */
490
static const yysigned_char yydefgoto[] =
495
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
497
#define YYPACT_NINF -10
498
static const yysigned_char yypact[] =
500
-9, -9, -10, -10, -9, 8, 36, -10, 13, -10,
501
-9, -9, -9, -9, -9, -9, -9, -10, 26, 41,
502
45, 18, -2, 14, -10, -9, 36
505
/* YYPGOTO[NTERM-NUM]. */
506
static const yysigned_char yypgoto[] =
511
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
512
positive, shift that token. If negative, reduce the rule which
513
number is the opposite. If zero, do what YYDEFACT says.
514
If YYTABLE_NINF, syntax error. */
515
#define YYTABLE_NINF -1
516
static const unsigned char yytable[] =
518
7, 1, 2, 8, 3, 4, 15, 16, 9, 18,
519
19, 20, 21, 22, 23, 24, 10, 11, 12, 13,
520
14, 15, 16, 16, 26, 14, 15, 16, 17, 10,
521
11, 12, 13, 14, 15, 16, 0, 0, 25, 10,
522
11, 12, 13, 14, 15, 16, 12, 13, 14, 15,
526
static const yysigned_char yycheck[] =
528
1, 10, 11, 4, 13, 14, 8, 9, 0, 10,
529
11, 12, 13, 14, 15, 16, 3, 4, 5, 6,
530
7, 8, 9, 9, 25, 7, 8, 9, 15, 3,
531
4, 5, 6, 7, 8, 9, -1, -1, 12, 3,
532
4, 5, 6, 7, 8, 9, 5, 6, 7, 8,
536
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
537
symbol of state STATE-NUM. */
538
static const unsigned char yystos[] =
540
0, 10, 11, 13, 14, 17, 18, 18, 18, 0,
541
3, 4, 5, 6, 7, 8, 9, 15, 18, 18,
542
18, 18, 18, 18, 18, 12, 18
545
#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
546
# define YYSIZE_T __SIZE_TYPE__
548
#if ! defined (YYSIZE_T) && defined (size_t)
549
# define YYSIZE_T size_t
551
#if ! defined (YYSIZE_T)
552
# if defined (__STDC__) || defined (__cplusplus)
553
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
554
# define YYSIZE_T size_t
557
#if ! defined (YYSIZE_T)
558
# define YYSIZE_T unsigned int
561
#define yyerrok (yyerrstatus = 0)
562
#define yyclearin (yychar = YYEMPTY)
566
#define YYACCEPT goto yyacceptlab
567
#define YYABORT goto yyabortlab
568
#define YYERROR goto yyerrlab1
571
/* Like YYERROR except do call yyerror. This remains here temporarily
572
to ease the transition to the new meaning of YYERROR, for GCC.
573
Once GCC version 2 has supplanted version 1, this can go. */
575
#define YYFAIL goto yyerrlab
577
#define YYRECOVERING() (!!yyerrstatus)
579
#define YYBACKUP(Token, Value) \
581
if (yychar == YYEMPTY && yylen == 1) \
585
yytoken = YYTRANSLATE (yychar); \
591
yyerror ("syntax error: cannot back up");\
597
#define YYERRCODE 256
599
/* YYLLOC_DEFAULT -- Compute the default location (before the actions
602
#ifndef YYLLOC_DEFAULT
603
# define YYLLOC_DEFAULT(Current, Rhs, N) \
604
Current.first_line = Rhs[1].first_line; \
605
Current.first_column = Rhs[1].first_column; \
606
Current.last_line = Rhs[N].last_line; \
607
Current.last_column = Rhs[N].last_column;
610
/* YYLEX -- calling `yylex' with the right arguments. */
613
# define YYLEX yylex (&yylval, YYLEX_PARAM)
615
# define YYLEX yylex (&yylval)
618
/* Enable debugging if requested. */
622
# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
623
# define YYFPRINTF fprintf
626
# define YYDPRINTF(Args) \
632
# define YYDSYMPRINT(Args) \
638
# define YYDSYMPRINTF(Title, Token, Value, Location) \
642
YYFPRINTF (stderr, "%s ", Title); \
643
yysymprint (stderr, \
645
YYFPRINTF (stderr, "\n"); \
649
/*------------------------------------------------------------------.
650
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
652
`------------------------------------------------------------------*/
654
#if defined (__STDC__) || defined (__cplusplus)
656
yy_stack_print (short *bottom, short *top)
659
yy_stack_print (bottom, top)
664
YYFPRINTF (stderr, "Stack now");
665
for (/* Nothing. */; bottom <= top; ++bottom)
666
YYFPRINTF (stderr, " %d", *bottom);
667
YYFPRINTF (stderr, "\n");
670
# define YY_STACK_PRINT(Bottom, Top) \
673
yy_stack_print ((Bottom), (Top)); \
677
/*------------------------------------------------.
678
| Report that the YYRULE is going to be reduced. |
679
`------------------------------------------------*/
681
#if defined (__STDC__) || defined (__cplusplus)
683
yy_reduce_print (int yyrule)
686
yy_reduce_print (yyrule)
691
unsigned int yylineno = yyrline[yyrule];
692
YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
693
yyrule - 1, yylineno);
694
/* Print the symbols being reduced, and their result. */
695
for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
696
YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
697
YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
700
# define YY_REDUCE_PRINT(Rule) \
703
yy_reduce_print (Rule); \
706
/* Nonzero means print parse trace. It is left uninitialized so that
707
multiple parsers can coexist. */
710
# define YYDPRINTF(Args)
711
# define YYDSYMPRINT(Args)
712
# define YYDSYMPRINTF(Title, Token, Value, Location)
713
# define YY_STACK_PRINT(Bottom, Top)
714
# define YY_REDUCE_PRINT(Rule)
715
#endif /* !YYDEBUG */
718
/* YYINITDEPTH -- initial size of the parser's stacks. */
720
# define YYINITDEPTH 200
723
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
724
if the built-in stack extension method is used).
726
Do not make this value too large; the results are undefined if
727
SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
728
evaluated with infinite-precision integer arithmetic. */
735
# define YYMAXDEPTH 10000
743
# if defined (__GLIBC__) && defined (_STRING_H)
744
# define yystrlen strlen
746
/* Return the length of YYSTR. */
748
# if defined (__STDC__) || defined (__cplusplus)
749
yystrlen (const char *yystr)
755
register const char *yys = yystr;
757
while (*yys++ != '\0')
760
return yys - yystr - 1;
766
# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
767
# define yystpcpy stpcpy
769
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
772
# if defined (__STDC__) || defined (__cplusplus)
773
yystpcpy (char *yydest, const char *yysrc)
775
yystpcpy (yydest, yysrc)
780
register char *yyd = yydest;
781
register const char *yys = yysrc;
783
while ((*yyd++ = *yys++) != '\0')
791
#endif /* !YYERROR_VERBOSE */
796
/*--------------------------------.
797
| Print this symbol on YYOUTPUT. |
798
`--------------------------------*/
800
#if defined (__STDC__) || defined (__cplusplus)
802
yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
805
yysymprint (yyoutput, yytype, yyvaluep)
811
/* Pacify ``unused variable'' warnings. */
814
if (yytype < YYNTOKENS)
816
YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
818
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
822
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
829
YYFPRINTF (yyoutput, ")");
832
#endif /* ! YYDEBUG */
833
/*-----------------------------------------------.
834
| Release the memory associated to this symbol. |
835
`-----------------------------------------------*/
837
#if defined (__STDC__) || defined (__cplusplus)
839
yydestruct (int yytype, YYSTYPE *yyvaluep)
842
yydestruct (yytype, yyvaluep)
847
/* Pacify ``unused variable'' warnings. */
859
/* Prevent warnings from -Wmissing-prototypes. */
862
# if defined (__STDC__) || defined (__cplusplus)
863
int yyparse (void *YYPARSE_PARAM);
867
#else /* ! YYPARSE_PARAM */
868
#if defined (__STDC__) || defined (__cplusplus)
873
#endif /* ! YYPARSE_PARAM */
885
# if defined (__STDC__) || defined (__cplusplus)
886
int yyparse (void *YYPARSE_PARAM)
888
int yyparse (YYPARSE_PARAM)
891
#else /* ! YYPARSE_PARAM */
892
#if defined (__STDC__) || defined (__cplusplus)
902
/* The lookahead symbol. */
905
/* The semantic value of the lookahead symbol. */
908
/* Number of syntax errors so far. */
911
register int yystate;
914
/* Number of tokens to shift before error messages enabled. */
916
/* Lookahead token as an internal (translated) token number. */
919
/* Three stacks and their tools:
920
`yyss': related to states,
921
`yyvs': related to semantic values,
922
`yyls': related to locations.
924
Refer to the stacks thru separate pointers, to allow yyoverflow
925
to reallocate them elsewhere. */
927
/* The state stack. */
928
short yyssa[YYINITDEPTH];
930
register short *yyssp;
932
/* The semantic value stack. */
933
YYSTYPE yyvsa[YYINITDEPTH];
934
YYSTYPE *yyvs = yyvsa;
935
register YYSTYPE *yyvsp;
939
#define YYPOPSTACK (yyvsp--, yyssp--)
941
YYSIZE_T yystacksize = YYINITDEPTH;
943
/* The variables used to return semantic value and location from the
948
/* When reducing, the number of symbols on the RHS of the reduced
952
YYDPRINTF ((stderr, "Starting parse\n"));
957
yychar = YYEMPTY; /* Cause a token to be read. */
959
/* Initialize stack pointers.
960
Waste one element of value and location stack
961
so that they stay on the same level as the state stack.
962
The wasted elements are never initialized. */
969
/*------------------------------------------------------------.
970
| yynewstate -- Push a new state, which is found in yystate. |
971
`------------------------------------------------------------*/
973
/* In all cases, when you get here, the value and location stacks
974
have just been pushed. so pushing a state here evens the stacks.
981
if (yyss + yystacksize - 1 <= yyssp)
983
/* Get the current used size of the three stacks, in elements. */
984
YYSIZE_T yysize = yyssp - yyss + 1;
988
/* Give user a chance to reallocate the stack. Use copies of
989
these so that the &'s don't force the real ones into
991
YYSTYPE *yyvs1 = yyvs;
995
/* Each stack pointer address is followed by the size of the
996
data in use in that stack, in bytes. This used to be a
997
conditional around just the two extra args, but that might
998
be undefined if yyoverflow is a macro. */
999
yyoverflow ("parser stack overflow",
1000
&yyss1, yysize * sizeof (*yyssp),
1001
&yyvs1, yysize * sizeof (*yyvsp),
1008
#else /* no yyoverflow */
1009
# ifndef YYSTACK_RELOCATE
1012
/* Extend the stack our own way. */
1013
if (YYMAXDEPTH <= yystacksize)
1016
if (YYMAXDEPTH < yystacksize)
1017
yystacksize = YYMAXDEPTH;
1020
short *yyss1 = yyss;
1021
union yyalloc *yyptr =
1022
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1025
YYSTACK_RELOCATE (yyss);
1026
YYSTACK_RELOCATE (yyvs);
1028
# undef YYSTACK_RELOCATE
1030
YYSTACK_FREE (yyss1);
1033
#endif /* no yyoverflow */
1035
yyssp = yyss + yysize - 1;
1036
yyvsp = yyvs + yysize - 1;
1039
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1040
(unsigned long int) yystacksize));
1042
if (yyss + yystacksize - 1 <= yyssp)
1046
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1055
/* Do appropriate processing given the current state. */
1056
/* Read a lookahead token if we need one and don't already have one. */
1059
/* First try to decide what to do without reference to lookahead token. */
1061
yyn = yypact[yystate];
1062
if (yyn == YYPACT_NINF)
1065
/* Not known => get a lookahead token if don't already have one. */
1067
/* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1068
if (yychar == YYEMPTY)
1070
YYDPRINTF ((stderr, "Reading a token: "));
1074
if (yychar <= YYEOF)
1076
yychar = yytoken = YYEOF;
1077
YYDPRINTF ((stderr, "Now at end of input.\n"));
1081
yytoken = YYTRANSLATE (yychar);
1082
YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
1085
/* If the proper action on seeing token YYTOKEN is to reduce or to
1086
detect an error, take that action. */
1088
if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1093
if (yyn == 0 || yyn == YYTABLE_NINF)
1102
/* Shift the lookahead token. */
1103
YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
1105
/* Discard the token being shifted unless it is eof. */
1106
if (yychar != YYEOF)
1112
/* Count tokens shifted since error; after three, turn off error
1121
/*-----------------------------------------------------------.
1122
| yydefault -- do the default action for the current state. |
1123
`-----------------------------------------------------------*/
1125
yyn = yydefact[yystate];
1131
/*-----------------------------.
1132
| yyreduce -- Do a reduction. |
1133
`-----------------------------*/
1135
/* yyn is the number of a rule to reduce with. */
1138
/* If YYLEN is nonzero, implement the default value of the action:
1141
Otherwise, the following line sets YYVAL to garbage.
1142
This behavior is undocumented and Bison
1143
users should not rely upon it. Assigning to YYVAL
1144
unconditionally makes the parser a bit smaller, and it avoids a
1145
GCC warning that YYVAL may be used uninitialized. */
1146
yyval = yyvsp[1-yylen];
1149
YY_REDUCE_PRINT (yyn);
1153
#line 183 "../../findutils/intl/plural.y"
1155
if (yyvsp[0].exp == NULL)
1157
((struct parse_args *) arg)->res = yyvsp[0].exp;
1162
#line 191 "../../findutils/intl/plural.y"
1164
yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp);
1169
#line 195 "../../findutils/intl/plural.y"
1171
yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp);
1176
#line 199 "../../findutils/intl/plural.y"
1178
yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp);
1183
#line 203 "../../findutils/intl/plural.y"
1185
yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1190
#line 207 "../../findutils/intl/plural.y"
1192
yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1197
#line 211 "../../findutils/intl/plural.y"
1199
yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1204
#line 215 "../../findutils/intl/plural.y"
1206
yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
1211
#line 219 "../../findutils/intl/plural.y"
1213
yyval.exp = new_exp_1 (lnot, yyvsp[0].exp);
1218
#line 223 "../../findutils/intl/plural.y"
1220
yyval.exp = new_exp_0 (var);
1225
#line 227 "../../findutils/intl/plural.y"
1227
if ((yyval.exp = new_exp_0 (num)) != NULL)
1228
yyval.exp->val.num = yyvsp[0].num;
1233
#line 232 "../../findutils/intl/plural.y"
1235
yyval.exp = yyvsp[-1].exp;
1242
/* Line 999 of yacc.c. */
1243
#line 1244 "plural.c"
1249
YY_STACK_PRINT (yyss, yyssp);
1254
/* Now `shift' the result of the reduction. Determine what state
1255
that goes to, based on the state we popped back to and the rule
1256
number reduced by. */
1260
yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1261
if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1262
yystate = yytable[yystate];
1264
yystate = yydefgoto[yyn - YYNTOKENS];
1269
/*------------------------------------.
1270
| yyerrlab -- here on detecting error |
1271
`------------------------------------*/
1273
/* If not already recovering from an error, report this error. */
1278
yyn = yypact[yystate];
1280
if (YYPACT_NINF < yyn && yyn < YYLAST)
1282
YYSIZE_T yysize = 0;
1283
int yytype = YYTRANSLATE (yychar);
1288
/* Start YYX at -YYN if negative to avoid negative indexes in
1290
for (yyx = yyn < 0 ? -yyn : 0;
1291
yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1292
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1293
yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1294
yysize += yystrlen ("syntax error, unexpected ") + 1;
1295
yysize += yystrlen (yytname[yytype]);
1296
yymsg = (char *) YYSTACK_ALLOC (yysize);
1299
char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
1300
yyp = yystpcpy (yyp, yytname[yytype]);
1305
for (yyx = yyn < 0 ? -yyn : 0;
1306
yyx < (int) (sizeof (yytname) / sizeof (char *));
1308
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1310
const char *yyq = ! yycount ? ", expecting " : " or ";
1311
yyp = yystpcpy (yyp, yyq);
1312
yyp = yystpcpy (yyp, yytname[yyx]);
1317
YYSTACK_FREE (yymsg);
1320
yyerror ("syntax error; also virtual memory exhausted");
1323
#endif /* YYERROR_VERBOSE */
1324
yyerror ("syntax error");
1329
if (yyerrstatus == 3)
1331
/* If just tried and failed to reuse lookahead token after an
1332
error, discard it. */
1334
/* Return failure if at end of input. */
1335
if (yychar == YYEOF)
1337
/* Pop the error token. */
1339
/* Pop the rest of the stack. */
1340
while (yyss < yyssp)
1342
YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1343
yydestruct (yystos[*yyssp], yyvsp);
1349
YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
1350
yydestruct (yytoken, &yylval);
1355
/* Else will try to reuse lookahead token after shifting the error
1360
/*----------------------------------------------------.
1361
| yyerrlab1 -- error raised explicitly by an action. |
1362
`----------------------------------------------------*/
1364
yyerrstatus = 3; /* Each real token shifted decrements this. */
1368
yyn = yypact[yystate];
1369
if (yyn != YYPACT_NINF)
1372
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1380
/* Pop the current state because it cannot handle the error token. */
1384
YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1385
yydestruct (yystos[yystate], yyvsp);
1389
YY_STACK_PRINT (yyss, yyssp);
1395
YYDPRINTF ((stderr, "Shifting error token, "));
1404
/*-------------------------------------.
1405
| yyacceptlab -- YYACCEPT comes here. |
1406
`-------------------------------------*/
1411
/*-----------------------------------.
1412
| yyabortlab -- YYABORT comes here. |
1413
`-----------------------------------*/
1419
/*----------------------------------------------.
1420
| yyoverflowlab -- parser overflow comes here. |
1421
`----------------------------------------------*/
1423
yyerror ("parser stack overflow");
1431
YYSTACK_FREE (yyss);
1437
#line 237 "../../findutils/intl/plural.y"
1442
FREE_EXPRESSION (exp)
1443
struct expression *exp;
1448
/* Handle the recursive case. */
1452
FREE_EXPRESSION (exp->val.args[2]);
1455
FREE_EXPRESSION (exp->val.args[1]);
1458
FREE_EXPRESSION (exp->val.args[0]);
1473
const char *exp = *pexp;
1484
if (exp[0] != ' ' && exp[0] != '\t')
1493
case '0': case '1': case '2': case '3': case '4':
1494
case '5': case '6': case '7': case '8': case '9':
1496
unsigned long int n = result - '0';
1497
while (exp[0] >= '0' && exp[0] <= '9')
1523
lval->op = not_equal;
1530
if (exp[0] == result)
1540
lval->op = less_or_equal;
1543
lval->op = less_than;
1551
lval->op = greater_or_equal;
1554
lval->op = greater_than;
1588
/* Nothing, just return the character. */
1594
/* Be safe and let the user call this function again. */
1617
/* Do nothing. We don't print error messages here. */