1 | /* A Bison parser, made from plural.y
|
---|
2 | by GNU bison 1.35. */
|
---|
3 |
|
---|
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
|
---|
13 | # define EQUOP2 257
|
---|
14 | # define CMPOP2 258
|
---|
15 | # define ADDOP2 259
|
---|
16 | # define MULOP2 260
|
---|
17 | # define NUMBER 261
|
---|
18 |
|
---|
19 | #line 1 "plural.y"
|
---|
20 |
|
---|
21 | /* Expression parsing for plural form selection.
|
---|
22 | Copyright (C) 2000, 2001 Free Software Foundation, Inc.
|
---|
23 | 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"
|
---|
66 | #ifndef YYSTYPE
|
---|
67 | typedef union {
|
---|
68 | unsigned long int num;
|
---|
69 | enum operator op;
|
---|
70 | struct expression *exp;
|
---|
71 | } yystype;
|
---|
72 | # define YYSTYPE yystype
|
---|
73 | # define YYSTYPE_IS_TRIVIAL 1
|
---|
74 | #endif
|
---|
75 | #line 55 "plural.y"
|
---|
76 |
|
---|
77 | /* Prototypes for local functions. */
|
---|
78 | static struct expression *new_exp PARAMS ((int nargs, enum operator op,
|
---|
79 | struct expression * const *args));
|
---|
80 | static inline struct expression *new_exp_0 PARAMS ((enum operator op));
|
---|
81 | static inline struct expression *new_exp_1 PARAMS ((enum operator op,
|
---|
82 | struct expression *right));
|
---|
83 | static struct expression *new_exp_2 PARAMS ((enum operator op,
|
---|
84 | struct expression *left,
|
---|
85 | struct expression *right));
|
---|
86 | static inline struct expression *new_exp_3 PARAMS ((enum operator op,
|
---|
87 | struct expression *bexp,
|
---|
88 | struct expression *tbranch,
|
---|
89 | struct expression *fbranch));
|
---|
90 | static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
|
---|
91 | static void yyerror PARAMS ((const char *str));
|
---|
92 |
|
---|
93 | /* Allocation of expressions. */
|
---|
94 |
|
---|
95 | static struct expression *
|
---|
96 | new_exp (nargs, op, args)
|
---|
97 | int nargs;
|
---|
98 | enum operator op;
|
---|
99 | struct expression * const *args;
|
---|
100 | {
|
---|
101 | int i;
|
---|
102 | struct expression *newp;
|
---|
103 |
|
---|
104 | /* If any of the argument could not be malloc'ed, just return NULL. */
|
---|
105 | for (i = nargs - 1; i >= 0; i--)
|
---|
106 | if (args[i] == NULL)
|
---|
107 | goto fail;
|
---|
108 |
|
---|
109 | /* Allocate a new expression. */
|
---|
110 | newp = (struct expression *) malloc (sizeof (*newp));
|
---|
111 | if (newp != NULL)
|
---|
112 | {
|
---|
113 | newp->nargs = nargs;
|
---|
114 | newp->operation = op;
|
---|
115 | for (i = nargs - 1; i >= 0; i--)
|
---|
116 | newp->val.args[i] = args[i];
|
---|
117 | return newp;
|
---|
118 | }
|
---|
119 |
|
---|
120 | fail:
|
---|
121 | for (i = nargs - 1; i >= 0; i--)
|
---|
122 | FREE_EXPRESSION (args[i]);
|
---|
123 |
|
---|
124 | return NULL;
|
---|
125 | }
|
---|
126 |
|
---|
127 | static inline struct expression *
|
---|
128 | new_exp_0 (op)
|
---|
129 | enum operator op;
|
---|
130 | {
|
---|
131 | return new_exp (0, op, NULL);
|
---|
132 | }
|
---|
133 |
|
---|
134 | static inline struct expression *
|
---|
135 | new_exp_1 (op, right)
|
---|
136 | enum operator op;
|
---|
137 | struct expression *right;
|
---|
138 | {
|
---|
139 | struct expression *args[1];
|
---|
140 |
|
---|
141 | args[0] = right;
|
---|
142 | return new_exp (1, op, args);
|
---|
143 | }
|
---|
144 |
|
---|
145 | static struct expression *
|
---|
146 | new_exp_2 (op, left, right)
|
---|
147 | enum operator op;
|
---|
148 | struct expression *left;
|
---|
149 | struct expression *right;
|
---|
150 | {
|
---|
151 | struct expression *args[2];
|
---|
152 |
|
---|
153 | args[0] = left;
|
---|
154 | args[1] = right;
|
---|
155 | return new_exp (2, op, args);
|
---|
156 | }
|
---|
157 |
|
---|
158 | static inline struct expression *
|
---|
159 | new_exp_3 (op, bexp, tbranch, fbranch)
|
---|
160 | enum operator op;
|
---|
161 | struct expression *bexp;
|
---|
162 | struct expression *tbranch;
|
---|
163 | struct expression *fbranch;
|
---|
164 | {
|
---|
165 | struct expression *args[3];
|
---|
166 |
|
---|
167 | args[0] = bexp;
|
---|
168 | args[1] = tbranch;
|
---|
169 | args[2] = fbranch;
|
---|
170 | return new_exp (3, op, args);
|
---|
171 | }
|
---|
172 |
|
---|
173 | #ifndef YYDEBUG
|
---|
174 | # define YYDEBUG 0
|
---|
175 | #endif
|
---|
176 |
|
---|
177 |
|
---|
178 |
|
---|
179 | #define YYFINAL 27
|
---|
180 | #define YYFLAG -32768
|
---|
181 | #define YYNTBASE 16
|
---|
182 |
|
---|
183 | /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
|
---|
184 | #define YYTRANSLATE(x) ((unsigned)(x) <= 261 ? yytranslate[x] : 18)
|
---|
185 |
|
---|
186 | /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
|
---|
187 | static const char yytranslate[] =
|
---|
188 | {
|
---|
189 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
190 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
191 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
192 | 2, 2, 2, 10, 2, 2, 2, 2, 5, 2,
|
---|
193 | 14, 15, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
194 | 2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
|
---|
195 | 2, 2, 2, 3, 2, 2, 2, 2, 2, 2,
|
---|
196 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
197 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
198 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
199 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
200 | 13, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
201 | 2, 2, 2, 2, 4, 2, 2, 2, 2, 2,
|
---|
202 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
203 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
204 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
205 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
206 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
207 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
208 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
209 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
210 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
211 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
212 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
213 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
214 | 2, 2, 2, 2, 2, 2, 1, 6, 7, 8,
|
---|
215 | 9, 11
|
---|
216 | };
|
---|
217 |
|
---|
218 | #if YYDEBUG
|
---|
219 | static const short yyprhs[] =
|
---|
220 | {
|
---|
221 | 0, 0, 2, 8, 12, 16, 20, 24, 28, 32,
|
---|
222 | 35, 37, 39
|
---|
223 | };
|
---|
224 | static const short yyrhs[] =
|
---|
225 | {
|
---|
226 | 17, 0, 17, 3, 17, 12, 17, 0, 17, 4,
|
---|
227 | 17, 0, 17, 5, 17, 0, 17, 6, 17, 0,
|
---|
228 | 17, 7, 17, 0, 17, 8, 17, 0, 17, 9,
|
---|
229 | 17, 0, 10, 17, 0, 13, 0, 11, 0, 14,
|
---|
230 | 17, 15, 0
|
---|
231 | };
|
---|
232 |
|
---|
233 | #endif
|
---|
234 |
|
---|
235 | #if YYDEBUG
|
---|
236 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
|
---|
237 | static const short yyrline[] =
|
---|
238 | {
|
---|
239 | 0, 174, 182, 186, 190, 194, 198, 202, 206, 210,
|
---|
240 | 214, 218, 223
|
---|
241 | };
|
---|
242 | #endif
|
---|
243 |
|
---|
244 |
|
---|
245 | #if (YYDEBUG) || defined YYERROR_VERBOSE
|
---|
246 |
|
---|
247 | /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
|
---|
248 | static const char *const yytname[] =
|
---|
249 | {
|
---|
250 | "$", "error", "$undefined.", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
|
---|
251 | "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
|
---|
252 | "start", "exp", 0
|
---|
253 | };
|
---|
254 | #endif
|
---|
255 |
|
---|
256 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
|
---|
257 | static const short yyr1[] =
|
---|
258 | {
|
---|
259 | 0, 16, 17, 17, 17, 17, 17, 17, 17, 17,
|
---|
260 | 17, 17, 17
|
---|
261 | };
|
---|
262 |
|
---|
263 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
|
---|
264 | static const short yyr2[] =
|
---|
265 | {
|
---|
266 | 0, 1, 5, 3, 3, 3, 3, 3, 3, 2,
|
---|
267 | 1, 1, 3
|
---|
268 | };
|
---|
269 |
|
---|
270 | /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
|
---|
271 | doesn't specify something else to do. Zero means the default is an
|
---|
272 | error. */
|
---|
273 | static const short yydefact[] =
|
---|
274 | {
|
---|
275 | 0, 0, 11, 10, 0, 1, 9, 0, 0, 0,
|
---|
276 | 0, 0, 0, 0, 0, 12, 0, 3, 4, 5,
|
---|
277 | 6, 7, 8, 0, 2, 0, 0, 0
|
---|
278 | };
|
---|
279 |
|
---|
280 | static const short yydefgoto[] =
|
---|
281 | {
|
---|
282 | 25, 5
|
---|
283 | };
|
---|
284 |
|
---|
285 | static const short yypact[] =
|
---|
286 | {
|
---|
287 | -9, -9,-32768,-32768, -9, 34,-32768, 11, -9, -9,
|
---|
288 | -9, -9, -9, -9, -9,-32768, 24, 39, 43, 16,
|
---|
289 | 26, -3,-32768, -9, 34, 21, 53,-32768
|
---|
290 | };
|
---|
291 |
|
---|
292 | static const short yypgoto[] =
|
---|
293 | {
|
---|
294 | -32768, -1
|
---|
295 | };
|
---|
296 |
|
---|
297 |
|
---|
298 | #define YYLAST 53
|
---|
299 |
|
---|
300 |
|
---|
301 | static const short yytable[] =
|
---|
302 | {
|
---|
303 | 6, 1, 2, 7, 3, 4, 14, 16, 17, 18,
|
---|
304 | 19, 20, 21, 22, 8, 9, 10, 11, 12, 13,
|
---|
305 | 14, 26, 24, 12, 13, 14, 15, 8, 9, 10,
|
---|
306 | 11, 12, 13, 14, 13, 14, 23, 8, 9, 10,
|
---|
307 | 11, 12, 13, 14, 10, 11, 12, 13, 14, 11,
|
---|
308 | 12, 13, 14, 27
|
---|
309 | };
|
---|
310 |
|
---|
311 | static const short yycheck[] =
|
---|
312 | {
|
---|
313 | 1, 10, 11, 4, 13, 14, 9, 8, 9, 10,
|
---|
314 | 11, 12, 13, 14, 3, 4, 5, 6, 7, 8,
|
---|
315 | 9, 0, 23, 7, 8, 9, 15, 3, 4, 5,
|
---|
316 | 6, 7, 8, 9, 8, 9, 12, 3, 4, 5,
|
---|
317 | 6, 7, 8, 9, 5, 6, 7, 8, 9, 6,
|
---|
318 | 7, 8, 9, 0
|
---|
319 | };
|
---|
320 | #define YYPURE 1
|
---|
321 |
|
---|
322 | /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
|
---|
323 | #line 3 "/usr/local/share/bison/bison.simple"
|
---|
324 |
|
---|
325 | /* Skeleton output parser for bison,
|
---|
326 |
|
---|
327 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
|
---|
328 | Foundation, Inc.
|
---|
329 |
|
---|
330 | This program is free software; you can redistribute it and/or modify
|
---|
331 | it under the terms of the GNU General Public License as published by
|
---|
332 | the Free Software Foundation; either version 2, or (at your option)
|
---|
333 | any later version.
|
---|
334 |
|
---|
335 | This program is distributed in the hope that it will be useful,
|
---|
336 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
337 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
338 | GNU General Public License for more details.
|
---|
339 |
|
---|
340 | You should have received a copy of the GNU General Public License
|
---|
341 | along with this program; if not, write to the Free Software
|
---|
342 | Foundation, Inc., 59 Temple Place - Suite 330,
|
---|
343 | Boston, MA 02111-1307, USA. */
|
---|
344 |
|
---|
345 | /* As a special exception, when this file is copied by Bison into a
|
---|
346 | Bison output file, you may use that output file without restriction.
|
---|
347 | This special exception was added by the Free Software Foundation
|
---|
348 | in version 1.24 of Bison. */
|
---|
349 |
|
---|
350 | /* This is the parser code that is written into each bison parser when
|
---|
351 | the %semantic_parser declaration is not specified in the grammar.
|
---|
352 | It was written by Richard Stallman by simplifying the hairy parser
|
---|
353 | used when %semantic_parser is specified. */
|
---|
354 |
|
---|
355 | /* All symbols defined below should begin with yy or YY, to avoid
|
---|
356 | infringing on user name space. This should be done even for local
|
---|
357 | variables, as they might otherwise be expanded by user macros.
|
---|
358 | There are some unavoidable exceptions within include files to
|
---|
359 | define necessary library symbols; they are noted "INFRINGES ON
|
---|
360 | USER NAME SPACE" below. */
|
---|
361 |
|
---|
362 | #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
|
---|
363 |
|
---|
364 | /* The parser invokes alloca or malloc; define the necessary symbols. */
|
---|
365 |
|
---|
366 | # if YYSTACK_USE_ALLOCA
|
---|
367 | # define YYSTACK_ALLOC alloca
|
---|
368 | # else
|
---|
369 | # ifndef YYSTACK_USE_ALLOCA
|
---|
370 | # if defined (alloca) || defined (_ALLOCA_H)
|
---|
371 | # define YYSTACK_ALLOC alloca
|
---|
372 | # else
|
---|
373 | # ifdef __GNUC__
|
---|
374 | # define YYSTACK_ALLOC __builtin_alloca
|
---|
375 | # endif
|
---|
376 | # endif
|
---|
377 | # endif
|
---|
378 | # endif
|
---|
379 |
|
---|
380 | # ifdef YYSTACK_ALLOC
|
---|
381 | /* Pacify GCC's `empty if-body' warning. */
|
---|
382 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
|
---|
383 | # else
|
---|
384 | # if defined (__STDC__) || defined (__cplusplus)
|
---|
385 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
|
---|
386 | # define YYSIZE_T size_t
|
---|
387 | # endif
|
---|
388 | # define YYSTACK_ALLOC malloc
|
---|
389 | # define YYSTACK_FREE free
|
---|
390 | # endif
|
---|
391 | #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
|
---|
392 |
|
---|
393 |
|
---|
394 | #if (! defined (yyoverflow) \
|
---|
395 | && (! defined (__cplusplus) \
|
---|
396 | || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
|
---|
397 |
|
---|
398 | /* A type that is properly aligned for any stack member. */
|
---|
399 | union yyalloc
|
---|
400 | {
|
---|
401 | short yyss;
|
---|
402 | YYSTYPE yyvs;
|
---|
403 | # if YYLSP_NEEDED
|
---|
404 | YYLTYPE yyls;
|
---|
405 | # endif
|
---|
406 | };
|
---|
407 |
|
---|
408 | /* The size of the maximum gap between one aligned stack and the next. */
|
---|
409 | # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
|
---|
410 |
|
---|
411 | /* The size of an array large to enough to hold all stacks, each with
|
---|
412 | N elements. */
|
---|
413 | # if YYLSP_NEEDED
|
---|
414 | # define YYSTACK_BYTES(N) \
|
---|
415 | ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
|
---|
416 | + 2 * YYSTACK_GAP_MAX)
|
---|
417 | # else
|
---|
418 | # define YYSTACK_BYTES(N) \
|
---|
419 | ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
|
---|
420 | + YYSTACK_GAP_MAX)
|
---|
421 | # endif
|
---|
422 |
|
---|
423 | /* Copy COUNT objects from FROM to TO. The source and destination do
|
---|
424 | not overlap. */
|
---|
425 | # ifndef YYCOPY
|
---|
426 | # if 1 < __GNUC__
|
---|
427 | # define YYCOPY(To, From, Count) \
|
---|
428 | __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
|
---|
429 | # else
|
---|
430 | # define YYCOPY(To, From, Count) \
|
---|
431 | do \
|
---|
432 | { \
|
---|
433 | register YYSIZE_T yyi; \
|
---|
434 | for (yyi = 0; yyi < (Count); yyi++) \
|
---|
435 | (To)[yyi] = (From)[yyi]; \
|
---|
436 | } \
|
---|
437 | while (0)
|
---|
438 | # endif
|
---|
439 | # endif
|
---|
440 |
|
---|
441 | /* Relocate STACK from its old location to the new one. The
|
---|
442 | local variables YYSIZE and YYSTACKSIZE give the old and new number of
|
---|
443 | elements in the stack, and YYPTR gives the new location of the
|
---|
444 | stack. Advance YYPTR to a properly aligned location for the next
|
---|
445 | stack. */
|
---|
446 | # define YYSTACK_RELOCATE(Stack) \
|
---|
447 | do \
|
---|
448 | { \
|
---|
449 | YYSIZE_T yynewbytes; \
|
---|
450 | YYCOPY (&yyptr->Stack, Stack, yysize); \
|
---|
451 | Stack = &yyptr->Stack; \
|
---|
452 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
|
---|
453 | yyptr += yynewbytes / sizeof (*yyptr); \
|
---|
454 | } \
|
---|
455 | while (0)
|
---|
456 |
|
---|
457 | #endif
|
---|
458 |
|
---|
459 |
|
---|
460 | #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
|
---|
461 | # define YYSIZE_T __SIZE_TYPE__
|
---|
462 | #endif
|
---|
463 | #if ! defined (YYSIZE_T) && defined (size_t)
|
---|
464 | # define YYSIZE_T size_t
|
---|
465 | #endif
|
---|
466 | #if ! defined (YYSIZE_T)
|
---|
467 | # if defined (__STDC__) || defined (__cplusplus)
|
---|
468 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
|
---|
469 | # define YYSIZE_T size_t
|
---|
470 | # endif
|
---|
471 | #endif
|
---|
472 | #if ! defined (YYSIZE_T)
|
---|
473 | # define YYSIZE_T unsigned int
|
---|
474 | #endif
|
---|
475 |
|
---|
476 | #define yyerrok (yyerrstatus = 0)
|
---|
477 | #define yyclearin (yychar = YYEMPTY)
|
---|
478 | #define YYEMPTY -2
|
---|
479 | #define YYEOF 0
|
---|
480 | #define YYACCEPT goto yyacceptlab
|
---|
481 | #define YYABORT goto yyabortlab
|
---|
482 | #define YYERROR goto yyerrlab1
|
---|
483 | /* Like YYERROR except do call yyerror. This remains here temporarily
|
---|
484 | to ease the transition to the new meaning of YYERROR, for GCC.
|
---|
485 | Once GCC version 2 has supplanted version 1, this can go. */
|
---|
486 | #define YYFAIL goto yyerrlab
|
---|
487 | #define YYRECOVERING() (!!yyerrstatus)
|
---|
488 | #define YYBACKUP(Token, Value) \
|
---|
489 | do \
|
---|
490 | if (yychar == YYEMPTY && yylen == 1) \
|
---|
491 | { \
|
---|
492 | yychar = (Token); \
|
---|
493 | yylval = (Value); \
|
---|
494 | yychar1 = YYTRANSLATE (yychar); \
|
---|
495 | YYPOPSTACK; \
|
---|
496 | goto yybackup; \
|
---|
497 | } \
|
---|
498 | else \
|
---|
499 | { \
|
---|
500 | yyerror ("syntax error: cannot back up"); \
|
---|
501 | YYERROR; \
|
---|
502 | } \
|
---|
503 | while (0)
|
---|
504 |
|
---|
505 | #define YYTERROR 1
|
---|
506 | #define YYERRCODE 256
|
---|
507 |
|
---|
508 |
|
---|
509 | /* YYLLOC_DEFAULT -- Compute the default location (before the actions
|
---|
510 | are run).
|
---|
511 |
|
---|
512 | When YYLLOC_DEFAULT is run, CURRENT is set the location of the
|
---|
513 | first token. By default, to implement support for ranges, extend
|
---|
514 | its range to the last symbol. */
|
---|
515 |
|
---|
516 | #ifndef YYLLOC_DEFAULT
|
---|
517 | # define YYLLOC_DEFAULT(Current, Rhs, N) \
|
---|
518 | Current.last_line = Rhs[N].last_line; \
|
---|
519 | Current.last_column = Rhs[N].last_column;
|
---|
520 | #endif
|
---|
521 |
|
---|
522 |
|
---|
523 | /* YYLEX -- calling `yylex' with the right arguments. */
|
---|
524 |
|
---|
525 | #if YYPURE
|
---|
526 | # if YYLSP_NEEDED
|
---|
527 | # ifdef YYLEX_PARAM
|
---|
528 | # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
|
---|
529 | # else
|
---|
530 | # define YYLEX yylex (&yylval, &yylloc)
|
---|
531 | # endif
|
---|
532 | # else /* !YYLSP_NEEDED */
|
---|
533 | # ifdef YYLEX_PARAM
|
---|
534 | # define YYLEX yylex (&yylval, YYLEX_PARAM)
|
---|
535 | # else
|
---|
536 | # define YYLEX yylex (&yylval)
|
---|
537 | # endif
|
---|
538 | # endif /* !YYLSP_NEEDED */
|
---|
539 | #else /* !YYPURE */
|
---|
540 | # define YYLEX yylex ()
|
---|
541 | #endif /* !YYPURE */
|
---|
542 |
|
---|
543 |
|
---|
544 | /* Enable debugging if requested. */
|
---|
545 | #if YYDEBUG
|
---|
546 |
|
---|
547 | # ifndef YYFPRINTF
|
---|
548 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
|
---|
549 | # define YYFPRINTF fprintf
|
---|
550 | # endif
|
---|
551 |
|
---|
552 | # define YYDPRINTF(Args) \
|
---|
553 | do { \
|
---|
554 | if (yydebug) \
|
---|
555 | YYFPRINTF Args; \
|
---|
556 | } while (0)
|
---|
557 | /* Nonzero means print parse trace. It is left uninitialized so that
|
---|
558 | multiple parsers can coexist. */
|
---|
559 | int yydebug;
|
---|
560 | #else /* !YYDEBUG */
|
---|
561 | # define YYDPRINTF(Args)
|
---|
562 | #endif /* !YYDEBUG */
|
---|
563 |
|
---|
564 | /* YYINITDEPTH -- initial size of the parser's stacks. */
|
---|
565 | #ifndef YYINITDEPTH
|
---|
566 | # define YYINITDEPTH 200
|
---|
567 | #endif
|
---|
568 |
|
---|
569 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
|
---|
570 | if the built-in stack extension method is used).
|
---|
571 |
|
---|
572 | Do not make this value too large; the results are undefined if
|
---|
573 | SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
|
---|
574 | evaluated with infinite-precision integer arithmetic. */
|
---|
575 |
|
---|
576 | #if YYMAXDEPTH == 0
|
---|
577 | # undef YYMAXDEPTH
|
---|
578 | #endif
|
---|
579 |
|
---|
580 | #ifndef YYMAXDEPTH
|
---|
581 | # define YYMAXDEPTH 10000
|
---|
582 | #endif
|
---|
583 | |
---|
584 |
|
---|
585 | #ifdef YYERROR_VERBOSE
|
---|
586 |
|
---|
587 | # ifndef yystrlen
|
---|
588 | # if defined (__GLIBC__) && defined (_STRING_H)
|
---|
589 | # define yystrlen strlen
|
---|
590 | # else
|
---|
591 | /* Return the length of YYSTR. */
|
---|
592 | static YYSIZE_T
|
---|
593 | # if defined (__STDC__) || defined (__cplusplus)
|
---|
594 | yystrlen (const char *yystr)
|
---|
595 | # else
|
---|
596 | yystrlen (yystr)
|
---|
597 | const char *yystr;
|
---|
598 | # endif
|
---|
599 | {
|
---|
600 | register const char *yys = yystr;
|
---|
601 |
|
---|
602 | while (*yys++ != '\0')
|
---|
603 | continue;
|
---|
604 |
|
---|
605 | return yys - yystr - 1;
|
---|
606 | }
|
---|
607 | # endif
|
---|
608 | # endif
|
---|
609 |
|
---|
610 | # ifndef yystpcpy
|
---|
611 | # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
|
---|
612 | # define yystpcpy stpcpy
|
---|
613 | # else
|
---|
614 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
|
---|
615 | YYDEST. */
|
---|
616 | static char *
|
---|
617 | # if defined (__STDC__) || defined (__cplusplus)
|
---|
618 | yystpcpy (char *yydest, const char *yysrc)
|
---|
619 | # else
|
---|
620 | yystpcpy (yydest, yysrc)
|
---|
621 | char *yydest;
|
---|
622 | const char *yysrc;
|
---|
623 | # endif
|
---|
624 | {
|
---|
625 | register char *yyd = yydest;
|
---|
626 | register const char *yys = yysrc;
|
---|
627 |
|
---|
628 | while ((*yyd++ = *yys++) != '\0')
|
---|
629 | continue;
|
---|
630 |
|
---|
631 | return yyd - 1;
|
---|
632 | }
|
---|
633 | # endif
|
---|
634 | # endif
|
---|
635 | #endif
|
---|
636 | |
---|
637 |
|
---|
638 | #line 315 "/usr/local/share/bison/bison.simple"
|
---|
639 |
|
---|
640 |
|
---|
641 | /* The user can define YYPARSE_PARAM as the name of an argument to be passed
|
---|
642 | into yyparse. The argument should have type void *.
|
---|
643 | It should actually point to an object.
|
---|
644 | Grammar actions can access the variable by casting it
|
---|
645 | to the proper pointer type. */
|
---|
646 |
|
---|
647 | #ifdef YYPARSE_PARAM
|
---|
648 | # if defined (__STDC__) || defined (__cplusplus)
|
---|
649 | # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
|
---|
650 | # define YYPARSE_PARAM_DECL
|
---|
651 | # else
|
---|
652 | # define YYPARSE_PARAM_ARG YYPARSE_PARAM
|
---|
653 | # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
|
---|
654 | # endif
|
---|
655 | #else /* !YYPARSE_PARAM */
|
---|
656 | # define YYPARSE_PARAM_ARG
|
---|
657 | # define YYPARSE_PARAM_DECL
|
---|
658 | #endif /* !YYPARSE_PARAM */
|
---|
659 |
|
---|
660 | /* Prevent warning if -Wstrict-prototypes. */
|
---|
661 | #ifdef __GNUC__
|
---|
662 | # ifdef YYPARSE_PARAM
|
---|
663 | int yyparse (void *);
|
---|
664 | # else
|
---|
665 | int yyparse (void);
|
---|
666 | # endif
|
---|
667 | #endif
|
---|
668 |
|
---|
669 | /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
|
---|
670 | variables are global, or local to YYPARSE. */
|
---|
671 |
|
---|
672 | #define YY_DECL_NON_LSP_VARIABLES \
|
---|
673 | /* The lookahead symbol. */ \
|
---|
674 | int yychar; \
|
---|
675 | \
|
---|
676 | /* The semantic value of the lookahead symbol. */ \
|
---|
677 | YYSTYPE yylval; \
|
---|
678 | \
|
---|
679 | /* Number of parse errors so far. */ \
|
---|
680 | int yynerrs;
|
---|
681 |
|
---|
682 | #if YYLSP_NEEDED
|
---|
683 | # define YY_DECL_VARIABLES \
|
---|
684 | YY_DECL_NON_LSP_VARIABLES \
|
---|
685 | \
|
---|
686 | /* Location data for the lookahead symbol. */ \
|
---|
687 | YYLTYPE yylloc;
|
---|
688 | #else
|
---|
689 | # define YY_DECL_VARIABLES \
|
---|
690 | YY_DECL_NON_LSP_VARIABLES
|
---|
691 | #endif
|
---|
692 |
|
---|
693 |
|
---|
694 | /* If nonreentrant, generate the variables here. */
|
---|
695 |
|
---|
696 | #if !YYPURE
|
---|
697 | YY_DECL_VARIABLES
|
---|
698 | #endif /* !YYPURE */
|
---|
699 |
|
---|
700 | int
|
---|
701 | yyparse (YYPARSE_PARAM_ARG)
|
---|
702 | YYPARSE_PARAM_DECL
|
---|
703 | {
|
---|
704 | /* If reentrant, generate the variables here. */
|
---|
705 | #if YYPURE
|
---|
706 | YY_DECL_VARIABLES
|
---|
707 | #endif /* !YYPURE */
|
---|
708 |
|
---|
709 | register int yystate;
|
---|
710 | register int yyn;
|
---|
711 | int yyresult;
|
---|
712 | /* Number of tokens to shift before error messages enabled. */
|
---|
713 | int yyerrstatus;
|
---|
714 | /* Lookahead token as an internal (translated) token number. */
|
---|
715 | int yychar1 = 0;
|
---|
716 |
|
---|
717 | /* Three stacks and their tools:
|
---|
718 | `yyss': related to states,
|
---|
719 | `yyvs': related to semantic values,
|
---|
720 | `yyls': related to locations.
|
---|
721 |
|
---|
722 | Refer to the stacks thru separate pointers, to allow yyoverflow
|
---|
723 | to reallocate them elsewhere. */
|
---|
724 |
|
---|
725 | /* The state stack. */
|
---|
726 | short yyssa[YYINITDEPTH];
|
---|
727 | short *yyss = yyssa;
|
---|
728 | register short *yyssp;
|
---|
729 |
|
---|
730 | /* The semantic value stack. */
|
---|
731 | YYSTYPE yyvsa[YYINITDEPTH];
|
---|
732 | YYSTYPE *yyvs = yyvsa;
|
---|
733 | register YYSTYPE *yyvsp;
|
---|
734 |
|
---|
735 | #if YYLSP_NEEDED
|
---|
736 | /* The location stack. */
|
---|
737 | YYLTYPE yylsa[YYINITDEPTH];
|
---|
738 | YYLTYPE *yyls = yylsa;
|
---|
739 | YYLTYPE *yylsp;
|
---|
740 | #endif
|
---|
741 |
|
---|
742 | #if YYLSP_NEEDED
|
---|
743 | # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
|
---|
744 | #else
|
---|
745 | # define YYPOPSTACK (yyvsp--, yyssp--)
|
---|
746 | #endif
|
---|
747 |
|
---|
748 | YYSIZE_T yystacksize = YYINITDEPTH;
|
---|
749 |
|
---|
750 |
|
---|
751 | /* The variables used to return semantic value and location from the
|
---|
752 | action routines. */
|
---|
753 | YYSTYPE yyval;
|
---|
754 | #if YYLSP_NEEDED
|
---|
755 | YYLTYPE yyloc;
|
---|
756 | #endif
|
---|
757 |
|
---|
758 | /* When reducing, the number of symbols on the RHS of the reduced
|
---|
759 | rule. */
|
---|
760 | int yylen;
|
---|
761 |
|
---|
762 | YYDPRINTF ((stderr, "Starting parse\n"));
|
---|
763 |
|
---|
764 | yystate = 0;
|
---|
765 | yyerrstatus = 0;
|
---|
766 | yynerrs = 0;
|
---|
767 | yychar = YYEMPTY; /* Cause a token to be read. */
|
---|
768 |
|
---|
769 | /* Initialize stack pointers.
|
---|
770 | Waste one element of value and location stack
|
---|
771 | so that they stay on the same level as the state stack.
|
---|
772 | The wasted elements are never initialized. */
|
---|
773 |
|
---|
774 | yyssp = yyss;
|
---|
775 | yyvsp = yyvs;
|
---|
776 | #if YYLSP_NEEDED
|
---|
777 | yylsp = yyls;
|
---|
778 | #endif
|
---|
779 | goto yysetstate;
|
---|
780 |
|
---|
781 | /*------------------------------------------------------------.
|
---|
782 | | yynewstate -- Push a new state, which is found in yystate. |
|
---|
783 | `------------------------------------------------------------*/
|
---|
784 | yynewstate:
|
---|
785 | /* In all cases, when you get here, the value and location stacks
|
---|
786 | have just been pushed. so pushing a state here evens the stacks.
|
---|
787 | */
|
---|
788 | yyssp++;
|
---|
789 |
|
---|
790 | yysetstate:
|
---|
791 | *yyssp = yystate;
|
---|
792 |
|
---|
793 | if (yyssp >= yyss + yystacksize - 1)
|
---|
794 | {
|
---|
795 | /* Get the current used size of the three stacks, in elements. */
|
---|
796 | YYSIZE_T yysize = yyssp - yyss + 1;
|
---|
797 |
|
---|
798 | #ifdef yyoverflow
|
---|
799 | {
|
---|
800 | /* Give user a chance to reallocate the stack. Use copies of
|
---|
801 | these so that the &'s don't force the real ones into
|
---|
802 | memory. */
|
---|
803 | YYSTYPE *yyvs1 = yyvs;
|
---|
804 | short *yyss1 = yyss;
|
---|
805 |
|
---|
806 | /* Each stack pointer address is followed by the size of the
|
---|
807 | data in use in that stack, in bytes. */
|
---|
808 | # if YYLSP_NEEDED
|
---|
809 | YYLTYPE *yyls1 = yyls;
|
---|
810 | /* This used to be a conditional around just the two extra args,
|
---|
811 | but that might be undefined if yyoverflow is a macro. */
|
---|
812 | yyoverflow ("parser stack overflow",
|
---|
813 | &yyss1, yysize * sizeof (*yyssp),
|
---|
814 | &yyvs1, yysize * sizeof (*yyvsp),
|
---|
815 | &yyls1, yysize * sizeof (*yylsp),
|
---|
816 | &yystacksize);
|
---|
817 | yyls = yyls1;
|
---|
818 | # else
|
---|
819 | yyoverflow ("parser stack overflow",
|
---|
820 | &yyss1, yysize * sizeof (*yyssp),
|
---|
821 | &yyvs1, yysize * sizeof (*yyvsp),
|
---|
822 | &yystacksize);
|
---|
823 | # endif
|
---|
824 | yyss = yyss1;
|
---|
825 | yyvs = yyvs1;
|
---|
826 | }
|
---|
827 | #else /* no yyoverflow */
|
---|
828 | # ifndef YYSTACK_RELOCATE
|
---|
829 | goto yyoverflowlab;
|
---|
830 | # else
|
---|
831 | /* Extend the stack our own way. */
|
---|
832 | if (yystacksize >= YYMAXDEPTH)
|
---|
833 | goto yyoverflowlab;
|
---|
834 | yystacksize *= 2;
|
---|
835 | if (yystacksize > YYMAXDEPTH)
|
---|
836 | yystacksize = YYMAXDEPTH;
|
---|
837 |
|
---|
838 | {
|
---|
839 | short *yyss1 = yyss;
|
---|
840 | union yyalloc *yyptr =
|
---|
841 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
|
---|
842 | if (! yyptr)
|
---|
843 | goto yyoverflowlab;
|
---|
844 | YYSTACK_RELOCATE (yyss);
|
---|
845 | YYSTACK_RELOCATE (yyvs);
|
---|
846 | # if YYLSP_NEEDED
|
---|
847 | YYSTACK_RELOCATE (yyls);
|
---|
848 | # endif
|
---|
849 | # undef YYSTACK_RELOCATE
|
---|
850 | if (yyss1 != yyssa)
|
---|
851 | YYSTACK_FREE (yyss1);
|
---|
852 | }
|
---|
853 | # endif
|
---|
854 | #endif /* no yyoverflow */
|
---|
855 |
|
---|
856 | yyssp = yyss + yysize - 1;
|
---|
857 | yyvsp = yyvs + yysize - 1;
|
---|
858 | #if YYLSP_NEEDED
|
---|
859 | yylsp = yyls + yysize - 1;
|
---|
860 | #endif
|
---|
861 |
|
---|
862 | YYDPRINTF ((stderr, "Stack size increased to %lu\n",
|
---|
863 | (unsigned long int) yystacksize));
|
---|
864 |
|
---|
865 | if (yyssp >= yyss + yystacksize - 1)
|
---|
866 | YYABORT;
|
---|
867 | }
|
---|
868 |
|
---|
869 | YYDPRINTF ((stderr, "Entering state %d\n", yystate));
|
---|
870 |
|
---|
871 | goto yybackup;
|
---|
872 |
|
---|
873 |
|
---|
874 | /*-----------.
|
---|
875 | | yybackup. |
|
---|
876 | `-----------*/
|
---|
877 | yybackup:
|
---|
878 |
|
---|
879 | /* Do appropriate processing given the current state. */
|
---|
880 | /* Read a lookahead token if we need one and don't already have one. */
|
---|
881 | /* yyresume: */
|
---|
882 |
|
---|
883 | /* First try to decide what to do without reference to lookahead token. */
|
---|
884 |
|
---|
885 | yyn = yypact[yystate];
|
---|
886 | if (yyn == YYFLAG)
|
---|
887 | goto yydefault;
|
---|
888 |
|
---|
889 | /* Not known => get a lookahead token if don't already have one. */
|
---|
890 |
|
---|
891 | /* yychar is either YYEMPTY or YYEOF
|
---|
892 | or a valid token in external form. */
|
---|
893 |
|
---|
894 | if (yychar == YYEMPTY)
|
---|
895 | {
|
---|
896 | YYDPRINTF ((stderr, "Reading a token: "));
|
---|
897 | yychar = YYLEX;
|
---|
898 | }
|
---|
899 |
|
---|
900 | /* Convert token to internal form (in yychar1) for indexing tables with */
|
---|
901 |
|
---|
902 | if (yychar <= 0) /* This means end of input. */
|
---|
903 | {
|
---|
904 | yychar1 = 0;
|
---|
905 | yychar = YYEOF; /* Don't call YYLEX any more */
|
---|
906 |
|
---|
907 | YYDPRINTF ((stderr, "Now at end of input.\n"));
|
---|
908 | }
|
---|
909 | else
|
---|
910 | {
|
---|
911 | yychar1 = YYTRANSLATE (yychar);
|
---|
912 |
|
---|
913 | #if YYDEBUG
|
---|
914 | /* We have to keep this `#if YYDEBUG', since we use variables
|
---|
915 | which are defined only if `YYDEBUG' is set. */
|
---|
916 | if (yydebug)
|
---|
917 | {
|
---|
918 | YYFPRINTF (stderr, "Next token is %d (%s",
|
---|
919 | yychar, yytname[yychar1]);
|
---|
920 | /* Give the individual parser a way to print the precise
|
---|
921 | meaning of a token, for further debugging info. */
|
---|
922 | # ifdef YYPRINT
|
---|
923 | YYPRINT (stderr, yychar, yylval);
|
---|
924 | # endif
|
---|
925 | YYFPRINTF (stderr, ")\n");
|
---|
926 | }
|
---|
927 | #endif
|
---|
928 | }
|
---|
929 |
|
---|
930 | yyn += yychar1;
|
---|
931 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
|
---|
932 | goto yydefault;
|
---|
933 |
|
---|
934 | yyn = yytable[yyn];
|
---|
935 |
|
---|
936 | /* yyn is what to do for this token type in this state.
|
---|
937 | Negative => reduce, -yyn is rule number.
|
---|
938 | Positive => shift, yyn is new state.
|
---|
939 | New state is final state => don't bother to shift,
|
---|
940 | just return success.
|
---|
941 | 0, or most negative number => error. */
|
---|
942 |
|
---|
943 | if (yyn < 0)
|
---|
944 | {
|
---|
945 | if (yyn == YYFLAG)
|
---|
946 | goto yyerrlab;
|
---|
947 | yyn = -yyn;
|
---|
948 | goto yyreduce;
|
---|
949 | }
|
---|
950 | else if (yyn == 0)
|
---|
951 | goto yyerrlab;
|
---|
952 |
|
---|
953 | if (yyn == YYFINAL)
|
---|
954 | YYACCEPT;
|
---|
955 |
|
---|
956 | /* Shift the lookahead token. */
|
---|
957 | YYDPRINTF ((stderr, "Shifting token %d (%s), ",
|
---|
958 | yychar, yytname[yychar1]));
|
---|
959 |
|
---|
960 | /* Discard the token being shifted unless it is eof. */
|
---|
961 | if (yychar != YYEOF)
|
---|
962 | yychar = YYEMPTY;
|
---|
963 |
|
---|
964 | *++yyvsp = yylval;
|
---|
965 | #if YYLSP_NEEDED
|
---|
966 | *++yylsp = yylloc;
|
---|
967 | #endif
|
---|
968 |
|
---|
969 | /* Count tokens shifted since error; after three, turn off error
|
---|
970 | status. */
|
---|
971 | if (yyerrstatus)
|
---|
972 | yyerrstatus--;
|
---|
973 |
|
---|
974 | yystate = yyn;
|
---|
975 | goto yynewstate;
|
---|
976 |
|
---|
977 |
|
---|
978 | /*-----------------------------------------------------------.
|
---|
979 | | yydefault -- do the default action for the current state. |
|
---|
980 | `-----------------------------------------------------------*/
|
---|
981 | yydefault:
|
---|
982 | yyn = yydefact[yystate];
|
---|
983 | if (yyn == 0)
|
---|
984 | goto yyerrlab;
|
---|
985 | goto yyreduce;
|
---|
986 |
|
---|
987 |
|
---|
988 | /*-----------------------------.
|
---|
989 | | yyreduce -- Do a reduction. |
|
---|
990 | `-----------------------------*/
|
---|
991 | yyreduce:
|
---|
992 | /* yyn is the number of a rule to reduce with. */
|
---|
993 | yylen = yyr2[yyn];
|
---|
994 |
|
---|
995 | /* If YYLEN is nonzero, implement the default value of the action:
|
---|
996 | `$$ = $1'.
|
---|
997 |
|
---|
998 | Otherwise, the following line sets YYVAL to the semantic value of
|
---|
999 | the lookahead token. This behavior is undocumented and Bison
|
---|
1000 | users should not rely upon it. Assigning to YYVAL
|
---|
1001 | unconditionally makes the parser a bit smaller, and it avoids a
|
---|
1002 | GCC warning that YYVAL may be used uninitialized. */
|
---|
1003 | yyval = yyvsp[1-yylen];
|
---|
1004 |
|
---|
1005 | #if YYLSP_NEEDED
|
---|
1006 | /* Similarly for the default location. Let the user run additional
|
---|
1007 | commands if for instance locations are ranges. */
|
---|
1008 | yyloc = yylsp[1-yylen];
|
---|
1009 | YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
|
---|
1010 | #endif
|
---|
1011 |
|
---|
1012 | #if YYDEBUG
|
---|
1013 | /* We have to keep this `#if YYDEBUG', since we use variables which
|
---|
1014 | are defined only if `YYDEBUG' is set. */
|
---|
1015 | if (yydebug)
|
---|
1016 | {
|
---|
1017 | int yyi;
|
---|
1018 |
|
---|
1019 | YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
|
---|
1020 | yyn, yyrline[yyn]);
|
---|
1021 |
|
---|
1022 | /* Print the symbols being reduced, and their result. */
|
---|
1023 | for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
|
---|
1024 | YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
|
---|
1025 | YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
|
---|
1026 | }
|
---|
1027 | #endif
|
---|
1028 |
|
---|
1029 | switch (yyn) {
|
---|
1030 |
|
---|
1031 | case 1:
|
---|
1032 | #line 175 "plural.y"
|
---|
1033 | {
|
---|
1034 | if (yyvsp[0].exp == NULL)
|
---|
1035 | YYABORT;
|
---|
1036 | ((struct parse_args *) arg)->res = yyvsp[0].exp;
|
---|
1037 | }
|
---|
1038 | break;
|
---|
1039 | case 2:
|
---|
1040 | #line 183 "plural.y"
|
---|
1041 | {
|
---|
1042 | yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp);
|
---|
1043 | }
|
---|
1044 | break;
|
---|
1045 | case 3:
|
---|
1046 | #line 187 "plural.y"
|
---|
1047 | {
|
---|
1048 | yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp);
|
---|
1049 | }
|
---|
1050 | break;
|
---|
1051 | case 4:
|
---|
1052 | #line 191 "plural.y"
|
---|
1053 | {
|
---|
1054 | yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp);
|
---|
1055 | }
|
---|
1056 | break;
|
---|
1057 | case 5:
|
---|
1058 | #line 195 "plural.y"
|
---|
1059 | {
|
---|
1060 | yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
|
---|
1061 | }
|
---|
1062 | break;
|
---|
1063 | case 6:
|
---|
1064 | #line 199 "plural.y"
|
---|
1065 | {
|
---|
1066 | yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
|
---|
1067 | }
|
---|
1068 | break;
|
---|
1069 | case 7:
|
---|
1070 | #line 203 "plural.y"
|
---|
1071 | {
|
---|
1072 | yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
|
---|
1073 | }
|
---|
1074 | break;
|
---|
1075 | case 8:
|
---|
1076 | #line 207 "plural.y"
|
---|
1077 | {
|
---|
1078 | yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
|
---|
1079 | }
|
---|
1080 | break;
|
---|
1081 | case 9:
|
---|
1082 | #line 211 "plural.y"
|
---|
1083 | {
|
---|
1084 | yyval.exp = new_exp_1 (lnot, yyvsp[0].exp);
|
---|
1085 | }
|
---|
1086 | break;
|
---|
1087 | case 10:
|
---|
1088 | #line 215 "plural.y"
|
---|
1089 | {
|
---|
1090 | yyval.exp = new_exp_0 (var);
|
---|
1091 | }
|
---|
1092 | break;
|
---|
1093 | case 11:
|
---|
1094 | #line 219 "plural.y"
|
---|
1095 | {
|
---|
1096 | if ((yyval.exp = new_exp_0 (num)) != NULL)
|
---|
1097 | yyval.exp->val.num = yyvsp[0].num;
|
---|
1098 | }
|
---|
1099 | break;
|
---|
1100 | case 12:
|
---|
1101 | #line 224 "plural.y"
|
---|
1102 | {
|
---|
1103 | yyval.exp = yyvsp[-1].exp;
|
---|
1104 | }
|
---|
1105 | break;
|
---|
1106 | }
|
---|
1107 |
|
---|
1108 | #line 705 "/usr/local/share/bison/bison.simple"
|
---|
1109 |
|
---|
1110 | |
---|
1111 |
|
---|
1112 | yyvsp -= yylen;
|
---|
1113 | yyssp -= yylen;
|
---|
1114 | #if YYLSP_NEEDED
|
---|
1115 | yylsp -= yylen;
|
---|
1116 | #endif
|
---|
1117 |
|
---|
1118 | #if YYDEBUG
|
---|
1119 | if (yydebug)
|
---|
1120 | {
|
---|
1121 | short *yyssp1 = yyss - 1;
|
---|
1122 | YYFPRINTF (stderr, "state stack now");
|
---|
1123 | while (yyssp1 != yyssp)
|
---|
1124 | YYFPRINTF (stderr, " %d", *++yyssp1);
|
---|
1125 | YYFPRINTF (stderr, "\n");
|
---|
1126 | }
|
---|
1127 | #endif
|
---|
1128 |
|
---|
1129 | *++yyvsp = yyval;
|
---|
1130 | #if YYLSP_NEEDED
|
---|
1131 | *++yylsp = yyloc;
|
---|
1132 | #endif
|
---|
1133 |
|
---|
1134 | /* Now `shift' the result of the reduction. Determine what state
|
---|
1135 | that goes to, based on the state we popped back to and the rule
|
---|
1136 | number reduced by. */
|
---|
1137 |
|
---|
1138 | yyn = yyr1[yyn];
|
---|
1139 |
|
---|
1140 | yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
|
---|
1141 | if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
|
---|
1142 | yystate = yytable[yystate];
|
---|
1143 | else
|
---|
1144 | yystate = yydefgoto[yyn - YYNTBASE];
|
---|
1145 |
|
---|
1146 | goto yynewstate;
|
---|
1147 |
|
---|
1148 |
|
---|
1149 | /*------------------------------------.
|
---|
1150 | | yyerrlab -- here on detecting error |
|
---|
1151 | `------------------------------------*/
|
---|
1152 | yyerrlab:
|
---|
1153 | /* If not already recovering from an error, report this error. */
|
---|
1154 | if (!yyerrstatus)
|
---|
1155 | {
|
---|
1156 | ++yynerrs;
|
---|
1157 |
|
---|
1158 | #ifdef YYERROR_VERBOSE
|
---|
1159 | yyn = yypact[yystate];
|
---|
1160 |
|
---|
1161 | if (yyn > YYFLAG && yyn < YYLAST)
|
---|
1162 | {
|
---|
1163 | YYSIZE_T yysize = 0;
|
---|
1164 | char *yymsg;
|
---|
1165 | int yyx, yycount;
|
---|
1166 |
|
---|
1167 | yycount = 0;
|
---|
1168 | /* Start YYX at -YYN if negative to avoid negative indexes in
|
---|
1169 | YYCHECK. */
|
---|
1170 | for (yyx = yyn < 0 ? -yyn : 0;
|
---|
1171 | yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
|
---|
1172 | if (yycheck[yyx + yyn] == yyx)
|
---|
1173 | yysize += yystrlen (yytname[yyx]) + 15, yycount++;
|
---|
1174 | yysize += yystrlen ("parse error, unexpected ") + 1;
|
---|
1175 | yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
|
---|
1176 | yymsg = (char *) YYSTACK_ALLOC (yysize);
|
---|
1177 | if (yymsg != 0)
|
---|
1178 | {
|
---|
1179 | char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
|
---|
1180 | yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
|
---|
1181 |
|
---|
1182 | if (yycount < 5)
|
---|
1183 | {
|
---|
1184 | yycount = 0;
|
---|
1185 | for (yyx = yyn < 0 ? -yyn : 0;
|
---|
1186 | yyx < (int) (sizeof (yytname) / sizeof (char *));
|
---|
1187 | yyx++)
|
---|
1188 | if (yycheck[yyx + yyn] == yyx)
|
---|
1189 | {
|
---|
1190 | const char *yyq = ! yycount ? ", expecting " : " or ";
|
---|
1191 | yyp = yystpcpy (yyp, yyq);
|
---|
1192 | yyp = yystpcpy (yyp, yytname[yyx]);
|
---|
1193 | yycount++;
|
---|
1194 | }
|
---|
1195 | }
|
---|
1196 | yyerror (yymsg);
|
---|
1197 | YYSTACK_FREE (yymsg);
|
---|
1198 | }
|
---|
1199 | else
|
---|
1200 | yyerror ("parse error; also virtual memory exhausted");
|
---|
1201 | }
|
---|
1202 | else
|
---|
1203 | #endif /* defined (YYERROR_VERBOSE) */
|
---|
1204 | yyerror ("parse error");
|
---|
1205 | }
|
---|
1206 | goto yyerrlab1;
|
---|
1207 |
|
---|
1208 |
|
---|
1209 | /*--------------------------------------------------.
|
---|
1210 | | yyerrlab1 -- error raised explicitly by an action |
|
---|
1211 | `--------------------------------------------------*/
|
---|
1212 | yyerrlab1:
|
---|
1213 | if (yyerrstatus == 3)
|
---|
1214 | {
|
---|
1215 | /* If just tried and failed to reuse lookahead token after an
|
---|
1216 | error, discard it. */
|
---|
1217 |
|
---|
1218 | /* return failure if at end of input */
|
---|
1219 | if (yychar == YYEOF)
|
---|
1220 | YYABORT;
|
---|
1221 | YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
|
---|
1222 | yychar, yytname[yychar1]));
|
---|
1223 | yychar = YYEMPTY;
|
---|
1224 | }
|
---|
1225 |
|
---|
1226 | /* Else will try to reuse lookahead token after shifting the error
|
---|
1227 | token. */
|
---|
1228 |
|
---|
1229 | yyerrstatus = 3; /* Each real token shifted decrements this */
|
---|
1230 |
|
---|
1231 | goto yyerrhandle;
|
---|
1232 |
|
---|
1233 |
|
---|
1234 | /*-------------------------------------------------------------------.
|
---|
1235 | | yyerrdefault -- current state does not do anything special for the |
|
---|
1236 | | error token. |
|
---|
1237 | `-------------------------------------------------------------------*/
|
---|
1238 | yyerrdefault:
|
---|
1239 | #if 0
|
---|
1240 | /* This is wrong; only states that explicitly want error tokens
|
---|
1241 | should shift them. */
|
---|
1242 |
|
---|
1243 | /* If its default is to accept any token, ok. Otherwise pop it. */
|
---|
1244 | yyn = yydefact[yystate];
|
---|
1245 | if (yyn)
|
---|
1246 | goto yydefault;
|
---|
1247 | #endif
|
---|
1248 |
|
---|
1249 |
|
---|
1250 | /*---------------------------------------------------------------.
|
---|
1251 | | yyerrpop -- pop the current state because it cannot handle the |
|
---|
1252 | | error token |
|
---|
1253 | `---------------------------------------------------------------*/
|
---|
1254 | yyerrpop:
|
---|
1255 | if (yyssp == yyss)
|
---|
1256 | YYABORT;
|
---|
1257 | yyvsp--;
|
---|
1258 | yystate = *--yyssp;
|
---|
1259 | #if YYLSP_NEEDED
|
---|
1260 | yylsp--;
|
---|
1261 | #endif
|
---|
1262 |
|
---|
1263 | #if YYDEBUG
|
---|
1264 | if (yydebug)
|
---|
1265 | {
|
---|
1266 | short *yyssp1 = yyss - 1;
|
---|
1267 | YYFPRINTF (stderr, "Error: state stack now");
|
---|
1268 | while (yyssp1 != yyssp)
|
---|
1269 | YYFPRINTF (stderr, " %d", *++yyssp1);
|
---|
1270 | YYFPRINTF (stderr, "\n");
|
---|
1271 | }
|
---|
1272 | #endif
|
---|
1273 |
|
---|
1274 | /*--------------.
|
---|
1275 | | yyerrhandle. |
|
---|
1276 | `--------------*/
|
---|
1277 | yyerrhandle:
|
---|
1278 | yyn = yypact[yystate];
|
---|
1279 | if (yyn == YYFLAG)
|
---|
1280 | goto yyerrdefault;
|
---|
1281 |
|
---|
1282 | yyn += YYTERROR;
|
---|
1283 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
|
---|
1284 | goto yyerrdefault;
|
---|
1285 |
|
---|
1286 | yyn = yytable[yyn];
|
---|
1287 | if (yyn < 0)
|
---|
1288 | {
|
---|
1289 | if (yyn == YYFLAG)
|
---|
1290 | goto yyerrpop;
|
---|
1291 | yyn = -yyn;
|
---|
1292 | goto yyreduce;
|
---|
1293 | }
|
---|
1294 | else if (yyn == 0)
|
---|
1295 | goto yyerrpop;
|
---|
1296 |
|
---|
1297 | if (yyn == YYFINAL)
|
---|
1298 | YYACCEPT;
|
---|
1299 |
|
---|
1300 | YYDPRINTF ((stderr, "Shifting error token, "));
|
---|
1301 |
|
---|
1302 | *++yyvsp = yylval;
|
---|
1303 | #if YYLSP_NEEDED
|
---|
1304 | *++yylsp = yylloc;
|
---|
1305 | #endif
|
---|
1306 |
|
---|
1307 | yystate = yyn;
|
---|
1308 | goto yynewstate;
|
---|
1309 |
|
---|
1310 |
|
---|
1311 | /*-------------------------------------.
|
---|
1312 | | yyacceptlab -- YYACCEPT comes here. |
|
---|
1313 | `-------------------------------------*/
|
---|
1314 | yyacceptlab:
|
---|
1315 | yyresult = 0;
|
---|
1316 | goto yyreturn;
|
---|
1317 |
|
---|
1318 | /*-----------------------------------.
|
---|
1319 | | yyabortlab -- YYABORT comes here. |
|
---|
1320 | `-----------------------------------*/
|
---|
1321 | yyabortlab:
|
---|
1322 | yyresult = 1;
|
---|
1323 | goto yyreturn;
|
---|
1324 |
|
---|
1325 | /*---------------------------------------------.
|
---|
1326 | | yyoverflowab -- parser overflow comes here. |
|
---|
1327 | `---------------------------------------------*/
|
---|
1328 | yyoverflowlab:
|
---|
1329 | yyerror ("parser stack overflow");
|
---|
1330 | yyresult = 2;
|
---|
1331 | /* Fall through. */
|
---|
1332 |
|
---|
1333 | yyreturn:
|
---|
1334 | #ifndef yyoverflow
|
---|
1335 | if (yyss != yyssa)
|
---|
1336 | YYSTACK_FREE (yyss);
|
---|
1337 | #endif
|
---|
1338 | return yyresult;
|
---|
1339 | }
|
---|
1340 | #line 229 "plural.y"
|
---|
1341 |
|
---|
1342 |
|
---|
1343 | void
|
---|
1344 | internal_function
|
---|
1345 | FREE_EXPRESSION (exp)
|
---|
1346 | struct expression *exp;
|
---|
1347 | {
|
---|
1348 | if (exp == NULL)
|
---|
1349 | return;
|
---|
1350 |
|
---|
1351 | /* Handle the recursive case. */
|
---|
1352 | switch (exp->nargs)
|
---|
1353 | {
|
---|
1354 | case 3:
|
---|
1355 | FREE_EXPRESSION (exp->val.args[2]);
|
---|
1356 | /* FALLTHROUGH */
|
---|
1357 | case 2:
|
---|
1358 | FREE_EXPRESSION (exp->val.args[1]);
|
---|
1359 | /* FALLTHROUGH */
|
---|
1360 | case 1:
|
---|
1361 | FREE_EXPRESSION (exp->val.args[0]);
|
---|
1362 | /* FALLTHROUGH */
|
---|
1363 | default:
|
---|
1364 | break;
|
---|
1365 | }
|
---|
1366 |
|
---|
1367 | free (exp);
|
---|
1368 | }
|
---|
1369 |
|
---|
1370 |
|
---|
1371 | static int
|
---|
1372 | yylex (lval, pexp)
|
---|
1373 | YYSTYPE *lval;
|
---|
1374 | const char **pexp;
|
---|
1375 | {
|
---|
1376 | const char *exp = *pexp;
|
---|
1377 | int result;
|
---|
1378 |
|
---|
1379 | while (1)
|
---|
1380 | {
|
---|
1381 | if (exp[0] == '\0')
|
---|
1382 | {
|
---|
1383 | *pexp = exp;
|
---|
1384 | return YYEOF;
|
---|
1385 | }
|
---|
1386 |
|
---|
1387 | if (exp[0] != ' ' && exp[0] != '\t')
|
---|
1388 | break;
|
---|
1389 |
|
---|
1390 | ++exp;
|
---|
1391 | }
|
---|
1392 |
|
---|
1393 | result = *exp++;
|
---|
1394 | switch (result)
|
---|
1395 | {
|
---|
1396 | case '0': case '1': case '2': case '3': case '4':
|
---|
1397 | case '5': case '6': case '7': case '8': case '9':
|
---|
1398 | {
|
---|
1399 | unsigned long int n = result - '0';
|
---|
1400 | while (exp[0] >= '0' && exp[0] <= '9')
|
---|
1401 | {
|
---|
1402 | n *= 10;
|
---|
1403 | n += exp[0] - '0';
|
---|
1404 | ++exp;
|
---|
1405 | }
|
---|
1406 | lval->num = n;
|
---|
1407 | result = NUMBER;
|
---|
1408 | }
|
---|
1409 | break;
|
---|
1410 |
|
---|
1411 | case '=':
|
---|
1412 | if (exp[0] == '=')
|
---|
1413 | {
|
---|
1414 | ++exp;
|
---|
1415 | lval->op = equal;
|
---|
1416 | result = EQUOP2;
|
---|
1417 | }
|
---|
1418 | else
|
---|
1419 | result = YYERRCODE;
|
---|
1420 | break;
|
---|
1421 |
|
---|
1422 | case '!':
|
---|
1423 | if (exp[0] == '=')
|
---|
1424 | {
|
---|
1425 | ++exp;
|
---|
1426 | lval->op = not_equal;
|
---|
1427 | result = EQUOP2;
|
---|
1428 | }
|
---|
1429 | break;
|
---|
1430 |
|
---|
1431 | case '&':
|
---|
1432 | case '|':
|
---|
1433 | if (exp[0] == result)
|
---|
1434 | ++exp;
|
---|
1435 | else
|
---|
1436 | result = YYERRCODE;
|
---|
1437 | break;
|
---|
1438 |
|
---|
1439 | case '<':
|
---|
1440 | if (exp[0] == '=')
|
---|
1441 | {
|
---|
1442 | ++exp;
|
---|
1443 | lval->op = less_or_equal;
|
---|
1444 | }
|
---|
1445 | else
|
---|
1446 | lval->op = less_than;
|
---|
1447 | result = CMPOP2;
|
---|
1448 | break;
|
---|
1449 |
|
---|
1450 | case '>':
|
---|
1451 | if (exp[0] == '=')
|
---|
1452 | {
|
---|
1453 | ++exp;
|
---|
1454 | lval->op = greater_or_equal;
|
---|
1455 | }
|
---|
1456 | else
|
---|
1457 | lval->op = greater_than;
|
---|
1458 | result = CMPOP2;
|
---|
1459 | break;
|
---|
1460 |
|
---|
1461 | case '*':
|
---|
1462 | lval->op = mult;
|
---|
1463 | result = MULOP2;
|
---|
1464 | break;
|
---|
1465 |
|
---|
1466 | case '/':
|
---|
1467 | lval->op = divide;
|
---|
1468 | result = MULOP2;
|
---|
1469 | break;
|
---|
1470 |
|
---|
1471 | case '%':
|
---|
1472 | lval->op = module;
|
---|
1473 | result = MULOP2;
|
---|
1474 | break;
|
---|
1475 |
|
---|
1476 | case '+':
|
---|
1477 | lval->op = plus;
|
---|
1478 | result = ADDOP2;
|
---|
1479 | break;
|
---|
1480 |
|
---|
1481 | case '-':
|
---|
1482 | lval->op = minus;
|
---|
1483 | result = ADDOP2;
|
---|
1484 | break;
|
---|
1485 |
|
---|
1486 | case 'n':
|
---|
1487 | case '?':
|
---|
1488 | case ':':
|
---|
1489 | case '(':
|
---|
1490 | case ')':
|
---|
1491 | /* Nothing, just return the character. */
|
---|
1492 | break;
|
---|
1493 |
|
---|
1494 | case ';':
|
---|
1495 | case '\n':
|
---|
1496 | case '\0':
|
---|
1497 | /* Be safe and let the user call this function again. */
|
---|
1498 | --exp;
|
---|
1499 | result = YYEOF;
|
---|
1500 | break;
|
---|
1501 |
|
---|
1502 | default:
|
---|
1503 | result = YYERRCODE;
|
---|
1504 | #if YYDEBUG != 0
|
---|
1505 | --exp;
|
---|
1506 | #endif
|
---|
1507 | break;
|
---|
1508 | }
|
---|
1509 |
|
---|
1510 | *pexp = exp;
|
---|
1511 |
|
---|
1512 | return result;
|
---|
1513 | }
|
---|
1514 |
|
---|
1515 |
|
---|
1516 | static void
|
---|
1517 | yyerror (str)
|
---|
1518 | const char *str;
|
---|
1519 | {
|
---|
1520 | /* Do nothing. We don't print error messages here. */
|
---|
1521 | }
|
---|