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