Commit | Line | Data |
---|---|---|
bf070c84 SE |
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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, | |
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., 51 Franklin Street - Fifth Floor, | |
343 | Boston, MA 02110-1301, 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 | \f | |
584 | #ifdef YYERROR_VERBOSE | |
585 | ||
586 | # ifndef yystrlen | |
587 | # if defined (__GLIBC__) && defined (_STRING_H) | |
588 | # define yystrlen strlen | |
589 | # else | |
590 | /* Return the length of YYSTR. */ | |
591 | static YYSIZE_T | |
592 | # if defined (__STDC__) || defined (__cplusplus) | |
593 | yystrlen (const char *yystr) | |
594 | # else | |
595 | yystrlen (yystr) | |
596 | const char *yystr; | |
597 | # endif | |
598 | { | |
599 | register const char *yys = yystr; | |
600 | ||
601 | while (*yys++ != '\0') | |
602 | continue; | |
603 | ||
604 | return yys - yystr - 1; | |
605 | } | |
606 | # endif | |
607 | # endif | |
608 | ||
609 | # ifndef yystpcpy | |
610 | # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) | |
611 | # define yystpcpy stpcpy | |
612 | # else | |
613 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in | |
614 | YYDEST. */ | |
615 | static char * | |
616 | # if defined (__STDC__) || defined (__cplusplus) | |
617 | yystpcpy (char *yydest, const char *yysrc) | |
618 | # else | |
619 | yystpcpy (yydest, yysrc) | |
620 | char *yydest; | |
621 | const char *yysrc; | |
622 | # endif | |
623 | { | |
624 | register char *yyd = yydest; | |
625 | register const char *yys = yysrc; | |
626 | ||
627 | while ((*yyd++ = *yys++) != '\0') | |
628 | continue; | |
629 | ||
630 | return yyd - 1; | |
631 | } | |
632 | # endif | |
633 | # endif | |
634 | #endif | |
635 | \f | |
636 | #line 315 "/usr/local/share/bison/bison.simple" | |
637 | ||
638 | ||
639 | /* The user can define YYPARSE_PARAM as the name of an argument to be passed | |
640 | into yyparse. The argument should have type void *. | |
641 | It should actually point to an object. | |
642 | Grammar actions can access the variable by casting it | |
643 | to the proper pointer type. */ | |
644 | ||
645 | #ifdef YYPARSE_PARAM | |
646 | # if defined (__STDC__) || defined (__cplusplus) | |
647 | # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM | |
648 | # define YYPARSE_PARAM_DECL | |
649 | # else | |
650 | # define YYPARSE_PARAM_ARG YYPARSE_PARAM | |
651 | # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; | |
652 | # endif | |
653 | #else /* !YYPARSE_PARAM */ | |
654 | # define YYPARSE_PARAM_ARG | |
655 | # define YYPARSE_PARAM_DECL | |
656 | #endif /* !YYPARSE_PARAM */ | |
657 | ||
658 | /* Prevent warning if -Wstrict-prototypes. */ | |
659 | #ifdef __GNUC__ | |
660 | # ifdef YYPARSE_PARAM | |
661 | int yyparse (void *); | |
662 | # else | |
663 | int yyparse (void); | |
664 | # endif | |
665 | #endif | |
666 | ||
667 | /* YY_DECL_VARIABLES -- depending whether we use a pure parser, | |
668 | variables are global, or local to YYPARSE. */ | |
669 | ||
670 | #define YY_DECL_NON_LSP_VARIABLES \ | |
671 | /* The lookahead symbol. */ \ | |
672 | int yychar; \ | |
673 | \ | |
674 | /* The semantic value of the lookahead symbol. */ \ | |
675 | YYSTYPE yylval; \ | |
676 | \ | |
677 | /* Number of parse errors so far. */ \ | |
678 | int yynerrs; | |
679 | ||
680 | #if YYLSP_NEEDED | |
681 | # define YY_DECL_VARIABLES \ | |
682 | YY_DECL_NON_LSP_VARIABLES \ | |
683 | \ | |
684 | /* Location data for the lookahead symbol. */ \ | |
685 | YYLTYPE yylloc; | |
686 | #else | |
687 | # define YY_DECL_VARIABLES \ | |
688 | YY_DECL_NON_LSP_VARIABLES | |
689 | #endif | |
690 | ||
691 | ||
692 | /* If nonreentrant, generate the variables here. */ | |
693 | ||
694 | #if !YYPURE | |
695 | YY_DECL_VARIABLES | |
696 | #endif /* !YYPURE */ | |
697 | ||
698 | int | |
699 | yyparse (YYPARSE_PARAM_ARG) | |
700 | YYPARSE_PARAM_DECL | |
701 | { | |
702 | /* If reentrant, generate the variables here. */ | |
703 | #if YYPURE | |
704 | YY_DECL_VARIABLES | |
705 | #endif /* !YYPURE */ | |
706 | ||
707 | register int yystate; | |
708 | register int yyn; | |
709 | int yyresult; | |
710 | /* Number of tokens to shift before error messages enabled. */ | |
711 | int yyerrstatus; | |
712 | /* Lookahead token as an internal (translated) token number. */ | |
713 | int yychar1 = 0; | |
714 | ||
715 | /* Three stacks and their tools: | |
716 | `yyss': related to states, | |
717 | `yyvs': related to semantic values, | |
718 | `yyls': related to locations. | |
719 | ||
720 | Refer to the stacks thru separate pointers, to allow yyoverflow | |
721 | to reallocate them elsewhere. */ | |
722 | ||
723 | /* The state stack. */ | |
724 | short yyssa[YYINITDEPTH]; | |
725 | short *yyss = yyssa; | |
726 | register short *yyssp; | |
727 | ||
728 | /* The semantic value stack. */ | |
729 | YYSTYPE yyvsa[YYINITDEPTH]; | |
730 | YYSTYPE *yyvs = yyvsa; | |
731 | register YYSTYPE *yyvsp; | |
732 | ||
733 | #if YYLSP_NEEDED | |
734 | /* The location stack. */ | |
735 | YYLTYPE yylsa[YYINITDEPTH]; | |
736 | YYLTYPE *yyls = yylsa; | |
737 | YYLTYPE *yylsp; | |
738 | #endif | |
739 | ||
740 | #if YYLSP_NEEDED | |
741 | # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) | |
742 | #else | |
743 | # define YYPOPSTACK (yyvsp--, yyssp--) | |
744 | #endif | |
745 | ||
746 | YYSIZE_T yystacksize = YYINITDEPTH; | |
747 | ||
748 | ||
749 | /* The variables used to return semantic value and location from the | |
750 | action routines. */ | |
751 | YYSTYPE yyval; | |
752 | #if YYLSP_NEEDED | |
753 | YYLTYPE yyloc; | |
754 | #endif | |
755 | ||
756 | /* When reducing, the number of symbols on the RHS of the reduced | |
757 | rule. */ | |
758 | int yylen; | |
759 | ||
760 | YYDPRINTF ((stderr, "Starting parse\n")); | |
761 | ||
762 | yystate = 0; | |
763 | yyerrstatus = 0; | |
764 | yynerrs = 0; | |
765 | yychar = YYEMPTY; /* Cause a token to be read. */ | |
766 | ||
767 | /* Initialize stack pointers. | |
768 | Waste one element of value and location stack | |
769 | so that they stay on the same level as the state stack. | |
770 | The wasted elements are never initialized. */ | |
771 | ||
772 | yyssp = yyss; | |
773 | yyvsp = yyvs; | |
774 | #if YYLSP_NEEDED | |
775 | yylsp = yyls; | |
776 | #endif | |
777 | goto yysetstate; | |
778 | ||
779 | /*------------------------------------------------------------. | |
780 | | yynewstate -- Push a new state, which is found in yystate. | | |
781 | `------------------------------------------------------------*/ | |
782 | yynewstate: | |
783 | /* In all cases, when you get here, the value and location stacks | |
784 | have just been pushed. so pushing a state here evens the stacks. | |
785 | */ | |
786 | yyssp++; | |
787 | ||
788 | yysetstate: | |
789 | *yyssp = yystate; | |
790 | ||
791 | if (yyssp >= yyss + yystacksize - 1) | |
792 | { | |
793 | /* Get the current used size of the three stacks, in elements. */ | |
794 | YYSIZE_T yysize = yyssp - yyss + 1; | |
795 | ||
796 | #ifdef yyoverflow | |
797 | { | |
798 | /* Give user a chance to reallocate the stack. Use copies of | |
799 | these so that the &'s don't force the real ones into | |
800 | memory. */ | |
801 | YYSTYPE *yyvs1 = yyvs; | |
802 | short *yyss1 = yyss; | |
803 | ||
804 | /* Each stack pointer address is followed by the size of the | |
805 | data in use in that stack, in bytes. */ | |
806 | # if YYLSP_NEEDED | |
807 | YYLTYPE *yyls1 = yyls; | |
808 | /* This used to be a conditional around just the two extra args, | |
809 | but that might be undefined if yyoverflow is a macro. */ | |
810 | yyoverflow ("parser stack overflow", | |
811 | &yyss1, yysize * sizeof (*yyssp), | |
812 | &yyvs1, yysize * sizeof (*yyvsp), | |
813 | &yyls1, yysize * sizeof (*yylsp), | |
814 | &yystacksize); | |
815 | yyls = yyls1; | |
816 | # else | |
817 | yyoverflow ("parser stack overflow", | |
818 | &yyss1, yysize * sizeof (*yyssp), | |
819 | &yyvs1, yysize * sizeof (*yyvsp), | |
820 | &yystacksize); | |
821 | # endif | |
822 | yyss = yyss1; | |
823 | yyvs = yyvs1; | |
824 | } | |
825 | #else /* no yyoverflow */ | |
826 | # ifndef YYSTACK_RELOCATE | |
827 | goto yyoverflowlab; | |
828 | # else | |
829 | /* Extend the stack our own way. */ | |
830 | if (yystacksize >= YYMAXDEPTH) | |
831 | goto yyoverflowlab; | |
832 | yystacksize *= 2; | |
833 | if (yystacksize > YYMAXDEPTH) | |
834 | yystacksize = YYMAXDEPTH; | |
835 | ||
836 | { | |
837 | short *yyss1 = yyss; | |
838 | union yyalloc *yyptr = | |
839 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); | |
840 | if (! yyptr) | |
841 | goto yyoverflowlab; | |
842 | YYSTACK_RELOCATE (yyss); | |
843 | YYSTACK_RELOCATE (yyvs); | |
844 | # if YYLSP_NEEDED | |
845 | YYSTACK_RELOCATE (yyls); | |
846 | # endif | |
847 | # undef YYSTACK_RELOCATE | |
848 | if (yyss1 != yyssa) | |
849 | YYSTACK_FREE (yyss1); | |
850 | } | |
851 | # endif | |
852 | #endif /* no yyoverflow */ | |
853 | ||
854 | yyssp = yyss + yysize - 1; | |
855 | yyvsp = yyvs + yysize - 1; | |
856 | #if YYLSP_NEEDED | |
857 | yylsp = yyls + yysize - 1; | |
858 | #endif | |
859 | ||
860 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", | |
861 | (unsigned long int) yystacksize)); | |
862 | ||
863 | if (yyssp >= yyss + yystacksize - 1) | |
864 | YYABORT; | |
865 | } | |
866 | ||
867 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); | |
868 | ||
869 | goto yybackup; | |
870 | ||
871 | ||
872 | /*-----------. | |
873 | | yybackup. | | |
874 | `-----------*/ | |
875 | yybackup: | |
876 | ||
877 | /* Do appropriate processing given the current state. */ | |
878 | /* Read a lookahead token if we need one and don't already have one. */ | |
879 | /* yyresume: */ | |
880 | ||
881 | /* First try to decide what to do without reference to lookahead token. */ | |
882 | ||
883 | yyn = yypact[yystate]; | |
884 | if (yyn == YYFLAG) | |
885 | goto yydefault; | |
886 | ||
887 | /* Not known => get a lookahead token if don't already have one. */ | |
888 | ||
889 | /* yychar is either YYEMPTY or YYEOF | |
890 | or a valid token in external form. */ | |
891 | ||
892 | if (yychar == YYEMPTY) | |
893 | { | |
894 | YYDPRINTF ((stderr, "Reading a token: ")); | |
895 | yychar = YYLEX; | |
896 | } | |
897 | ||
898 | /* Convert token to internal form (in yychar1) for indexing tables with */ | |
899 | ||
900 | if (yychar <= 0) /* This means end of input. */ | |
901 | { | |
902 | yychar1 = 0; | |
903 | yychar = YYEOF; /* Don't call YYLEX any more */ | |
904 | ||
905 | YYDPRINTF ((stderr, "Now at end of input.\n")); | |
906 | } | |
907 | else | |
908 | { | |
909 | yychar1 = YYTRANSLATE (yychar); | |
910 | ||
911 | #if YYDEBUG | |
912 | /* We have to keep this `#if YYDEBUG', since we use variables | |
913 | which are defined only if `YYDEBUG' is set. */ | |
914 | if (yydebug) | |
915 | { | |
916 | YYFPRINTF (stderr, "Next token is %d (%s", | |
917 | yychar, yytname[yychar1]); | |
918 | /* Give the individual parser a way to print the precise | |
919 | meaning of a token, for further debugging info. */ | |
920 | # ifdef YYPRINT | |
921 | YYPRINT (stderr, yychar, yylval); | |
922 | # endif | |
923 | YYFPRINTF (stderr, ")\n"); | |
924 | } | |
925 | #endif | |
926 | } | |
927 | ||
928 | yyn += yychar1; | |
929 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) | |
930 | goto yydefault; | |
931 | ||
932 | yyn = yytable[yyn]; | |
933 | ||
934 | /* yyn is what to do for this token type in this state. | |
935 | Negative => reduce, -yyn is rule number. | |
936 | Positive => shift, yyn is new state. | |
937 | New state is final state => don't bother to shift, | |
938 | just return success. | |
939 | 0, or most negative number => error. */ | |
940 | ||
941 | if (yyn < 0) | |
942 | { | |
943 | if (yyn == YYFLAG) | |
944 | goto yyerrlab; | |
945 | yyn = -yyn; | |
946 | goto yyreduce; | |
947 | } | |
948 | else if (yyn == 0) | |
949 | goto yyerrlab; | |
950 | ||
951 | if (yyn == YYFINAL) | |
952 | YYACCEPT; | |
953 | ||
954 | /* Shift the lookahead token. */ | |
955 | YYDPRINTF ((stderr, "Shifting token %d (%s), ", | |
956 | yychar, yytname[yychar1])); | |
957 | ||
958 | /* Discard the token being shifted unless it is eof. */ | |
959 | if (yychar != YYEOF) | |
960 | yychar = YYEMPTY; | |
961 | ||
962 | *++yyvsp = yylval; | |
963 | #if YYLSP_NEEDED | |
964 | *++yylsp = yylloc; | |
965 | #endif | |
966 | ||
967 | /* Count tokens shifted since error; after three, turn off error | |
968 | status. */ | |
969 | if (yyerrstatus) | |
970 | yyerrstatus--; | |
971 | ||
972 | yystate = yyn; | |
973 | goto yynewstate; | |
974 | ||
975 | ||
976 | /*-----------------------------------------------------------. | |
977 | | yydefault -- do the default action for the current state. | | |
978 | `-----------------------------------------------------------*/ | |
979 | yydefault: | |
980 | yyn = yydefact[yystate]; | |
981 | if (yyn == 0) | |
982 | goto yyerrlab; | |
983 | goto yyreduce; | |
984 | ||
985 | ||
986 | /*-----------------------------. | |
987 | | yyreduce -- Do a reduction. | | |
988 | `-----------------------------*/ | |
989 | yyreduce: | |
990 | /* yyn is the number of a rule to reduce with. */ | |
991 | yylen = yyr2[yyn]; | |
992 | ||
993 | /* If YYLEN is nonzero, implement the default value of the action: | |
994 | `$$ = $1'. | |
995 | ||
996 | Otherwise, the following line sets YYVAL to the semantic value of | |
997 | the lookahead token. This behavior is undocumented and Bison | |
998 | users should not rely upon it. Assigning to YYVAL | |
999 | unconditionally makes the parser a bit smaller, and it avoids a | |
1000 | GCC warning that YYVAL may be used uninitialized. */ | |
1001 | yyval = yyvsp[1-yylen]; | |
1002 | ||
1003 | #if YYLSP_NEEDED | |
1004 | /* Similarly for the default location. Let the user run additional | |
1005 | commands if for instance locations are ranges. */ | |
1006 | yyloc = yylsp[1-yylen]; | |
1007 | YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); | |
1008 | #endif | |
1009 | ||
1010 | #if YYDEBUG | |
1011 | /* We have to keep this `#if YYDEBUG', since we use variables which | |
1012 | are defined only if `YYDEBUG' is set. */ | |
1013 | if (yydebug) | |
1014 | { | |
1015 | int yyi; | |
1016 | ||
1017 | YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", | |
1018 | yyn, yyrline[yyn]); | |
1019 | ||
1020 | /* Print the symbols being reduced, and their result. */ | |
1021 | for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++) | |
1022 | YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); | |
1023 | YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]); | |
1024 | } | |
1025 | #endif | |
1026 | ||
1027 | switch (yyn) { | |
1028 | ||
1029 | case 1: | |
1030 | #line 175 "plural.y" | |
1031 | { | |
1032 | if (yyvsp[0].exp == NULL) | |
1033 | YYABORT; | |
1034 | ((struct parse_args *) arg)->res = yyvsp[0].exp; | |
1035 | } | |
1036 | break; | |
1037 | case 2: | |
1038 | #line 183 "plural.y" | |
1039 | { | |
1040 | yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp); | |
1041 | } | |
1042 | break; | |
1043 | case 3: | |
1044 | #line 187 "plural.y" | |
1045 | { | |
1046 | yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp); | |
1047 | } | |
1048 | break; | |
1049 | case 4: | |
1050 | #line 191 "plural.y" | |
1051 | { | |
1052 | yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp); | |
1053 | } | |
1054 | break; | |
1055 | case 5: | |
1056 | #line 195 "plural.y" | |
1057 | { | |
1058 | yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp); | |
1059 | } | |
1060 | break; | |
1061 | case 6: | |
1062 | #line 199 "plural.y" | |
1063 | { | |
1064 | yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp); | |
1065 | } | |
1066 | break; | |
1067 | case 7: | |
1068 | #line 203 "plural.y" | |
1069 | { | |
1070 | yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp); | |
1071 | } | |
1072 | break; | |
1073 | case 8: | |
1074 | #line 207 "plural.y" | |
1075 | { | |
1076 | yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp); | |
1077 | } | |
1078 | break; | |
1079 | case 9: | |
1080 | #line 211 "plural.y" | |
1081 | { | |
1082 | yyval.exp = new_exp_1 (lnot, yyvsp[0].exp); | |
1083 | } | |
1084 | break; | |
1085 | case 10: | |
1086 | #line 215 "plural.y" | |
1087 | { | |
1088 | yyval.exp = new_exp_0 (var); | |
1089 | } | |
1090 | break; | |
1091 | case 11: | |
1092 | #line 219 "plural.y" | |
1093 | { | |
1094 | if ((yyval.exp = new_exp_0 (num)) != NULL) | |
1095 | yyval.exp->val.num = yyvsp[0].num; | |
1096 | } | |
1097 | break; | |
1098 | case 12: | |
1099 | #line 224 "plural.y" | |
1100 | { | |
1101 | yyval.exp = yyvsp[-1].exp; | |
1102 | } | |
1103 | break; | |
1104 | } | |
1105 | ||
1106 | #line 705 "/usr/local/share/bison/bison.simple" | |
1107 | ||
1108 | \f | |
1109 | yyvsp -= yylen; | |
1110 | yyssp -= yylen; | |
1111 | #if YYLSP_NEEDED | |
1112 | yylsp -= yylen; | |
1113 | #endif | |
1114 | ||
1115 | #if YYDEBUG | |
1116 | if (yydebug) | |
1117 | { | |
1118 | short *yyssp1 = yyss - 1; | |
1119 | YYFPRINTF (stderr, "state stack now"); | |
1120 | while (yyssp1 != yyssp) | |
1121 | YYFPRINTF (stderr, " %d", *++yyssp1); | |
1122 | YYFPRINTF (stderr, "\n"); | |
1123 | } | |
1124 | #endif | |
1125 | ||
1126 | *++yyvsp = yyval; | |
1127 | #if YYLSP_NEEDED | |
1128 | *++yylsp = yyloc; | |
1129 | #endif | |
1130 | ||
1131 | /* Now `shift' the result of the reduction. Determine what state | |
1132 | that goes to, based on the state we popped back to and the rule | |
1133 | number reduced by. */ | |
1134 | ||
1135 | yyn = yyr1[yyn]; | |
1136 | ||
1137 | yystate = yypgoto[yyn - YYNTBASE] + *yyssp; | |
1138 | if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) | |
1139 | yystate = yytable[yystate]; | |
1140 | else | |
1141 | yystate = yydefgoto[yyn - YYNTBASE]; | |
1142 | ||
1143 | goto yynewstate; | |
1144 | ||
1145 | ||
1146 | /*------------------------------------. | |
1147 | | yyerrlab -- here on detecting error | | |
1148 | `------------------------------------*/ | |
1149 | yyerrlab: | |
1150 | /* If not already recovering from an error, report this error. */ | |
1151 | if (!yyerrstatus) | |
1152 | { | |
1153 | ++yynerrs; | |
1154 | ||
1155 | #ifdef YYERROR_VERBOSE | |
1156 | yyn = yypact[yystate]; | |
1157 | ||
1158 | if (yyn > YYFLAG && yyn < YYLAST) | |
1159 | { | |
1160 | YYSIZE_T yysize = 0; | |
1161 | char *yymsg; | |
1162 | int yyx, yycount; | |
1163 | ||
1164 | yycount = 0; | |
1165 | /* Start YYX at -YYN if negative to avoid negative indexes in | |
1166 | YYCHECK. */ | |
1167 | for (yyx = yyn < 0 ? -yyn : 0; | |
1168 | yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) | |
1169 | if (yycheck[yyx + yyn] == yyx) | |
1170 | yysize += yystrlen (yytname[yyx]) + 15, yycount++; | |
1171 | yysize += yystrlen ("parse error, unexpected ") + 1; | |
1172 | yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); | |
1173 | yymsg = (char *) YYSTACK_ALLOC (yysize); | |
1174 | if (yymsg != 0) | |
1175 | { | |
1176 | char *yyp = yystpcpy (yymsg, "parse error, unexpected "); | |
1177 | yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); | |
1178 | ||
1179 | if (yycount < 5) | |
1180 | { | |
1181 | yycount = 0; | |
1182 | for (yyx = yyn < 0 ? -yyn : 0; | |
1183 | yyx < (int) (sizeof (yytname) / sizeof (char *)); | |
1184 | yyx++) | |
1185 | if (yycheck[yyx + yyn] == yyx) | |
1186 | { | |
1187 | const char *yyq = ! yycount ? ", expecting " : " or "; | |
1188 | yyp = yystpcpy (yyp, yyq); | |
1189 | yyp = yystpcpy (yyp, yytname[yyx]); | |
1190 | yycount++; | |
1191 | } | |
1192 | } | |
1193 | yyerror (yymsg); | |
1194 | YYSTACK_FREE (yymsg); | |
1195 | } | |
1196 | else | |
1197 | yyerror ("parse error; also virtual memory exhausted"); | |
1198 | } | |
1199 | else | |
1200 | #endif /* defined (YYERROR_VERBOSE) */ | |
1201 | yyerror ("parse error"); | |
1202 | } | |
1203 | goto yyerrlab1; | |
1204 | ||
1205 | ||
1206 | /*--------------------------------------------------. | |
1207 | | yyerrlab1 -- error raised explicitly by an action | | |
1208 | `--------------------------------------------------*/ | |
1209 | yyerrlab1: | |
1210 | if (yyerrstatus == 3) | |
1211 | { | |
1212 | /* If just tried and failed to reuse lookahead token after an | |
1213 | error, discard it. */ | |
1214 | ||
1215 | /* return failure if at end of input */ | |
1216 | if (yychar == YYEOF) | |
1217 | YYABORT; | |
1218 | YYDPRINTF ((stderr, "Discarding token %d (%s).\n", | |
1219 | yychar, yytname[yychar1])); | |
1220 | yychar = YYEMPTY; | |
1221 | } | |
1222 | ||
1223 | /* Else will try to reuse lookahead token after shifting the error | |
1224 | token. */ | |
1225 | ||
1226 | yyerrstatus = 3; /* Each real token shifted decrements this */ | |
1227 | ||
1228 | goto yyerrhandle; | |
1229 | ||
1230 | ||
1231 | /*-------------------------------------------------------------------. | |
1232 | | yyerrdefault -- current state does not do anything special for the | | |
1233 | | error token. | | |
1234 | `-------------------------------------------------------------------*/ | |
1235 | yyerrdefault: | |
1236 | #if 0 | |
1237 | /* This is wrong; only states that explicitly want error tokens | |
1238 | should shift them. */ | |
1239 | ||
1240 | /* If its default is to accept any token, ok. Otherwise pop it. */ | |
1241 | yyn = yydefact[yystate]; | |
1242 | if (yyn) | |
1243 | goto yydefault; | |
1244 | #endif | |
1245 | ||
1246 | ||
1247 | /*---------------------------------------------------------------. | |
1248 | | yyerrpop -- pop the current state because it cannot handle the | | |
1249 | | error token | | |
1250 | `---------------------------------------------------------------*/ | |
1251 | yyerrpop: | |
1252 | if (yyssp == yyss) | |
1253 | YYABORT; | |
1254 | yyvsp--; | |
1255 | yystate = *--yyssp; | |
1256 | #if YYLSP_NEEDED | |
1257 | yylsp--; | |
1258 | #endif | |
1259 | ||
1260 | #if YYDEBUG | |
1261 | if (yydebug) | |
1262 | { | |
1263 | short *yyssp1 = yyss - 1; | |
1264 | YYFPRINTF (stderr, "Error: state stack now"); | |
1265 | while (yyssp1 != yyssp) | |
1266 | YYFPRINTF (stderr, " %d", *++yyssp1); | |
1267 | YYFPRINTF (stderr, "\n"); | |
1268 | } | |
1269 | #endif | |
1270 | ||
1271 | /*--------------. | |
1272 | | yyerrhandle. | | |
1273 | `--------------*/ | |
1274 | yyerrhandle: | |
1275 | yyn = yypact[yystate]; | |
1276 | if (yyn == YYFLAG) | |
1277 | goto yyerrdefault; | |
1278 | ||
1279 | yyn += YYTERROR; | |
1280 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) | |
1281 | goto yyerrdefault; | |
1282 | ||
1283 | yyn = yytable[yyn]; | |
1284 | if (yyn < 0) | |
1285 | { | |
1286 | if (yyn == YYFLAG) | |
1287 | goto yyerrpop; | |
1288 | yyn = -yyn; | |
1289 | goto yyreduce; | |
1290 | } | |
1291 | else if (yyn == 0) | |
1292 | goto yyerrpop; | |
1293 | ||
1294 | if (yyn == YYFINAL) | |
1295 | YYACCEPT; | |
1296 | ||
1297 | YYDPRINTF ((stderr, "Shifting error token, ")); | |
1298 | ||
1299 | *++yyvsp = yylval; | |
1300 | #if YYLSP_NEEDED | |
1301 | *++yylsp = yylloc; | |
1302 | #endif | |
1303 | ||
1304 | yystate = yyn; | |
1305 | goto yynewstate; | |
1306 | ||
1307 | ||
1308 | /*-------------------------------------. | |
1309 | | yyacceptlab -- YYACCEPT comes here. | | |
1310 | `-------------------------------------*/ | |
1311 | yyacceptlab: | |
1312 | yyresult = 0; | |
1313 | goto yyreturn; | |
1314 | ||
1315 | /*-----------------------------------. | |
1316 | | yyabortlab -- YYABORT comes here. | | |
1317 | `-----------------------------------*/ | |
1318 | yyabortlab: | |
1319 | yyresult = 1; | |
1320 | goto yyreturn; | |
1321 | ||
1322 | /*---------------------------------------------. | |
1323 | | yyoverflowab -- parser overflow comes here. | | |
1324 | `---------------------------------------------*/ | |
1325 | yyoverflowlab: | |
1326 | yyerror ("parser stack overflow"); | |
1327 | yyresult = 2; | |
1328 | /* Fall through. */ | |
1329 | ||
1330 | yyreturn: | |
1331 | #ifndef yyoverflow | |
1332 | if (yyss != yyssa) | |
1333 | YYSTACK_FREE (yyss); | |
1334 | #endif | |
1335 | return yyresult; | |
1336 | } | |
1337 | #line 229 "plural.y" | |
1338 | ||
1339 | ||
1340 | void | |
1341 | internal_function | |
1342 | FREE_EXPRESSION (exp) | |
1343 | struct expression *exp; | |
1344 | { | |
1345 | if (exp == NULL) | |
1346 | return; | |
1347 | ||
1348 | /* Handle the recursive case. */ | |
1349 | switch (exp->nargs) | |
1350 | { | |
1351 | case 3: | |
1352 | FREE_EXPRESSION (exp->val.args[2]); | |
1353 | /* FALLTHROUGH */ | |
1354 | case 2: | |
1355 | FREE_EXPRESSION (exp->val.args[1]); | |
1356 | /* FALLTHROUGH */ | |
1357 | case 1: | |
1358 | FREE_EXPRESSION (exp->val.args[0]); | |
1359 | /* FALLTHROUGH */ | |
1360 | default: | |
1361 | break; | |
1362 | } | |
1363 | ||
1364 | free (exp); | |
1365 | } | |
1366 | ||
1367 | ||
1368 | static int | |
1369 | yylex (lval, pexp) | |
1370 | YYSTYPE *lval; | |
1371 | const char **pexp; | |
1372 | { | |
1373 | const char *exp = *pexp; | |
1374 | int result; | |
1375 | ||
1376 | while (1) | |
1377 | { | |
1378 | if (exp[0] == '\0') | |
1379 | { | |
1380 | *pexp = exp; | |
1381 | return YYEOF; | |
1382 | } | |
1383 | ||
1384 | if (exp[0] != ' ' && exp[0] != '\t') | |
1385 | break; | |
1386 | ||
1387 | ++exp; | |
1388 | } | |
1389 | ||
1390 | result = *exp++; | |
1391 | switch (result) | |
1392 | { | |
1393 | case '0': case '1': case '2': case '3': case '4': | |
1394 | case '5': case '6': case '7': case '8': case '9': | |
1395 | { | |
1396 | unsigned long int n = result - '0'; | |
1397 | while (exp[0] >= '0' && exp[0] <= '9') | |
1398 | { | |
1399 | n *= 10; | |
1400 | n += exp[0] - '0'; | |
1401 | ++exp; | |
1402 | } | |
1403 | lval->num = n; | |
1404 | result = NUMBER; | |
1405 | } | |
1406 | break; | |
1407 | ||
1408 | case '=': | |
1409 | if (exp[0] == '=') | |
1410 | { | |
1411 | ++exp; | |
1412 | lval->op = equal; | |
1413 | result = EQUOP2; | |
1414 | } | |
1415 | else | |
1416 | result = YYERRCODE; | |
1417 | break; | |
1418 | ||
1419 | case '!': | |
1420 | if (exp[0] == '=') | |
1421 | { | |
1422 | ++exp; | |
1423 | lval->op = not_equal; | |
1424 | result = EQUOP2; | |
1425 | } | |
1426 | break; | |
1427 | ||
1428 | case '&': | |
1429 | case '|': | |
1430 | if (exp[0] == result) | |
1431 | ++exp; | |
1432 | else | |
1433 | result = YYERRCODE; | |
1434 | break; | |
1435 | ||
1436 | case '<': | |
1437 | if (exp[0] == '=') | |
1438 | { | |
1439 | ++exp; | |
1440 | lval->op = less_or_equal; | |
1441 | } | |
1442 | else | |
1443 | lval->op = less_than; | |
1444 | result = CMPOP2; | |
1445 | break; | |
1446 | ||
1447 | case '>': | |
1448 | if (exp[0] == '=') | |
1449 | { | |
1450 | ++exp; | |
1451 | lval->op = greater_or_equal; | |
1452 | } | |
1453 | else | |
1454 | lval->op = greater_than; | |
1455 | result = CMPOP2; | |
1456 | break; | |
1457 | ||
1458 | case '*': | |
1459 | lval->op = mult; | |
1460 | result = MULOP2; | |
1461 | break; | |
1462 | ||
1463 | case '/': | |
1464 | lval->op = divide; | |
1465 | result = MULOP2; | |
1466 | break; | |
1467 | ||
1468 | case '%': | |
1469 | lval->op = module; | |
1470 | result = MULOP2; | |
1471 | break; | |
1472 | ||
1473 | case '+': | |
1474 | lval->op = plus; | |
1475 | result = ADDOP2; | |
1476 | break; | |
1477 | ||
1478 | case '-': | |
1479 | lval->op = minus; | |
1480 | result = ADDOP2; | |
1481 | break; | |
1482 | ||
1483 | case 'n': | |
1484 | case '?': | |
1485 | case ':': | |
1486 | case '(': | |
1487 | case ')': | |
1488 | /* Nothing, just return the character. */ | |
1489 | break; | |
1490 | ||
1491 | case ';': | |
1492 | case '\n': | |
1493 | case '\0': | |
1494 | /* Be safe and let the user call this function again. */ | |
1495 | --exp; | |
1496 | result = YYEOF; | |
1497 | break; | |
1498 | ||
1499 | default: | |
1500 | result = YYERRCODE; | |
1501 | #if YYDEBUG != 0 | |
1502 | --exp; | |
1503 | #endif | |
1504 | break; | |
1505 | } | |
1506 | ||
1507 | *pexp = exp; | |
1508 | ||
1509 | return result; | |
1510 | } | |
1511 | ||
1512 | ||
1513 | static void | |
1514 | yyerror (str) | |
1515 | const char *str; | |
1516 | { | |
1517 | /* Do nothing. We don't print error messages here. */ | |
1518 | } |