Rev 2714 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2714 | cejka | 1 | /* A Bison parser, made by GNU Bison 2.3. */ |
2 | |||
3 | /* Skeleton implementation for Bison's Yacc-like parsers in C |
||
4 | |||
5 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 |
||
6 | Free Software Foundation, Inc. |
||
7 | |||
8 | This program is free software; you can redistribute it and/or modify |
||
9 | it under the terms of the GNU General Public License as published by |
||
10 | the Free Software Foundation; either version 2, or (at your option) |
||
11 | any later version. |
||
12 | |||
13 | This program is distributed in the hope that it will be useful, |
||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
16 | GNU General Public License for more details. |
||
17 | |||
18 | You should have received a copy of the GNU General Public License |
||
19 | along with this program; if not, write to the Free Software |
||
20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, |
||
21 | Boston, MA 02110-1301, USA. */ |
||
22 | |||
23 | /* As a special exception, you may create a larger work that contains |
||
24 | part or all of the Bison parser skeleton and distribute that work |
||
25 | under terms of your choice, so long as that work isn't itself a |
||
26 | parser generator using the skeleton or a modified version thereof |
||
27 | as a parser skeleton. Alternatively, if you modify or redistribute |
||
28 | the parser skeleton itself, you may (at your option) remove this |
||
29 | special exception, which will cause the skeleton and the resulting |
||
30 | Bison output files to be licensed under the GNU General Public |
||
31 | License without this special exception. |
||
32 | |||
33 | This special exception was added by the Free Software Foundation in |
||
34 | version 2.2 of Bison. */ |
||
35 | |||
36 | /* C LALR(1) parser skeleton written by Richard Stallman, by |
||
37 | simplifying the original so-called "semantic" parser. */ |
||
38 | |||
39 | /* All symbols defined below should begin with yy or YY, to avoid |
||
40 | infringing on user name space. This should be done even for local |
||
41 | variables, as they might otherwise be expanded by user macros. |
||
42 | There are some unavoidable exceptions within include files to |
||
43 | define necessary library symbols; they are noted "INFRINGES ON |
||
44 | USER NAME SPACE" below. */ |
||
45 | |||
46 | /* Identify Bison output. */ |
||
47 | #define YYBISON 1 |
||
48 | |||
49 | /* Bison version. */ |
||
50 | #define YYBISON_VERSION "2.3" |
||
51 | |||
52 | /* Skeleton name. */ |
||
53 | #define YYSKELETON_NAME "yacc.c" |
||
54 | |||
55 | /* Pure parsers. */ |
||
56 | #define YYPURE 0 |
||
57 | |||
58 | /* Using locations. */ |
||
59 | #define YYLSP_NEEDED 0 |
||
60 | |||
61 | |||
62 | |||
63 | /* Tokens. */ |
||
64 | #ifndef YYTOKENTYPE |
||
65 | # define YYTOKENTYPE |
||
66 | /* Put the tokens into the symbol table, so that GDB and other debuggers |
||
67 | know about them. */ |
||
68 | enum yytokentype { |
||
69 | ARITH_NUM = 258, |
||
70 | ARITH_LPAREN = 259, |
||
71 | ARITH_RPAREN = 260, |
||
72 | ARITH_OR = 261, |
||
73 | ARITH_AND = 262, |
||
74 | ARITH_BOR = 263, |
||
75 | ARITH_BXOR = 264, |
||
76 | ARITH_BAND = 265, |
||
77 | ARITH_NE = 266, |
||
78 | ARITH_EQ = 267, |
||
79 | ARITH_LE = 268, |
||
80 | ARITH_GE = 269, |
||
81 | ARITH_GT = 270, |
||
82 | ARITH_LT = 271, |
||
83 | ARITH_RSHIFT = 272, |
||
84 | ARITH_LSHIFT = 273, |
||
85 | ARITH_SUB = 274, |
||
86 | ARITH_ADD = 275, |
||
87 | ARITH_REM = 276, |
||
88 | ARITH_DIV = 277, |
||
89 | ARITH_MUL = 278, |
||
90 | ARITH_BNOT = 279, |
||
91 | ARITH_NOT = 280, |
||
92 | ARITH_UNARYPLUS = 281, |
||
93 | ARITH_UNARYMINUS = 282 |
||
94 | }; |
||
95 | #endif |
||
96 | /* Tokens. */ |
||
97 | #define ARITH_NUM 258 |
||
98 | #define ARITH_LPAREN 259 |
||
99 | #define ARITH_RPAREN 260 |
||
100 | #define ARITH_OR 261 |
||
101 | #define ARITH_AND 262 |
||
102 | #define ARITH_BOR 263 |
||
103 | #define ARITH_BXOR 264 |
||
104 | #define ARITH_BAND 265 |
||
105 | #define ARITH_NE 266 |
||
106 | #define ARITH_EQ 267 |
||
107 | #define ARITH_LE 268 |
||
108 | #define ARITH_GE 269 |
||
109 | #define ARITH_GT 270 |
||
110 | #define ARITH_LT 271 |
||
111 | #define ARITH_RSHIFT 272 |
||
112 | #define ARITH_LSHIFT 273 |
||
113 | #define ARITH_SUB 274 |
||
114 | #define ARITH_ADD 275 |
||
115 | #define ARITH_REM 276 |
||
116 | #define ARITH_DIV 277 |
||
117 | #define ARITH_MUL 278 |
||
118 | #define ARITH_BNOT 279 |
||
119 | #define ARITH_NOT 280 |
||
120 | #define ARITH_UNARYPLUS 281 |
||
121 | #define ARITH_UNARYMINUS 282 |
||
122 | |||
123 | |||
124 | |||
125 | |||
126 | /* Copy the first part of user declarations. */ |
||
127 | #line 1 "arith.y" |
||
128 | |||
129 | /* $NetBSD: arith.y,v 1.13 1999/07/09 03:05:49 christos Exp $ */ |
||
130 | |||
131 | /*- |
||
132 | * Copyright (c) 1993 |
||
133 | * The Regents of the University of California. All rights reserved. |
||
134 | * |
||
135 | * This code is derived from software contributed to Berkeley by |
||
136 | * Kenneth Almquist. |
||
137 | * |
||
138 | * Redistribution and use in source and binary forms, with or without |
||
139 | * modification, are permitted provided that the following conditions |
||
140 | * are met: |
||
141 | * 1. Redistributions of source code must retain the above copyright |
||
142 | * notice, this list of conditions and the following disclaimer. |
||
143 | * 2. Redistributions in binary form must reproduce the above copyright |
||
144 | * notice, this list of conditions and the following disclaimer in the |
||
145 | * documentation and/or other materials provided with the distribution. |
||
146 | * 3. All advertising materials mentioning features or use of this software |
||
147 | * must display the following acknowledgement: |
||
148 | * This product includes software developed by the University of |
||
149 | * California, Berkeley and its contributors. |
||
150 | * 4. Neither the name of the University nor the names of its contributors |
||
151 | * may be used to endorse or promote products derived from this software |
||
152 | * without specific prior written permission. |
||
153 | * |
||
154 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
||
155 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||
156 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||
157 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
||
158 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||
159 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
||
160 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
||
161 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
||
162 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
||
163 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
||
164 | * SUCH DAMAGE. |
||
165 | */ |
||
166 | |||
167 | #include <sys/cdefs.h> |
||
168 | #ifndef lint |
||
169 | #if 0 |
||
170 | static char sccsid[] = "@(#)arith.y 8.3 (Berkeley) 5/4/95"; |
||
171 | #else |
||
172 | __RCSID("$NetBSD: arith.y,v 1.13 1999/07/09 03:05:49 christos Exp $"); |
||
173 | #endif |
||
174 | #endif /* not lint */ |
||
175 | |||
176 | #include <stdlib.h> |
||
177 | #include "expand.h" |
||
178 | #include "shell.h" |
||
179 | #include "error.h" |
||
180 | #include "output.h" |
||
181 | #include "memalloc.h" |
||
182 | |||
183 | const char *arith_buf, *arith_startbuf; |
||
184 | |||
185 | void yyerror (const char *); |
||
186 | int yyparse (void); |
||
187 | #ifdef TESTARITH |
||
188 | int main (int , char *[]); |
||
189 | int error (char *); |
||
190 | #endif |
||
191 | |||
192 | int |
||
193 | arith(s) |
||
194 | const char *s; |
||
195 | { |
||
196 | long result; |
||
197 | |||
198 | arith_buf = arith_startbuf = s; |
||
199 | |||
200 | INTOFF; |
||
201 | result = yyparse(); |
||
202 | arith_lex_reset(); /* reprime lex */ |
||
203 | INTON; |
||
204 | |||
205 | return (result); |
||
206 | } |
||
207 | |||
208 | |||
209 | /* |
||
210 | * The exp(1) builtin. |
||
211 | */ |
||
212 | int |
||
213 | expcmd(argc, argv) |
||
214 | int argc; |
||
215 | char **argv; |
||
216 | { |
||
217 | const char *p; |
||
218 | char *concat; |
||
219 | char **ap; |
||
220 | long i; |
||
221 | |||
222 | if (argc > 1) { |
||
223 | p = argv[1]; |
||
224 | if (argc > 2) { |
||
225 | /* |
||
226 | * concatenate arguments |
||
227 | */ |
||
228 | STARTSTACKSTR(concat); |
||
229 | ap = argv + 2; |
||
230 | for (;;) { |
||
231 | while (*p) |
||
232 | STPUTC(*p++, concat); |
||
233 | if ((p = *ap++) == NULL) |
||
234 | break; |
||
235 | STPUTC(' ', concat); |
||
236 | } |
||
237 | STPUTC('\0', concat); |
||
238 | p = grabstackstr(concat); |
||
239 | } |
||
240 | } else |
||
241 | p = ""; |
||
242 | |||
243 | i = arith(p); |
||
244 | |||
245 | out1fmt("%ld\n", i); |
||
246 | return (! i); |
||
247 | } |
||
248 | |||
249 | /*************************/ |
||
250 | #ifdef TEST_ARITH |
||
251 | #include <stdio.h> |
||
252 | main(argc, argv) |
||
253 | char *argv[]; |
||
254 | { |
||
255 | printf("%d\n", exp(argv[1])); |
||
256 | } |
||
257 | error(s) |
||
258 | char *s; |
||
259 | { |
||
260 | fprintf(stderr, "exp: %s\n", s); |
||
261 | exit(1); |
||
262 | } |
||
263 | #endif |
||
264 | |||
265 | |||
266 | /* Enabling traces. */ |
||
267 | #ifndef YYDEBUG |
||
268 | # define YYDEBUG 0 |
||
269 | #endif |
||
270 | |||
271 | /* Enabling verbose error messages. */ |
||
272 | #ifdef YYERROR_VERBOSE |
||
273 | # undef YYERROR_VERBOSE |
||
274 | # define YYERROR_VERBOSE 1 |
||
275 | #else |
||
276 | # define YYERROR_VERBOSE 0 |
||
277 | #endif |
||
278 | |||
279 | /* Enabling the token table. */ |
||
280 | #ifndef YYTOKEN_TABLE |
||
281 | # define YYTOKEN_TABLE 0 |
||
282 | #endif |
||
283 | |||
284 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED |
||
285 | typedef int YYSTYPE; |
||
286 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ |
||
287 | # define YYSTYPE_IS_DECLARED 1 |
||
288 | # define YYSTYPE_IS_TRIVIAL 1 |
||
289 | #endif |
||
290 | |||
291 | |||
292 | |||
293 | /* Copy the second part of user declarations. */ |
||
294 | |||
295 | |||
296 | /* Line 216 of yacc.c. */ |
||
297 | #line 298 "y.tab.c" |
||
298 | |||
299 | #ifdef short |
||
300 | # undef short |
||
301 | #endif |
||
302 | |||
303 | #ifdef YYTYPE_UINT8 |
||
304 | typedef YYTYPE_UINT8 yytype_uint8; |
||
305 | #else |
||
306 | typedef unsigned char yytype_uint8; |
||
307 | #endif |
||
308 | |||
309 | #ifdef YYTYPE_INT8 |
||
310 | typedef YYTYPE_INT8 yytype_int8; |
||
311 | #elif (defined __STDC__ || defined __C99__FUNC__ \ |
||
312 | || defined __cplusplus || defined _MSC_VER) |
||
313 | typedef signed char yytype_int8; |
||
314 | #else |
||
315 | typedef short int yytype_int8; |
||
316 | #endif |
||
317 | |||
318 | #ifdef YYTYPE_UINT16 |
||
319 | typedef YYTYPE_UINT16 yytype_uint16; |
||
320 | #else |
||
321 | typedef unsigned short int yytype_uint16; |
||
322 | #endif |
||
323 | |||
324 | #ifdef YYTYPE_INT16 |
||
325 | typedef YYTYPE_INT16 yytype_int16; |
||
326 | #else |
||
327 | typedef short int yytype_int16; |
||
328 | #endif |
||
329 | |||
330 | #ifndef YYSIZE_T |
||
331 | # ifdef __SIZE_TYPE__ |
||
332 | # define YYSIZE_T __SIZE_TYPE__ |
||
333 | # elif defined size_t |
||
334 | # define YYSIZE_T size_t |
||
335 | # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ |
||
336 | || defined __cplusplus || defined _MSC_VER) |
||
337 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ |
||
338 | # define YYSIZE_T size_t |
||
339 | # else |
||
340 | # define YYSIZE_T unsigned int |
||
341 | # endif |
||
342 | #endif |
||
343 | |||
344 | #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) |
||
345 | |||
346 | #ifndef YY_ |
||
347 | # if YYENABLE_NLS |
||
348 | # if ENABLE_NLS |
||
349 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ |
||
350 | # define YY_(msgid) dgettext ("bison-runtime", msgid) |
||
351 | # endif |
||
352 | # endif |
||
353 | # ifndef YY_ |
||
354 | # define YY_(msgid) msgid |
||
355 | # endif |
||
356 | #endif |
||
357 | |||
358 | /* Suppress unused-variable warnings by "using" E. */ |
||
359 | #if ! defined lint || defined __GNUC__ |
||
360 | # define YYUSE(e) ((void) (e)) |
||
361 | #else |
||
362 | # define YYUSE(e) /* empty */ |
||
363 | #endif |
||
364 | |||
365 | /* Identity function, used to suppress warnings about constant conditions. */ |
||
366 | #ifndef lint |
||
367 | # define YYID(n) (n) |
||
368 | #else |
||
369 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
||
370 | || defined __cplusplus || defined _MSC_VER) |
||
371 | static int |
||
372 | YYID (int i) |
||
373 | #else |
||
374 | static int |
||
375 | YYID (i) |
||
376 | int i; |
||
377 | #endif |
||
378 | { |
||
379 | return i; |
||
380 | } |
||
381 | #endif |
||
382 | |||
383 | #if ! defined yyoverflow || YYERROR_VERBOSE |
||
384 | |||
385 | /* The parser invokes alloca or malloc; define the necessary symbols. */ |
||
386 | |||
387 | # ifdef YYSTACK_USE_ALLOCA |
||
388 | # if YYSTACK_USE_ALLOCA |
||
389 | # ifdef __GNUC__ |
||
390 | # define YYSTACK_ALLOC __builtin_alloca |
||
391 | # elif defined __BUILTIN_VA_ARG_INCR |
||
392 | # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ |
||
393 | # elif defined _AIX |
||
394 | # define YYSTACK_ALLOC __alloca |
||
395 | # elif defined _MSC_VER |
||
396 | # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ |
||
397 | # define alloca _alloca |
||
398 | # else |
||
399 | # define YYSTACK_ALLOC alloca |
||
400 | # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ |
||
401 | || defined __cplusplus || defined _MSC_VER) |
||
402 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
||
403 | # ifndef _STDLIB_H |
||
404 | # define _STDLIB_H 1 |
||
405 | # endif |
||
406 | # endif |
||
407 | # endif |
||
408 | # endif |
||
409 | # endif |
||
410 | |||
411 | # ifdef YYSTACK_ALLOC |
||
412 | /* Pacify GCC's `empty if-body' warning. */ |
||
413 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) |
||
414 | # ifndef YYSTACK_ALLOC_MAXIMUM |
||
415 | /* The OS might guarantee only one guard page at the bottom of the stack, |
||
416 | and a page size can be as small as 4096 bytes. So we cannot safely |
||
417 | invoke alloca (N) if N exceeds 4096. Use a slightly smaller number |
||
418 | to allow for a few compiler-allocated temporary stack slots. */ |
||
419 | # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ |
||
420 | # endif |
||
421 | # else |
||
422 | # define YYSTACK_ALLOC YYMALLOC |
||
423 | # define YYSTACK_FREE YYFREE |
||
424 | # ifndef YYSTACK_ALLOC_MAXIMUM |
||
425 | # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM |
||
426 | # endif |
||
427 | # if (defined __cplusplus && ! defined _STDLIB_H \ |
||
428 | && ! ((defined YYMALLOC || defined malloc) \ |
||
429 | && (defined YYFREE || defined free))) |
||
430 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ |
||
431 | # ifndef _STDLIB_H |
||
432 | # define _STDLIB_H 1 |
||
433 | # endif |
||
434 | # endif |
||
435 | # ifndef YYMALLOC |
||
436 | # define YYMALLOC malloc |
||
437 | # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ |
||
438 | || defined __cplusplus || defined _MSC_VER) |
||
439 | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ |
||
440 | # endif |
||
441 | # endif |
||
442 | # ifndef YYFREE |
||
443 | # define YYFREE free |
||
444 | # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ |
||
445 | || defined __cplusplus || defined _MSC_VER) |
||
446 | void free (void *); /* INFRINGES ON USER NAME SPACE */ |
||
447 | # endif |
||
448 | # endif |
||
449 | # endif |
||
450 | #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ |
||
451 | |||
452 | |||
453 | #if (! defined yyoverflow \ |
||
454 | && (! defined __cplusplus \ |
||
455 | || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) |
||
456 | |||
457 | /* A type that is properly aligned for any stack member. */ |
||
458 | union yyalloc |
||
459 | { |
||
460 | yytype_int16 yyss; |
||
461 | YYSTYPE yyvs; |
||
462 | }; |
||
463 | |||
464 | /* The size of the maximum gap between one aligned stack and the next. */ |
||
465 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
||
466 | |||
467 | /* The size of an array large to enough to hold all stacks, each with |
||
468 | N elements. */ |
||
469 | # define YYSTACK_BYTES(N) \ |
||
470 | ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ |
||
471 | + YYSTACK_GAP_MAXIMUM) |
||
472 | |||
473 | /* Copy COUNT objects from FROM to TO. The source and destination do |
||
474 | not overlap. */ |
||
475 | # ifndef YYCOPY |
||
476 | # if defined __GNUC__ && 1 < __GNUC__ |
||
477 | # define YYCOPY(To, From, Count) \ |
||
478 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) |
||
479 | # else |
||
480 | # define YYCOPY(To, From, Count) \ |
||
481 | do \ |
||
482 | { \ |
||
483 | YYSIZE_T yyi; \ |
||
484 | for (yyi = 0; yyi < (Count); yyi++) \ |
||
485 | (To)[yyi] = (From)[yyi]; \ |
||
486 | } \ |
||
487 | while (YYID (0)) |
||
488 | # endif |
||
489 | # endif |
||
490 | |||
491 | /* Relocate STACK from its old location to the new one. The |
||
492 | local variables YYSIZE and YYSTACKSIZE give the old and new number of |
||
493 | elements in the stack, and YYPTR gives the new location of the |
||
494 | stack. Advance YYPTR to a properly aligned location for the next |
||
495 | stack. */ |
||
496 | # define YYSTACK_RELOCATE(Stack) \ |
||
497 | do \ |
||
498 | { \ |
||
499 | YYSIZE_T yynewbytes; \ |
||
500 | YYCOPY (&yyptr->Stack, Stack, yysize); \ |
||
501 | Stack = &yyptr->Stack; \ |
||
502 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ |
||
503 | yyptr += yynewbytes / sizeof (*yyptr); \ |
||
504 | } \ |
||
505 | while (YYID (0)) |
||
506 | |||
507 | #endif |
||
508 | |||
509 | /* YYFINAL -- State number of the termination state. */ |
||
510 | #define YYFINAL 14 |
||
511 | /* YYLAST -- Last index in YYTABLE. */ |
||
512 | #define YYLAST 170 |
||
513 | |||
514 | /* YYNTOKENS -- Number of terminals. */ |
||
515 | #define YYNTOKENS 28 |
||
516 | /* YYNNTS -- Number of nonterminals. */ |
||
517 | #define YYNNTS 3 |
||
518 | /* YYNRULES -- Number of rules. */ |
||
519 | #define YYNRULES 26 |
||
520 | /* YYNRULES -- Number of states. */ |
||
521 | #define YYNSTATES 52 |
||
522 | |||
523 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ |
||
524 | #define YYUNDEFTOK 2 |
||
525 | #define YYMAXUTOK 282 |
||
526 | |||
527 | #define YYTRANSLATE(YYX) \ |
||
528 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
||
529 | |||
530 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ |
||
531 | static const yytype_uint8 yytranslate[] = |
||
532 | { |
||
533 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
534 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
535 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
536 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
537 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
538 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
539 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
540 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
541 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
542 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
543 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
544 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
545 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
546 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
547 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
548 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
549 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
550 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
551 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
552 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
553 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
554 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
555 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
556 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
557 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
||
558 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, |
||
559 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, |
||
560 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
||
561 | 25, 26, 27 |
||
562 | }; |
||
563 | |||
564 | #if YYDEBUG |
||
565 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in |
||
566 | YYRHS. */ |
||
567 | static const yytype_uint8 yyprhs[] = |
||
568 | { |
||
569 | 0, 0, 3, 5, 9, 13, 17, 21, 25, 29, |
||
570 | 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, |
||
571 | 73, 77, 81, 84, 87, 90, 93 |
||
572 | }; |
||
573 | |||
574 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ |
||
575 | static const yytype_int8 yyrhs[] = |
||
576 | { |
||
577 | 29, 0, -1, 30, -1, 4, 30, 5, -1, 30, |
||
578 | 6, 30, -1, 30, 7, 30, -1, 30, 8, 30, |
||
579 | -1, 30, 9, 30, -1, 30, 10, 30, -1, 30, |
||
580 | 12, 30, -1, 30, 15, 30, -1, 30, 14, 30, |
||
581 | -1, 30, 16, 30, -1, 30, 13, 30, -1, 30, |
||
582 | 11, 30, -1, 30, 18, 30, -1, 30, 17, 30, |
||
583 | -1, 30, 20, 30, -1, 30, 19, 30, -1, 30, |
||
584 | 23, 30, -1, 30, 22, 30, -1, 30, 21, 30, |
||
585 | -1, 25, 30, -1, 24, 30, -1, 19, 30, -1, |
||
586 | 20, 30, -1, 3, -1 |
||
587 | }; |
||
588 | |||
589 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ |
||
590 | static const yytype_uint8 yyrline[] = |
||
591 | { |
||
592 | 0, 153, 153, 159, 160, 161, 162, 163, 164, 165, |
||
593 | 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, |
||
594 | 176, 181, 186, 187, 188, 189, 190 |
||
595 | }; |
||
596 | #endif |
||
597 | |||
598 | #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE |
||
599 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. |
||
600 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ |
||
601 | static const char *const yytname[] = |
||
602 | { |
||
603 | "$end", "error", "$undefined", "ARITH_NUM", "ARITH_LPAREN", |
||
604 | "ARITH_RPAREN", "ARITH_OR", "ARITH_AND", "ARITH_BOR", "ARITH_BXOR", |
||
605 | "ARITH_BAND", "ARITH_NE", "ARITH_EQ", "ARITH_LE", "ARITH_GE", "ARITH_GT", |
||
606 | "ARITH_LT", "ARITH_RSHIFT", "ARITH_LSHIFT", "ARITH_SUB", "ARITH_ADD", |
||
607 | "ARITH_REM", "ARITH_DIV", "ARITH_MUL", "ARITH_BNOT", "ARITH_NOT", |
||
608 | "ARITH_UNARYPLUS", "ARITH_UNARYMINUS", "$accept", "exp", "expr", 0 |
||
609 | }; |
||
610 | #endif |
||
611 | |||
612 | # ifdef YYPRINT |
||
613 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to |
||
614 | token YYLEX-NUM. */ |
||
615 | static const yytype_uint16 yytoknum[] = |
||
616 | { |
||
617 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, |
||
618 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, |
||
619 | 275, 276, 277, 278, 279, 280, 281, 282 |
||
620 | }; |
||
621 | # endif |
||
622 | |||
623 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ |
||
624 | static const yytype_uint8 yyr1[] = |
||
625 | { |
||
626 | 0, 28, 29, 30, 30, 30, 30, 30, 30, 30, |
||
627 | 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, |
||
628 | 30, 30, 30, 30, 30, 30, 30 |
||
629 | }; |
||
630 | |||
631 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ |
||
632 | static const yytype_uint8 yyr2[] = |
||
633 | { |
||
634 | 0, 2, 1, 3, 3, 3, 3, 3, 3, 3, |
||
635 | 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, |
||
636 | 3, 3, 2, 2, 2, 2, 1 |
||
637 | }; |
||
638 | |||
639 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state |
||
640 | STATE-NUM when YYTABLE doesn't specify something else to do. Zero |
||
641 | means the default is an error. */ |
||
642 | static const yytype_uint8 yydefact[] = |
||
643 | { |
||
644 | 0, 26, 0, 0, 0, 0, 0, 0, 2, 0, |
||
645 | 24, 25, 23, 22, 1, 0, 0, 0, 0, 0, |
||
646 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
||
647 | 0, 0, 0, 3, 4, 5, 6, 7, 8, 14, |
||
648 | 9, 13, 11, 10, 12, 16, 15, 18, 17, 21, |
||
649 | 20, 19 |
||
650 | }; |
||
651 | |||
652 | /* YYDEFGOTO[NTERM-NUM]. */ |
||
653 | static const yytype_int8 yydefgoto[] = |
||
654 | { |
||
655 | -1, 7, 8 |
||
656 | }; |
||
657 | |||
658 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing |
||
659 | STATE-NUM. */ |
||
660 | #define YYPACT_NINF -13 |
||
661 | static const yytype_int16 yypact[] = |
||
662 | { |
||
663 | 28, -13, 28, 28, 28, 28, 28, 12, 67, 49, |
||
664 | -13, -13, -13, -13, -13, 28, 28, 28, 28, 28, |
||
665 | 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, |
||
666 | 28, 28, 28, -13, 84, 100, 115, 23, 128, 139, |
||
667 | 139, -12, -12, -12, -12, 144, 144, 147, 147, -13, |
||
668 | -13, -13 |
||
669 | }; |
||
670 | |||
671 | /* YYPGOTO[NTERM-NUM]. */ |
||
672 | static const yytype_int8 yypgoto[] = |
||
673 | { |
||
674 | -13, -13, -2 |
||
675 | }; |
||
676 | |||
677 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If |
||
678 | positive, shift that token. If negative, reduce the rule which |
||
679 | number is the opposite. If zero, do what YYDEFACT says. |
||
680 | If YYTABLE_NINF, syntax error. */ |
||
681 | #define YYTABLE_NINF -1 |
||
682 | static const yytype_uint8 yytable[] = |
||
683 | { |
||
684 | 9, 10, 11, 12, 13, 26, 27, 28, 29, 30, |
||
685 | 31, 32, 14, 34, 35, 36, 37, 38, 39, 40, |
||
686 | 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, |
||
687 | 51, 1, 2, 19, 20, 21, 22, 23, 24, 25, |
||
688 | 26, 27, 28, 29, 30, 31, 32, 3, 4, 0, |
||
689 | 0, 0, 5, 6, 33, 15, 16, 17, 18, 19, |
||
690 | 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, |
||
691 | 30, 31, 32, 15, 16, 17, 18, 19, 20, 21, |
||
692 | 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, |
||
693 | 32, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
||
694 | 25, 26, 27, 28, 29, 30, 31, 32, 17, 18, |
||
695 | 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, |
||
696 | 29, 30, 31, 32, 18, 19, 20, 21, 22, 23, |
||
697 | 24, 25, 26, 27, 28, 29, 30, 31, 32, 20, |
||
698 | 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, |
||
699 | 31, 32, 22, 23, 24, 25, 26, 27, 28, 29, |
||
700 | 30, 31, 32, 28, 29, 30, 31, 32, 30, 31, |
||
701 | 32 |
||
702 | }; |
||
703 | |||
704 | static const yytype_int8 yycheck[] = |
||
705 | { |
||
706 | 2, 3, 4, 5, 6, 17, 18, 19, 20, 21, |
||
707 | 22, 23, 0, 15, 16, 17, 18, 19, 20, 21, |
||
708 | 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, |
||
709 | 32, 3, 4, 10, 11, 12, 13, 14, 15, 16, |
||
710 | 17, 18, 19, 20, 21, 22, 23, 19, 20, -1, |
||
711 | -1, -1, 24, 25, 5, 6, 7, 8, 9, 10, |
||
712 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
||
713 | 21, 22, 23, 6, 7, 8, 9, 10, 11, 12, |
||
714 | 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, |
||
715 | 23, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
||
716 | 16, 17, 18, 19, 20, 21, 22, 23, 8, 9, |
||
717 | 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, |
||
718 | 20, 21, 22, 23, 9, 10, 11, 12, 13, 14, |
||
719 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 11, |
||
720 | 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, |
||
721 | 22, 23, 13, 14, 15, 16, 17, 18, 19, 20, |
||
722 | 21, 22, 23, 19, 20, 21, 22, 23, 21, 22, |
||
723 | 23 |
||
724 | }; |
||
725 | |||
726 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing |
||
727 | symbol of state STATE-NUM. */ |
||
728 | static const yytype_uint8 yystos[] = |
||
729 | { |
||
730 | 0, 3, 4, 19, 20, 24, 25, 29, 30, 30, |
||
731 | 30, 30, 30, 30, 0, 6, 7, 8, 9, 10, |
||
732 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
||
733 | 21, 22, 23, 5, 30, 30, 30, 30, 30, 30, |
||
734 | 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, |
||
735 | 30, 30 |
||
736 | }; |
||
737 | |||
738 | #define yyerrok (yyerrstatus = 0) |
||
739 | #define yyclearin (yychar = YYEMPTY) |
||
740 | #define YYEMPTY (-2) |
||
741 | #define YYEOF 0 |
||
742 | |||
743 | #define YYACCEPT goto yyacceptlab |
||
744 | #define YYABORT goto yyabortlab |
||
745 | #define YYERROR goto yyerrorlab |
||
746 | |||
747 | |||
748 | /* Like YYERROR except do call yyerror. This remains here temporarily |
||
749 | to ease the transition to the new meaning of YYERROR, for GCC. |
||
750 | Once GCC version 2 has supplanted version 1, this can go. */ |
||
751 | |||
752 | #define YYFAIL goto yyerrlab |
||
753 | |||
754 | #define YYRECOVERING() (!!yyerrstatus) |
||
755 | |||
756 | #define YYBACKUP(Token, Value) \ |
||
757 | do \ |
||
758 | if (yychar == YYEMPTY && yylen == 1) \ |
||
759 | { \ |
||
760 | yychar = (Token); \ |
||
761 | yylval = (Value); \ |
||
762 | yytoken = YYTRANSLATE (yychar); \ |
||
763 | YYPOPSTACK (1); \ |
||
764 | goto yybackup; \ |
||
765 | } \ |
||
766 | else \ |
||
767 | { \ |
||
768 | yyerror (YY_("syntax error: cannot back up")); \ |
||
769 | YYERROR; \ |
||
770 | } \ |
||
771 | while (YYID (0)) |
||
772 | |||
773 | |||
774 | #define YYTERROR 1 |
||
775 | #define YYERRCODE 256 |
||
776 | |||
777 | |||
778 | /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. |
||
779 | If N is 0, then set CURRENT to the empty location which ends |
||
780 | the previous symbol: RHS[0] (always defined). */ |
||
781 | |||
782 | #define YYRHSLOC(Rhs, K) ((Rhs)[K]) |
||
783 | #ifndef YYLLOC_DEFAULT |
||
784 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ |
||
785 | do \ |
||
786 | if (YYID (N)) \ |
||
787 | { \ |
||
788 | (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ |
||
789 | (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ |
||
790 | (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ |
||
791 | (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ |
||
792 | } \ |
||
793 | else \ |
||
794 | { \ |
||
795 | (Current).first_line = (Current).last_line = \ |
||
796 | YYRHSLOC (Rhs, 0).last_line; \ |
||
797 | (Current).first_column = (Current).last_column = \ |
||
798 | YYRHSLOC (Rhs, 0).last_column; \ |
||
799 | } \ |
||
800 | while (YYID (0)) |
||
801 | #endif |
||
802 | |||
803 | |||
804 | /* YY_LOCATION_PRINT -- Print the location on the stream. |
||
805 | This macro was not mandated originally: define only if we know |
||
806 | we won't break user code: when these are the locations we know. */ |
||
807 | |||
808 | #ifndef YY_LOCATION_PRINT |
||
809 | # if YYLTYPE_IS_TRIVIAL |
||
810 | # define YY_LOCATION_PRINT(File, Loc) \ |
||
811 | fprintf (File, "%d.%d-%d.%d", \ |
||
812 | (Loc).first_line, (Loc).first_column, \ |
||
813 | (Loc).last_line, (Loc).last_column) |
||
814 | # else |
||
815 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) |
||
816 | # endif |
||
817 | #endif |
||
818 | |||
819 | |||
820 | /* YYLEX -- calling `yylex' with the right arguments. */ |
||
821 | |||
822 | #ifdef YYLEX_PARAM |
||
823 | # define YYLEX yylex (YYLEX_PARAM) |
||
824 | #else |
||
825 | # define YYLEX yylex () |
||
826 | #endif |
||
827 | |||
828 | /* Enable debugging if requested. */ |
||
829 | #if YYDEBUG |
||
830 | |||
831 | # ifndef YYFPRINTF |
||
832 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ |
||
833 | # define YYFPRINTF fprintf |
||
834 | # endif |
||
835 | |||
836 | # define YYDPRINTF(Args) \ |
||
837 | do { \ |
||
838 | if (yydebug) \ |
||
839 | YYFPRINTF Args; \ |
||
840 | } while (YYID (0)) |
||
841 | |||
842 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ |
||
843 | do { \ |
||
844 | if (yydebug) \ |
||
845 | { \ |
||
846 | YYFPRINTF (stderr, "%s ", Title); \ |
||
847 | yy_symbol_print (stderr, \ |
||
848 | Type, Value); \ |
||
849 | YYFPRINTF (stderr, "\n"); \ |
||
850 | } \ |
||
851 | } while (YYID (0)) |
||
852 | |||
853 | |||
854 | /*--------------------------------. |
||
855 | | Print this symbol on YYOUTPUT. | |
||
856 | `--------------------------------*/ |
||
857 | |||
858 | /*ARGSUSED*/ |
||
859 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
||
860 | || defined __cplusplus || defined _MSC_VER) |
||
861 | static void |
||
862 | yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) |
||
863 | #else |
||
864 | static void |
||
865 | yy_symbol_value_print (yyoutput, yytype, yyvaluep) |
||
866 | FILE *yyoutput; |
||
867 | int yytype; |
||
868 | YYSTYPE const * const yyvaluep; |
||
869 | #endif |
||
870 | { |
||
871 | if (!yyvaluep) |
||
872 | return; |
||
873 | # ifdef YYPRINT |
||
874 | if (yytype < YYNTOKENS) |
||
875 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); |
||
876 | # else |
||
877 | YYUSE (yyoutput); |
||
878 | # endif |
||
879 | switch (yytype) |
||
880 | { |
||
881 | default: |
||
882 | break; |
||
883 | } |
||
884 | } |
||
885 | |||
886 | |||
887 | /*--------------------------------. |
||
888 | | Print this symbol on YYOUTPUT. | |
||
889 | `--------------------------------*/ |
||
890 | |||
891 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
||
892 | || defined __cplusplus || defined _MSC_VER) |
||
893 | static void |
||
894 | yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) |
||
895 | #else |
||
896 | static void |
||
897 | yy_symbol_print (yyoutput, yytype, yyvaluep) |
||
898 | FILE *yyoutput; |
||
899 | int yytype; |
||
900 | YYSTYPE const * const yyvaluep; |
||
901 | #endif |
||
902 | { |
||
903 | if (yytype < YYNTOKENS) |
||
904 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); |
||
905 | else |
||
906 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); |
||
907 | |||
908 | yy_symbol_value_print (yyoutput, yytype, yyvaluep); |
||
909 | YYFPRINTF (yyoutput, ")"); |
||
910 | } |
||
911 | |||
912 | /*------------------------------------------------------------------. |
||
913 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | |
||
914 | | TOP (included). | |
||
915 | `------------------------------------------------------------------*/ |
||
916 | |||
917 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
||
918 | || defined __cplusplus || defined _MSC_VER) |
||
919 | static void |
||
920 | yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) |
||
921 | #else |
||
922 | static void |
||
923 | yy_stack_print (bottom, top) |
||
924 | yytype_int16 *bottom; |
||
925 | yytype_int16 *top; |
||
926 | #endif |
||
927 | { |
||
928 | YYFPRINTF (stderr, "Stack now"); |
||
929 | for (; bottom <= top; ++bottom) |
||
930 | YYFPRINTF (stderr, " %d", *bottom); |
||
931 | YYFPRINTF (stderr, "\n"); |
||
932 | } |
||
933 | |||
934 | # define YY_STACK_PRINT(Bottom, Top) \ |
||
935 | do { \ |
||
936 | if (yydebug) \ |
||
937 | yy_stack_print ((Bottom), (Top)); \ |
||
938 | } while (YYID (0)) |
||
939 | |||
940 | |||
941 | /*------------------------------------------------. |
||
942 | | Report that the YYRULE is going to be reduced. | |
||
943 | `------------------------------------------------*/ |
||
944 | |||
945 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
||
946 | || defined __cplusplus || defined _MSC_VER) |
||
947 | static void |
||
948 | yy_reduce_print (YYSTYPE *yyvsp, int yyrule) |
||
949 | #else |
||
950 | static void |
||
951 | yy_reduce_print (yyvsp, yyrule) |
||
952 | YYSTYPE *yyvsp; |
||
953 | int yyrule; |
||
954 | #endif |
||
955 | { |
||
956 | int yynrhs = yyr2[yyrule]; |
||
957 | int yyi; |
||
958 | unsigned long int yylno = yyrline[yyrule]; |
||
959 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", |
||
960 | yyrule - 1, yylno); |
||
961 | /* The symbols being reduced. */ |
||
962 | for (yyi = 0; yyi < yynrhs; yyi++) |
||
963 | { |
||
964 | fprintf (stderr, " $%d = ", yyi + 1); |
||
965 | yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], |
||
966 | &(yyvsp[(yyi + 1) - (yynrhs)]) |
||
967 | ); |
||
968 | fprintf (stderr, "\n"); |
||
969 | } |
||
970 | } |
||
971 | |||
972 | # define YY_REDUCE_PRINT(Rule) \ |
||
973 | do { \ |
||
974 | if (yydebug) \ |
||
975 | yy_reduce_print (yyvsp, Rule); \ |
||
976 | } while (YYID (0)) |
||
977 | |||
978 | /* Nonzero means print parse trace. It is left uninitialized so that |
||
979 | multiple parsers can coexist. */ |
||
980 | int yydebug; |
||
981 | #else /* !YYDEBUG */ |
||
982 | # define YYDPRINTF(Args) |
||
983 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) |
||
984 | # define YY_STACK_PRINT(Bottom, Top) |
||
985 | # define YY_REDUCE_PRINT(Rule) |
||
986 | #endif /* !YYDEBUG */ |
||
987 | |||
988 | |||
989 | /* YYINITDEPTH -- initial size of the parser's stacks. */ |
||
990 | #ifndef YYINITDEPTH |
||
991 | # define YYINITDEPTH 200 |
||
992 | #endif |
||
993 | |||
994 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only |
||
995 | if the built-in stack extension method is used). |
||
996 | |||
997 | Do not make this value too large; the results are undefined if |
||
998 | YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) |
||
999 | evaluated with infinite-precision integer arithmetic. */ |
||
1000 | |||
1001 | #ifndef YYMAXDEPTH |
||
1002 | # define YYMAXDEPTH 10000 |
||
1003 | #endif |
||
1004 | |||
1005 | |||
1006 | |||
1007 | #if YYERROR_VERBOSE |
||
1008 | |||
1009 | # ifndef yystrlen |
||
1010 | # if defined __GLIBC__ && defined _STRING_H |
||
1011 | # define yystrlen strlen |
||
1012 | # else |
||
1013 | /* Return the length of YYSTR. */ |
||
1014 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
||
1015 | || defined __cplusplus || defined _MSC_VER) |
||
1016 | static YYSIZE_T |
||
1017 | yystrlen (const char *yystr) |
||
1018 | #else |
||
1019 | static YYSIZE_T |
||
1020 | yystrlen (yystr) |
||
1021 | const char *yystr; |
||
1022 | #endif |
||
1023 | { |
||
1024 | YYSIZE_T yylen; |
||
1025 | for (yylen = 0; yystr[yylen]; yylen++) |
||
1026 | continue; |
||
1027 | return yylen; |
||
1028 | } |
||
1029 | # endif |
||
1030 | # endif |
||
1031 | |||
1032 | # ifndef yystpcpy |
||
1033 | # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE |
||
1034 | # define yystpcpy stpcpy |
||
1035 | # else |
||
1036 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in |
||
1037 | YYDEST. */ |
||
1038 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
||
1039 | || defined __cplusplus || defined _MSC_VER) |
||
1040 | static char * |
||
1041 | yystpcpy (char *yydest, const char *yysrc) |
||
1042 | #else |
||
1043 | static char * |
||
1044 | yystpcpy (yydest, yysrc) |
||
1045 | char *yydest; |
||
1046 | const char *yysrc; |
||
1047 | #endif |
||
1048 | { |
||
1049 | char *yyd = yydest; |
||
1050 | const char *yys = yysrc; |
||
1051 | |||
1052 | while ((*yyd++ = *yys++) != '\0') |
||
1053 | continue; |
||
1054 | |||
1055 | return yyd - 1; |
||
1056 | } |
||
1057 | # endif |
||
1058 | # endif |
||
1059 | |||
1060 | # ifndef yytnamerr |
||
1061 | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary |
||
1062 | quotes and backslashes, so that it's suitable for yyerror. The |
||
1063 | heuristic is that double-quoting is unnecessary unless the string |
||
1064 | contains an apostrophe, a comma, or backslash (other than |
||
1065 | backslash-backslash). YYSTR is taken from yytname. If YYRES is |
||
1066 | null, do not copy; instead, return the length of what the result |
||
1067 | would have been. */ |
||
1068 | static YYSIZE_T |
||
1069 | yytnamerr (char *yyres, const char *yystr) |
||
1070 | { |
||
1071 | if (*yystr == '"') |
||
1072 | { |
||
1073 | YYSIZE_T yyn = 0; |
||
1074 | char const *yyp = yystr; |
||
1075 | |||
1076 | for (;;) |
||
1077 | switch (*++yyp) |
||
1078 | { |
||
1079 | case '\'': |
||
1080 | case ',': |
||
1081 | goto do_not_strip_quotes; |
||
1082 | |||
1083 | case '\\': |
||
1084 | if (*++yyp != '\\') |
||
1085 | goto do_not_strip_quotes; |
||
1086 | /* Fall through. */ |
||
1087 | default: |
||
1088 | if (yyres) |
||
1089 | yyres[yyn] = *yyp; |
||
1090 | yyn++; |
||
1091 | break; |
||
1092 | |||
1093 | case '"': |
||
1094 | if (yyres) |
||
1095 | yyres[yyn] = '\0'; |
||
1096 | return yyn; |
||
1097 | } |
||
1098 | do_not_strip_quotes: ; |
||
1099 | } |
||
1100 | |||
1101 | if (! yyres) |
||
1102 | return yystrlen (yystr); |
||
1103 | |||
1104 | return yystpcpy (yyres, yystr) - yyres; |
||
1105 | } |
||
1106 | # endif |
||
1107 | |||
1108 | /* Copy into YYRESULT an error message about the unexpected token |
||
1109 | YYCHAR while in state YYSTATE. Return the number of bytes copied, |
||
1110 | including the terminating null byte. If YYRESULT is null, do not |
||
1111 | copy anything; just return the number of bytes that would be |
||
1112 | copied. As a special case, return 0 if an ordinary "syntax error" |
||
1113 | message will do. Return YYSIZE_MAXIMUM if overflow occurs during |
||
1114 | size calculation. */ |
||
1115 | static YYSIZE_T |
||
1116 | yysyntax_error (char *yyresult, int yystate, int yychar) |
||
1117 | { |
||
1118 | int yyn = yypact[yystate]; |
||
1119 | |||
1120 | if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) |
||
1121 | return 0; |
||
1122 | else |
||
1123 | { |
||
1124 | int yytype = YYTRANSLATE (yychar); |
||
1125 | YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); |
||
1126 | YYSIZE_T yysize = yysize0; |
||
1127 | YYSIZE_T yysize1; |
||
1128 | int yysize_overflow = 0; |
||
1129 | enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; |
||
1130 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; |
||
1131 | int yyx; |
||
1132 | |||
1133 | # if 0 |
||
1134 | /* This is so xgettext sees the translatable formats that are |
||
1135 | constructed on the fly. */ |
||
1136 | YY_("syntax error, unexpected %s"); |
||
1137 | YY_("syntax error, unexpected %s, expecting %s"); |
||
1138 | YY_("syntax error, unexpected %s, expecting %s or %s"); |
||
1139 | YY_("syntax error, unexpected %s, expecting %s or %s or %s"); |
||
1140 | YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); |
||
1141 | # endif |
||
1142 | char *yyfmt; |
||
1143 | char const *yyf; |
||
1144 | static char const yyunexpected[] = "syntax error, unexpected %s"; |
||
1145 | static char const yyexpecting[] = ", expecting %s"; |
||
1146 | static char const yyor[] = " or %s"; |
||
1147 | char yyformat[sizeof yyunexpected |
||
1148 | + sizeof yyexpecting - 1 |
||
1149 | + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) |
||
1150 | * (sizeof yyor - 1))]; |
||
1151 | char const *yyprefix = yyexpecting; |
||
1152 | |||
1153 | /* Start YYX at -YYN if negative to avoid negative indexes in |
||
1154 | YYCHECK. */ |
||
1155 | int yyxbegin = yyn < 0 ? -yyn : 0; |
||
1156 | |||
1157 | /* Stay within bounds of both yycheck and yytname. */ |
||
1158 | int yychecklim = YYLAST - yyn + 1; |
||
1159 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; |
||
1160 | int yycount = 1; |
||
1161 | |||
1162 | yyarg[0] = yytname[yytype]; |
||
1163 | yyfmt = yystpcpy (yyformat, yyunexpected); |
||
1164 | |||
1165 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) |
||
1166 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) |
||
1167 | { |
||
1168 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) |
||
1169 | { |
||
1170 | yycount = 1; |
||
1171 | yysize = yysize0; |
||
1172 | yyformat[sizeof yyunexpected - 1] = '\0'; |
||
1173 | break; |
||
1174 | } |
||
1175 | yyarg[yycount++] = yytname[yyx]; |
||
1176 | yysize1 = yysize + yytnamerr (0, yytname[yyx]); |
||
1177 | yysize_overflow |= (yysize1 < yysize); |
||
1178 | yysize = yysize1; |
||
1179 | yyfmt = yystpcpy (yyfmt, yyprefix); |
||
1180 | yyprefix = yyor; |
||
1181 | } |
||
1182 | |||
1183 | yyf = YY_(yyformat); |
||
1184 | yysize1 = yysize + yystrlen (yyf); |
||
1185 | yysize_overflow |= (yysize1 < yysize); |
||
1186 | yysize = yysize1; |
||
1187 | |||
1188 | if (yysize_overflow) |
||
1189 | return YYSIZE_MAXIMUM; |
||
1190 | |||
1191 | if (yyresult) |
||
1192 | { |
||
1193 | /* Avoid sprintf, as that infringes on the user's name space. |
||
1194 | Don't have undefined behavior even if the translation |
||
1195 | produced a string with the wrong number of "%s"s. */ |
||
1196 | char *yyp = yyresult; |
||
1197 | int yyi = 0; |
||
1198 | while ((*yyp = *yyf) != '\0') |
||
1199 | { |
||
1200 | if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) |
||
1201 | { |
||
1202 | yyp += yytnamerr (yyp, yyarg[yyi++]); |
||
1203 | yyf += 2; |
||
1204 | } |
||
1205 | else |
||
1206 | { |
||
1207 | yyp++; |
||
1208 | yyf++; |
||
1209 | } |
||
1210 | } |
||
1211 | } |
||
1212 | return yysize; |
||
1213 | } |
||
1214 | } |
||
1215 | #endif /* YYERROR_VERBOSE */ |
||
1216 | |||
1217 | |||
1218 | /*-----------------------------------------------. |
||
1219 | | Release the memory associated to this symbol. | |
||
1220 | `-----------------------------------------------*/ |
||
1221 | |||
1222 | /*ARGSUSED*/ |
||
1223 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
||
1224 | || defined __cplusplus || defined _MSC_VER) |
||
1225 | static void |
||
1226 | yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) |
||
1227 | #else |
||
1228 | static void |
||
1229 | yydestruct (yymsg, yytype, yyvaluep) |
||
1230 | const char *yymsg; |
||
1231 | int yytype; |
||
1232 | YYSTYPE *yyvaluep; |
||
1233 | #endif |
||
1234 | { |
||
1235 | YYUSE (yyvaluep); |
||
1236 | |||
1237 | if (!yymsg) |
||
1238 | yymsg = "Deleting"; |
||
1239 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); |
||
1240 | |||
1241 | switch (yytype) |
||
1242 | { |
||
1243 | |||
1244 | default: |
||
1245 | break; |
||
1246 | } |
||
1247 | } |
||
1248 | |||
1249 | |||
1250 | /* Prevent warnings from -Wmissing-prototypes. */ |
||
1251 | |||
1252 | #ifdef YYPARSE_PARAM |
||
1253 | #if defined __STDC__ || defined __cplusplus |
||
1254 | int yyparse (void *YYPARSE_PARAM); |
||
1255 | #else |
||
1256 | int yyparse (); |
||
1257 | #endif |
||
1258 | #else /* ! YYPARSE_PARAM */ |
||
1259 | #if defined __STDC__ || defined __cplusplus |
||
1260 | int yyparse (void); |
||
1261 | #else |
||
1262 | int yyparse (); |
||
1263 | #endif |
||
1264 | #endif /* ! YYPARSE_PARAM */ |
||
1265 | |||
1266 | |||
1267 | |||
1268 | /* The look-ahead symbol. */ |
||
1269 | int yychar; |
||
1270 | |||
1271 | /* The semantic value of the look-ahead symbol. */ |
||
1272 | YYSTYPE yylval; |
||
1273 | |||
1274 | /* Number of syntax errors so far. */ |
||
1275 | int yynerrs; |
||
1276 | |||
1277 | |||
1278 | |||
1279 | /*----------. |
||
1280 | | yyparse. | |
||
1281 | `----------*/ |
||
1282 | |||
1283 | #ifdef YYPARSE_PARAM |
||
1284 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
||
1285 | || defined __cplusplus || defined _MSC_VER) |
||
1286 | int |
||
1287 | yyparse (void *YYPARSE_PARAM) |
||
1288 | #else |
||
1289 | int |
||
1290 | yyparse (YYPARSE_PARAM) |
||
1291 | void *YYPARSE_PARAM; |
||
1292 | #endif |
||
1293 | #else /* ! YYPARSE_PARAM */ |
||
1294 | #if (defined __STDC__ || defined __C99__FUNC__ \ |
||
1295 | || defined __cplusplus || defined _MSC_VER) |
||
1296 | int |
||
1297 | yyparse (void) |
||
1298 | #else |
||
1299 | int |
||
1300 | yyparse () |
||
1301 | |||
1302 | #endif |
||
1303 | #endif |
||
1304 | { |
||
1305 | |||
1306 | int yystate; |
||
1307 | int yyn; |
||
1308 | int yyresult; |
||
1309 | /* Number of tokens to shift before error messages enabled. */ |
||
1310 | int yyerrstatus; |
||
1311 | /* Look-ahead token as an internal (translated) token number. */ |
||
1312 | int yytoken = 0; |
||
1313 | #if YYERROR_VERBOSE |
||
1314 | /* Buffer for error messages, and its allocated size. */ |
||
1315 | char yymsgbuf[128]; |
||
1316 | char *yymsg = yymsgbuf; |
||
1317 | YYSIZE_T yymsg_alloc = sizeof yymsgbuf; |
||
1318 | #endif |
||
1319 | |||
1320 | /* Three stacks and their tools: |
||
1321 | `yyss': related to states, |
||
1322 | `yyvs': related to semantic values, |
||
1323 | `yyls': related to locations. |
||
1324 | |||
1325 | Refer to the stacks thru separate pointers, to allow yyoverflow |
||
1326 | to reallocate them elsewhere. */ |
||
1327 | |||
1328 | /* The state stack. */ |
||
1329 | yytype_int16 yyssa[YYINITDEPTH]; |
||
1330 | yytype_int16 *yyss = yyssa; |
||
1331 | yytype_int16 *yyssp; |
||
1332 | |||
1333 | /* The semantic value stack. */ |
||
1334 | YYSTYPE yyvsa[YYINITDEPTH]; |
||
1335 | YYSTYPE *yyvs = yyvsa; |
||
1336 | YYSTYPE *yyvsp; |
||
1337 | |||
1338 | |||
1339 | |||
1340 | #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) |
||
1341 | |||
1342 | YYSIZE_T yystacksize = YYINITDEPTH; |
||
1343 | |||
1344 | /* The variables used to return semantic value and location from the |
||
1345 | action routines. */ |
||
1346 | YYSTYPE yyval; |
||
1347 | |||
1348 | |||
1349 | /* The number of symbols on the RHS of the reduced rule. |
||
1350 | Keep to zero when no symbol should be popped. */ |
||
1351 | int yylen = 0; |
||
1352 | |||
1353 | YYDPRINTF ((stderr, "Starting parse\n")); |
||
1354 | |||
1355 | yystate = 0; |
||
1356 | yyerrstatus = 0; |
||
1357 | yynerrs = 0; |
||
1358 | yychar = YYEMPTY; /* Cause a token to be read. */ |
||
1359 | |||
1360 | /* Initialize stack pointers. |
||
1361 | Waste one element of value and location stack |
||
1362 | so that they stay on the same level as the state stack. |
||
1363 | The wasted elements are never initialized. */ |
||
1364 | |||
1365 | yyssp = yyss; |
||
1366 | yyvsp = yyvs; |
||
1367 | |||
1368 | goto yysetstate; |
||
1369 | |||
1370 | /*------------------------------------------------------------. |
||
1371 | | yynewstate -- Push a new state, which is found in yystate. | |
||
1372 | `------------------------------------------------------------*/ |
||
1373 | yynewstate: |
||
1374 | /* In all cases, when you get here, the value and location stacks |
||
1375 | have just been pushed. So pushing a state here evens the stacks. */ |
||
1376 | yyssp++; |
||
1377 | |||
1378 | yysetstate: |
||
1379 | *yyssp = yystate; |
||
1380 | |||
1381 | if (yyss + yystacksize - 1 <= yyssp) |
||
1382 | { |
||
1383 | /* Get the current used size of the three stacks, in elements. */ |
||
1384 | YYSIZE_T yysize = yyssp - yyss + 1; |
||
1385 | |||
1386 | #ifdef yyoverflow |
||
1387 | { |
||
1388 | /* Give user a chance to reallocate the stack. Use copies of |
||
1389 | these so that the &'s don't force the real ones into |
||
1390 | memory. */ |
||
1391 | YYSTYPE *yyvs1 = yyvs; |
||
1392 | yytype_int16 *yyss1 = yyss; |
||
1393 | |||
1394 | |||
1395 | /* Each stack pointer address is followed by the size of the |
||
1396 | data in use in that stack, in bytes. This used to be a |
||
1397 | conditional around just the two extra args, but that might |
||
1398 | be undefined if yyoverflow is a macro. */ |
||
1399 | yyoverflow (YY_("memory exhausted"), |
||
1400 | &yyss1, yysize * sizeof (*yyssp), |
||
1401 | &yyvs1, yysize * sizeof (*yyvsp), |
||
1402 | |||
1403 | &yystacksize); |
||
1404 | |||
1405 | yyss = yyss1; |
||
1406 | yyvs = yyvs1; |
||
1407 | } |
||
1408 | #else /* no yyoverflow */ |
||
1409 | # ifndef YYSTACK_RELOCATE |
||
1410 | goto yyexhaustedlab; |
||
1411 | # else |
||
1412 | /* Extend the stack our own way. */ |
||
1413 | if (YYMAXDEPTH <= yystacksize) |
||
1414 | goto yyexhaustedlab; |
||
1415 | yystacksize *= 2; |
||
1416 | if (YYMAXDEPTH < yystacksize) |
||
1417 | yystacksize = YYMAXDEPTH; |
||
1418 | |||
1419 | { |
||
1420 | yytype_int16 *yyss1 = yyss; |
||
1421 | union yyalloc *yyptr = |
||
1422 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); |
||
1423 | if (! yyptr) |
||
1424 | goto yyexhaustedlab; |
||
1425 | YYSTACK_RELOCATE (yyss); |
||
1426 | YYSTACK_RELOCATE (yyvs); |
||
1427 | |||
1428 | # undef YYSTACK_RELOCATE |
||
1429 | if (yyss1 != yyssa) |
||
1430 | YYSTACK_FREE (yyss1); |
||
1431 | } |
||
1432 | # endif |
||
1433 | #endif /* no yyoverflow */ |
||
1434 | |||
1435 | yyssp = yyss + yysize - 1; |
||
1436 | yyvsp = yyvs + yysize - 1; |
||
1437 | |||
1438 | |||
1439 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", |
||
1440 | (unsigned long int) yystacksize)); |
||
1441 | |||
1442 | if (yyss + yystacksize - 1 <= yyssp) |
||
1443 | YYABORT; |
||
1444 | } |
||
1445 | |||
1446 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); |
||
1447 | |||
1448 | goto yybackup; |
||
1449 | |||
1450 | /*-----------. |
||
1451 | | yybackup. | |
||
1452 | `-----------*/ |
||
1453 | yybackup: |
||
1454 | |||
1455 | /* Do appropriate processing given the current state. Read a |
||
1456 | look-ahead token if we need one and don't already have one. */ |
||
1457 | |||
1458 | /* First try to decide what to do without reference to look-ahead token. */ |
||
1459 | yyn = yypact[yystate]; |
||
1460 | if (yyn == YYPACT_NINF) |
||
1461 | goto yydefault; |
||
1462 | |||
1463 | /* Not known => get a look-ahead token if don't already have one. */ |
||
1464 | |||
1465 | /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ |
||
1466 | if (yychar == YYEMPTY) |
||
1467 | { |
||
1468 | YYDPRINTF ((stderr, "Reading a token: ")); |
||
1469 | yychar = YYLEX; |
||
1470 | } |
||
1471 | |||
1472 | if (yychar <= YYEOF) |
||
1473 | { |
||
1474 | yychar = yytoken = YYEOF; |
||
1475 | YYDPRINTF ((stderr, "Now at end of input.\n")); |
||
1476 | } |
||
1477 | else |
||
1478 | { |
||
1479 | yytoken = YYTRANSLATE (yychar); |
||
1480 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); |
||
1481 | } |
||
1482 | |||
1483 | /* If the proper action on seeing token YYTOKEN is to reduce or to |
||
1484 | detect an error, take that action. */ |
||
1485 | yyn += yytoken; |
||
1486 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) |
||
1487 | goto yydefault; |
||
1488 | yyn = yytable[yyn]; |
||
1489 | if (yyn <= 0) |
||
1490 | { |
||
1491 | if (yyn == 0 || yyn == YYTABLE_NINF) |
||
1492 | goto yyerrlab; |
||
1493 | yyn = -yyn; |
||
1494 | goto yyreduce; |
||
1495 | } |
||
1496 | |||
1497 | if (yyn == YYFINAL) |
||
1498 | YYACCEPT; |
||
1499 | |||
1500 | /* Count tokens shifted since error; after three, turn off error |
||
1501 | status. */ |
||
1502 | if (yyerrstatus) |
||
1503 | yyerrstatus--; |
||
1504 | |||
1505 | /* Shift the look-ahead token. */ |
||
1506 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); |
||
1507 | |||
1508 | /* Discard the shifted token unless it is eof. */ |
||
1509 | if (yychar != YYEOF) |
||
1510 | yychar = YYEMPTY; |
||
1511 | |||
1512 | yystate = yyn; |
||
1513 | *++yyvsp = yylval; |
||
1514 | |||
1515 | goto yynewstate; |
||
1516 | |||
1517 | |||
1518 | /*-----------------------------------------------------------. |
||
1519 | | yydefault -- do the default action for the current state. | |
||
1520 | `-----------------------------------------------------------*/ |
||
1521 | yydefault: |
||
1522 | yyn = yydefact[yystate]; |
||
1523 | if (yyn == 0) |
||
1524 | goto yyerrlab; |
||
1525 | goto yyreduce; |
||
1526 | |||
1527 | |||
1528 | /*-----------------------------. |
||
1529 | | yyreduce -- Do a reduction. | |
||
1530 | `-----------------------------*/ |
||
1531 | yyreduce: |
||
1532 | /* yyn is the number of a rule to reduce with. */ |
||
1533 | yylen = yyr2[yyn]; |
||
1534 | |||
1535 | /* If YYLEN is nonzero, implement the default value of the action: |
||
1536 | `$$ = $1'. |
||
1537 | |||
1538 | Otherwise, the following line sets YYVAL to garbage. |
||
1539 | This behavior is undocumented and Bison |
||
1540 | users should not rely upon it. Assigning to YYVAL |
||
1541 | unconditionally makes the parser a bit smaller, and it avoids a |
||
1542 | GCC warning that YYVAL may be used uninitialized. */ |
||
1543 | yyval = yyvsp[1-yylen]; |
||
1544 | |||
1545 | |||
1546 | YY_REDUCE_PRINT (yyn); |
||
1547 | switch (yyn) |
||
1548 | { |
||
1549 | case 2: |
||
1550 | #line 153 "arith.y" |
||
1551 | { |
||
1552 | return ((yyvsp[(1) - (1)])); |
||
1553 | } |
||
1554 | break; |
||
1555 | |||
1556 | case 3: |
||
1557 | #line 159 "arith.y" |
||
1558 | { (yyval) = (yyvsp[(2) - (3)]); } |
||
1559 | break; |
||
1560 | |||
1561 | case 4: |
||
1562 | #line 160 "arith.y" |
||
1563 | { (yyval) = (yyvsp[(1) - (3)]) ? (yyvsp[(1) - (3)]) : (yyvsp[(3) - (3)]) ? (yyvsp[(3) - (3)]) : 0; } |
||
1564 | break; |
||
1565 | |||
1566 | case 5: |
||
1567 | #line 161 "arith.y" |
||
1568 | { (yyval) = (yyvsp[(1) - (3)]) ? ( (yyvsp[(3) - (3)]) ? (yyvsp[(3) - (3)]) : 0 ) : 0; } |
||
1569 | break; |
||
1570 | |||
1571 | case 6: |
||
1572 | #line 162 "arith.y" |
||
1573 | { (yyval) = (yyvsp[(1) - (3)]) | (yyvsp[(3) - (3)]); } |
||
1574 | break; |
||
1575 | |||
1576 | case 7: |
||
1577 | #line 163 "arith.y" |
||
1578 | { (yyval) = (yyvsp[(1) - (3)]) ^ (yyvsp[(3) - (3)]); } |
||
1579 | break; |
||
1580 | |||
1581 | case 8: |
||
1582 | #line 164 "arith.y" |
||
1583 | { (yyval) = (yyvsp[(1) - (3)]) & (yyvsp[(3) - (3)]); } |
||
1584 | break; |
||
1585 | |||
1586 | case 9: |
||
1587 | #line 165 "arith.y" |
||
1588 | { (yyval) = (yyvsp[(1) - (3)]) == (yyvsp[(3) - (3)]); } |
||
1589 | break; |
||
1590 | |||
1591 | case 10: |
||
1592 | #line 166 "arith.y" |
||
1593 | { (yyval) = (yyvsp[(1) - (3)]) > (yyvsp[(3) - (3)]); } |
||
1594 | break; |
||
1595 | |||
1596 | case 11: |
||
1597 | #line 167 "arith.y" |
||
1598 | { (yyval) = (yyvsp[(1) - (3)]) >= (yyvsp[(3) - (3)]); } |
||
1599 | break; |
||
1600 | |||
1601 | case 12: |
||
1602 | #line 168 "arith.y" |
||
1603 | { (yyval) = (yyvsp[(1) - (3)]) < (yyvsp[(3) - (3)]); } |
||
1604 | break; |
||
1605 | |||
1606 | case 13: |
||
1607 | #line 169 "arith.y" |
||
1608 | { (yyval) = (yyvsp[(1) - (3)]) <= (yyvsp[(3) - (3)]); } |
||
1609 | break; |
||
1610 | |||
1611 | case 14: |
||
1612 | #line 170 "arith.y" |
||
1613 | { (yyval) = (yyvsp[(1) - (3)]) != (yyvsp[(3) - (3)]); } |
||
1614 | break; |
||
1615 | |||
1616 | case 15: |
||
1617 | #line 171 "arith.y" |
||
1618 | { (yyval) = (yyvsp[(1) - (3)]) << (yyvsp[(3) - (3)]); } |
||
1619 | break; |
||
1620 | |||
1621 | case 16: |
||
1622 | #line 172 "arith.y" |
||
1623 | { (yyval) = (yyvsp[(1) - (3)]) >> (yyvsp[(3) - (3)]); } |
||
1624 | break; |
||
1625 | |||
1626 | case 17: |
||
1627 | #line 173 "arith.y" |
||
1628 | { (yyval) = (yyvsp[(1) - (3)]) + (yyvsp[(3) - (3)]); } |
||
1629 | break; |
||
1630 | |||
1631 | case 18: |
||
1632 | #line 174 "arith.y" |
||
1633 | { (yyval) = (yyvsp[(1) - (3)]) - (yyvsp[(3) - (3)]); } |
||
1634 | break; |
||
1635 | |||
1636 | case 19: |
||
1637 | #line 175 "arith.y" |
||
1638 | { (yyval) = (yyvsp[(1) - (3)]) * (yyvsp[(3) - (3)]); } |
||
1639 | break; |
||
1640 | |||
1641 | case 20: |
||
1642 | #line 176 "arith.y" |
||
1643 | { |
||
1644 | if ((yyvsp[(3) - (3)]) == 0) |
||
1645 | yyerror("division by zero"); |
||
1646 | (yyval) = (yyvsp[(1) - (3)]) / (yyvsp[(3) - (3)]); |
||
1647 | } |
||
1648 | break; |
||
1649 | |||
1650 | case 21: |
||
1651 | #line 181 "arith.y" |
||
1652 | { |
||
1653 | if ((yyvsp[(3) - (3)]) == 0) |
||
1654 | yyerror("division by zero"); |
||
1655 | (yyval) = (yyvsp[(1) - (3)]) % (yyvsp[(3) - (3)]); |
||
1656 | } |
||
1657 | break; |
||
1658 | |||
1659 | case 22: |
||
1660 | #line 186 "arith.y" |
||
1661 | { (yyval) = !((yyvsp[(2) - (2)])); } |
||
1662 | break; |
||
1663 | |||
1664 | case 23: |
||
1665 | #line 187 "arith.y" |
||
1666 | { (yyval) = ~((yyvsp[(2) - (2)])); } |
||
1667 | break; |
||
1668 | |||
1669 | case 24: |
||
1670 | #line 188 "arith.y" |
||
1671 | { (yyval) = -((yyvsp[(2) - (2)])); } |
||
1672 | break; |
||
1673 | |||
1674 | case 25: |
||
1675 | #line 189 "arith.y" |
||
1676 | { (yyval) = (yyvsp[(2) - (2)]); } |
||
1677 | break; |
||
1678 | |||
1679 | |||
1680 | /* Line 1267 of yacc.c. */ |
||
1681 | #line 1682 "y.tab.c" |
||
1682 | default: break; |
||
1683 | } |
||
1684 | YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); |
||
1685 | |||
1686 | YYPOPSTACK (yylen); |
||
1687 | yylen = 0; |
||
1688 | YY_STACK_PRINT (yyss, yyssp); |
||
1689 | |||
1690 | *++yyvsp = yyval; |
||
1691 | |||
1692 | |||
1693 | /* Now `shift' the result of the reduction. Determine what state |
||
1694 | that goes to, based on the state we popped back to and the rule |
||
1695 | number reduced by. */ |
||
1696 | |||
1697 | yyn = yyr1[yyn]; |
||
1698 | |||
1699 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; |
||
1700 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
||
1701 | yystate = yytable[yystate]; |
||
1702 | else |
||
1703 | yystate = yydefgoto[yyn - YYNTOKENS]; |
||
1704 | |||
1705 | goto yynewstate; |
||
1706 | |||
1707 | |||
1708 | /*------------------------------------. |
||
1709 | | yyerrlab -- here on detecting error | |
||
1710 | `------------------------------------*/ |
||
1711 | yyerrlab: |
||
1712 | /* If not already recovering from an error, report this error. */ |
||
1713 | if (!yyerrstatus) |
||
1714 | { |
||
1715 | ++yynerrs; |
||
1716 | #if ! YYERROR_VERBOSE |
||
1717 | yyerror (YY_("syntax error")); |
||
1718 | #else |
||
1719 | { |
||
1720 | YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); |
||
1721 | if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) |
||
1722 | { |
||
1723 | YYSIZE_T yyalloc = 2 * yysize; |
||
1724 | if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) |
||
1725 | yyalloc = YYSTACK_ALLOC_MAXIMUM; |
||
1726 | if (yymsg != yymsgbuf) |
||
1727 | YYSTACK_FREE (yymsg); |
||
1728 | yymsg = (char *) YYSTACK_ALLOC (yyalloc); |
||
1729 | if (yymsg) |
||
1730 | yymsg_alloc = yyalloc; |
||
1731 | else |
||
1732 | { |
||
1733 | yymsg = yymsgbuf; |
||
1734 | yymsg_alloc = sizeof yymsgbuf; |
||
1735 | } |
||
1736 | } |
||
1737 | |||
1738 | if (0 < yysize && yysize <= yymsg_alloc) |
||
1739 | { |
||
1740 | (void) yysyntax_error (yymsg, yystate, yychar); |
||
1741 | yyerror (yymsg); |
||
1742 | } |
||
1743 | else |
||
1744 | { |
||
1745 | yyerror (YY_("syntax error")); |
||
1746 | if (yysize != 0) |
||
1747 | goto yyexhaustedlab; |
||
1748 | } |
||
1749 | } |
||
1750 | #endif |
||
1751 | } |
||
1752 | |||
1753 | |||
1754 | |||
1755 | if (yyerrstatus == 3) |
||
1756 | { |
||
1757 | /* If just tried and failed to reuse look-ahead token after an |
||
1758 | error, discard it. */ |
||
1759 | |||
1760 | if (yychar <= YYEOF) |
||
1761 | { |
||
1762 | /* Return failure if at end of input. */ |
||
1763 | if (yychar == YYEOF) |
||
1764 | YYABORT; |
||
1765 | } |
||
1766 | else |
||
1767 | { |
||
1768 | yydestruct ("Error: discarding", |
||
1769 | yytoken, &yylval); |
||
1770 | yychar = YYEMPTY; |
||
1771 | } |
||
1772 | } |
||
1773 | |||
1774 | /* Else will try to reuse look-ahead token after shifting the error |
||
1775 | token. */ |
||
1776 | goto yyerrlab1; |
||
1777 | |||
1778 | |||
1779 | /*---------------------------------------------------. |
||
1780 | | yyerrorlab -- error raised explicitly by YYERROR. | |
||
1781 | `---------------------------------------------------*/ |
||
1782 | yyerrorlab: |
||
1783 | |||
1784 | /* Pacify compilers like GCC when the user code never invokes |
||
1785 | YYERROR and the label yyerrorlab therefore never appears in user |
||
1786 | code. */ |
||
1787 | if (/*CONSTCOND*/ 0) |
||
1788 | goto yyerrorlab; |
||
1789 | |||
1790 | /* Do not reclaim the symbols of the rule which action triggered |
||
1791 | this YYERROR. */ |
||
1792 | YYPOPSTACK (yylen); |
||
1793 | yylen = 0; |
||
1794 | YY_STACK_PRINT (yyss, yyssp); |
||
1795 | yystate = *yyssp; |
||
1796 | goto yyerrlab1; |
||
1797 | |||
1798 | |||
1799 | /*-------------------------------------------------------------. |
||
1800 | | yyerrlab1 -- common code for both syntax error and YYERROR. | |
||
1801 | `-------------------------------------------------------------*/ |
||
1802 | yyerrlab1: |
||
1803 | yyerrstatus = 3; /* Each real token shifted decrements this. */ |
||
1804 | |||
1805 | for (;;) |
||
1806 | { |
||
1807 | yyn = yypact[yystate]; |
||
1808 | if (yyn != YYPACT_NINF) |
||
1809 | { |
||
1810 | yyn += YYTERROR; |
||
1811 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) |
||
1812 | { |
||
1813 | yyn = yytable[yyn]; |
||
1814 | if (0 < yyn) |
||
1815 | break; |
||
1816 | } |
||
1817 | } |
||
1818 | |||
1819 | /* Pop the current state because it cannot handle the error token. */ |
||
1820 | if (yyssp == yyss) |
||
1821 | YYABORT; |
||
1822 | |||
1823 | |||
1824 | yydestruct ("Error: popping", |
||
1825 | yystos[yystate], yyvsp); |
||
1826 | YYPOPSTACK (1); |
||
1827 | yystate = *yyssp; |
||
1828 | YY_STACK_PRINT (yyss, yyssp); |
||
1829 | } |
||
1830 | |||
1831 | if (yyn == YYFINAL) |
||
1832 | YYACCEPT; |
||
1833 | |||
1834 | *++yyvsp = yylval; |
||
1835 | |||
1836 | |||
1837 | /* Shift the error token. */ |
||
1838 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); |
||
1839 | |||
1840 | yystate = yyn; |
||
1841 | goto yynewstate; |
||
1842 | |||
1843 | |||
1844 | /*-------------------------------------. |
||
1845 | | yyacceptlab -- YYACCEPT comes here. | |
||
1846 | `-------------------------------------*/ |
||
1847 | yyacceptlab: |
||
1848 | yyresult = 0; |
||
1849 | goto yyreturn; |
||
1850 | |||
1851 | /*-----------------------------------. |
||
1852 | | yyabortlab -- YYABORT comes here. | |
||
1853 | `-----------------------------------*/ |
||
1854 | yyabortlab: |
||
1855 | yyresult = 1; |
||
1856 | goto yyreturn; |
||
1857 | |||
1858 | #ifndef yyoverflow |
||
1859 | /*-------------------------------------------------. |
||
1860 | | yyexhaustedlab -- memory exhaustion comes here. | |
||
1861 | `-------------------------------------------------*/ |
||
1862 | yyexhaustedlab: |
||
1863 | yyerror (YY_("memory exhausted")); |
||
1864 | yyresult = 2; |
||
1865 | /* Fall through. */ |
||
1866 | #endif |
||
1867 | |||
1868 | yyreturn: |
||
1869 | if (yychar != YYEOF && yychar != YYEMPTY) |
||
1870 | yydestruct ("Cleanup: discarding lookahead", |
||
1871 | yytoken, &yylval); |
||
1872 | /* Do not reclaim the symbols of the rule which action triggered |
||
1873 | this YYABORT or YYACCEPT. */ |
||
1874 | YYPOPSTACK (yylen); |
||
1875 | YY_STACK_PRINT (yyss, yyssp); |
||
1876 | while (yyssp != yyss) |
||
1877 | { |
||
1878 | yydestruct ("Cleanup: popping", |
||
1879 | yystos[*yyssp], yyvsp); |
||
1880 | YYPOPSTACK (1); |
||
1881 | } |
||
1882 | #ifndef yyoverflow |
||
1883 | if (yyss != yyssa) |
||
1884 | YYSTACK_FREE (yyss); |
||
1885 | #endif |
||
1886 | #if YYERROR_VERBOSE |
||
1887 | if (yymsg != yymsgbuf) |
||
1888 | YYSTACK_FREE (yymsg); |
||
1889 | #endif |
||
1890 | /* Make sure YYID is used. */ |
||
1891 | return YYID (yyresult); |
||
1892 | } |
||
1893 | |||
1894 | |||
1895 | #line 192 "arith.y" |
||
1896 | |||
1897 | void |
||
1898 | yyerror(s) |
||
1899 | const char *s; |
||
1900 | { |
||
1901 | |||
1902 | yyclearin; |
||
1903 | arith_lex_reset(); /* reprime lex */ |
||
1904 | error("arithmetic expression: %s: \"%s\"", s, arith_startbuf); |
||
1905 | /* NOTREACHED */ |
||
1906 | } |
||
1907 |