blob: 535305b783b075242fca833a2590fb17387b6d71 [file] [log] [blame]
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001/* A Bison parser, made from plural.y
2 by GNU bison 1.35. */
Theodore Ts'oa04eba32003-05-03 16:35:17 -04003
4#define YYBISON 1 /* Identify Bison output. */
5
6#define yyparse __gettextparse
7#define yylex __gettextlex
8#define yyerror __gettexterror
9#define yylval __gettextlval
10#define yychar __gettextchar
11#define yydebug __gettextdebug
12#define yynerrs __gettextnerrs
Theodore Ts'ob0cacab2004-11-30 19:00:19 -050013# define EQUOP2 257
14# define CMPOP2 258
15# define ADDOP2 259
16# define MULOP2 260
17# define NUMBER 261
Theodore Ts'oa04eba32003-05-03 16:35:17 -040018
19#line 1 "plural.y"
20
21/* Expression parsing for plural form selection.
Theodore Ts'ob0cacab2004-11-30 19:00:19 -050022 Copyright (C) 2000-2001, 2003 Free Software Foundation, Inc.
Theodore Ts'oa04eba32003-05-03 16:35:17 -040023 Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
24
25 This program is free software; you can redistribute it and/or modify it
26 under the terms of the GNU Library General Public License as published
27 by the Free Software Foundation; either version 2, or (at your option)
28 any later version.
29
30 This program is distributed in the hope that it will be useful,
31 but WITHOUT ANY WARRANTY; without even the implied warranty of
32 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33 Library General Public License for more details.
34
35 You should have received a copy of the GNU Library General Public
36 License along with this program; if not, write to the Free Software
37 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
38 USA. */
39
40/* The bison generated parser uses alloca. AIX 3 forces us to put this
41 declaration at the beginning of the file. The declaration in bison's
42 skeleton file comes too late. This must come before <config.h>
43 because <config.h> may include arbitrary system headers. */
44#if defined _AIX && !defined __GNUC__
45 #pragma alloca
46#endif
47
48#ifdef HAVE_CONFIG_H
49# include <config.h>
50#endif
51
52#include <stddef.h>
53#include <stdlib.h>
54#include "plural-exp.h"
55
56/* The main function generated by the parser is called __gettextparse,
57 but we want it to be called PLURAL_PARSE. */
58#ifndef _LIBC
59# define __gettextparse PLURAL_PARSE
60#endif
61
62#define YYLEX_PARAM &((struct parse_args *) arg)->cp
63#define YYPARSE_PARAM arg
64
65#line 49 "plural.y"
Theodore Ts'ob0cacab2004-11-30 19:00:19 -050066#ifndef YYSTYPE
Theodore Ts'oa04eba32003-05-03 16:35:17 -040067typedef union {
68 unsigned long int num;
69 enum operator op;
70 struct expression *exp;
Theodore Ts'ob0cacab2004-11-30 19:00:19 -050071} yystype;
72# define YYSTYPE yystype
73# define YYSTYPE_IS_TRIVIAL 1
74#endif
Theodore Ts'oa04eba32003-05-03 16:35:17 -040075#line 55 "plural.y"
76
77/* Prototypes for local functions. */
Theodore Ts'ob0cacab2004-11-30 19:00:19 -050078static int yylex (YYSTYPE *lval, const char **pexp);
79static void yyerror (const char *str);
Theodore Ts'oa04eba32003-05-03 16:35:17 -040080
81/* Allocation of expressions. */
82
83static struct expression *
Theodore Ts'ob0cacab2004-11-30 19:00:19 -050084new_exp (int nargs, enum operator op, struct expression * const *args)
Theodore Ts'oa04eba32003-05-03 16:35:17 -040085{
86 int i;
87 struct expression *newp;
88
89 /* If any of the argument could not be malloc'ed, just return NULL. */
90 for (i = nargs - 1; i >= 0; i--)
91 if (args[i] == NULL)
92 goto fail;
93
94 /* Allocate a new expression. */
95 newp = (struct expression *) malloc (sizeof (*newp));
96 if (newp != NULL)
97 {
98 newp->nargs = nargs;
99 newp->operation = op;
100 for (i = nargs - 1; i >= 0; i--)
101 newp->val.args[i] = args[i];
102 return newp;
103 }
104
105 fail:
106 for (i = nargs - 1; i >= 0; i--)
107 FREE_EXPRESSION (args[i]);
108
109 return NULL;
110}
111
112static inline struct expression *
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500113new_exp_0 (enum operator op)
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400114{
115 return new_exp (0, op, NULL);
116}
117
118static inline struct expression *
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500119new_exp_1 (enum operator op, struct expression *right)
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400120{
121 struct expression *args[1];
122
123 args[0] = right;
124 return new_exp (1, op, args);
125}
126
127static struct expression *
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500128new_exp_2 (enum operator op, struct expression *left, struct expression *right)
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400129{
130 struct expression *args[2];
131
132 args[0] = left;
133 args[1] = right;
134 return new_exp (2, op, args);
135}
136
137static inline struct expression *
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500138new_exp_3 (enum operator op, struct expression *bexp,
139 struct expression *tbranch, struct expression *fbranch)
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400140{
141 struct expression *args[3];
142
143 args[0] = bexp;
144 args[1] = tbranch;
145 args[2] = fbranch;
146 return new_exp (3, op, args);
147}
148
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500149#ifndef YYDEBUG
150# define YYDEBUG 0
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400151#endif
152
153
154
155#define YYFINAL 27
156#define YYFLAG -32768
157#define YYNTBASE 16
158
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500159/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400160#define YYTRANSLATE(x) ((unsigned)(x) <= 261 ? yytranslate[x] : 18)
161
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500162/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
163static const char yytranslate[] =
164{
165 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
166 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
167 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
168 2, 2, 2, 10, 2, 2, 2, 2, 5, 2,
169 14, 15, 2, 2, 2, 2, 2, 2, 2, 2,
170 2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
171 2, 2, 2, 3, 2, 2, 2, 2, 2, 2,
172 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
173 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
174 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
175 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
176 13, 2, 2, 2, 2, 2, 2, 2, 2, 2,
177 2, 2, 2, 2, 4, 2, 2, 2, 2, 2,
178 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
179 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
180 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
181 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
182 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
183 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
184 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
185 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
186 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
187 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
188 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
189 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
190 2, 2, 2, 2, 2, 2, 1, 6, 7, 8,
191 9, 11
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400192};
193
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500194#if YYDEBUG
195static const short yyprhs[] =
196{
197 0, 0, 2, 8, 12, 16, 20, 24, 28, 32,
198 35, 37, 39
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400199};
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500200static const short yyrhs[] =
201{
202 17, 0, 17, 3, 17, 12, 17, 0, 17, 4,
203 17, 0, 17, 5, 17, 0, 17, 6, 17, 0,
204 17, 7, 17, 0, 17, 8, 17, 0, 17, 9,
205 17, 0, 10, 17, 0, 13, 0, 11, 0, 14,
206 17, 15, 0
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400207};
208
209#endif
210
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500211#if YYDEBUG
212/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
213static const short yyrline[] =
214{
215 0, 150, 158, 162, 166, 170, 174, 178, 182, 186,
216 190, 194, 199
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400217};
218#endif
219
220
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500221#if (YYDEBUG) || defined YYERROR_VERBOSE
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400222
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500223/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
224static const char *const yytname[] =
225{
Theodore Ts'oefc6f622008-08-27 23:07:54 -0400226 "$", "error", "$undefined.", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
227 "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500228 "start", "exp", 0
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400229};
230#endif
231
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500232/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
233static const short yyr1[] =
234{
235 0, 16, 17, 17, 17, 17, 17, 17, 17, 17,
236 17, 17, 17
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400237};
238
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500239/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
240static const short yyr2[] =
241{
242 0, 1, 5, 3, 3, 3, 3, 3, 3, 2,
243 1, 1, 3
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400244};
245
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500246/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
247 doesn't specify something else to do. Zero means the default is an
248 error. */
249static const short yydefact[] =
250{
251 0, 0, 11, 10, 0, 1, 9, 0, 0, 0,
252 0, 0, 0, 0, 0, 12, 0, 3, 4, 5,
253 6, 7, 8, 0, 2, 0, 0, 0
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400254};
255
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500256static const short yydefgoto[] =
257{
258 25, 5
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400259};
260
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500261static const short yypact[] =
262{
263 -9, -9,-32768,-32768, -9, 34,-32768, 11, -9, -9,
264 -9, -9, -9, -9, -9,-32768, 24, 39, 43, 16,
265 26, -3,-32768, -9, 34, 21, 53,-32768
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400266};
267
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500268static const short yypgoto[] =
269{
270 -32768, -1
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400271};
272
273
274#define YYLAST 53
275
276
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500277static const short yytable[] =
278{
279 6, 1, 2, 7, 3, 4, 14, 16, 17, 18,
280 19, 20, 21, 22, 8, 9, 10, 11, 12, 13,
281 14, 26, 24, 12, 13, 14, 15, 8, 9, 10,
282 11, 12, 13, 14, 13, 14, 23, 8, 9, 10,
283 11, 12, 13, 14, 10, 11, 12, 13, 14, 11,
284 12, 13, 14, 27
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400285};
286
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500287static const short yycheck[] =
288{
289 1, 10, 11, 4, 13, 14, 9, 8, 9, 10,
290 11, 12, 13, 14, 3, 4, 5, 6, 7, 8,
291 9, 0, 23, 7, 8, 9, 15, 3, 4, 5,
292 6, 7, 8, 9, 8, 9, 12, 3, 4, 5,
293 6, 7, 8, 9, 5, 6, 7, 8, 9, 6,
294 7, 8, 9, 0
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400295};
296#define YYPURE 1
297
298/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500299#line 3 "/usr/local/share/bison/bison.simple"
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400300
301/* Skeleton output parser for bison,
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500302
303 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
304 Foundation, Inc.
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400305
306 This program is free software; you can redistribute it and/or modify
307 it under the terms of the GNU General Public License as published by
308 the Free Software Foundation; either version 2, or (at your option)
309 any later version.
310
311 This program is distributed in the hope that it will be useful,
312 but WITHOUT ANY WARRANTY; without even the implied warranty of
313 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
314 GNU General Public License for more details.
315
316 You should have received a copy of the GNU General Public License
317 along with this program; if not, write to the Free Software
318 Foundation, Inc., 59 Temple Place - Suite 330,
319 Boston, MA 02111-1307, USA. */
320
321/* As a special exception, when this file is copied by Bison into a
322 Bison output file, you may use that output file without restriction.
323 This special exception was added by the Free Software Foundation
324 in version 1.24 of Bison. */
325
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500326/* This is the parser code that is written into each bison parser when
327 the %semantic_parser declaration is not specified in the grammar.
328 It was written by Richard Stallman by simplifying the hairy parser
329 used when %semantic_parser is specified. */
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400330
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500331/* All symbols defined below should begin with yy or YY, to avoid
332 infringing on user name space. This should be done even for local
333 variables, as they might otherwise be expanded by user macros.
334 There are some unavoidable exceptions within include files to
335 define necessary library symbols; they are noted "INFRINGES ON
336 USER NAME SPACE" below. */
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400337
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500338#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
339
340/* The parser invokes alloca or malloc; define the necessary symbols. */
341
342# if YYSTACK_USE_ALLOCA
343# define YYSTACK_ALLOC alloca
344# else
345# ifndef YYSTACK_USE_ALLOCA
346# if defined (alloca) || defined (_ALLOCA_H)
347# define YYSTACK_ALLOC alloca
348# else
349# ifdef __GNUC__
350# define YYSTACK_ALLOC __builtin_alloca
351# endif
352# endif
353# endif
354# endif
355
356# ifdef YYSTACK_ALLOC
357 /* Pacify GCC's `empty if-body' warning. */
358# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
359# else
360# if defined (__STDC__) || defined (__cplusplus)
361# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
362# define YYSIZE_T size_t
363# endif
364# define YYSTACK_ALLOC malloc
365# define YYSTACK_FREE free
366# endif
367#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
368
369
370#if (! defined (yyoverflow) \
371 && (! defined (__cplusplus) \
372 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
373
374/* A type that is properly aligned for any stack member. */
375union yyalloc
376{
377 short yyss;
378 YYSTYPE yyvs;
379# if YYLSP_NEEDED
380 YYLTYPE yyls;
381# endif
382};
383
384/* The size of the maximum gap between one aligned stack and the next. */
385# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
386
387/* The size of an array large to enough to hold all stacks, each with
388 N elements. */
389# if YYLSP_NEEDED
390# define YYSTACK_BYTES(N) \
391 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
392 + 2 * YYSTACK_GAP_MAX)
393# else
394# define YYSTACK_BYTES(N) \
395 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
396 + YYSTACK_GAP_MAX)
397# endif
398
399/* Copy COUNT objects from FROM to TO. The source and destination do
400 not overlap. */
401# ifndef YYCOPY
402# if 1 < __GNUC__
403# define YYCOPY(To, From, Count) \
404 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
405# else
406# define YYCOPY(To, From, Count) \
407 do \
408 { \
409 register YYSIZE_T yyi; \
410 for (yyi = 0; yyi < (Count); yyi++) \
411 (To)[yyi] = (From)[yyi]; \
412 } \
413 while (0)
414# endif
415# endif
416
417/* Relocate STACK from its old location to the new one. The
418 local variables YYSIZE and YYSTACKSIZE give the old and new number of
419 elements in the stack, and YYPTR gives the new location of the
420 stack. Advance YYPTR to a properly aligned location for the next
421 stack. */
422# define YYSTACK_RELOCATE(Stack) \
423 do \
424 { \
425 YYSIZE_T yynewbytes; \
426 YYCOPY (&yyptr->Stack, Stack, yysize); \
427 Stack = &yyptr->Stack; \
428 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
429 yyptr += yynewbytes / sizeof (*yyptr); \
430 } \
431 while (0)
432
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400433#endif
434
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500435
436#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
437# define YYSIZE_T __SIZE_TYPE__
438#endif
439#if ! defined (YYSIZE_T) && defined (size_t)
440# define YYSIZE_T size_t
441#endif
442#if ! defined (YYSIZE_T)
443# if defined (__STDC__) || defined (__cplusplus)
444# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
445# define YYSIZE_T size_t
446# endif
447#endif
448#if ! defined (YYSIZE_T)
449# define YYSIZE_T unsigned int
450#endif
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400451
452#define yyerrok (yyerrstatus = 0)
453#define yyclearin (yychar = YYEMPTY)
454#define YYEMPTY -2
455#define YYEOF 0
456#define YYACCEPT goto yyacceptlab
457#define YYABORT goto yyabortlab
458#define YYERROR goto yyerrlab1
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500459/* Like YYERROR except do call yyerror. This remains here temporarily
460 to ease the transition to the new meaning of YYERROR, for GCC.
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400461 Once GCC version 2 has supplanted version 1, this can go. */
462#define YYFAIL goto yyerrlab
463#define YYRECOVERING() (!!yyerrstatus)
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500464#define YYBACKUP(Token, Value) \
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400465do \
466 if (yychar == YYEMPTY && yylen == 1) \
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500467 { \
468 yychar = (Token); \
469 yylval = (Value); \
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400470 yychar1 = YYTRANSLATE (yychar); \
471 YYPOPSTACK; \
472 goto yybackup; \
473 } \
474 else \
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500475 { \
476 yyerror ("syntax error: cannot back up"); \
477 YYERROR; \
478 } \
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400479while (0)
480
481#define YYTERROR 1
482#define YYERRCODE 256
483
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500484
485/* YYLLOC_DEFAULT -- Compute the default location (before the actions
486 are run).
487
488 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
489 first token. By default, to implement support for ranges, extend
490 its range to the last symbol. */
491
492#ifndef YYLLOC_DEFAULT
493# define YYLLOC_DEFAULT(Current, Rhs, N) \
494 Current.last_line = Rhs[N].last_line; \
495 Current.last_column = Rhs[N].last_column;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400496#endif
497
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400498
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500499/* YYLEX -- calling `yylex' with the right arguments. */
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400500
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500501#if YYPURE
502# if YYLSP_NEEDED
503# ifdef YYLEX_PARAM
504# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
505# else
506# define YYLEX yylex (&yylval, &yylloc)
507# endif
508# else /* !YYLSP_NEEDED */
509# ifdef YYLEX_PARAM
510# define YYLEX yylex (&yylval, YYLEX_PARAM)
511# else
512# define YYLEX yylex (&yylval)
513# endif
514# endif /* !YYLSP_NEEDED */
515#else /* !YYPURE */
516# define YYLEX yylex ()
517#endif /* !YYPURE */
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400518
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400519
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500520/* Enable debugging if requested. */
521#if YYDEBUG
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400522
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500523# ifndef YYFPRINTF
524# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
525# define YYFPRINTF fprintf
526# endif
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400527
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500528# define YYDPRINTF(Args) \
529do { \
530 if (yydebug) \
531 YYFPRINTF Args; \
532} while (0)
533/* Nonzero means print parse trace. It is left uninitialized so that
534 multiple parsers can coexist. */
535int yydebug;
536#else /* !YYDEBUG */
537# define YYDPRINTF(Args)
538#endif /* !YYDEBUG */
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400539
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500540/* YYINITDEPTH -- initial size of the parser's stacks. */
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400541#ifndef YYINITDEPTH
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500542# define YYINITDEPTH 200
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400543#endif
544
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500545/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
546 if the built-in stack extension method is used).
547
548 Do not make this value too large; the results are undefined if
549 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
550 evaluated with infinite-precision integer arithmetic. */
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400551
552#if YYMAXDEPTH == 0
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500553# undef YYMAXDEPTH
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400554#endif
555
556#ifndef YYMAXDEPTH
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500557# define YYMAXDEPTH 10000
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400558#endif
Theodore Ts'oefc6f622008-08-27 23:07:54 -0400559
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500560#ifdef YYERROR_VERBOSE
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400561
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500562# ifndef yystrlen
563# if defined (__GLIBC__) && defined (_STRING_H)
564# define yystrlen strlen
565# else
566/* Return the length of YYSTR. */
567static YYSIZE_T
568# if defined (__STDC__) || defined (__cplusplus)
569yystrlen (const char *yystr)
570# else
571yystrlen (yystr)
572 const char *yystr;
573# endif
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400574{
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500575 register const char *yys = yystr;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400576
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500577 while (*yys++ != '\0')
578 continue;
579
580 return yys - yystr - 1;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400581}
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500582# endif
583# endif
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400584
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500585# ifndef yystpcpy
586# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
587# define yystpcpy stpcpy
588# else
589/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
590 YYDEST. */
591static char *
592# if defined (__STDC__) || defined (__cplusplus)
593yystpcpy (char *yydest, const char *yysrc)
594# else
595yystpcpy (yydest, yysrc)
596 char *yydest;
597 const char *yysrc;
598# endif
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400599{
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500600 register char *yyd = yydest;
601 register const char *yys = yysrc;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400602
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500603 while ((*yyd++ = *yys++) != '\0')
604 continue;
605
606 return yyd - 1;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400607}
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500608# endif
609# endif
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400610#endif
Theodore Ts'oefc6f622008-08-27 23:07:54 -0400611
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500612#line 315 "/usr/local/share/bison/bison.simple"
613
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400614
615/* The user can define YYPARSE_PARAM as the name of an argument to be passed
616 into yyparse. The argument should have type void *.
617 It should actually point to an object.
618 Grammar actions can access the variable by casting it
619 to the proper pointer type. */
620
621#ifdef YYPARSE_PARAM
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500622# if defined (__STDC__) || defined (__cplusplus)
623# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
624# define YYPARSE_PARAM_DECL
625# else
626# define YYPARSE_PARAM_ARG YYPARSE_PARAM
627# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
628# endif
629#else /* !YYPARSE_PARAM */
630# define YYPARSE_PARAM_ARG
631# define YYPARSE_PARAM_DECL
632#endif /* !YYPARSE_PARAM */
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400633
634/* Prevent warning if -Wstrict-prototypes. */
635#ifdef __GNUC__
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500636# ifdef YYPARSE_PARAM
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400637int yyparse (void *);
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500638# else
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400639int yyparse (void);
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500640# endif
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400641#endif
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500642
643/* YY_DECL_VARIABLES -- depending whether we use a pure parser,
644 variables are global, or local to YYPARSE. */
645
646#define YY_DECL_NON_LSP_VARIABLES \
647/* The lookahead symbol. */ \
648int yychar; \
649 \
650/* The semantic value of the lookahead symbol. */ \
651YYSTYPE yylval; \
652 \
653/* Number of parse errors so far. */ \
654int yynerrs;
655
656#if YYLSP_NEEDED
657# define YY_DECL_VARIABLES \
658YY_DECL_NON_LSP_VARIABLES \
659 \
660/* Location data for the lookahead symbol. */ \
661YYLTYPE yylloc;
662#else
663# define YY_DECL_VARIABLES \
664YY_DECL_NON_LSP_VARIABLES
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400665#endif
666
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500667
668/* If nonreentrant, generate the variables here. */
669
670#if !YYPURE
671YY_DECL_VARIABLES
672#endif /* !YYPURE */
673
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400674int
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500675yyparse (YYPARSE_PARAM_ARG)
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400676 YYPARSE_PARAM_DECL
677{
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500678 /* If reentrant, generate the variables here. */
679#if YYPURE
680 YY_DECL_VARIABLES
681#endif /* !YYPURE */
682
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400683 register int yystate;
684 register int yyn;
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500685 int yyresult;
686 /* Number of tokens to shift before error messages enabled. */
687 int yyerrstatus;
688 /* Lookahead token as an internal (translated) token number. */
689 int yychar1 = 0;
690
691 /* Three stacks and their tools:
692 `yyss': related to states,
693 `yyvs': related to semantic values,
694 `yyls': related to locations.
695
696 Refer to the stacks thru separate pointers, to allow yyoverflow
697 to reallocate them elsewhere. */
698
699 /* The state stack. */
700 short yyssa[YYINITDEPTH];
701 short *yyss = yyssa;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400702 register short *yyssp;
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500703
704 /* The semantic value stack. */
705 YYSTYPE yyvsa[YYINITDEPTH];
706 YYSTYPE *yyvs = yyvsa;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400707 register YYSTYPE *yyvsp;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400708
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500709#if YYLSP_NEEDED
710 /* The location stack. */
711 YYLTYPE yylsa[YYINITDEPTH];
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400712 YYLTYPE *yyls = yylsa;
713 YYLTYPE *yylsp;
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500714#endif
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400715
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500716#if YYLSP_NEEDED
717# define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400718#else
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500719# define YYPOPSTACK (yyvsp--, yyssp--)
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400720#endif
721
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500722 YYSIZE_T yystacksize = YYINITDEPTH;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400723
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500724
725 /* The variables used to return semantic value and location from the
726 action routines. */
727 YYSTYPE yyval;
728#if YYLSP_NEEDED
729 YYLTYPE yyloc;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400730#endif
731
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500732 /* When reducing, the number of symbols on the RHS of the reduced
733 rule. */
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400734 int yylen;
735
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500736 YYDPRINTF ((stderr, "Starting parse\n"));
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400737
738 yystate = 0;
739 yyerrstatus = 0;
740 yynerrs = 0;
741 yychar = YYEMPTY; /* Cause a token to be read. */
742
743 /* Initialize stack pointers.
744 Waste one element of value and location stack
745 so that they stay on the same level as the state stack.
746 The wasted elements are never initialized. */
747
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500748 yyssp = yyss;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400749 yyvsp = yyvs;
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500750#if YYLSP_NEEDED
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400751 yylsp = yyls;
752#endif
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500753 goto yysetstate;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400754
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500755/*------------------------------------------------------------.
756| yynewstate -- Push a new state, which is found in yystate. |
757`------------------------------------------------------------*/
758 yynewstate:
759 /* In all cases, when you get here, the value and location stacks
760 have just been pushed. so pushing a state here evens the stacks.
761 */
762 yyssp++;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400763
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500764 yysetstate:
765 *yyssp = yystate;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400766
767 if (yyssp >= yyss + yystacksize - 1)
768 {
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400769 /* Get the current used size of the three stacks, in elements. */
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500770 YYSIZE_T yysize = yyssp - yyss + 1;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400771
772#ifdef yyoverflow
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500773 {
774 /* Give user a chance to reallocate the stack. Use copies of
775 these so that the &'s don't force the real ones into
776 memory. */
777 YYSTYPE *yyvs1 = yyvs;
778 short *yyss1 = yyss;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400779
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500780 /* Each stack pointer address is followed by the size of the
781 data in use in that stack, in bytes. */
782# if YYLSP_NEEDED
783 YYLTYPE *yyls1 = yyls;
784 /* This used to be a conditional around just the two extra args,
785 but that might be undefined if yyoverflow is a macro. */
786 yyoverflow ("parser stack overflow",
787 &yyss1, yysize * sizeof (*yyssp),
788 &yyvs1, yysize * sizeof (*yyvsp),
789 &yyls1, yysize * sizeof (*yylsp),
790 &yystacksize);
791 yyls = yyls1;
792# else
793 yyoverflow ("parser stack overflow",
794 &yyss1, yysize * sizeof (*yyssp),
795 &yyvs1, yysize * sizeof (*yyvsp),
796 &yystacksize);
797# endif
798 yyss = yyss1;
799 yyvs = yyvs1;
800 }
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400801#else /* no yyoverflow */
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500802# ifndef YYSTACK_RELOCATE
803 goto yyoverflowlab;
804# else
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400805 /* Extend the stack our own way. */
806 if (yystacksize >= YYMAXDEPTH)
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500807 goto yyoverflowlab;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400808 yystacksize *= 2;
809 if (yystacksize > YYMAXDEPTH)
810 yystacksize = YYMAXDEPTH;
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500811
812 {
813 short *yyss1 = yyss;
814 union yyalloc *yyptr =
815 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
816 if (! yyptr)
817 goto yyoverflowlab;
818 YYSTACK_RELOCATE (yyss);
819 YYSTACK_RELOCATE (yyvs);
820# if YYLSP_NEEDED
821 YYSTACK_RELOCATE (yyls);
822# endif
823# undef YYSTACK_RELOCATE
824 if (yyss1 != yyssa)
825 YYSTACK_FREE (yyss1);
826 }
827# endif
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400828#endif /* no yyoverflow */
829
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500830 yyssp = yyss + yysize - 1;
831 yyvsp = yyvs + yysize - 1;
832#if YYLSP_NEEDED
833 yylsp = yyls + yysize - 1;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400834#endif
835
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500836 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
837 (unsigned long int) yystacksize));
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400838
839 if (yyssp >= yyss + yystacksize - 1)
840 YYABORT;
841 }
842
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500843 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400844
845 goto yybackup;
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500846
847
848/*-----------.
849| yybackup. |
850`-----------*/
851yybackup:
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400852
853/* Do appropriate processing given the current state. */
854/* Read a lookahead token if we need one and don't already have one. */
855/* yyresume: */
856
857 /* First try to decide what to do without reference to lookahead token. */
858
859 yyn = yypact[yystate];
860 if (yyn == YYFLAG)
861 goto yydefault;
862
863 /* Not known => get a lookahead token if don't already have one. */
864
865 /* yychar is either YYEMPTY or YYEOF
866 or a valid token in external form. */
867
868 if (yychar == YYEMPTY)
869 {
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500870 YYDPRINTF ((stderr, "Reading a token: "));
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400871 yychar = YYLEX;
872 }
873
874 /* Convert token to internal form (in yychar1) for indexing tables with */
875
876 if (yychar <= 0) /* This means end of input. */
877 {
878 yychar1 = 0;
879 yychar = YYEOF; /* Don't call YYLEX any more */
880
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500881 YYDPRINTF ((stderr, "Now at end of input.\n"));
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400882 }
883 else
884 {
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500885 yychar1 = YYTRANSLATE (yychar);
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400886
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500887#if YYDEBUG
888 /* We have to keep this `#if YYDEBUG', since we use variables
889 which are defined only if `YYDEBUG' is set. */
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400890 if (yydebug)
891 {
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500892 YYFPRINTF (stderr, "Next token is %d (%s",
893 yychar, yytname[yychar1]);
894 /* Give the individual parser a way to print the precise
895 meaning of a token, for further debugging info. */
896# ifdef YYPRINT
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400897 YYPRINT (stderr, yychar, yylval);
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500898# endif
899 YYFPRINTF (stderr, ")\n");
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400900 }
901#endif
902 }
903
904 yyn += yychar1;
905 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
906 goto yydefault;
907
908 yyn = yytable[yyn];
909
910 /* yyn is what to do for this token type in this state.
911 Negative => reduce, -yyn is rule number.
912 Positive => shift, yyn is new state.
913 New state is final state => don't bother to shift,
914 just return success.
915 0, or most negative number => error. */
916
917 if (yyn < 0)
918 {
919 if (yyn == YYFLAG)
920 goto yyerrlab;
921 yyn = -yyn;
922 goto yyreduce;
923 }
924 else if (yyn == 0)
925 goto yyerrlab;
926
927 if (yyn == YYFINAL)
928 YYACCEPT;
929
930 /* Shift the lookahead token. */
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500931 YYDPRINTF ((stderr, "Shifting token %d (%s), ",
932 yychar, yytname[yychar1]));
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400933
934 /* Discard the token being shifted unless it is eof. */
935 if (yychar != YYEOF)
936 yychar = YYEMPTY;
937
938 *++yyvsp = yylval;
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500939#if YYLSP_NEEDED
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400940 *++yylsp = yylloc;
941#endif
942
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500943 /* Count tokens shifted since error; after three, turn off error
944 status. */
945 if (yyerrstatus)
946 yyerrstatus--;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400947
948 yystate = yyn;
949 goto yynewstate;
950
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400951
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500952/*-----------------------------------------------------------.
953| yydefault -- do the default action for the current state. |
954`-----------------------------------------------------------*/
955yydefault:
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400956 yyn = yydefact[yystate];
957 if (yyn == 0)
958 goto yyerrlab;
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500959 goto yyreduce;
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400960
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500961
962/*-----------------------------.
963| yyreduce -- Do a reduction. |
964`-----------------------------*/
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400965yyreduce:
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500966 /* yyn is the number of a rule to reduce with. */
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400967 yylen = yyr2[yyn];
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400968
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500969 /* If YYLEN is nonzero, implement the default value of the action:
970 `$$ = $1'.
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400971
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500972 Otherwise, the following line sets YYVAL to the semantic value of
973 the lookahead token. This behavior is undocumented and Bison
974 users should not rely upon it. Assigning to YYVAL
975 unconditionally makes the parser a bit smaller, and it avoids a
976 GCC warning that YYVAL may be used uninitialized. */
977 yyval = yyvsp[1-yylen];
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400978
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500979#if YYLSP_NEEDED
980 /* Similarly for the default location. Let the user run additional
981 commands if for instance locations are ranges. */
982 yyloc = yylsp[1-yylen];
983 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
Theodore Ts'oa04eba32003-05-03 16:35:17 -0400984#endif
985
Theodore Ts'ob0cacab2004-11-30 19:00:19 -0500986#if YYDEBUG
987 /* We have to keep this `#if YYDEBUG', since we use variables which
988 are defined only if `YYDEBUG' is set. */
989 if (yydebug)
990 {
991 int yyi;
992
993 YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
994 yyn, yyrline[yyn]);
995
996 /* Print the symbols being reduced, and their result. */
997 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
998 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
999 YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1000 }
1001#endif
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001002
1003 switch (yyn) {
1004
1005case 1:
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001006#line 151 "plural.y"
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001007{
1008 if (yyvsp[0].exp == NULL)
1009 YYABORT;
1010 ((struct parse_args *) arg)->res = yyvsp[0].exp;
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001011 }
1012 break;
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001013case 2:
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001014#line 159 "plural.y"
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001015{
1016 yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp);
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001017 }
1018 break;
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001019case 3:
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001020#line 163 "plural.y"
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001021{
1022 yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp);
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001023 }
1024 break;
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001025case 4:
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001026#line 167 "plural.y"
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001027{
1028 yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp);
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001029 }
1030 break;
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001031case 5:
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001032#line 171 "plural.y"
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001033{
1034 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001035 }
1036 break;
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001037case 6:
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001038#line 175 "plural.y"
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001039{
1040 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001041 }
1042 break;
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001043case 7:
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001044#line 179 "plural.y"
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001045{
1046 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001047 }
1048 break;
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001049case 8:
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001050#line 183 "plural.y"
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001051{
1052 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001053 }
1054 break;
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001055case 9:
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001056#line 187 "plural.y"
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001057{
1058 yyval.exp = new_exp_1 (lnot, yyvsp[0].exp);
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001059 }
1060 break;
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001061case 10:
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001062#line 191 "plural.y"
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001063{
1064 yyval.exp = new_exp_0 (var);
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001065 }
1066 break;
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001067case 11:
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001068#line 195 "plural.y"
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001069{
1070 if ((yyval.exp = new_exp_0 (num)) != NULL)
1071 yyval.exp->val.num = yyvsp[0].num;
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001072 }
1073 break;
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001074case 12:
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001075#line 200 "plural.y"
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001076{
1077 yyval.exp = yyvsp[-1].exp;
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001078 }
1079 break;
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001080}
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001081
1082#line 705 "/usr/local/share/bison/bison.simple"
1083
Theodore Ts'oefc6f622008-08-27 23:07:54 -04001084
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001085 yyvsp -= yylen;
1086 yyssp -= yylen;
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001087#if YYLSP_NEEDED
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001088 yylsp -= yylen;
1089#endif
1090
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001091#if YYDEBUG
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001092 if (yydebug)
1093 {
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001094 short *yyssp1 = yyss - 1;
1095 YYFPRINTF (stderr, "state stack now");
1096 while (yyssp1 != yyssp)
1097 YYFPRINTF (stderr, " %d", *++yyssp1);
1098 YYFPRINTF (stderr, "\n");
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001099 }
1100#endif
1101
1102 *++yyvsp = yyval;
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001103#if YYLSP_NEEDED
1104 *++yylsp = yyloc;
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001105#endif
1106
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001107 /* Now `shift' the result of the reduction. Determine what state
1108 that goes to, based on the state we popped back to and the rule
1109 number reduced by. */
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001110
1111 yyn = yyr1[yyn];
1112
1113 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1114 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1115 yystate = yytable[yystate];
1116 else
1117 yystate = yydefgoto[yyn - YYNTBASE];
1118
1119 goto yynewstate;
1120
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001121
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001122/*------------------------------------.
1123| yyerrlab -- here on detecting error |
1124`------------------------------------*/
1125yyerrlab:
1126 /* If not already recovering from an error, report this error. */
1127 if (!yyerrstatus)
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001128 {
1129 ++yynerrs;
1130
1131#ifdef YYERROR_VERBOSE
1132 yyn = yypact[yystate];
1133
1134 if (yyn > YYFLAG && yyn < YYLAST)
1135 {
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001136 YYSIZE_T yysize = 0;
1137 char *yymsg;
1138 int yyx, yycount;
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001139
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001140 yycount = 0;
1141 /* Start YYX at -YYN if negative to avoid negative indexes in
1142 YYCHECK. */
1143 for (yyx = yyn < 0 ? -yyn : 0;
1144 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1145 if (yycheck[yyx + yyn] == yyx)
1146 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1147 yysize += yystrlen ("parse error, unexpected ") + 1;
1148 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
1149 yymsg = (char *) YYSTACK_ALLOC (yysize);
1150 if (yymsg != 0)
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001151 {
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001152 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
1153 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001154
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001155 if (yycount < 5)
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001156 {
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001157 yycount = 0;
1158 for (yyx = yyn < 0 ? -yyn : 0;
1159 yyx < (int) (sizeof (yytname) / sizeof (char *));
1160 yyx++)
1161 if (yycheck[yyx + yyn] == yyx)
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001162 {
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001163 const char *yyq = ! yycount ? ", expecting " : " or ";
1164 yyp = yystpcpy (yyp, yyq);
1165 yyp = yystpcpy (yyp, yytname[yyx]);
1166 yycount++;
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001167 }
1168 }
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001169 yyerror (yymsg);
1170 YYSTACK_FREE (yymsg);
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001171 }
1172 else
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001173 yyerror ("parse error; also virtual memory exhausted");
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001174 }
1175 else
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001176#endif /* defined (YYERROR_VERBOSE) */
1177 yyerror ("parse error");
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001178 }
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001179 goto yyerrlab1;
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001180
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001181
1182/*--------------------------------------------------.
1183| yyerrlab1 -- error raised explicitly by an action |
1184`--------------------------------------------------*/
1185yyerrlab1:
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001186 if (yyerrstatus == 3)
1187 {
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001188 /* If just tried and failed to reuse lookahead token after an
1189 error, discard it. */
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001190
1191 /* return failure if at end of input */
1192 if (yychar == YYEOF)
1193 YYABORT;
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001194 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
1195 yychar, yytname[yychar1]));
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001196 yychar = YYEMPTY;
1197 }
1198
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001199 /* Else will try to reuse lookahead token after shifting the error
1200 token. */
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001201
1202 yyerrstatus = 3; /* Each real token shifted decrements this */
1203
1204 goto yyerrhandle;
1205
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001206
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001207/*-------------------------------------------------------------------.
1208| yyerrdefault -- current state does not do anything special for the |
1209| error token. |
1210`-------------------------------------------------------------------*/
1211yyerrdefault:
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001212#if 0
1213 /* This is wrong; only states that explicitly want error tokens
1214 should shift them. */
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001215
1216 /* If its default is to accept any token, ok. Otherwise pop it. */
1217 yyn = yydefact[yystate];
1218 if (yyn)
1219 goto yydefault;
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001220#endif
1221
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001222
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001223/*---------------------------------------------------------------.
1224| yyerrpop -- pop the current state because it cannot handle the |
1225| error token |
1226`---------------------------------------------------------------*/
1227yyerrpop:
1228 if (yyssp == yyss)
1229 YYABORT;
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001230 yyvsp--;
1231 yystate = *--yyssp;
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001232#if YYLSP_NEEDED
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001233 yylsp--;
1234#endif
1235
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001236#if YYDEBUG
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001237 if (yydebug)
1238 {
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001239 short *yyssp1 = yyss - 1;
1240 YYFPRINTF (stderr, "Error: state stack now");
1241 while (yyssp1 != yyssp)
1242 YYFPRINTF (stderr, " %d", *++yyssp1);
1243 YYFPRINTF (stderr, "\n");
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001244 }
1245#endif
1246
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001247/*--------------.
1248| yyerrhandle. |
1249`--------------*/
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001250yyerrhandle:
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001251 yyn = yypact[yystate];
1252 if (yyn == YYFLAG)
1253 goto yyerrdefault;
1254
1255 yyn += YYTERROR;
1256 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1257 goto yyerrdefault;
1258
1259 yyn = yytable[yyn];
1260 if (yyn < 0)
1261 {
1262 if (yyn == YYFLAG)
1263 goto yyerrpop;
1264 yyn = -yyn;
1265 goto yyreduce;
1266 }
1267 else if (yyn == 0)
1268 goto yyerrpop;
1269
1270 if (yyn == YYFINAL)
1271 YYACCEPT;
1272
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001273 YYDPRINTF ((stderr, "Shifting error token, "));
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001274
1275 *++yyvsp = yylval;
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001276#if YYLSP_NEEDED
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001277 *++yylsp = yylloc;
1278#endif
1279
1280 yystate = yyn;
1281 goto yynewstate;
1282
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001283
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001284/*-------------------------------------.
1285| yyacceptlab -- YYACCEPT comes here. |
1286`-------------------------------------*/
1287yyacceptlab:
1288 yyresult = 0;
1289 goto yyreturn;
1290
1291/*-----------------------------------.
1292| yyabortlab -- YYABORT comes here. |
1293`-----------------------------------*/
1294yyabortlab:
1295 yyresult = 1;
1296 goto yyreturn;
1297
1298/*---------------------------------------------.
1299| yyoverflowab -- parser overflow comes here. |
1300`---------------------------------------------*/
1301yyoverflowlab:
1302 yyerror ("parser stack overflow");
1303 yyresult = 2;
1304 /* Fall through. */
1305
1306yyreturn:
1307#ifndef yyoverflow
1308 if (yyss != yyssa)
1309 YYSTACK_FREE (yyss);
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001310#endif
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001311 return yyresult;
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001312}
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001313#line 205 "plural.y"
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001314
1315
1316void
1317internal_function
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001318FREE_EXPRESSION (struct expression *exp)
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001319{
1320 if (exp == NULL)
1321 return;
1322
1323 /* Handle the recursive case. */
1324 switch (exp->nargs)
1325 {
1326 case 3:
1327 FREE_EXPRESSION (exp->val.args[2]);
1328 /* FALLTHROUGH */
1329 case 2:
1330 FREE_EXPRESSION (exp->val.args[1]);
1331 /* FALLTHROUGH */
1332 case 1:
1333 FREE_EXPRESSION (exp->val.args[0]);
1334 /* FALLTHROUGH */
1335 default:
1336 break;
1337 }
1338
1339 free (exp);
1340}
1341
1342
1343static int
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001344yylex (YYSTYPE *lval, const char **pexp)
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001345{
1346 const char *exp = *pexp;
1347 int result;
1348
1349 while (1)
1350 {
1351 if (exp[0] == '\0')
1352 {
1353 *pexp = exp;
1354 return YYEOF;
1355 }
1356
1357 if (exp[0] != ' ' && exp[0] != '\t')
1358 break;
1359
1360 ++exp;
1361 }
1362
1363 result = *exp++;
1364 switch (result)
1365 {
1366 case '0': case '1': case '2': case '3': case '4':
1367 case '5': case '6': case '7': case '8': case '9':
1368 {
1369 unsigned long int n = result - '0';
1370 while (exp[0] >= '0' && exp[0] <= '9')
1371 {
1372 n *= 10;
1373 n += exp[0] - '0';
1374 ++exp;
1375 }
1376 lval->num = n;
1377 result = NUMBER;
1378 }
1379 break;
1380
1381 case '=':
1382 if (exp[0] == '=')
1383 {
1384 ++exp;
1385 lval->op = equal;
1386 result = EQUOP2;
1387 }
1388 else
1389 result = YYERRCODE;
1390 break;
1391
1392 case '!':
1393 if (exp[0] == '=')
1394 {
1395 ++exp;
1396 lval->op = not_equal;
1397 result = EQUOP2;
1398 }
1399 break;
1400
1401 case '&':
1402 case '|':
1403 if (exp[0] == result)
1404 ++exp;
1405 else
1406 result = YYERRCODE;
1407 break;
1408
1409 case '<':
1410 if (exp[0] == '=')
1411 {
1412 ++exp;
1413 lval->op = less_or_equal;
1414 }
1415 else
1416 lval->op = less_than;
1417 result = CMPOP2;
1418 break;
1419
1420 case '>':
1421 if (exp[0] == '=')
1422 {
1423 ++exp;
1424 lval->op = greater_or_equal;
1425 }
1426 else
1427 lval->op = greater_than;
1428 result = CMPOP2;
1429 break;
1430
1431 case '*':
1432 lval->op = mult;
1433 result = MULOP2;
1434 break;
1435
1436 case '/':
1437 lval->op = divide;
1438 result = MULOP2;
1439 break;
1440
1441 case '%':
1442 lval->op = module;
1443 result = MULOP2;
1444 break;
1445
1446 case '+':
1447 lval->op = plus;
1448 result = ADDOP2;
1449 break;
1450
1451 case '-':
1452 lval->op = minus;
1453 result = ADDOP2;
1454 break;
1455
1456 case 'n':
1457 case '?':
1458 case ':':
1459 case '(':
1460 case ')':
1461 /* Nothing, just return the character. */
1462 break;
1463
1464 case ';':
1465 case '\n':
1466 case '\0':
1467 /* Be safe and let the user call this function again. */
1468 --exp;
1469 result = YYEOF;
1470 break;
1471
1472 default:
1473 result = YYERRCODE;
1474#if YYDEBUG != 0
1475 --exp;
1476#endif
1477 break;
1478 }
1479
1480 *pexp = exp;
1481
1482 return result;
1483}
1484
1485
1486static void
Theodore Ts'ob0cacab2004-11-30 19:00:19 -05001487yyerror (const char *str)
Theodore Ts'oa04eba32003-05-03 16:35:17 -04001488{
1489 /* Do nothing. We don't print error messages here. */
1490}