1 |
|
---|
2 | /* A Bison parser, made from plural.y
|
---|
3 | by GNU Bison version 1.28 */
|
---|
4 |
|
---|
5 | #define YYBISON 1 /* Identify Bison output. */
|
---|
6 |
|
---|
7 | #define yyparse __gettextparse
|
---|
8 | #define yylex __gettextlex
|
---|
9 | #define yyerror __gettexterror
|
---|
10 | #define yylval __gettextlval
|
---|
11 | #define yychar __gettextchar
|
---|
12 | #define yydebug __gettextdebug
|
---|
13 | #define yynerrs __gettextnerrs
|
---|
14 | #define EQUOP2 257
|
---|
15 | #define CMPOP2 258
|
---|
16 | #define ADDOP2 259
|
---|
17 | #define MULOP2 260
|
---|
18 | #define NUMBER 261
|
---|
19 |
|
---|
20 | #line 1 "plural.y"
|
---|
21 |
|
---|
22 | /* Expression parsing for plural form selection.
|
---|
23 | Copyright (C) 2000, 2001 Free Software Foundation, Inc.
|
---|
24 | Written by Ulrich Drepper <[email protected]>, 2000.
|
---|
25 |
|
---|
26 | This program is free software; you can redistribute it and/or modify it
|
---|
27 | under the terms of the GNU Library General Public License as published
|
---|
28 | by the Free Software Foundation; either version 2, or (at your option)
|
---|
29 | any later version.
|
---|
30 |
|
---|
31 | This program is distributed in the hope that it will be useful,
|
---|
32 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
33 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
34 | Library General Public License for more details.
|
---|
35 |
|
---|
36 | You should have received a copy of the GNU Library General Public
|
---|
37 | License along with this program; if not, write to the Free Software
|
---|
38 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
---|
39 | USA. */
|
---|
40 |
|
---|
41 | /* The bison generated parser uses alloca. AIX 3 forces us to put this
|
---|
42 | declaration at the beginning of the file. The declaration in bison's
|
---|
43 | skeleton file comes too late. This must come before <config.h>
|
---|
44 | because <config.h> may include arbitrary system headers. */
|
---|
45 | #if defined _AIX && !defined __GNUC__
|
---|
46 | #pragma alloca
|
---|
47 | #endif
|
---|
48 |
|
---|
49 | #ifdef HAVE_CONFIG_H
|
---|
50 | # include <config.h>
|
---|
51 | #endif
|
---|
52 |
|
---|
53 | #include <stddef.h>
|
---|
54 | #include <stdlib.h>
|
---|
55 | #include "plural-exp.h"
|
---|
56 |
|
---|
57 | /* The main function generated by the parser is called __gettextparse,
|
---|
58 | but we want it to be called PLURAL_PARSE. */
|
---|
59 | #ifndef _LIBC
|
---|
60 | # define __gettextparse PLURAL_PARSE
|
---|
61 | #endif
|
---|
62 |
|
---|
63 | #define YYLEX_PARAM &((struct parse_args *) arg)->cp
|
---|
64 | #define YYPARSE_PARAM arg
|
---|
65 |
|
---|
66 | #line 49 "plural.y"
|
---|
67 | typedef union {
|
---|
68 | unsigned long int num;
|
---|
69 | enum operator op;
|
---|
70 | struct expression *exp;
|
---|
71 | } YYSTYPE;
|
---|
72 | #line 55 "plural.y"
|
---|
73 |
|
---|
74 | /* Prototypes for local functions. */
|
---|
75 | static struct expression *new_exp PARAMS ((int nargs, enum operator op,
|
---|
76 | struct expression * const *args));
|
---|
77 | static inline struct expression *new_exp_0 PARAMS ((enum operator op));
|
---|
78 | static inline struct expression *new_exp_1 PARAMS ((enum operator op,
|
---|
79 | struct expression *right));
|
---|
80 | static struct expression *new_exp_2 PARAMS ((enum operator op,
|
---|
81 | struct expression *left,
|
---|
82 | struct expression *right));
|
---|
83 | static inline struct expression *new_exp_3 PARAMS ((enum operator op,
|
---|
84 | struct expression *bexp,
|
---|
85 | struct expression *tbranch,
|
---|
86 | struct expression *fbranch));
|
---|
87 | static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
|
---|
88 | static void yyerror PARAMS ((const char *str));
|
---|
89 |
|
---|
90 | /* Allocation of expressions. */
|
---|
91 |
|
---|
92 | static struct expression *
|
---|
93 | new_exp (nargs, op, args)
|
---|
94 | int nargs;
|
---|
95 | enum operator op;
|
---|
96 | struct expression * const *args;
|
---|
97 | {
|
---|
98 | int i;
|
---|
99 | struct expression *newp;
|
---|
100 |
|
---|
101 | /* If any of the argument could not be malloc'ed, just return NULL. */
|
---|
102 | for (i = nargs - 1; i >= 0; i--)
|
---|
103 | if (args[i] == NULL)
|
---|
104 | goto fail;
|
---|
105 |
|
---|
106 | /* Allocate a new expression. */
|
---|
107 | newp = (struct expression *) malloc (sizeof (*newp));
|
---|
108 | if (newp != NULL)
|
---|
109 | {
|
---|
110 | newp->nargs = nargs;
|
---|
111 | newp->operation = op;
|
---|
112 | for (i = nargs - 1; i >= 0; i--)
|
---|
113 | newp->val.args[i] = args[i];
|
---|
114 | return newp;
|
---|
115 | }
|
---|
116 |
|
---|
117 | fail:
|
---|
118 | for (i = nargs - 1; i >= 0; i--)
|
---|
119 | FREE_EXPRESSION (args[i]);
|
---|
120 |
|
---|
121 | return NULL;
|
---|
122 | }
|
---|
123 |
|
---|
124 | static inline struct expression *
|
---|
125 | new_exp_0 (op)
|
---|
126 | enum operator op;
|
---|
127 | {
|
---|
128 | return new_exp (0, op, NULL);
|
---|
129 | }
|
---|
130 |
|
---|
131 | static inline struct expression *
|
---|
132 | new_exp_1 (op, right)
|
---|
133 | enum operator op;
|
---|
134 | struct expression *right;
|
---|
135 | {
|
---|
136 | struct expression *args[1];
|
---|
137 |
|
---|
138 | args[0] = right;
|
---|
139 | return new_exp (1, op, args);
|
---|
140 | }
|
---|
141 |
|
---|
142 | static struct expression *
|
---|
143 | new_exp_2 (op, left, right)
|
---|
144 | enum operator op;
|
---|
145 | struct expression *left;
|
---|
146 | struct expression *right;
|
---|
147 | {
|
---|
148 | struct expression *args[2];
|
---|
149 |
|
---|
150 | args[0] = left;
|
---|
151 | args[1] = right;
|
---|
152 | return new_exp (2, op, args);
|
---|
153 | }
|
---|
154 |
|
---|
155 | static inline struct expression *
|
---|
156 | new_exp_3 (op, bexp, tbranch, fbranch)
|
---|
157 | enum operator op;
|
---|
158 | struct expression *bexp;
|
---|
159 | struct expression *tbranch;
|
---|
160 | struct expression *fbranch;
|
---|
161 | {
|
---|
162 | struct expression *args[3];
|
---|
163 |
|
---|
164 | args[0] = bexp;
|
---|
165 | args[1] = tbranch;
|
---|
166 | args[2] = fbranch;
|
---|
167 | return new_exp (3, op, args);
|
---|
168 | }
|
---|
169 |
|
---|
170 | #include <stdio.h>
|
---|
171 |
|
---|
172 | #ifndef __cplusplus
|
---|
173 | #ifndef __STDC__
|
---|
174 | #define const
|
---|
175 | #endif
|
---|
176 | #endif
|
---|
177 |
|
---|
178 |
|
---|
179 |
|
---|
180 | #define YYFINAL 27
|
---|
181 | #define YYFLAG -32768
|
---|
182 | #define YYNTBASE 16
|
---|
183 |
|
---|
184 | #define YYTRANSLATE(x) ((unsigned)(x) <= 261 ? yytranslate[x] : 18)
|
---|
185 |
|
---|
186 | static const char yytranslate[] = { 0,
|
---|
187 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
188 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
189 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
190 | 2, 2, 10, 2, 2, 2, 2, 5, 2, 14,
|
---|
191 | 15, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
192 | 2, 2, 2, 2, 2, 2, 2, 12, 2, 2,
|
---|
193 | 2, 2, 3, 2, 2, 2, 2, 2, 2, 2,
|
---|
194 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
195 | 2, 2, 2, 2, 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, 13,
|
---|
198 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
199 | 2, 2, 2, 4, 2, 2, 2, 2, 2, 2,
|
---|
200 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
---|
201 | 2, 2, 2, 2, 2, 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, 1, 6, 7, 8, 9,
|
---|
213 | 11
|
---|
214 | };
|
---|
215 |
|
---|
216 | #if YYDEBUG != 0
|
---|
217 | static const short yyprhs[] = { 0,
|
---|
218 | 0, 2, 8, 12, 16, 20, 24, 28, 32, 35,
|
---|
219 | 37, 39
|
---|
220 | };
|
---|
221 |
|
---|
222 | static const short yyrhs[] = { 17,
|
---|
223 | 0, 17, 3, 17, 12, 17, 0, 17, 4, 17,
|
---|
224 | 0, 17, 5, 17, 0, 17, 6, 17, 0, 17,
|
---|
225 | 7, 17, 0, 17, 8, 17, 0, 17, 9, 17,
|
---|
226 | 0, 10, 17, 0, 13, 0, 11, 0, 14, 17,
|
---|
227 | 15, 0
|
---|
228 | };
|
---|
229 |
|
---|
230 | #endif
|
---|
231 |
|
---|
232 | #if YYDEBUG != 0
|
---|
233 | static const short yyrline[] = { 0,
|
---|
234 | 174, 182, 186, 190, 194, 198, 202, 206, 210, 214,
|
---|
235 | 218, 223
|
---|
236 | };
|
---|
237 | #endif
|
---|
238 |
|
---|
239 |
|
---|
240 | #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
|
---|
241 |
|
---|
242 | static const char * const yytname[] = { "$","error","$undefined.","'?'","'|'",
|
---|
243 | "'&'","EQUOP2","CMPOP2","ADDOP2","MULOP2","'!'","NUMBER","':'","'n'","'('","')'",
|
---|
244 | "start","exp", NULL
|
---|
245 | };
|
---|
246 | #endif
|
---|
247 |
|
---|
248 | static const short yyr1[] = { 0,
|
---|
249 | 16, 17, 17, 17, 17, 17, 17, 17, 17, 17,
|
---|
250 | 17, 17
|
---|
251 | };
|
---|
252 |
|
---|
253 | static const short yyr2[] = { 0,
|
---|
254 | 1, 5, 3, 3, 3, 3, 3, 3, 2, 1,
|
---|
255 | 1, 3
|
---|
256 | };
|
---|
257 |
|
---|
258 | static const short yydefact[] = { 0,
|
---|
259 | 0, 11, 10, 0, 1, 9, 0, 0, 0, 0,
|
---|
260 | 0, 0, 0, 0, 12, 0, 3, 4, 5, 6,
|
---|
261 | 7, 8, 0, 2, 0, 0, 0
|
---|
262 | };
|
---|
263 |
|
---|
264 | static const short yydefgoto[] = { 25,
|
---|
265 | 5
|
---|
266 | };
|
---|
267 |
|
---|
268 | static const short yypact[] = { -9,
|
---|
269 | -9,-32768,-32768, -9, 34,-32768, 11, -9, -9, -9,
|
---|
270 | -9, -9, -9, -9,-32768, 24, 39, 43, 16, 26,
|
---|
271 | -3,-32768, -9, 34, 21, 53,-32768
|
---|
272 | };
|
---|
273 |
|
---|
274 | static const short yypgoto[] = {-32768,
|
---|
275 | -1
|
---|
276 | };
|
---|
277 |
|
---|
278 |
|
---|
279 | #define YYLAST 53
|
---|
280 |
|
---|
281 |
|
---|
282 | static const short yytable[] = { 6,
|
---|
283 | 1, 2, 7, 3, 4, 14, 16, 17, 18, 19,
|
---|
284 | 20, 21, 22, 8, 9, 10, 11, 12, 13, 14,
|
---|
285 | 26, 24, 12, 13, 14, 15, 8, 9, 10, 11,
|
---|
286 | 12, 13, 14, 13, 14, 23, 8, 9, 10, 11,
|
---|
287 | 12, 13, 14, 10, 11, 12, 13, 14, 11, 12,
|
---|
288 | 13, 14, 27
|
---|
289 | };
|
---|
290 |
|
---|
291 | static const short yycheck[] = { 1,
|
---|
292 | 10, 11, 4, 13, 14, 9, 8, 9, 10, 11,
|
---|
293 | 12, 13, 14, 3, 4, 5, 6, 7, 8, 9,
|
---|
294 | 0, 23, 7, 8, 9, 15, 3, 4, 5, 6,
|
---|
295 | 7, 8, 9, 8, 9, 12, 3, 4, 5, 6,
|
---|
296 | 7, 8, 9, 5, 6, 7, 8, 9, 6, 7,
|
---|
297 | 8, 9, 0
|
---|
298 | };
|
---|
299 | #define YYPURE 1
|
---|
300 |
|
---|
301 | /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
|
---|
302 | #line 3 "/usr/local/share/bison.simple"
|
---|
303 | /* This file comes from bison-1.28. */
|
---|
304 |
|
---|
305 | /* Skeleton output parser for bison,
|
---|
306 | Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
|
---|
307 |
|
---|
308 | This program is free software; you can redistribute it and/or modify
|
---|
309 | it under the terms of the GNU General Public License as published by
|
---|
310 | the Free Software Foundation; either version 2, or (at your option)
|
---|
311 | any later version.
|
---|
312 |
|
---|
313 | This program is distributed in the hope that it will be useful,
|
---|
314 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
315 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
316 | GNU General Public License for more details.
|
---|
317 |
|
---|
318 | You should have received a copy of the GNU General Public License
|
---|
319 | along with this program; if not, write to the Free Software
|
---|
320 | Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
---|
321 | Boston, MA 02110-1301, USA. */
|
---|
322 |
|
---|
323 | /* As a special exception, when this file is copied by Bison into a
|
---|
324 | Bison output file, you may use that output file without restriction.
|
---|
325 | This special exception was added by the Free Software Foundation
|
---|
326 | in version 1.24 of Bison. */
|
---|
327 |
|
---|
328 | /* This is the parser code that is written into each bison parser
|
---|
329 | when the %semantic_parser declaration is not specified in the grammar.
|
---|
330 | It was written by Richard Stallman by simplifying the hairy parser
|
---|
331 | used when %semantic_parser is specified. */
|
---|
332 |
|
---|
333 | #ifndef YYSTACK_USE_ALLOCA
|
---|
334 | #ifdef alloca
|
---|
335 | #define YYSTACK_USE_ALLOCA
|
---|
336 | #else /* alloca not defined */
|
---|
337 | #ifdef __GNUC__
|
---|
338 | #define YYSTACK_USE_ALLOCA
|
---|
339 | #define alloca __builtin_alloca
|
---|
340 | #else /* not GNU C. */
|
---|
341 | #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
|
---|
342 | #define YYSTACK_USE_ALLOCA
|
---|
343 | #include <alloca.h>
|
---|
344 | #else /* not sparc */
|
---|
345 | /* We think this test detects Watcom and Microsoft C. */
|
---|
346 | /* This used to test MSDOS, but that is a bad idea
|
---|
347 | since that symbol is in the user namespace. */
|
---|
348 | #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
|
---|
349 | #if 0 /* No need for malloc.h, which pollutes the namespace;
|
---|
350 | instead, just don't use alloca. */
|
---|
351 | #include <malloc.h>
|
---|
352 | #endif
|
---|
353 | #else /* not MSDOS, or __TURBOC__ */
|
---|
354 | #if defined(_AIX)
|
---|
355 | /* I don't know what this was needed for, but it pollutes the namespace.
|
---|
356 | So I turned it off. rms, 2 May 1997. */
|
---|
357 | /* #include <malloc.h> */
|
---|
358 | #pragma alloca
|
---|
359 | #define YYSTACK_USE_ALLOCA
|
---|
360 | #else /* not MSDOS, or __TURBOC__, or _AIX */
|
---|
361 | #if 0
|
---|
362 | #ifdef __hpux /* [email protected] says this works for HPUX 9.05 and up,
|
---|
363 | and on HPUX 10. Eventually we can turn this on. */
|
---|
364 | #define YYSTACK_USE_ALLOCA
|
---|
365 | #define alloca __builtin_alloca
|
---|
366 | #endif /* __hpux */
|
---|
367 | #endif
|
---|
368 | #endif /* not _AIX */
|
---|
369 | #endif /* not MSDOS, or __TURBOC__ */
|
---|
370 | #endif /* not sparc */
|
---|
371 | #endif /* not GNU C */
|
---|
372 | #endif /* alloca not defined */
|
---|
373 | #endif /* YYSTACK_USE_ALLOCA not defined */
|
---|
374 |
|
---|
375 | #ifdef YYSTACK_USE_ALLOCA
|
---|
376 | #define YYSTACK_ALLOC alloca
|
---|
377 | #else
|
---|
378 | #define YYSTACK_ALLOC malloc
|
---|
379 | #endif
|
---|
380 |
|
---|
381 | /* Note: there must be only one dollar sign in this file.
|
---|
382 | It is replaced by the list of actions, each action
|
---|
383 | as one case of the switch. */
|
---|
384 |
|
---|
385 | #define yyerrok (yyerrstatus = 0)
|
---|
386 | #define yyclearin (yychar = YYEMPTY)
|
---|
387 | #define YYEMPTY -2
|
---|
388 | #define YYEOF 0
|
---|
389 | #define YYACCEPT goto yyacceptlab
|
---|
390 | #define YYABORT goto yyabortlab
|
---|
391 | #define YYERROR goto yyerrlab1
|
---|
392 | /* Like YYERROR except do call yyerror.
|
---|
393 | This remains here temporarily to ease the
|
---|
394 | transition to the new meaning of YYERROR, for GCC.
|
---|
395 | Once GCC version 2 has supplanted version 1, this can go. */
|
---|
396 | #define YYFAIL goto yyerrlab
|
---|
397 | #define YYRECOVERING() (!!yyerrstatus)
|
---|
398 | #define YYBACKUP(token, value) \
|
---|
399 | do \
|
---|
400 | if (yychar == YYEMPTY && yylen == 1) \
|
---|
401 | { yychar = (token), yylval = (value); \
|
---|
402 | yychar1 = YYTRANSLATE (yychar); \
|
---|
403 | YYPOPSTACK; \
|
---|
404 | goto yybackup; \
|
---|
405 | } \
|
---|
406 | else \
|
---|
407 | { yyerror ("syntax error: cannot back up"); YYERROR; } \
|
---|
408 | while (0)
|
---|
409 |
|
---|
410 | #define YYTERROR 1
|
---|
411 | #define YYERRCODE 256
|
---|
412 |
|
---|
413 | #ifndef YYPURE
|
---|
414 | #define YYLEX yylex()
|
---|
415 | #endif
|
---|
416 |
|
---|
417 | #ifdef YYPURE
|
---|
418 | #ifdef YYLSP_NEEDED
|
---|
419 | #ifdef YYLEX_PARAM
|
---|
420 | #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
|
---|
421 | #else
|
---|
422 | #define YYLEX yylex(&yylval, &yylloc)
|
---|
423 | #endif
|
---|
424 | #else /* not YYLSP_NEEDED */
|
---|
425 | #ifdef YYLEX_PARAM
|
---|
426 | #define YYLEX yylex(&yylval, YYLEX_PARAM)
|
---|
427 | #else
|
---|
428 | #define YYLEX yylex(&yylval)
|
---|
429 | #endif
|
---|
430 | #endif /* not YYLSP_NEEDED */
|
---|
431 | #endif
|
---|
432 |
|
---|
433 | /* If nonreentrant, generate the variables here */
|
---|
434 |
|
---|
435 | #ifndef YYPURE
|
---|
436 |
|
---|
437 | int yychar; /* the lookahead symbol */
|
---|
438 | YYSTYPE yylval; /* the semantic value of the */
|
---|
439 | /* lookahead symbol */
|
---|
440 |
|
---|
441 | #ifdef YYLSP_NEEDED
|
---|
442 | YYLTYPE yylloc; /* location data for the lookahead */
|
---|
443 | /* symbol */
|
---|
444 | #endif
|
---|
445 |
|
---|
446 | int yynerrs; /* number of parse errors so far */
|
---|
447 | #endif /* not YYPURE */
|
---|
448 |
|
---|
449 | #if YYDEBUG != 0
|
---|
450 | int yydebug; /* nonzero means print parse trace */
|
---|
451 | /* Since this is uninitialized, it does not stop multiple parsers
|
---|
452 | from coexisting. */
|
---|
453 | #endif
|
---|
454 |
|
---|
455 | /* YYINITDEPTH indicates the initial size of the parser's stacks */
|
---|
456 |
|
---|
457 | #ifndef YYINITDEPTH
|
---|
458 | #define YYINITDEPTH 200
|
---|
459 | #endif
|
---|
460 |
|
---|
461 | /* YYMAXDEPTH is the maximum size the stacks can grow to
|
---|
462 | (effective only if the built-in stack extension method is used). */
|
---|
463 |
|
---|
464 | #if YYMAXDEPTH == 0
|
---|
465 | #undef YYMAXDEPTH
|
---|
466 | #endif
|
---|
467 |
|
---|
468 | #ifndef YYMAXDEPTH
|
---|
469 | #define YYMAXDEPTH 10000
|
---|
470 | #endif
|
---|
471 | |
---|
472 |
|
---|
473 | /* Define __yy_memcpy. Note that the size argument
|
---|
474 | should be passed with type unsigned int, because that is what the non-GCC
|
---|
475 | definitions require. With GCC, __builtin_memcpy takes an arg
|
---|
476 | of type size_t, but it can handle unsigned int. */
|
---|
477 |
|
---|
478 | #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
|
---|
479 | #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
|
---|
480 | #else /* not GNU C or C++ */
|
---|
481 | #ifndef __cplusplus
|
---|
482 |
|
---|
483 | /* This is the most reliable way to avoid incompatibilities
|
---|
484 | in available built-in functions on various systems. */
|
---|
485 | static void
|
---|
486 | __yy_memcpy (to, from, count)
|
---|
487 | char *to;
|
---|
488 | char *from;
|
---|
489 | unsigned int count;
|
---|
490 | {
|
---|
491 | register char *f = from;
|
---|
492 | register char *t = to;
|
---|
493 | register int i = count;
|
---|
494 |
|
---|
495 | while (i-- > 0)
|
---|
496 | *t++ = *f++;
|
---|
497 | }
|
---|
498 |
|
---|
499 | #else /* __cplusplus */
|
---|
500 |
|
---|
501 | /* This is the most reliable way to avoid incompatibilities
|
---|
502 | in available built-in functions on various systems. */
|
---|
503 | static void
|
---|
504 | __yy_memcpy (char *to, char *from, unsigned int count)
|
---|
505 | {
|
---|
506 | register char *t = to;
|
---|
507 | register char *f = from;
|
---|
508 | register int i = count;
|
---|
509 |
|
---|
510 | while (i-- > 0)
|
---|
511 | *t++ = *f++;
|
---|
512 | }
|
---|
513 |
|
---|
514 | #endif
|
---|
515 | #endif
|
---|
516 | |
---|
517 |
|
---|
518 | #line 217 "/usr/local/share/bison.simple"
|
---|
519 |
|
---|
520 | /* The user can define YYPARSE_PARAM as the name of an argument to be passed
|
---|
521 | into yyparse. The argument should have type void *.
|
---|
522 | It should actually point to an object.
|
---|
523 | Grammar actions can access the variable by casting it
|
---|
524 | to the proper pointer type. */
|
---|
525 |
|
---|
526 | #ifdef YYPARSE_PARAM
|
---|
527 | #ifdef __cplusplus
|
---|
528 | #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
|
---|
529 | #define YYPARSE_PARAM_DECL
|
---|
530 | #else /* not __cplusplus */
|
---|
531 | #define YYPARSE_PARAM_ARG YYPARSE_PARAM
|
---|
532 | #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
|
---|
533 | #endif /* not __cplusplus */
|
---|
534 | #else /* not YYPARSE_PARAM */
|
---|
535 | #define YYPARSE_PARAM_ARG
|
---|
536 | #define YYPARSE_PARAM_DECL
|
---|
537 | #endif /* not YYPARSE_PARAM */
|
---|
538 |
|
---|
539 | /* Prevent warning if -Wstrict-prototypes. */
|
---|
540 | #ifdef __GNUC__
|
---|
541 | #ifdef YYPARSE_PARAM
|
---|
542 | int yyparse (void *);
|
---|
543 | #else
|
---|
544 | int yyparse (void);
|
---|
545 | #endif
|
---|
546 | #endif
|
---|
547 |
|
---|
548 | int
|
---|
549 | yyparse(YYPARSE_PARAM_ARG)
|
---|
550 | YYPARSE_PARAM_DECL
|
---|
551 | {
|
---|
552 | register int yystate;
|
---|
553 | register int yyn;
|
---|
554 | register short *yyssp;
|
---|
555 | register YYSTYPE *yyvsp;
|
---|
556 | int yyerrstatus; /* number of tokens to shift before error messages enabled */
|
---|
557 | int yychar1 = 0; /* lookahead token as an internal (translated) token number */
|
---|
558 |
|
---|
559 | short yyssa[YYINITDEPTH]; /* the state stack */
|
---|
560 | YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
|
---|
561 |
|
---|
562 | short *yyss = yyssa; /* refer to the stacks thru separate pointers */
|
---|
563 | YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
|
---|
564 |
|
---|
565 | #ifdef YYLSP_NEEDED
|
---|
566 | YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
|
---|
567 | YYLTYPE *yyls = yylsa;
|
---|
568 | YYLTYPE *yylsp;
|
---|
569 |
|
---|
570 | #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
|
---|
571 | #else
|
---|
572 | #define YYPOPSTACK (yyvsp--, yyssp--)
|
---|
573 | #endif
|
---|
574 |
|
---|
575 | int yystacksize = YYINITDEPTH;
|
---|
576 | int yyfree_stacks = 0;
|
---|
577 |
|
---|
578 | #ifdef YYPURE
|
---|
579 | int yychar;
|
---|
580 | YYSTYPE yylval;
|
---|
581 | int yynerrs;
|
---|
582 | #ifdef YYLSP_NEEDED
|
---|
583 | YYLTYPE yylloc;
|
---|
584 | #endif
|
---|
585 | #endif
|
---|
586 |
|
---|
587 | YYSTYPE yyval; /* the variable used to return */
|
---|
588 | /* semantic values from the action */
|
---|
589 | /* routines */
|
---|
590 |
|
---|
591 | int yylen;
|
---|
592 |
|
---|
593 | #if YYDEBUG != 0
|
---|
594 | if (yydebug)
|
---|
595 | fprintf(stderr, "Starting parse\n");
|
---|
596 | #endif
|
---|
597 |
|
---|
598 | yystate = 0;
|
---|
599 | yyerrstatus = 0;
|
---|
600 | yynerrs = 0;
|
---|
601 | yychar = YYEMPTY; /* Cause a token to be read. */
|
---|
602 |
|
---|
603 | /* Initialize stack pointers.
|
---|
604 | Waste one element of value and location stack
|
---|
605 | so that they stay on the same level as the state stack.
|
---|
606 | The wasted elements are never initialized. */
|
---|
607 |
|
---|
608 | yyssp = yyss - 1;
|
---|
609 | yyvsp = yyvs;
|
---|
610 | #ifdef YYLSP_NEEDED
|
---|
611 | yylsp = yyls;
|
---|
612 | #endif
|
---|
613 |
|
---|
614 | /* Push a new state, which is found in yystate . */
|
---|
615 | /* In all cases, when you get here, the value and location stacks
|
---|
616 | have just been pushed. so pushing a state here evens the stacks. */
|
---|
617 | yynewstate:
|
---|
618 |
|
---|
619 | *++yyssp = yystate;
|
---|
620 |
|
---|
621 | if (yyssp >= yyss + yystacksize - 1)
|
---|
622 | {
|
---|
623 | /* Give user a chance to reallocate the stack */
|
---|
624 | /* Use copies of these so that the &'s don't force the real ones into memory. */
|
---|
625 | YYSTYPE *yyvs1 = yyvs;
|
---|
626 | short *yyss1 = yyss;
|
---|
627 | #ifdef YYLSP_NEEDED
|
---|
628 | YYLTYPE *yyls1 = yyls;
|
---|
629 | #endif
|
---|
630 |
|
---|
631 | /* Get the current used size of the three stacks, in elements. */
|
---|
632 | int size = yyssp - yyss + 1;
|
---|
633 |
|
---|
634 | #ifdef yyoverflow
|
---|
635 | /* Each stack pointer address is followed by the size of
|
---|
636 | the data in use in that stack, in bytes. */
|
---|
637 | #ifdef YYLSP_NEEDED
|
---|
638 | /* This used to be a conditional around just the two extra args,
|
---|
639 | but that might be undefined if yyoverflow is a macro. */
|
---|
640 | yyoverflow("parser stack overflow",
|
---|
641 | &yyss1, size * sizeof (*yyssp),
|
---|
642 | &yyvs1, size * sizeof (*yyvsp),
|
---|
643 | &yyls1, size * sizeof (*yylsp),
|
---|
644 | &yystacksize);
|
---|
645 | #else
|
---|
646 | yyoverflow("parser stack overflow",
|
---|
647 | &yyss1, size * sizeof (*yyssp),
|
---|
648 | &yyvs1, size * sizeof (*yyvsp),
|
---|
649 | &yystacksize);
|
---|
650 | #endif
|
---|
651 |
|
---|
652 | yyss = yyss1; yyvs = yyvs1;
|
---|
653 | #ifdef YYLSP_NEEDED
|
---|
654 | yyls = yyls1;
|
---|
655 | #endif
|
---|
656 | #else /* no yyoverflow */
|
---|
657 | /* Extend the stack our own way. */
|
---|
658 | if (yystacksize >= YYMAXDEPTH)
|
---|
659 | {
|
---|
660 | yyerror("parser stack overflow");
|
---|
661 | if (yyfree_stacks)
|
---|
662 | {
|
---|
663 | free (yyss);
|
---|
664 | free (yyvs);
|
---|
665 | #ifdef YYLSP_NEEDED
|
---|
666 | free (yyls);
|
---|
667 | #endif
|
---|
668 | }
|
---|
669 | return 2;
|
---|
670 | }
|
---|
671 | yystacksize *= 2;
|
---|
672 | if (yystacksize > YYMAXDEPTH)
|
---|
673 | yystacksize = YYMAXDEPTH;
|
---|
674 | #ifndef YYSTACK_USE_ALLOCA
|
---|
675 | yyfree_stacks = 1;
|
---|
676 | #endif
|
---|
677 | yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
|
---|
678 | __yy_memcpy ((char *)yyss, (char *)yyss1,
|
---|
679 | size * (unsigned int) sizeof (*yyssp));
|
---|
680 | yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
|
---|
681 | __yy_memcpy ((char *)yyvs, (char *)yyvs1,
|
---|
682 | size * (unsigned int) sizeof (*yyvsp));
|
---|
683 | #ifdef YYLSP_NEEDED
|
---|
684 | yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
|
---|
685 | __yy_memcpy ((char *)yyls, (char *)yyls1,
|
---|
686 | size * (unsigned int) sizeof (*yylsp));
|
---|
687 | #endif
|
---|
688 | #endif /* no yyoverflow */
|
---|
689 |
|
---|
690 | yyssp = yyss + size - 1;
|
---|
691 | yyvsp = yyvs + size - 1;
|
---|
692 | #ifdef YYLSP_NEEDED
|
---|
693 | yylsp = yyls + size - 1;
|
---|
694 | #endif
|
---|
695 |
|
---|
696 | #if YYDEBUG != 0
|
---|
697 | if (yydebug)
|
---|
698 | fprintf(stderr, "Stack size increased to %d\n", yystacksize);
|
---|
699 | #endif
|
---|
700 |
|
---|
701 | if (yyssp >= yyss + yystacksize - 1)
|
---|
702 | YYABORT;
|
---|
703 | }
|
---|
704 |
|
---|
705 | #if YYDEBUG != 0
|
---|
706 | if (yydebug)
|
---|
707 | fprintf(stderr, "Entering state %d\n", yystate);
|
---|
708 | #endif
|
---|
709 |
|
---|
710 | goto yybackup;
|
---|
711 | yybackup:
|
---|
712 |
|
---|
713 | /* Do appropriate processing given the current state. */
|
---|
714 | /* Read a lookahead token if we need one and don't already have one. */
|
---|
715 | /* yyresume: */
|
---|
716 |
|
---|
717 | /* First try to decide what to do without reference to lookahead token. */
|
---|
718 |
|
---|
719 | yyn = yypact[yystate];
|
---|
720 | if (yyn == YYFLAG)
|
---|
721 | goto yydefault;
|
---|
722 |
|
---|
723 | /* Not known => get a lookahead token if don't already have one. */
|
---|
724 |
|
---|
725 | /* yychar is either YYEMPTY or YYEOF
|
---|
726 | or a valid token in external form. */
|
---|
727 |
|
---|
728 | if (yychar == YYEMPTY)
|
---|
729 | {
|
---|
730 | #if YYDEBUG != 0
|
---|
731 | if (yydebug)
|
---|
732 | fprintf(stderr, "Reading a token: ");
|
---|
733 | #endif
|
---|
734 | yychar = YYLEX;
|
---|
735 | }
|
---|
736 |
|
---|
737 | /* Convert token to internal form (in yychar1) for indexing tables with */
|
---|
738 |
|
---|
739 | if (yychar <= 0) /* This means end of input. */
|
---|
740 | {
|
---|
741 | yychar1 = 0;
|
---|
742 | yychar = YYEOF; /* Don't call YYLEX any more */
|
---|
743 |
|
---|
744 | #if YYDEBUG != 0
|
---|
745 | if (yydebug)
|
---|
746 | fprintf(stderr, "Now at end of input.\n");
|
---|
747 | #endif
|
---|
748 | }
|
---|
749 | else
|
---|
750 | {
|
---|
751 | yychar1 = YYTRANSLATE(yychar);
|
---|
752 |
|
---|
753 | #if YYDEBUG != 0
|
---|
754 | if (yydebug)
|
---|
755 | {
|
---|
756 | fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
|
---|
757 | /* Give the individual parser a way to print the precise meaning
|
---|
758 | of a token, for further debugging info. */
|
---|
759 | #ifdef YYPRINT
|
---|
760 | YYPRINT (stderr, yychar, yylval);
|
---|
761 | #endif
|
---|
762 | fprintf (stderr, ")\n");
|
---|
763 | }
|
---|
764 | #endif
|
---|
765 | }
|
---|
766 |
|
---|
767 | yyn += yychar1;
|
---|
768 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
|
---|
769 | goto yydefault;
|
---|
770 |
|
---|
771 | yyn = yytable[yyn];
|
---|
772 |
|
---|
773 | /* yyn is what to do for this token type in this state.
|
---|
774 | Negative => reduce, -yyn is rule number.
|
---|
775 | Positive => shift, yyn is new state.
|
---|
776 | New state is final state => don't bother to shift,
|
---|
777 | just return success.
|
---|
778 | 0, or most negative number => error. */
|
---|
779 |
|
---|
780 | if (yyn < 0)
|
---|
781 | {
|
---|
782 | if (yyn == YYFLAG)
|
---|
783 | goto yyerrlab;
|
---|
784 | yyn = -yyn;
|
---|
785 | goto yyreduce;
|
---|
786 | }
|
---|
787 | else if (yyn == 0)
|
---|
788 | goto yyerrlab;
|
---|
789 |
|
---|
790 | if (yyn == YYFINAL)
|
---|
791 | YYACCEPT;
|
---|
792 |
|
---|
793 | /* Shift the lookahead token. */
|
---|
794 |
|
---|
795 | #if YYDEBUG != 0
|
---|
796 | if (yydebug)
|
---|
797 | fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
|
---|
798 | #endif
|
---|
799 |
|
---|
800 | /* Discard the token being shifted unless it is eof. */
|
---|
801 | if (yychar != YYEOF)
|
---|
802 | yychar = YYEMPTY;
|
---|
803 |
|
---|
804 | *++yyvsp = yylval;
|
---|
805 | #ifdef YYLSP_NEEDED
|
---|
806 | *++yylsp = yylloc;
|
---|
807 | #endif
|
---|
808 |
|
---|
809 | /* count tokens shifted since error; after three, turn off error status. */
|
---|
810 | if (yyerrstatus) yyerrstatus--;
|
---|
811 |
|
---|
812 | yystate = yyn;
|
---|
813 | goto yynewstate;
|
---|
814 |
|
---|
815 | /* Do the default action for the current state. */
|
---|
816 | yydefault:
|
---|
817 |
|
---|
818 | yyn = yydefact[yystate];
|
---|
819 | if (yyn == 0)
|
---|
820 | goto yyerrlab;
|
---|
821 |
|
---|
822 | /* Do a reduction. yyn is the number of a rule to reduce with. */
|
---|
823 | yyreduce:
|
---|
824 | yylen = yyr2[yyn];
|
---|
825 | if (yylen > 0)
|
---|
826 | yyval = yyvsp[1-yylen]; /* implement default value of the action */
|
---|
827 |
|
---|
828 | #if YYDEBUG != 0
|
---|
829 | if (yydebug)
|
---|
830 | {
|
---|
831 | int i;
|
---|
832 |
|
---|
833 | fprintf (stderr, "Reducing via rule %d (line %d), ",
|
---|
834 | yyn, yyrline[yyn]);
|
---|
835 |
|
---|
836 | /* Print the symbols being reduced, and their result. */
|
---|
837 | for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
|
---|
838 | fprintf (stderr, "%s ", yytname[yyrhs[i]]);
|
---|
839 | fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
|
---|
840 | }
|
---|
841 | #endif
|
---|
842 |
|
---|
843 |
|
---|
844 | switch (yyn) {
|
---|
845 |
|
---|
846 | case 1:
|
---|
847 | #line 175 "plural.y"
|
---|
848 | {
|
---|
849 | if (yyvsp[0].exp == NULL)
|
---|
850 | YYABORT;
|
---|
851 | ((struct parse_args *) arg)->res = yyvsp[0].exp;
|
---|
852 | ;
|
---|
853 | break;}
|
---|
854 | case 2:
|
---|
855 | #line 183 "plural.y"
|
---|
856 | {
|
---|
857 | yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp);
|
---|
858 | ;
|
---|
859 | break;}
|
---|
860 | case 3:
|
---|
861 | #line 187 "plural.y"
|
---|
862 | {
|
---|
863 | yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp);
|
---|
864 | ;
|
---|
865 | break;}
|
---|
866 | case 4:
|
---|
867 | #line 191 "plural.y"
|
---|
868 | {
|
---|
869 | yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp);
|
---|
870 | ;
|
---|
871 | break;}
|
---|
872 | case 5:
|
---|
873 | #line 195 "plural.y"
|
---|
874 | {
|
---|
875 | yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
|
---|
876 | ;
|
---|
877 | break;}
|
---|
878 | case 6:
|
---|
879 | #line 199 "plural.y"
|
---|
880 | {
|
---|
881 | yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
|
---|
882 | ;
|
---|
883 | break;}
|
---|
884 | case 7:
|
---|
885 | #line 203 "plural.y"
|
---|
886 | {
|
---|
887 | yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
|
---|
888 | ;
|
---|
889 | break;}
|
---|
890 | case 8:
|
---|
891 | #line 207 "plural.y"
|
---|
892 | {
|
---|
893 | yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
|
---|
894 | ;
|
---|
895 | break;}
|
---|
896 | case 9:
|
---|
897 | #line 211 "plural.y"
|
---|
898 | {
|
---|
899 | yyval.exp = new_exp_1 (lnot, yyvsp[0].exp);
|
---|
900 | ;
|
---|
901 | break;}
|
---|
902 | case 10:
|
---|
903 | #line 215 "plural.y"
|
---|
904 | {
|
---|
905 | yyval.exp = new_exp_0 (var);
|
---|
906 | ;
|
---|
907 | break;}
|
---|
908 | case 11:
|
---|
909 | #line 219 "plural.y"
|
---|
910 | {
|
---|
911 | if ((yyval.exp = new_exp_0 (num)) != NULL)
|
---|
912 | yyval.exp->val.num = yyvsp[0].num;
|
---|
913 | ;
|
---|
914 | break;}
|
---|
915 | case 12:
|
---|
916 | #line 224 "plural.y"
|
---|
917 | {
|
---|
918 | yyval.exp = yyvsp[-1].exp;
|
---|
919 | ;
|
---|
920 | break;}
|
---|
921 | }
|
---|
922 | /* the action file gets copied in in place of this dollarsign */
|
---|
923 | #line 543 "/usr/local/share/bison.simple"
|
---|
924 | |
---|
925 |
|
---|
926 | yyvsp -= yylen;
|
---|
927 | yyssp -= yylen;
|
---|
928 | #ifdef YYLSP_NEEDED
|
---|
929 | yylsp -= yylen;
|
---|
930 | #endif
|
---|
931 |
|
---|
932 | #if YYDEBUG != 0
|
---|
933 | if (yydebug)
|
---|
934 | {
|
---|
935 | short *ssp1 = yyss - 1;
|
---|
936 | fprintf (stderr, "state stack now");
|
---|
937 | while (ssp1 != yyssp)
|
---|
938 | fprintf (stderr, " %d", *++ssp1);
|
---|
939 | fprintf (stderr, "\n");
|
---|
940 | }
|
---|
941 | #endif
|
---|
942 |
|
---|
943 | *++yyvsp = yyval;
|
---|
944 |
|
---|
945 | #ifdef YYLSP_NEEDED
|
---|
946 | yylsp++;
|
---|
947 | if (yylen == 0)
|
---|
948 | {
|
---|
949 | yylsp->first_line = yylloc.first_line;
|
---|
950 | yylsp->first_column = yylloc.first_column;
|
---|
951 | yylsp->last_line = (yylsp-1)->last_line;
|
---|
952 | yylsp->last_column = (yylsp-1)->last_column;
|
---|
953 | yylsp->text = 0;
|
---|
954 | }
|
---|
955 | else
|
---|
956 | {
|
---|
957 | yylsp->last_line = (yylsp+yylen-1)->last_line;
|
---|
958 | yylsp->last_column = (yylsp+yylen-1)->last_column;
|
---|
959 | }
|
---|
960 | #endif
|
---|
961 |
|
---|
962 | /* Now "shift" the result of the reduction.
|
---|
963 | Determine what state that goes to,
|
---|
964 | based on the state we popped back to
|
---|
965 | and the rule number reduced by. */
|
---|
966 |
|
---|
967 | yyn = yyr1[yyn];
|
---|
968 |
|
---|
969 | yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
|
---|
970 | if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
|
---|
971 | yystate = yytable[yystate];
|
---|
972 | else
|
---|
973 | yystate = yydefgoto[yyn - YYNTBASE];
|
---|
974 |
|
---|
975 | goto yynewstate;
|
---|
976 |
|
---|
977 | yyerrlab: /* here on detecting error */
|
---|
978 |
|
---|
979 | if (! yyerrstatus)
|
---|
980 | /* If not already recovering from an error, report this error. */
|
---|
981 | {
|
---|
982 | ++yynerrs;
|
---|
983 |
|
---|
984 | #ifdef YYERROR_VERBOSE
|
---|
985 | yyn = yypact[yystate];
|
---|
986 |
|
---|
987 | if (yyn > YYFLAG && yyn < YYLAST)
|
---|
988 | {
|
---|
989 | int size = 0;
|
---|
990 | char *msg;
|
---|
991 | int x, count;
|
---|
992 |
|
---|
993 | count = 0;
|
---|
994 | /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
|
---|
995 | for (x = (yyn < 0 ? -yyn : 0);
|
---|
996 | x < (sizeof(yytname) / sizeof(char *)); x++)
|
---|
997 | if (yycheck[x + yyn] == x)
|
---|
998 | size += strlen(yytname[x]) + 15, count++;
|
---|
999 | msg = (char *) malloc(size + 15);
|
---|
1000 | if (msg != 0)
|
---|
1001 | {
|
---|
1002 | strcpy(msg, "parse error");
|
---|
1003 |
|
---|
1004 | if (count < 5)
|
---|
1005 | {
|
---|
1006 | count = 0;
|
---|
1007 | for (x = (yyn < 0 ? -yyn : 0);
|
---|
1008 | x < (sizeof(yytname) / sizeof(char *)); x++)
|
---|
1009 | if (yycheck[x + yyn] == x)
|
---|
1010 | {
|
---|
1011 | strcat(msg, count == 0 ? ", expecting `" : " or `");
|
---|
1012 | strcat(msg, yytname[x]);
|
---|
1013 | strcat(msg, "'");
|
---|
1014 | count++;
|
---|
1015 | }
|
---|
1016 | }
|
---|
1017 | yyerror(msg);
|
---|
1018 | free(msg);
|
---|
1019 | }
|
---|
1020 | else
|
---|
1021 | yyerror ("parse error; also virtual memory exceeded");
|
---|
1022 | }
|
---|
1023 | else
|
---|
1024 | #endif /* YYERROR_VERBOSE */
|
---|
1025 | yyerror("parse error");
|
---|
1026 | }
|
---|
1027 |
|
---|
1028 | goto yyerrlab1;
|
---|
1029 | yyerrlab1: /* here on error raised explicitly by an action */
|
---|
1030 |
|
---|
1031 | if (yyerrstatus == 3)
|
---|
1032 | {
|
---|
1033 | /* if just tried and failed to reuse lookahead token after an error, discard it. */
|
---|
1034 |
|
---|
1035 | /* return failure if at end of input */
|
---|
1036 | if (yychar == YYEOF)
|
---|
1037 | YYABORT;
|
---|
1038 |
|
---|
1039 | #if YYDEBUG != 0
|
---|
1040 | if (yydebug)
|
---|
1041 | fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
|
---|
1042 | #endif
|
---|
1043 |
|
---|
1044 | yychar = YYEMPTY;
|
---|
1045 | }
|
---|
1046 |
|
---|
1047 | /* Else will try to reuse lookahead token
|
---|
1048 | after shifting the error token. */
|
---|
1049 |
|
---|
1050 | yyerrstatus = 3; /* Each real token shifted decrements this */
|
---|
1051 |
|
---|
1052 | goto yyerrhandle;
|
---|
1053 |
|
---|
1054 | yyerrdefault: /* current state does not do anything special for the error token. */
|
---|
1055 |
|
---|
1056 | #if 0
|
---|
1057 | /* This is wrong; only states that explicitly want error tokens
|
---|
1058 | should shift them. */
|
---|
1059 | yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
|
---|
1060 | if (yyn) goto yydefault;
|
---|
1061 | #endif
|
---|
1062 |
|
---|
1063 | yyerrpop: /* pop the current state because it cannot handle the error token */
|
---|
1064 |
|
---|
1065 | if (yyssp == yyss) YYABORT;
|
---|
1066 | yyvsp--;
|
---|
1067 | yystate = *--yyssp;
|
---|
1068 | #ifdef YYLSP_NEEDED
|
---|
1069 | yylsp--;
|
---|
1070 | #endif
|
---|
1071 |
|
---|
1072 | #if YYDEBUG != 0
|
---|
1073 | if (yydebug)
|
---|
1074 | {
|
---|
1075 | short *ssp1 = yyss - 1;
|
---|
1076 | fprintf (stderr, "Error: state stack now");
|
---|
1077 | while (ssp1 != yyssp)
|
---|
1078 | fprintf (stderr, " %d", *++ssp1);
|
---|
1079 | fprintf (stderr, "\n");
|
---|
1080 | }
|
---|
1081 | #endif
|
---|
1082 |
|
---|
1083 | yyerrhandle:
|
---|
1084 |
|
---|
1085 | yyn = yypact[yystate];
|
---|
1086 | if (yyn == YYFLAG)
|
---|
1087 | goto yyerrdefault;
|
---|
1088 |
|
---|
1089 | yyn += YYTERROR;
|
---|
1090 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
|
---|
1091 | goto yyerrdefault;
|
---|
1092 |
|
---|
1093 | yyn = yytable[yyn];
|
---|
1094 | if (yyn < 0)
|
---|
1095 | {
|
---|
1096 | if (yyn == YYFLAG)
|
---|
1097 | goto yyerrpop;
|
---|
1098 | yyn = -yyn;
|
---|
1099 | goto yyreduce;
|
---|
1100 | }
|
---|
1101 | else if (yyn == 0)
|
---|
1102 | goto yyerrpop;
|
---|
1103 |
|
---|
1104 | if (yyn == YYFINAL)
|
---|
1105 | YYACCEPT;
|
---|
1106 |
|
---|
1107 | #if YYDEBUG != 0
|
---|
1108 | if (yydebug)
|
---|
1109 | fprintf(stderr, "Shifting error token, ");
|
---|
1110 | #endif
|
---|
1111 |
|
---|
1112 | *++yyvsp = yylval;
|
---|
1113 | #ifdef YYLSP_NEEDED
|
---|
1114 | *++yylsp = yylloc;
|
---|
1115 | #endif
|
---|
1116 |
|
---|
1117 | yystate = yyn;
|
---|
1118 | goto yynewstate;
|
---|
1119 |
|
---|
1120 | yyacceptlab:
|
---|
1121 | /* YYACCEPT comes here. */
|
---|
1122 | if (yyfree_stacks)
|
---|
1123 | {
|
---|
1124 | free (yyss);
|
---|
1125 | free (yyvs);
|
---|
1126 | #ifdef YYLSP_NEEDED
|
---|
1127 | free (yyls);
|
---|
1128 | #endif
|
---|
1129 | }
|
---|
1130 | return 0;
|
---|
1131 |
|
---|
1132 | yyabortlab:
|
---|
1133 | /* YYABORT comes here. */
|
---|
1134 | if (yyfree_stacks)
|
---|
1135 | {
|
---|
1136 | free (yyss);
|
---|
1137 | free (yyvs);
|
---|
1138 | #ifdef YYLSP_NEEDED
|
---|
1139 | free (yyls);
|
---|
1140 | #endif
|
---|
1141 | }
|
---|
1142 | return 1;
|
---|
1143 | }
|
---|
1144 | #line 229 "plural.y"
|
---|
1145 |
|
---|
1146 |
|
---|
1147 | void
|
---|
1148 | internal_function
|
---|
1149 | FREE_EXPRESSION (exp)
|
---|
1150 | struct expression *exp;
|
---|
1151 | {
|
---|
1152 | if (exp == NULL)
|
---|
1153 | return;
|
---|
1154 |
|
---|
1155 | /* Handle the recursive case. */
|
---|
1156 | switch (exp->nargs)
|
---|
1157 | {
|
---|
1158 | case 3:
|
---|
1159 | FREE_EXPRESSION (exp->val.args[2]);
|
---|
1160 | /* FALLTHROUGH */
|
---|
1161 | case 2:
|
---|
1162 | FREE_EXPRESSION (exp->val.args[1]);
|
---|
1163 | /* FALLTHROUGH */
|
---|
1164 | case 1:
|
---|
1165 | FREE_EXPRESSION (exp->val.args[0]);
|
---|
1166 | /* FALLTHROUGH */
|
---|
1167 | default:
|
---|
1168 | break;
|
---|
1169 | }
|
---|
1170 |
|
---|
1171 | free (exp);
|
---|
1172 | }
|
---|
1173 |
|
---|
1174 |
|
---|
1175 | static int
|
---|
1176 | yylex (lval, pexp)
|
---|
1177 | YYSTYPE *lval;
|
---|
1178 | const char **pexp;
|
---|
1179 | {
|
---|
1180 | const char *exp = *pexp;
|
---|
1181 | int result;
|
---|
1182 |
|
---|
1183 | while (1)
|
---|
1184 | {
|
---|
1185 | if (exp[0] == '\0')
|
---|
1186 | {
|
---|
1187 | *pexp = exp;
|
---|
1188 | return YYEOF;
|
---|
1189 | }
|
---|
1190 |
|
---|
1191 | if (exp[0] != ' ' && exp[0] != '\t')
|
---|
1192 | break;
|
---|
1193 |
|
---|
1194 | ++exp;
|
---|
1195 | }
|
---|
1196 |
|
---|
1197 | result = *exp++;
|
---|
1198 | switch (result)
|
---|
1199 | {
|
---|
1200 | case '0': case '1': case '2': case '3': case '4':
|
---|
1201 | case '5': case '6': case '7': case '8': case '9':
|
---|
1202 | {
|
---|
1203 | unsigned long int n = result - '0';
|
---|
1204 | while (exp[0] >= '0' && exp[0] <= '9')
|
---|
1205 | {
|
---|
1206 | n *= 10;
|
---|
1207 | n += exp[0] - '0';
|
---|
1208 | ++exp;
|
---|
1209 | }
|
---|
1210 | lval->num = n;
|
---|
1211 | result = NUMBER;
|
---|
1212 | }
|
---|
1213 | break;
|
---|
1214 |
|
---|
1215 | case '=':
|
---|
1216 | if (exp[0] == '=')
|
---|
1217 | {
|
---|
1218 | ++exp;
|
---|
1219 | lval->op = equal;
|
---|
1220 | result = EQUOP2;
|
---|
1221 | }
|
---|
1222 | else
|
---|
1223 | result = YYERRCODE;
|
---|
1224 | break;
|
---|
1225 |
|
---|
1226 | case '!':
|
---|
1227 | if (exp[0] == '=')
|
---|
1228 | {
|
---|
1229 | ++exp;
|
---|
1230 | lval->op = not_equal;
|
---|
1231 | result = EQUOP2;
|
---|
1232 | }
|
---|
1233 | break;
|
---|
1234 |
|
---|
1235 | case '&':
|
---|
1236 | case '|':
|
---|
1237 | if (exp[0] == result)
|
---|
1238 | ++exp;
|
---|
1239 | else
|
---|
1240 | result = YYERRCODE;
|
---|
1241 | break;
|
---|
1242 |
|
---|
1243 | case '<':
|
---|
1244 | if (exp[0] == '=')
|
---|
1245 | {
|
---|
1246 | ++exp;
|
---|
1247 | lval->op = less_or_equal;
|
---|
1248 | }
|
---|
1249 | else
|
---|
1250 | lval->op = less_than;
|
---|
1251 | result = CMPOP2;
|
---|
1252 | break;
|
---|
1253 |
|
---|
1254 | case '>':
|
---|
1255 | if (exp[0] == '=')
|
---|
1256 | {
|
---|
1257 | ++exp;
|
---|
1258 | lval->op = greater_or_equal;
|
---|
1259 | }
|
---|
1260 | else
|
---|
1261 | lval->op = greater_than;
|
---|
1262 | result = CMPOP2;
|
---|
1263 | break;
|
---|
1264 |
|
---|
1265 | case '*':
|
---|
1266 | lval->op = mult;
|
---|
1267 | result = MULOP2;
|
---|
1268 | break;
|
---|
1269 |
|
---|
1270 | case '/':
|
---|
1271 | lval->op = divide;
|
---|
1272 | result = MULOP2;
|
---|
1273 | break;
|
---|
1274 |
|
---|
1275 | case '%':
|
---|
1276 | lval->op = module;
|
---|
1277 | result = MULOP2;
|
---|
1278 | break;
|
---|
1279 |
|
---|
1280 | case '+':
|
---|
1281 | lval->op = plus;
|
---|
1282 | result = ADDOP2;
|
---|
1283 | break;
|
---|
1284 |
|
---|
1285 | case '-':
|
---|
1286 | lval->op = minus;
|
---|
1287 | result = ADDOP2;
|
---|
1288 | break;
|
---|
1289 |
|
---|
1290 | case 'n':
|
---|
1291 | case '?':
|
---|
1292 | case ':':
|
---|
1293 | case '(':
|
---|
1294 | case ')':
|
---|
1295 | /* Nothing, just return the character. */
|
---|
1296 | break;
|
---|
1297 |
|
---|
1298 | case ';':
|
---|
1299 | case '\n':
|
---|
1300 | case '\0':
|
---|
1301 | /* Be safe and let the user call this function again. */
|
---|
1302 | --exp;
|
---|
1303 | result = YYEOF;
|
---|
1304 | break;
|
---|
1305 |
|
---|
1306 | default:
|
---|
1307 | result = YYERRCODE;
|
---|
1308 | #if YYDEBUG != 0
|
---|
1309 | --exp;
|
---|
1310 | #endif
|
---|
1311 | break;
|
---|
1312 | }
|
---|
1313 |
|
---|
1314 | *pexp = exp;
|
---|
1315 |
|
---|
1316 | return result;
|
---|
1317 | }
|
---|
1318 |
|
---|
1319 |
|
---|
1320 | static void
|
---|
1321 | yyerror (str)
|
---|
1322 | const char *str;
|
---|
1323 | {
|
---|
1324 | /* Do nothing. We don't print error messages here. */
|
---|
1325 | }
|
---|