Check the main application only if SHARED is defined
[glibc.git] / intl / plural.c
blob0d8bf4c6d59ff64606f38bd5956bd2cbdd8baf73
1 /* A Bison parser, made by GNU Bison 2.5. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* As a special exception, you may create a larger work that contains
21 part or all of the Bison parser skeleton and distribute that work
22 under terms of your choice, so long as that work isn't itself a
23 parser generator using the skeleton or a modified version thereof
24 as a parser skeleton. Alternatively, if you modify or redistribute
25 the parser skeleton itself, you may (at your option) remove this
26 special exception, which will cause the skeleton and the resulting
27 Bison output files to be licensed under the GNU General Public
28 License without this special exception.
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
36 /* All symbols defined below should begin with yy or YY, to avoid
37 infringing on user name space. This should be done even for local
38 variables, as they might otherwise be expanded by user macros.
39 There are some unavoidable exceptions within include files to
40 define necessary library symbols; they are noted "INFRINGES ON
41 USER NAME SPACE" below. */
43 /* Identify Bison output. */
44 #define YYBISON 1
46 /* Bison version. */
47 #define YYBISON_VERSION "2.5"
49 /* Skeleton name. */
50 #define YYSKELETON_NAME "yacc.c"
52 /* Pure parsers. */
53 #define YYPURE 1
55 /* Push parsers. */
56 #define YYPUSH 0
58 /* Pull parsers. */
59 #define YYPULL 1
61 /* Using locations. */
62 #define YYLSP_NEEDED 0
64 /* Substitute the variable and function names. */
65 #define yyparse __gettextparse
66 #define yylex __gettextlex
67 #define yyerror __gettexterror
68 #define yylval __gettextlval
69 #define yychar __gettextchar
70 #define yydebug __gettextdebug
71 #define yynerrs __gettextnerrs
74 /* Copy the first part of user declarations. */
76 /* Line 268 of yacc.c */
77 #line 1 "plural.y"
79 /* Expression parsing for plural form selection.
80 Copyright (C) 2000, 2001 Free Software Foundation, Inc.
81 This file is part of the GNU C Library.
82 Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
84 The GNU C Library is free software; you can redistribute it and/or
85 modify it under the terms of the GNU Lesser General Public
86 License as published by the Free Software Foundation; either
87 version 2.1 of the License, or (at your option) any later version.
89 The GNU C Library is distributed in the hope that it will be useful,
90 but WITHOUT ANY WARRANTY; without even the implied warranty of
91 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
92 Lesser General Public License for more details.
94 You should have received a copy of the GNU Lesser General Public
95 License along with the GNU C Library; if not, see
96 <http://www.gnu.org/licenses/>. */
98 /* The bison generated parser uses alloca. AIX 3 forces us to put this
99 declaration at the beginning of the file. The declaration in bison's
100 skeleton file comes too late. This must come before <config.h>
101 because <config.h> may include arbitrary system headers. */
102 #if defined _AIX && !defined __GNUC__
103 #pragma alloca
104 #endif
105 #ifdef HAVE_CONFIG_H
106 # include <config.h>
107 #endif
109 #include <stddef.h>
110 #include <stdlib.h>
111 #include <string.h>
112 #include "plural-exp.h"
114 /* The main function generated by the parser is called __gettextparse,
115 but we want it to be called PLURAL_PARSE. */
116 #ifndef _LIBC
117 # define __gettextparse PLURAL_PARSE
118 #endif
120 #define YYLEX_PARAM &((struct parse_args *) arg)->cp
121 #define YYPARSE_PARAM arg
124 /* Line 268 of yacc.c */
125 #line 126 "plural.c"
127 /* Enabling traces. */
128 #ifndef YYDEBUG
129 # define YYDEBUG 0
130 #endif
132 /* Enabling verbose error messages. */
133 #ifdef YYERROR_VERBOSE
134 # undef YYERROR_VERBOSE
135 # define YYERROR_VERBOSE 1
136 #else
137 # define YYERROR_VERBOSE 0
138 #endif
140 /* Enabling the token table. */
141 #ifndef YYTOKEN_TABLE
142 # define YYTOKEN_TABLE 0
143 #endif
146 /* Tokens. */
147 #ifndef YYTOKENTYPE
148 # define YYTOKENTYPE
149 /* Put the tokens into the symbol table, so that GDB and other debuggers
150 know about them. */
151 enum yytokentype {
152 EQUOP2 = 258,
153 CMPOP2 = 259,
154 ADDOP2 = 260,
155 MULOP2 = 261,
156 NUMBER = 262
158 #endif
159 /* Tokens. */
160 #define EQUOP2 258
161 #define CMPOP2 259
162 #define ADDOP2 260
163 #define MULOP2 261
164 #define NUMBER 262
169 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
170 typedef union YYSTYPE
173 /* Line 293 of yacc.c */
174 #line 49 "plural.y"
176 unsigned long int num;
177 enum operator op;
178 struct expression *exp;
182 /* Line 293 of yacc.c */
183 #line 184 "plural.c"
184 } YYSTYPE;
185 # define YYSTYPE_IS_TRIVIAL 1
186 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
187 # define YYSTYPE_IS_DECLARED 1
188 #endif
191 /* Copy the second part of user declarations. */
193 /* Line 343 of yacc.c */
194 #line 55 "plural.y"
196 /* Prototypes for local functions. */
197 static struct expression *new_exp PARAMS ((int nargs, enum operator op,
198 struct expression * const *args));
199 static inline struct expression *new_exp_0 PARAMS ((enum operator op));
200 static inline struct expression *new_exp_1 PARAMS ((enum operator op,
201 struct expression *right));
202 static struct expression *new_exp_2 PARAMS ((enum operator op,
203 struct expression *left,
204 struct expression *right));
205 static inline struct expression *new_exp_3 PARAMS ((enum operator op,
206 struct expression *bexp,
207 struct expression *tbranch,
208 struct expression *fbranch));
209 static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
210 static void yyerror PARAMS ((const char *str));
212 /* Allocation of expressions. */
214 static struct expression *
215 new_exp (nargs, op, args)
216 int nargs;
217 enum operator op;
218 struct expression * const *args;
220 int i;
221 struct expression *newp;
223 /* If any of the argument could not be malloc'ed, just return NULL. */
224 for (i = nargs - 1; i >= 0; i--)
225 if (args[i] == NULL)
226 goto fail;
228 /* Allocate a new expression. */
229 newp = (struct expression *) malloc (sizeof (*newp));
230 if (newp != NULL)
232 newp->nargs = nargs;
233 newp->operation = op;
234 for (i = nargs - 1; i >= 0; i--)
235 newp->val.args[i] = args[i];
236 return newp;
239 fail:
240 for (i = nargs - 1; i >= 0; i--)
241 FREE_EXPRESSION (args[i]);
243 return NULL;
246 static inline struct expression *
247 new_exp_0 (op)
248 enum operator op;
250 return new_exp (0, op, NULL);
253 static inline struct expression *
254 new_exp_1 (op, right)
255 enum operator op;
256 struct expression *right;
258 struct expression *args[1];
260 args[0] = right;
261 return new_exp (1, op, args);
264 static struct expression *
265 new_exp_2 (op, left, right)
266 enum operator op;
267 struct expression *left;
268 struct expression *right;
270 struct expression *args[2];
272 args[0] = left;
273 args[1] = right;
274 return new_exp (2, op, args);
277 static inline struct expression *
278 new_exp_3 (op, bexp, tbranch, fbranch)
279 enum operator op;
280 struct expression *bexp;
281 struct expression *tbranch;
282 struct expression *fbranch;
284 struct expression *args[3];
286 args[0] = bexp;
287 args[1] = tbranch;
288 args[2] = fbranch;
289 return new_exp (3, op, args);
294 /* Line 343 of yacc.c */
295 #line 296 "plural.c"
297 #ifdef short
298 # undef short
299 #endif
301 #ifdef YYTYPE_UINT8
302 typedef YYTYPE_UINT8 yytype_uint8;
303 #else
304 typedef unsigned char yytype_uint8;
305 #endif
307 #ifdef YYTYPE_INT8
308 typedef YYTYPE_INT8 yytype_int8;
309 #elif (defined __STDC__ || defined __C99__FUNC__ \
310 || defined __cplusplus || defined _MSC_VER)
311 typedef signed char yytype_int8;
312 #else
313 typedef short int yytype_int8;
314 #endif
316 #ifdef YYTYPE_UINT16
317 typedef YYTYPE_UINT16 yytype_uint16;
318 #else
319 typedef unsigned short int yytype_uint16;
320 #endif
322 #ifdef YYTYPE_INT16
323 typedef YYTYPE_INT16 yytype_int16;
324 #else
325 typedef short int yytype_int16;
326 #endif
328 #ifndef YYSIZE_T
329 # ifdef __SIZE_TYPE__
330 # define YYSIZE_T __SIZE_TYPE__
331 # elif defined size_t
332 # define YYSIZE_T size_t
333 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
334 || defined __cplusplus || defined _MSC_VER)
335 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
336 # define YYSIZE_T size_t
337 # else
338 # define YYSIZE_T unsigned int
339 # endif
340 #endif
342 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
344 #ifndef YY_
345 # if defined YYENABLE_NLS && YYENABLE_NLS
346 # if ENABLE_NLS
347 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
348 # define YY_(msgid) dgettext ("bison-runtime", msgid)
349 # endif
350 # endif
351 # ifndef YY_
352 # define YY_(msgid) msgid
353 # endif
354 #endif
356 /* Suppress unused-variable warnings by "using" E. */
357 #if ! defined lint || defined __GNUC__
358 # define YYUSE(e) ((void) (e))
359 #else
360 # define YYUSE(e) /* empty */
361 #endif
363 /* Identity function, used to suppress warnings about constant conditions. */
364 #ifndef lint
365 # define YYID(n) (n)
366 #else
367 #if (defined __STDC__ || defined __C99__FUNC__ \
368 || defined __cplusplus || defined _MSC_VER)
369 static int
370 YYID (int yyi)
371 #else
372 static int
373 YYID (yyi)
374 int yyi;
375 #endif
377 return yyi;
379 #endif
381 #if ! defined yyoverflow || YYERROR_VERBOSE
383 /* The parser invokes alloca or malloc; define the necessary symbols. */
385 # ifdef YYSTACK_USE_ALLOCA
386 # if YYSTACK_USE_ALLOCA
387 # ifdef __GNUC__
388 # define YYSTACK_ALLOC __builtin_alloca
389 # elif defined __BUILTIN_VA_ARG_INCR
390 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
391 # elif defined _AIX
392 # define YYSTACK_ALLOC __alloca
393 # elif defined _MSC_VER
394 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
395 # define alloca _alloca
396 # else
397 # define YYSTACK_ALLOC alloca
398 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
399 || defined __cplusplus || defined _MSC_VER)
400 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
401 # ifndef EXIT_SUCCESS
402 # define EXIT_SUCCESS 0
403 # endif
404 # endif
405 # endif
406 # endif
407 # endif
409 # ifdef YYSTACK_ALLOC
410 /* Pacify GCC's `empty if-body' warning. */
411 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
412 # ifndef YYSTACK_ALLOC_MAXIMUM
413 /* The OS might guarantee only one guard page at the bottom of the stack,
414 and a page size can be as small as 4096 bytes. So we cannot safely
415 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
416 to allow for a few compiler-allocated temporary stack slots. */
417 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
418 # endif
419 # else
420 # define YYSTACK_ALLOC YYMALLOC
421 # define YYSTACK_FREE YYFREE
422 # ifndef YYSTACK_ALLOC_MAXIMUM
423 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
424 # endif
425 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
426 && ! ((defined YYMALLOC || defined malloc) \
427 && (defined YYFREE || defined free)))
428 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
429 # ifndef EXIT_SUCCESS
430 # define EXIT_SUCCESS 0
431 # endif
432 # endif
433 # ifndef YYMALLOC
434 # define YYMALLOC malloc
435 # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
436 || defined __cplusplus || defined _MSC_VER)
437 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
438 # endif
439 # endif
440 # ifndef YYFREE
441 # define YYFREE free
442 # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
443 || defined __cplusplus || defined _MSC_VER)
444 void free (void *); /* INFRINGES ON USER NAME SPACE */
445 # endif
446 # endif
447 # endif
448 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
451 #if (! defined yyoverflow \
452 && (! defined __cplusplus \
453 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
455 /* A type that is properly aligned for any stack member. */
456 union yyalloc
458 yytype_int16 yyss_alloc;
459 YYSTYPE yyvs_alloc;
462 /* The size of the maximum gap between one aligned stack and the next. */
463 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
465 /* The size of an array large to enough to hold all stacks, each with
466 N elements. */
467 # define YYSTACK_BYTES(N) \
468 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
469 + YYSTACK_GAP_MAXIMUM)
471 # define YYCOPY_NEEDED 1
473 /* Relocate STACK from its old location to the new one. The
474 local variables YYSIZE and YYSTACKSIZE give the old and new number of
475 elements in the stack, and YYPTR gives the new location of the
476 stack. Advance YYPTR to a properly aligned location for the next
477 stack. */
478 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
479 do \
481 YYSIZE_T yynewbytes; \
482 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
483 Stack = &yyptr->Stack_alloc; \
484 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
485 yyptr += yynewbytes / sizeof (*yyptr); \
487 while (YYID (0))
489 #endif
491 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
492 /* Copy COUNT objects from FROM to TO. The source and destination do
493 not overlap. */
494 # ifndef YYCOPY
495 # if defined __GNUC__ && 1 < __GNUC__
496 # define YYCOPY(To, From, Count) \
497 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
498 # else
499 # define YYCOPY(To, From, Count) \
500 do \
502 YYSIZE_T yyi; \
503 for (yyi = 0; yyi < (Count); yyi++) \
504 (To)[yyi] = (From)[yyi]; \
506 while (YYID (0))
507 # endif
508 # endif
509 #endif /* !YYCOPY_NEEDED */
511 /* YYFINAL -- State number of the termination state. */
512 #define YYFINAL 9
513 /* YYLAST -- Last index in YYTABLE. */
514 #define YYLAST 54
516 /* YYNTOKENS -- Number of terminals. */
517 #define YYNTOKENS 16
518 /* YYNNTS -- Number of nonterminals. */
519 #define YYNNTS 3
520 /* YYNRULES -- Number of rules. */
521 #define YYNRULES 13
522 /* YYNRULES -- Number of states. */
523 #define YYNSTATES 27
525 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
526 #define YYUNDEFTOK 2
527 #define YYMAXUTOK 262
529 #define YYTRANSLATE(YYX) \
530 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
532 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
533 static const yytype_uint8 yytranslate[] =
535 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
536 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
537 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
538 2, 2, 2, 10, 2, 2, 2, 2, 5, 2,
539 14, 15, 2, 2, 2, 2, 2, 2, 2, 2,
540 2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
541 2, 2, 2, 3, 2, 2, 2, 2, 2, 2,
542 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
543 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
544 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
545 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
546 13, 2, 2, 2, 2, 2, 2, 2, 2, 2,
547 2, 2, 2, 2, 4, 2, 2, 2, 2, 2,
548 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
549 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
550 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
551 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
552 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
553 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
554 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
555 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
556 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
557 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
558 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
559 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
560 2, 2, 2, 2, 2, 2, 1, 2, 6, 7,
561 8, 9, 11
564 #if YYDEBUG
565 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
566 YYRHS. */
567 static const yytype_uint8 yyprhs[] =
569 0, 0, 3, 5, 11, 15, 19, 23, 27, 31,
570 35, 38, 40, 42
573 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
574 static const yytype_int8 yyrhs[] =
576 17, 0, -1, 18, -1, 18, 3, 18, 12, 18,
577 -1, 18, 4, 18, -1, 18, 5, 18, -1, 18,
578 6, 18, -1, 18, 7, 18, -1, 18, 8, 18,
579 -1, 18, 9, 18, -1, 10, 18, -1, 13, -1,
580 11, -1, 14, 18, 15, -1
583 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
584 static const yytype_uint8 yyrline[] =
586 0, 174, 174, 182, 186, 190, 194, 198, 202, 206,
587 210, 214, 218, 223
589 #endif
591 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
592 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
593 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
594 static const char *const yytname[] =
596 "$end", "error", "$undefined", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
597 "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
598 "$accept", "start", "exp", 0
600 #endif
602 # ifdef YYPRINT
603 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
604 token YYLEX-NUM. */
605 static const yytype_uint16 yytoknum[] =
607 0, 256, 257, 63, 124, 38, 258, 259, 260, 261,
608 33, 262, 58, 110, 40, 41
610 # endif
612 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
613 static const yytype_uint8 yyr1[] =
615 0, 16, 17, 18, 18, 18, 18, 18, 18, 18,
616 18, 18, 18, 18
619 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
620 static const yytype_uint8 yyr2[] =
622 0, 2, 1, 5, 3, 3, 3, 3, 3, 3,
623 2, 1, 1, 3
626 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
627 Performed when YYTABLE doesn't specify something else to do. Zero
628 means the default is an error. */
629 static const yytype_uint8 yydefact[] =
631 0, 0, 12, 11, 0, 0, 2, 10, 0, 1,
632 0, 0, 0, 0, 0, 0, 0, 13, 0, 4,
633 5, 6, 7, 8, 9, 0, 3
636 /* YYDEFGOTO[NTERM-NUM]. */
637 static const yytype_int8 yydefgoto[] =
639 -1, 5, 6
642 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
643 STATE-NUM. */
644 #define YYPACT_NINF -10
645 static const yytype_int8 yypact[] =
647 -9, -9, -10, -10, -9, 8, 36, -10, 13, -10,
648 -9, -9, -9, -9, -9, -9, -9, -10, 26, 41,
649 45, 18, -2, 14, -10, -9, 36
652 /* YYPGOTO[NTERM-NUM]. */
653 static const yytype_int8 yypgoto[] =
655 -10, -10, -1
658 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
659 positive, shift that token. If negative, reduce the rule which
660 number is the opposite. If YYTABLE_NINF, syntax error. */
661 #define YYTABLE_NINF -1
662 static const yytype_uint8 yytable[] =
664 7, 1, 2, 8, 3, 4, 15, 16, 9, 18,
665 19, 20, 21, 22, 23, 24, 10, 11, 12, 13,
666 14, 15, 16, 16, 26, 14, 15, 16, 17, 10,
667 11, 12, 13, 14, 15, 16, 0, 0, 25, 10,
668 11, 12, 13, 14, 15, 16, 12, 13, 14, 15,
669 16, 13, 14, 15, 16
672 #define yypact_value_is_default(yystate) \
673 ((yystate) == (-10))
675 #define yytable_value_is_error(yytable_value) \
676 YYID (0)
678 static const yytype_int8 yycheck[] =
680 1, 10, 11, 4, 13, 14, 8, 9, 0, 10,
681 11, 12, 13, 14, 15, 16, 3, 4, 5, 6,
682 7, 8, 9, 9, 25, 7, 8, 9, 15, 3,
683 4, 5, 6, 7, 8, 9, -1, -1, 12, 3,
684 4, 5, 6, 7, 8, 9, 5, 6, 7, 8,
685 9, 6, 7, 8, 9
688 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
689 symbol of state STATE-NUM. */
690 static const yytype_uint8 yystos[] =
692 0, 10, 11, 13, 14, 17, 18, 18, 18, 0,
693 3, 4, 5, 6, 7, 8, 9, 15, 18, 18,
694 18, 18, 18, 18, 18, 12, 18
697 #define yyerrok (yyerrstatus = 0)
698 #define yyclearin (yychar = YYEMPTY)
699 #define YYEMPTY (-2)
700 #define YYEOF 0
702 #define YYACCEPT goto yyacceptlab
703 #define YYABORT goto yyabortlab
704 #define YYERROR goto yyerrorlab
707 /* Like YYERROR except do call yyerror. This remains here temporarily
708 to ease the transition to the new meaning of YYERROR, for GCC.
709 Once GCC version 2 has supplanted version 1, this can go. However,
710 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
711 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
712 discussed. */
714 #define YYFAIL goto yyerrlab
715 #if defined YYFAIL
716 /* This is here to suppress warnings from the GCC cpp's
717 -Wunused-macros. Normally we don't worry about that warning, but
718 some users do, and we want to make it easy for users to remove
719 YYFAIL uses, which will produce warnings from Bison 2.5. */
720 #endif
722 #define YYRECOVERING() (!!yyerrstatus)
724 #define YYBACKUP(Token, Value) \
725 do \
726 if (yychar == YYEMPTY && yylen == 1) \
728 yychar = (Token); \
729 yylval = (Value); \
730 YYPOPSTACK (1); \
731 goto yybackup; \
733 else \
735 yyerror (YY_("syntax error: cannot back up")); \
736 YYERROR; \
738 while (YYID (0))
741 #define YYTERROR 1
742 #define YYERRCODE 256
745 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
746 If N is 0, then set CURRENT to the empty location which ends
747 the previous symbol: RHS[0] (always defined). */
749 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
750 #ifndef YYLLOC_DEFAULT
751 # define YYLLOC_DEFAULT(Current, Rhs, N) \
752 do \
753 if (YYID (N)) \
755 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
756 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
757 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
758 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
760 else \
762 (Current).first_line = (Current).last_line = \
763 YYRHSLOC (Rhs, 0).last_line; \
764 (Current).first_column = (Current).last_column = \
765 YYRHSLOC (Rhs, 0).last_column; \
767 while (YYID (0))
768 #endif
771 /* This macro is provided for backward compatibility. */
773 #ifndef YY_LOCATION_PRINT
774 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
775 #endif
778 /* YYLEX -- calling `yylex' with the right arguments. */
780 #ifdef YYLEX_PARAM
781 # define YYLEX yylex (&yylval, YYLEX_PARAM)
782 #else
783 # define YYLEX yylex (&yylval)
784 #endif
786 /* Enable debugging if requested. */
787 #if YYDEBUG
789 # ifndef YYFPRINTF
790 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
791 # define YYFPRINTF fprintf
792 # endif
794 # define YYDPRINTF(Args) \
795 do { \
796 if (yydebug) \
797 YYFPRINTF Args; \
798 } while (YYID (0))
800 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
801 do { \
802 if (yydebug) \
804 YYFPRINTF (stderr, "%s ", Title); \
805 yy_symbol_print (stderr, \
806 Type, Value); \
807 YYFPRINTF (stderr, "\n"); \
809 } while (YYID (0))
812 /*--------------------------------.
813 | Print this symbol on YYOUTPUT. |
814 `--------------------------------*/
816 /*ARGSUSED*/
817 #if (defined __STDC__ || defined __C99__FUNC__ \
818 || defined __cplusplus || defined _MSC_VER)
819 static void
820 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
821 #else
822 static void
823 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
824 FILE *yyoutput;
825 int yytype;
826 YYSTYPE const * const yyvaluep;
827 #endif
829 if (!yyvaluep)
830 return;
831 # ifdef YYPRINT
832 if (yytype < YYNTOKENS)
833 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
834 # else
835 YYUSE (yyoutput);
836 # endif
837 switch (yytype)
839 default:
840 break;
845 /*--------------------------------.
846 | Print this symbol on YYOUTPUT. |
847 `--------------------------------*/
849 #if (defined __STDC__ || defined __C99__FUNC__ \
850 || defined __cplusplus || defined _MSC_VER)
851 static void
852 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
853 #else
854 static void
855 yy_symbol_print (yyoutput, yytype, yyvaluep)
856 FILE *yyoutput;
857 int yytype;
858 YYSTYPE const * const yyvaluep;
859 #endif
861 if (yytype < YYNTOKENS)
862 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
863 else
864 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
866 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
867 YYFPRINTF (yyoutput, ")");
870 /*------------------------------------------------------------------.
871 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
872 | TOP (included). |
873 `------------------------------------------------------------------*/
875 #if (defined __STDC__ || defined __C99__FUNC__ \
876 || defined __cplusplus || defined _MSC_VER)
877 static void
878 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
879 #else
880 static void
881 yy_stack_print (yybottom, yytop)
882 yytype_int16 *yybottom;
883 yytype_int16 *yytop;
884 #endif
886 YYFPRINTF (stderr, "Stack now");
887 for (; yybottom <= yytop; yybottom++)
889 int yybot = *yybottom;
890 YYFPRINTF (stderr, " %d", yybot);
892 YYFPRINTF (stderr, "\n");
895 # define YY_STACK_PRINT(Bottom, Top) \
896 do { \
897 if (yydebug) \
898 yy_stack_print ((Bottom), (Top)); \
899 } while (YYID (0))
902 /*------------------------------------------------.
903 | Report that the YYRULE is going to be reduced. |
904 `------------------------------------------------*/
906 #if (defined __STDC__ || defined __C99__FUNC__ \
907 || defined __cplusplus || defined _MSC_VER)
908 static void
909 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
910 #else
911 static void
912 yy_reduce_print (yyvsp, yyrule)
913 YYSTYPE *yyvsp;
914 int yyrule;
915 #endif
917 int yynrhs = yyr2[yyrule];
918 int yyi;
919 unsigned long int yylno = yyrline[yyrule];
920 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
921 yyrule - 1, yylno);
922 /* The symbols being reduced. */
923 for (yyi = 0; yyi < yynrhs; yyi++)
925 YYFPRINTF (stderr, " $%d = ", yyi + 1);
926 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
927 &(yyvsp[(yyi + 1) - (yynrhs)])
929 YYFPRINTF (stderr, "\n");
933 # define YY_REDUCE_PRINT(Rule) \
934 do { \
935 if (yydebug) \
936 yy_reduce_print (yyvsp, Rule); \
937 } while (YYID (0))
939 /* Nonzero means print parse trace. It is left uninitialized so that
940 multiple parsers can coexist. */
941 int yydebug;
942 #else /* !YYDEBUG */
943 # define YYDPRINTF(Args)
944 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
945 # define YY_STACK_PRINT(Bottom, Top)
946 # define YY_REDUCE_PRINT(Rule)
947 #endif /* !YYDEBUG */
950 /* YYINITDEPTH -- initial size of the parser's stacks. */
951 #ifndef YYINITDEPTH
952 # define YYINITDEPTH 200
953 #endif
955 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
956 if the built-in stack extension method is used).
958 Do not make this value too large; the results are undefined if
959 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
960 evaluated with infinite-precision integer arithmetic. */
962 #ifndef YYMAXDEPTH
963 # define YYMAXDEPTH 10000
964 #endif
967 #if YYERROR_VERBOSE
969 # ifndef yystrlen
970 # if defined __GLIBC__ && defined _STRING_H
971 # define yystrlen strlen
972 # else
973 /* Return the length of YYSTR. */
974 #if (defined __STDC__ || defined __C99__FUNC__ \
975 || defined __cplusplus || defined _MSC_VER)
976 static YYSIZE_T
977 yystrlen (const char *yystr)
978 #else
979 static YYSIZE_T
980 yystrlen (yystr)
981 const char *yystr;
982 #endif
984 YYSIZE_T yylen;
985 for (yylen = 0; yystr[yylen]; yylen++)
986 continue;
987 return yylen;
989 # endif
990 # endif
992 # ifndef yystpcpy
993 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
994 # define yystpcpy stpcpy
995 # else
996 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
997 YYDEST. */
998 #if (defined __STDC__ || defined __C99__FUNC__ \
999 || defined __cplusplus || defined _MSC_VER)
1000 static char *
1001 yystpcpy (char *yydest, const char *yysrc)
1002 #else
1003 static char *
1004 yystpcpy (yydest, yysrc)
1005 char *yydest;
1006 const char *yysrc;
1007 #endif
1009 char *yyd = yydest;
1010 const char *yys = yysrc;
1012 while ((*yyd++ = *yys++) != '\0')
1013 continue;
1015 return yyd - 1;
1017 # endif
1018 # endif
1020 # ifndef yytnamerr
1021 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1022 quotes and backslashes, so that it's suitable for yyerror. The
1023 heuristic is that double-quoting is unnecessary unless the string
1024 contains an apostrophe, a comma, or backslash (other than
1025 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1026 null, do not copy; instead, return the length of what the result
1027 would have been. */
1028 static YYSIZE_T
1029 yytnamerr (char *yyres, const char *yystr)
1031 if (*yystr == '"')
1033 YYSIZE_T yyn = 0;
1034 char const *yyp = yystr;
1036 for (;;)
1037 switch (*++yyp)
1039 case '\'':
1040 case ',':
1041 goto do_not_strip_quotes;
1043 case '\\':
1044 if (*++yyp != '\\')
1045 goto do_not_strip_quotes;
1046 /* Fall through. */
1047 default:
1048 if (yyres)
1049 yyres[yyn] = *yyp;
1050 yyn++;
1051 break;
1053 case '"':
1054 if (yyres)
1055 yyres[yyn] = '\0';
1056 return yyn;
1058 do_not_strip_quotes: ;
1061 if (! yyres)
1062 return yystrlen (yystr);
1064 return yystpcpy (yyres, yystr) - yyres;
1066 # endif
1068 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1069 about the unexpected token YYTOKEN for the state stack whose top is
1070 YYSSP.
1072 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1073 not large enough to hold the message. In that case, also set
1074 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1075 required number of bytes is too large to store. */
1076 static int
1077 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1078 yytype_int16 *yyssp, int yytoken)
1080 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
1081 YYSIZE_T yysize = yysize0;
1082 YYSIZE_T yysize1;
1083 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1084 /* Internationalized format string. */
1085 const char *yyformat = 0;
1086 /* Arguments of yyformat. */
1087 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1088 /* Number of reported tokens (one for the "unexpected", one per
1089 "expected"). */
1090 int yycount = 0;
1092 /* There are many possibilities here to consider:
1093 - Assume YYFAIL is not used. It's too flawed to consider. See
1094 <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1095 for details. YYERROR is fine as it does not invoke this
1096 function.
1097 - If this state is a consistent state with a default action, then
1098 the only way this function was invoked is if the default action
1099 is an error action. In that case, don't check for expected
1100 tokens because there are none.
1101 - The only way there can be no lookahead present (in yychar) is if
1102 this state is a consistent state with a default action. Thus,
1103 detecting the absence of a lookahead is sufficient to determine
1104 that there is no unexpected or expected token to report. In that
1105 case, just report a simple "syntax error".
1106 - Don't assume there isn't a lookahead just because this state is a
1107 consistent state with a default action. There might have been a
1108 previous inconsistent state, consistent state with a non-default
1109 action, or user semantic action that manipulated yychar.
1110 - Of course, the expected token list depends on states to have
1111 correct lookahead information, and it depends on the parser not
1112 to perform extra reductions after fetching a lookahead from the
1113 scanner and before detecting a syntax error. Thus, state merging
1114 (from LALR or IELR) and default reductions corrupt the expected
1115 token list. However, the list is correct for canonical LR with
1116 one exception: it will still contain any token that will not be
1117 accepted due to an error action in a later state.
1119 if (yytoken != YYEMPTY)
1121 int yyn = yypact[*yyssp];
1122 yyarg[yycount++] = yytname[yytoken];
1123 if (!yypact_value_is_default (yyn))
1125 /* Start YYX at -YYN if negative to avoid negative indexes in
1126 YYCHECK. In other words, skip the first -YYN actions for
1127 this state because they are default actions. */
1128 int yyxbegin = yyn < 0 ? -yyn : 0;
1129 /* Stay within bounds of both yycheck and yytname. */
1130 int yychecklim = YYLAST - yyn + 1;
1131 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1132 int yyx;
1134 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1135 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1136 && !yytable_value_is_error (yytable[yyx + yyn]))
1138 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1140 yycount = 1;
1141 yysize = yysize0;
1142 break;
1144 yyarg[yycount++] = yytname[yyx];
1145 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1146 if (! (yysize <= yysize1
1147 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1148 return 2;
1149 yysize = yysize1;
1154 switch (yycount)
1156 # define YYCASE_(N, S) \
1157 case N: \
1158 yyformat = S; \
1159 break
1160 YYCASE_(0, YY_("syntax error"));
1161 YYCASE_(1, YY_("syntax error, unexpected %s"));
1162 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1163 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1164 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1165 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1166 # undef YYCASE_
1169 yysize1 = yysize + yystrlen (yyformat);
1170 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1171 return 2;
1172 yysize = yysize1;
1174 if (*yymsg_alloc < yysize)
1176 *yymsg_alloc = 2 * yysize;
1177 if (! (yysize <= *yymsg_alloc
1178 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1179 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1180 return 1;
1183 /* Avoid sprintf, as that infringes on the user's name space.
1184 Don't have undefined behavior even if the translation
1185 produced a string with the wrong number of "%s"s. */
1187 char *yyp = *yymsg;
1188 int yyi = 0;
1189 while ((*yyp = *yyformat) != '\0')
1190 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1192 yyp += yytnamerr (yyp, yyarg[yyi++]);
1193 yyformat += 2;
1195 else
1197 yyp++;
1198 yyformat++;
1201 return 0;
1203 #endif /* YYERROR_VERBOSE */
1205 /*-----------------------------------------------.
1206 | Release the memory associated to this symbol. |
1207 `-----------------------------------------------*/
1209 /*ARGSUSED*/
1210 #if (defined __STDC__ || defined __C99__FUNC__ \
1211 || defined __cplusplus || defined _MSC_VER)
1212 static void
1213 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1214 #else
1215 static void
1216 yydestruct (yymsg, yytype, yyvaluep)
1217 const char *yymsg;
1218 int yytype;
1219 YYSTYPE *yyvaluep;
1220 #endif
1222 YYUSE (yyvaluep);
1224 if (!yymsg)
1225 yymsg = "Deleting";
1226 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1228 switch (yytype)
1231 default:
1232 break;
1237 /* Prevent warnings from -Wmissing-prototypes. */
1238 #ifdef YYPARSE_PARAM
1239 #if defined __STDC__ || defined __cplusplus
1240 int yyparse (void *YYPARSE_PARAM);
1241 #else
1242 int yyparse ();
1243 #endif
1244 #else /* ! YYPARSE_PARAM */
1245 #if defined __STDC__ || defined __cplusplus
1246 int yyparse (void);
1247 #else
1248 int yyparse ();
1249 #endif
1250 #endif /* ! YYPARSE_PARAM */
1253 /*----------.
1254 | yyparse. |
1255 `----------*/
1257 #ifdef YYPARSE_PARAM
1258 #if (defined __STDC__ || defined __C99__FUNC__ \
1259 || defined __cplusplus || defined _MSC_VER)
1261 yyparse (void *YYPARSE_PARAM)
1262 #else
1264 yyparse (YYPARSE_PARAM)
1265 void *YYPARSE_PARAM;
1266 #endif
1267 #else /* ! YYPARSE_PARAM */
1268 #if (defined __STDC__ || defined __C99__FUNC__ \
1269 || defined __cplusplus || defined _MSC_VER)
1271 yyparse (void)
1272 #else
1274 yyparse ()
1276 #endif
1277 #endif
1279 /* The lookahead symbol. */
1280 int yychar;
1282 /* The semantic value of the lookahead symbol. */
1283 YYSTYPE yylval;
1285 /* Number of syntax errors so far. */
1286 int yynerrs;
1288 int yystate;
1289 /* Number of tokens to shift before error messages enabled. */
1290 int yyerrstatus;
1292 /* The stacks and their tools:
1293 `yyss': related to states.
1294 `yyvs': related to semantic values.
1296 Refer to the stacks thru separate pointers, to allow yyoverflow
1297 to reallocate them elsewhere. */
1299 /* The state stack. */
1300 yytype_int16 yyssa[YYINITDEPTH];
1301 yytype_int16 *yyss;
1302 yytype_int16 *yyssp;
1304 /* The semantic value stack. */
1305 YYSTYPE yyvsa[YYINITDEPTH];
1306 YYSTYPE *yyvs;
1307 YYSTYPE *yyvsp;
1309 YYSIZE_T yystacksize;
1311 int yyn;
1312 int yyresult;
1313 /* Lookahead token as an internal (translated) token number. */
1314 int yytoken;
1315 /* The variables used to return semantic value and location from the
1316 action routines. */
1317 YYSTYPE yyval;
1319 #if YYERROR_VERBOSE
1320 /* Buffer for error messages, and its allocated size. */
1321 char yymsgbuf[128];
1322 char *yymsg = yymsgbuf;
1323 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1324 #endif
1326 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1328 /* The number of symbols on the RHS of the reduced rule.
1329 Keep to zero when no symbol should be popped. */
1330 int yylen = 0;
1332 yytoken = 0;
1333 yyss = yyssa;
1334 yyvs = yyvsa;
1335 yystacksize = YYINITDEPTH;
1337 YYDPRINTF ((stderr, "Starting parse\n"));
1339 yystate = 0;
1340 yyerrstatus = 0;
1341 yynerrs = 0;
1342 yychar = YYEMPTY; /* Cause a token to be read. */
1344 /* Initialize stack pointers.
1345 Waste one element of value and location stack
1346 so that they stay on the same level as the state stack.
1347 The wasted elements are never initialized. */
1348 yyssp = yyss;
1349 yyvsp = yyvs;
1351 goto yysetstate;
1353 /*------------------------------------------------------------.
1354 | yynewstate -- Push a new state, which is found in yystate. |
1355 `------------------------------------------------------------*/
1356 yynewstate:
1357 /* In all cases, when you get here, the value and location stacks
1358 have just been pushed. So pushing a state here evens the stacks. */
1359 yyssp++;
1361 yysetstate:
1362 *yyssp = yystate;
1364 if (yyss + yystacksize - 1 <= yyssp)
1366 /* Get the current used size of the three stacks, in elements. */
1367 YYSIZE_T yysize = yyssp - yyss + 1;
1369 #ifdef yyoverflow
1371 /* Give user a chance to reallocate the stack. Use copies of
1372 these so that the &'s don't force the real ones into
1373 memory. */
1374 YYSTYPE *yyvs1 = yyvs;
1375 yytype_int16 *yyss1 = yyss;
1377 /* Each stack pointer address is followed by the size of the
1378 data in use in that stack, in bytes. This used to be a
1379 conditional around just the two extra args, but that might
1380 be undefined if yyoverflow is a macro. */
1381 yyoverflow (YY_("memory exhausted"),
1382 &yyss1, yysize * sizeof (*yyssp),
1383 &yyvs1, yysize * sizeof (*yyvsp),
1384 &yystacksize);
1386 yyss = yyss1;
1387 yyvs = yyvs1;
1389 #else /* no yyoverflow */
1390 # ifndef YYSTACK_RELOCATE
1391 goto yyexhaustedlab;
1392 # else
1393 /* Extend the stack our own way. */
1394 if (YYMAXDEPTH <= yystacksize)
1395 goto yyexhaustedlab;
1396 yystacksize *= 2;
1397 if (YYMAXDEPTH < yystacksize)
1398 yystacksize = YYMAXDEPTH;
1401 yytype_int16 *yyss1 = yyss;
1402 union yyalloc *yyptr =
1403 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1404 if (! yyptr)
1405 goto yyexhaustedlab;
1406 YYSTACK_RELOCATE (yyss_alloc, yyss);
1407 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1408 # undef YYSTACK_RELOCATE
1409 if (yyss1 != yyssa)
1410 YYSTACK_FREE (yyss1);
1412 # endif
1413 #endif /* no yyoverflow */
1415 yyssp = yyss + yysize - 1;
1416 yyvsp = yyvs + yysize - 1;
1418 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1419 (unsigned long int) yystacksize));
1421 if (yyss + yystacksize - 1 <= yyssp)
1422 YYABORT;
1425 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1427 if (yystate == YYFINAL)
1428 YYACCEPT;
1430 goto yybackup;
1432 /*-----------.
1433 | yybackup. |
1434 `-----------*/
1435 yybackup:
1437 /* Do appropriate processing given the current state. Read a
1438 lookahead token if we need one and don't already have one. */
1440 /* First try to decide what to do without reference to lookahead token. */
1441 yyn = yypact[yystate];
1442 if (yypact_value_is_default (yyn))
1443 goto yydefault;
1445 /* Not known => get a lookahead token if don't already have one. */
1447 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1448 if (yychar == YYEMPTY)
1450 YYDPRINTF ((stderr, "Reading a token: "));
1451 yychar = YYLEX;
1454 if (yychar <= YYEOF)
1456 yychar = yytoken = YYEOF;
1457 YYDPRINTF ((stderr, "Now at end of input.\n"));
1459 else
1461 yytoken = YYTRANSLATE (yychar);
1462 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1465 /* If the proper action on seeing token YYTOKEN is to reduce or to
1466 detect an error, take that action. */
1467 yyn += yytoken;
1468 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1469 goto yydefault;
1470 yyn = yytable[yyn];
1471 if (yyn <= 0)
1473 if (yytable_value_is_error (yyn))
1474 goto yyerrlab;
1475 yyn = -yyn;
1476 goto yyreduce;
1479 /* Count tokens shifted since error; after three, turn off error
1480 status. */
1481 if (yyerrstatus)
1482 yyerrstatus--;
1484 /* Shift the lookahead token. */
1485 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1487 /* Discard the shifted token. */
1488 yychar = YYEMPTY;
1490 yystate = yyn;
1491 *++yyvsp = yylval;
1493 goto yynewstate;
1496 /*-----------------------------------------------------------.
1497 | yydefault -- do the default action for the current state. |
1498 `-----------------------------------------------------------*/
1499 yydefault:
1500 yyn = yydefact[yystate];
1501 if (yyn == 0)
1502 goto yyerrlab;
1503 goto yyreduce;
1506 /*-----------------------------.
1507 | yyreduce -- Do a reduction. |
1508 `-----------------------------*/
1509 yyreduce:
1510 /* yyn is the number of a rule to reduce with. */
1511 yylen = yyr2[yyn];
1513 /* If YYLEN is nonzero, implement the default value of the action:
1514 `$$ = $1'.
1516 Otherwise, the following line sets YYVAL to garbage.
1517 This behavior is undocumented and Bison
1518 users should not rely upon it. Assigning to YYVAL
1519 unconditionally makes the parser a bit smaller, and it avoids a
1520 GCC warning that YYVAL may be used uninitialized. */
1521 yyval = yyvsp[1-yylen];
1524 YY_REDUCE_PRINT (yyn);
1525 switch (yyn)
1527 case 2:
1529 /* Line 1806 of yacc.c */
1530 #line 175 "plural.y"
1532 if ((yyvsp[(1) - (1)].exp) == NULL)
1533 YYABORT;
1534 ((struct parse_args *) arg)->res = (yyvsp[(1) - (1)].exp);
1536 break;
1538 case 3:
1540 /* Line 1806 of yacc.c */
1541 #line 183 "plural.y"
1543 (yyval.exp) = new_exp_3 (qmop, (yyvsp[(1) - (5)].exp), (yyvsp[(3) - (5)].exp), (yyvsp[(5) - (5)].exp));
1545 break;
1547 case 4:
1549 /* Line 1806 of yacc.c */
1550 #line 187 "plural.y"
1552 (yyval.exp) = new_exp_2 (lor, (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1554 break;
1556 case 5:
1558 /* Line 1806 of yacc.c */
1559 #line 191 "plural.y"
1561 (yyval.exp) = new_exp_2 (land, (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1563 break;
1565 case 6:
1567 /* Line 1806 of yacc.c */
1568 #line 195 "plural.y"
1570 (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1572 break;
1574 case 7:
1576 /* Line 1806 of yacc.c */
1577 #line 199 "plural.y"
1579 (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1581 break;
1583 case 8:
1585 /* Line 1806 of yacc.c */
1586 #line 203 "plural.y"
1588 (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1590 break;
1592 case 9:
1594 /* Line 1806 of yacc.c */
1595 #line 207 "plural.y"
1597 (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1599 break;
1601 case 10:
1603 /* Line 1806 of yacc.c */
1604 #line 211 "plural.y"
1606 (yyval.exp) = new_exp_1 (lnot, (yyvsp[(2) - (2)].exp));
1608 break;
1610 case 11:
1612 /* Line 1806 of yacc.c */
1613 #line 215 "plural.y"
1615 (yyval.exp) = new_exp_0 (var);
1617 break;
1619 case 12:
1621 /* Line 1806 of yacc.c */
1622 #line 219 "plural.y"
1624 if (((yyval.exp) = new_exp_0 (num)) != NULL)
1625 (yyval.exp)->val.num = (yyvsp[(1) - (1)].num);
1627 break;
1629 case 13:
1631 /* Line 1806 of yacc.c */
1632 #line 224 "plural.y"
1634 (yyval.exp) = (yyvsp[(2) - (3)].exp);
1636 break;
1640 /* Line 1806 of yacc.c */
1641 #line 1642 "plural.c"
1642 default: break;
1644 /* User semantic actions sometimes alter yychar, and that requires
1645 that yytoken be updated with the new translation. We take the
1646 approach of translating immediately before every use of yytoken.
1647 One alternative is translating here after every semantic action,
1648 but that translation would be missed if the semantic action invokes
1649 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1650 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1651 incorrect destructor might then be invoked immediately. In the
1652 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1653 to an incorrect destructor call or verbose syntax error message
1654 before the lookahead is translated. */
1655 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1657 YYPOPSTACK (yylen);
1658 yylen = 0;
1659 YY_STACK_PRINT (yyss, yyssp);
1661 *++yyvsp = yyval;
1663 /* Now `shift' the result of the reduction. Determine what state
1664 that goes to, based on the state we popped back to and the rule
1665 number reduced by. */
1667 yyn = yyr1[yyn];
1669 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1670 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1671 yystate = yytable[yystate];
1672 else
1673 yystate = yydefgoto[yyn - YYNTOKENS];
1675 goto yynewstate;
1678 /*------------------------------------.
1679 | yyerrlab -- here on detecting error |
1680 `------------------------------------*/
1681 yyerrlab:
1682 /* Make sure we have latest lookahead translation. See comments at
1683 user semantic actions for why this is necessary. */
1684 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1686 /* If not already recovering from an error, report this error. */
1687 if (!yyerrstatus)
1689 ++yynerrs;
1690 #if ! YYERROR_VERBOSE
1691 yyerror (YY_("syntax error"));
1692 #else
1693 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1694 yyssp, yytoken)
1696 char const *yymsgp = YY_("syntax error");
1697 int yysyntax_error_status;
1698 yysyntax_error_status = YYSYNTAX_ERROR;
1699 if (yysyntax_error_status == 0)
1700 yymsgp = yymsg;
1701 else if (yysyntax_error_status == 1)
1703 if (yymsg != yymsgbuf)
1704 YYSTACK_FREE (yymsg);
1705 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1706 if (!yymsg)
1708 yymsg = yymsgbuf;
1709 yymsg_alloc = sizeof yymsgbuf;
1710 yysyntax_error_status = 2;
1712 else
1714 yysyntax_error_status = YYSYNTAX_ERROR;
1715 yymsgp = yymsg;
1718 yyerror (yymsgp);
1719 if (yysyntax_error_status == 2)
1720 goto yyexhaustedlab;
1722 # undef YYSYNTAX_ERROR
1723 #endif
1728 if (yyerrstatus == 3)
1730 /* If just tried and failed to reuse lookahead token after an
1731 error, discard it. */
1733 if (yychar <= YYEOF)
1735 /* Return failure if at end of input. */
1736 if (yychar == YYEOF)
1737 YYABORT;
1739 else
1741 yydestruct ("Error: discarding",
1742 yytoken, &yylval);
1743 yychar = YYEMPTY;
1747 /* Else will try to reuse lookahead token after shifting the error
1748 token. */
1749 goto yyerrlab1;
1752 /*---------------------------------------------------.
1753 | yyerrorlab -- error raised explicitly by YYERROR. |
1754 `---------------------------------------------------*/
1755 yyerrorlab:
1757 /* Pacify compilers like GCC when the user code never invokes
1758 YYERROR and the label yyerrorlab therefore never appears in user
1759 code. */
1760 if (/*CONSTCOND*/ 0)
1761 goto yyerrorlab;
1763 /* Do not reclaim the symbols of the rule which action triggered
1764 this YYERROR. */
1765 YYPOPSTACK (yylen);
1766 yylen = 0;
1767 YY_STACK_PRINT (yyss, yyssp);
1768 yystate = *yyssp;
1769 goto yyerrlab1;
1772 /*-------------------------------------------------------------.
1773 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1774 `-------------------------------------------------------------*/
1775 yyerrlab1:
1776 yyerrstatus = 3; /* Each real token shifted decrements this. */
1778 for (;;)
1780 yyn = yypact[yystate];
1781 if (!yypact_value_is_default (yyn))
1783 yyn += YYTERROR;
1784 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1786 yyn = yytable[yyn];
1787 if (0 < yyn)
1788 break;
1792 /* Pop the current state because it cannot handle the error token. */
1793 if (yyssp == yyss)
1794 YYABORT;
1797 yydestruct ("Error: popping",
1798 yystos[yystate], yyvsp);
1799 YYPOPSTACK (1);
1800 yystate = *yyssp;
1801 YY_STACK_PRINT (yyss, yyssp);
1804 *++yyvsp = yylval;
1807 /* Shift the error token. */
1808 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1810 yystate = yyn;
1811 goto yynewstate;
1814 /*-------------------------------------.
1815 | yyacceptlab -- YYACCEPT comes here. |
1816 `-------------------------------------*/
1817 yyacceptlab:
1818 yyresult = 0;
1819 goto yyreturn;
1821 /*-----------------------------------.
1822 | yyabortlab -- YYABORT comes here. |
1823 `-----------------------------------*/
1824 yyabortlab:
1825 yyresult = 1;
1826 goto yyreturn;
1828 #if !defined(yyoverflow) || YYERROR_VERBOSE
1829 /*-------------------------------------------------.
1830 | yyexhaustedlab -- memory exhaustion comes here. |
1831 `-------------------------------------------------*/
1832 yyexhaustedlab:
1833 yyerror (YY_("memory exhausted"));
1834 yyresult = 2;
1835 /* Fall through. */
1836 #endif
1838 yyreturn:
1839 if (yychar != YYEMPTY)
1841 /* Make sure we have latest lookahead translation. See comments at
1842 user semantic actions for why this is necessary. */
1843 yytoken = YYTRANSLATE (yychar);
1844 yydestruct ("Cleanup: discarding lookahead",
1845 yytoken, &yylval);
1847 /* Do not reclaim the symbols of the rule which action triggered
1848 this YYABORT or YYACCEPT. */
1849 YYPOPSTACK (yylen);
1850 YY_STACK_PRINT (yyss, yyssp);
1851 while (yyssp != yyss)
1853 yydestruct ("Cleanup: popping",
1854 yystos[*yyssp], yyvsp);
1855 YYPOPSTACK (1);
1857 #ifndef yyoverflow
1858 if (yyss != yyssa)
1859 YYSTACK_FREE (yyss);
1860 #endif
1861 #if YYERROR_VERBOSE
1862 if (yymsg != yymsgbuf)
1863 YYSTACK_FREE (yymsg);
1864 #endif
1865 /* Make sure YYID is used. */
1866 return YYID (yyresult);
1871 /* Line 2067 of yacc.c */
1872 #line 229 "plural.y"
1875 void
1876 internal_function
1877 FREE_EXPRESSION (exp)
1878 struct expression *exp;
1880 if (exp == NULL)
1881 return;
1883 /* Handle the recursive case. */
1884 switch (exp->nargs)
1886 case 3:
1887 FREE_EXPRESSION (exp->val.args[2]);
1888 /* FALLTHROUGH */
1889 case 2:
1890 FREE_EXPRESSION (exp->val.args[1]);
1891 /* FALLTHROUGH */
1892 case 1:
1893 FREE_EXPRESSION (exp->val.args[0]);
1894 /* FALLTHROUGH */
1895 default:
1896 break;
1899 free (exp);
1903 static int
1904 yylex (lval, pexp)
1905 YYSTYPE *lval;
1906 const char **pexp;
1908 const char *exp = *pexp;
1909 int result;
1911 while (1)
1913 if (exp[0] == '\0')
1915 *pexp = exp;
1916 return YYEOF;
1919 if (exp[0] != ' ' && exp[0] != '\t')
1920 break;
1922 ++exp;
1925 result = *exp++;
1926 switch (result)
1928 case '0': case '1': case '2': case '3': case '4':
1929 case '5': case '6': case '7': case '8': case '9':
1931 unsigned long int n = result - '0';
1932 while (exp[0] >= '0' && exp[0] <= '9')
1934 n *= 10;
1935 n += exp[0] - '0';
1936 ++exp;
1938 lval->num = n;
1939 result = NUMBER;
1941 break;
1943 case '=':
1944 if (exp[0] == '=')
1946 ++exp;
1947 lval->op = equal;
1948 result = EQUOP2;
1950 else
1951 result = YYERRCODE;
1952 break;
1954 case '!':
1955 if (exp[0] == '=')
1957 ++exp;
1958 lval->op = not_equal;
1959 result = EQUOP2;
1961 break;
1963 case '&':
1964 case '|':
1965 if (exp[0] == result)
1966 ++exp;
1967 else
1968 result = YYERRCODE;
1969 break;
1971 case '<':
1972 if (exp[0] == '=')
1974 ++exp;
1975 lval->op = less_or_equal;
1977 else
1978 lval->op = less_than;
1979 result = CMPOP2;
1980 break;
1982 case '>':
1983 if (exp[0] == '=')
1985 ++exp;
1986 lval->op = greater_or_equal;
1988 else
1989 lval->op = greater_than;
1990 result = CMPOP2;
1991 break;
1993 case '*':
1994 lval->op = mult;
1995 result = MULOP2;
1996 break;
1998 case '/':
1999 lval->op = divide;
2000 result = MULOP2;
2001 break;
2003 case '%':
2004 lval->op = module;
2005 result = MULOP2;
2006 break;
2008 case '+':
2009 lval->op = plus;
2010 result = ADDOP2;
2011 break;
2013 case '-':
2014 lval->op = minus;
2015 result = ADDOP2;
2016 break;
2018 case 'n':
2019 case '?':
2020 case ':':
2021 case '(':
2022 case ')':
2023 /* Nothing, just return the character. */
2024 break;
2026 case ';':
2027 case '\n':
2028 case '\0':
2029 /* Be safe and let the user call this function again. */
2030 --exp;
2031 result = YYEOF;
2032 break;
2034 default:
2035 result = YYERRCODE;
2036 #if YYDEBUG != 0
2037 --exp;
2038 #endif
2039 break;
2042 *pexp = exp;
2044 return result;
2048 static void
2049 yyerror (str)
2050 const char *str;
2052 /* Do nothing. We don't print error messages here. */