1 /* A Bison parser, made from plural.y
4 #define YYBISON 1 /* Identify Bison output. */
6 #define yyparse __gettextparse
7 #define yylex __gettextlex
8 #define yyerror __gettexterror
9 #define yylval __gettextlval
10 #define yychar __gettextchar
11 #define yydebug __gettextdebug
12 #define yynerrs __gettextnerrs
21 /* Expression parsing for plural form selection.
22 Copyright (C) 2000-2001, 2003, 2005 Free Software Foundation, Inc.
23 Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
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)
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
40 /* For bison < 2.0, the bison generated parser uses alloca. AIX 3 forces us
41 to put this declaration at the beginning of the file. The declaration in
42 bison's skeleton file comes too late. This must come before <config.h>
43 because <config.h> may include arbitrary system headers.
44 This can go away once the AM_INTL_SUBDIR macro requires bison >= 2.0. */
45 #if defined _AIX && !defined __GNUC__
56 #include "plural-exp.h"
58 /* The main function generated by the parser is called __gettextparse,
59 but we want it to be called PLURAL_PARSE. */
61 # define __gettextparse PLURAL_PARSE
64 #define YYLEX_PARAM &((struct parse_args *) arg)->cp
65 #define YYPARSE_PARAM arg
70 unsigned long int num
;
72 struct expression
*exp
;
74 # define YYSTYPE yystype
75 # define YYSTYPE_IS_TRIVIAL 1
79 /* Prototypes for local functions. */
80 static int yylex (YYSTYPE
*lval
, const char **pexp
);
81 static void yyerror (const char *str
);
83 /* Allocation of expressions. */
85 static struct expression
*
86 new_exp (int nargs
, enum operator op
, struct expression
* const *args
)
89 struct expression
*newp
;
91 /* If any of the argument could not be malloc'ed, just return NULL. */
92 for (i
= nargs
- 1; i
>= 0; i
--)
96 /* Allocate a new expression. */
97 newp
= (struct expression
*) malloc (sizeof (*newp
));
101 newp
->operation
= op
;
102 for (i
= nargs
- 1; i
>= 0; i
--)
103 newp
->val
.args
[i
] = args
[i
];
108 for (i
= nargs
- 1; i
>= 0; i
--)
109 FREE_EXPRESSION (args
[i
]);
114 static inline struct expression
*
115 new_exp_0 (enum operator op
)
117 return new_exp (0, op
, NULL
);
120 static inline struct expression
*
121 new_exp_1 (enum operator op
, struct expression
*right
)
123 struct expression
*args
[1];
126 return new_exp (1, op
, args
);
129 static struct expression
*
130 new_exp_2 (enum operator op
, struct expression
*left
, struct expression
*right
)
132 struct expression
*args
[2];
136 return new_exp (2, op
, args
);
139 static inline struct expression
*
140 new_exp_3 (enum operator op
, struct expression
*bexp
,
141 struct expression
*tbranch
, struct expression
*fbranch
)
143 struct expression
*args
[3];
148 return new_exp (3, op
, args
);
158 #define YYFLAG -32768
161 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
162 #define YYTRANSLATE(x) ((unsigned)(x) <= 261 ? yytranslate[x] : 18)
164 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
165 static const char yytranslate
[] =
167 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
168 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
169 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
170 2, 2, 2, 10, 2, 2, 2, 2, 5, 2,
171 14, 15, 2, 2, 2, 2, 2, 2, 2, 2,
172 2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
173 2, 2, 2, 3, 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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
177 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
178 13, 2, 2, 2, 2, 2, 2, 2, 2, 2,
179 2, 2, 2, 2, 4, 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, 2, 2, 2, 2,
191 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
192 2, 2, 2, 2, 2, 2, 1, 6, 7, 8,
197 static const short yyprhs
[] =
199 0, 0, 2, 8, 12, 16, 20, 24, 28, 32,
202 static const short yyrhs
[] =
204 17, 0, 17, 3, 17, 12, 17, 0, 17, 4,
205 17, 0, 17, 5, 17, 0, 17, 6, 17, 0,
206 17, 7, 17, 0, 17, 8, 17, 0, 17, 9,
207 17, 0, 10, 17, 0, 13, 0, 11, 0, 14,
214 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
215 static const short yyrline
[] =
217 0, 152, 160, 164, 168, 172, 176, 180, 184, 188,
223 #if (YYDEBUG) || defined YYERROR_VERBOSE
225 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
226 static const char *const yytname
[] =
228 "$", "error", "$undefined.", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
229 "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
234 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
235 static const short yyr1
[] =
237 0, 16, 17, 17, 17, 17, 17, 17, 17, 17,
241 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
242 static const short yyr2
[] =
244 0, 1, 5, 3, 3, 3, 3, 3, 3, 2,
248 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
249 doesn't specify something else to do. Zero means the default is an
251 static const short yydefact
[] =
253 0, 0, 11, 10, 0, 1, 9, 0, 0, 0,
254 0, 0, 0, 0, 0, 12, 0, 3, 4, 5,
255 6, 7, 8, 0, 2, 0, 0, 0
258 static const short yydefgoto
[] =
263 static const short yypact
[] =
265 -9, -9,-32768,-32768, -9, 34,-32768, 11, -9, -9,
266 -9, -9, -9, -9, -9,-32768, 24, 39, 43, 16,
267 26, -3,-32768, -9, 34, 21, 53,-32768
270 static const short yypgoto
[] =
279 static const short yytable
[] =
281 6, 1, 2, 7, 3, 4, 14, 16, 17, 18,
282 19, 20, 21, 22, 8, 9, 10, 11, 12, 13,
283 14, 26, 24, 12, 13, 14, 15, 8, 9, 10,
284 11, 12, 13, 14, 13, 14, 23, 8, 9, 10,
285 11, 12, 13, 14, 10, 11, 12, 13, 14, 11,
289 static const short yycheck
[] =
291 1, 10, 11, 4, 13, 14, 9, 8, 9, 10,
292 11, 12, 13, 14, 3, 4, 5, 6, 7, 8,
293 9, 0, 23, 7, 8, 9, 15, 3, 4, 5,
294 6, 7, 8, 9, 8, 9, 12, 3, 4, 5,
295 6, 7, 8, 9, 5, 6, 7, 8, 9, 6,
300 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
301 #line 3 "bison.simple"
303 /* Skeleton output parser for bison,
305 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
308 This program is free software; you can redistribute it and/or modify
309 it under the terms of the GNU General Public License as published by
310 the Free Software Foundation; either version 2, or (at your option)
313 This program is distributed in the hope that it will be useful,
314 but WITHOUT ANY WARRANTY; without even the implied warranty of
315 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
316 GNU General Public License for more details.
318 You should have received a copy of the GNU General Public License
319 along with this program; if not, write to the Free Software
320 Foundation, Inc., 59 Temple Place - Suite 330,
321 Boston, MA 02111-1307, USA. */
323 /* As a special exception, when this file is copied by Bison into a
324 Bison output file, you may use that output file without restriction.
325 This special exception was added by the Free Software Foundation
326 in version 1.24 of Bison. */
328 /* This is the parser code that is written into each bison parser when
329 the %semantic_parser declaration is not specified in the grammar.
330 It was written by Richard Stallman by simplifying the hairy parser
331 used when %semantic_parser is specified. */
333 /* All symbols defined below should begin with yy or YY, to avoid
334 infringing on user name space. This should be done even for local
335 variables, as they might otherwise be expanded by user macros.
336 There are some unavoidable exceptions within include files to
337 define necessary library symbols; they are noted "INFRINGES ON
338 USER NAME SPACE" below. */
340 #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
342 /* The parser invokes alloca or malloc; define the necessary symbols. */
344 # if YYSTACK_USE_ALLOCA
345 # define YYSTACK_ALLOC alloca
347 # ifndef YYSTACK_USE_ALLOCA
348 # if defined (alloca) || defined (_ALLOCA_H)
349 # define YYSTACK_ALLOC alloca
352 # define YYSTACK_ALLOC __builtin_alloca
358 # ifdef YYSTACK_ALLOC
359 /* Pacify GCC's `empty if-body' warning. */
360 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
362 # if defined (__STDC__) || defined (__cplusplus)
363 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
364 # define YYSIZE_T size_t
366 # define YYSTACK_ALLOC malloc
367 # define YYSTACK_FREE free
369 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
372 #if (! defined (yyoverflow) \
373 && (! defined (__cplusplus) \
374 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
376 /* A type that is properly aligned for any stack member. */
386 /* The size of the maximum gap between one aligned stack and the next. */
387 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
389 /* The size of an array large to enough to hold all stacks, each with
392 # define YYSTACK_BYTES(N) \
393 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
394 + 2 * YYSTACK_GAP_MAX)
396 # define YYSTACK_BYTES(N) \
397 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
401 /* Copy COUNT objects from FROM to TO. The source and destination do
405 # define YYCOPY(To, From, Count) \
406 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
408 # define YYCOPY(To, From, Count) \
411 register YYSIZE_T yyi; \
412 for (yyi = 0; yyi < (Count); yyi++) \
413 (To)[yyi] = (From)[yyi]; \
419 /* Relocate STACK from its old location to the new one. The
420 local variables YYSIZE and YYSTACKSIZE give the old and new number of
421 elements in the stack, and YYPTR gives the new location of the
422 stack. Advance YYPTR to a properly aligned location for the next
424 # define YYSTACK_RELOCATE(Stack) \
427 YYSIZE_T yynewbytes; \
428 YYCOPY (&yyptr->Stack, Stack, yysize); \
429 Stack = &yyptr->Stack; \
430 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
431 yyptr += yynewbytes / sizeof (*yyptr); \
438 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
439 # define YYSIZE_T __SIZE_TYPE__
441 #if ! defined (YYSIZE_T) && defined (size_t)
442 # define YYSIZE_T size_t
444 #if ! defined (YYSIZE_T)
445 # if defined (__STDC__) || defined (__cplusplus)
446 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
447 # define YYSIZE_T size_t
450 #if ! defined (YYSIZE_T)
451 # define YYSIZE_T unsigned int
454 #define yyerrok (yyerrstatus = 0)
455 #define yyclearin (yychar = YYEMPTY)
458 #define YYACCEPT goto yyacceptlab
459 #define YYABORT goto yyabortlab
460 #define YYERROR goto yyerrlab1
461 /* Like YYERROR except do call yyerror. This remains here temporarily
462 to ease the transition to the new meaning of YYERROR, for GCC.
463 Once GCC version 2 has supplanted version 1, this can go. */
464 #define YYFAIL goto yyerrlab
465 #define YYRECOVERING() (!!yyerrstatus)
466 #define YYBACKUP(Token, Value) \
468 if (yychar == YYEMPTY && yylen == 1) \
472 yychar1 = YYTRANSLATE (yychar); \
478 yyerror ("syntax error: cannot back up"); \
484 #define YYERRCODE 256
487 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
490 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
491 first token. By default, to implement support for ranges, extend
492 its range to the last symbol. */
494 #ifndef YYLLOC_DEFAULT
495 # define YYLLOC_DEFAULT(Current, Rhs, N) \
496 Current.last_line = Rhs[N].last_line; \
497 Current.last_column = Rhs[N].last_column;
501 /* YYLEX -- calling `yylex' with the right arguments. */
506 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
508 # define YYLEX yylex (&yylval, &yylloc)
510 # else /* !YYLSP_NEEDED */
512 # define YYLEX yylex (&yylval, YYLEX_PARAM)
514 # define YYLEX yylex (&yylval)
516 # endif /* !YYLSP_NEEDED */
518 # define YYLEX yylex ()
522 /* Enable debugging if requested. */
526 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
527 # define YYFPRINTF fprintf
530 # define YYDPRINTF(Args) \
535 /* Nonzero means print parse trace. It is left uninitialized so that
536 multiple parsers can coexist. */
539 # define YYDPRINTF(Args)
540 #endif /* !YYDEBUG */
542 /* YYINITDEPTH -- initial size of the parser's stacks. */
544 # define YYINITDEPTH 200
547 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
548 if the built-in stack extension method is used).
550 Do not make this value too large; the results are undefined if
551 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
552 evaluated with infinite-precision integer arithmetic. */
559 # define YYMAXDEPTH 10000
562 #ifdef YYERROR_VERBOSE
565 # if defined (__GLIBC__) && defined (_STRING_H)
566 # define yystrlen strlen
568 /* Return the length of YYSTR. */
570 # if defined (__STDC__) || defined (__cplusplus)
571 yystrlen (const char *yystr
)
577 register const char *yys
= yystr
;
579 while (*yys
++ != '\0')
582 return yys
- yystr
- 1;
588 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
589 # define yystpcpy stpcpy
591 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
594 # if defined (__STDC__) || defined (__cplusplus)
595 yystpcpy (char *yydest
, const char *yysrc
)
597 yystpcpy (yydest
, yysrc
)
602 register char *yyd
= yydest
;
603 register const char *yys
= yysrc
;
605 while ((*yyd
++ = *yys
++) != '\0')
614 #line 315 "bison.simple"
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. */
624 # if defined (__STDC__) || defined (__cplusplus)
625 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
626 # define YYPARSE_PARAM_DECL
628 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
629 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
631 #else /* !YYPARSE_PARAM */
632 # define YYPARSE_PARAM_ARG
633 # define YYPARSE_PARAM_DECL
634 #endif /* !YYPARSE_PARAM */
636 /* Prevent warning if -Wstrict-prototypes. */
638 # ifdef YYPARSE_PARAM
639 int yyparse (void *);
645 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
646 variables are global, or local to YYPARSE. */
648 #define YY_DECL_NON_LSP_VARIABLES \
649 /* The lookahead symbol. */ \
652 /* The semantic value of the lookahead symbol. */ \
655 /* Number of parse errors so far. */ \
659 # define YY_DECL_VARIABLES \
660 YY_DECL_NON_LSP_VARIABLES \
662 /* Location data for the lookahead symbol. */ \
665 # define YY_DECL_VARIABLES \
666 YY_DECL_NON_LSP_VARIABLES
670 /* If nonreentrant, generate the variables here. */
677 yyparse (YYPARSE_PARAM_ARG
)
680 /* If reentrant, generate the variables here. */
685 register int yystate
;
688 /* Number of tokens to shift before error messages enabled. */
690 /* Lookahead token as an internal (translated) token number. */
693 /* Three stacks and their tools:
694 `yyss': related to states,
695 `yyvs': related to semantic values,
696 `yyls': related to locations.
698 Refer to the stacks thru separate pointers, to allow yyoverflow
699 to reallocate them elsewhere. */
701 /* The state stack. */
702 short yyssa
[YYINITDEPTH
];
704 register short *yyssp
;
706 /* The semantic value stack. */
707 YYSTYPE yyvsa
[YYINITDEPTH
];
708 YYSTYPE
*yyvs
= yyvsa
;
709 register YYSTYPE
*yyvsp
;
712 /* The location stack. */
713 YYLTYPE yylsa
[YYINITDEPTH
];
714 YYLTYPE
*yyls
= yylsa
;
719 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
721 # define YYPOPSTACK (yyvsp--, yyssp--)
724 YYSIZE_T yystacksize
= YYINITDEPTH
;
727 /* The variables used to return semantic value and location from the
734 /* When reducing, the number of symbols on the RHS of the reduced
738 YYDPRINTF ((stderr
, "Starting parse\n"));
743 yychar
= YYEMPTY
; /* Cause a token to be read. */
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. */
757 /*------------------------------------------------------------.
758 | yynewstate -- Push a new state, which is found in yystate. |
759 `------------------------------------------------------------*/
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.
769 if (yyssp
>= yyss
+ yystacksize
- 1)
771 /* Get the current used size of the three stacks, in elements. */
772 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
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
779 YYSTYPE
*yyvs1
= yyvs
;
782 /* Each stack pointer address is followed by the size of the
783 data in use in that stack, in bytes. */
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
),
795 yyoverflow ("parser stack overflow",
796 &yyss1
, yysize
* sizeof (*yyssp
),
797 &yyvs1
, yysize
* sizeof (*yyvsp
),
803 #else /* no yyoverflow */
804 # ifndef YYSTACK_RELOCATE
807 /* Extend the stack our own way. */
808 if (yystacksize
>= YYMAXDEPTH
)
811 if (yystacksize
> YYMAXDEPTH
)
812 yystacksize
= YYMAXDEPTH
;
816 union yyalloc
*yyptr
=
817 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
820 YYSTACK_RELOCATE (yyss
);
821 YYSTACK_RELOCATE (yyvs
);
823 YYSTACK_RELOCATE (yyls
);
825 # undef YYSTACK_RELOCATE
827 YYSTACK_FREE (yyss1
);
830 #endif /* no yyoverflow */
832 yyssp
= yyss
+ yysize
- 1;
833 yyvsp
= yyvs
+ yysize
- 1;
835 yylsp
= yyls
+ yysize
- 1;
838 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
839 (unsigned long int) yystacksize
));
841 if (yyssp
>= yyss
+ yystacksize
- 1)
845 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
855 /* Do appropriate processing given the current state. */
856 /* Read a lookahead token if we need one and don't already have one. */
859 /* First try to decide what to do without reference to lookahead token. */
861 yyn
= yypact
[yystate
];
865 /* Not known => get a lookahead token if don't already have one. */
867 /* yychar is either YYEMPTY or YYEOF
868 or a valid token in external form. */
870 if (yychar
== YYEMPTY
)
872 YYDPRINTF ((stderr
, "Reading a token: "));
876 /* Convert token to internal form (in yychar1) for indexing tables with */
878 if (yychar
<= 0) /* This means end of input. */
881 yychar
= YYEOF
; /* Don't call YYLEX any more */
883 YYDPRINTF ((stderr
, "Now at end of input.\n"));
887 yychar1
= YYTRANSLATE (yychar
);
890 /* We have to keep this `#if YYDEBUG', since we use variables
891 which are defined only if `YYDEBUG' is set. */
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. */
899 YYPRINT (stderr
, yychar
, yylval
);
901 YYFPRINTF (stderr
, ")\n");
907 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != yychar1
)
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,
917 0, or most negative number => error. */
932 /* Shift the lookahead token. */
933 YYDPRINTF ((stderr
, "Shifting token %d (%s), ",
934 yychar
, yytname
[yychar1
]));
936 /* Discard the token being shifted unless it is eof. */
945 /* Count tokens shifted since error; after three, turn off error
954 /*-----------------------------------------------------------.
955 | yydefault -- do the default action for the current state. |
956 `-----------------------------------------------------------*/
958 yyn
= yydefact
[yystate
];
964 /*-----------------------------.
965 | yyreduce -- Do a reduction. |
966 `-----------------------------*/
968 /* yyn is the number of a rule to reduce with. */
971 /* If YYLEN is nonzero, implement the default value of the action:
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
];
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
);
989 /* We have to keep this `#if YYDEBUG', since we use variables which
990 are defined only if `YYDEBUG' is set. */
995 YYFPRINTF (stderr
, "Reducing via rule %d (line %d), ",
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
]]);
1008 #line 153 "plural.y"
1010 if (yyvsp
[0].exp
== NULL
)
1012 ((struct parse_args
*) arg
)->res
= yyvsp
[0].exp
;
1016 #line 161 "plural.y"
1018 yyval
.exp
= new_exp_3 (qmop
, yyvsp
[-4].exp
, yyvsp
[-2].exp
, yyvsp
[0].exp
);
1022 #line 165 "plural.y"
1024 yyval
.exp
= new_exp_2 (lor
, yyvsp
[-2].exp
, yyvsp
[0].exp
);
1028 #line 169 "plural.y"
1030 yyval
.exp
= new_exp_2 (land
, yyvsp
[-2].exp
, yyvsp
[0].exp
);
1034 #line 173 "plural.y"
1036 yyval
.exp
= new_exp_2 (yyvsp
[-1].op
, yyvsp
[-2].exp
, yyvsp
[0].exp
);
1040 #line 177 "plural.y"
1042 yyval
.exp
= new_exp_2 (yyvsp
[-1].op
, yyvsp
[-2].exp
, yyvsp
[0].exp
);
1046 #line 181 "plural.y"
1048 yyval
.exp
= new_exp_2 (yyvsp
[-1].op
, yyvsp
[-2].exp
, yyvsp
[0].exp
);
1052 #line 185 "plural.y"
1054 yyval
.exp
= new_exp_2 (yyvsp
[-1].op
, yyvsp
[-2].exp
, yyvsp
[0].exp
);
1058 #line 189 "plural.y"
1060 yyval
.exp
= new_exp_1 (lnot
, yyvsp
[0].exp
);
1064 #line 193 "plural.y"
1066 yyval
.exp
= new_exp_0 (var
);
1070 #line 197 "plural.y"
1072 if ((yyval
.exp
= new_exp_0 (num
)) != NULL
)
1073 yyval
.exp
->val
.num
= yyvsp
[0].num
;
1077 #line 202 "plural.y"
1079 yyval
.exp
= yyvsp
[-1].exp
;
1084 #line 705 "bison.simple"
1096 short *yyssp1
= yyss
- 1;
1097 YYFPRINTF (stderr
, "state stack now");
1098 while (yyssp1
!= yyssp
)
1099 YYFPRINTF (stderr
, " %d", *++yyssp1
);
1100 YYFPRINTF (stderr
, "\n");
1109 /* Now `shift' the result of the reduction. Determine what state
1110 that goes to, based on the state we popped back to and the rule
1111 number reduced by. */
1115 yystate
= yypgoto
[yyn
- YYNTBASE
] + *yyssp
;
1116 if (yystate
>= 0 && yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1117 yystate
= yytable
[yystate
];
1119 yystate
= yydefgoto
[yyn
- YYNTBASE
];
1124 /*------------------------------------.
1125 | yyerrlab -- here on detecting error |
1126 `------------------------------------*/
1128 /* If not already recovering from an error, report this error. */
1133 #ifdef YYERROR_VERBOSE
1134 yyn
= yypact
[yystate
];
1136 if (yyn
> YYFLAG
&& yyn
< YYLAST
)
1138 YYSIZE_T yysize
= 0;
1143 /* Start YYX at -YYN if negative to avoid negative indexes in
1145 for (yyx
= yyn
< 0 ? -yyn
: 0;
1146 yyx
< (int) (sizeof (yytname
) / sizeof (char *)); yyx
++)
1147 if (yycheck
[yyx
+ yyn
] == yyx
)
1148 yysize
+= yystrlen (yytname
[yyx
]) + 15, yycount
++;
1149 yysize
+= yystrlen ("parse error, unexpected ") + 1;
1150 yysize
+= yystrlen (yytname
[YYTRANSLATE (yychar
)]);
1151 yymsg
= (char *) YYSTACK_ALLOC (yysize
);
1154 char *yyp
= yystpcpy (yymsg
, "parse error, unexpected ");
1155 yyp
= yystpcpy (yyp
, yytname
[YYTRANSLATE (yychar
)]);
1160 for (yyx
= yyn
< 0 ? -yyn
: 0;
1161 yyx
< (int) (sizeof (yytname
) / sizeof (char *));
1163 if (yycheck
[yyx
+ yyn
] == yyx
)
1165 const char *yyq
= ! yycount
? ", expecting " : " or ";
1166 yyp
= yystpcpy (yyp
, yyq
);
1167 yyp
= yystpcpy (yyp
, yytname
[yyx
]);
1172 YYSTACK_FREE (yymsg
);
1175 yyerror ("parse error; also virtual memory exhausted");
1178 #endif /* defined (YYERROR_VERBOSE) */
1179 yyerror ("parse error");
1184 /*--------------------------------------------------.
1185 | yyerrlab1 -- error raised explicitly by an action |
1186 `--------------------------------------------------*/
1188 if (yyerrstatus
== 3)
1190 /* If just tried and failed to reuse lookahead token after an
1191 error, discard it. */
1193 /* return failure if at end of input */
1194 if (yychar
== YYEOF
)
1196 YYDPRINTF ((stderr
, "Discarding token %d (%s).\n",
1197 yychar
, yytname
[yychar1
]));
1201 /* Else will try to reuse lookahead token after shifting the error
1204 yyerrstatus
= 3; /* Each real token shifted decrements this */
1209 /*-------------------------------------------------------------------.
1210 | yyerrdefault -- current state does not do anything special for the |
1212 `-------------------------------------------------------------------*/
1215 /* This is wrong; only states that explicitly want error tokens
1216 should shift them. */
1218 /* If its default is to accept any token, ok. Otherwise pop it. */
1219 yyn
= yydefact
[yystate
];
1225 /*---------------------------------------------------------------.
1226 | yyerrpop -- pop the current state because it cannot handle the |
1228 `---------------------------------------------------------------*/
1241 short *yyssp1
= yyss
- 1;
1242 YYFPRINTF (stderr
, "Error: state stack now");
1243 while (yyssp1
!= yyssp
)
1244 YYFPRINTF (stderr
, " %d", *++yyssp1
);
1245 YYFPRINTF (stderr
, "\n");
1253 yyn
= yypact
[yystate
];
1258 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != YYTERROR
)
1275 YYDPRINTF ((stderr
, "Shifting error token, "));
1286 /*-------------------------------------.
1287 | yyacceptlab -- YYACCEPT comes here. |
1288 `-------------------------------------*/
1293 /*-----------------------------------.
1294 | yyabortlab -- YYABORT comes here. |
1295 `-----------------------------------*/
1300 /*---------------------------------------------.
1301 | yyoverflowab -- parser overflow comes here. |
1302 `---------------------------------------------*/
1304 yyerror ("parser stack overflow");
1311 YYSTACK_FREE (yyss
);
1315 #line 207 "plural.y"
1320 FREE_EXPRESSION (struct expression
*exp
)
1325 /* Handle the recursive case. */
1329 FREE_EXPRESSION (exp
->val
.args
[2]);
1332 FREE_EXPRESSION (exp
->val
.args
[1]);
1335 FREE_EXPRESSION (exp
->val
.args
[0]);
1346 yylex (YYSTYPE
*lval
, const char **pexp
)
1348 const char *exp
= *pexp
;
1359 if (exp
[0] != ' ' && exp
[0] != '\t')
1368 case '0': case '1': case '2': case '3': case '4':
1369 case '5': case '6': case '7': case '8': case '9':
1371 unsigned long int n
= result
- '0';
1372 while (exp
[0] >= '0' && exp
[0] <= '9')
1398 lval
->op
= not_equal
;
1405 if (exp
[0] == result
)
1415 lval
->op
= less_or_equal
;
1418 lval
->op
= less_than
;
1426 lval
->op
= greater_or_equal
;
1429 lval
->op
= greater_than
;
1463 /* Nothing, just return the character. */
1469 /* Be safe and let the user call this function again. */
1489 yyerror (const char *str
)
1491 /* Do nothing. We don't print error messages here. */