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