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