Install gettext-0.18.1.1.tar.gz
[msysgit.git] / mingw / share / gettext / intl / plural.c
blob7a4d947a2427688f7db49ad6950072d36c8c473e
1 /* A Bison parser, made by GNU Bison 2.3a. */
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
23 /* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
39 /* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
46 /* Identify Bison output. */
47 #define YYBISON 1
49 /* Bison version. */
50 #define YYBISON_VERSION "2.3a"
52 /* Skeleton name. */
53 #define YYSKELETON_NAME "yacc.c"
55 /* Pure parsers. */
56 #define YYPURE 1
58 /* Using locations. */
59 #define YYLSP_NEEDED 0
61 /* Substitute the variable and function names. */
62 #define yyparse __gettextparse
63 #define yylex __gettextlex
64 #define yyerror __gettexterror
65 #define yylval __gettextlval
66 #define yychar __gettextchar
67 #define yydebug __gettextdebug
68 #define yynerrs __gettextnerrs
71 /* Copy the first part of user declarations. */
72 /* Line 164 of yacc.c. */
73 #line 1 "plural.y"
75 /* Expression parsing for plural form selection.
76 Copyright (C) 2000-2001, 2003, 2005-2006 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 it
80 under the terms of the GNU Library General Public License as published
81 by the Free Software Foundation; either version 2, or (at your option)
82 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 GNU
87 Library General Public License for more details.
89 You should have received a copy of the GNU Library General Public
90 License along with this program; if not, write to the Free Software
91 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
92 USA. */
94 /* For bison < 2.0, the bison generated parser uses alloca. AIX 3 forces us
95 to put this declaration at the beginning of the file. The declaration in
96 bison's skeleton file comes too late. This must come before <config.h>
97 because <config.h> may include arbitrary system headers.
98 This can go away once the AM_INTL_SUBDIR macro requires bison >= 2.0. */
99 #if defined _AIX && !defined __GNUC__
100 #pragma alloca
101 #endif
103 #ifdef HAVE_CONFIG_H
104 # include <config.h>
105 #endif
107 #include <stddef.h>
108 #include <stdlib.h>
109 #include <string.h>
110 #include "plural-exp.h"
112 /* The main function generated by the parser is called __gettextparse,
113 but we want it to be called PLURAL_PARSE. */
114 #ifndef _LIBC
115 # define __gettextparse PLURAL_PARSE
116 #endif
118 #define YYLEX_PARAM &((struct parse_args *) arg)->cp
119 #define YYPARSE_PARAM arg
122 /* Enabling traces. */
123 #ifndef YYDEBUG
124 # define YYDEBUG 0
125 #endif
127 /* Enabling verbose error messages. */
128 #ifdef YYERROR_VERBOSE
129 # undef YYERROR_VERBOSE
130 # define YYERROR_VERBOSE 1
131 #else
132 # define YYERROR_VERBOSE 0
133 #endif
135 /* Enabling the token table. */
136 #ifndef YYTOKEN_TABLE
137 # define YYTOKEN_TABLE 0
138 #endif
141 /* Tokens. */
142 #ifndef YYTOKENTYPE
143 # define YYTOKENTYPE
144 /* Put the tokens into the symbol table, so that GDB and other debuggers
145 know about them. */
146 enum yytokentype {
147 EQUOP2 = 258,
148 CMPOP2 = 259,
149 ADDOP2 = 260,
150 MULOP2 = 261,
151 NUMBER = 262
153 #endif
154 /* Tokens. */
155 #define EQUOP2 258
156 #define CMPOP2 259
157 #define ADDOP2 260
158 #define MULOP2 261
159 #define NUMBER 262
164 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
165 typedef union YYSTYPE
166 {/* Line 191 of yacc.c. */
167 #line 51 "plural.y"
169 unsigned long int num;
170 enum expression_operator op;
171 struct expression *exp;
173 /* Line 191 of yacc.c. */
174 #line 175 "plural.c"
175 YYSTYPE;
176 # define YYSTYPE_IS_TRIVIAL 1
177 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
178 # define YYSTYPE_IS_DECLARED 1
179 #endif
184 /* Copy the second part of user declarations. */
185 /* Line 221 of yacc.c. */
186 #line 57 "plural.y"
188 /* Prototypes for local functions. */
189 static int yylex (YYSTYPE *lval, const char **pexp);
190 static void yyerror (const char *str);
192 /* Allocation of expressions. */
194 static struct expression *
195 new_exp (int nargs, enum expression_operator op,
196 struct expression * const *args)
198 int i;
199 struct expression *newp;
201 /* If any of the argument could not be malloc'ed, just return NULL. */
202 for (i = nargs - 1; i >= 0; i--)
203 if (args[i] == NULL)
204 goto fail;
206 /* Allocate a new expression. */
207 newp = (struct expression *) malloc (sizeof (*newp));
208 if (newp != NULL)
210 newp->nargs = nargs;
211 newp->operation = op;
212 for (i = nargs - 1; i >= 0; i--)
213 newp->val.args[i] = args[i];
214 return newp;
217 fail:
218 for (i = nargs - 1; i >= 0; i--)
219 FREE_EXPRESSION (args[i]);
221 return NULL;
224 static inline struct expression *
225 new_exp_0 (enum expression_operator op)
227 return new_exp (0, op, NULL);
230 static inline struct expression *
231 new_exp_1 (enum expression_operator op, struct expression *right)
233 struct expression *args[1];
235 args[0] = right;
236 return new_exp (1, op, args);
239 static struct expression *
240 new_exp_2 (enum expression_operator op, struct expression *left,
241 struct expression *right)
243 struct expression *args[2];
245 args[0] = left;
246 args[1] = right;
247 return new_exp (2, op, args);
250 static inline struct expression *
251 new_exp_3 (enum expression_operator op, struct expression *bexp,
252 struct expression *tbranch, struct expression *fbranch)
254 struct expression *args[3];
256 args[0] = bexp;
257 args[1] = tbranch;
258 args[2] = fbranch;
259 return new_exp (3, op, args);
263 /* Line 221 of yacc.c. */
264 #line 265 "plural.c"
266 #ifdef short
267 # undef short
268 #endif
270 #ifdef YYTYPE_UINT8
271 typedef YYTYPE_UINT8 yytype_uint8;
272 #else
273 typedef unsigned char yytype_uint8;
274 #endif
276 #ifdef YYTYPE_INT8
277 typedef YYTYPE_INT8 yytype_int8;
278 #elif (defined __STDC__ || defined __C99__FUNC__ \
279 || defined __cplusplus || defined _MSC_VER)
280 typedef signed char yytype_int8;
281 #else
282 typedef short int yytype_int8;
283 #endif
285 #ifdef YYTYPE_UINT16
286 typedef YYTYPE_UINT16 yytype_uint16;
287 #else
288 typedef unsigned short int yytype_uint16;
289 #endif
291 #ifdef YYTYPE_INT16
292 typedef YYTYPE_INT16 yytype_int16;
293 #else
294 typedef short int yytype_int16;
295 #endif
297 #ifndef YYSIZE_T
298 # ifdef __SIZE_TYPE__
299 # define YYSIZE_T __SIZE_TYPE__
300 # elif defined size_t
301 # define YYSIZE_T size_t
302 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
303 || defined __cplusplus || defined _MSC_VER)
304 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
305 # define YYSIZE_T size_t
306 # else
307 # define YYSIZE_T unsigned int
308 # endif
309 #endif
311 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
313 #ifndef YY_
314 # if YYENABLE_NLS
315 # if ENABLE_NLS
316 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
317 # define YY_(msgid) dgettext ("bison-runtime", msgid)
318 # endif
319 # endif
320 # ifndef YY_
321 # define YY_(msgid) msgid
322 # endif
323 #endif
325 /* Suppress unused-variable warnings by "using" E. */
326 #if ! defined lint || defined __GNUC__
327 # define YYUSE(e) ((void) (e))
328 #else
329 # define YYUSE(e) /* empty */
330 #endif
332 /* Identity function, used to suppress warnings about constant conditions. */
333 #ifndef lint
334 # define YYID(n) (n)
335 #else
336 #if (defined __STDC__ || defined __C99__FUNC__ \
337 || defined __cplusplus || defined _MSC_VER)
338 static int
339 YYID (int yyi)
340 #else
341 static int
342 YYID (yyi)
343 int yyi;
344 #endif
346 return yyi;
348 #endif
350 #if ! defined yyoverflow || YYERROR_VERBOSE
352 /* The parser invokes alloca or malloc; define the necessary symbols. */
354 # ifdef YYSTACK_USE_ALLOCA
355 # if YYSTACK_USE_ALLOCA
356 # ifdef __GNUC__
357 # define YYSTACK_ALLOC __builtin_alloca
358 # elif defined __BUILTIN_VA_ARG_INCR
359 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
360 # elif defined _AIX
361 # define YYSTACK_ALLOC __alloca
362 # elif defined _MSC_VER
363 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
364 # define alloca _alloca
365 # else
366 # define YYSTACK_ALLOC alloca
367 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
368 || defined __cplusplus || defined _MSC_VER)
369 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
370 # ifndef _STDLIB_H
371 # define _STDLIB_H 1
372 # endif
373 # endif
374 # endif
375 # endif
376 # endif
378 # ifdef YYSTACK_ALLOC
379 /* Pacify GCC's `empty if-body' warning. */
380 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
381 # ifndef YYSTACK_ALLOC_MAXIMUM
382 /* The OS might guarantee only one guard page at the bottom of the stack,
383 and a page size can be as small as 4096 bytes. So we cannot safely
384 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
385 to allow for a few compiler-allocated temporary stack slots. */
386 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
387 # endif
388 # else
389 # define YYSTACK_ALLOC YYMALLOC
390 # define YYSTACK_FREE YYFREE
391 # ifndef YYSTACK_ALLOC_MAXIMUM
392 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
393 # endif
394 # if (defined __cplusplus && ! defined _STDLIB_H \
395 && ! ((defined YYMALLOC || defined malloc) \
396 && (defined YYFREE || defined free)))
397 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
398 # ifndef _STDLIB_H
399 # define _STDLIB_H 1
400 # endif
401 # endif
402 # ifndef YYMALLOC
403 # define YYMALLOC malloc
404 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
405 || defined __cplusplus || defined _MSC_VER)
406 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
407 # endif
408 # endif
409 # ifndef YYFREE
410 # define YYFREE free
411 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
412 || defined __cplusplus || defined _MSC_VER)
413 void free (void *); /* INFRINGES ON USER NAME SPACE */
414 # endif
415 # endif
416 # endif
417 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
420 #if (! defined yyoverflow \
421 && (! defined __cplusplus \
422 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
424 /* A type that is properly aligned for any stack member. */
425 union yyalloc
427 yytype_int16 yyss;
428 YYSTYPE yyvs;
431 /* The size of the maximum gap between one aligned stack and the next. */
432 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
434 /* The size of an array large to enough to hold all stacks, each with
435 N elements. */
436 # define YYSTACK_BYTES(N) \
437 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
438 + YYSTACK_GAP_MAXIMUM)
440 /* Copy COUNT objects from FROM to TO. The source and destination do
441 not overlap. */
442 # ifndef YYCOPY
443 # if defined __GNUC__ && 1 < __GNUC__
444 # define YYCOPY(To, From, Count) \
445 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
446 # else
447 # define YYCOPY(To, From, Count) \
448 do \
450 YYSIZE_T yyi; \
451 for (yyi = 0; yyi < (Count); yyi++) \
452 (To)[yyi] = (From)[yyi]; \
454 while (YYID (0))
455 # endif
456 # endif
458 /* Relocate STACK from its old location to the new one. The
459 local variables YYSIZE and YYSTACKSIZE give the old and new number of
460 elements in the stack, and YYPTR gives the new location of the
461 stack. Advance YYPTR to a properly aligned location for the next
462 stack. */
463 # define YYSTACK_RELOCATE(Stack) \
464 do \
466 YYSIZE_T yynewbytes; \
467 YYCOPY (&yyptr->Stack, Stack, yysize); \
468 Stack = &yyptr->Stack; \
469 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
470 yyptr += yynewbytes / sizeof (*yyptr); \
472 while (YYID (0))
474 #endif
476 /* YYFINAL -- State number of the termination state. */
477 #define YYFINAL 9
478 /* YYLAST -- Last index in YYTABLE. */
479 #define YYLAST 54
481 /* YYNTOKENS -- Number of terminals. */
482 #define YYNTOKENS 16
483 /* YYNNTS -- Number of nonterminals. */
484 #define YYNNTS 3
485 /* YYNRULES -- Number of rules. */
486 #define YYNRULES 13
487 /* YYNRULES -- Number of states. */
488 #define YYNSTATES 27
490 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
491 #define YYUNDEFTOK 2
492 #define YYMAXUTOK 262
494 #define YYTRANSLATE(YYX) \
495 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
497 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
498 static const yytype_uint8 yytranslate[] =
500 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
501 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
502 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
503 2, 2, 2, 10, 2, 2, 2, 2, 5, 2,
504 14, 15, 2, 2, 2, 2, 2, 2, 2, 2,
505 2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
506 2, 2, 2, 3, 2, 2, 2, 2, 2, 2,
507 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
508 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
509 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
510 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
511 13, 2, 2, 2, 2, 2, 2, 2, 2, 2,
512 2, 2, 2, 2, 4, 2, 2, 2, 2, 2,
513 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
514 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
515 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
516 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
517 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
518 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
519 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
520 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
521 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
522 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
523 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
524 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
525 2, 2, 2, 2, 2, 2, 1, 2, 6, 7,
526 8, 9, 11
529 #if YYDEBUG
530 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
531 YYRHS. */
532 static const yytype_uint8 yyprhs[] =
534 0, 0, 3, 5, 11, 15, 19, 23, 27, 31,
535 35, 38, 40, 42
538 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
539 static const yytype_int8 yyrhs[] =
541 17, 0, -1, 18, -1, 18, 3, 18, 12, 18,
542 -1, 18, 4, 18, -1, 18, 5, 18, -1, 18,
543 6, 18, -1, 18, 7, 18, -1, 18, 8, 18,
544 -1, 18, 9, 18, -1, 10, 18, -1, 13, -1,
545 11, -1, 14, 18, 15, -1
548 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
549 static const yytype_uint8 yyrline[] =
551 0, 154, 154, 162, 166, 170, 174, 178, 182, 186,
552 190, 194, 198, 203
554 #endif
556 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
557 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
558 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
559 static const char *const yytname[] =
561 "$end", "error", "$undefined", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
562 "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
563 "$accept", "start", "exp", 0
565 #endif
567 # ifdef YYPRINT
568 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
569 token YYLEX-NUM. */
570 static const yytype_uint16 yytoknum[] =
572 0, 256, 257, 63, 124, 38, 258, 259, 260, 261,
573 33, 262, 58, 110, 40, 41
575 # endif
577 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
578 static const yytype_uint8 yyr1[] =
580 0, 16, 17, 18, 18, 18, 18, 18, 18, 18,
581 18, 18, 18, 18
584 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
585 static const yytype_uint8 yyr2[] =
587 0, 2, 1, 5, 3, 3, 3, 3, 3, 3,
588 2, 1, 1, 3
591 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
592 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
593 means the default is an error. */
594 static const yytype_uint8 yydefact[] =
596 0, 0, 12, 11, 0, 0, 2, 10, 0, 1,
597 0, 0, 0, 0, 0, 0, 0, 13, 0, 4,
598 5, 6, 7, 8, 9, 0, 3
601 /* YYDEFGOTO[NTERM-NUM]. */
602 static const yytype_int8 yydefgoto[] =
604 -1, 5, 6
607 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
608 STATE-NUM. */
609 #define YYPACT_NINF -10
610 static const yytype_int8 yypact[] =
612 -9, -9, -10, -10, -9, 8, 36, -10, 13, -10,
613 -9, -9, -9, -9, -9, -9, -9, -10, 26, 41,
614 45, 18, -2, 14, -10, -9, 36
617 /* YYPGOTO[NTERM-NUM]. */
618 static const yytype_int8 yypgoto[] =
620 -10, -10, -1
623 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
624 positive, shift that token. If negative, reduce the rule which
625 number is the opposite. If zero, do what YYDEFACT says.
626 If YYTABLE_NINF, syntax error. */
627 #define YYTABLE_NINF -1
628 static const yytype_uint8 yytable[] =
630 7, 1, 2, 8, 3, 4, 15, 16, 9, 18,
631 19, 20, 21, 22, 23, 24, 10, 11, 12, 13,
632 14, 15, 16, 16, 26, 14, 15, 16, 17, 10,
633 11, 12, 13, 14, 15, 16, 0, 0, 25, 10,
634 11, 12, 13, 14, 15, 16, 12, 13, 14, 15,
635 16, 13, 14, 15, 16
638 static const yytype_int8 yycheck[] =
640 1, 10, 11, 4, 13, 14, 8, 9, 0, 10,
641 11, 12, 13, 14, 15, 16, 3, 4, 5, 6,
642 7, 8, 9, 9, 25, 7, 8, 9, 15, 3,
643 4, 5, 6, 7, 8, 9, -1, -1, 12, 3,
644 4, 5, 6, 7, 8, 9, 5, 6, 7, 8,
645 9, 6, 7, 8, 9
648 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
649 symbol of state STATE-NUM. */
650 static const yytype_uint8 yystos[] =
652 0, 10, 11, 13, 14, 17, 18, 18, 18, 0,
653 3, 4, 5, 6, 7, 8, 9, 15, 18, 18,
654 18, 18, 18, 18, 18, 12, 18
657 #define yyerrok (yyerrstatus = 0)
658 #define yyclearin (yychar = YYEMPTY)
659 #define YYEMPTY (-2)
660 #define YYEOF 0
662 #define YYACCEPT goto yyacceptlab
663 #define YYABORT goto yyabortlab
664 #define YYERROR goto yyerrorlab
667 /* Like YYERROR except do call yyerror. This remains here temporarily
668 to ease the transition to the new meaning of YYERROR, for GCC.
669 Once GCC version 2 has supplanted version 1, this can go. */
671 #define YYFAIL goto yyerrlab
673 #define YYRECOVERING() (!!yyerrstatus)
675 #define YYBACKUP(Token, Value) \
676 do \
677 if (yychar == YYEMPTY && yylen == 1) \
679 yychar = (Token); \
680 yylval = (Value); \
681 yytoken = YYTRANSLATE (yychar); \
682 YYPOPSTACK (1); \
683 goto yybackup; \
685 else \
687 yyerror (YY_("syntax error: cannot back up")); \
688 YYERROR; \
690 while (YYID (0))
693 #define YYTERROR 1
694 #define YYERRCODE 256
697 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
698 If N is 0, then set CURRENT to the empty location which ends
699 the previous symbol: RHS[0] (always defined). */
701 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
702 #ifndef YYLLOC_DEFAULT
703 # define YYLLOC_DEFAULT(Current, Rhs, N) \
704 do \
705 if (YYID (N)) \
707 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
708 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
709 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
710 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
712 else \
714 (Current).first_line = (Current).last_line = \
715 YYRHSLOC (Rhs, 0).last_line; \
716 (Current).first_column = (Current).last_column = \
717 YYRHSLOC (Rhs, 0).last_column; \
719 while (YYID (0))
720 #endif
723 /* YY_LOCATION_PRINT -- Print the location on the stream.
724 This macro was not mandated originally: define only if we know
725 we won't break user code: when these are the locations we know. */
727 #ifndef YY_LOCATION_PRINT
728 # if YYLTYPE_IS_TRIVIAL
729 # define YY_LOCATION_PRINT(File, Loc) \
730 fprintf (File, "%d.%d-%d.%d", \
731 (Loc).first_line, (Loc).first_column, \
732 (Loc).last_line, (Loc).last_column)
733 # else
734 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
735 # endif
736 #endif
739 /* YYLEX -- calling `yylex' with the right arguments. */
741 #ifdef YYLEX_PARAM
742 # define YYLEX yylex (&yylval, YYLEX_PARAM)
743 #else
744 # define YYLEX yylex (&yylval)
745 #endif
747 /* Enable debugging if requested. */
748 #if YYDEBUG
750 # ifndef YYFPRINTF
751 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
752 # define YYFPRINTF fprintf
753 # endif
755 # define YYDPRINTF(Args) \
756 do { \
757 if (yydebug) \
758 YYFPRINTF Args; \
759 } while (YYID (0))
761 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
762 do { \
763 if (yydebug) \
765 YYFPRINTF (stderr, "%s ", Title); \
766 yy_symbol_print (stderr, \
767 Type, Value); \
768 YYFPRINTF (stderr, "\n"); \
770 } while (YYID (0))
773 /*--------------------------------.
774 | Print this symbol on YYOUTPUT. |
775 `--------------------------------*/
777 /*ARGSUSED*/
778 #if (defined __STDC__ || defined __C99__FUNC__ \
779 || defined __cplusplus || defined _MSC_VER)
780 static void
781 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
782 #else
783 static void
784 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
785 FILE *yyoutput;
786 int yytype;
787 YYSTYPE const * const yyvaluep;
788 #endif
790 if (!yyvaluep)
791 return;
792 # ifdef YYPRINT
793 if (yytype < YYNTOKENS)
794 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
795 # else
796 YYUSE (yyoutput);
797 # endif
798 switch (yytype)
800 default:
801 break;
806 /*--------------------------------.
807 | Print this symbol on YYOUTPUT. |
808 `--------------------------------*/
810 #if (defined __STDC__ || defined __C99__FUNC__ \
811 || defined __cplusplus || defined _MSC_VER)
812 static void
813 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
814 #else
815 static void
816 yy_symbol_print (yyoutput, yytype, yyvaluep)
817 FILE *yyoutput;
818 int yytype;
819 YYSTYPE const * const yyvaluep;
820 #endif
822 if (yytype < YYNTOKENS)
823 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
824 else
825 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
827 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
828 YYFPRINTF (yyoutput, ")");
831 /*------------------------------------------------------------------.
832 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
833 | TOP (included). |
834 `------------------------------------------------------------------*/
836 #if (defined __STDC__ || defined __C99__FUNC__ \
837 || defined __cplusplus || defined _MSC_VER)
838 static void
839 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
840 #else
841 static void
842 yy_stack_print (yybottom, yytop)
843 yytype_int16 *yybottom;
844 yytype_int16 *yytop;
845 #endif
847 YYFPRINTF (stderr, "Stack now");
848 for (; yybottom <= yytop; yybottom++)
850 int yybot = *yybottom;
851 YYFPRINTF (stderr, " %d", yybot);
853 YYFPRINTF (stderr, "\n");
856 # define YY_STACK_PRINT(Bottom, Top) \
857 do { \
858 if (yydebug) \
859 yy_stack_print ((Bottom), (Top)); \
860 } while (YYID (0))
863 /*------------------------------------------------.
864 | Report that the YYRULE is going to be reduced. |
865 `------------------------------------------------*/
867 #if (defined __STDC__ || defined __C99__FUNC__ \
868 || defined __cplusplus || defined _MSC_VER)
869 static void
870 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
871 #else
872 static void
873 yy_reduce_print (yyvsp, yyrule)
874 YYSTYPE *yyvsp;
875 int yyrule;
876 #endif
878 int yynrhs = yyr2[yyrule];
879 int yyi;
880 unsigned long int yylno = yyrline[yyrule];
881 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
882 yyrule - 1, yylno);
883 /* The symbols being reduced. */
884 for (yyi = 0; yyi < yynrhs; yyi++)
886 fprintf (stderr, " $%d = ", yyi + 1);
887 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
888 &(yyvsp[(yyi + 1) - (yynrhs)])
890 fprintf (stderr, "\n");
894 # define YY_REDUCE_PRINT(Rule) \
895 do { \
896 if (yydebug) \
897 yy_reduce_print (yyvsp, Rule); \
898 } while (YYID (0))
900 /* Nonzero means print parse trace. It is left uninitialized so that
901 multiple parsers can coexist. */
902 int yydebug;
903 #else /* !YYDEBUG */
904 # define YYDPRINTF(Args)
905 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
906 # define YY_STACK_PRINT(Bottom, Top)
907 # define YY_REDUCE_PRINT(Rule)
908 #endif /* !YYDEBUG */
911 /* YYINITDEPTH -- initial size of the parser's stacks. */
912 #ifndef YYINITDEPTH
913 # define YYINITDEPTH 200
914 #endif
916 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
917 if the built-in stack extension method is used).
919 Do not make this value too large; the results are undefined if
920 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
921 evaluated with infinite-precision integer arithmetic. */
923 #ifndef YYMAXDEPTH
924 # define YYMAXDEPTH 10000
925 #endif
929 #if YYERROR_VERBOSE
931 # ifndef yystrlen
932 # if defined __GLIBC__ && defined _STRING_H
933 # define yystrlen strlen
934 # else
935 /* Return the length of YYSTR. */
936 #if (defined __STDC__ || defined __C99__FUNC__ \
937 || defined __cplusplus || defined _MSC_VER)
938 static YYSIZE_T
939 yystrlen (const char *yystr)
940 #else
941 static YYSIZE_T
942 yystrlen (yystr)
943 const char *yystr;
944 #endif
946 YYSIZE_T yylen;
947 for (yylen = 0; yystr[yylen]; yylen++)
948 continue;
949 return yylen;
951 # endif
952 # endif
954 # ifndef yystpcpy
955 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
956 # define yystpcpy stpcpy
957 # else
958 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
959 YYDEST. */
960 #if (defined __STDC__ || defined __C99__FUNC__ \
961 || defined __cplusplus || defined _MSC_VER)
962 static char *
963 yystpcpy (char *yydest, const char *yysrc)
964 #else
965 static char *
966 yystpcpy (yydest, yysrc)
967 char *yydest;
968 const char *yysrc;
969 #endif
971 char *yyd = yydest;
972 const char *yys = yysrc;
974 while ((*yyd++ = *yys++) != '\0')
975 continue;
977 return yyd - 1;
979 # endif
980 # endif
982 # ifndef yytnamerr
983 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
984 quotes and backslashes, so that it's suitable for yyerror. The
985 heuristic is that double-quoting is unnecessary unless the string
986 contains an apostrophe, a comma, or backslash (other than
987 backslash-backslash). YYSTR is taken from yytname. If YYRES is
988 null, do not copy; instead, return the length of what the result
989 would have been. */
990 static YYSIZE_T
991 yytnamerr (char *yyres, const char *yystr)
993 if (*yystr == '"')
995 YYSIZE_T yyn = 0;
996 char const *yyp = yystr;
998 for (;;)
999 switch (*++yyp)
1001 case '\'':
1002 case ',':
1003 goto do_not_strip_quotes;
1005 case '\\':
1006 if (*++yyp != '\\')
1007 goto do_not_strip_quotes;
1008 /* Fall through. */
1009 default:
1010 if (yyres)
1011 yyres[yyn] = *yyp;
1012 yyn++;
1013 break;
1015 case '"':
1016 if (yyres)
1017 yyres[yyn] = '\0';
1018 return yyn;
1020 do_not_strip_quotes: ;
1023 if (! yyres)
1024 return yystrlen (yystr);
1026 return yystpcpy (yyres, yystr) - yyres;
1028 # endif
1030 /* Copy into YYRESULT an error message about the unexpected token
1031 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1032 including the terminating null byte. If YYRESULT is null, do not
1033 copy anything; just return the number of bytes that would be
1034 copied. As a special case, return 0 if an ordinary "syntax error"
1035 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1036 size calculation. */
1037 static YYSIZE_T
1038 yysyntax_error (char *yyresult, int yystate, int yychar)
1040 int yyn = yypact[yystate];
1042 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1043 return 0;
1044 else
1046 int yytype = YYTRANSLATE (yychar);
1047 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1048 YYSIZE_T yysize = yysize0;
1049 YYSIZE_T yysize1;
1050 int yysize_overflow = 0;
1051 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1052 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1053 int yyx;
1055 # if 0
1056 /* This is so xgettext sees the translatable formats that are
1057 constructed on the fly. */
1058 YY_("syntax error, unexpected %s");
1059 YY_("syntax error, unexpected %s, expecting %s");
1060 YY_("syntax error, unexpected %s, expecting %s or %s");
1061 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1062 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1063 # endif
1064 char *yyfmt;
1065 char const *yyf;
1066 static char const yyunexpected[] = "syntax error, unexpected %s";
1067 static char const yyexpecting[] = ", expecting %s";
1068 static char const yyor[] = " or %s";
1069 char yyformat[sizeof yyunexpected
1070 + sizeof yyexpecting - 1
1071 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1072 * (sizeof yyor - 1))];
1073 char const *yyprefix = yyexpecting;
1075 /* Start YYX at -YYN if negative to avoid negative indexes in
1076 YYCHECK. */
1077 int yyxbegin = yyn < 0 ? -yyn : 0;
1079 /* Stay within bounds of both yycheck and yytname. */
1080 int yychecklim = YYLAST - yyn + 1;
1081 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1082 int yycount = 1;
1084 yyarg[0] = yytname[yytype];
1085 yyfmt = yystpcpy (yyformat, yyunexpected);
1087 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1088 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1090 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1092 yycount = 1;
1093 yysize = yysize0;
1094 yyformat[sizeof yyunexpected - 1] = '\0';
1095 break;
1097 yyarg[yycount++] = yytname[yyx];
1098 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1099 yysize_overflow |= (yysize1 < yysize);
1100 yysize = yysize1;
1101 yyfmt = yystpcpy (yyfmt, yyprefix);
1102 yyprefix = yyor;
1105 yyf = YY_(yyformat);
1106 yysize1 = yysize + yystrlen (yyf);
1107 yysize_overflow |= (yysize1 < yysize);
1108 yysize = yysize1;
1110 if (yysize_overflow)
1111 return YYSIZE_MAXIMUM;
1113 if (yyresult)
1115 /* Avoid sprintf, as that infringes on the user's name space.
1116 Don't have undefined behavior even if the translation
1117 produced a string with the wrong number of "%s"s. */
1118 char *yyp = yyresult;
1119 int yyi = 0;
1120 while ((*yyp = *yyf) != '\0')
1122 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1124 yyp += yytnamerr (yyp, yyarg[yyi++]);
1125 yyf += 2;
1127 else
1129 yyp++;
1130 yyf++;
1134 return yysize;
1137 #endif /* YYERROR_VERBOSE */
1140 /*-----------------------------------------------.
1141 | Release the memory associated to this symbol. |
1142 `-----------------------------------------------*/
1144 /*ARGSUSED*/
1145 #if (defined __STDC__ || defined __C99__FUNC__ \
1146 || defined __cplusplus || defined _MSC_VER)
1147 static void
1148 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1149 #else
1150 static void
1151 yydestruct (yymsg, yytype, yyvaluep)
1152 const char *yymsg;
1153 int yytype;
1154 YYSTYPE *yyvaluep;
1155 #endif
1157 YYUSE (yyvaluep);
1159 if (!yymsg)
1160 yymsg = "Deleting";
1161 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1163 switch (yytype)
1166 default:
1167 break;
1172 /* Prevent warnings from -Wmissing-prototypes. */
1174 #ifdef YYPARSE_PARAM
1175 #if defined __STDC__ || defined __cplusplus
1176 int yyparse (void *YYPARSE_PARAM);
1177 #else
1178 int yyparse ();
1179 #endif
1180 #else /* ! YYPARSE_PARAM */
1181 #if defined __STDC__ || defined __cplusplus
1182 int yyparse (void);
1183 #else
1184 int yyparse ();
1185 #endif
1186 #endif /* ! YYPARSE_PARAM */
1193 /*----------.
1194 | yyparse. |
1195 `----------*/
1197 #ifdef YYPARSE_PARAM
1198 #if (defined __STDC__ || defined __C99__FUNC__ \
1199 || defined __cplusplus || defined _MSC_VER)
1201 yyparse (void *YYPARSE_PARAM)
1202 #else
1204 yyparse (YYPARSE_PARAM)
1205 void *YYPARSE_PARAM;
1206 #endif
1207 #else /* ! YYPARSE_PARAM */
1208 #if (defined __STDC__ || defined __C99__FUNC__ \
1209 || defined __cplusplus || defined _MSC_VER)
1211 yyparse (void)
1212 #else
1214 yyparse ()
1216 #endif
1217 #endif
1219 /* The lookahead symbol. */
1220 int yychar;
1222 /* The semantic value of the lookahead symbol. */
1223 YYSTYPE yylval;
1225 /* Number of syntax errors so far. */
1226 int yynerrs;
1228 int yystate;
1229 int yyn;
1230 int yyresult;
1231 /* Number of tokens to shift before error messages enabled. */
1232 int yyerrstatus;
1233 /* Lookahead token as an internal (translated) token number. */
1234 int yytoken = 0;
1235 #if YYERROR_VERBOSE
1236 /* Buffer for error messages, and its allocated size. */
1237 char yymsgbuf[128];
1238 char *yymsg = yymsgbuf;
1239 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1240 #endif
1242 /* Three stacks and their tools:
1243 `yyss': related to states,
1244 `yyvs': related to semantic values,
1245 `yyls': related to locations.
1247 Refer to the stacks thru separate pointers, to allow yyoverflow
1248 to reallocate them elsewhere. */
1250 /* The state stack. */
1251 yytype_int16 yyssa[YYINITDEPTH];
1252 yytype_int16 *yyss = yyssa;
1253 yytype_int16 *yyssp;
1255 /* The semantic value stack. */
1256 YYSTYPE yyvsa[YYINITDEPTH];
1257 YYSTYPE *yyvs = yyvsa;
1258 YYSTYPE *yyvsp;
1262 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1264 YYSIZE_T yystacksize = YYINITDEPTH;
1266 /* The variables used to return semantic value and location from the
1267 action routines. */
1268 YYSTYPE yyval;
1271 /* The number of symbols on the RHS of the reduced rule.
1272 Keep to zero when no symbol should be popped. */
1273 int yylen = 0;
1275 YYDPRINTF ((stderr, "Starting parse\n"));
1277 yystate = 0;
1278 yyerrstatus = 0;
1279 yynerrs = 0;
1280 yychar = YYEMPTY; /* Cause a token to be read. */
1282 /* Initialize stack pointers.
1283 Waste one element of value and location stack
1284 so that they stay on the same level as the state stack.
1285 The wasted elements are never initialized. */
1287 yyssp = yyss;
1288 yyvsp = yyvs;
1290 goto yysetstate;
1292 /*------------------------------------------------------------.
1293 | yynewstate -- Push a new state, which is found in yystate. |
1294 `------------------------------------------------------------*/
1295 yynewstate:
1296 /* In all cases, when you get here, the value and location stacks
1297 have just been pushed. So pushing a state here evens the stacks. */
1298 yyssp++;
1300 yysetstate:
1301 *yyssp = yystate;
1303 if (yyss + yystacksize - 1 <= yyssp)
1305 /* Get the current used size of the three stacks, in elements. */
1306 YYSIZE_T yysize = yyssp - yyss + 1;
1308 #ifdef yyoverflow
1310 /* Give user a chance to reallocate the stack. Use copies of
1311 these so that the &'s don't force the real ones into
1312 memory. */
1313 YYSTYPE *yyvs1 = yyvs;
1314 yytype_int16 *yyss1 = yyss;
1317 /* Each stack pointer address is followed by the size of the
1318 data in use in that stack, in bytes. This used to be a
1319 conditional around just the two extra args, but that might
1320 be undefined if yyoverflow is a macro. */
1321 yyoverflow (YY_("memory exhausted"),
1322 &yyss1, yysize * sizeof (*yyssp),
1323 &yyvs1, yysize * sizeof (*yyvsp),
1325 &yystacksize);
1327 yyss = yyss1;
1328 yyvs = yyvs1;
1330 #else /* no yyoverflow */
1331 # ifndef YYSTACK_RELOCATE
1332 goto yyexhaustedlab;
1333 # else
1334 /* Extend the stack our own way. */
1335 if (YYMAXDEPTH <= yystacksize)
1336 goto yyexhaustedlab;
1337 yystacksize *= 2;
1338 if (YYMAXDEPTH < yystacksize)
1339 yystacksize = YYMAXDEPTH;
1342 yytype_int16 *yyss1 = yyss;
1343 union yyalloc *yyptr =
1344 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1345 if (! yyptr)
1346 goto yyexhaustedlab;
1347 YYSTACK_RELOCATE (yyss);
1348 YYSTACK_RELOCATE (yyvs);
1350 # undef YYSTACK_RELOCATE
1351 if (yyss1 != yyssa)
1352 YYSTACK_FREE (yyss1);
1354 # endif
1355 #endif /* no yyoverflow */
1357 yyssp = yyss + yysize - 1;
1358 yyvsp = yyvs + yysize - 1;
1361 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1362 (unsigned long int) yystacksize));
1364 if (yyss + yystacksize - 1 <= yyssp)
1365 YYABORT;
1368 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1370 if (yystate == YYFINAL)
1371 YYACCEPT;
1373 goto yybackup;
1375 /*-----------.
1376 | yybackup. |
1377 `-----------*/
1378 yybackup:
1380 /* Do appropriate processing given the current state. Read a
1381 lookahead token if we need one and don't already have one. */
1383 /* First try to decide what to do without reference to lookahead token. */
1384 yyn = yypact[yystate];
1385 if (yyn == YYPACT_NINF)
1386 goto yydefault;
1388 /* Not known => get a lookahead token if don't already have one. */
1390 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1391 if (yychar == YYEMPTY)
1393 YYDPRINTF ((stderr, "Reading a token: "));
1394 yychar = YYLEX;
1397 if (yychar <= YYEOF)
1399 yychar = yytoken = YYEOF;
1400 YYDPRINTF ((stderr, "Now at end of input.\n"));
1402 else
1404 yytoken = YYTRANSLATE (yychar);
1405 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1408 /* If the proper action on seeing token YYTOKEN is to reduce or to
1409 detect an error, take that action. */
1410 yyn += yytoken;
1411 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1412 goto yydefault;
1413 yyn = yytable[yyn];
1414 if (yyn <= 0)
1416 if (yyn == 0 || yyn == YYTABLE_NINF)
1417 goto yyerrlab;
1418 yyn = -yyn;
1419 goto yyreduce;
1422 /* Count tokens shifted since error; after three, turn off error
1423 status. */
1424 if (yyerrstatus)
1425 yyerrstatus--;
1427 /* Shift the lookahead token. */
1428 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1430 /* Discard the shifted token. */
1431 yychar = YYEMPTY;
1433 yystate = yyn;
1434 *++yyvsp = yylval;
1436 goto yynewstate;
1439 /*-----------------------------------------------------------.
1440 | yydefault -- do the default action for the current state. |
1441 `-----------------------------------------------------------*/
1442 yydefault:
1443 yyn = yydefact[yystate];
1444 if (yyn == 0)
1445 goto yyerrlab;
1446 goto yyreduce;
1449 /*-----------------------------.
1450 | yyreduce -- Do a reduction. |
1451 `-----------------------------*/
1452 yyreduce:
1453 /* yyn is the number of a rule to reduce with. */
1454 yylen = yyr2[yyn];
1456 /* If YYLEN is nonzero, implement the default value of the action:
1457 `$$ = $1'.
1459 Otherwise, the following line sets YYVAL to garbage.
1460 This behavior is undocumented and Bison
1461 users should not rely upon it. Assigning to YYVAL
1462 unconditionally makes the parser a bit smaller, and it avoids a
1463 GCC warning that YYVAL may be used uninitialized. */
1464 yyval = yyvsp[1-yylen];
1467 YY_REDUCE_PRINT (yyn);
1468 switch (yyn)
1470 case 2:
1471 /* Line 1269 of yacc.c. */
1472 #line 155 "plural.y"
1474 if ((yyvsp[(1) - (1)].exp) == NULL)
1475 YYABORT;
1476 ((struct parse_args *) arg)->res = (yyvsp[(1) - (1)].exp);
1478 break;
1480 case 3:
1481 /* Line 1269 of yacc.c. */
1482 #line 163 "plural.y"
1484 (yyval.exp) = new_exp_3 (qmop, (yyvsp[(1) - (5)].exp), (yyvsp[(3) - (5)].exp), (yyvsp[(5) - (5)].exp));
1486 break;
1488 case 4:
1489 /* Line 1269 of yacc.c. */
1490 #line 167 "plural.y"
1492 (yyval.exp) = new_exp_2 (lor, (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1494 break;
1496 case 5:
1497 /* Line 1269 of yacc.c. */
1498 #line 171 "plural.y"
1500 (yyval.exp) = new_exp_2 (land, (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1502 break;
1504 case 6:
1505 /* Line 1269 of yacc.c. */
1506 #line 175 "plural.y"
1508 (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1510 break;
1512 case 7:
1513 /* Line 1269 of yacc.c. */
1514 #line 179 "plural.y"
1516 (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1518 break;
1520 case 8:
1521 /* Line 1269 of yacc.c. */
1522 #line 183 "plural.y"
1524 (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1526 break;
1528 case 9:
1529 /* Line 1269 of yacc.c. */
1530 #line 187 "plural.y"
1532 (yyval.exp) = new_exp_2 ((yyvsp[(2) - (3)].op), (yyvsp[(1) - (3)].exp), (yyvsp[(3) - (3)].exp));
1534 break;
1536 case 10:
1537 /* Line 1269 of yacc.c. */
1538 #line 191 "plural.y"
1540 (yyval.exp) = new_exp_1 (lnot, (yyvsp[(2) - (2)].exp));
1542 break;
1544 case 11:
1545 /* Line 1269 of yacc.c. */
1546 #line 195 "plural.y"
1548 (yyval.exp) = new_exp_0 (var);
1550 break;
1552 case 12:
1553 /* Line 1269 of yacc.c. */
1554 #line 199 "plural.y"
1556 if (((yyval.exp) = new_exp_0 (num)) != NULL)
1557 (yyval.exp)->val.num = (yyvsp[(1) - (1)].num);
1559 break;
1561 case 13:
1562 /* Line 1269 of yacc.c. */
1563 #line 204 "plural.y"
1565 (yyval.exp) = (yyvsp[(2) - (3)].exp);
1567 break;
1570 /* Line 1269 of yacc.c. */
1571 #line 1572 "plural.c"
1572 default: break;
1574 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1576 YYPOPSTACK (yylen);
1577 yylen = 0;
1578 YY_STACK_PRINT (yyss, yyssp);
1580 *++yyvsp = yyval;
1583 /* Now `shift' the result of the reduction. Determine what state
1584 that goes to, based on the state we popped back to and the rule
1585 number reduced by. */
1587 yyn = yyr1[yyn];
1589 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1590 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1591 yystate = yytable[yystate];
1592 else
1593 yystate = yydefgoto[yyn - YYNTOKENS];
1595 goto yynewstate;
1598 /*------------------------------------.
1599 | yyerrlab -- here on detecting error |
1600 `------------------------------------*/
1601 yyerrlab:
1602 /* If not already recovering from an error, report this error. */
1603 if (!yyerrstatus)
1605 ++yynerrs;
1606 #if ! YYERROR_VERBOSE
1607 yyerror (YY_("syntax error"));
1608 #else
1610 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1611 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1613 YYSIZE_T yyalloc = 2 * yysize;
1614 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1615 yyalloc = YYSTACK_ALLOC_MAXIMUM;
1616 if (yymsg != yymsgbuf)
1617 YYSTACK_FREE (yymsg);
1618 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1619 if (yymsg)
1620 yymsg_alloc = yyalloc;
1621 else
1623 yymsg = yymsgbuf;
1624 yymsg_alloc = sizeof yymsgbuf;
1628 if (0 < yysize && yysize <= yymsg_alloc)
1630 (void) yysyntax_error (yymsg, yystate, yychar);
1631 yyerror (yymsg);
1633 else
1635 yyerror (YY_("syntax error"));
1636 if (yysize != 0)
1637 goto yyexhaustedlab;
1640 #endif
1645 if (yyerrstatus == 3)
1647 /* If just tried and failed to reuse lookahead token after an
1648 error, discard it. */
1650 if (yychar <= YYEOF)
1652 /* Return failure if at end of input. */
1653 if (yychar == YYEOF)
1654 YYABORT;
1656 else
1658 yydestruct ("Error: discarding",
1659 yytoken, &yylval);
1660 yychar = YYEMPTY;
1664 /* Else will try to reuse lookahead token after shifting the error
1665 token. */
1666 goto yyerrlab1;
1669 /*---------------------------------------------------.
1670 | yyerrorlab -- error raised explicitly by YYERROR. |
1671 `---------------------------------------------------*/
1672 yyerrorlab:
1674 /* Pacify compilers like GCC when the user code never invokes
1675 YYERROR and the label yyerrorlab therefore never appears in user
1676 code. */
1677 if (/*CONSTCOND*/ 0)
1678 goto yyerrorlab;
1680 /* Do not reclaim the symbols of the rule which action triggered
1681 this YYERROR. */
1682 YYPOPSTACK (yylen);
1683 yylen = 0;
1684 YY_STACK_PRINT (yyss, yyssp);
1685 yystate = *yyssp;
1686 goto yyerrlab1;
1689 /*-------------------------------------------------------------.
1690 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1691 `-------------------------------------------------------------*/
1692 yyerrlab1:
1693 yyerrstatus = 3; /* Each real token shifted decrements this. */
1695 for (;;)
1697 yyn = yypact[yystate];
1698 if (yyn != YYPACT_NINF)
1700 yyn += YYTERROR;
1701 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1703 yyn = yytable[yyn];
1704 if (0 < yyn)
1705 break;
1709 /* Pop the current state because it cannot handle the error token. */
1710 if (yyssp == yyss)
1711 YYABORT;
1714 yydestruct ("Error: popping",
1715 yystos[yystate], yyvsp);
1716 YYPOPSTACK (1);
1717 yystate = *yyssp;
1718 YY_STACK_PRINT (yyss, yyssp);
1721 *++yyvsp = yylval;
1724 /* Shift the error token. */
1725 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1727 yystate = yyn;
1728 goto yynewstate;
1731 /*-------------------------------------.
1732 | yyacceptlab -- YYACCEPT comes here. |
1733 `-------------------------------------*/
1734 yyacceptlab:
1735 yyresult = 0;
1736 goto yyreturn;
1738 /*-----------------------------------.
1739 | yyabortlab -- YYABORT comes here. |
1740 `-----------------------------------*/
1741 yyabortlab:
1742 yyresult = 1;
1743 goto yyreturn;
1745 #ifndef yyoverflow
1746 /*-------------------------------------------------.
1747 | yyexhaustedlab -- memory exhaustion comes here. |
1748 `-------------------------------------------------*/
1749 yyexhaustedlab:
1750 yyerror (YY_("memory exhausted"));
1751 yyresult = 2;
1752 /* Fall through. */
1753 #endif
1755 yyreturn:
1756 if (yychar != YYEMPTY)
1757 yydestruct ("Cleanup: discarding lookahead",
1758 yytoken, &yylval);
1759 /* Do not reclaim the symbols of the rule which action triggered
1760 this YYABORT or YYACCEPT. */
1761 YYPOPSTACK (yylen);
1762 YY_STACK_PRINT (yyss, yyssp);
1763 while (yyssp != yyss)
1765 yydestruct ("Cleanup: popping",
1766 yystos[*yyssp], yyvsp);
1767 YYPOPSTACK (1);
1769 #ifndef yyoverflow
1770 if (yyss != yyssa)
1771 YYSTACK_FREE (yyss);
1772 #endif
1773 #if YYERROR_VERBOSE
1774 if (yymsg != yymsgbuf)
1775 YYSTACK_FREE (yymsg);
1776 #endif
1777 /* Make sure YYID is used. */
1778 return YYID (yyresult);
1782 /* Line 1486 of yacc.c. */
1783 #line 209 "plural.y"
1786 void
1787 internal_function
1788 FREE_EXPRESSION (struct expression *exp)
1790 if (exp == NULL)
1791 return;
1793 /* Handle the recursive case. */
1794 switch (exp->nargs)
1796 case 3:
1797 FREE_EXPRESSION (exp->val.args[2]);
1798 /* FALLTHROUGH */
1799 case 2:
1800 FREE_EXPRESSION (exp->val.args[1]);
1801 /* FALLTHROUGH */
1802 case 1:
1803 FREE_EXPRESSION (exp->val.args[0]);
1804 /* FALLTHROUGH */
1805 default:
1806 break;
1809 free (exp);
1813 static int
1814 yylex (YYSTYPE *lval, const char **pexp)
1816 const char *exp = *pexp;
1817 int result;
1819 while (1)
1821 if (exp[0] == '\0')
1823 *pexp = exp;
1824 return YYEOF;
1827 if (exp[0] != ' ' && exp[0] != '\t')
1828 break;
1830 ++exp;
1833 result = *exp++;
1834 switch (result)
1836 case '0': case '1': case '2': case '3': case '4':
1837 case '5': case '6': case '7': case '8': case '9':
1839 unsigned long int n = result - '0';
1840 while (exp[0] >= '0' && exp[0] <= '9')
1842 n *= 10;
1843 n += exp[0] - '0';
1844 ++exp;
1846 lval->num = n;
1847 result = NUMBER;
1849 break;
1851 case '=':
1852 if (exp[0] == '=')
1854 ++exp;
1855 lval->op = equal;
1856 result = EQUOP2;
1858 else
1859 result = YYERRCODE;
1860 break;
1862 case '!':
1863 if (exp[0] == '=')
1865 ++exp;
1866 lval->op = not_equal;
1867 result = EQUOP2;
1869 break;
1871 case '&':
1872 case '|':
1873 if (exp[0] == result)
1874 ++exp;
1875 else
1876 result = YYERRCODE;
1877 break;
1879 case '<':
1880 if (exp[0] == '=')
1882 ++exp;
1883 lval->op = less_or_equal;
1885 else
1886 lval->op = less_than;
1887 result = CMPOP2;
1888 break;
1890 case '>':
1891 if (exp[0] == '=')
1893 ++exp;
1894 lval->op = greater_or_equal;
1896 else
1897 lval->op = greater_than;
1898 result = CMPOP2;
1899 break;
1901 case '*':
1902 lval->op = mult;
1903 result = MULOP2;
1904 break;
1906 case '/':
1907 lval->op = divide;
1908 result = MULOP2;
1909 break;
1911 case '%':
1912 lval->op = module;
1913 result = MULOP2;
1914 break;
1916 case '+':
1917 lval->op = plus;
1918 result = ADDOP2;
1919 break;
1921 case '-':
1922 lval->op = minus;
1923 result = ADDOP2;
1924 break;
1926 case 'n':
1927 case '?':
1928 case ':':
1929 case '(':
1930 case ')':
1931 /* Nothing, just return the character. */
1932 break;
1934 case ';':
1935 case '\n':
1936 case '\0':
1937 /* Be safe and let the user call this function again. */
1938 --exp;
1939 result = YYEOF;
1940 break;
1942 default:
1943 result = YYERRCODE;
1944 #if YYDEBUG != 0
1945 --exp;
1946 #endif
1947 break;
1950 *pexp = exp;
1952 return result;
1956 static void
1957 yyerror (const char *str)
1959 /* Do nothing. We don't print error messages here. */