Update copyright notices with scripts/update-copyrights
[glibc.git] / intl / plural.c
blob1bac3c06664c81b3434e81d286a235466d5f0091
1 /* A Bison parser, made by GNU Bison 2.7. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2012 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.7"
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
62 /* Substitute the variable and function names. */
63 #define yyparse __gettextparse
64 #define yylex __gettextlex
65 #define yyerror __gettexterror
66 #define yylval __gettextlval
67 #define yychar __gettextchar
68 #define yydebug __gettextdebug
69 #define yynerrs __gettextnerrs
71 /* Copy the first part of user declarations. */
72 /* Line 371 of yacc.c */
73 #line 1 "plural.y"
75 /* Expression parsing for plural form selection.
76 Copyright (C) 2000-2014 Free Software Foundation, Inc.
77 This file is part of the GNU C Library.
78 Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
80 The GNU C Library is free software; you can redistribute it and/or
81 modify it under the terms of the GNU Lesser General Public
82 License as published by the Free Software Foundation; either
83 version 2.1 of the License, or (at your option) any later version.
85 The GNU C Library is distributed in the hope that it will be useful,
86 but WITHOUT ANY WARRANTY; without even the implied warranty of
87 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
88 Lesser General Public License for more details.
90 You should have received a copy of the GNU Lesser General Public
91 License along with the GNU C Library; if not, see
92 <http://www.gnu.org/licenses/>. */
94 /* The bison generated parser uses alloca. AIX 3 forces us to put this
95 declaration at the beginning of the file. The declaration in bison's
96 skeleton file comes too late. This must come before <config.h>
97 because <config.h> may include arbitrary system headers. */
98 #if defined _AIX && !defined __GNUC__
99 #pragma alloca
100 #endif
101 #ifdef HAVE_CONFIG_H
102 # include <config.h>
103 #endif
105 #include <stddef.h>
106 #include <stdlib.h>
107 #include <string.h>
108 #include "plural-exp.h"
110 /* The main function generated by the parser is called __gettextparse,
111 but we want it to be called PLURAL_PARSE. */
112 #ifndef _LIBC
113 # define __gettextparse PLURAL_PARSE
114 #endif
116 #define YYLEX_PARAM &((struct parse_args *) arg)->cp
117 #define YYPARSE_PARAM arg
119 /* Line 371 of yacc.c */
120 #line 121 "plural.c"
122 # ifndef YY_NULL
123 # if defined __cplusplus && 201103L <= __cplusplus
124 # define YY_NULL nullptr
125 # else
126 # define YY_NULL 0
127 # endif
128 # endif
130 /* Enabling verbose error messages. */
131 #ifdef YYERROR_VERBOSE
132 # undef YYERROR_VERBOSE
133 # define YYERROR_VERBOSE 1
134 #else
135 # define YYERROR_VERBOSE 0
136 #endif
139 /* Enabling traces. */
140 #ifndef YYDEBUG
141 # define YYDEBUG 0
142 #endif
143 #if YYDEBUG
144 extern int __gettextdebug;
145 #endif
147 /* Tokens. */
148 #ifndef YYTOKENTYPE
149 # define YYTOKENTYPE
150 /* Put the tokens into the symbol table, so that GDB and other debuggers
151 know about them. */
152 enum yytokentype {
153 EQUOP2 = 258,
154 CMPOP2 = 259,
155 ADDOP2 = 260,
156 MULOP2 = 261,
157 NUMBER = 262
159 #endif
160 /* Tokens. */
161 #define EQUOP2 258
162 #define CMPOP2 259
163 #define ADDOP2 260
164 #define MULOP2 261
165 #define NUMBER 262
169 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
170 typedef union YYSTYPE
172 /* Line 387 of yacc.c */
173 #line 49 "plural.y"
175 unsigned long int num;
176 enum operator op;
177 struct expression *exp;
180 /* Line 387 of yacc.c */
181 #line 182 "plural.c"
182 } YYSTYPE;
183 # define YYSTYPE_IS_TRIVIAL 1
184 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
185 # define YYSTYPE_IS_DECLARED 1
186 #endif
189 #ifdef YYPARSE_PARAM
190 #if defined __STDC__ || defined __cplusplus
191 int __gettextparse (void *YYPARSE_PARAM);
192 #else
193 int __gettextparse ();
194 #endif
195 #else /* ! YYPARSE_PARAM */
196 #if defined __STDC__ || defined __cplusplus
197 int __gettextparse (void);
198 #else
199 int __gettextparse ();
200 #endif
201 #endif /* ! YYPARSE_PARAM */
205 /* Copy the second part of user declarations. */
206 /* Line 390 of yacc.c */
207 #line 55 "plural.y"
209 /* Prototypes for local functions. */
210 static struct expression *new_exp PARAMS ((int nargs, enum operator op,
211 struct expression * const *args));
212 static inline struct expression *new_exp_0 PARAMS ((enum operator op));
213 static inline struct expression *new_exp_1 PARAMS ((enum operator op,
214 struct expression *right));
215 static struct expression *new_exp_2 PARAMS ((enum operator op,
216 struct expression *left,
217 struct expression *right));
218 static inline struct expression *new_exp_3 PARAMS ((enum operator op,
219 struct expression *bexp,
220 struct expression *tbranch,
221 struct expression *fbranch));
222 static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
223 static void yyerror PARAMS ((const char *str));
225 /* Allocation of expressions. */
227 static struct expression *
228 new_exp (nargs, op, args)
229 int nargs;
230 enum operator op;
231 struct expression * const *args;
233 int i;
234 struct expression *newp;
236 /* If any of the argument could not be malloc'ed, just return NULL. */
237 for (i = nargs - 1; i >= 0; i--)
238 if (args[i] == NULL)
239 goto fail;
241 /* Allocate a new expression. */
242 newp = (struct expression *) malloc (sizeof (*newp));
243 if (newp != NULL)
245 newp->nargs = nargs;
246 newp->operation = op;
247 for (i = nargs - 1; i >= 0; i--)
248 newp->val.args[i] = args[i];
249 return newp;
252 fail:
253 for (i = nargs - 1; i >= 0; i--)
254 FREE_EXPRESSION (args[i]);
256 return NULL;
259 static inline struct expression *
260 new_exp_0 (op)
261 enum operator op;
263 return new_exp (0, op, NULL);
266 static inline struct expression *
267 new_exp_1 (op, right)
268 enum operator op;
269 struct expression *right;
271 struct expression *args[1];
273 args[0] = right;
274 return new_exp (1, op, args);
277 static struct expression *
278 new_exp_2 (op, left, right)
279 enum operator op;
280 struct expression *left;
281 struct expression *right;
283 struct expression *args[2];
285 args[0] = left;
286 args[1] = right;
287 return new_exp (2, op, args);
290 static inline struct expression *
291 new_exp_3 (op, bexp, tbranch, fbranch)
292 enum operator op;
293 struct expression *bexp;
294 struct expression *tbranch;
295 struct expression *fbranch;
297 struct expression *args[3];
299 args[0] = bexp;
300 args[1] = tbranch;
301 args[2] = fbranch;
302 return new_exp (3, op, args);
306 /* Line 390 of yacc.c */
307 #line 308 "plural.c"
309 #ifdef short
310 # undef short
311 #endif
313 #ifdef YYTYPE_UINT8
314 typedef YYTYPE_UINT8 yytype_uint8;
315 #else
316 typedef unsigned char yytype_uint8;
317 #endif
319 #ifdef YYTYPE_INT8
320 typedef YYTYPE_INT8 yytype_int8;
321 #elif (defined __STDC__ || defined __C99__FUNC__ \
322 || defined __cplusplus || defined _MSC_VER)
323 typedef signed char yytype_int8;
324 #else
325 typedef short int yytype_int8;
326 #endif
328 #ifdef YYTYPE_UINT16
329 typedef YYTYPE_UINT16 yytype_uint16;
330 #else
331 typedef unsigned short int yytype_uint16;
332 #endif
334 #ifdef YYTYPE_INT16
335 typedef YYTYPE_INT16 yytype_int16;
336 #else
337 typedef short int yytype_int16;
338 #endif
340 #ifndef YYSIZE_T
341 # ifdef __SIZE_TYPE__
342 # define YYSIZE_T __SIZE_TYPE__
343 # elif defined size_t
344 # define YYSIZE_T size_t
345 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
346 || defined __cplusplus || defined _MSC_VER)
347 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
348 # define YYSIZE_T size_t
349 # else
350 # define YYSIZE_T unsigned int
351 # endif
352 #endif
354 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
356 #ifndef YY_
357 # if defined YYENABLE_NLS && YYENABLE_NLS
358 # if ENABLE_NLS
359 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
360 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
361 # endif
362 # endif
363 # ifndef YY_
364 # define YY_(Msgid) Msgid
365 # endif
366 #endif
368 /* Suppress unused-variable warnings by "using" E. */
369 #if ! defined lint || defined __GNUC__
370 # define YYUSE(E) ((void) (E))
371 #else
372 # define YYUSE(E) /* empty */
373 #endif
375 /* Identity function, used to suppress warnings about constant conditions. */
376 #ifndef lint
377 # define YYID(N) (N)
378 #else
379 #if (defined __STDC__ || defined __C99__FUNC__ \
380 || defined __cplusplus || defined _MSC_VER)
381 static int
382 YYID (int yyi)
383 #else
384 static int
385 YYID (yyi)
386 int yyi;
387 #endif
389 return yyi;
391 #endif
393 #if ! defined yyoverflow || YYERROR_VERBOSE
395 /* The parser invokes alloca or malloc; define the necessary symbols. */
397 # ifdef YYSTACK_USE_ALLOCA
398 # if YYSTACK_USE_ALLOCA
399 # ifdef __GNUC__
400 # define YYSTACK_ALLOC __builtin_alloca
401 # elif defined __BUILTIN_VA_ARG_INCR
402 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
403 # elif defined _AIX
404 # define YYSTACK_ALLOC __alloca
405 # elif defined _MSC_VER
406 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
407 # define alloca _alloca
408 # else
409 # define YYSTACK_ALLOC alloca
410 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
411 || defined __cplusplus || defined _MSC_VER)
412 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
413 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
414 # ifndef EXIT_SUCCESS
415 # define EXIT_SUCCESS 0
416 # endif
417 # endif
418 # endif
419 # endif
420 # endif
422 # ifdef YYSTACK_ALLOC
423 /* Pacify GCC's `empty if-body' warning. */
424 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
425 # ifndef YYSTACK_ALLOC_MAXIMUM
426 /* The OS might guarantee only one guard page at the bottom of the stack,
427 and a page size can be as small as 4096 bytes. So we cannot safely
428 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
429 to allow for a few compiler-allocated temporary stack slots. */
430 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
431 # endif
432 # else
433 # define YYSTACK_ALLOC YYMALLOC
434 # define YYSTACK_FREE YYFREE
435 # ifndef YYSTACK_ALLOC_MAXIMUM
436 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
437 # endif
438 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
439 && ! ((defined YYMALLOC || defined malloc) \
440 && (defined YYFREE || defined free)))
441 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
442 # ifndef EXIT_SUCCESS
443 # define EXIT_SUCCESS 0
444 # endif
445 # endif
446 # ifndef YYMALLOC
447 # define YYMALLOC malloc
448 # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
449 || defined __cplusplus || defined _MSC_VER)
450 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
451 # endif
452 # endif
453 # ifndef YYFREE
454 # define YYFREE free
455 # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
456 || defined __cplusplus || defined _MSC_VER)
457 void free (void *); /* INFRINGES ON USER NAME SPACE */
458 # endif
459 # endif
460 # endif
461 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
464 #if (! defined yyoverflow \
465 && (! defined __cplusplus \
466 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
468 /* A type that is properly aligned for any stack member. */
469 union yyalloc
471 yytype_int16 yyss_alloc;
472 YYSTYPE yyvs_alloc;
475 /* The size of the maximum gap between one aligned stack and the next. */
476 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
478 /* The size of an array large to enough to hold all stacks, each with
479 N elements. */
480 # define YYSTACK_BYTES(N) \
481 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
482 + YYSTACK_GAP_MAXIMUM)
484 # define YYCOPY_NEEDED 1
486 /* Relocate STACK from its old location to the new one. The
487 local variables YYSIZE and YYSTACKSIZE give the old and new number of
488 elements in the stack, and YYPTR gives the new location of the
489 stack. Advance YYPTR to a properly aligned location for the next
490 stack. */
491 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
492 do \
494 YYSIZE_T yynewbytes; \
495 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
496 Stack = &yyptr->Stack_alloc; \
497 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
498 yyptr += yynewbytes / sizeof (*yyptr); \
500 while (YYID (0))
502 #endif
504 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
505 /* Copy COUNT objects from SRC to DST. The source and destination do
506 not overlap. */
507 # ifndef YYCOPY
508 # if defined __GNUC__ && 1 < __GNUC__
509 # define YYCOPY(Dst, Src, Count) \
510 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
511 # else
512 # define YYCOPY(Dst, Src, Count) \
513 do \
515 YYSIZE_T yyi; \
516 for (yyi = 0; yyi < (Count); yyi++) \
517 (Dst)[yyi] = (Src)[yyi]; \
519 while (YYID (0))
520 # endif
521 # endif
522 #endif /* !YYCOPY_NEEDED */
524 /* YYFINAL -- State number of the termination state. */
525 #define YYFINAL 9
526 /* YYLAST -- Last index in YYTABLE. */
527 #define YYLAST 54
529 /* YYNTOKENS -- Number of terminals. */
530 #define YYNTOKENS 16
531 /* YYNNTS -- Number of nonterminals. */
532 #define YYNNTS 3
533 /* YYNRULES -- Number of rules. */
534 #define YYNRULES 13
535 /* YYNRULES -- Number of states. */
536 #define YYNSTATES 27
538 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
539 #define YYUNDEFTOK 2
540 #define YYMAXUTOK 262
542 #define YYTRANSLATE(YYX) \
543 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
545 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
546 static const yytype_uint8 yytranslate[] =
548 0, 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, 10, 2, 2, 2, 2, 5, 2,
552 14, 15, 2, 2, 2, 2, 2, 2, 2, 2,
553 2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
554 2, 2, 2, 3, 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 13, 2, 2, 2, 2, 2, 2, 2, 2, 2,
560 2, 2, 2, 2, 4, 2, 2, 2, 2, 2,
561 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
562 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
563 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
564 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
565 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
566 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
567 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
568 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
569 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
570 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
571 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
572 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
573 2, 2, 2, 2, 2, 2, 1, 2, 6, 7,
574 8, 9, 11
577 #if YYDEBUG
578 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
579 YYRHS. */
580 static const yytype_uint8 yyprhs[] =
582 0, 0, 3, 5, 11, 15, 19, 23, 27, 31,
583 35, 38, 40, 42
586 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
587 static const yytype_int8 yyrhs[] =
589 17, 0, -1, 18, -1, 18, 3, 18, 12, 18,
590 -1, 18, 4, 18, -1, 18, 5, 18, -1, 18,
591 6, 18, -1, 18, 7, 18, -1, 18, 8, 18,
592 -1, 18, 9, 18, -1, 10, 18, -1, 13, -1,
593 11, -1, 14, 18, 15, -1
596 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
597 static const yytype_uint8 yyrline[] =
599 0, 174, 174, 182, 186, 190, 194, 198, 202, 206,
600 210, 214, 218, 223
602 #endif
604 #if YYDEBUG || YYERROR_VERBOSE || 0
605 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
606 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
607 static const char *const yytname[] =
609 "$end", "error", "$undefined", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
610 "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
611 "$accept", "start", "exp", YY_NULL
613 #endif
615 # ifdef YYPRINT
616 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
617 token YYLEX-NUM. */
618 static const yytype_uint16 yytoknum[] =
620 0, 256, 257, 63, 124, 38, 258, 259, 260, 261,
621 33, 262, 58, 110, 40, 41
623 # endif
625 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
626 static const yytype_uint8 yyr1[] =
628 0, 16, 17, 18, 18, 18, 18, 18, 18, 18,
629 18, 18, 18, 18
632 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
633 static const yytype_uint8 yyr2[] =
635 0, 2, 1, 5, 3, 3, 3, 3, 3, 3,
636 2, 1, 1, 3
639 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
640 Performed when YYTABLE doesn't specify something else to do. Zero
641 means the default is an error. */
642 static const yytype_uint8 yydefact[] =
644 0, 0, 12, 11, 0, 0, 2, 10, 0, 1,
645 0, 0, 0, 0, 0, 0, 0, 13, 0, 4,
646 5, 6, 7, 8, 9, 0, 3
649 /* YYDEFGOTO[NTERM-NUM]. */
650 static const yytype_int8 yydefgoto[] =
652 -1, 5, 6
655 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
656 STATE-NUM. */
657 #define YYPACT_NINF -10
658 static const yytype_int8 yypact[] =
660 -9, -9, -10, -10, -9, 8, 36, -10, 13, -10,
661 -9, -9, -9, -9, -9, -9, -9, -10, 26, 41,
662 45, 18, -2, 14, -10, -9, 36
665 /* YYPGOTO[NTERM-NUM]. */
666 static const yytype_int8 yypgoto[] =
668 -10, -10, -1
671 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
672 positive, shift that token. If negative, reduce the rule which
673 number is the opposite. If YYTABLE_NINF, syntax error. */
674 #define YYTABLE_NINF -1
675 static const yytype_uint8 yytable[] =
677 7, 1, 2, 8, 3, 4, 15, 16, 9, 18,
678 19, 20, 21, 22, 23, 24, 10, 11, 12, 13,
679 14, 15, 16, 16, 26, 14, 15, 16, 17, 10,
680 11, 12, 13, 14, 15, 16, 0, 0, 25, 10,
681 11, 12, 13, 14, 15, 16, 12, 13, 14, 15,
682 16, 13, 14, 15, 16
685 #define yypact_value_is_default(Yystate) \
686 (!!((Yystate) == (-10)))
688 #define yytable_value_is_error(Yytable_value) \
689 YYID (0)
691 static const yytype_int8 yycheck[] =
693 1, 10, 11, 4, 13, 14, 8, 9, 0, 10,
694 11, 12, 13, 14, 15, 16, 3, 4, 5, 6,
695 7, 8, 9, 9, 25, 7, 8, 9, 15, 3,
696 4, 5, 6, 7, 8, 9, -1, -1, 12, 3,
697 4, 5, 6, 7, 8, 9, 5, 6, 7, 8,
698 9, 6, 7, 8, 9
701 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
702 symbol of state STATE-NUM. */
703 static const yytype_uint8 yystos[] =
705 0, 10, 11, 13, 14, 17, 18, 18, 18, 0,
706 3, 4, 5, 6, 7, 8, 9, 15, 18, 18,
707 18, 18, 18, 18, 18, 12, 18
710 #define yyerrok (yyerrstatus = 0)
711 #define yyclearin (yychar = YYEMPTY)
712 #define YYEMPTY (-2)
713 #define YYEOF 0
715 #define YYACCEPT goto yyacceptlab
716 #define YYABORT goto yyabortlab
717 #define YYERROR goto yyerrorlab
720 /* Like YYERROR except do call yyerror. This remains here temporarily
721 to ease the transition to the new meaning of YYERROR, for GCC.
722 Once GCC version 2 has supplanted version 1, this can go. However,
723 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
724 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
725 discussed. */
727 #define YYFAIL goto yyerrlab
728 #if defined YYFAIL
729 /* This is here to suppress warnings from the GCC cpp's
730 -Wunused-macros. Normally we don't worry about that warning, but
731 some users do, and we want to make it easy for users to remove
732 YYFAIL uses, which will produce warnings from Bison 2.5. */
733 #endif
735 #define YYRECOVERING() (!!yyerrstatus)
737 #define YYBACKUP(Token, Value) \
738 do \
739 if (yychar == YYEMPTY) \
741 yychar = (Token); \
742 yylval = (Value); \
743 YYPOPSTACK (yylen); \
744 yystate = *yyssp; \
745 goto yybackup; \
747 else \
749 yyerror (YY_("syntax error: cannot back up")); \
750 YYERROR; \
752 while (YYID (0))
754 /* Error token number */
755 #define YYTERROR 1
756 #define YYERRCODE 256
759 /* This macro is provided for backward compatibility. */
760 #ifndef YY_LOCATION_PRINT
761 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
762 #endif
765 /* YYLEX -- calling `yylex' with the right arguments. */
766 #ifdef YYLEX_PARAM
767 # define YYLEX yylex (&yylval, YYLEX_PARAM)
768 #else
769 # define YYLEX yylex (&yylval)
770 #endif
772 /* Enable debugging if requested. */
773 #if YYDEBUG
775 # ifndef YYFPRINTF
776 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
777 # define YYFPRINTF fprintf
778 # endif
780 # define YYDPRINTF(Args) \
781 do { \
782 if (yydebug) \
783 YYFPRINTF Args; \
784 } while (YYID (0))
786 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
787 do { \
788 if (yydebug) \
790 YYFPRINTF (stderr, "%s ", Title); \
791 yy_symbol_print (stderr, \
792 Type, Value); \
793 YYFPRINTF (stderr, "\n"); \
795 } while (YYID (0))
798 /*--------------------------------.
799 | Print this symbol on YYOUTPUT. |
800 `--------------------------------*/
802 /*ARGSUSED*/
803 #if (defined __STDC__ || defined __C99__FUNC__ \
804 || defined __cplusplus || defined _MSC_VER)
805 static void
806 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
807 #else
808 static void
809 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
810 FILE *yyoutput;
811 int yytype;
812 YYSTYPE const * const yyvaluep;
813 #endif
815 FILE *yyo = yyoutput;
816 YYUSE (yyo);
817 if (!yyvaluep)
818 return;
819 # ifdef YYPRINT
820 if (yytype < YYNTOKENS)
821 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
822 # else
823 YYUSE (yyoutput);
824 # endif
825 switch (yytype)
827 default:
828 break;
833 /*--------------------------------.
834 | Print this symbol on YYOUTPUT. |
835 `--------------------------------*/
837 #if (defined __STDC__ || defined __C99__FUNC__ \
838 || defined __cplusplus || defined _MSC_VER)
839 static void
840 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
841 #else
842 static void
843 yy_symbol_print (yyoutput, yytype, yyvaluep)
844 FILE *yyoutput;
845 int yytype;
846 YYSTYPE const * const yyvaluep;
847 #endif
849 if (yytype < YYNTOKENS)
850 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
851 else
852 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
854 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
855 YYFPRINTF (yyoutput, ")");
858 /*------------------------------------------------------------------.
859 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
860 | TOP (included). |
861 `------------------------------------------------------------------*/
863 #if (defined __STDC__ || defined __C99__FUNC__ \
864 || defined __cplusplus || defined _MSC_VER)
865 static void
866 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
867 #else
868 static void
869 yy_stack_print (yybottom, yytop)
870 yytype_int16 *yybottom;
871 yytype_int16 *yytop;
872 #endif
874 YYFPRINTF (stderr, "Stack now");
875 for (; yybottom <= yytop; yybottom++)
877 int yybot = *yybottom;
878 YYFPRINTF (stderr, " %d", yybot);
880 YYFPRINTF (stderr, "\n");
883 # define YY_STACK_PRINT(Bottom, Top) \
884 do { \
885 if (yydebug) \
886 yy_stack_print ((Bottom), (Top)); \
887 } while (YYID (0))
890 /*------------------------------------------------.
891 | Report that the YYRULE is going to be reduced. |
892 `------------------------------------------------*/
894 #if (defined __STDC__ || defined __C99__FUNC__ \
895 || defined __cplusplus || defined _MSC_VER)
896 static void
897 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
898 #else
899 static void
900 yy_reduce_print (yyvsp, yyrule)
901 YYSTYPE *yyvsp;
902 int yyrule;
903 #endif
905 int yynrhs = yyr2[yyrule];
906 int yyi;
907 unsigned long int yylno = yyrline[yyrule];
908 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
909 yyrule - 1, yylno);
910 /* The symbols being reduced. */
911 for (yyi = 0; yyi < yynrhs; yyi++)
913 YYFPRINTF (stderr, " $%d = ", yyi + 1);
914 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
915 &(yyvsp[(yyi + 1) - (yynrhs)])
917 YYFPRINTF (stderr, "\n");
921 # define YY_REDUCE_PRINT(Rule) \
922 do { \
923 if (yydebug) \
924 yy_reduce_print (yyvsp, Rule); \
925 } while (YYID (0))
927 /* Nonzero means print parse trace. It is left uninitialized so that
928 multiple parsers can coexist. */
929 int yydebug;
930 #else /* !YYDEBUG */
931 # define YYDPRINTF(Args)
932 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
933 # define YY_STACK_PRINT(Bottom, Top)
934 # define YY_REDUCE_PRINT(Rule)
935 #endif /* !YYDEBUG */
938 /* YYINITDEPTH -- initial size of the parser's stacks. */
939 #ifndef YYINITDEPTH
940 # define YYINITDEPTH 200
941 #endif
943 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
944 if the built-in stack extension method is used).
946 Do not make this value too large; the results are undefined if
947 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
948 evaluated with infinite-precision integer arithmetic. */
950 #ifndef YYMAXDEPTH
951 # define YYMAXDEPTH 10000
952 #endif
955 #if YYERROR_VERBOSE
957 # ifndef yystrlen
958 # if defined __GLIBC__ && defined _STRING_H
959 # define yystrlen strlen
960 # else
961 /* Return the length of YYSTR. */
962 #if (defined __STDC__ || defined __C99__FUNC__ \
963 || defined __cplusplus || defined _MSC_VER)
964 static YYSIZE_T
965 yystrlen (const char *yystr)
966 #else
967 static YYSIZE_T
968 yystrlen (yystr)
969 const char *yystr;
970 #endif
972 YYSIZE_T yylen;
973 for (yylen = 0; yystr[yylen]; yylen++)
974 continue;
975 return yylen;
977 # endif
978 # endif
980 # ifndef yystpcpy
981 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
982 # define yystpcpy stpcpy
983 # else
984 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
985 YYDEST. */
986 #if (defined __STDC__ || defined __C99__FUNC__ \
987 || defined __cplusplus || defined _MSC_VER)
988 static char *
989 yystpcpy (char *yydest, const char *yysrc)
990 #else
991 static char *
992 yystpcpy (yydest, yysrc)
993 char *yydest;
994 const char *yysrc;
995 #endif
997 char *yyd = yydest;
998 const char *yys = yysrc;
1000 while ((*yyd++ = *yys++) != '\0')
1001 continue;
1003 return yyd - 1;
1005 # endif
1006 # endif
1008 # ifndef yytnamerr
1009 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1010 quotes and backslashes, so that it's suitable for yyerror. The
1011 heuristic is that double-quoting is unnecessary unless the string
1012 contains an apostrophe, a comma, or backslash (other than
1013 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1014 null, do not copy; instead, return the length of what the result
1015 would have been. */
1016 static YYSIZE_T
1017 yytnamerr (char *yyres, const char *yystr)
1019 if (*yystr == '"')
1021 YYSIZE_T yyn = 0;
1022 char const *yyp = yystr;
1024 for (;;)
1025 switch (*++yyp)
1027 case '\'':
1028 case ',':
1029 goto do_not_strip_quotes;
1031 case '\\':
1032 if (*++yyp != '\\')
1033 goto do_not_strip_quotes;
1034 /* Fall through. */
1035 default:
1036 if (yyres)
1037 yyres[yyn] = *yyp;
1038 yyn++;
1039 break;
1041 case '"':
1042 if (yyres)
1043 yyres[yyn] = '\0';
1044 return yyn;
1046 do_not_strip_quotes: ;
1049 if (! yyres)
1050 return yystrlen (yystr);
1052 return yystpcpy (yyres, yystr) - yyres;
1054 # endif
1056 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1057 about the unexpected token YYTOKEN for the state stack whose top is
1058 YYSSP.
1060 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1061 not large enough to hold the message. In that case, also set
1062 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1063 required number of bytes is too large to store. */
1064 static int
1065 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1066 yytype_int16 *yyssp, int yytoken)
1068 YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
1069 YYSIZE_T yysize = yysize0;
1070 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1071 /* Internationalized format string. */
1072 const char *yyformat = YY_NULL;
1073 /* Arguments of yyformat. */
1074 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1075 /* Number of reported tokens (one for the "unexpected", one per
1076 "expected"). */
1077 int yycount = 0;
1079 /* There are many possibilities here to consider:
1080 - Assume YYFAIL is not used. It's too flawed to consider. See
1081 <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1082 for details. YYERROR is fine as it does not invoke this
1083 function.
1084 - If this state is a consistent state with a default action, then
1085 the only way this function was invoked is if the default action
1086 is an error action. In that case, don't check for expected
1087 tokens because there are none.
1088 - The only way there can be no lookahead present (in yychar) is if
1089 this state is a consistent state with a default action. Thus,
1090 detecting the absence of a lookahead is sufficient to determine
1091 that there is no unexpected or expected token to report. In that
1092 case, just report a simple "syntax error".
1093 - Don't assume there isn't a lookahead just because this state is a
1094 consistent state with a default action. There might have been a
1095 previous inconsistent state, consistent state with a non-default
1096 action, or user semantic action that manipulated yychar.
1097 - Of course, the expected token list depends on states to have
1098 correct lookahead information, and it depends on the parser not
1099 to perform extra reductions after fetching a lookahead from the
1100 scanner and before detecting a syntax error. Thus, state merging
1101 (from LALR or IELR) and default reductions corrupt the expected
1102 token list. However, the list is correct for canonical LR with
1103 one exception: it will still contain any token that will not be
1104 accepted due to an error action in a later state.
1106 if (yytoken != YYEMPTY)
1108 int yyn = yypact[*yyssp];
1109 yyarg[yycount++] = yytname[yytoken];
1110 if (!yypact_value_is_default (yyn))
1112 /* Start YYX at -YYN if negative to avoid negative indexes in
1113 YYCHECK. In other words, skip the first -YYN actions for
1114 this state because they are default actions. */
1115 int yyxbegin = yyn < 0 ? -yyn : 0;
1116 /* Stay within bounds of both yycheck and yytname. */
1117 int yychecklim = YYLAST - yyn + 1;
1118 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1119 int yyx;
1121 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1122 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1123 && !yytable_value_is_error (yytable[yyx + yyn]))
1125 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1127 yycount = 1;
1128 yysize = yysize0;
1129 break;
1131 yyarg[yycount++] = yytname[yyx];
1133 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
1134 if (! (yysize <= yysize1
1135 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1136 return 2;
1137 yysize = yysize1;
1143 switch (yycount)
1145 # define YYCASE_(N, S) \
1146 case N: \
1147 yyformat = S; \
1148 break
1149 YYCASE_(0, YY_("syntax error"));
1150 YYCASE_(1, YY_("syntax error, unexpected %s"));
1151 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1152 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1153 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1154 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1155 # undef YYCASE_
1159 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1160 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1161 return 2;
1162 yysize = yysize1;
1165 if (*yymsg_alloc < yysize)
1167 *yymsg_alloc = 2 * yysize;
1168 if (! (yysize <= *yymsg_alloc
1169 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1170 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1171 return 1;
1174 /* Avoid sprintf, as that infringes on the user's name space.
1175 Don't have undefined behavior even if the translation
1176 produced a string with the wrong number of "%s"s. */
1178 char *yyp = *yymsg;
1179 int yyi = 0;
1180 while ((*yyp = *yyformat) != '\0')
1181 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1183 yyp += yytnamerr (yyp, yyarg[yyi++]);
1184 yyformat += 2;
1186 else
1188 yyp++;
1189 yyformat++;
1192 return 0;
1194 #endif /* YYERROR_VERBOSE */
1196 /*-----------------------------------------------.
1197 | Release the memory associated to this symbol. |
1198 `-----------------------------------------------*/
1200 /*ARGSUSED*/
1201 #if (defined __STDC__ || defined __C99__FUNC__ \
1202 || defined __cplusplus || defined _MSC_VER)
1203 static void
1204 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1205 #else
1206 static void
1207 yydestruct (yymsg, yytype, yyvaluep)
1208 const char *yymsg;
1209 int yytype;
1210 YYSTYPE *yyvaluep;
1211 #endif
1213 YYUSE (yyvaluep);
1215 if (!yymsg)
1216 yymsg = "Deleting";
1217 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1219 switch (yytype)
1222 default:
1223 break;
1230 /*----------.
1231 | yyparse. |
1232 `----------*/
1234 #ifdef YYPARSE_PARAM
1235 #if (defined __STDC__ || defined __C99__FUNC__ \
1236 || defined __cplusplus || defined _MSC_VER)
1238 yyparse (void *YYPARSE_PARAM)
1239 #else
1241 yyparse (YYPARSE_PARAM)
1242 void *YYPARSE_PARAM;
1243 #endif
1244 #else /* ! YYPARSE_PARAM */
1245 #if (defined __STDC__ || defined __C99__FUNC__ \
1246 || defined __cplusplus || defined _MSC_VER)
1248 yyparse (void)
1249 #else
1251 yyparse ()
1253 #endif
1254 #endif
1256 /* The lookahead symbol. */
1257 int yychar;
1260 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
1261 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
1262 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
1263 _Pragma ("GCC diagnostic push") \
1264 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
1265 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
1266 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
1267 _Pragma ("GCC diagnostic pop")
1268 #else
1269 /* Default value used for initialization, for pacifying older GCCs
1270 or non-GCC compilers. */
1271 static YYSTYPE yyval_default;
1272 # define YY_INITIAL_VALUE(Value) = Value
1273 #endif
1274 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1275 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1276 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
1277 #endif
1278 #ifndef YY_INITIAL_VALUE
1279 # define YY_INITIAL_VALUE(Value) /* Nothing. */
1280 #endif
1282 /* The semantic value of the lookahead symbol. */
1283 YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
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 through 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 = 0;
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 yyssp = yyss = yyssa;
1333 yyvsp = yyvs = yyvsa;
1334 yystacksize = YYINITDEPTH;
1336 YYDPRINTF ((stderr, "Starting parse\n"));
1338 yystate = 0;
1339 yyerrstatus = 0;
1340 yynerrs = 0;
1341 yychar = YYEMPTY; /* Cause a token to be read. */
1342 goto yysetstate;
1344 /*------------------------------------------------------------.
1345 | yynewstate -- Push a new state, which is found in yystate. |
1346 `------------------------------------------------------------*/
1347 yynewstate:
1348 /* In all cases, when you get here, the value and location stacks
1349 have just been pushed. So pushing a state here evens the stacks. */
1350 yyssp++;
1352 yysetstate:
1353 *yyssp = yystate;
1355 if (yyss + yystacksize - 1 <= yyssp)
1357 /* Get the current used size of the three stacks, in elements. */
1358 YYSIZE_T yysize = yyssp - yyss + 1;
1360 #ifdef yyoverflow
1362 /* Give user a chance to reallocate the stack. Use copies of
1363 these so that the &'s don't force the real ones into
1364 memory. */
1365 YYSTYPE *yyvs1 = yyvs;
1366 yytype_int16 *yyss1 = yyss;
1368 /* Each stack pointer address is followed by the size of the
1369 data in use in that stack, in bytes. This used to be a
1370 conditional around just the two extra args, but that might
1371 be undefined if yyoverflow is a macro. */
1372 yyoverflow (YY_("memory exhausted"),
1373 &yyss1, yysize * sizeof (*yyssp),
1374 &yyvs1, yysize * sizeof (*yyvsp),
1375 &yystacksize);
1377 yyss = yyss1;
1378 yyvs = yyvs1;
1380 #else /* no yyoverflow */
1381 # ifndef YYSTACK_RELOCATE
1382 goto yyexhaustedlab;
1383 # else
1384 /* Extend the stack our own way. */
1385 if (YYMAXDEPTH <= yystacksize)
1386 goto yyexhaustedlab;
1387 yystacksize *= 2;
1388 if (YYMAXDEPTH < yystacksize)
1389 yystacksize = YYMAXDEPTH;
1392 yytype_int16 *yyss1 = yyss;
1393 union yyalloc *yyptr =
1394 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1395 if (! yyptr)
1396 goto yyexhaustedlab;
1397 YYSTACK_RELOCATE (yyss_alloc, yyss);
1398 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1399 # undef YYSTACK_RELOCATE
1400 if (yyss1 != yyssa)
1401 YYSTACK_FREE (yyss1);
1403 # endif
1404 #endif /* no yyoverflow */
1406 yyssp = yyss + yysize - 1;
1407 yyvsp = yyvs + yysize - 1;
1409 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1410 (unsigned long int) yystacksize));
1412 if (yyss + yystacksize - 1 <= yyssp)
1413 YYABORT;
1416 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1418 if (yystate == YYFINAL)
1419 YYACCEPT;
1421 goto yybackup;
1423 /*-----------.
1424 | yybackup. |
1425 `-----------*/
1426 yybackup:
1428 /* Do appropriate processing given the current state. Read a
1429 lookahead token if we need one and don't already have one. */
1431 /* First try to decide what to do without reference to lookahead token. */
1432 yyn = yypact[yystate];
1433 if (yypact_value_is_default (yyn))
1434 goto yydefault;
1436 /* Not known => get a lookahead token if don't already have one. */
1438 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1439 if (yychar == YYEMPTY)
1441 YYDPRINTF ((stderr, "Reading a token: "));
1442 yychar = YYLEX;
1445 if (yychar <= YYEOF)
1447 yychar = yytoken = YYEOF;
1448 YYDPRINTF ((stderr, "Now at end of input.\n"));
1450 else
1452 yytoken = YYTRANSLATE (yychar);
1453 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1456 /* If the proper action on seeing token YYTOKEN is to reduce or to
1457 detect an error, take that action. */
1458 yyn += yytoken;
1459 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1460 goto yydefault;
1461 yyn = yytable[yyn];
1462 if (yyn <= 0)
1464 if (yytable_value_is_error (yyn))
1465 goto yyerrlab;
1466 yyn = -yyn;
1467 goto yyreduce;
1470 /* Count tokens shifted since error; after three, turn off error
1471 status. */
1472 if (yyerrstatus)
1473 yyerrstatus--;
1475 /* Shift the lookahead token. */
1476 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1478 /* Discard the shifted token. */
1479 yychar = YYEMPTY;
1481 yystate = yyn;
1482 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1483 *++yyvsp = yylval;
1484 YY_IGNORE_MAYBE_UNINITIALIZED_END
1486 goto yynewstate;
1489 /*-----------------------------------------------------------.
1490 | yydefault -- do the default action for the current state. |
1491 `-----------------------------------------------------------*/
1492 yydefault:
1493 yyn = yydefact[yystate];
1494 if (yyn == 0)
1495 goto yyerrlab;
1496 goto yyreduce;
1499 /*-----------------------------.
1500 | yyreduce -- Do a reduction. |
1501 `-----------------------------*/
1502 yyreduce:
1503 /* yyn is the number of a rule to reduce with. */
1504 yylen = yyr2[yyn];
1506 /* If YYLEN is nonzero, implement the default value of the action:
1507 `$$ = $1'.
1509 Otherwise, the following line sets YYVAL to garbage.
1510 This behavior is undocumented and Bison
1511 users should not rely upon it. Assigning to YYVAL
1512 unconditionally makes the parser a bit smaller, and it avoids a
1513 GCC warning that YYVAL may be used uninitialized. */
1514 yyval = yyvsp[1-yylen];
1517 YY_REDUCE_PRINT (yyn);
1518 switch (yyn)
1520 case 2:
1521 /* Line 1792 of yacc.c */
1522 #line 175 "plural.y"
1524 if ((yyvsp[(1) - (1)].exp) == NULL)
1525 YYABORT;
1526 ((struct parse_args *) arg)->res = (yyvsp[(1) - (1)].exp);
1528 break;
1530 case 3:
1531 /* Line 1792 of yacc.c */
1532 #line 183 "plural.y"
1534 (yyval.exp) = new_exp_3 (qmop, (yyvsp[(1) - (5)].exp), (yyvsp[(3) - (5)].exp), (yyvsp[(5) - (5)].exp));
1536 break;
1538 case 4:
1539 /* Line 1792 of yacc.c */
1540 #line 187 "plural.y"
1542 (yyval.exp) = new_exp_2 (lor, (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1544 break;
1546 case 5:
1547 /* Line 1792 of yacc.c */
1548 #line 191 "plural.y"
1550 (yyval.exp) = new_exp_2 (land, (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1552 break;
1554 case 6:
1555 /* Line 1792 of yacc.c */
1556 #line 195 "plural.y"
1558 (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1560 break;
1562 case 7:
1563 /* Line 1792 of yacc.c */
1564 #line 199 "plural.y"
1566 (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1568 break;
1570 case 8:
1571 /* Line 1792 of yacc.c */
1572 #line 203 "plural.y"
1574 (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1576 break;
1578 case 9:
1579 /* Line 1792 of yacc.c */
1580 #line 207 "plural.y"
1582 (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1584 break;
1586 case 10:
1587 /* Line 1792 of yacc.c */
1588 #line 211 "plural.y"
1590 (yyval.exp) = new_exp_1 (lnot, (yyvsp[(2) - (2)].exp));
1592 break;
1594 case 11:
1595 /* Line 1792 of yacc.c */
1596 #line 215 "plural.y"
1598 (yyval.exp) = new_exp_0 (var);
1600 break;
1602 case 12:
1603 /* Line 1792 of yacc.c */
1604 #line 219 "plural.y"
1606 if (((yyval.exp) = new_exp_0 (num)) != NULL)
1607 (yyval.exp)->val.num = (yyvsp[(1) - (1)].num);
1609 break;
1611 case 13:
1612 /* Line 1792 of yacc.c */
1613 #line 224 "plural.y"
1615 (yyval.exp) = (yyvsp[(2) - (3)].exp);
1617 break;
1620 /* Line 1792 of yacc.c */
1621 #line 1622 "plural.c"
1622 default: break;
1624 /* User semantic actions sometimes alter yychar, and that requires
1625 that yytoken be updated with the new translation. We take the
1626 approach of translating immediately before every use of yytoken.
1627 One alternative is translating here after every semantic action,
1628 but that translation would be missed if the semantic action invokes
1629 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1630 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1631 incorrect destructor might then be invoked immediately. In the
1632 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1633 to an incorrect destructor call or verbose syntax error message
1634 before the lookahead is translated. */
1635 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1637 YYPOPSTACK (yylen);
1638 yylen = 0;
1639 YY_STACK_PRINT (yyss, yyssp);
1641 *++yyvsp = yyval;
1643 /* Now `shift' the result of the reduction. Determine what state
1644 that goes to, based on the state we popped back to and the rule
1645 number reduced by. */
1647 yyn = yyr1[yyn];
1649 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1650 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1651 yystate = yytable[yystate];
1652 else
1653 yystate = yydefgoto[yyn - YYNTOKENS];
1655 goto yynewstate;
1658 /*------------------------------------.
1659 | yyerrlab -- here on detecting error |
1660 `------------------------------------*/
1661 yyerrlab:
1662 /* Make sure we have latest lookahead translation. See comments at
1663 user semantic actions for why this is necessary. */
1664 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1666 /* If not already recovering from an error, report this error. */
1667 if (!yyerrstatus)
1669 ++yynerrs;
1670 #if ! YYERROR_VERBOSE
1671 yyerror (YY_("syntax error"));
1672 #else
1673 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1674 yyssp, yytoken)
1676 char const *yymsgp = YY_("syntax error");
1677 int yysyntax_error_status;
1678 yysyntax_error_status = YYSYNTAX_ERROR;
1679 if (yysyntax_error_status == 0)
1680 yymsgp = yymsg;
1681 else if (yysyntax_error_status == 1)
1683 if (yymsg != yymsgbuf)
1684 YYSTACK_FREE (yymsg);
1685 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1686 if (!yymsg)
1688 yymsg = yymsgbuf;
1689 yymsg_alloc = sizeof yymsgbuf;
1690 yysyntax_error_status = 2;
1692 else
1694 yysyntax_error_status = YYSYNTAX_ERROR;
1695 yymsgp = yymsg;
1698 yyerror (yymsgp);
1699 if (yysyntax_error_status == 2)
1700 goto yyexhaustedlab;
1702 # undef YYSYNTAX_ERROR
1703 #endif
1708 if (yyerrstatus == 3)
1710 /* If just tried and failed to reuse lookahead token after an
1711 error, discard it. */
1713 if (yychar <= YYEOF)
1715 /* Return failure if at end of input. */
1716 if (yychar == YYEOF)
1717 YYABORT;
1719 else
1721 yydestruct ("Error: discarding",
1722 yytoken, &yylval);
1723 yychar = YYEMPTY;
1727 /* Else will try to reuse lookahead token after shifting the error
1728 token. */
1729 goto yyerrlab1;
1732 /*---------------------------------------------------.
1733 | yyerrorlab -- error raised explicitly by YYERROR. |
1734 `---------------------------------------------------*/
1735 yyerrorlab:
1737 /* Pacify compilers like GCC when the user code never invokes
1738 YYERROR and the label yyerrorlab therefore never appears in user
1739 code. */
1740 if (/*CONSTCOND*/ 0)
1741 goto yyerrorlab;
1743 /* Do not reclaim the symbols of the rule which action triggered
1744 this YYERROR. */
1745 YYPOPSTACK (yylen);
1746 yylen = 0;
1747 YY_STACK_PRINT (yyss, yyssp);
1748 yystate = *yyssp;
1749 goto yyerrlab1;
1752 /*-------------------------------------------------------------.
1753 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1754 `-------------------------------------------------------------*/
1755 yyerrlab1:
1756 yyerrstatus = 3; /* Each real token shifted decrements this. */
1758 for (;;)
1760 yyn = yypact[yystate];
1761 if (!yypact_value_is_default (yyn))
1763 yyn += YYTERROR;
1764 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1766 yyn = yytable[yyn];
1767 if (0 < yyn)
1768 break;
1772 /* Pop the current state because it cannot handle the error token. */
1773 if (yyssp == yyss)
1774 YYABORT;
1777 yydestruct ("Error: popping",
1778 yystos[yystate], yyvsp);
1779 YYPOPSTACK (1);
1780 yystate = *yyssp;
1781 YY_STACK_PRINT (yyss, yyssp);
1784 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1785 *++yyvsp = yylval;
1786 YY_IGNORE_MAYBE_UNINITIALIZED_END
1789 /* Shift the error token. */
1790 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1792 yystate = yyn;
1793 goto yynewstate;
1796 /*-------------------------------------.
1797 | yyacceptlab -- YYACCEPT comes here. |
1798 `-------------------------------------*/
1799 yyacceptlab:
1800 yyresult = 0;
1801 goto yyreturn;
1803 /*-----------------------------------.
1804 | yyabortlab -- YYABORT comes here. |
1805 `-----------------------------------*/
1806 yyabortlab:
1807 yyresult = 1;
1808 goto yyreturn;
1810 #if !defined yyoverflow || YYERROR_VERBOSE
1811 /*-------------------------------------------------.
1812 | yyexhaustedlab -- memory exhaustion comes here. |
1813 `-------------------------------------------------*/
1814 yyexhaustedlab:
1815 yyerror (YY_("memory exhausted"));
1816 yyresult = 2;
1817 /* Fall through. */
1818 #endif
1820 yyreturn:
1821 if (yychar != YYEMPTY)
1823 /* Make sure we have latest lookahead translation. See comments at
1824 user semantic actions for why this is necessary. */
1825 yytoken = YYTRANSLATE (yychar);
1826 yydestruct ("Cleanup: discarding lookahead",
1827 yytoken, &yylval);
1829 /* Do not reclaim the symbols of the rule which action triggered
1830 this YYABORT or YYACCEPT. */
1831 YYPOPSTACK (yylen);
1832 YY_STACK_PRINT (yyss, yyssp);
1833 while (yyssp != yyss)
1835 yydestruct ("Cleanup: popping",
1836 yystos[*yyssp], yyvsp);
1837 YYPOPSTACK (1);
1839 #ifndef yyoverflow
1840 if (yyss != yyssa)
1841 YYSTACK_FREE (yyss);
1842 #endif
1843 #if YYERROR_VERBOSE
1844 if (yymsg != yymsgbuf)
1845 YYSTACK_FREE (yymsg);
1846 #endif
1847 /* Make sure YYID is used. */
1848 return YYID (yyresult);
1852 /* Line 2055 of yacc.c */
1853 #line 229 "plural.y"
1856 void
1857 internal_function
1858 FREE_EXPRESSION (exp)
1859 struct expression *exp;
1861 if (exp == NULL)
1862 return;
1864 /* Handle the recursive case. */
1865 switch (exp->nargs)
1867 case 3:
1868 FREE_EXPRESSION (exp->val.args[2]);
1869 /* FALLTHROUGH */
1870 case 2:
1871 FREE_EXPRESSION (exp->val.args[1]);
1872 /* FALLTHROUGH */
1873 case 1:
1874 FREE_EXPRESSION (exp->val.args[0]);
1875 /* FALLTHROUGH */
1876 default:
1877 break;
1880 free (exp);
1884 static int
1885 yylex (lval, pexp)
1886 YYSTYPE *lval;
1887 const char **pexp;
1889 const char *exp = *pexp;
1890 int result;
1892 while (1)
1894 if (exp[0] == '\0')
1896 *pexp = exp;
1897 return YYEOF;
1900 if (exp[0] != ' ' && exp[0] != '\t')
1901 break;
1903 ++exp;
1906 result = *exp++;
1907 switch (result)
1909 case '0': case '1': case '2': case '3': case '4':
1910 case '5': case '6': case '7': case '8': case '9':
1912 unsigned long int n = result - '0';
1913 while (exp[0] >= '0' && exp[0] <= '9')
1915 n *= 10;
1916 n += exp[0] - '0';
1917 ++exp;
1919 lval->num = n;
1920 result = NUMBER;
1922 break;
1924 case '=':
1925 if (exp[0] == '=')
1927 ++exp;
1928 lval->op = equal;
1929 result = EQUOP2;
1931 else
1932 result = YYERRCODE;
1933 break;
1935 case '!':
1936 if (exp[0] == '=')
1938 ++exp;
1939 lval->op = not_equal;
1940 result = EQUOP2;
1942 break;
1944 case '&':
1945 case '|':
1946 if (exp[0] == result)
1947 ++exp;
1948 else
1949 result = YYERRCODE;
1950 break;
1952 case '<':
1953 if (exp[0] == '=')
1955 ++exp;
1956 lval->op = less_or_equal;
1958 else
1959 lval->op = less_than;
1960 result = CMPOP2;
1961 break;
1963 case '>':
1964 if (exp[0] == '=')
1966 ++exp;
1967 lval->op = greater_or_equal;
1969 else
1970 lval->op = greater_than;
1971 result = CMPOP2;
1972 break;
1974 case '*':
1975 lval->op = mult;
1976 result = MULOP2;
1977 break;
1979 case '/':
1980 lval->op = divide;
1981 result = MULOP2;
1982 break;
1984 case '%':
1985 lval->op = module;
1986 result = MULOP2;
1987 break;
1989 case '+':
1990 lval->op = plus;
1991 result = ADDOP2;
1992 break;
1994 case '-':
1995 lval->op = minus;
1996 result = ADDOP2;
1997 break;
1999 case 'n':
2000 case '?':
2001 case ':':
2002 case '(':
2003 case ')':
2004 /* Nothing, just return the character. */
2005 break;
2007 case ';':
2008 case '\n':
2009 case '\0':
2010 /* Be safe and let the user call this function again. */
2011 --exp;
2012 result = YYEOF;
2013 break;
2015 default:
2016 result = YYERRCODE;
2017 #if YYDEBUG != 0
2018 --exp;
2019 #endif
2020 break;
2023 *pexp = exp;
2025 return result;
2029 static void
2030 yyerror (str)
2031 const char *str;
2033 /* Do nothing. We don't print error messages here. */