"Fossies" - the Fresh Open Source Software Archive 
Member "tin-2.6.2/intl/plural.c" (28 Jan 2022, 54967 Bytes) of package /linux/misc/tin-2.6.2.tar.xz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
See also the latest
Fossies "Diffs" side-by-side code changes report for "plural.c":
2.6.1_vs_2.6.2.
1 /* original parser id follows */
2 /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
3 /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
4
5 #define YYBYACC 1
6 #define YYMAJOR 2
7 #define YYMINOR 0
8 #define YYPATCH 20220114
9
10 #define YYEMPTY (-1)
11 #define yyclearin (yychar = YYEMPTY)
12 #define yyerrok (yyerrflag = 0)
13 #define YYRECOVERING() (yyerrflag != 0)
14 #define YYENOMEM (-2)
15 #define YYEOF 0
16 #undef YYBTYACC
17 #define YYBTYACC 0
18 #define YYDEBUGSTR YYPREFIX "debug"
19
20 #ifndef yyparse
21 #define yyparse __gettextparse
22 #endif /* yyparse */
23
24 #ifndef yylex
25 #define yylex __gettextlex
26 #endif /* yylex */
27
28 #ifndef yyerror
29 #define yyerror __gettexterror
30 #endif /* yyerror */
31
32 #ifndef yychar
33 #define yychar __gettextchar
34 #endif /* yychar */
35
36 #ifndef yyval
37 #define yyval __gettextval
38 #endif /* yyval */
39
40 #ifndef yylval
41 #define yylval __gettextlval
42 #endif /* yylval */
43
44 #ifndef yydebug
45 #define yydebug __gettextdebug
46 #endif /* yydebug */
47
48 #ifndef yynerrs
49 #define yynerrs __gettextnerrs
50 #endif /* yynerrs */
51
52 #ifndef yyerrflag
53 #define yyerrflag __gettexterrflag
54 #endif /* yyerrflag */
55
56 #ifndef yylhs
57 #define yylhs __gettextlhs
58 #endif /* yylhs */
59
60 #ifndef yylen
61 #define yylen __gettextlen
62 #endif /* yylen */
63
64 #ifndef yydefred
65 #define yydefred __gettextdefred
66 #endif /* yydefred */
67
68 #ifndef yystos
69 #define yystos __gettextstos
70 #endif /* yystos */
71
72 #ifndef yydgoto
73 #define yydgoto __gettextdgoto
74 #endif /* yydgoto */
75
76 #ifndef yysindex
77 #define yysindex __gettextsindex
78 #endif /* yysindex */
79
80 #ifndef yyrindex
81 #define yyrindex __gettextrindex
82 #endif /* yyrindex */
83
84 #ifndef yygindex
85 #define yygindex __gettextgindex
86 #endif /* yygindex */
87
88 #ifndef yytable
89 #define yytable __gettexttable
90 #endif /* yytable */
91
92 #ifndef yycheck
93 #define yycheck __gettextcheck
94 #endif /* yycheck */
95
96 #ifndef yyname
97 #define yyname __gettextname
98 #endif /* yyname */
99
100 #ifndef yyrule
101 #define yyrule __gettextrule
102 #endif /* yyrule */
103
104 #if YYBTYACC
105
106 #ifndef yycindex
107 #define yycindex __gettextcindex
108 #endif /* yycindex */
109
110 #ifndef yyctable
111 #define yyctable __gettextctable
112 #endif /* yyctable */
113
114 #endif /* YYBTYACC */
115
116 #define YYPREFIX "__gettext"
117
118 #define YYPURE 1
119
120 #line 2 "plural.y"
121 /* Expression parsing for plural form selection.
122 Copyright (C) 2000, 2001 Free Software Foundation, Inc.
123 Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
124
125 This program is free software; you can redistribute it and/or modify it
126 under the terms of the GNU Library General Public License as published
127 by the Free Software Foundation; either version 2, or (at your option)
128 any later version.
129
130 This program is distributed in the hope that it will be useful,
131 but WITHOUT ANY WARRANTY; without even the implied warranty of
132 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
133 Library General Public License for more details.
134
135 You should have received a copy of the GNU Library General Public
136 License along with this program; if not, write to the Free Software
137 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
138 USA. */
139
140 /* The bison generated parser uses alloca. AIX 3 forces us to put this
141 declaration at the beginning of the file. The declaration in bison's
142 skeleton file comes too late. This must come before <autoconf.h>
143 because <autoconf.h> may include arbitrary system headers. */
144 #if defined _AIX && !defined __GNUC__
145 #pragma alloca
146 #endif
147
148 #ifdef HAVE_CONFIG_H
149 # include <autoconf.h>
150 #endif
151
152 #include <stdlib.h>
153 #include "gettextP.h"
154
155 /* Names for the libintl functions are a problem. They must not clash
156 with existing names and they should follow ANSI C. But this source
157 code is also used in GNU C Library where the names have a __
158 prefix. So we have to make a difference here. */
159 #ifdef _LIBC
160 # define FREE_EXPRESSION __gettext_free_exp
161 #else
162 # define FREE_EXPRESSION gettext_free_exp__
163 # define __gettextparse gettextparse__
164 #endif
165
166 #define YYLEX_PARAM &((struct parse_args *) arg)->cp
167 #define YYPARSE_PARAM arg
168 #ifdef YYSTYPE
169 #undef YYSTYPE_IS_DECLARED
170 #define YYSTYPE_IS_DECLARED 1
171 #endif
172 #ifndef YYSTYPE_IS_DECLARED
173 #define YYSTYPE_IS_DECLARED 1
174 #line 53 "plural.y"
175 typedef union YYSTYPE {
176 unsigned long int num;
177 enum operator op;
178 struct expression *exp;
179 } YYSTYPE;
180 #endif /* !YYSTYPE_IS_DECLARED */
181 #line 60 "plural.y"
182 /* Prototypes for local functions. */
183 static struct expression *new_exp PARAMS ((int nargs, enum operator op,
184 struct expression * const *args));
185 static inline struct expression *new_exp_0 PARAMS ((enum operator op));
186 static inline struct expression *new_exp_1 PARAMS ((enum operator op,
187 struct expression *right));
188 static struct expression *new_exp_2 PARAMS ((enum operator op,
189 struct expression *left,
190 struct expression *right));
191 static inline struct expression *new_exp_3 PARAMS ((enum operator op,
192 struct expression *bexp,
193 struct expression *tbranch,
194 struct expression *fbranch));
195 static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
196 static void yyerror PARAMS ((const char *str));
197
198 /* Allocation of expressions. */
199
200 static struct expression *
201 new_exp (nargs, op, args)
202 int nargs;
203 enum operator op;
204 struct expression * const *args;
205 {
206 int i;
207 struct expression *newp;
208
209 /* If any of the argument could not be malloc'ed, just return NULL. */
210 for (i = nargs - 1; i >= 0; i--)
211 if (args[i] == NULL)
212 goto fail;
213
214 /* Allocate a new expression. */
215 newp = (struct expression *) malloc (sizeof (*newp));
216 if (newp != NULL)
217 {
218 newp->nargs = nargs;
219 newp->operation = op;
220 for (i = nargs - 1; i >= 0; i--)
221 newp->val.args[i] = args[i];
222 return newp;
223 }
224
225 fail:
226 for (i = nargs - 1; i >= 0; i--)
227 FREE_EXPRESSION (args[i]);
228
229 return NULL;
230 }
231
232 static inline struct expression *
233 new_exp_0 (op)
234 enum operator op;
235 {
236 return new_exp (0, op, NULL);
237 }
238
239 static inline struct expression *
240 new_exp_1 (op, right)
241 enum operator op;
242 struct expression *right;
243 {
244 struct expression *args[1];
245
246 args[0] = right;
247 return new_exp (1, op, args);
248 }
249
250 static struct expression *
251 new_exp_2 (op, left, right)
252 enum operator op;
253 struct expression *left;
254 struct expression *right;
255 {
256 struct expression *args[2];
257
258 args[0] = left;
259 args[1] = right;
260 return new_exp (2, op, args);
261 }
262
263 static inline struct expression *
264 new_exp_3 (op, bexp, tbranch, fbranch)
265 enum operator op;
266 struct expression *bexp;
267 struct expression *tbranch;
268 struct expression *fbranch;
269 {
270 struct expression *args[3];
271
272 args[0] = bexp;
273 args[1] = tbranch;
274 args[2] = fbranch;
275 return new_exp (3, op, args);
276 }
277
278 #line 279 "plural.c"
279
280 /* compatibility with bison */
281 #ifdef YYPARSE_PARAM
282 /* compatibility with FreeBSD */
283 # ifdef YYPARSE_PARAM_TYPE
284 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
285 # else
286 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
287 # endif
288 #else
289 # define YYPARSE_DECL() yyparse(void)
290 #endif
291
292 /* Parameters sent to lex. */
293 #ifdef YYLEX_PARAM
294 # ifdef YYLEX_PARAM_TYPE
295 # define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLEX_PARAM_TYPE YYLEX_PARAM)
296 # else
297 # define YYLEX_DECL() yylex(YYSTYPE *yylval, void * YYLEX_PARAM)
298 # endif
299 # define YYLEX yylex(&yylval, YYLEX_PARAM)
300 #else
301 # define YYLEX_DECL() yylex(YYSTYPE *yylval)
302 # define YYLEX yylex(&yylval)
303 #endif
304
305 /* Parameters sent to yyerror. */
306 #ifndef YYERROR_DECL
307 #define YYERROR_DECL() yyerror(const char *s)
308 #endif
309 #ifndef YYERROR_CALL
310 #define YYERROR_CALL(msg) yyerror(msg)
311 #endif
312
313 extern int YYPARSE_DECL();
314
315 #define EQUOP2 257
316 #define CMPOP2 258
317 #define ADDOP2 259
318 #define MULOP2 260
319 #define NUMBER 261
320 #define YYERRCODE 256
321 typedef int YYINT;
322 static const YYINT __gettextlhs[] = { -1,
323 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
324 1, 1,
325 };
326 static const YYINT __gettextlen[] = { 2,
327 1, 5, 3, 3, 3, 3, 3, 3, 2, 1,
328 1, 3,
329 };
330 static const YYINT __gettextdefred[] = { 0,
331 0, 11, 10, 0, 0, 0, 9, 0, 0, 0,
332 0, 0, 0, 0, 0, 12, 0, 0, 0, 0,
333 0, 0, 8, 0, 0,
334 };
335 #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
336 static const YYINT __gettextstos[] = { 0,
337 33, 261, 110, 40, 263, 264, 264, 264, 63, 124,
338 38, 257, 258, 259, 260, 41, 264, 264, 264, 264,
339 264, 264, 264, 58, 264,
340 };
341 #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
342 static const YYINT __gettextdgoto[] = { 5,
343 6,
344 };
345 static const YYINT __gettextsindex[] = { -31,
346 -31, 0, 0, -31, 0, -26, 0, -38, -31, -31,
347 -31, -31, -31, -31, -31, 0, -34, -22, -240, -237,
348 -233, -254, 0, -31, -26,
349 };
350 static const YYINT __gettextrindex[] = { 0,
351 0, 0, 0, 0, 0, 8, 0, 0, 0, 0,
352 0, 0, 0, 0, 0, 0, 0, 13, 11, 7,
353 5, 1, 0, 0, 14,
354 };
355 #if YYBTYACC
356 static const YYINT __gettextcindex[] = { 0,
357 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
358 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
359 0, 0, 0, 0, 0,
360 };
361 #endif
362 static const YYINT __gettextgindex[] = { 0,
363 90,
364 };
365 #define YYTABLESIZE 264
366 static const YYINT __gettexttable[] = { 11,
367 7, 1, 16, 11, 6, 15, 5, 1, 4, 0,
368 4, 11, 3, 2, 0, 11, 12, 13, 14, 15,
369 13, 14, 15, 24, 9, 14, 15, 0, 9, 0,
370 0, 0, 0, 0, 0, 0, 9, 0, 7, 0,
371 0, 7, 6, 0, 5, 6, 0, 5, 4, 0,
372 0, 4, 0, 3, 2, 0, 0, 0, 7, 0,
373 0, 0, 6, 7, 5, 0, 0, 6, 4, 5,
374 3, 2, 0, 4, 0, 3, 0, 0, 3, 0,
375 0, 0, 0, 0, 0, 10, 0, 0, 0, 10,
376 7, 0, 0, 8, 0, 0, 0, 10, 17, 18,
377 19, 20, 21, 22, 23, 0, 0, 0, 0, 0,
378 0, 0, 0, 25, 0, 0, 0, 0, 0, 0,
379 0, 0, 0, 0, 7, 0, 0, 0, 6, 0,
380 5, 0, 0, 0, 4, 0, 3, 0, 0, 0,
381 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
382 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
383 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
384 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
385 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
386 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
387 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
388 0, 0, 0, 0, 0, 0, 0, 0, 12, 13,
389 14, 15, 12, 13, 14, 15, 0, 0, 0, 2,
390 12, 13, 14, 15, 12, 13, 14, 15, 0, 0,
391 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
392 0, 0, 0, 0, 0, 0, 0, 7, 7, 7,
393 0, 6, 6, 5,
394 };
395 static const YYINT __gettextcheck[] = { 38,
396 0, 33, 41, 38, 0, 260, 0, 0, 40, -1,
397 0, 38, 0, 0, -1, 38, 257, 258, 259, 260,
398 258, 259, 260, 58, 63, 259, 260, -1, 63, -1,
399 -1, -1, -1, -1, -1, -1, 63, -1, 38, -1,
400 -1, 41, 38, -1, 38, 41, -1, 41, 38, -1,
401 -1, 41, -1, 41, 41, -1, -1, -1, 58, -1,
402 -1, -1, 58, 63, 58, -1, -1, 63, 58, 63,
403 58, 58, -1, 63, -1, 63, -1, -1, 110, -1,
404 -1, -1, -1, -1, -1, 124, -1, -1, -1, 124,
405 1, -1, -1, 4, -1, -1, -1, 124, 9, 10,
406 11, 12, 13, 14, 15, -1, -1, -1, -1, -1,
407 -1, -1, -1, 24, -1, -1, -1, -1, -1, -1,
408 -1, -1, -1, -1, 124, -1, -1, -1, 124, -1,
409 124, -1, -1, -1, 124, -1, 124, -1, -1, -1,
410 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
411 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
412 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
413 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
414 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
415 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
416 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
417 -1, -1, -1, -1, -1, -1, -1, -1, 257, 258,
418 259, 260, 257, 258, 259, 260, -1, -1, -1, 261,
419 257, 258, 259, 260, 257, 258, 259, 260, -1, -1,
420 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
421 -1, -1, -1, -1, -1, -1, -1, 257, 258, 259,
422 -1, 257, 258, 257,
423 };
424 #if YYBTYACC
425 static const YYINT __gettextctable[] = { -1,
426 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
427 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
428 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
429 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
430 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
431 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
432 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
433 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
434 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
435 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
436 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
437 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
438 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
439 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
440 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
441 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
442 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
443 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
444 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
445 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
446 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
447 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
448 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
449 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
450 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
451 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
452 -1, -1, -1,
453 };
454 #endif
455 #define YYFINAL 5
456 #ifndef YYDEBUG
457 #define YYDEBUG 0
458 #endif
459 #define YYMAXTOKEN 261
460 #define YYUNDFTOKEN 265
461 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
462 #if YYDEBUG
463 static const char *const __gettextname[] = {
464
465 "$end",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'!'",0,
466 0,0,0,"'&'",0,"'('","')'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"':'",0,0,0,0,"'?'",0,
467 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
468 0,0,0,0,0,"'n'",0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
469 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
470 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
471 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error",
472 "EQUOP2","CMPOP2","ADDOP2","MULOP2","NUMBER","$accept","start","exp",
473 "illegal-symbol",
474 };
475 static const char *const __gettextrule[] = {
476 "$accept : start",
477 "start : exp",
478 "exp : exp '?' exp ':' exp",
479 "exp : exp '|' exp",
480 "exp : exp '&' exp",
481 "exp : exp EQUOP2 exp",
482 "exp : exp CMPOP2 exp",
483 "exp : exp ADDOP2 exp",
484 "exp : exp MULOP2 exp",
485 "exp : '!' exp",
486 "exp : 'n'",
487 "exp : NUMBER",
488 "exp : '(' exp ')'",
489
490 };
491 #endif
492
493 #if YYDEBUG
494 int yydebug;
495 #endif
496
497 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
498 #ifndef YYLLOC_DEFAULT
499 #define YYLLOC_DEFAULT(loc, rhs, n) \
500 do \
501 { \
502 if (n == 0) \
503 { \
504 (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
505 (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
506 (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
507 (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
508 } \
509 else \
510 { \
511 (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
512 (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
513 (loc).last_line = YYRHSLOC(rhs, n).last_line; \
514 (loc).last_column = YYRHSLOC(rhs, n).last_column; \
515 } \
516 } while (0)
517 #endif /* YYLLOC_DEFAULT */
518 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
519 #if YYBTYACC
520
521 #ifndef YYLVQUEUEGROWTH
522 #define YYLVQUEUEGROWTH 32
523 #endif
524 #endif /* YYBTYACC */
525
526 /* define the initial stack-sizes */
527 #ifdef YYSTACKSIZE
528 #undef YYMAXDEPTH
529 #define YYMAXDEPTH YYSTACKSIZE
530 #else
531 #ifdef YYMAXDEPTH
532 #define YYSTACKSIZE YYMAXDEPTH
533 #else
534 #define YYSTACKSIZE 10000
535 #define YYMAXDEPTH 10000
536 #endif
537 #endif
538
539 #ifndef YYINITSTACKSIZE
540 #define YYINITSTACKSIZE 200
541 #endif
542
543 typedef struct {
544 unsigned stacksize;
545 YYINT *s_base;
546 YYINT *s_mark;
547 YYINT *s_last;
548 YYSTYPE *l_base;
549 YYSTYPE *l_mark;
550 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
551 YYLTYPE *p_base;
552 YYLTYPE *p_mark;
553 #endif
554 } YYSTACKDATA;
555 #if YYBTYACC
556
557 struct YYParseState_s
558 {
559 struct YYParseState_s *save; /* Previously saved parser state */
560 YYSTACKDATA yystack; /* saved parser stack */
561 int state; /* saved parser state */
562 int errflag; /* saved error recovery status */
563 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
564 YYINT ctry; /* saved index in yyctable[] for this conflict */
565 };
566 typedef struct YYParseState_s YYParseState;
567 #endif /* YYBTYACC */
568 #line 234 "plural.y"
569
570 void
571 internal_function
572 FREE_EXPRESSION (exp)
573 struct expression *exp;
574 {
575 if (exp == NULL)
576 return;
577
578 /* Handle the recursive case. */
579 switch (exp->nargs)
580 {
581 case 3:
582 FREE_EXPRESSION (exp->val.args[2]);
583 /* FALLTHROUGH */
584 case 2:
585 FREE_EXPRESSION (exp->val.args[1]);
586 /* FALLTHROUGH */
587 case 1:
588 FREE_EXPRESSION (exp->val.args[0]);
589 /* FALLTHROUGH */
590 default:
591 break;
592 }
593
594 free (exp);
595 }
596
597
598 static int
599 yylex (lval, pexp)
600 YYSTYPE *lval;
601 const char **pexp;
602 {
603 const char *exp = *pexp;
604 int result;
605
606 while (1)
607 {
608 if (exp[0] == '\0')
609 {
610 *pexp = exp;
611 return YYEOF;
612 }
613
614 if (exp[0] != ' ' && exp[0] != '\t')
615 break;
616
617 ++exp;
618 }
619
620 result = *exp++;
621 switch (result)
622 {
623 case '0': case '1': case '2': case '3': case '4':
624 case '5': case '6': case '7': case '8': case '9':
625 {
626 unsigned long int n = result - '0';
627 while (exp[0] >= '0' && exp[0] <= '9')
628 {
629 n *= 10;
630 n += exp[0] - '0';
631 ++exp;
632 }
633 lval->num = n;
634 result = NUMBER;
635 }
636 break;
637
638 case '=':
639 if (exp[0] == '=')
640 {
641 ++exp;
642 lval->op = equal;
643 result = EQUOP2;
644 }
645 else
646 result = YYERRCODE;
647 break;
648
649 case '!':
650 if (exp[0] == '=')
651 {
652 ++exp;
653 lval->op = not_equal;
654 result = EQUOP2;
655 }
656 break;
657
658 case '&':
659 case '|':
660 if (exp[0] == result)
661 ++exp;
662 else
663 result = YYERRCODE;
664 break;
665
666 case '<':
667 if (exp[0] == '=')
668 {
669 ++exp;
670 lval->op = less_or_equal;
671 }
672 else
673 lval->op = less_than;
674 result = CMPOP2;
675 break;
676
677 case '>':
678 if (exp[0] == '=')
679 {
680 ++exp;
681 lval->op = greater_or_equal;
682 }
683 else
684 lval->op = greater_than;
685 result = CMPOP2;
686 break;
687
688 case '*':
689 lval->op = mult;
690 result = MULOP2;
691 break;
692
693 case '/':
694 lval->op = divide;
695 result = MULOP2;
696 break;
697
698 case '%':
699 lval->op = module;
700 result = MULOP2;
701 break;
702
703 case '+':
704 lval->op = plus;
705 result = ADDOP2;
706 break;
707
708 case '-':
709 lval->op = minus;
710 result = ADDOP2;
711 break;
712
713 case 'n':
714 case '?':
715 case ':':
716 case '(':
717 case ')':
718 /* Nothing, just return the character. */
719 break;
720
721 case ';':
722 case '\n':
723 case '\0':
724 /* Be safe and let the user call this function again. */
725 --exp;
726 result = YYEOF;
727 break;
728
729 default:
730 result = YYERRCODE;
731 #if YYDEBUG != 0
732 --exp;
733 #endif
734 break;
735 }
736
737 *pexp = exp;
738
739 return result;
740 }
741
742
743 static void
744 yyerror (str)
745 const char *str;
746 {
747 /* Do nothing. We don't print error messages here. */
748 }
749 #line 750 "plural.c"
750
751 /* For use in generated program */
752 #define yydepth (int)(yystack.s_mark - yystack.s_base)
753 #if YYBTYACC
754 #define yytrial (yyps->save)
755 #endif /* YYBTYACC */
756
757 #if YYDEBUG
758 #include <stdio.h> /* needed for printf */
759 #endif
760
761 #include <stdlib.h> /* needed for malloc, etc */
762 #include <string.h> /* needed for memset */
763
764 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
765 static int yygrowstack(YYSTACKDATA *data)
766 {
767 int i;
768 unsigned newsize;
769 YYINT *newss;
770 YYSTYPE *newvs;
771 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
772 YYLTYPE *newps;
773 #endif
774
775 if ((newsize = data->stacksize) == 0)
776 newsize = YYINITSTACKSIZE;
777 else if (newsize >= YYMAXDEPTH)
778 return YYENOMEM;
779 else if ((newsize *= 2) > YYMAXDEPTH)
780 newsize = YYMAXDEPTH;
781
782 i = (int) (data->s_mark - data->s_base);
783 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
784 if (newss == 0)
785 return YYENOMEM;
786
787 data->s_base = newss;
788 data->s_mark = newss + i;
789
790 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
791 if (newvs == 0)
792 return YYENOMEM;
793
794 data->l_base = newvs;
795 data->l_mark = newvs + i;
796
797 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
798 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
799 if (newps == 0)
800 return YYENOMEM;
801
802 data->p_base = newps;
803 data->p_mark = newps + i;
804 #endif
805
806 data->stacksize = newsize;
807 data->s_last = data->s_base + newsize - 1;
808
809 #if YYDEBUG
810 if (yydebug)
811 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
812 #endif
813 return 0;
814 }
815
816 #if YYPURE || defined(YY_NO_LEAKS)
817 static void yyfreestack(YYSTACKDATA *data)
818 {
819 free(data->s_base);
820 free(data->l_base);
821 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
822 free(data->p_base);
823 #endif
824 memset(data, 0, sizeof(*data));
825 }
826 #else
827 #define yyfreestack(data) /* nothing */
828 #endif /* YYPURE || defined(YY_NO_LEAKS) */
829 #if YYBTYACC
830
831 static YYParseState *
832 yyNewState(unsigned size)
833 {
834 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
835 if (p == NULL) return NULL;
836
837 p->yystack.stacksize = size;
838 if (size == 0)
839 {
840 p->yystack.s_base = NULL;
841 p->yystack.l_base = NULL;
842 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
843 p->yystack.p_base = NULL;
844 #endif
845 return p;
846 }
847 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
848 if (p->yystack.s_base == NULL) return NULL;
849 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
850 if (p->yystack.l_base == NULL) return NULL;
851 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
852 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
853 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
854 if (p->yystack.p_base == NULL) return NULL;
855 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
856 #endif
857
858 return p;
859 }
860
861 static void
862 yyFreeState(YYParseState *p)
863 {
864 yyfreestack(&p->yystack);
865 free(p);
866 }
867 #endif /* YYBTYACC */
868
869 #define YYABORT goto yyabort
870 #define YYREJECT goto yyabort
871 #define YYACCEPT goto yyaccept
872 #define YYERROR goto yyerrlab
873 #if YYBTYACC
874 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
875 #define YYVALID_NESTED do { if (yyps->save && \
876 yyps->save->save == 0) goto yyvalid; } while(0)
877 #endif /* YYBTYACC */
878
879 int
880 YYPARSE_DECL()
881 {
882 int yyerrflag;
883 int yychar;
884 YYSTYPE yyval;
885 YYSTYPE yylval;
886 int yynerrs;
887
888 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
889 YYLTYPE yyloc; /* position returned by actions */
890 YYLTYPE yylloc; /* position from the lexer */
891 #endif
892
893 /* variables for the parser stack */
894 YYSTACKDATA yystack;
895 #if YYBTYACC
896
897 /* Current parser state */
898 static YYParseState *yyps = 0;
899
900 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
901 static YYParseState *yypath = 0;
902
903 /* Base of the lexical value queue */
904 static YYSTYPE *yylvals = 0;
905
906 /* Current position at lexical value queue */
907 static YYSTYPE *yylvp = 0;
908
909 /* End position of lexical value queue */
910 static YYSTYPE *yylve = 0;
911
912 /* The last allocated position at the lexical value queue */
913 static YYSTYPE *yylvlim = 0;
914
915 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
916 /* Base of the lexical position queue */
917 static YYLTYPE *yylpsns = 0;
918
919 /* Current position at lexical position queue */
920 static YYLTYPE *yylpp = 0;
921
922 /* End position of lexical position queue */
923 static YYLTYPE *yylpe = 0;
924
925 /* The last allocated position at the lexical position queue */
926 static YYLTYPE *yylplim = 0;
927 #endif
928
929 /* Current position at lexical token queue */
930 static YYINT *yylexp = 0;
931
932 static YYINT *yylexemes = 0;
933 #endif /* YYBTYACC */
934 int yym, yyn, yystate, yyresult;
935 #if YYBTYACC
936 int yynewerrflag;
937 YYParseState *yyerrctx = NULL;
938 #endif /* YYBTYACC */
939 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
940 YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
941 #endif
942 #if YYDEBUG
943 const char *yys;
944
945 if ((yys = getenv("YYDEBUG")) != 0)
946 {
947 yyn = *yys;
948 if (yyn >= '0' && yyn <= '9')
949 yydebug = yyn - '0';
950 }
951 if (yydebug)
952 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
953 #endif
954 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
955 memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
956 #endif
957
958 yyerrflag = 0;
959 yychar = 0;
960 memset(&yyval, 0, sizeof(yyval));
961 memset(&yylval, 0, sizeof(yylval));
962 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
963 memset(&yyloc, 0, sizeof(yyloc));
964 memset(&yylloc, 0, sizeof(yylloc));
965 #endif
966
967 #if YYBTYACC
968 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
969 yyps->save = 0;
970 #endif /* YYBTYACC */
971 yym = 0;
972 /* yyn is set below */
973 yynerrs = 0;
974 yyerrflag = 0;
975 yychar = YYEMPTY;
976 yystate = 0;
977
978 #if YYPURE
979 memset(&yystack, 0, sizeof(yystack));
980 #endif
981
982 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
983 yystack.s_mark = yystack.s_base;
984 yystack.l_mark = yystack.l_base;
985 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
986 yystack.p_mark = yystack.p_base;
987 #endif
988 yystate = 0;
989 *yystack.s_mark = 0;
990
991 yyloop:
992 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
993 if (yychar < 0)
994 {
995 #if YYBTYACC
996 do {
997 if (yylvp < yylve)
998 {
999 /* we're currently re-reading tokens */
1000 yylval = *yylvp++;
1001 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1002 yylloc = *yylpp++;
1003 #endif
1004 yychar = *yylexp++;
1005 break;
1006 }
1007 if (yyps->save)
1008 {
1009 /* in trial mode; save scanner results for future parse attempts */
1010 if (yylvp == yylvlim)
1011 { /* Enlarge lexical value queue */
1012 size_t p = (size_t) (yylvp - yylvals);
1013 size_t s = (size_t) (yylvlim - yylvals);
1014
1015 s += YYLVQUEUEGROWTH;
1016 if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
1017 if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
1018 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1019 if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
1020 #endif
1021 yylvp = yylve = yylvals + p;
1022 yylvlim = yylvals + s;
1023 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1024 yylpp = yylpe = yylpsns + p;
1025 yylplim = yylpsns + s;
1026 #endif
1027 yylexp = yylexemes + p;
1028 }
1029 *yylexp = (YYINT) YYLEX;
1030 *yylvp++ = yylval;
1031 yylve++;
1032 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1033 *yylpp++ = yylloc;
1034 yylpe++;
1035 #endif
1036 yychar = *yylexp++;
1037 break;
1038 }
1039 /* normal operation, no conflict encountered */
1040 #endif /* YYBTYACC */
1041 yychar = YYLEX;
1042 #if YYBTYACC
1043 } while (0);
1044 #endif /* YYBTYACC */
1045 if (yychar < 0) yychar = YYEOF;
1046 #if YYDEBUG
1047 if (yydebug)
1048 {
1049 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1050 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
1051 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1052 #ifdef YYSTYPE_TOSTRING
1053 #if YYBTYACC
1054 if (!yytrial)
1055 #endif /* YYBTYACC */
1056 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
1057 #endif
1058 fputc('\n', stderr);
1059 }
1060 #endif
1061 }
1062 #if YYBTYACC
1063
1064 /* Do we have a conflict? */
1065 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1066 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1067 {
1068 YYINT ctry;
1069
1070 if (yypath)
1071 {
1072 YYParseState *save;
1073 #if YYDEBUG
1074 if (yydebug)
1075 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
1076 YYDEBUGSTR, yydepth, yystate);
1077 #endif
1078 /* Switch to the next conflict context */
1079 save = yypath;
1080 yypath = save->save;
1081 save->save = NULL;
1082 ctry = save->ctry;
1083 if (save->state != yystate) YYABORT;
1084 yyFreeState(save);
1085
1086 }
1087 else
1088 {
1089
1090 /* Unresolved conflict - start/continue trial parse */
1091 YYParseState *save;
1092 #if YYDEBUG
1093 if (yydebug)
1094 {
1095 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
1096 if (yyps->save)
1097 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
1098 else
1099 fputs("Starting trial parse.\n", stderr);
1100 }
1101 #endif
1102 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
1103 if (save == NULL) goto yyenomem;
1104 save->save = yyps->save;
1105 save->state = yystate;
1106 save->errflag = yyerrflag;
1107 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
1108 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1109 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
1110 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1111 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1112 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
1113 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1114 #endif
1115 ctry = yytable[yyn];
1116 if (yyctable[ctry] == -1)
1117 {
1118 #if YYDEBUG
1119 if (yydebug && yychar >= YYEOF)
1120 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
1121 #endif
1122 ctry++;
1123 }
1124 save->ctry = ctry;
1125 if (yyps->save == NULL)
1126 {
1127 /* If this is a first conflict in the stack, start saving lexemes */
1128 if (!yylexemes)
1129 {
1130 yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
1131 if (yylexemes == NULL) goto yyenomem;
1132 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
1133 if (yylvals == NULL) goto yyenomem;
1134 yylvlim = yylvals + YYLVQUEUEGROWTH;
1135 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1136 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
1137 if (yylpsns == NULL) goto yyenomem;
1138 yylplim = yylpsns + YYLVQUEUEGROWTH;
1139 #endif
1140 }
1141 if (yylvp == yylve)
1142 {
1143 yylvp = yylve = yylvals;
1144 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1145 yylpp = yylpe = yylpsns;
1146 #endif
1147 yylexp = yylexemes;
1148 if (yychar >= YYEOF)
1149 {
1150 *yylve++ = yylval;
1151 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1152 *yylpe++ = yylloc;
1153 #endif
1154 *yylexp = (YYINT) yychar;
1155 yychar = YYEMPTY;
1156 }
1157 }
1158 }
1159 if (yychar >= YYEOF)
1160 {
1161 yylvp--;
1162 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1163 yylpp--;
1164 #endif
1165 yylexp--;
1166 yychar = YYEMPTY;
1167 }
1168 save->lexeme = (int) (yylvp - yylvals);
1169 yyps->save = save;
1170 }
1171 if (yytable[yyn] == ctry)
1172 {
1173 #if YYDEBUG
1174 if (yydebug)
1175 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
1176 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
1177 #endif
1178 if (yychar < 0)
1179 {
1180 yylvp++;
1181 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1182 yylpp++;
1183 #endif
1184 yylexp++;
1185 }
1186 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
1187 goto yyoverflow;
1188 yystate = yyctable[ctry];
1189 *++yystack.s_mark = (YYINT) yystate;
1190 *++yystack.l_mark = yylval;
1191 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1192 *++yystack.p_mark = yylloc;
1193 #endif
1194 yychar = YYEMPTY;
1195 if (yyerrflag > 0) --yyerrflag;
1196 goto yyloop;
1197 }
1198 else
1199 {
1200 yyn = yyctable[ctry];
1201 goto yyreduce;
1202 }
1203 } /* End of code dealing with conflicts */
1204 #endif /* YYBTYACC */
1205 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1206 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1207 {
1208 #if YYDEBUG
1209 if (yydebug)
1210 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
1211 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
1212 #endif
1213 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1214 yystate = yytable[yyn];
1215 *++yystack.s_mark = yytable[yyn];
1216 *++yystack.l_mark = yylval;
1217 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1218 *++yystack.p_mark = yylloc;
1219 #endif
1220 yychar = YYEMPTY;
1221 if (yyerrflag > 0) --yyerrflag;
1222 goto yyloop;
1223 }
1224 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
1225 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
1226 {
1227 yyn = yytable[yyn];
1228 goto yyreduce;
1229 }
1230 if (yyerrflag != 0) goto yyinrecovery;
1231 #if YYBTYACC
1232
1233 yynewerrflag = 1;
1234 goto yyerrhandler;
1235 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1236
1237 yyerrlab:
1238 /* explicit YYERROR from an action -- pop the rhs of the rule reduced
1239 * before looking for error recovery */
1240 yystack.s_mark -= yym;
1241 yystate = *yystack.s_mark;
1242 yystack.l_mark -= yym;
1243 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1244 yystack.p_mark -= yym;
1245 #endif
1246
1247 yynewerrflag = 0;
1248 yyerrhandler:
1249 while (yyps->save)
1250 {
1251 int ctry;
1252 YYParseState *save = yyps->save;
1253 #if YYDEBUG
1254 if (yydebug)
1255 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
1256 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
1257 (int)(yylvp - yylvals - yyps->save->lexeme));
1258 #endif
1259 /* Memorize most forward-looking error state in case it's really an error. */
1260 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
1261 {
1262 /* Free old saved error context state */
1263 if (yyerrctx) yyFreeState(yyerrctx);
1264 /* Create and fill out new saved error context state */
1265 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
1266 if (yyerrctx == NULL) goto yyenomem;
1267 yyerrctx->save = yyps->save;
1268 yyerrctx->state = yystate;
1269 yyerrctx->errflag = yyerrflag;
1270 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
1271 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1272 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
1273 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1274 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1275 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
1276 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1277 #endif
1278 yyerrctx->lexeme = (int) (yylvp - yylvals);
1279 }
1280 yylvp = yylvals + save->lexeme;
1281 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1282 yylpp = yylpsns + save->lexeme;
1283 #endif
1284 yylexp = yylexemes + save->lexeme;
1285 yychar = YYEMPTY;
1286 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
1287 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1288 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
1289 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1290 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1291 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
1292 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1293 #endif
1294 ctry = ++save->ctry;
1295 yystate = save->state;
1296 /* We tried shift, try reduce now */
1297 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
1298 yyps->save = save->save;
1299 save->save = NULL;
1300 yyFreeState(save);
1301
1302 /* Nothing left on the stack -- error */
1303 if (!yyps->save)
1304 {
1305 #if YYDEBUG
1306 if (yydebug)
1307 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
1308 YYPREFIX, yydepth);
1309 #endif
1310 /* Restore state as it was in the most forward-advanced error */
1311 yylvp = yylvals + yyerrctx->lexeme;
1312 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1313 yylpp = yylpsns + yyerrctx->lexeme;
1314 #endif
1315 yylexp = yylexemes + yyerrctx->lexeme;
1316 yychar = yylexp[-1];
1317 yylval = yylvp[-1];
1318 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1319 yylloc = yylpp[-1];
1320 #endif
1321 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
1322 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1323 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
1324 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1325 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1326 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
1327 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1328 #endif
1329 yystate = yyerrctx->state;
1330 yyFreeState(yyerrctx);
1331 yyerrctx = NULL;
1332 }
1333 yynewerrflag = 1;
1334 }
1335 if (yynewerrflag == 0) goto yyinrecovery;
1336 #endif /* YYBTYACC */
1337
1338 YYERROR_CALL("syntax error");
1339 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1340 yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
1341 #endif
1342
1343 #if !YYBTYACC
1344 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1345 yyerrlab:
1346 #endif
1347 ++yynerrs;
1348
1349 yyinrecovery:
1350 if (yyerrflag < 3)
1351 {
1352 yyerrflag = 3;
1353 for (;;)
1354 {
1355 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1356 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1357 {
1358 #if YYDEBUG
1359 if (yydebug)
1360 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1361 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1362 #endif
1363 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1364 yystate = yytable[yyn];
1365 *++yystack.s_mark = yytable[yyn];
1366 *++yystack.l_mark = yylval;
1367 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1368 /* lookahead position is error end position */
1369 yyerror_loc_range[2] = yylloc;
1370 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1371 *++yystack.p_mark = yyloc;
1372 #endif
1373 goto yyloop;
1374 }
1375 else
1376 {
1377 #if YYDEBUG
1378 if (yydebug)
1379 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1380 YYDEBUGSTR, yydepth, *yystack.s_mark);
1381 #endif
1382 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1383 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1384 /* the current TOS position is the error start position */
1385 yyerror_loc_range[1] = *yystack.p_mark;
1386 #endif
1387 #if defined(YYDESTRUCT_CALL)
1388 #if YYBTYACC
1389 if (!yytrial)
1390 #endif /* YYBTYACC */
1391 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1392 YYDESTRUCT_CALL("error: discarding state",
1393 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1394 #else
1395 YYDESTRUCT_CALL("error: discarding state",
1396 yystos[*yystack.s_mark], yystack.l_mark);
1397 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1398 #endif /* defined(YYDESTRUCT_CALL) */
1399 --yystack.s_mark;
1400 --yystack.l_mark;
1401 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1402 --yystack.p_mark;
1403 #endif
1404 }
1405 }
1406 }
1407 else
1408 {
1409 if (yychar == YYEOF) goto yyabort;
1410 #if YYDEBUG
1411 if (yydebug)
1412 {
1413 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1414 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1415 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1416 }
1417 #endif
1418 #if defined(YYDESTRUCT_CALL)
1419 #if YYBTYACC
1420 if (!yytrial)
1421 #endif /* YYBTYACC */
1422 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1423 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1424 #else
1425 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1426 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1427 #endif /* defined(YYDESTRUCT_CALL) */
1428 yychar = YYEMPTY;
1429 goto yyloop;
1430 }
1431
1432 yyreduce:
1433 yym = yylen[yyn];
1434 #if YYDEBUG
1435 if (yydebug)
1436 {
1437 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1438 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1439 #ifdef YYSTYPE_TOSTRING
1440 #if YYBTYACC
1441 if (!yytrial)
1442 #endif /* YYBTYACC */
1443 if (yym > 0)
1444 {
1445 int i;
1446 fputc('<', stderr);
1447 for (i = yym; i > 0; i--)
1448 {
1449 if (i != yym) fputs(", ", stderr);
1450 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1451 yystack.l_mark[1-i]), stderr);
1452 }
1453 fputc('>', stderr);
1454 }
1455 #endif
1456 fputc('\n', stderr);
1457 }
1458 #endif
1459 if (yym > 0)
1460 yyval = yystack.l_mark[1-yym];
1461 else
1462 memset(&yyval, 0, sizeof yyval);
1463 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1464
1465 /* Perform position reduction */
1466 memset(&yyloc, 0, sizeof(yyloc));
1467 #if YYBTYACC
1468 if (!yytrial)
1469 #endif /* YYBTYACC */
1470 {
1471 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
1472 /* just in case YYERROR is invoked within the action, save
1473 the start of the rhs as the error start position */
1474 yyerror_loc_range[1] = yystack.p_mark[1-yym];
1475 }
1476 #endif
1477
1478 switch (yyn)
1479 {
1480 case 1:
1481 #line 179 "plural.y"
1482 {
1483 if (yystack.l_mark[0].exp == NULL)
1484 YYABORT;
1485 ((struct parse_args *) arg)->res = yystack.l_mark[0].exp;
1486 }
1487 #line 1488 "plural.c"
1488 break;
1489 case 2:
1490 #line 187 "plural.y"
1491 {
1492 yyval.exp = new_exp_3 (qmop, yystack.l_mark[-4].exp, yystack.l_mark[-2].exp, yystack.l_mark[0].exp);
1493 }
1494 #line 1495 "plural.c"
1495 break;
1496 case 3:
1497 #line 191 "plural.y"
1498 {
1499 yyval.exp = new_exp_2 (lor, yystack.l_mark[-2].exp, yystack.l_mark[0].exp);
1500 }
1501 #line 1502 "plural.c"
1502 break;
1503 case 4:
1504 #line 195 "plural.y"
1505 {
1506 yyval.exp = new_exp_2 (land, yystack.l_mark[-2].exp, yystack.l_mark[0].exp);
1507 }
1508 #line 1509 "plural.c"
1509 break;
1510 case 5:
1511 #line 199 "plural.y"
1512 {
1513 yyval.exp = new_exp_2 (yystack.l_mark[-1].op, yystack.l_mark[-2].exp, yystack.l_mark[0].exp);
1514 }
1515 #line 1516 "plural.c"
1516 break;
1517 case 6:
1518 #line 203 "plural.y"
1519 {
1520 yyval.exp = new_exp_2 (yystack.l_mark[-1].op, yystack.l_mark[-2].exp, yystack.l_mark[0].exp);
1521 }
1522 #line 1523 "plural.c"
1523 break;
1524 case 7:
1525 #line 207 "plural.y"
1526 {
1527 yyval.exp = new_exp_2 (yystack.l_mark[-1].op, yystack.l_mark[-2].exp, yystack.l_mark[0].exp);
1528 }
1529 #line 1530 "plural.c"
1530 break;
1531 case 8:
1532 #line 211 "plural.y"
1533 {
1534 yyval.exp = new_exp_2 (yystack.l_mark[-1].op, yystack.l_mark[-2].exp, yystack.l_mark[0].exp);
1535 }
1536 #line 1537 "plural.c"
1537 break;
1538 case 9:
1539 #line 215 "plural.y"
1540 {
1541 yyval.exp = new_exp_1 (lnot, yystack.l_mark[0].exp);
1542 }
1543 #line 1544 "plural.c"
1544 break;
1545 case 10:
1546 #line 219 "plural.y"
1547 {
1548 yyval.exp = new_exp_0 (var);
1549 }
1550 #line 1551 "plural.c"
1551 break;
1552 case 11:
1553 #line 223 "plural.y"
1554 {
1555 if ((yyval.exp = new_exp_0 (num)) != NULL)
1556 yyval.exp->val.num = yystack.l_mark[0].num;
1557 }
1558 #line 1559 "plural.c"
1559 break;
1560 case 12:
1561 #line 228 "plural.y"
1562 {
1563 yyval.exp = yystack.l_mark[-1].exp;
1564 }
1565 #line 1566 "plural.c"
1566 break;
1567 #line 1568 "plural.c"
1568 default:
1569 break;
1570 }
1571 yystack.s_mark -= yym;
1572 yystate = *yystack.s_mark;
1573 yystack.l_mark -= yym;
1574 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1575 yystack.p_mark -= yym;
1576 #endif
1577 yym = yylhs[yyn];
1578 if (yystate == 0 && yym == 0)
1579 {
1580 #if YYDEBUG
1581 if (yydebug)
1582 {
1583 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1584 #ifdef YYSTYPE_TOSTRING
1585 #if YYBTYACC
1586 if (!yytrial)
1587 #endif /* YYBTYACC */
1588 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1589 #endif
1590 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1591 }
1592 #endif
1593 yystate = YYFINAL;
1594 *++yystack.s_mark = YYFINAL;
1595 *++yystack.l_mark = yyval;
1596 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1597 *++yystack.p_mark = yyloc;
1598 #endif
1599 if (yychar < 0)
1600 {
1601 #if YYBTYACC
1602 do {
1603 if (yylvp < yylve)
1604 {
1605 /* we're currently re-reading tokens */
1606 yylval = *yylvp++;
1607 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1608 yylloc = *yylpp++;
1609 #endif
1610 yychar = *yylexp++;
1611 break;
1612 }
1613 if (yyps->save)
1614 {
1615 /* in trial mode; save scanner results for future parse attempts */
1616 if (yylvp == yylvlim)
1617 { /* Enlarge lexical value queue */
1618 size_t p = (size_t) (yylvp - yylvals);
1619 size_t s = (size_t) (yylvlim - yylvals);
1620
1621 s += YYLVQUEUEGROWTH;
1622 if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
1623 goto yyenomem;
1624 if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1625 goto yyenomem;
1626 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1627 if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1628 goto yyenomem;
1629 #endif
1630 yylvp = yylve = yylvals + p;
1631 yylvlim = yylvals + s;
1632 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1633 yylpp = yylpe = yylpsns + p;
1634 yylplim = yylpsns + s;
1635 #endif
1636 yylexp = yylexemes + p;
1637 }
1638 *yylexp = (YYINT) YYLEX;
1639 *yylvp++ = yylval;
1640 yylve++;
1641 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1642 *yylpp++ = yylloc;
1643 yylpe++;
1644 #endif
1645 yychar = *yylexp++;
1646 break;
1647 }
1648 /* normal operation, no conflict encountered */
1649 #endif /* YYBTYACC */
1650 yychar = YYLEX;
1651 #if YYBTYACC
1652 } while (0);
1653 #endif /* YYBTYACC */
1654 if (yychar < 0) yychar = YYEOF;
1655 #if YYDEBUG
1656 if (yydebug)
1657 {
1658 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1659 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
1660 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1661 }
1662 #endif
1663 }
1664 if (yychar == YYEOF) goto yyaccept;
1665 goto yyloop;
1666 }
1667 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1668 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1669 yystate = yytable[yyn];
1670 else
1671 yystate = yydgoto[yym];
1672 #if YYDEBUG
1673 if (yydebug)
1674 {
1675 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1676 #ifdef YYSTYPE_TOSTRING
1677 #if YYBTYACC
1678 if (!yytrial)
1679 #endif /* YYBTYACC */
1680 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1681 #endif
1682 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1683 }
1684 #endif
1685 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1686 *++yystack.s_mark = (YYINT) yystate;
1687 *++yystack.l_mark = yyval;
1688 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1689 *++yystack.p_mark = yyloc;
1690 #endif
1691 goto yyloop;
1692 #if YYBTYACC
1693
1694 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1695 yyvalid:
1696 if (yypath) YYABORT;
1697 while (yyps->save)
1698 {
1699 YYParseState *save = yyps->save;
1700 yyps->save = save->save;
1701 save->save = yypath;
1702 yypath = save;
1703 }
1704 #if YYDEBUG
1705 if (yydebug)
1706 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1707 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1708 #endif
1709 if (yyerrctx)
1710 {
1711 yyFreeState(yyerrctx);
1712 yyerrctx = NULL;
1713 }
1714 yylvp = yylvals + yypath->lexeme;
1715 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1716 yylpp = yylpsns + yypath->lexeme;
1717 #endif
1718 yylexp = yylexemes + yypath->lexeme;
1719 yychar = YYEMPTY;
1720 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1721 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1722 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1723 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1724 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1725 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1726 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1727 #endif
1728 yystate = yypath->state;
1729 goto yyloop;
1730 #endif /* YYBTYACC */
1731
1732 yyoverflow:
1733 YYERROR_CALL("yacc stack overflow");
1734 #if YYBTYACC
1735 goto yyabort_nomem;
1736 yyenomem:
1737 YYERROR_CALL("memory exhausted");
1738 yyabort_nomem:
1739 #endif /* YYBTYACC */
1740 yyresult = 2;
1741 goto yyreturn;
1742
1743 yyabort:
1744 yyresult = 1;
1745 goto yyreturn;
1746
1747 yyaccept:
1748 #if YYBTYACC
1749 if (yyps->save) goto yyvalid;
1750 #endif /* YYBTYACC */
1751 yyresult = 0;
1752
1753 yyreturn:
1754 #if defined(YYDESTRUCT_CALL)
1755 if (yychar != YYEOF && yychar != YYEMPTY)
1756 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1757 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1758 #else
1759 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1760 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1761
1762 {
1763 YYSTYPE *pv;
1764 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1765 YYLTYPE *pp;
1766
1767 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1768 YYDESTRUCT_CALL("cleanup: discarding state",
1769 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1770 #else
1771 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1772 YYDESTRUCT_CALL("cleanup: discarding state",
1773 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1774 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1775 }
1776 #endif /* defined(YYDESTRUCT_CALL) */
1777
1778 #if YYBTYACC
1779 if (yyerrctx)
1780 {
1781 yyFreeState(yyerrctx);
1782 yyerrctx = NULL;
1783 }
1784 while (yyps)
1785 {
1786 YYParseState *save = yyps;
1787 yyps = save->save;
1788 save->save = NULL;
1789 yyFreeState(save);
1790 }
1791 while (yypath)
1792 {
1793 YYParseState *save = yypath;
1794 yypath = save->save;
1795 save->save = NULL;
1796 yyFreeState(save);
1797 }
1798 #endif /* YYBTYACC */
1799 yyfreestack(&yystack);
1800 return (yyresult);
1801 }