]>
Commit | Line | Data |
---|---|---|
1 | /* A Bison parser, made by GNU Bison 1.875b. */ | |
2 | ||
3 | /* Skeleton parser for Yacc-like parsing with Bison, | |
4 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2, or (at your option) | |
9 | any later version. | |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with this program; if not, write to the Free Software | |
18 | Foundation, Inc., 59 Temple Place - Suite 330, | |
19 | Boston, MA 02111-1307, USA. */ | |
20 | ||
21 | /* As a special exception, when this file is copied by Bison into a | |
22 | Bison output file, you may use that output file without restriction. | |
23 | This special exception was added by the Free Software Foundation | |
24 | in version 1.24 of Bison. */ | |
25 | ||
26 | /* Written by Richard Stallman by simplifying the original so called | |
27 | ``semantic'' parser. */ | |
28 | ||
29 | /* All symbols defined below should begin with yy or YY, to avoid | |
30 | infringing on user name space. This should be done even for local | |
31 | variables, as they might otherwise be expanded by user macros. | |
32 | There are some unavoidable exceptions within include files to | |
33 | define necessary library symbols; they are noted "INFRINGES ON | |
34 | USER NAME SPACE" below. */ | |
35 | ||
36 | /* Identify Bison output. */ | |
37 | #define YYBISON 1 | |
38 | ||
39 | /* Skeleton name. */ | |
40 | #define YYSKELETON_NAME "yacc.c" | |
41 | ||
42 | /* Pure parsers. */ | |
43 | #define YYPURE 1 | |
44 | ||
45 | /* Using locations. */ | |
46 | #define YYLSP_NEEDED 1 | |
47 | ||
48 | /* If NAME_PREFIX is specified substitute the variables and functions | |
49 | names. */ | |
50 | #define yyparse gram_parse | |
51 | #define yylex gram_lex | |
52 | #define yyerror gram_error | |
53 | #define yylval gram_lval | |
54 | #define yychar gram_char | |
55 | #define yydebug gram_debug | |
56 | #define yynerrs gram_nerrs | |
57 | #define yylloc gram_lloc | |
58 | ||
59 | /* Tokens. */ | |
60 | #ifndef YYTOKENTYPE | |
61 | # define YYTOKENTYPE | |
62 | /* Put the tokens into the symbol table, so that GDB and other debuggers | |
63 | know about them. */ | |
64 | enum yytokentype { | |
65 | GRAM_EOF = 0, | |
66 | STRING = 258, | |
67 | INT = 259, | |
68 | PERCENT_TOKEN = 260, | |
69 | PERCENT_NTERM = 261, | |
70 | PERCENT_TYPE = 262, | |
71 | PERCENT_DESTRUCTOR = 263, | |
72 | PERCENT_PRINTER = 264, | |
73 | PERCENT_UNION = 265, | |
74 | PERCENT_LEFT = 266, | |
75 | PERCENT_RIGHT = 267, | |
76 | PERCENT_NONASSOC = 268, | |
77 | PERCENT_PREC = 269, | |
78 | PERCENT_DPREC = 270, | |
79 | PERCENT_MERGE = 271, | |
80 | PERCENT_DEBUG = 272, | |
81 | PERCENT_DEFINE = 273, | |
82 | PERCENT_DEFINES = 274, | |
83 | PERCENT_ERROR_VERBOSE = 275, | |
84 | PERCENT_EXPECT = 276, | |
85 | PERCENT_FILE_PREFIX = 277, | |
86 | PERCENT_GLR_PARSER = 278, | |
87 | PERCENT_LEX_PARAM = 279, | |
88 | PERCENT_LOCATIONS = 280, | |
89 | PERCENT_NAME_PREFIX = 281, | |
90 | PERCENT_NO_LINES = 282, | |
91 | PERCENT_OUTPUT = 283, | |
92 | PERCENT_PARSE_PARAM = 284, | |
93 | PERCENT_PURE_PARSER = 285, | |
94 | PERCENT_SKELETON = 286, | |
95 | PERCENT_START = 287, | |
96 | PERCENT_TOKEN_TABLE = 288, | |
97 | PERCENT_VERBOSE = 289, | |
98 | PERCENT_YACC = 290, | |
99 | TYPE = 291, | |
100 | EQUAL = 292, | |
101 | SEMICOLON = 293, | |
102 | PIPE = 294, | |
103 | ID = 295, | |
104 | ID_COLON = 296, | |
105 | PERCENT_PERCENT = 297, | |
106 | PROLOGUE = 298, | |
107 | EPILOGUE = 299, | |
108 | BRACED_CODE = 300 | |
109 | }; | |
110 | #endif | |
111 | #define GRAM_EOF 0 | |
112 | #define STRING 258 | |
113 | #define INT 259 | |
114 | #define PERCENT_TOKEN 260 | |
115 | #define PERCENT_NTERM 261 | |
116 | #define PERCENT_TYPE 262 | |
117 | #define PERCENT_DESTRUCTOR 263 | |
118 | #define PERCENT_PRINTER 264 | |
119 | #define PERCENT_UNION 265 | |
120 | #define PERCENT_LEFT 266 | |
121 | #define PERCENT_RIGHT 267 | |
122 | #define PERCENT_NONASSOC 268 | |
123 | #define PERCENT_PREC 269 | |
124 | #define PERCENT_DPREC 270 | |
125 | #define PERCENT_MERGE 271 | |
126 | #define PERCENT_DEBUG 272 | |
127 | #define PERCENT_DEFINE 273 | |
128 | #define PERCENT_DEFINES 274 | |
129 | #define PERCENT_ERROR_VERBOSE 275 | |
130 | #define PERCENT_EXPECT 276 | |
131 | #define PERCENT_FILE_PREFIX 277 | |
132 | #define PERCENT_GLR_PARSER 278 | |
133 | #define PERCENT_LEX_PARAM 279 | |
134 | #define PERCENT_LOCATIONS 280 | |
135 | #define PERCENT_NAME_PREFIX 281 | |
136 | #define PERCENT_NO_LINES 282 | |
137 | #define PERCENT_OUTPUT 283 | |
138 | #define PERCENT_PARSE_PARAM 284 | |
139 | #define PERCENT_PURE_PARSER 285 | |
140 | #define PERCENT_SKELETON 286 | |
141 | #define PERCENT_START 287 | |
142 | #define PERCENT_TOKEN_TABLE 288 | |
143 | #define PERCENT_VERBOSE 289 | |
144 | #define PERCENT_YACC 290 | |
145 | #define TYPE 291 | |
146 | #define EQUAL 292 | |
147 | #define SEMICOLON 293 | |
148 | #define PIPE 294 | |
149 | #define ID 295 | |
150 | #define ID_COLON 296 | |
151 | #define PERCENT_PERCENT 297 | |
152 | #define PROLOGUE 298 | |
153 | #define EPILOGUE 299 | |
154 | #define BRACED_CODE 300 | |
155 | ||
156 | ||
157 | ||
158 | ||
159 | /* Copy the first part of user declarations. */ | |
160 | #line 32 "parse-gram.y" | |
161 | ||
162 | #include "system.h" | |
163 | ||
164 | #include "complain.h" | |
165 | #include "conflicts.h" | |
166 | #include "files.h" | |
167 | #include "getargs.h" | |
168 | #include "gram.h" | |
169 | #include "muscle_tab.h" | |
170 | #include "output.h" | |
171 | #include "reader.h" | |
172 | #include "symlist.h" | |
173 | ||
174 | /* Produce verbose syntax errors. */ | |
175 | #define YYERROR_VERBOSE 1 | |
176 | ||
177 | #define YYLLOC_DEFAULT(Current, Rhs, N) (Current) = lloc_default (Rhs, N) | |
178 | static YYLTYPE lloc_default (YYLTYPE const *, int); | |
179 | ||
180 | /* Request detailed syntax error messages, and pass them to GRAM_ERROR. | |
181 | FIXME: depends on the undocumented availability of YYLLOC. */ | |
182 | #undef yyerror | |
183 | #define yyerror(Msg) \ | |
184 | gram_error (&yylloc, Msg) | |
185 | static void gram_error (location const *, char const *); | |
186 | ||
187 | #define YYPRINT(File, Type, Value) \ | |
188 | print_token_value (File, Type, &Value) | |
189 | static void print_token_value (FILE *, int, YYSTYPE const *); | |
190 | ||
191 | static void add_param (char const *, char *, location); | |
192 | ||
193 | symbol_class current_class = unknown_sym; | |
194 | uniqstr current_type = 0; | |
195 | symbol *current_lhs; | |
196 | location current_lhs_location; | |
197 | assoc current_assoc; | |
198 | int current_prec = 0; | |
199 | ||
200 | ||
201 | /* Enabling traces. */ | |
202 | #ifndef YYDEBUG | |
203 | # define YYDEBUG 1 | |
204 | #endif | |
205 | ||
206 | /* Enabling verbose error messages. */ | |
207 | #ifdef YYERROR_VERBOSE | |
208 | # undef YYERROR_VERBOSE | |
209 | # define YYERROR_VERBOSE 1 | |
210 | #else | |
211 | # define YYERROR_VERBOSE 0 | |
212 | #endif | |
213 | ||
214 | #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) | |
215 | #line 75 "parse-gram.y" | |
216 | typedef union YYSTYPE { | |
217 | symbol *symbol; | |
218 | symbol_list *list; | |
219 | int integer; | |
220 | char *chars; | |
221 | assoc assoc; | |
222 | uniqstr uniqstr; | |
223 | } YYSTYPE; | |
224 | /* Line 191 of yacc.c. */ | |
225 | #line 226 "parse-gram.c" | |
226 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ | |
227 | # define YYSTYPE_IS_DECLARED 1 | |
228 | # define YYSTYPE_IS_TRIVIAL 1 | |
229 | #endif | |
230 | ||
231 | #if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED) | |
232 | typedef struct YYLTYPE | |
233 | { | |
234 | int first_line; | |
235 | int first_column; | |
236 | int last_line; | |
237 | int last_column; | |
238 | } YYLTYPE; | |
239 | # define yyltype YYLTYPE /* obsolescent; will be withdrawn */ | |
240 | # define YYLTYPE_IS_DECLARED 1 | |
241 | # define YYLTYPE_IS_TRIVIAL 1 | |
242 | #endif | |
243 | ||
244 | ||
245 | /* Copy the second part of user declarations. */ | |
246 | ||
247 | ||
248 | /* Line 214 of yacc.c. */ | |
249 | #line 250 "parse-gram.c" | |
250 | ||
251 | #if ! defined (yyoverflow) || YYERROR_VERBOSE | |
252 | ||
253 | /* The parser invokes alloca or malloc; define the necessary symbols. */ | |
254 | ||
255 | # if YYSTACK_USE_ALLOCA | |
256 | # define YYSTACK_ALLOC alloca | |
257 | # else | |
258 | # ifndef YYSTACK_USE_ALLOCA | |
259 | # if defined (alloca) || defined (_ALLOCA_H) | |
260 | # define YYSTACK_ALLOC alloca | |
261 | # else | |
262 | # ifdef __GNUC__ | |
263 | # define YYSTACK_ALLOC __builtin_alloca | |
264 | # endif | |
265 | # endif | |
266 | # endif | |
267 | # endif | |
268 | ||
269 | # ifdef YYSTACK_ALLOC | |
270 | /* Pacify GCC's `empty if-body' warning. */ | |
271 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) | |
272 | # else | |
273 | # if defined (__STDC__) || defined (__cplusplus) | |
274 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ | |
275 | # define YYSIZE_T size_t | |
276 | # endif | |
277 | # define YYSTACK_ALLOC malloc | |
278 | # define YYSTACK_FREE free | |
279 | # endif | |
280 | #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ | |
281 | ||
282 | ||
283 | #if (! defined (yyoverflow) \ | |
284 | && (! defined (__cplusplus) \ | |
285 | || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) | |
286 | ||
287 | /* A type that is properly aligned for any stack member. */ | |
288 | union yyalloc | |
289 | { | |
290 | short yyss; | |
291 | YYSTYPE yyvs; | |
292 | YYLTYPE yyls; | |
293 | }; | |
294 | ||
295 | /* The size of the maximum gap between one aligned stack and the next. */ | |
296 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) | |
297 | ||
298 | /* The size of an array large to enough to hold all stacks, each with | |
299 | N elements. */ | |
300 | # define YYSTACK_BYTES(N) \ | |
301 | ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ | |
302 | + 2 * YYSTACK_GAP_MAXIMUM) | |
303 | ||
304 | /* Copy COUNT objects from FROM to TO. The source and destination do | |
305 | not overlap. */ | |
306 | # ifndef YYCOPY | |
307 | # if 1 < __GNUC__ | |
308 | # define YYCOPY(To, From, Count) \ | |
309 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) | |
310 | # else | |
311 | # define YYCOPY(To, From, Count) \ | |
312 | do \ | |
313 | { \ | |
314 | register YYSIZE_T yyi; \ | |
315 | for (yyi = 0; yyi < (Count); yyi++) \ | |
316 | (To)[yyi] = (From)[yyi]; \ | |
317 | } \ | |
318 | while (0) | |
319 | # endif | |
320 | # endif | |
321 | ||
322 | /* Relocate STACK from its old location to the new one. The | |
323 | local variables YYSIZE and YYSTACKSIZE give the old and new number of | |
324 | elements in the stack, and YYPTR gives the new location of the | |
325 | stack. Advance YYPTR to a properly aligned location for the next | |
326 | stack. */ | |
327 | # define YYSTACK_RELOCATE(Stack) \ | |
328 | do \ | |
329 | { \ | |
330 | YYSIZE_T yynewbytes; \ | |
331 | YYCOPY (&yyptr->Stack, Stack, yysize); \ | |
332 | Stack = &yyptr->Stack; \ | |
333 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ | |
334 | yyptr += yynewbytes / sizeof (*yyptr); \ | |
335 | } \ | |
336 | while (0) | |
337 | ||
338 | #endif | |
339 | ||
340 | #if defined (__STDC__) || defined (__cplusplus) | |
341 | typedef signed char yysigned_char; | |
342 | #else | |
343 | typedef short yysigned_char; | |
344 | #endif | |
345 | ||
346 | /* YYFINAL -- State number of the termination state. */ | |
347 | #define YYFINAL 3 | |
348 | /* YYLAST -- Last index in YYTABLE. */ | |
349 | #define YYLAST 157 | |
350 | ||
351 | /* YYNTOKENS -- Number of terminals. */ | |
352 | #define YYNTOKENS 46 | |
353 | /* YYNNTS -- Number of nonterminals. */ | |
354 | #define YYNNTS 25 | |
355 | /* YYNRULES -- Number of rules. */ | |
356 | #define YYNRULES 74 | |
357 | /* YYNRULES -- Number of states. */ | |
358 | #define YYNSTATES 101 | |
359 | ||
360 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ | |
361 | #define YYUNDEFTOK 2 | |
362 | #define YYMAXUTOK 300 | |
363 | ||
364 | #define YYTRANSLATE(YYX) \ | |
365 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) | |
366 | ||
367 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ | |
368 | static const unsigned char yytranslate[] = | |
369 | { | |
370 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
371 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
372 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
373 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
374 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
375 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
376 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
377 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
378 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
379 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
380 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
381 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
382 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
383 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
384 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
385 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
386 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
387 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
388 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
389 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
390 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
391 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
392 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
393 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
394 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
395 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, | |
396 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, | |
397 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, | |
398 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, | |
399 | 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, | |
400 | 45 | |
401 | }; | |
402 | ||
403 | #if YYDEBUG | |
404 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in | |
405 | YYRHS. */ | |
406 | static const unsigned char yyprhs[] = | |
407 | { | |
408 | 0, 0, 3, 8, 9, 12, 14, 16, 18, 22, | |
409 | 24, 26, 29, 33, 35, 37, 39, 43, 45, 49, | |
410 | 51, 53, 56, 58, 60, 62, 64, 66, 68, 71, | |
411 | 73, 76, 79, 80, 84, 85, 89, 93, 97, 99, | |
412 | 101, 103, 104, 106, 108, 111, 113, 115, 118, 121, | |
413 | 125, 127, 130, 132, 135, 137, 139, 142, 144, 145, | |
414 | 149, 151, 155, 156, 159, 162, 166, 170, 174, 176, | |
415 | 178, 180, 182, 184, 185 | |
416 | }; | |
417 | ||
418 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ | |
419 | static const yysigned_char yyrhs[] = | |
420 | { | |
421 | 47, 0, -1, 48, 42, 60, 70, -1, -1, 48, | |
422 | 49, -1, 50, -1, 43, -1, 17, -1, 18, 69, | |
423 | 69, -1, 19, -1, 20, -1, 21, 4, -1, 22, | |
424 | 37, 69, -1, 23, -1, 24, -1, 25, -1, 26, | |
425 | 37, 69, -1, 27, -1, 28, 37, 69, -1, 29, | |
426 | -1, 30, -1, 31, 69, -1, 33, -1, 34, -1, | |
427 | 35, -1, 38, -1, 54, -1, 51, -1, 32, 66, | |
428 | -1, 10, -1, 8, 57, -1, 9, 57, -1, -1, | |
429 | 6, 52, 59, -1, -1, 5, 53, 59, -1, 7, | |
430 | 36, 57, -1, 55, 56, 57, -1, 11, -1, 12, | |
431 | -1, 13, -1, -1, 36, -1, 66, -1, 57, 66, | |
432 | -1, 36, -1, 40, -1, 40, 4, -1, 40, 68, | |
433 | -1, 40, 4, 68, -1, 58, -1, 59, 58, -1, | |
434 | 61, -1, 60, 61, -1, 62, -1, 50, -1, 1, | |
435 | 38, -1, 38, -1, -1, 41, 63, 64, -1, 65, | |
436 | -1, 64, 39, 65, -1, -1, 65, 66, -1, 65, | |
437 | 67, -1, 65, 14, 66, -1, 65, 15, 4, -1, | |
438 | 65, 16, 36, -1, 40, -1, 68, -1, 45, -1, | |
439 | 3, -1, 3, -1, -1, 42, 44, -1 | |
440 | }; | |
441 | ||
442 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ | |
443 | static const unsigned short yyrline[] = | |
444 | { | |
445 | 0, 161, 161, 169, 171, 175, 176, 177, 178, 179, | |
446 | 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, | |
447 | 190, 191, 192, 193, 194, 195, 199, 200, 201, 205, | |
448 | 211, 218, 228, 228, 233, 233, 238, 248, 263, 264, | |
449 | 265, 269, 270, 276, 277, 282, 286, 291, 297, 303, | |
450 | 314, 315, 324, 325, 331, 332, 337, 341, 345, 345, | |
451 | 349, 350, 355, 356, 358, 360, 362, 364, 369, 370, | |
452 | 374, 380, 389, 396, 398 | |
453 | }; | |
454 | #endif | |
455 | ||
456 | #if YYDEBUG || YYERROR_VERBOSE | |
457 | /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. | |
458 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ | |
459 | static const char *const yytname[] = | |
460 | { | |
461 | "\"end of file\"", "error", "$undefined", "\"string\"", "\"integer\"", | |
462 | "\"%token\"", "\"%nterm\"", "\"%type\"", "\"%destructor {...}\"", | |
463 | "\"%printer {...}\"", "\"%union {...}\"", "\"%left\"", "\"%right\"", | |
464 | "\"%nonassoc\"", "\"%prec\"", "\"%dprec\"", "\"%merge\"", "\"%debug\"", | |
465 | "\"%define\"", "\"%defines\"", "\"%error-verbose\"", "\"%expect\"", | |
466 | "\"%file-prefix\"", "\"%glr-parser\"", "\"%lex-param {...}\"", | |
467 | "\"%locations\"", "\"%name-prefix\"", "\"%no-lines\"", "\"%output\"", | |
468 | "\"%parse-param {...}\"", "\"%pure-parser\"", "\"%skeleton\"", | |
469 | "\"%start\"", "\"%token-table\"", "\"%verbose\"", "\"%yacc\"", | |
470 | "\"type\"", "\"=\"", "\";\"", "\"|\"", "\"identifier\"", | |
471 | "\"identifier:\"", "\"%%\"", "\"%{...%}\"", "\"epilogue\"", "\"{...}\"", | |
472 | "$accept", "input", "declarations", "declaration", | |
473 | "grammar_declaration", "symbol_declaration", "@1", "@2", | |
474 | "precedence_declaration", "precedence_declarator", "type.opt", | |
475 | "symbols.1", "symbol_def", "symbol_defs.1", "grammar", | |
476 | "rules_or_grammar_declaration", "rules", "@3", "rhses.1", "rhs", | |
477 | "symbol", "action", "string_as_id", "string_content", "epilogue.opt", 0 | |
478 | }; | |
479 | #endif | |
480 | ||
481 | # ifdef YYPRINT | |
482 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to | |
483 | token YYLEX-NUM. */ | |
484 | static const unsigned short yytoknum[] = | |
485 | { | |
486 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, | |
487 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, | |
488 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, | |
489 | 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, | |
490 | 295, 296, 297, 298, 299, 300 | |
491 | }; | |
492 | # endif | |
493 | ||
494 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ | |
495 | static const unsigned char yyr1[] = | |
496 | { | |
497 | 0, 46, 47, 48, 48, 49, 49, 49, 49, 49, | |
498 | 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, | |
499 | 49, 49, 49, 49, 49, 49, 50, 50, 50, 50, | |
500 | 50, 50, 52, 51, 53, 51, 51, 54, 55, 55, | |
501 | 55, 56, 56, 57, 57, 58, 58, 58, 58, 58, | |
502 | 59, 59, 60, 60, 61, 61, 61, 61, 63, 62, | |
503 | 64, 64, 65, 65, 65, 65, 65, 65, 66, 66, | |
504 | 67, 68, 69, 70, 70 | |
505 | }; | |
506 | ||
507 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ | |
508 | static const unsigned char yyr2[] = | |
509 | { | |
510 | 0, 2, 4, 0, 2, 1, 1, 1, 3, 1, | |
511 | 1, 2, 3, 1, 1, 1, 3, 1, 3, 1, | |
512 | 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, | |
513 | 2, 2, 0, 3, 0, 3, 3, 3, 1, 1, | |
514 | 1, 0, 1, 1, 2, 1, 1, 2, 2, 3, | |
515 | 1, 2, 1, 2, 1, 1, 2, 1, 0, 3, | |
516 | 1, 3, 0, 2, 2, 3, 3, 3, 1, 1, | |
517 | 1, 1, 1, 0, 2 | |
518 | }; | |
519 | ||
520 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state | |
521 | STATE-NUM when YYTABLE doesn't specify something else to do. Zero | |
522 | means the default is an error. */ | |
523 | static const unsigned char yydefact[] = | |
524 | { | |
525 | 3, 0, 0, 1, 34, 32, 0, 0, 0, 29, | |
526 | 38, 39, 40, 7, 0, 9, 10, 0, 0, 13, | |
527 | 14, 15, 0, 17, 0, 19, 20, 0, 0, 22, | |
528 | 23, 24, 25, 0, 6, 4, 5, 27, 26, 41, | |
529 | 0, 0, 0, 71, 68, 30, 43, 69, 31, 72, | |
530 | 0, 11, 0, 0, 0, 21, 28, 0, 57, 58, | |
531 | 55, 0, 52, 54, 42, 0, 45, 46, 50, 35, | |
532 | 33, 36, 44, 8, 12, 16, 18, 56, 62, 0, | |
533 | 53, 2, 37, 47, 48, 51, 59, 60, 74, 49, | |
534 | 62, 0, 0, 0, 70, 63, 64, 61, 65, 66, | |
535 | 67 | |
536 | }; | |
537 | ||
538 | /* YYDEFGOTO[NTERM-NUM]. */ | |
539 | static const yysigned_char yydefgoto[] = | |
540 | { | |
541 | -1, 1, 2, 35, 60, 37, 41, 40, 38, 39, | |
542 | 65, 45, 68, 69, 61, 62, 63, 78, 86, 87, | |
543 | 46, 96, 47, 50, 81 | |
544 | }; | |
545 | ||
546 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing | |
547 | STATE-NUM. */ | |
548 | #define YYPACT_NINF -65 | |
549 | static const yysigned_char yypact[] = | |
550 | { | |
551 | -65, 5, 114, -65, -65, -65, -24, 1, 1, -65, | |
552 | -65, -65, -65, -65, 10, -65, -65, 11, -23, -65, | |
553 | -65, -65, -21, -65, -15, -65, -65, 10, 1, -65, | |
554 | -65, -65, -65, 77, -65, -65, -65, -65, -65, -13, | |
555 | -34, -34, 1, -65, -65, 1, -65, -65, 1, -65, | |
556 | 10, -65, 10, 10, 10, -65, -65, -17, -65, -65, | |
557 | -65, 39, -65, -65, -65, 1, -65, 4, -65, -34, | |
558 | -34, 1, -65, -65, -65, -65, -65, -65, -65, -20, | |
559 | -65, -65, 1, 22, -65, -65, -12, 15, -65, -65, | |
560 | -65, 1, 24, -10, -65, -65, -65, 15, -65, -65, | |
561 | -65 | |
562 | }; | |
563 | ||
564 | /* YYPGOTO[NTERM-NUM]. */ | |
565 | static const yysigned_char yypgoto[] = | |
566 | { | |
567 | -65, -65, -65, -65, 30, -65, -65, -65, -65, -65, | |
568 | -65, -7, -60, -8, -65, -19, -65, -65, -65, -37, | |
569 | -28, -65, -64, -16, -65 | |
570 | }; | |
571 | ||
572 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If | |
573 | positive, shift that token. If negative, reduce the rule which | |
574 | number is the opposite. If zero, do what YYDEFACT says. | |
575 | If YYTABLE_NINF, syntax error. */ | |
576 | #define YYTABLE_NINF -74 | |
577 | static const yysigned_char yytable[] = | |
578 | { | |
579 | 56, 48, 66, 84, 43, 3, 67, 43, 83, 85, | |
580 | 85, 55, 42, 49, 52, 51, 53, 72, 43, 89, | |
581 | 72, 77, 54, 64, 88, 43, 100, 90, 99, 91, | |
582 | 92, 93, 36, 70, 73, 71, 74, 75, 76, -73, | |
583 | 57, 44, 80, 72, 4, 5, 6, 7, 8, 9, | |
584 | 10, 11, 12, 97, 72, 44, 0, 0, 82, 95, | |
585 | 94, 0, 0, 98, 0, 0, 0, 0, 0, 95, | |
586 | 0, 28, 0, 0, 0, 0, 0, 58, 57, 0, | |
587 | 59, 79, 4, 5, 6, 7, 8, 9, 10, 11, | |
588 | 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
589 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, | |
590 | 0, 0, 0, 0, 0, 58, 0, 0, 59, 4, | |
591 | 5, 6, 7, 8, 9, 10, 11, 12, 0, 0, | |
592 | 0, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
593 | 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
594 | 0, 0, 32, 0, 0, 0, 33, 34 | |
595 | }; | |
596 | ||
597 | static const yysigned_char yycheck[] = | |
598 | { | |
599 | 28, 8, 36, 67, 3, 0, 40, 3, 4, 69, | |
600 | 70, 27, 36, 3, 37, 4, 37, 45, 3, 83, | |
601 | 48, 38, 37, 36, 44, 3, 36, 39, 4, 14, | |
602 | 15, 16, 2, 41, 50, 42, 52, 53, 54, 0, | |
603 | 1, 40, 61, 71, 5, 6, 7, 8, 9, 10, | |
604 | 11, 12, 13, 90, 82, 40, -1, -1, 65, 87, | |
605 | 45, -1, -1, 91, -1, -1, -1, -1, -1, 97, | |
606 | -1, 32, -1, -1, -1, -1, -1, 38, 1, -1, | |
607 | 41, 42, 5, 6, 7, 8, 9, 10, 11, 12, | |
608 | 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, | |
609 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 32, | |
610 | -1, -1, -1, -1, -1, 38, -1, -1, 41, 5, | |
611 | 6, 7, 8, 9, 10, 11, 12, 13, -1, -1, | |
612 | -1, 17, 18, 19, 20, 21, 22, 23, 24, 25, | |
613 | 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, | |
614 | -1, -1, 38, -1, -1, -1, 42, 43 | |
615 | }; | |
616 | ||
617 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing | |
618 | symbol of state STATE-NUM. */ | |
619 | static const unsigned char yystos[] = | |
620 | { | |
621 | 0, 47, 48, 0, 5, 6, 7, 8, 9, 10, | |
622 | 11, 12, 13, 17, 18, 19, 20, 21, 22, 23, | |
623 | 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, | |
624 | 34, 35, 38, 42, 43, 49, 50, 51, 54, 55, | |
625 | 53, 52, 36, 3, 40, 57, 66, 68, 57, 3, | |
626 | 69, 4, 37, 37, 37, 69, 66, 1, 38, 41, | |
627 | 50, 60, 61, 62, 36, 56, 36, 40, 58, 59, | |
628 | 59, 57, 66, 69, 69, 69, 69, 38, 63, 42, | |
629 | 61, 70, 57, 4, 68, 58, 64, 65, 44, 68, | |
630 | 39, 14, 15, 16, 45, 66, 67, 65, 66, 4, | |
631 | 36 | |
632 | }; | |
633 | ||
634 | #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) | |
635 | # define YYSIZE_T __SIZE_TYPE__ | |
636 | #endif | |
637 | #if ! defined (YYSIZE_T) && defined (size_t) | |
638 | # define YYSIZE_T size_t | |
639 | #endif | |
640 | #if ! defined (YYSIZE_T) | |
641 | # if defined (__STDC__) || defined (__cplusplus) | |
642 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ | |
643 | # define YYSIZE_T size_t | |
644 | # endif | |
645 | #endif | |
646 | #if ! defined (YYSIZE_T) | |
647 | # define YYSIZE_T unsigned int | |
648 | #endif | |
649 | ||
650 | #define yyerrok (yyerrstatus = 0) | |
651 | #define yyclearin (yychar = YYEMPTY) | |
652 | #define YYEMPTY (-2) | |
653 | #define YYEOF 0 | |
654 | ||
655 | #define YYACCEPT goto yyacceptlab | |
656 | #define YYABORT goto yyabortlab | |
657 | #define YYERROR do \ | |
658 | { \ | |
659 | yylerrsp = yylsp; \ | |
660 | *++yylerrsp = yyloc; \ | |
661 | goto yyerrlab1; \ | |
662 | } \ | |
663 | while (0) | |
664 | ||
665 | ||
666 | /* Like YYERROR except do call yyerror. This remains here temporarily | |
667 | to ease the transition to the new meaning of YYERROR, for GCC. | |
668 | Once GCC version 2 has supplanted version 1, this can go. */ | |
669 | ||
670 | #define YYFAIL goto yyerrlab | |
671 | ||
672 | #define YYRECOVERING() (!!yyerrstatus) | |
673 | ||
674 | #define YYBACKUP(Token, Value) \ | |
675 | do \ | |
676 | if (yychar == YYEMPTY && yylen == 1) \ | |
677 | { \ | |
678 | yychar = (Token); \ | |
679 | yylval = (Value); \ | |
680 | yytoken = YYTRANSLATE (yychar); \ | |
681 | YYPOPSTACK; \ | |
682 | goto yybackup; \ | |
683 | } \ | |
684 | else \ | |
685 | { \ | |
686 | yyerror ("syntax error: cannot back up");\ | |
687 | YYERROR; \ | |
688 | } \ | |
689 | while (0) | |
690 | ||
691 | #define YYTERROR 1 | |
692 | #define YYERRCODE 256 | |
693 | ||
694 | /* YYLLOC_DEFAULT -- Compute the default location (before the actions | |
695 | are run). */ | |
696 | ||
697 | #ifndef YYLLOC_DEFAULT | |
698 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ | |
699 | Current.first_line = Rhs[1].first_line; \ | |
700 | Current.first_column = Rhs[1].first_column; \ | |
701 | Current.last_line = Rhs[N].last_line; \ | |
702 | Current.last_column = Rhs[N].last_column; | |
703 | #endif | |
704 | ||
705 | /* YYLEX -- calling `yylex' with the right arguments. */ | |
706 | ||
707 | #ifdef YYLEX_PARAM | |
708 | # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) | |
709 | #else | |
710 | # define YYLEX yylex (&yylval, &yylloc) | |
711 | #endif | |
712 | ||
713 | /* Enable debugging if requested. */ | |
714 | #if YYDEBUG | |
715 | ||
716 | # ifndef YYFPRINTF | |
717 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ | |
718 | # define YYFPRINTF fprintf | |
719 | # endif | |
720 | ||
721 | # define YYDPRINTF(Args) \ | |
722 | do { \ | |
723 | if (yydebug) \ | |
724 | YYFPRINTF Args; \ | |
725 | } while (0) | |
726 | ||
727 | # define YYDSYMPRINT(Args) \ | |
728 | do { \ | |
729 | if (yydebug) \ | |
730 | yysymprint Args; \ | |
731 | } while (0) | |
732 | ||
733 | # define YYDSYMPRINTF(Title, Token, Value, Location) \ | |
734 | do { \ | |
735 | if (yydebug) \ | |
736 | { \ | |
737 | YYFPRINTF (stderr, "%s ", Title); \ | |
738 | yysymprint (stderr, \ | |
739 | Token, Value, Location); \ | |
740 | YYFPRINTF (stderr, "\n"); \ | |
741 | } \ | |
742 | } while (0) | |
743 | ||
744 | /*------------------------------------------------------------------. | |
745 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | | |
746 | | TOP (cinluded). | | |
747 | `------------------------------------------------------------------*/ | |
748 | ||
749 | #if defined (__STDC__) || defined (__cplusplus) | |
750 | static void | |
751 | yy_stack_print (short *bottom, short *top) | |
752 | #else | |
753 | static void | |
754 | yy_stack_print (bottom, top) | |
755 | short *bottom; | |
756 | short *top; | |
757 | #endif | |
758 | { | |
759 | YYFPRINTF (stderr, "Stack now"); | |
760 | for (/* Nothing. */; bottom <= top; ++bottom) | |
761 | YYFPRINTF (stderr, " %d", *bottom); | |
762 | YYFPRINTF (stderr, "\n"); | |
763 | } | |
764 | ||
765 | # define YY_STACK_PRINT(Bottom, Top) \ | |
766 | do { \ | |
767 | if (yydebug) \ | |
768 | yy_stack_print ((Bottom), (Top)); \ | |
769 | } while (0) | |
770 | ||
771 | ||
772 | /*------------------------------------------------. | |
773 | | Report that the YYRULE is going to be reduced. | | |
774 | `------------------------------------------------*/ | |
775 | ||
776 | #if defined (__STDC__) || defined (__cplusplus) | |
777 | static void | |
778 | yy_reduce_print (int yyrule) | |
779 | #else | |
780 | static void | |
781 | yy_reduce_print (yyrule) | |
782 | int yyrule; | |
783 | #endif | |
784 | { | |
785 | int yyi; | |
786 | unsigned int yylno = yyrline[yyrule]; | |
787 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", | |
788 | yyrule - 1, yylno); | |
789 | /* Print the symbols being reduced, and their result. */ | |
790 | for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) | |
791 | YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); | |
792 | YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); | |
793 | } | |
794 | ||
795 | # define YY_REDUCE_PRINT(Rule) \ | |
796 | do { \ | |
797 | if (yydebug) \ | |
798 | yy_reduce_print (Rule); \ | |
799 | } while (0) | |
800 | ||
801 | /* Nonzero means print parse trace. It is left uninitialized so that | |
802 | multiple parsers can coexist. */ | |
803 | int yydebug; | |
804 | #else /* !YYDEBUG */ | |
805 | # define YYDPRINTF(Args) | |
806 | # define YYDSYMPRINT(Args) | |
807 | # define YYDSYMPRINTF(Title, Token, Value, Location) | |
808 | # define YY_STACK_PRINT(Bottom, Top) | |
809 | # define YY_REDUCE_PRINT(Rule) | |
810 | #endif /* !YYDEBUG */ | |
811 | ||
812 | ||
813 | /* YYINITDEPTH -- initial size of the parser's stacks. */ | |
814 | #ifndef YYINITDEPTH | |
815 | # define YYINITDEPTH 200 | |
816 | #endif | |
817 | ||
818 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only | |
819 | if the built-in stack extension method is used). | |
820 | ||
821 | Do not make this value too large; the results are undefined if | |
822 | SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) | |
823 | evaluated with infinite-precision integer arithmetic. */ | |
824 | ||
825 | #if YYMAXDEPTH == 0 | |
826 | # undef YYMAXDEPTH | |
827 | #endif | |
828 | ||
829 | #ifndef YYMAXDEPTH | |
830 | # define YYMAXDEPTH 10000 | |
831 | #endif | |
832 | ||
833 | \f | |
834 | ||
835 | #if YYERROR_VERBOSE | |
836 | ||
837 | # ifndef yystrlen | |
838 | # if defined (__GLIBC__) && defined (_STRING_H) | |
839 | # define yystrlen strlen | |
840 | # else | |
841 | /* Return the length of YYSTR. */ | |
842 | static YYSIZE_T | |
843 | # if defined (__STDC__) || defined (__cplusplus) | |
844 | yystrlen (const char *yystr) | |
845 | # else | |
846 | yystrlen (yystr) | |
847 | const char *yystr; | |
848 | # endif | |
849 | { | |
850 | register const char *yys = yystr; | |
851 | ||
852 | while (*yys++ != '\0') | |
853 | continue; | |
854 | ||
855 | return yys - yystr - 1; | |
856 | } | |
857 | # endif | |
858 | # endif | |
859 | ||
860 | # ifndef yystpcpy | |
861 | # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) | |
862 | # define yystpcpy stpcpy | |
863 | # else | |
864 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in | |
865 | YYDEST. */ | |
866 | static char * | |
867 | # if defined (__STDC__) || defined (__cplusplus) | |
868 | yystpcpy (char *yydest, const char *yysrc) | |
869 | # else | |
870 | yystpcpy (yydest, yysrc) | |
871 | char *yydest; | |
872 | const char *yysrc; | |
873 | # endif | |
874 | { | |
875 | register char *yyd = yydest; | |
876 | register const char *yys = yysrc; | |
877 | ||
878 | while ((*yyd++ = *yys++) != '\0') | |
879 | continue; | |
880 | ||
881 | return yyd - 1; | |
882 | } | |
883 | # endif | |
884 | # endif | |
885 | ||
886 | #endif /* !YYERROR_VERBOSE */ | |
887 | ||
888 | \f | |
889 | ||
890 | #if YYDEBUG | |
891 | /*--------------------------------. | |
892 | | Print this symbol on YYOUTPUT. | | |
893 | `--------------------------------*/ | |
894 | ||
895 | #if defined (__STDC__) || defined (__cplusplus) | |
896 | static void | |
897 | yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp) | |
898 | #else | |
899 | static void | |
900 | yysymprint (yyoutput, yytype, yyvaluep, yylocationp) | |
901 | FILE *yyoutput; | |
902 | int yytype; | |
903 | YYSTYPE *yyvaluep; | |
904 | YYLTYPE *yylocationp; | |
905 | #endif | |
906 | { | |
907 | /* Pacify ``unused variable'' warnings. */ | |
908 | (void) yyvaluep; | |
909 | (void) yylocationp; | |
910 | ||
911 | if (yytype < YYNTOKENS) | |
912 | { | |
913 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); | |
914 | # ifdef YYPRINT | |
915 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); | |
916 | # endif | |
917 | } | |
918 | else | |
919 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); | |
920 | ||
921 | switch (yytype) | |
922 | { | |
923 | default: | |
924 | break; | |
925 | } | |
926 | YYFPRINTF (yyoutput, ")"); | |
927 | } | |
928 | ||
929 | #endif /* ! YYDEBUG */ | |
930 | /*-----------------------------------------------. | |
931 | | Release the memory associated to this symbol. | | |
932 | `-----------------------------------------------*/ | |
933 | ||
934 | #if defined (__STDC__) || defined (__cplusplus) | |
935 | static void | |
936 | yydestruct (int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp) | |
937 | #else | |
938 | static void | |
939 | yydestruct (yytype, yyvaluep, yylocationp) | |
940 | int yytype; | |
941 | YYSTYPE *yyvaluep; | |
942 | YYLTYPE *yylocationp; | |
943 | #endif | |
944 | { | |
945 | /* Pacify ``unused variable'' warnings. */ | |
946 | (void) yyvaluep; | |
947 | (void) yylocationp; | |
948 | ||
949 | switch (yytype) | |
950 | { | |
951 | ||
952 | default: | |
953 | break; | |
954 | } | |
955 | } | |
956 | \f | |
957 | ||
958 | /* Prevent warnings from -Wmissing-prototypes. */ | |
959 | ||
960 | #ifdef YYPARSE_PARAM | |
961 | # if defined (__STDC__) || defined (__cplusplus) | |
962 | int yyparse (void *YYPARSE_PARAM); | |
963 | # else | |
964 | int yyparse (); | |
965 | # endif | |
966 | #else /* ! YYPARSE_PARAM */ | |
967 | #if defined (__STDC__) || defined (__cplusplus) | |
968 | int yyparse (void); | |
969 | #else | |
970 | int yyparse (); | |
971 | #endif | |
972 | #endif /* ! YYPARSE_PARAM */ | |
973 | ||
974 | ||
975 | ||
976 | ||
977 | ||
978 | ||
979 | /*----------. | |
980 | | yyparse. | | |
981 | `----------*/ | |
982 | ||
983 | #ifdef YYPARSE_PARAM | |
984 | # if defined (__STDC__) || defined (__cplusplus) | |
985 | int yyparse (void *YYPARSE_PARAM) | |
986 | # else | |
987 | int yyparse (YYPARSE_PARAM) | |
988 | void *YYPARSE_PARAM; | |
989 | # endif | |
990 | #else /* ! YYPARSE_PARAM */ | |
991 | #if defined (__STDC__) || defined (__cplusplus) | |
992 | int | |
993 | yyparse (void) | |
994 | #else | |
995 | int | |
996 | yyparse () | |
997 | ||
998 | #endif | |
999 | #endif | |
1000 | { | |
1001 | /* The lookahead symbol. */ | |
1002 | int yychar; | |
1003 | ||
1004 | /* The semantic value of the lookahead symbol. */ | |
1005 | YYSTYPE yylval; | |
1006 | ||
1007 | /* Number of syntax errors so far. */ | |
1008 | int yynerrs; | |
1009 | /* Location data for the lookahead symbol. */ | |
1010 | YYLTYPE yylloc; | |
1011 | ||
1012 | register int yystate; | |
1013 | register int yyn; | |
1014 | int yyresult; | |
1015 | /* Number of tokens to shift before error messages enabled. */ | |
1016 | int yyerrstatus; | |
1017 | /* Lookahead token as an internal (translated) token number. */ | |
1018 | int yytoken = 0; | |
1019 | ||
1020 | /* Three stacks and their tools: | |
1021 | `yyss': related to states, | |
1022 | `yyvs': related to semantic values, | |
1023 | `yyls': related to locations. | |
1024 | ||
1025 | Refer to the stacks thru separate pointers, to allow yyoverflow | |
1026 | to reallocate them elsewhere. */ | |
1027 | ||
1028 | /* The state stack. */ | |
1029 | short yyssa[YYINITDEPTH]; | |
1030 | short *yyss = yyssa; | |
1031 | register short *yyssp; | |
1032 | ||
1033 | /* The semantic value stack. */ | |
1034 | YYSTYPE yyvsa[YYINITDEPTH]; | |
1035 | YYSTYPE *yyvs = yyvsa; | |
1036 | register YYSTYPE *yyvsp; | |
1037 | ||
1038 | /* The location stack. */ | |
1039 | YYLTYPE yylsa[YYINITDEPTH]; | |
1040 | YYLTYPE *yyls = yylsa; | |
1041 | YYLTYPE *yylsp; | |
1042 | YYLTYPE *yylerrsp; | |
1043 | ||
1044 | #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) | |
1045 | ||
1046 | YYSIZE_T yystacksize = YYINITDEPTH; | |
1047 | ||
1048 | /* The variables used to return semantic value and location from the | |
1049 | action routines. */ | |
1050 | YYSTYPE yyval; | |
1051 | YYLTYPE yyloc; | |
1052 | ||
1053 | /* When reducing, the number of symbols on the RHS of the reduced | |
1054 | rule. */ | |
1055 | int yylen; | |
1056 | ||
1057 | YYDPRINTF ((stderr, "Starting parse\n")); | |
1058 | ||
1059 | yystate = 0; | |
1060 | yyerrstatus = 0; | |
1061 | yynerrs = 0; | |
1062 | yychar = YYEMPTY; /* Cause a token to be read. */ | |
1063 | ||
1064 | /* Initialize stack pointers. | |
1065 | Waste one element of value and location stack | |
1066 | so that they stay on the same level as the state stack. | |
1067 | The wasted elements are never initialized. */ | |
1068 | ||
1069 | yyssp = yyss; | |
1070 | yyvsp = yyvs; | |
1071 | yylsp = yyls; | |
1072 | goto yysetstate; | |
1073 | ||
1074 | /*------------------------------------------------------------. | |
1075 | | yynewstate -- Push a new state, which is found in yystate. | | |
1076 | `------------------------------------------------------------*/ | |
1077 | yynewstate: | |
1078 | /* In all cases, when you get here, the value and location stacks | |
1079 | have just been pushed. so pushing a state here evens the stacks. | |
1080 | */ | |
1081 | yyssp++; | |
1082 | ||
1083 | yysetstate: | |
1084 | *yyssp = yystate; | |
1085 | ||
1086 | if (yyss + yystacksize - 1 <= yyssp) | |
1087 | { | |
1088 | /* Get the current used size of the three stacks, in elements. */ | |
1089 | YYSIZE_T yysize = yyssp - yyss + 1; | |
1090 | ||
1091 | #ifdef yyoverflow | |
1092 | { | |
1093 | /* Give user a chance to reallocate the stack. Use copies of | |
1094 | these so that the &'s don't force the real ones into | |
1095 | memory. */ | |
1096 | YYSTYPE *yyvs1 = yyvs; | |
1097 | short *yyss1 = yyss; | |
1098 | YYLTYPE *yyls1 = yyls; | |
1099 | ||
1100 | /* Each stack pointer address is followed by the size of the | |
1101 | data in use in that stack, in bytes. This used to be a | |
1102 | conditional around just the two extra args, but that might | |
1103 | be undefined if yyoverflow is a macro. */ | |
1104 | yyoverflow ("parser stack overflow", | |
1105 | &yyss1, yysize * sizeof (*yyssp), | |
1106 | &yyvs1, yysize * sizeof (*yyvsp), | |
1107 | &yyls1, yysize * sizeof (*yylsp), | |
1108 | &yystacksize); | |
1109 | yyls = yyls1; | |
1110 | yyss = yyss1; | |
1111 | yyvs = yyvs1; | |
1112 | } | |
1113 | #else /* no yyoverflow */ | |
1114 | # ifndef YYSTACK_RELOCATE | |
1115 | goto yyoverflowlab; | |
1116 | # else | |
1117 | /* Extend the stack our own way. */ | |
1118 | if (YYMAXDEPTH <= yystacksize) | |
1119 | goto yyoverflowlab; | |
1120 | yystacksize *= 2; | |
1121 | if (YYMAXDEPTH < yystacksize) | |
1122 | yystacksize = YYMAXDEPTH; | |
1123 | ||
1124 | { | |
1125 | short *yyss1 = yyss; | |
1126 | union yyalloc *yyptr = | |
1127 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); | |
1128 | if (! yyptr) | |
1129 | goto yyoverflowlab; | |
1130 | YYSTACK_RELOCATE (yyss); | |
1131 | YYSTACK_RELOCATE (yyvs); | |
1132 | YYSTACK_RELOCATE (yyls); | |
1133 | # undef YYSTACK_RELOCATE | |
1134 | if (yyss1 != yyssa) | |
1135 | YYSTACK_FREE (yyss1); | |
1136 | } | |
1137 | # endif | |
1138 | #endif /* no yyoverflow */ | |
1139 | ||
1140 | yyssp = yyss + yysize - 1; | |
1141 | yyvsp = yyvs + yysize - 1; | |
1142 | yylsp = yyls + yysize - 1; | |
1143 | ||
1144 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", | |
1145 | (unsigned long int) yystacksize)); | |
1146 | ||
1147 | if (yyss + yystacksize - 1 <= yyssp) | |
1148 | YYABORT; | |
1149 | } | |
1150 | ||
1151 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); | |
1152 | ||
1153 | goto yybackup; | |
1154 | ||
1155 | /*-----------. | |
1156 | | yybackup. | | |
1157 | `-----------*/ | |
1158 | yybackup: | |
1159 | ||
1160 | /* Do appropriate processing given the current state. */ | |
1161 | /* Read a lookahead token if we need one and don't already have one. */ | |
1162 | /* yyresume: */ | |
1163 | ||
1164 | /* First try to decide what to do without reference to lookahead token. */ | |
1165 | ||
1166 | yyn = yypact[yystate]; | |
1167 | if (yyn == YYPACT_NINF) | |
1168 | goto yydefault; | |
1169 | ||
1170 | /* Not known => get a lookahead token if don't already have one. */ | |
1171 | ||
1172 | /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ | |
1173 | if (yychar == YYEMPTY) | |
1174 | { | |
1175 | YYDPRINTF ((stderr, "Reading a token: ")); | |
1176 | yychar = YYLEX; | |
1177 | } | |
1178 | ||
1179 | if (yychar <= YYEOF) | |
1180 | { | |
1181 | yychar = yytoken = YYEOF; | |
1182 | YYDPRINTF ((stderr, "Now at end of input.\n")); | |
1183 | } | |
1184 | else | |
1185 | { | |
1186 | yytoken = YYTRANSLATE (yychar); | |
1187 | YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); | |
1188 | } | |
1189 | ||
1190 | /* If the proper action on seeing token YYTOKEN is to reduce or to | |
1191 | detect an error, take that action. */ | |
1192 | yyn += yytoken; | |
1193 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) | |
1194 | goto yydefault; | |
1195 | yyn = yytable[yyn]; | |
1196 | if (yyn <= 0) | |
1197 | { | |
1198 | if (yyn == 0 || yyn == YYTABLE_NINF) | |
1199 | goto yyerrlab; | |
1200 | yyn = -yyn; | |
1201 | goto yyreduce; | |
1202 | } | |
1203 | ||
1204 | if (yyn == YYFINAL) | |
1205 | YYACCEPT; | |
1206 | ||
1207 | /* Shift the lookahead token. */ | |
1208 | YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); | |
1209 | ||
1210 | /* Discard the token being shifted unless it is eof. */ | |
1211 | if (yychar != YYEOF) | |
1212 | yychar = YYEMPTY; | |
1213 | ||
1214 | *++yyvsp = yylval; | |
1215 | *++yylsp = yylloc; | |
1216 | ||
1217 | /* Count tokens shifted since error; after three, turn off error | |
1218 | status. */ | |
1219 | if (yyerrstatus) | |
1220 | yyerrstatus--; | |
1221 | ||
1222 | yystate = yyn; | |
1223 | goto yynewstate; | |
1224 | ||
1225 | ||
1226 | /*-----------------------------------------------------------. | |
1227 | | yydefault -- do the default action for the current state. | | |
1228 | `-----------------------------------------------------------*/ | |
1229 | yydefault: | |
1230 | yyn = yydefact[yystate]; | |
1231 | if (yyn == 0) | |
1232 | goto yyerrlab; | |
1233 | goto yyreduce; | |
1234 | ||
1235 | ||
1236 | /*-----------------------------. | |
1237 | | yyreduce -- Do a reduction. | | |
1238 | `-----------------------------*/ | |
1239 | yyreduce: | |
1240 | /* yyn is the number of a rule to reduce with. */ | |
1241 | yylen = yyr2[yyn]; | |
1242 | ||
1243 | /* If YYLEN is nonzero, implement the default value of the action: | |
1244 | `$$ = $1'. | |
1245 | ||
1246 | Otherwise, the following line sets YYVAL to garbage. | |
1247 | This behavior is undocumented and Bison | |
1248 | users should not rely upon it. Assigning to YYVAL | |
1249 | unconditionally makes the parser a bit smaller, and it avoids a | |
1250 | GCC warning that YYVAL may be used uninitialized. */ | |
1251 | yyval = yyvsp[1-yylen]; | |
1252 | ||
1253 | /* Default location. */ | |
1254 | YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); | |
1255 | YY_REDUCE_PRINT (yyn); | |
1256 | switch (yyn) | |
1257 | { | |
1258 | case 6: | |
1259 | #line 176 "parse-gram.y" | |
1260 | { prologue_augment (yyvsp[0].chars, yylsp[0]); } | |
1261 | break; | |
1262 | ||
1263 | case 7: | |
1264 | #line 177 "parse-gram.y" | |
1265 | { debug_flag = 1; } | |
1266 | break; | |
1267 | ||
1268 | case 8: | |
1269 | #line 178 "parse-gram.y" | |
1270 | { muscle_insert (yyvsp[-1].chars, yyvsp[0].chars); } | |
1271 | break; | |
1272 | ||
1273 | case 9: | |
1274 | #line 179 "parse-gram.y" | |
1275 | { defines_flag = 1; } | |
1276 | break; | |
1277 | ||
1278 | case 10: | |
1279 | #line 180 "parse-gram.y" | |
1280 | { error_verbose = 1; } | |
1281 | break; | |
1282 | ||
1283 | case 11: | |
1284 | #line 181 "parse-gram.y" | |
1285 | { expected_conflicts = yyvsp[0].integer; } | |
1286 | break; | |
1287 | ||
1288 | case 12: | |
1289 | #line 182 "parse-gram.y" | |
1290 | { spec_file_prefix = yyvsp[0].chars; } | |
1291 | break; | |
1292 | ||
1293 | case 13: | |
1294 | #line 183 "parse-gram.y" | |
1295 | { glr_parser = 1; } | |
1296 | break; | |
1297 | ||
1298 | case 14: | |
1299 | #line 184 "parse-gram.y" | |
1300 | { add_param ("lex_param", yyvsp[0].chars, yylsp[0]); } | |
1301 | break; | |
1302 | ||
1303 | case 15: | |
1304 | #line 185 "parse-gram.y" | |
1305 | { locations_flag = 1; } | |
1306 | break; | |
1307 | ||
1308 | case 16: | |
1309 | #line 186 "parse-gram.y" | |
1310 | { spec_name_prefix = yyvsp[0].chars; } | |
1311 | break; | |
1312 | ||
1313 | case 17: | |
1314 | #line 187 "parse-gram.y" | |
1315 | { no_lines_flag = 1; } | |
1316 | break; | |
1317 | ||
1318 | case 18: | |
1319 | #line 188 "parse-gram.y" | |
1320 | { spec_outfile = yyvsp[0].chars; } | |
1321 | break; | |
1322 | ||
1323 | case 19: | |
1324 | #line 189 "parse-gram.y" | |
1325 | { add_param ("parse_param", yyvsp[0].chars, yylsp[0]); } | |
1326 | break; | |
1327 | ||
1328 | case 20: | |
1329 | #line 190 "parse-gram.y" | |
1330 | { pure_parser = 1; } | |
1331 | break; | |
1332 | ||
1333 | case 21: | |
1334 | #line 191 "parse-gram.y" | |
1335 | { skeleton = yyvsp[0].chars; } | |
1336 | break; | |
1337 | ||
1338 | case 22: | |
1339 | #line 192 "parse-gram.y" | |
1340 | { token_table_flag = 1; } | |
1341 | break; | |
1342 | ||
1343 | case 23: | |
1344 | #line 193 "parse-gram.y" | |
1345 | { report_flag = report_states; } | |
1346 | break; | |
1347 | ||
1348 | case 24: | |
1349 | #line 194 "parse-gram.y" | |
1350 | { yacc_flag = 1; } | |
1351 | break; | |
1352 | ||
1353 | case 28: | |
1354 | #line 202 "parse-gram.y" | |
1355 | { | |
1356 | grammar_start_symbol_set (yyvsp[0].symbol, yylsp[0]); | |
1357 | } | |
1358 | break; | |
1359 | ||
1360 | case 29: | |
1361 | #line 206 "parse-gram.y" | |
1362 | { | |
1363 | typed = 1; | |
1364 | MUSCLE_INSERT_INT ("stype_line", yylsp[0].start.line); | |
1365 | muscle_insert ("stype", yyvsp[0].chars); | |
1366 | } | |
1367 | break; | |
1368 | ||
1369 | case 30: | |
1370 | #line 212 "parse-gram.y" | |
1371 | { | |
1372 | symbol_list *list; | |
1373 | for (list = yyvsp[0].list; list; list = list->next) | |
1374 | symbol_destructor_set (list->sym, yyvsp[-1].chars, yylsp[-1]); | |
1375 | symbol_list_free (yyvsp[0].list); | |
1376 | } | |
1377 | break; | |
1378 | ||
1379 | case 31: | |
1380 | #line 219 "parse-gram.y" | |
1381 | { | |
1382 | symbol_list *list; | |
1383 | for (list = yyvsp[0].list; list; list = list->next) | |
1384 | symbol_printer_set (list->sym, yyvsp[-1].chars, list->location); | |
1385 | symbol_list_free (yyvsp[0].list); | |
1386 | } | |
1387 | break; | |
1388 | ||
1389 | case 32: | |
1390 | #line 228 "parse-gram.y" | |
1391 | { current_class = nterm_sym; } | |
1392 | break; | |
1393 | ||
1394 | case 33: | |
1395 | #line 229 "parse-gram.y" | |
1396 | { | |
1397 | current_class = unknown_sym; | |
1398 | current_type = NULL; | |
1399 | } | |
1400 | break; | |
1401 | ||
1402 | case 34: | |
1403 | #line 233 "parse-gram.y" | |
1404 | { current_class = token_sym; } | |
1405 | break; | |
1406 | ||
1407 | case 35: | |
1408 | #line 234 "parse-gram.y" | |
1409 | { | |
1410 | current_class = unknown_sym; | |
1411 | current_type = NULL; | |
1412 | } | |
1413 | break; | |
1414 | ||
1415 | case 36: | |
1416 | #line 239 "parse-gram.y" | |
1417 | { | |
1418 | symbol_list *list; | |
1419 | for (list = yyvsp[0].list; list; list = list->next) | |
1420 | symbol_type_set (list->sym, yyvsp[-1].uniqstr, yylsp[-1]); | |
1421 | symbol_list_free (yyvsp[0].list); | |
1422 | } | |
1423 | break; | |
1424 | ||
1425 | case 37: | |
1426 | #line 249 "parse-gram.y" | |
1427 | { | |
1428 | symbol_list *list; | |
1429 | ++current_prec; | |
1430 | for (list = yyvsp[0].list; list; list = list->next) | |
1431 | { | |
1432 | symbol_type_set (list->sym, current_type, yylsp[-1]); | |
1433 | symbol_precedence_set (list->sym, current_prec, yyvsp[-2].assoc, yylsp[-2]); | |
1434 | } | |
1435 | symbol_list_free (yyvsp[0].list); | |
1436 | current_type = NULL; | |
1437 | } | |
1438 | break; | |
1439 | ||
1440 | case 38: | |
1441 | #line 263 "parse-gram.y" | |
1442 | { yyval.assoc = left_assoc; } | |
1443 | break; | |
1444 | ||
1445 | case 39: | |
1446 | #line 264 "parse-gram.y" | |
1447 | { yyval.assoc = right_assoc; } | |
1448 | break; | |
1449 | ||
1450 | case 40: | |
1451 | #line 265 "parse-gram.y" | |
1452 | { yyval.assoc = non_assoc; } | |
1453 | break; | |
1454 | ||
1455 | case 41: | |
1456 | #line 269 "parse-gram.y" | |
1457 | { current_type = NULL; } | |
1458 | break; | |
1459 | ||
1460 | case 42: | |
1461 | #line 270 "parse-gram.y" | |
1462 | { current_type = yyvsp[0].uniqstr; } | |
1463 | break; | |
1464 | ||
1465 | case 43: | |
1466 | #line 276 "parse-gram.y" | |
1467 | { yyval.list = symbol_list_new (yyvsp[0].symbol, yylsp[0]); } | |
1468 | break; | |
1469 | ||
1470 | case 44: | |
1471 | #line 277 "parse-gram.y" | |
1472 | { yyval.list = symbol_list_prepend (yyvsp[-1].list, yyvsp[0].symbol, yylsp[0]); } | |
1473 | break; | |
1474 | ||
1475 | case 45: | |
1476 | #line 283 "parse-gram.y" | |
1477 | { | |
1478 | current_type = yyvsp[0].uniqstr; | |
1479 | } | |
1480 | break; | |
1481 | ||
1482 | case 46: | |
1483 | #line 287 "parse-gram.y" | |
1484 | { | |
1485 | symbol_class_set (yyvsp[0].symbol, current_class, yylsp[0]); | |
1486 | symbol_type_set (yyvsp[0].symbol, current_type, yylsp[0]); | |
1487 | } | |
1488 | break; | |
1489 | ||
1490 | case 47: | |
1491 | #line 292 "parse-gram.y" | |
1492 | { | |
1493 | symbol_class_set (yyvsp[-1].symbol, current_class, yylsp[-1]); | |
1494 | symbol_type_set (yyvsp[-1].symbol, current_type, yylsp[-1]); | |
1495 | symbol_user_token_number_set (yyvsp[-1].symbol, yyvsp[0].integer, yylsp[0]); | |
1496 | } | |
1497 | break; | |
1498 | ||
1499 | case 48: | |
1500 | #line 298 "parse-gram.y" | |
1501 | { | |
1502 | symbol_class_set (yyvsp[-1].symbol, current_class, yylsp[-1]); | |
1503 | symbol_type_set (yyvsp[-1].symbol, current_type, yylsp[-1]); | |
1504 | symbol_make_alias (yyvsp[-1].symbol, yyvsp[0].symbol, yyloc); | |
1505 | } | |
1506 | break; | |
1507 | ||
1508 | case 49: | |
1509 | #line 304 "parse-gram.y" | |
1510 | { | |
1511 | symbol_class_set (yyvsp[-2].symbol, current_class, yylsp[-2]); | |
1512 | symbol_type_set (yyvsp[-2].symbol, current_type, yylsp[-2]); | |
1513 | symbol_user_token_number_set (yyvsp[-2].symbol, yyvsp[-1].integer, yylsp[-1]); | |
1514 | symbol_make_alias (yyvsp[-2].symbol, yyvsp[0].symbol, yyloc); | |
1515 | } | |
1516 | break; | |
1517 | ||
1518 | case 55: | |
1519 | #line 333 "parse-gram.y" | |
1520 | { | |
1521 | if (yacc_flag) | |
1522 | complain_at (yyloc, _("POSIX forbids declarations in the grammar")); | |
1523 | } | |
1524 | break; | |
1525 | ||
1526 | case 56: | |
1527 | #line 338 "parse-gram.y" | |
1528 | { | |
1529 | yyerrok; | |
1530 | } | |
1531 | break; | |
1532 | ||
1533 | case 58: | |
1534 | #line 345 "parse-gram.y" | |
1535 | { current_lhs = yyvsp[0].symbol; current_lhs_location = yylsp[0]; } | |
1536 | break; | |
1537 | ||
1538 | case 60: | |
1539 | #line 349 "parse-gram.y" | |
1540 | { grammar_rule_end (yylsp[0]); } | |
1541 | break; | |
1542 | ||
1543 | case 61: | |
1544 | #line 350 "parse-gram.y" | |
1545 | { grammar_rule_end (yylsp[0]); } | |
1546 | break; | |
1547 | ||
1548 | case 62: | |
1549 | #line 355 "parse-gram.y" | |
1550 | { grammar_rule_begin (current_lhs, current_lhs_location); } | |
1551 | break; | |
1552 | ||
1553 | case 63: | |
1554 | #line 357 "parse-gram.y" | |
1555 | { grammar_current_rule_symbol_append (yyvsp[0].symbol, yylsp[0]); } | |
1556 | break; | |
1557 | ||
1558 | case 64: | |
1559 | #line 359 "parse-gram.y" | |
1560 | { grammar_current_rule_action_append (yyvsp[0].chars, yylsp[0]); } | |
1561 | break; | |
1562 | ||
1563 | case 65: | |
1564 | #line 361 "parse-gram.y" | |
1565 | { grammar_current_rule_prec_set (yyvsp[0].symbol, yylsp[0]); } | |
1566 | break; | |
1567 | ||
1568 | case 66: | |
1569 | #line 363 "parse-gram.y" | |
1570 | { grammar_current_rule_dprec_set (yyvsp[0].integer, yylsp[0]); } | |
1571 | break; | |
1572 | ||
1573 | case 67: | |
1574 | #line 365 "parse-gram.y" | |
1575 | { grammar_current_rule_merge_set (yyvsp[0].uniqstr, yylsp[0]); } | |
1576 | break; | |
1577 | ||
1578 | case 68: | |
1579 | #line 369 "parse-gram.y" | |
1580 | { yyval.symbol = yyvsp[0].symbol; } | |
1581 | break; | |
1582 | ||
1583 | case 69: | |
1584 | #line 370 "parse-gram.y" | |
1585 | { yyval.symbol = yyvsp[0].symbol; } | |
1586 | break; | |
1587 | ||
1588 | case 70: | |
1589 | #line 375 "parse-gram.y" | |
1590 | { yyval.chars = yyvsp[0].chars; } | |
1591 | break; | |
1592 | ||
1593 | case 71: | |
1594 | #line 381 "parse-gram.y" | |
1595 | { | |
1596 | yyval.symbol = symbol_get (yyvsp[0].chars, yylsp[0]); | |
1597 | symbol_class_set (yyval.symbol, token_sym, yylsp[0]); | |
1598 | } | |
1599 | break; | |
1600 | ||
1601 | case 72: | |
1602 | #line 390 "parse-gram.y" | |
1603 | { | |
1604 | yyval.chars = yyvsp[0].chars + 1; | |
1605 | yyval.chars[strlen (yyval.chars) - 1] = '\0'; | |
1606 | } | |
1607 | break; | |
1608 | ||
1609 | case 74: | |
1610 | #line 399 "parse-gram.y" | |
1611 | { | |
1612 | epilogue_augment (yyvsp[0].chars, yylsp[0]); | |
1613 | scanner_last_string_free (); | |
1614 | } | |
1615 | break; | |
1616 | ||
1617 | ||
1618 | } | |
1619 | ||
1620 | /* Line 999 of yacc.c. */ | |
1621 | #line 1622 "parse-gram.c" | |
1622 | \f | |
1623 | yyvsp -= yylen; | |
1624 | yyssp -= yylen; | |
1625 | yylsp -= yylen; | |
1626 | ||
1627 | YY_STACK_PRINT (yyss, yyssp); | |
1628 | ||
1629 | *++yyvsp = yyval; | |
1630 | *++yylsp = yyloc; | |
1631 | ||
1632 | /* Now `shift' the result of the reduction. Determine what state | |
1633 | that goes to, based on the state we popped back to and the rule | |
1634 | number reduced by. */ | |
1635 | ||
1636 | yyn = yyr1[yyn]; | |
1637 | ||
1638 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; | |
1639 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) | |
1640 | yystate = yytable[yystate]; | |
1641 | else | |
1642 | yystate = yydefgoto[yyn - YYNTOKENS]; | |
1643 | ||
1644 | goto yynewstate; | |
1645 | ||
1646 | ||
1647 | /*------------------------------------. | |
1648 | | yyerrlab -- here on detecting error | | |
1649 | `------------------------------------*/ | |
1650 | yyerrlab: | |
1651 | /* If not already recovering from an error, report this error. */ | |
1652 | if (!yyerrstatus) | |
1653 | { | |
1654 | ++yynerrs; | |
1655 | #if YYERROR_VERBOSE | |
1656 | yyn = yypact[yystate]; | |
1657 | ||
1658 | if (YYPACT_NINF < yyn && yyn < YYLAST) | |
1659 | { | |
1660 | YYSIZE_T yysize = 0; | |
1661 | int yytype = YYTRANSLATE (yychar); | |
1662 | char *yymsg; | |
1663 | int yyx; | |
1664 | ||
1665 | /* Start YYX at -YYN if negative to avoid negative indexes in | |
1666 | YYCHECK. */ | |
1667 | int yyxbase = yyn < 0 ? -yyn : 0; | |
1668 | ||
1669 | /* Stay within bounds of both yycheck and yytname. */ | |
1670 | int yychecklim = YYLAST - yyn; | |
1671 | int yynsyms = sizeof (yytname) / sizeof (yytname[0]); | |
1672 | int yyxlim = yychecklim < yynsyms ? yychecklim : yynsyms; | |
1673 | int yycount = 0; | |
1674 | ||
1675 | for (yyx = yyxbase; yyx < yyxlim; yyx++) | |
1676 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) | |
1677 | { | |
1678 | yysize += (! yycount | |
1679 | ? sizeof (", expecting ") - 1 | |
1680 | : sizeof (" or ") - 1); | |
1681 | yysize += yystrlen (yytname[yyx]); | |
1682 | yycount++; | |
1683 | if (yycount == 5) | |
1684 | { | |
1685 | yysize = 0; | |
1686 | break; | |
1687 | } | |
1688 | } | |
1689 | yysize += (sizeof ("syntax error, unexpected ") | |
1690 | + yystrlen (yytname[yytype])); | |
1691 | yymsg = (char *) YYSTACK_ALLOC (yysize); | |
1692 | if (yymsg != 0) | |
1693 | { | |
1694 | char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); | |
1695 | yyp = yystpcpy (yyp, yytname[yytype]); | |
1696 | ||
1697 | if (yycount < 5) | |
1698 | { | |
1699 | yycount = 0; | |
1700 | for (yyx = yyxbase; yyx < yyxlim; yyx++) | |
1701 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) | |
1702 | { | |
1703 | const char *yyq = ! yycount ? ", expecting " : " or "; | |
1704 | yyp = yystpcpy (yyp, yyq); | |
1705 | yyp = yystpcpy (yyp, yytname[yyx]); | |
1706 | yycount++; | |
1707 | } | |
1708 | } | |
1709 | yyerror (yymsg); | |
1710 | YYSTACK_FREE (yymsg); | |
1711 | } | |
1712 | else | |
1713 | yyerror ("syntax error; also virtual memory exhausted"); | |
1714 | } | |
1715 | else | |
1716 | #endif /* YYERROR_VERBOSE */ | |
1717 | yyerror ("syntax error"); | |
1718 | } | |
1719 | ||
1720 | yylerrsp = yylsp; | |
1721 | ||
1722 | if (yyerrstatus == 3) | |
1723 | { | |
1724 | /* If just tried and failed to reuse lookahead token after an | |
1725 | error, discard it. */ | |
1726 | ||
1727 | /* Return failure if at end of input. */ | |
1728 | if (yychar == YYEOF) | |
1729 | { | |
1730 | /* Pop the error token. */ | |
1731 | YYPOPSTACK; | |
1732 | /* Pop the rest of the stack. */ | |
1733 | while (yyss < yyssp) | |
1734 | { | |
1735 | YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); | |
1736 | yydestruct (yystos[*yyssp], yyvsp, yylsp); | |
1737 | YYPOPSTACK; | |
1738 | } | |
1739 | YYABORT; | |
1740 | } | |
1741 | ||
1742 | YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); | |
1743 | yydestruct (yytoken, &yylval, &yylloc); | |
1744 | yychar = YYEMPTY; | |
1745 | *++yylerrsp = yylloc; | |
1746 | } | |
1747 | ||
1748 | /* Else will try to reuse lookahead token after shifting the error | |
1749 | token. */ | |
1750 | goto yyerrlab1; | |
1751 | ||
1752 | ||
1753 | /*----------------------------------------------------. | |
1754 | | yyerrlab1 -- error raised explicitly by an action. | | |
1755 | `----------------------------------------------------*/ | |
1756 | yyerrlab1: | |
1757 | yyerrstatus = 3; /* Each real token shifted decrements this. */ | |
1758 | ||
1759 | for (;;) | |
1760 | { | |
1761 | yyn = yypact[yystate]; | |
1762 | if (yyn != YYPACT_NINF) | |
1763 | { | |
1764 | yyn += YYTERROR; | |
1765 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) | |
1766 | { | |
1767 | yyn = yytable[yyn]; | |
1768 | if (0 < yyn) | |
1769 | break; | |
1770 | } | |
1771 | } | |
1772 | ||
1773 | /* Pop the current state because it cannot handle the error token. */ | |
1774 | if (yyssp == yyss) | |
1775 | YYABORT; | |
1776 | ||
1777 | YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); | |
1778 | yydestruct (yystos[yystate], yyvsp, yylsp); | |
1779 | yyvsp--; | |
1780 | yystate = *--yyssp; | |
1781 | yylsp--; | |
1782 | YY_STACK_PRINT (yyss, yyssp); | |
1783 | } | |
1784 | ||
1785 | if (yyn == YYFINAL) | |
1786 | YYACCEPT; | |
1787 | ||
1788 | YYDPRINTF ((stderr, "Shifting error token, ")); | |
1789 | ||
1790 | *++yyvsp = yylval; | |
1791 | YYLLOC_DEFAULT (yyloc, yylsp, (yylerrsp - yylsp)); | |
1792 | *++yylsp = yyloc; | |
1793 | ||
1794 | yystate = yyn; | |
1795 | goto yynewstate; | |
1796 | ||
1797 | ||
1798 | /*-------------------------------------. | |
1799 | | yyacceptlab -- YYACCEPT comes here. | | |
1800 | `-------------------------------------*/ | |
1801 | yyacceptlab: | |
1802 | yyresult = 0; | |
1803 | goto yyreturn; | |
1804 | ||
1805 | /*-----------------------------------. | |
1806 | | yyabortlab -- YYABORT comes here. | | |
1807 | `-----------------------------------*/ | |
1808 | yyabortlab: | |
1809 | yyresult = 1; | |
1810 | goto yyreturn; | |
1811 | ||
1812 | #ifndef yyoverflow | |
1813 | /*----------------------------------------------. | |
1814 | | yyoverflowlab -- parser overflow comes here. | | |
1815 | `----------------------------------------------*/ | |
1816 | yyoverflowlab: | |
1817 | yyerror ("parser stack overflow"); | |
1818 | yyresult = 2; | |
1819 | /* Fall through. */ | |
1820 | #endif | |
1821 | ||
1822 | yyreturn: | |
1823 | #ifndef yyoverflow | |
1824 | if (yyss != yyssa) | |
1825 | YYSTACK_FREE (yyss); | |
1826 | #endif | |
1827 | return yyresult; | |
1828 | } | |
1829 | ||
1830 | ||
1831 | #line 405 "parse-gram.y" | |
1832 | ||
1833 | ||
1834 | ||
1835 | /* Return the location of the left-hand side of a rule whose | |
1836 | right-hand side is RHS[1] ... RHS[N]. Ignore empty nonterminals in | |
1837 | the right-hand side, and return an empty location equal to the end | |
1838 | boundary of RHS[0] if the right-hand side is empty. */ | |
1839 | ||
1840 | static YYLTYPE | |
1841 | lloc_default (YYLTYPE const *rhs, int n) | |
1842 | { | |
1843 | int i; | |
1844 | YYLTYPE loc; | |
1845 | loc.start = loc.end = rhs[n].end; | |
1846 | ||
1847 | /* Ignore empty nonterminals the start of the the right-hand side. | |
1848 | Do not bother to ignore them at the end of the right-hand side, | |
1849 | since empty nonterminals have the same end as their predecessors. */ | |
1850 | for (i = 1; i <= n; i++) | |
1851 | if (! equal_boundaries (rhs[i].start, rhs[i].end)) | |
1852 | { | |
1853 | loc.start = rhs[i].start; | |
1854 | break; | |
1855 | } | |
1856 | ||
1857 | return loc; | |
1858 | } | |
1859 | ||
1860 | ||
1861 | /* Add a lex-param or a parse-param (depending on TYPE) with | |
1862 | declaration DECL and location LOC. */ | |
1863 | ||
1864 | static void | |
1865 | add_param (char const *type, char *decl, location loc) | |
1866 | { | |
1867 | static char const alphanum[] = | |
1868 | "0123456789" | |
1869 | "abcdefghijklmnopqrstuvwxyz" | |
1870 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
1871 | "_"; | |
1872 | char const *alpha = alphanum + 10; | |
1873 | char const *name_start = NULL; | |
1874 | char *p; | |
1875 | ||
1876 | for (p = decl; *p; p++) | |
1877 | if ((p == decl || ! strchr (alphanum, p[-1])) && strchr (alpha, p[0])) | |
1878 | name_start = p; | |
1879 | ||
1880 | /* Strip the surrounding '{' and '}'. */ | |
1881 | decl++; | |
1882 | p[-1] = '\0'; | |
1883 | ||
1884 | if (! name_start) | |
1885 | complain_at (loc, _("missing identifier in parameter declaration")); | |
1886 | else | |
1887 | { | |
1888 | char *name; | |
1889 | size_t name_len; | |
1890 | ||
1891 | for (name_len = 1; | |
1892 | name_start[name_len] && strchr (alphanum, name_start[name_len]); | |
1893 | name_len++) | |
1894 | continue; | |
1895 | ||
1896 | name = xmalloc (name_len + 1); | |
1897 | memcpy (name, name_start, name_len); | |
1898 | name[name_len] = '\0'; | |
1899 | muscle_pair_list_grow (type, decl, name); | |
1900 | free (name); | |
1901 | } | |
1902 | ||
1903 | scanner_last_string_free (); | |
1904 | } | |
1905 | ||
1906 | /*----------------------------------------------------. | |
1907 | | When debugging the parser, display tokens' values. | | |
1908 | `----------------------------------------------------*/ | |
1909 | ||
1910 | static void | |
1911 | print_token_value (FILE *file, int type, YYSTYPE const *value) | |
1912 | { | |
1913 | fputc (' ', file); | |
1914 | switch (type) | |
1915 | { | |
1916 | case ID: | |
1917 | fprintf (file, " = %s", value->symbol->tag); | |
1918 | break; | |
1919 | ||
1920 | case INT: | |
1921 | fprintf (file, " = %d", value->integer); | |
1922 | break; | |
1923 | ||
1924 | case STRING: | |
1925 | fprintf (file, " = \"%s\"", value->chars); | |
1926 | break; | |
1927 | ||
1928 | case TYPE: | |
1929 | fprintf (file, " = <%s>", value->uniqstr); | |
1930 | break; | |
1931 | ||
1932 | case BRACED_CODE: | |
1933 | case PERCENT_DESTRUCTOR: | |
1934 | case PERCENT_LEX_PARAM: | |
1935 | case PERCENT_PARSE_PARAM: | |
1936 | case PERCENT_PRINTER: | |
1937 | case PERCENT_UNION: | |
1938 | case PROLOGUE: | |
1939 | case EPILOGUE: | |
1940 | fprintf (file, " = {{ %s }}", value->chars); | |
1941 | break; | |
1942 | ||
1943 | default: | |
1944 | fprintf (file, "unknown token type"); | |
1945 | break; | |
1946 | } | |
1947 | } | |
1948 | ||
1949 | static void | |
1950 | gram_error (location const *loc, char const *msg) | |
1951 | { | |
1952 | complain_at (*loc, "%s", msg); | |
1953 | } | |
1954 | ||
1955 | char const * | |
1956 | token_name (int type) | |
1957 | { | |
1958 | return yytname[type]; | |
1959 | } | |
1960 |