Installed header hygiene (BZ#20366): Test of installed headers.
[glibc.git] / intl / plural.c
bloba94af3c542b1aeadebbe02d67dabd2d535f70726
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 2
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-2016 Free Software Foundation, Inc.
77 Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
79 This program is free software: you can redistribute it and/or modify
80 it under the terms of the GNU Lesser General Public License as published by
81 the Free Software Foundation; either version 2.1 of the License, or
82 (at your option) any later version.
84 This program is distributed in the hope that it will be useful,
85 but WITHOUT ANY WARRANTY; without even the implied warranty of
86 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
87 GNU Lesser General Public License for more details.
89 You should have received a copy of the GNU Lesser General Public License
90 along with this program. If not, see <http://www.gnu.org/licenses/>. */
92 /* For bison < 2.0, the bison generated parser uses alloca. AIX 3 forces us
93 to put this declaration at the beginning of the file. The declaration in
94 bison's skeleton file comes too late. This must come before <config.h>
95 because <config.h> may include arbitrary system headers.
96 This can go away once the AM_INTL_SUBDIR macro requires bison >= 2.0. */
97 #if defined _AIX && !defined __GNUC__
98 #pragma alloca
99 #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
117 /* Line 371 of yacc.c */
118 #line 119 "plural.c"
120 # ifndef YY_NULL
121 # if defined __cplusplus && 201103L <= __cplusplus
122 # define YY_NULL nullptr
123 # else
124 # define YY_NULL 0
125 # endif
126 # endif
128 /* Enabling verbose error messages. */
129 #ifdef YYERROR_VERBOSE
130 # undef YYERROR_VERBOSE
131 # define YYERROR_VERBOSE 1
132 #else
133 # define YYERROR_VERBOSE 0
134 #endif
137 /* Enabling traces. */
138 #ifndef YYDEBUG
139 # define YYDEBUG 0
140 #endif
141 #if YYDEBUG
142 extern int __gettextdebug;
143 #endif
145 /* Tokens. */
146 #ifndef YYTOKENTYPE
147 # define YYTOKENTYPE
148 /* Put the tokens into the symbol table, so that GDB and other debuggers
149 know about them. */
150 enum yytokentype {
151 EQUOP2 = 258,
152 CMPOP2 = 259,
153 ADDOP2 = 260,
154 MULOP2 = 261,
155 NUMBER = 262
157 #endif
158 /* Tokens. */
159 #define EQUOP2 258
160 #define CMPOP2 259
161 #define ADDOP2 260
162 #define MULOP2 261
163 #define NUMBER 262
167 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
168 typedef union YYSTYPE
170 /* Line 387 of yacc.c */
171 #line 49 "plural.y"
173 unsigned long int num;
174 enum expression_operator op;
175 struct expression *exp;
178 /* Line 387 of yacc.c */
179 #line 180 "plural.c"
180 } YYSTYPE;
181 # define YYSTYPE_IS_TRIVIAL 1
182 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
183 # define YYSTYPE_IS_DECLARED 1
184 #endif
187 #ifdef YYPARSE_PARAM
188 #if defined __STDC__ || defined __cplusplus
189 int __gettextparse (void *YYPARSE_PARAM);
190 #else
191 int __gettextparse ();
192 #endif
193 #else /* ! YYPARSE_PARAM */
194 #if defined __STDC__ || defined __cplusplus
195 int __gettextparse (struct parse_args *arg);
196 #else
197 int __gettextparse ();
198 #endif
199 #endif /* ! YYPARSE_PARAM */
203 /* Copy the second part of user declarations. */
204 /* Line 390 of yacc.c */
205 #line 55 "plural.y"
207 /* Prototypes for local functions. */
208 static int yylex (YYSTYPE *lval, struct parse_args *arg);
209 static void yyerror (struct parse_args *arg, const char *str);
211 /* Allocation of expressions. */
213 static struct expression *
214 new_exp (int nargs, enum expression_operator op,
215 struct expression * const *args)
217 int i;
218 struct expression *newp;
220 /* If any of the argument could not be malloc'ed, just return NULL. */
221 for (i = nargs - 1; i >= 0; i--)
222 if (args[i] == NULL)
223 goto fail;
225 /* Allocate a new expression. */
226 newp = (struct expression *) malloc (sizeof (*newp));
227 if (newp != NULL)
229 newp->nargs = nargs;
230 newp->operation = op;
231 for (i = nargs - 1; i >= 0; i--)
232 newp->val.args[i] = args[i];
233 return newp;
236 fail:
237 for (i = nargs - 1; i >= 0; i--)
238 FREE_EXPRESSION (args[i]);
240 return NULL;
243 static inline struct expression *
244 new_exp_0 (enum expression_operator op)
246 return new_exp (0, op, NULL);
249 static inline struct expression *
250 new_exp_1 (enum expression_operator op, struct expression *right)
252 struct expression *args[1];
254 args[0] = right;
255 return new_exp (1, op, args);
258 static struct expression *
259 new_exp_2 (enum expression_operator op, struct expression *left,
260 struct expression *right)
262 struct expression *args[2];
264 args[0] = left;
265 args[1] = right;
266 return new_exp (2, op, args);
269 static inline struct expression *
270 new_exp_3 (enum expression_operator op, struct expression *bexp,
271 struct expression *tbranch, struct expression *fbranch)
273 struct expression *args[3];
275 args[0] = bexp;
276 args[1] = tbranch;
277 args[2] = fbranch;
278 return new_exp (3, op, args);
282 /* Line 390 of yacc.c */
283 #line 284 "plural.c"
285 #ifdef short
286 # undef short
287 #endif
289 #ifdef YYTYPE_UINT8
290 typedef YYTYPE_UINT8 yytype_uint8;
291 #else
292 typedef unsigned char yytype_uint8;
293 #endif
295 #ifdef YYTYPE_INT8
296 typedef YYTYPE_INT8 yytype_int8;
297 #elif (defined __STDC__ || defined __C99__FUNC__ \
298 || defined __cplusplus || defined _MSC_VER)
299 typedef signed char yytype_int8;
300 #else
301 typedef short int yytype_int8;
302 #endif
304 #ifdef YYTYPE_UINT16
305 typedef YYTYPE_UINT16 yytype_uint16;
306 #else
307 typedef unsigned short int yytype_uint16;
308 #endif
310 #ifdef YYTYPE_INT16
311 typedef YYTYPE_INT16 yytype_int16;
312 #else
313 typedef short int yytype_int16;
314 #endif
316 #ifndef YYSIZE_T
317 # ifdef __SIZE_TYPE__
318 # define YYSIZE_T __SIZE_TYPE__
319 # elif defined size_t
320 # define YYSIZE_T size_t
321 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
322 || defined __cplusplus || defined _MSC_VER)
323 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
324 # define YYSIZE_T size_t
325 # else
326 # define YYSIZE_T unsigned int
327 # endif
328 #endif
330 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
332 #ifndef YY_
333 # if defined YYENABLE_NLS && YYENABLE_NLS
334 # if ENABLE_NLS
335 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
336 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
337 # endif
338 # endif
339 # ifndef YY_
340 # define YY_(Msgid) Msgid
341 # endif
342 #endif
344 /* Suppress unused-variable warnings by "using" E. */
345 #if ! defined lint || defined __GNUC__
346 # define YYUSE(E) ((void) (E))
347 #else
348 # define YYUSE(E) /* empty */
349 #endif
351 /* Identity function, used to suppress warnings about constant conditions. */
352 #ifndef lint
353 # define YYID(N) (N)
354 #else
355 #if (defined __STDC__ || defined __C99__FUNC__ \
356 || defined __cplusplus || defined _MSC_VER)
357 static int
358 YYID (int yyi)
359 #else
360 static int
361 YYID (yyi)
362 int yyi;
363 #endif
365 return yyi;
367 #endif
369 #if ! defined yyoverflow || YYERROR_VERBOSE
371 /* The parser invokes alloca or malloc; define the necessary symbols. */
373 # ifdef YYSTACK_USE_ALLOCA
374 # if YYSTACK_USE_ALLOCA
375 # ifdef __GNUC__
376 # define YYSTACK_ALLOC __builtin_alloca
377 # elif defined __BUILTIN_VA_ARG_INCR
378 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
379 # elif defined _AIX
380 # define YYSTACK_ALLOC __alloca
381 # elif defined _MSC_VER
382 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
383 # define alloca _alloca
384 # else
385 # define YYSTACK_ALLOC alloca
386 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
387 || defined __cplusplus || defined _MSC_VER)
388 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
389 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
390 # ifndef EXIT_SUCCESS
391 # define EXIT_SUCCESS 0
392 # endif
393 # endif
394 # endif
395 # endif
396 # endif
398 # ifdef YYSTACK_ALLOC
399 /* Pacify GCC's `empty if-body' warning. */
400 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
401 # ifndef YYSTACK_ALLOC_MAXIMUM
402 /* The OS might guarantee only one guard page at the bottom of the stack,
403 and a page size can be as small as 4096 bytes. So we cannot safely
404 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
405 to allow for a few compiler-allocated temporary stack slots. */
406 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
407 # endif
408 # else
409 # define YYSTACK_ALLOC YYMALLOC
410 # define YYSTACK_FREE YYFREE
411 # ifndef YYSTACK_ALLOC_MAXIMUM
412 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
413 # endif
414 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
415 && ! ((defined YYMALLOC || defined malloc) \
416 && (defined YYFREE || defined free)))
417 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
418 # ifndef EXIT_SUCCESS
419 # define EXIT_SUCCESS 0
420 # endif
421 # endif
422 # ifndef YYMALLOC
423 # define YYMALLOC malloc
424 # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
425 || defined __cplusplus || defined _MSC_VER)
426 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
427 # endif
428 # endif
429 # ifndef YYFREE
430 # define YYFREE free
431 # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
432 || defined __cplusplus || defined _MSC_VER)
433 void free (void *); /* INFRINGES ON USER NAME SPACE */
434 # endif
435 # endif
436 # endif
437 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
440 #if (! defined yyoverflow \
441 && (! defined __cplusplus \
442 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
444 /* A type that is properly aligned for any stack member. */
445 union yyalloc
447 yytype_int16 yyss_alloc;
448 YYSTYPE yyvs_alloc;
451 /* The size of the maximum gap between one aligned stack and the next. */
452 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
454 /* The size of an array large to enough to hold all stacks, each with
455 N elements. */
456 # define YYSTACK_BYTES(N) \
457 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
458 + YYSTACK_GAP_MAXIMUM)
460 # define YYCOPY_NEEDED 1
462 /* Relocate STACK from its old location to the new one. The
463 local variables YYSIZE and YYSTACKSIZE give the old and new number of
464 elements in the stack, and YYPTR gives the new location of the
465 stack. Advance YYPTR to a properly aligned location for the next
466 stack. */
467 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
468 do \
470 YYSIZE_T yynewbytes; \
471 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
472 Stack = &yyptr->Stack_alloc; \
473 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
474 yyptr += yynewbytes / sizeof (*yyptr); \
476 while (YYID (0))
478 #endif
480 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
481 /* Copy COUNT objects from SRC to DST. The source and destination do
482 not overlap. */
483 # ifndef YYCOPY
484 # if defined __GNUC__ && 1 < __GNUC__
485 # define YYCOPY(Dst, Src, Count) \
486 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
487 # else
488 # define YYCOPY(Dst, Src, Count) \
489 do \
491 YYSIZE_T yyi; \
492 for (yyi = 0; yyi < (Count); yyi++) \
493 (Dst)[yyi] = (Src)[yyi]; \
495 while (YYID (0))
496 # endif
497 # endif
498 #endif /* !YYCOPY_NEEDED */
500 /* YYFINAL -- State number of the termination state. */
501 #define YYFINAL 9
502 /* YYLAST -- Last index in YYTABLE. */
503 #define YYLAST 54
505 /* YYNTOKENS -- Number of terminals. */
506 #define YYNTOKENS 16
507 /* YYNNTS -- Number of nonterminals. */
508 #define YYNNTS 3
509 /* YYNRULES -- Number of rules. */
510 #define YYNRULES 13
511 /* YYNRULES -- Number of states. */
512 #define YYNSTATES 27
514 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
515 #define YYUNDEFTOK 2
516 #define YYMAXUTOK 262
518 #define YYTRANSLATE(YYX) \
519 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
521 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
522 static const yytype_uint8 yytranslate[] =
524 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
525 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
526 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
527 2, 2, 2, 10, 2, 2, 2, 2, 5, 2,
528 14, 15, 2, 2, 2, 2, 2, 2, 2, 2,
529 2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
530 2, 2, 2, 3, 2, 2, 2, 2, 2, 2,
531 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
532 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
533 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
534 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
535 13, 2, 2, 2, 2, 2, 2, 2, 2, 2,
536 2, 2, 2, 2, 4, 2, 2, 2, 2, 2,
537 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
538 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
539 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
540 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
541 2, 2, 2, 2, 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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
547 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
548 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
549 2, 2, 2, 2, 2, 2, 1, 2, 6, 7,
550 8, 9, 11
553 #if YYDEBUG
554 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
555 YYRHS. */
556 static const yytype_uint8 yyprhs[] =
558 0, 0, 3, 5, 11, 15, 19, 23, 27, 31,
559 35, 38, 40, 42
562 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
563 static const yytype_int8 yyrhs[] =
565 17, 0, -1, 18, -1, 18, 3, 18, 12, 18,
566 -1, 18, 4, 18, -1, 18, 5, 18, -1, 18,
567 6, 18, -1, 18, 7, 18, -1, 18, 8, 18,
568 -1, 18, 9, 18, -1, 10, 18, -1, 13, -1,
569 11, -1, 14, 18, 15, -1
572 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
573 static const yytype_uint8 yyrline[] =
575 0, 152, 152, 160, 164, 168, 172, 176, 180, 184,
576 188, 192, 196, 201
578 #endif
580 #if YYDEBUG || YYERROR_VERBOSE || 0
581 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
582 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
583 static const char *const yytname[] =
585 "$end", "error", "$undefined", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
586 "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
587 "$accept", "start", "exp", YY_NULL
589 #endif
591 # ifdef YYPRINT
592 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
593 token YYLEX-NUM. */
594 static const yytype_uint16 yytoknum[] =
596 0, 256, 257, 63, 124, 38, 258, 259, 260, 261,
597 33, 262, 58, 110, 40, 41
599 # endif
601 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
602 static const yytype_uint8 yyr1[] =
604 0, 16, 17, 18, 18, 18, 18, 18, 18, 18,
605 18, 18, 18, 18
608 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
609 static const yytype_uint8 yyr2[] =
611 0, 2, 1, 5, 3, 3, 3, 3, 3, 3,
612 2, 1, 1, 3
615 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
616 Performed when YYTABLE doesn't specify something else to do. Zero
617 means the default is an error. */
618 static const yytype_uint8 yydefact[] =
620 0, 0, 12, 11, 0, 0, 2, 10, 0, 1,
621 0, 0, 0, 0, 0, 0, 0, 13, 0, 4,
622 5, 6, 7, 8, 9, 0, 3
625 /* YYDEFGOTO[NTERM-NUM]. */
626 static const yytype_int8 yydefgoto[] =
628 -1, 5, 6
631 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
632 STATE-NUM. */
633 #define YYPACT_NINF -10
634 static const yytype_int8 yypact[] =
636 -9, -9, -10, -10, -9, 8, 36, -10, 13, -10,
637 -9, -9, -9, -9, -9, -9, -9, -10, 26, 41,
638 45, 18, -2, 14, -10, -9, 36
641 /* YYPGOTO[NTERM-NUM]. */
642 static const yytype_int8 yypgoto[] =
644 -10, -10, -1
647 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
648 positive, shift that token. If negative, reduce the rule which
649 number is the opposite. If YYTABLE_NINF, syntax error. */
650 #define YYTABLE_NINF -1
651 static const yytype_uint8 yytable[] =
653 7, 1, 2, 8, 3, 4, 15, 16, 9, 18,
654 19, 20, 21, 22, 23, 24, 10, 11, 12, 13,
655 14, 15, 16, 16, 26, 14, 15, 16, 17, 10,
656 11, 12, 13, 14, 15, 16, 0, 0, 25, 10,
657 11, 12, 13, 14, 15, 16, 12, 13, 14, 15,
658 16, 13, 14, 15, 16
661 #define yypact_value_is_default(Yystate) \
662 (!!((Yystate) == (-10)))
664 #define yytable_value_is_error(Yytable_value) \
665 YYID (0)
667 static const yytype_int8 yycheck[] =
669 1, 10, 11, 4, 13, 14, 8, 9, 0, 10,
670 11, 12, 13, 14, 15, 16, 3, 4, 5, 6,
671 7, 8, 9, 9, 25, 7, 8, 9, 15, 3,
672 4, 5, 6, 7, 8, 9, -1, -1, 12, 3,
673 4, 5, 6, 7, 8, 9, 5, 6, 7, 8,
674 9, 6, 7, 8, 9
677 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
678 symbol of state STATE-NUM. */
679 static const yytype_uint8 yystos[] =
681 0, 10, 11, 13, 14, 17, 18, 18, 18, 0,
682 3, 4, 5, 6, 7, 8, 9, 15, 18, 18,
683 18, 18, 18, 18, 18, 12, 18
686 #define yyerrok (yyerrstatus = 0)
687 #define yyclearin (yychar = YYEMPTY)
688 #define YYEMPTY (-2)
689 #define YYEOF 0
691 #define YYACCEPT goto yyacceptlab
692 #define YYABORT goto yyabortlab
693 #define YYERROR goto yyerrorlab
696 /* Like YYERROR except do call yyerror. This remains here temporarily
697 to ease the transition to the new meaning of YYERROR, for GCC.
698 Once GCC version 2 has supplanted version 1, this can go. However,
699 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
700 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
701 discussed. */
703 #define YYFAIL goto yyerrlab
704 #if defined YYFAIL
705 /* This is here to suppress warnings from the GCC cpp's
706 -Wunused-macros. Normally we don't worry about that warning, but
707 some users do, and we want to make it easy for users to remove
708 YYFAIL uses, which will produce warnings from Bison 2.5. */
709 #endif
711 #define YYRECOVERING() (!!yyerrstatus)
713 #define YYBACKUP(Token, Value) \
714 do \
715 if (yychar == YYEMPTY) \
717 yychar = (Token); \
718 yylval = (Value); \
719 YYPOPSTACK (yylen); \
720 yystate = *yyssp; \
721 goto yybackup; \
723 else \
725 yyerror (arg, YY_("syntax error: cannot back up")); \
726 YYERROR; \
728 while (YYID (0))
730 /* Error token number */
731 #define YYTERROR 1
732 #define YYERRCODE 256
735 /* This macro is provided for backward compatibility. */
736 #ifndef YY_LOCATION_PRINT
737 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
738 #endif
741 /* YYLEX -- calling `yylex' with the right arguments. */
742 #ifdef YYLEX_PARAM
743 # define YYLEX yylex (&yylval, YYLEX_PARAM)
744 #else
745 # define YYLEX yylex (&yylval, arg)
746 #endif
748 /* Enable debugging if requested. */
749 #if YYDEBUG
751 # ifndef YYFPRINTF
752 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
753 # define YYFPRINTF fprintf
754 # endif
756 # define YYDPRINTF(Args) \
757 do { \
758 if (yydebug) \
759 YYFPRINTF Args; \
760 } while (YYID (0))
762 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
763 do { \
764 if (yydebug) \
766 YYFPRINTF (stderr, "%s ", Title); \
767 yy_symbol_print (stderr, \
768 Type, Value, arg); \
769 YYFPRINTF (stderr, "\n"); \
771 } while (YYID (0))
774 /*--------------------------------.
775 | Print this symbol on YYOUTPUT. |
776 `--------------------------------*/
778 /*ARGSUSED*/
779 #if (defined __STDC__ || defined __C99__FUNC__ \
780 || defined __cplusplus || defined _MSC_VER)
781 static void
782 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct parse_args *arg)
783 #else
784 static void
785 yy_symbol_value_print (yyoutput, yytype, yyvaluep, arg)
786 FILE *yyoutput;
787 int yytype;
788 YYSTYPE const * const yyvaluep;
789 struct parse_args *arg;
790 #endif
792 FILE *yyo = yyoutput;
793 YYUSE (yyo);
794 if (!yyvaluep)
795 return;
796 YYUSE (arg);
797 # ifdef YYPRINT
798 if (yytype < YYNTOKENS)
799 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
800 # else
801 YYUSE (yyoutput);
802 # endif
803 switch (yytype)
805 default:
806 break;
811 /*--------------------------------.
812 | Print this symbol on YYOUTPUT. |
813 `--------------------------------*/
815 #if (defined __STDC__ || defined __C99__FUNC__ \
816 || defined __cplusplus || defined _MSC_VER)
817 static void
818 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, struct parse_args *arg)
819 #else
820 static void
821 yy_symbol_print (yyoutput, yytype, yyvaluep, arg)
822 FILE *yyoutput;
823 int yytype;
824 YYSTYPE const * const yyvaluep;
825 struct parse_args *arg;
826 #endif
828 if (yytype < YYNTOKENS)
829 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
830 else
831 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
833 yy_symbol_value_print (yyoutput, yytype, yyvaluep, arg);
834 YYFPRINTF (yyoutput, ")");
837 /*------------------------------------------------------------------.
838 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
839 | TOP (included). |
840 `------------------------------------------------------------------*/
842 #if (defined __STDC__ || defined __C99__FUNC__ \
843 || defined __cplusplus || defined _MSC_VER)
844 static void
845 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
846 #else
847 static void
848 yy_stack_print (yybottom, yytop)
849 yytype_int16 *yybottom;
850 yytype_int16 *yytop;
851 #endif
853 YYFPRINTF (stderr, "Stack now");
854 for (; yybottom <= yytop; yybottom++)
856 int yybot = *yybottom;
857 YYFPRINTF (stderr, " %d", yybot);
859 YYFPRINTF (stderr, "\n");
862 # define YY_STACK_PRINT(Bottom, Top) \
863 do { \
864 if (yydebug) \
865 yy_stack_print ((Bottom), (Top)); \
866 } while (YYID (0))
869 /*------------------------------------------------.
870 | Report that the YYRULE is going to be reduced. |
871 `------------------------------------------------*/
873 #if (defined __STDC__ || defined __C99__FUNC__ \
874 || defined __cplusplus || defined _MSC_VER)
875 static void
876 yy_reduce_print (YYSTYPE *yyvsp, int yyrule, struct parse_args *arg)
877 #else
878 static void
879 yy_reduce_print (yyvsp, yyrule, arg)
880 YYSTYPE *yyvsp;
881 int yyrule;
882 struct parse_args *arg;
883 #endif
885 int yynrhs = yyr2[yyrule];
886 int yyi;
887 unsigned long int yylno = yyrline[yyrule];
888 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
889 yyrule - 1, yylno);
890 /* The symbols being reduced. */
891 for (yyi = 0; yyi < yynrhs; yyi++)
893 YYFPRINTF (stderr, " $%d = ", yyi + 1);
894 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
895 &(yyvsp[(yyi + 1) - (yynrhs)])
896 , arg);
897 YYFPRINTF (stderr, "\n");
901 # define YY_REDUCE_PRINT(Rule) \
902 do { \
903 if (yydebug) \
904 yy_reduce_print (yyvsp, Rule, arg); \
905 } while (YYID (0))
907 /* Nonzero means print parse trace. It is left uninitialized so that
908 multiple parsers can coexist. */
909 int yydebug;
910 #else /* !YYDEBUG */
911 # define YYDPRINTF(Args)
912 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
913 # define YY_STACK_PRINT(Bottom, Top)
914 # define YY_REDUCE_PRINT(Rule)
915 #endif /* !YYDEBUG */
918 /* YYINITDEPTH -- initial size of the parser's stacks. */
919 #ifndef YYINITDEPTH
920 # define YYINITDEPTH 200
921 #endif
923 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
924 if the built-in stack extension method is used).
926 Do not make this value too large; the results are undefined if
927 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
928 evaluated with infinite-precision integer arithmetic. */
930 #ifndef YYMAXDEPTH
931 # define YYMAXDEPTH 10000
932 #endif
935 #if YYERROR_VERBOSE
937 # ifndef yystrlen
938 # if defined __GLIBC__ && defined _STRING_H
939 # define yystrlen strlen
940 # else
941 /* Return the length of YYSTR. */
942 #if (defined __STDC__ || defined __C99__FUNC__ \
943 || defined __cplusplus || defined _MSC_VER)
944 static YYSIZE_T
945 yystrlen (const char *yystr)
946 #else
947 static YYSIZE_T
948 yystrlen (yystr)
949 const char *yystr;
950 #endif
952 YYSIZE_T yylen;
953 for (yylen = 0; yystr[yylen]; yylen++)
954 continue;
955 return yylen;
957 # endif
958 # endif
960 # ifndef yystpcpy
961 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
962 # define yystpcpy stpcpy
963 # else
964 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
965 YYDEST. */
966 #if (defined __STDC__ || defined __C99__FUNC__ \
967 || defined __cplusplus || defined _MSC_VER)
968 static char *
969 yystpcpy (char *yydest, const char *yysrc)
970 #else
971 static char *
972 yystpcpy (yydest, yysrc)
973 char *yydest;
974 const char *yysrc;
975 #endif
977 char *yyd = yydest;
978 const char *yys = yysrc;
980 while ((*yyd++ = *yys++) != '\0')
981 continue;
983 return yyd - 1;
985 # endif
986 # endif
988 # ifndef yytnamerr
989 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
990 quotes and backslashes, so that it's suitable for yyerror. The
991 heuristic is that double-quoting is unnecessary unless the string
992 contains an apostrophe, a comma, or backslash (other than
993 backslash-backslash). YYSTR is taken from yytname. If YYRES is
994 null, do not copy; instead, return the length of what the result
995 would have been. */
996 static YYSIZE_T
997 yytnamerr (char *yyres, const char *yystr)
999 if (*yystr == '"')
1001 YYSIZE_T yyn = 0;
1002 char const *yyp = yystr;
1004 for (;;)
1005 switch (*++yyp)
1007 case '\'':
1008 case ',':
1009 goto do_not_strip_quotes;
1011 case '\\':
1012 if (*++yyp != '\\')
1013 goto do_not_strip_quotes;
1014 /* Fall through. */
1015 default:
1016 if (yyres)
1017 yyres[yyn] = *yyp;
1018 yyn++;
1019 break;
1021 case '"':
1022 if (yyres)
1023 yyres[yyn] = '\0';
1024 return yyn;
1026 do_not_strip_quotes: ;
1029 if (! yyres)
1030 return yystrlen (yystr);
1032 return yystpcpy (yyres, yystr) - yyres;
1034 # endif
1036 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1037 about the unexpected token YYTOKEN for the state stack whose top is
1038 YYSSP.
1040 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1041 not large enough to hold the message. In that case, also set
1042 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1043 required number of bytes is too large to store. */
1044 static int
1045 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1046 yytype_int16 *yyssp, int yytoken)
1048 YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
1049 YYSIZE_T yysize = yysize0;
1050 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1051 /* Internationalized format string. */
1052 const char *yyformat = YY_NULL;
1053 /* Arguments of yyformat. */
1054 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1055 /* Number of reported tokens (one for the "unexpected", one per
1056 "expected"). */
1057 int yycount = 0;
1059 /* There are many possibilities here to consider:
1060 - Assume YYFAIL is not used. It's too flawed to consider. See
1061 <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1062 for details. YYERROR is fine as it does not invoke this
1063 function.
1064 - If this state is a consistent state with a default action, then
1065 the only way this function was invoked is if the default action
1066 is an error action. In that case, don't check for expected
1067 tokens because there are none.
1068 - The only way there can be no lookahead present (in yychar) is if
1069 this state is a consistent state with a default action. Thus,
1070 detecting the absence of a lookahead is sufficient to determine
1071 that there is no unexpected or expected token to report. In that
1072 case, just report a simple "syntax error".
1073 - Don't assume there isn't a lookahead just because this state is a
1074 consistent state with a default action. There might have been a
1075 previous inconsistent state, consistent state with a non-default
1076 action, or user semantic action that manipulated yychar.
1077 - Of course, the expected token list depends on states to have
1078 correct lookahead information, and it depends on the parser not
1079 to perform extra reductions after fetching a lookahead from the
1080 scanner and before detecting a syntax error. Thus, state merging
1081 (from LALR or IELR) and default reductions corrupt the expected
1082 token list. However, the list is correct for canonical LR with
1083 one exception: it will still contain any token that will not be
1084 accepted due to an error action in a later state.
1086 if (yytoken != YYEMPTY)
1088 int yyn = yypact[*yyssp];
1089 yyarg[yycount++] = yytname[yytoken];
1090 if (!yypact_value_is_default (yyn))
1092 /* Start YYX at -YYN if negative to avoid negative indexes in
1093 YYCHECK. In other words, skip the first -YYN actions for
1094 this state because they are default actions. */
1095 int yyxbegin = yyn < 0 ? -yyn : 0;
1096 /* Stay within bounds of both yycheck and yytname. */
1097 int yychecklim = YYLAST - yyn + 1;
1098 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1099 int yyx;
1101 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1102 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1103 && !yytable_value_is_error (yytable[yyx + yyn]))
1105 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1107 yycount = 1;
1108 yysize = yysize0;
1109 break;
1111 yyarg[yycount++] = yytname[yyx];
1113 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
1114 if (! (yysize <= yysize1
1115 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1116 return 2;
1117 yysize = yysize1;
1123 switch (yycount)
1125 # define YYCASE_(N, S) \
1126 case N: \
1127 yyformat = S; \
1128 break
1129 YYCASE_(0, YY_("syntax error"));
1130 YYCASE_(1, YY_("syntax error, unexpected %s"));
1131 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1132 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1133 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1134 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1135 # undef YYCASE_
1139 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1140 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1141 return 2;
1142 yysize = yysize1;
1145 if (*yymsg_alloc < yysize)
1147 *yymsg_alloc = 2 * yysize;
1148 if (! (yysize <= *yymsg_alloc
1149 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1150 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1151 return 1;
1154 /* Avoid sprintf, as that infringes on the user's name space.
1155 Don't have undefined behavior even if the translation
1156 produced a string with the wrong number of "%s"s. */
1158 char *yyp = *yymsg;
1159 int yyi = 0;
1160 while ((*yyp = *yyformat) != '\0')
1161 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1163 yyp += yytnamerr (yyp, yyarg[yyi++]);
1164 yyformat += 2;
1166 else
1168 yyp++;
1169 yyformat++;
1172 return 0;
1174 #endif /* YYERROR_VERBOSE */
1176 /*-----------------------------------------------.
1177 | Release the memory associated to this symbol. |
1178 `-----------------------------------------------*/
1180 /*ARGSUSED*/
1181 #if (defined __STDC__ || defined __C99__FUNC__ \
1182 || defined __cplusplus || defined _MSC_VER)
1183 static void
1184 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, struct parse_args *arg)
1185 #else
1186 static void
1187 yydestruct (yymsg, yytype, yyvaluep, arg)
1188 const char *yymsg;
1189 int yytype;
1190 YYSTYPE *yyvaluep;
1191 struct parse_args *arg;
1192 #endif
1194 YYUSE (yyvaluep);
1195 YYUSE (arg);
1197 if (!yymsg)
1198 yymsg = "Deleting";
1199 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1201 switch (yytype)
1204 default:
1205 break;
1212 /*----------.
1213 | yyparse. |
1214 `----------*/
1216 #ifdef YYPARSE_PARAM
1217 #if (defined __STDC__ || defined __C99__FUNC__ \
1218 || defined __cplusplus || defined _MSC_VER)
1220 yyparse (void *YYPARSE_PARAM)
1221 #else
1223 yyparse (YYPARSE_PARAM)
1224 void *YYPARSE_PARAM;
1225 #endif
1226 #else /* ! YYPARSE_PARAM */
1227 #if (defined __STDC__ || defined __C99__FUNC__ \
1228 || defined __cplusplus || defined _MSC_VER)
1230 yyparse (struct parse_args *arg)
1231 #else
1233 yyparse (arg)
1234 struct parse_args *arg;
1235 #endif
1236 #endif
1238 /* The lookahead symbol. */
1239 int yychar;
1242 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
1243 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
1244 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
1245 _Pragma ("GCC diagnostic push") \
1246 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
1247 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
1248 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
1249 _Pragma ("GCC diagnostic pop")
1250 #else
1251 /* Default value used for initialization, for pacifying older GCCs
1252 or non-GCC compilers. */
1253 static YYSTYPE yyval_default;
1254 # define YY_INITIAL_VALUE(Value) = Value
1255 #endif
1256 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1257 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1258 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
1259 #endif
1260 #ifndef YY_INITIAL_VALUE
1261 # define YY_INITIAL_VALUE(Value) /* Nothing. */
1262 #endif
1264 /* The semantic value of the lookahead symbol. */
1265 YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
1267 /* Number of syntax errors so far. */
1268 int yynerrs;
1270 int yystate;
1271 /* Number of tokens to shift before error messages enabled. */
1272 int yyerrstatus;
1274 /* The stacks and their tools:
1275 `yyss': related to states.
1276 `yyvs': related to semantic values.
1278 Refer to the stacks through separate pointers, to allow yyoverflow
1279 to reallocate them elsewhere. */
1281 /* The state stack. */
1282 yytype_int16 yyssa[YYINITDEPTH];
1283 yytype_int16 *yyss;
1284 yytype_int16 *yyssp;
1286 /* The semantic value stack. */
1287 YYSTYPE yyvsa[YYINITDEPTH];
1288 YYSTYPE *yyvs;
1289 YYSTYPE *yyvsp;
1291 YYSIZE_T yystacksize;
1293 int yyn;
1294 int yyresult;
1295 /* Lookahead token as an internal (translated) token number. */
1296 int yytoken = 0;
1297 /* The variables used to return semantic value and location from the
1298 action routines. */
1299 YYSTYPE yyval;
1301 #if YYERROR_VERBOSE
1302 /* Buffer for error messages, and its allocated size. */
1303 char yymsgbuf[128];
1304 char *yymsg = yymsgbuf;
1305 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1306 #endif
1308 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1310 /* The number of symbols on the RHS of the reduced rule.
1311 Keep to zero when no symbol should be popped. */
1312 int yylen = 0;
1314 yyssp = yyss = yyssa;
1315 yyvsp = yyvs = yyvsa;
1316 yystacksize = YYINITDEPTH;
1318 YYDPRINTF ((stderr, "Starting parse\n"));
1320 yystate = 0;
1321 yyerrstatus = 0;
1322 yynerrs = 0;
1323 yychar = YYEMPTY; /* Cause a token to be read. */
1324 goto yysetstate;
1326 /*------------------------------------------------------------.
1327 | yynewstate -- Push a new state, which is found in yystate. |
1328 `------------------------------------------------------------*/
1329 yynewstate:
1330 /* In all cases, when you get here, the value and location stacks
1331 have just been pushed. So pushing a state here evens the stacks. */
1332 yyssp++;
1334 yysetstate:
1335 *yyssp = yystate;
1337 if (yyss + yystacksize - 1 <= yyssp)
1339 /* Get the current used size of the three stacks, in elements. */
1340 YYSIZE_T yysize = yyssp - yyss + 1;
1342 #ifdef yyoverflow
1344 /* Give user a chance to reallocate the stack. Use copies of
1345 these so that the &'s don't force the real ones into
1346 memory. */
1347 YYSTYPE *yyvs1 = yyvs;
1348 yytype_int16 *yyss1 = yyss;
1350 /* Each stack pointer address is followed by the size of the
1351 data in use in that stack, in bytes. This used to be a
1352 conditional around just the two extra args, but that might
1353 be undefined if yyoverflow is a macro. */
1354 yyoverflow (YY_("memory exhausted"),
1355 &yyss1, yysize * sizeof (*yyssp),
1356 &yyvs1, yysize * sizeof (*yyvsp),
1357 &yystacksize);
1359 yyss = yyss1;
1360 yyvs = yyvs1;
1362 #else /* no yyoverflow */
1363 # ifndef YYSTACK_RELOCATE
1364 goto yyexhaustedlab;
1365 # else
1366 /* Extend the stack our own way. */
1367 if (YYMAXDEPTH <= yystacksize)
1368 goto yyexhaustedlab;
1369 yystacksize *= 2;
1370 if (YYMAXDEPTH < yystacksize)
1371 yystacksize = YYMAXDEPTH;
1374 yytype_int16 *yyss1 = yyss;
1375 union yyalloc *yyptr =
1376 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1377 if (! yyptr)
1378 goto yyexhaustedlab;
1379 YYSTACK_RELOCATE (yyss_alloc, yyss);
1380 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1381 # undef YYSTACK_RELOCATE
1382 if (yyss1 != yyssa)
1383 YYSTACK_FREE (yyss1);
1385 # endif
1386 #endif /* no yyoverflow */
1388 yyssp = yyss + yysize - 1;
1389 yyvsp = yyvs + yysize - 1;
1391 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1392 (unsigned long int) yystacksize));
1394 if (yyss + yystacksize - 1 <= yyssp)
1395 YYABORT;
1398 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1400 if (yystate == YYFINAL)
1401 YYACCEPT;
1403 goto yybackup;
1405 /*-----------.
1406 | yybackup. |
1407 `-----------*/
1408 yybackup:
1410 /* Do appropriate processing given the current state. Read a
1411 lookahead token if we need one and don't already have one. */
1413 /* First try to decide what to do without reference to lookahead token. */
1414 yyn = yypact[yystate];
1415 if (yypact_value_is_default (yyn))
1416 goto yydefault;
1418 /* Not known => get a lookahead token if don't already have one. */
1420 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1421 if (yychar == YYEMPTY)
1423 YYDPRINTF ((stderr, "Reading a token: "));
1424 yychar = YYLEX;
1427 if (yychar <= YYEOF)
1429 yychar = yytoken = YYEOF;
1430 YYDPRINTF ((stderr, "Now at end of input.\n"));
1432 else
1434 yytoken = YYTRANSLATE (yychar);
1435 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1438 /* If the proper action on seeing token YYTOKEN is to reduce or to
1439 detect an error, take that action. */
1440 yyn += yytoken;
1441 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1442 goto yydefault;
1443 yyn = yytable[yyn];
1444 if (yyn <= 0)
1446 if (yytable_value_is_error (yyn))
1447 goto yyerrlab;
1448 yyn = -yyn;
1449 goto yyreduce;
1452 /* Count tokens shifted since error; after three, turn off error
1453 status. */
1454 if (yyerrstatus)
1455 yyerrstatus--;
1457 /* Shift the lookahead token. */
1458 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1460 /* Discard the shifted token. */
1461 yychar = YYEMPTY;
1463 yystate = yyn;
1464 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1465 *++yyvsp = yylval;
1466 YY_IGNORE_MAYBE_UNINITIALIZED_END
1468 goto yynewstate;
1471 /*-----------------------------------------------------------.
1472 | yydefault -- do the default action for the current state. |
1473 `-----------------------------------------------------------*/
1474 yydefault:
1475 yyn = yydefact[yystate];
1476 if (yyn == 0)
1477 goto yyerrlab;
1478 goto yyreduce;
1481 /*-----------------------------.
1482 | yyreduce -- Do a reduction. |
1483 `-----------------------------*/
1484 yyreduce:
1485 /* yyn is the number of a rule to reduce with. */
1486 yylen = yyr2[yyn];
1488 /* If YYLEN is nonzero, implement the default value of the action:
1489 `$$ = $1'.
1491 Otherwise, the following line sets YYVAL to garbage.
1492 This behavior is undocumented and Bison
1493 users should not rely upon it. Assigning to YYVAL
1494 unconditionally makes the parser a bit smaller, and it avoids a
1495 GCC warning that YYVAL may be used uninitialized. */
1496 yyval = yyvsp[1-yylen];
1499 YY_REDUCE_PRINT (yyn);
1500 switch (yyn)
1502 case 2:
1503 /* Line 1792 of yacc.c */
1504 #line 153 "plural.y"
1506 if ((yyvsp[(1) - (1)].exp) == NULL)
1507 YYABORT;
1508 arg->res = (yyvsp[(1) - (1)].exp);
1510 break;
1512 case 3:
1513 /* Line 1792 of yacc.c */
1514 #line 161 "plural.y"
1516 (yyval.exp) = new_exp_3 (qmop, (yyvsp[(1) - (5)].exp), (yyvsp[(3) - (5)].exp), (yyvsp[(5) - (5)].exp));
1518 break;
1520 case 4:
1521 /* Line 1792 of yacc.c */
1522 #line 165 "plural.y"
1524 (yyval.exp) = new_exp_2 (lor, (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1526 break;
1528 case 5:
1529 /* Line 1792 of yacc.c */
1530 #line 169 "plural.y"
1532 (yyval.exp) = new_exp_2 (land, (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1534 break;
1536 case 6:
1537 /* Line 1792 of yacc.c */
1538 #line 173 "plural.y"
1540 (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1542 break;
1544 case 7:
1545 /* Line 1792 of yacc.c */
1546 #line 177 "plural.y"
1548 (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1550 break;
1552 case 8:
1553 /* Line 1792 of yacc.c */
1554 #line 181 "plural.y"
1556 (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1558 break;
1560 case 9:
1561 /* Line 1792 of yacc.c */
1562 #line 185 "plural.y"
1564 (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1566 break;
1568 case 10:
1569 /* Line 1792 of yacc.c */
1570 #line 189 "plural.y"
1572 (yyval.exp) = new_exp_1 (lnot, (yyvsp[(2) - (2)].exp));
1574 break;
1576 case 11:
1577 /* Line 1792 of yacc.c */
1578 #line 193 "plural.y"
1580 (yyval.exp) = new_exp_0 (var);
1582 break;
1584 case 12:
1585 /* Line 1792 of yacc.c */
1586 #line 197 "plural.y"
1588 if (((yyval.exp) = new_exp_0 (num)) != NULL)
1589 (yyval.exp)->val.num = (yyvsp[(1) - (1)].num);
1591 break;
1593 case 13:
1594 /* Line 1792 of yacc.c */
1595 #line 202 "plural.y"
1597 (yyval.exp) = (yyvsp[(2) - (3)].exp);
1599 break;
1602 /* Line 1792 of yacc.c */
1603 #line 1604 "plural.c"
1604 default: break;
1606 /* User semantic actions sometimes alter yychar, and that requires
1607 that yytoken be updated with the new translation. We take the
1608 approach of translating immediately before every use of yytoken.
1609 One alternative is translating here after every semantic action,
1610 but that translation would be missed if the semantic action invokes
1611 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1612 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1613 incorrect destructor might then be invoked immediately. In the
1614 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1615 to an incorrect destructor call or verbose syntax error message
1616 before the lookahead is translated. */
1617 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1619 YYPOPSTACK (yylen);
1620 yylen = 0;
1621 YY_STACK_PRINT (yyss, yyssp);
1623 *++yyvsp = yyval;
1625 /* Now `shift' the result of the reduction. Determine what state
1626 that goes to, based on the state we popped back to and the rule
1627 number reduced by. */
1629 yyn = yyr1[yyn];
1631 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1632 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1633 yystate = yytable[yystate];
1634 else
1635 yystate = yydefgoto[yyn - YYNTOKENS];
1637 goto yynewstate;
1640 /*------------------------------------.
1641 | yyerrlab -- here on detecting error |
1642 `------------------------------------*/
1643 yyerrlab:
1644 /* Make sure we have latest lookahead translation. See comments at
1645 user semantic actions for why this is necessary. */
1646 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1648 /* If not already recovering from an error, report this error. */
1649 if (!yyerrstatus)
1651 ++yynerrs;
1652 #if ! YYERROR_VERBOSE
1653 yyerror (arg, YY_("syntax error"));
1654 #else
1655 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1656 yyssp, yytoken)
1658 char const *yymsgp = YY_("syntax error");
1659 int yysyntax_error_status;
1660 yysyntax_error_status = YYSYNTAX_ERROR;
1661 if (yysyntax_error_status == 0)
1662 yymsgp = yymsg;
1663 else if (yysyntax_error_status == 1)
1665 if (yymsg != yymsgbuf)
1666 YYSTACK_FREE (yymsg);
1667 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1668 if (!yymsg)
1670 yymsg = yymsgbuf;
1671 yymsg_alloc = sizeof yymsgbuf;
1672 yysyntax_error_status = 2;
1674 else
1676 yysyntax_error_status = YYSYNTAX_ERROR;
1677 yymsgp = yymsg;
1680 yyerror (arg, yymsgp);
1681 if (yysyntax_error_status == 2)
1682 goto yyexhaustedlab;
1684 # undef YYSYNTAX_ERROR
1685 #endif
1690 if (yyerrstatus == 3)
1692 /* If just tried and failed to reuse lookahead token after an
1693 error, discard it. */
1695 if (yychar <= YYEOF)
1697 /* Return failure if at end of input. */
1698 if (yychar == YYEOF)
1699 YYABORT;
1701 else
1703 yydestruct ("Error: discarding",
1704 yytoken, &yylval, arg);
1705 yychar = YYEMPTY;
1709 /* Else will try to reuse lookahead token after shifting the error
1710 token. */
1711 goto yyerrlab1;
1714 /*---------------------------------------------------.
1715 | yyerrorlab -- error raised explicitly by YYERROR. |
1716 `---------------------------------------------------*/
1717 yyerrorlab:
1719 /* Pacify compilers like GCC when the user code never invokes
1720 YYERROR and the label yyerrorlab therefore never appears in user
1721 code. */
1722 if (/*CONSTCOND*/ 0)
1723 goto yyerrorlab;
1725 /* Do not reclaim the symbols of the rule which action triggered
1726 this YYERROR. */
1727 YYPOPSTACK (yylen);
1728 yylen = 0;
1729 YY_STACK_PRINT (yyss, yyssp);
1730 yystate = *yyssp;
1731 goto yyerrlab1;
1734 /*-------------------------------------------------------------.
1735 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1736 `-------------------------------------------------------------*/
1737 yyerrlab1:
1738 yyerrstatus = 3; /* Each real token shifted decrements this. */
1740 for (;;)
1742 yyn = yypact[yystate];
1743 if (!yypact_value_is_default (yyn))
1745 yyn += YYTERROR;
1746 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1748 yyn = yytable[yyn];
1749 if (0 < yyn)
1750 break;
1754 /* Pop the current state because it cannot handle the error token. */
1755 if (yyssp == yyss)
1756 YYABORT;
1759 yydestruct ("Error: popping",
1760 yystos[yystate], yyvsp, arg);
1761 YYPOPSTACK (1);
1762 yystate = *yyssp;
1763 YY_STACK_PRINT (yyss, yyssp);
1766 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1767 *++yyvsp = yylval;
1768 YY_IGNORE_MAYBE_UNINITIALIZED_END
1771 /* Shift the error token. */
1772 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1774 yystate = yyn;
1775 goto yynewstate;
1778 /*-------------------------------------.
1779 | yyacceptlab -- YYACCEPT comes here. |
1780 `-------------------------------------*/
1781 yyacceptlab:
1782 yyresult = 0;
1783 goto yyreturn;
1785 /*-----------------------------------.
1786 | yyabortlab -- YYABORT comes here. |
1787 `-----------------------------------*/
1788 yyabortlab:
1789 yyresult = 1;
1790 goto yyreturn;
1792 #if !defined yyoverflow || YYERROR_VERBOSE
1793 /*-------------------------------------------------.
1794 | yyexhaustedlab -- memory exhaustion comes here. |
1795 `-------------------------------------------------*/
1796 yyexhaustedlab:
1797 yyerror (arg, YY_("memory exhausted"));
1798 yyresult = 2;
1799 /* Fall through. */
1800 #endif
1802 yyreturn:
1803 if (yychar != YYEMPTY)
1805 /* Make sure we have latest lookahead translation. See comments at
1806 user semantic actions for why this is necessary. */
1807 yytoken = YYTRANSLATE (yychar);
1808 yydestruct ("Cleanup: discarding lookahead",
1809 yytoken, &yylval, arg);
1811 /* Do not reclaim the symbols of the rule which action triggered
1812 this YYABORT or YYACCEPT. */
1813 YYPOPSTACK (yylen);
1814 YY_STACK_PRINT (yyss, yyssp);
1815 while (yyssp != yyss)
1817 yydestruct ("Cleanup: popping",
1818 yystos[*yyssp], yyvsp, arg);
1819 YYPOPSTACK (1);
1821 #ifndef yyoverflow
1822 if (yyss != yyssa)
1823 YYSTACK_FREE (yyss);
1824 #endif
1825 #if YYERROR_VERBOSE
1826 if (yymsg != yymsgbuf)
1827 YYSTACK_FREE (yymsg);
1828 #endif
1829 /* Make sure YYID is used. */
1830 return YYID (yyresult);
1834 /* Line 2055 of yacc.c */
1835 #line 207 "plural.y"
1838 void
1839 internal_function
1840 FREE_EXPRESSION (struct expression *exp)
1842 if (exp == NULL)
1843 return;
1845 /* Handle the recursive case. */
1846 switch (exp->nargs)
1848 case 3:
1849 FREE_EXPRESSION (exp->val.args[2]);
1850 /* FALLTHROUGH */
1851 case 2:
1852 FREE_EXPRESSION (exp->val.args[1]);
1853 /* FALLTHROUGH */
1854 case 1:
1855 FREE_EXPRESSION (exp->val.args[0]);
1856 /* FALLTHROUGH */
1857 default:
1858 break;
1861 free (exp);
1865 static int
1866 yylex (YYSTYPE *lval, struct parse_args *arg)
1868 const char *exp = arg->cp;
1869 int result;
1871 while (1)
1873 if (exp[0] == '\0')
1875 arg->cp = exp;
1876 return YYEOF;
1879 if (exp[0] != ' ' && exp[0] != '\t')
1880 break;
1882 ++exp;
1885 result = *exp++;
1886 switch (result)
1888 case '0': case '1': case '2': case '3': case '4':
1889 case '5': case '6': case '7': case '8': case '9':
1891 unsigned long int n = result - '0';
1892 while (exp[0] >= '0' && exp[0] <= '9')
1894 n *= 10;
1895 n += exp[0] - '0';
1896 ++exp;
1898 lval->num = n;
1899 result = NUMBER;
1901 break;
1903 case '=':
1904 if (exp[0] == '=')
1906 ++exp;
1907 lval->op = equal;
1908 result = EQUOP2;
1910 else
1911 result = YYERRCODE;
1912 break;
1914 case '!':
1915 if (exp[0] == '=')
1917 ++exp;
1918 lval->op = not_equal;
1919 result = EQUOP2;
1921 break;
1923 case '&':
1924 case '|':
1925 if (exp[0] == result)
1926 ++exp;
1927 else
1928 result = YYERRCODE;
1929 break;
1931 case '<':
1932 if (exp[0] == '=')
1934 ++exp;
1935 lval->op = less_or_equal;
1937 else
1938 lval->op = less_than;
1939 result = CMPOP2;
1940 break;
1942 case '>':
1943 if (exp[0] == '=')
1945 ++exp;
1946 lval->op = greater_or_equal;
1948 else
1949 lval->op = greater_than;
1950 result = CMPOP2;
1951 break;
1953 case '*':
1954 lval->op = mult;
1955 result = MULOP2;
1956 break;
1958 case '/':
1959 lval->op = divide;
1960 result = MULOP2;
1961 break;
1963 case '%':
1964 lval->op = module;
1965 result = MULOP2;
1966 break;
1968 case '+':
1969 lval->op = plus;
1970 result = ADDOP2;
1971 break;
1973 case '-':
1974 lval->op = minus;
1975 result = ADDOP2;
1976 break;
1978 case 'n':
1979 case '?':
1980 case ':':
1981 case '(':
1982 case ')':
1983 /* Nothing, just return the character. */
1984 break;
1986 case ';':
1987 case '\n':
1988 case '\0':
1989 /* Be safe and let the user call this function again. */
1990 --exp;
1991 result = YYEOF;
1992 break;
1994 default:
1995 result = YYERRCODE;
1996 #if YYDEBUG != 0
1997 --exp;
1998 #endif
1999 break;
2002 arg->cp = exp;
2004 return result;
2008 static void
2009 yyerror (struct parse_args *arg, const char *str)
2011 /* Do nothing. We don't print error messages here. */