1 /* A Bison parser, made from parse-gram.y
4 #define YYBISON 1 /* Identify Bison output. */
6 #define yyparse gram_parse
8 #define yyerror gram_error
9 #define yylval gram_lval
10 #define yychar gram_char
11 #define yydebug gram_debug
12 #define yynerrs gram_nerrs
13 #define YYLSP_NEEDED 1
17 # define CHARACTER 258
19 # define PERCENT_TOKEN 260
20 # define PERCENT_NTERM 261
21 # define PERCENT_TYPE 262
22 # define PERCENT_UNION 263
23 # define PERCENT_EXPECT 264
24 # define PERCENT_START 265
25 # define PERCENT_LEFT 266
26 # define PERCENT_RIGHT 267
27 # define PERCENT_NONASSOC 268
28 # define PERCENT_PREC 269
29 # define PERCENT_VERBOSE 270
30 # define PERCENT_ERROR_VERBOSE 271
31 # define PERCENT_OUTPUT 272
32 # define PERCENT_FILE_PREFIX 273
33 # define PERCENT_NAME_PREFIX 274
34 # define PERCENT_DEFINE 275
35 # define PERCENT_PURE_PARSER 276
36 # define PERCENT_DEFINES 277
37 # define PERCENT_YACC 278
38 # define PERCENT_DEBUG 279
39 # define PERCENT_LOCATIONS 280
40 # define PERCENT_NO_LINES 281
41 # define PERCENT_SKELETON 282
42 # define PERCENT_TOKEN_TABLE 283
45 # define SEMICOLON 286
49 # define PERCENT_PERCENT 290
52 # define BRACED_CODE 293
54 #line 31 "parse-gram.y"
57 #include "muscle_tab.h"
63 #include "conflicts.h"
65 /* Produce verbose parse errors. */
66 #define YYERROR_VERBOSE 1
68 /* Pass the control structure to YYPARSE and YYLEX. */
69 #define YYPARSE_PARAM gram_control
70 #define YYLEX_PARAM gram_control
71 /* YYPARSE receives GRAM_CONTROL as a void *. Provide a
72 correctly typed access to it. */
73 #define yycontrol ((gram_control_t *) gram_control)
75 /* Request detailed parse error messages, and pass them to
78 #define yyerror(Msg) \
79 gram_error (yycontrol, &yylloc, Msg)
81 /* When debugging our pure parser, we want to see values and locations
83 #define YYPRINT(File, Type, Value) \
84 yyprint (File, &yylloc, Type, &Value)
85 static void yyprint (FILE *file
, const location_t
*loc
,
86 int type
, const yystype
*value
);
88 symbol_class current_class
= unknown_sym
;
89 char *current_type
= 0;
90 symbol_t
*current_lhs
;
91 associativity current_assoc
;
94 #line 73 "parse-gram.y"
103 # define YYSTYPE yystype
104 # define YYSTYPE_IS_TRIVIAL 1
108 typedef struct yyltype
117 # define YYLTYPE yyltype
118 # define YYLTYPE_IS_TRIVIAL 1
128 #define YYFLAG -32768
131 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
132 #define YYTRANSLATE(x) ((unsigned)(x) <= 293 ? yytranslate[x] : 69)
134 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
135 static const char yytranslate
[] =
137 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
138 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
139 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
140 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
141 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
142 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
143 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
144 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
145 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
146 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
147 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
148 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
149 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
150 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
151 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
152 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
153 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
154 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
155 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
156 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
157 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
158 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
159 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
160 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
161 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
162 2, 2, 2, 2, 2, 2, 1, 4, 5, 6,
163 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
164 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
165 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
170 static const short yyprhs
[] =
172 0, 0, 1, 7, 8, 11, 13, 15, 17, 21,
173 23, 25, 28, 32, 34, 38, 40, 44, 46, 49,
174 51, 53, 55, 57, 59, 62, 66, 67, 71, 72,
175 76, 77, 82, 83, 88, 90, 92, 94, 95, 97,
176 99, 102, 104, 107, 109, 111, 114, 117, 121, 123,
177 126, 128, 131, 132, 138, 140, 144, 145, 148, 151,
178 155, 157, 159, 161, 163, 165, 167, 168, 171, 172
180 static const short yyrhs
[] =
182 -1, 42, 43, 37, 58, 67, 0, 0, 43, 44,
183 0, 45, 0, 38, 0, 26, 0, 22, 66, 66,
184 0, 24, 0, 18, 0, 11, 6, 0, 20, 32,
185 66, 0, 27, 0, 21, 32, 66, 0, 28, 0,
186 19, 32, 66, 0, 23, 0, 29, 66, 0, 30,
187 0, 17, 0, 25, 0, 50, 0, 46, 0, 12,
188 63, 0, 10, 40, 68, 0, 0, 8, 47, 57,
189 0, 0, 7, 48, 57, 0, 0, 9, 31, 49,
190 54, 0, 0, 52, 53, 51, 55, 0, 13, 0,
191 14, 0, 15, 0, 0, 31, 0, 36, 0, 54,
192 36, 0, 63, 0, 55, 63, 0, 31, 0, 36,
193 0, 36, 6, 0, 36, 65, 0, 36, 6, 65,
194 0, 56, 0, 57, 56, 0, 59, 0, 58, 59,
195 0, 0, 36, 34, 60, 61, 33, 0, 62, 0,
196 61, 35, 62, 0, 0, 62, 63, 0, 62, 64,
197 0, 62, 16, 63, 0, 36, 0, 65, 0, 5,
198 0, 40, 0, 4, 0, 4, 0, 0, 37, 39,
205 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
206 static const short yyrline
[] =
208 0, 134, 134, 147, 149, 152, 154, 155, 156, 157,
209 158, 159, 160, 161, 162, 163, 164, 165, 166, 167,
210 168, 169, 172, 174, 175, 179, 187, 187, 193, 193,
211 198, 198, 204, 204, 211, 213, 214, 217, 219, 223,
212 225, 229, 235, 243, 248, 253, 259, 265, 275, 278,
213 287, 289, 292, 292, 297, 299, 302, 305, 307, 309,
214 313, 315, 316, 319, 325, 334, 342, 347, 353, 355
219 #if (YYDEBUG) || defined YYERROR_VERBOSE
221 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
222 static const char *const yytname
[] =
224 "$", "error", "$undefined.", "\"end of string\"", "STRING", "CHARACTER",
225 "INT", "\"%token\"", "\"%nterm\"", "\"%type\"", "\"%union\"",
226 "\"%expect\"", "\"%start\"", "\"%left\"", "\"%right\"", "\"%nonassoc\"",
227 "\"%prec\"", "\"%verbose\"", "\"%error-verbose\"", "\"%output\"",
228 "\"%file-prefix\"", "\"%name-prefix\"", "\"%define\"",
229 "\"%pure-parser\"", "\"%defines\"", "\"%yacc\"", "\"%debug\"",
230 "\"%locations\"", "\"%no-lines\"", "\"%skeleton\"", "\"%token-table\"",
231 "TYPE", "\"=\"", "\";\"", "\":\"", "\"|\"", "\"identifier\"", "\"%%\"",
232 "PROLOGUE", "EPILOGUE", "BRACED_CODE", "input", "@1", "declarations",
233 "declaration", "grammar_declaration", "symbol_declaration", "@2", "@3",
234 "@4", "precedence_declaration", "@5", "precedence_declarator",
235 "type.opt", "nterms_to_type.1", "terms_to_prec.1", "symbol_def",
236 "symbol_defs.1", "grammar", "rules", "@6", "rhses.1", "rhs", "symbol",
237 "action", "string_as_id", "string_content", "epilogue.opt",
242 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
243 static const short yyr1
[] =
245 0, 42, 41, 43, 43, 44, 44, 44, 44, 44,
246 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
247 44, 44, 45, 45, 45, 45, 47, 46, 48, 46,
248 49, 46, 51, 50, 52, 52, 52, 53, 53, 54,
249 54, 55, 55, 56, 56, 56, 56, 56, 57, 57,
250 58, 58, 60, 59, 61, 61, 62, 62, 62, 62,
251 63, 63, 63, 64, 65, 66, 67, 67, 68, 68
254 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
255 static const short yyr2
[] =
257 0, 0, 5, 0, 2, 1, 1, 1, 3, 1,
258 1, 2, 3, 1, 3, 1, 3, 1, 2, 1,
259 1, 1, 1, 1, 2, 3, 0, 3, 0, 3,
260 0, 4, 0, 4, 1, 1, 1, 0, 1, 1,
261 2, 1, 2, 1, 1, 2, 2, 3, 1, 2,
262 1, 2, 0, 5, 1, 3, 0, 2, 2, 3,
263 1, 1, 1, 1, 1, 1, 0, 2, 0, 1
266 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
267 doesn't specify something else to do. Zero means the default is an
269 static const short yydefact
[] =
271 1, 3, 0, 28, 26, 0, 0, 0, 0, 34,
272 35, 36, 20, 10, 0, 0, 0, 0, 17, 9,
273 21, 7, 13, 15, 0, 19, 0, 6, 4, 5,
274 23, 22, 37, 0, 0, 30, 68, 11, 64, 62,
275 60, 24, 61, 0, 0, 0, 65, 0, 18, 0,
276 66, 50, 38, 32, 43, 44, 48, 29, 27, 0,
277 69, 25, 16, 12, 14, 8, 52, 0, 51, 2,
278 0, 45, 46, 49, 39, 31, 56, 67, 33, 41,
279 47, 40, 0, 54, 42, 53, 56, 0, 63, 57,
283 static const short yydefgoto
[] =
285 93, 1, 2, 28, 29, 30, 34, 33, 59, 31,
286 70, 32, 53, 75, 78, 56, 57, 50, 51, 76,
287 82, 83, 89, 90, 42, 47, 69, 61
290 static const short yypact
[] =
292 -32768,-32768, 31,-32768,-32768, -22, -29, 8, -1,-32768,
293 -32768,-32768,-32768,-32768, -16, -14, -11, 19,-32768,-32768,
294 -32768,-32768,-32768,-32768, 19,-32768, -9,-32768,-32768,-32768,
295 -32768,-32768, 0, -24, -24,-32768, 1,-32768,-32768,-32768,
296 -32768,-32768,-32768, 19, 19, 19,-32768, 19,-32768, -2,
297 -17,-32768,-32768,-32768,-32768, 4,-32768, -24, -24, 11,
298 -32768,-32768,-32768,-32768,-32768,-32768,-32768, 24,-32768,-32768,
299 -1, 32,-32768,-32768,-32768, 28,-32768,-32768, -1,-32768,
300 -32768,-32768, -18, -3,-32768,-32768,-32768, -1,-32768,-32768,
301 -32768, -3,-32768, 65, 66,-32768
304 static const short yypgoto
[] =
306 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
307 -32768,-32768,-32768,-32768,-32768, -28, 33,-32768, 21,-32768,
308 -32768, -13, -8,-32768, -49, -19,-32768,-32768
315 static const short yytable
[] =
317 41, 38, 39, 38, 39, 48, 72, 54, 38, 35,
318 71, 36, 55, 87, 37, 85, 43, 86, 44, 49,
319 67, 45, 80, 46, 62, 63, 64, 49, 65, 73,
320 73, 52, 66, 40, 60, 40, 38, 88, 3, 4,
321 5, 6, 7, 8, 9, 10, 11, 74, 12, 13,
322 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
323 24, 25, 79, 77, 81, 94, 95, 58, 26, 27,
324 84, 68, 0, 91, 0, 0, 0, 0, 0, 92
327 static const short yycheck
[] =
329 8, 4, 5, 4, 5, 24, 55, 31, 4, 31,
330 6, 40, 36, 16, 6, 33, 32, 35, 32, 36,
331 37, 32, 71, 4, 43, 44, 45, 36, 47, 57,
332 58, 31, 34, 36, 33, 36, 4, 40, 7, 8,
333 9, 10, 11, 12, 13, 14, 15, 36, 17, 18,
334 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
335 29, 30, 70, 39, 36, 0, 0, 34, 37, 38,
336 78, 50, -1, 86, -1, -1, -1, -1, -1, 87
340 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
341 #line 3 "/usr/share/bison/bison.simple"
343 /* Skeleton output parser for bison,
345 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
348 This program is free software; you can redistribute it and/or modify
349 it under the terms of the GNU General Public License as published by
350 the Free Software Foundation; either version 2, or (at your option)
353 This program is distributed in the hope that it will be useful,
354 but WITHOUT ANY WARRANTY; without even the implied warranty of
355 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
356 GNU General Public License for more details.
358 You should have received a copy of the GNU General Public License
359 along with this program; if not, write to the Free Software
360 Foundation, Inc., 59 Temple Place - Suite 330,
361 Boston, MA 02111-1307, USA. */
363 /* As a special exception, when this file is copied by Bison into a
364 Bison output file, you may use that output file without restriction.
365 This special exception was added by the Free Software Foundation
366 in version 1.24 of Bison. */
368 /* This is the parser code that is written into each bison parser when
369 the %semantic_parser declaration is not specified in the grammar.
370 It was written by Richard Stallman by simplifying the hairy parser
371 used when %semantic_parser is specified. */
373 /* All symbols defined below should begin with yy or YY, to avoid
374 infringing on user name space. This should be done even for local
375 variables, as they might otherwise be expanded by user macros.
376 There are some unavoidable exceptions within include files to
377 define necessary library symbols; they are noted "INFRINGES ON
378 USER NAME SPACE" below. */
380 #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
382 /* The parser invokes alloca or malloc; define the necessary symbols. */
384 # if YYSTACK_USE_ALLOCA
385 # define YYSTACK_ALLOC alloca
387 # ifndef YYSTACK_USE_ALLOCA
388 # if defined (alloca) || defined (_ALLOCA_H)
389 # define YYSTACK_ALLOC alloca
392 # define YYSTACK_ALLOC __builtin_alloca
398 # ifdef YYSTACK_ALLOC
399 /* Pacify GCC's `empty if-body' warning. */
400 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
402 # if defined (__STDC__) || defined (__cplusplus)
403 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
404 # define YYSIZE_T size_t
406 # define YYSTACK_ALLOC malloc
407 # define YYSTACK_FREE free
409 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
412 #if (! defined (yyoverflow) \
413 && (! defined (__cplusplus) \
414 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
416 /* A type that is properly aligned for any stack member. */
426 /* The size of the maximum gap between one aligned stack and the next. */
427 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
429 /* The size of an array large to enough to hold all stacks, each with
432 # define YYSTACK_BYTES(N) \
433 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
434 + 2 * YYSTACK_GAP_MAX)
436 # define YYSTACK_BYTES(N) \
437 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
441 /* Copy COUNT objects from FROM to TO. The source and destination do
445 # define YYCOPY(To, From, Count) \
446 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
448 # define YYCOPY(To, From, Count) \
451 register YYSIZE_T yyi; \
452 for (yyi = 0; yyi < (Count); yyi++) \
453 (To)[yyi] = (From)[yyi]; \
459 /* Relocate STACK from its old location to the new one. The
460 local variables YYSIZE and YYSTACKSIZE give the old and new number of
461 elements in the stack, and YYPTR gives the new location of the
462 stack. Advance YYPTR to a properly aligned location for the next
464 # define YYSTACK_RELOCATE(Stack) \
467 YYSIZE_T yynewbytes; \
468 YYCOPY (&yyptr->Stack, Stack, yysize); \
469 Stack = &yyptr->Stack; \
470 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
471 yyptr += yynewbytes / sizeof (*yyptr); \
478 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
479 # define YYSIZE_T __SIZE_TYPE__
481 #if ! defined (YYSIZE_T) && defined (size_t)
482 # define YYSIZE_T size_t
484 #if ! defined (YYSIZE_T)
485 # if defined (__STDC__) || defined (__cplusplus)
486 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
487 # define YYSIZE_T size_t
490 #if ! defined (YYSIZE_T)
491 # define YYSIZE_T unsigned int
494 #define yyerrok (yyerrstatus = 0)
495 #define yyclearin (yychar = YYEMPTY)
498 #define YYACCEPT goto yyacceptlab
499 #define YYABORT goto yyabortlab
500 #define YYERROR goto yyerrlab1
501 /* Like YYERROR except do call yyerror. This remains here temporarily
502 to ease the transition to the new meaning of YYERROR, for GCC.
503 Once GCC version 2 has supplanted version 1, this can go. */
504 #define YYFAIL goto yyerrlab
505 #define YYRECOVERING() (!!yyerrstatus)
506 #define YYBACKUP(Token, Value) \
508 if (yychar == YYEMPTY && yylen == 1) \
512 yychar1 = YYTRANSLATE (yychar); \
518 yyerror ("syntax error: cannot back up"); \
524 #define YYERRCODE 256
527 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
530 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
531 first token. By default, to implement support for ranges, extend
532 its range to the last symbol. */
534 #ifndef YYLLOC_DEFAULT
535 # define YYLLOC_DEFAULT(Current, Rhs, N) \
536 Current.last_line = Rhs[N].last_line; \
537 Current.last_column = Rhs[N].last_column;
541 /* YYLEX -- calling `yylex' with the right arguments. */
546 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
548 # define YYLEX yylex (&yylval, &yylloc)
550 # else /* !YYLSP_NEEDED */
552 # define YYLEX yylex (&yylval, YYLEX_PARAM)
554 # define YYLEX yylex (&yylval)
556 # endif /* !YYLSP_NEEDED */
558 # define YYLEX yylex ()
562 /* Enable debugging if requested. */
566 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
567 # define YYFPRINTF fprintf
570 # define YYDPRINTF(Args) \
575 /* Nonzero means print parse trace. It is left uninitialized so that
576 multiple parsers can coexist. */
579 # define YYDPRINTF(Args)
580 #endif /* !YYDEBUG */
582 /* YYINITDEPTH -- initial size of the parser's stacks. */
584 # define YYINITDEPTH 200
587 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
588 if the built-in stack extension method is used).
590 Do not make this value too large; the results are undefined if
591 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
592 evaluated with infinite-precision integer arithmetic. */
599 # define YYMAXDEPTH 10000
602 #ifdef YYERROR_VERBOSE
605 # if defined (__GLIBC__) && defined (_STRING_H)
606 # define yystrlen strlen
608 /* Return the length of YYSTR. */
610 # if defined (__STDC__) || defined (__cplusplus)
611 yystrlen (const char *yystr
)
617 register const char *yys
= yystr
;
619 while (*yys
++ != '\0')
622 return yys
- yystr
- 1;
628 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
629 # define yystpcpy stpcpy
631 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
634 # if defined (__STDC__) || defined (__cplusplus)
635 yystpcpy (char *yydest
, const char *yysrc
)
637 yystpcpy (yydest
, yysrc
)
642 register char *yyd
= yydest
;
643 register const char *yys
= yysrc
;
645 while ((*yyd
++ = *yys
++) != '\0')
654 #line 315 "/usr/share/bison/bison.simple"
657 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
658 into yyparse. The argument should have type void *.
659 It should actually point to an object.
660 Grammar actions can access the variable by casting it
661 to the proper pointer type. */
664 # if defined (__STDC__) || defined (__cplusplus)
665 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
666 # define YYPARSE_PARAM_DECL
668 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
669 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
671 #else /* !YYPARSE_PARAM */
672 # define YYPARSE_PARAM_ARG
673 # define YYPARSE_PARAM_DECL
674 #endif /* !YYPARSE_PARAM */
676 /* Prevent warning if -Wstrict-prototypes. */
678 # ifdef YYPARSE_PARAM
679 int yyparse (void *);
685 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
686 variables are global, or local to YYPARSE. */
688 #define YY_DECL_NON_LSP_VARIABLES \
689 /* The lookahead symbol. */ \
692 /* The semantic value of the lookahead symbol. */ \
695 /* Number of parse errors so far. */ \
699 # define YY_DECL_VARIABLES \
700 YY_DECL_NON_LSP_VARIABLES \
702 /* Location data for the lookahead symbol. */ \
705 # define YY_DECL_VARIABLES \
706 YY_DECL_NON_LSP_VARIABLES
710 /* If nonreentrant, generate the variables here. */
717 yyparse (YYPARSE_PARAM_ARG
)
720 /* If reentrant, generate the variables here. */
725 register int yystate
;
728 /* Number of tokens to shift before error messages enabled. */
730 /* Lookahead token as an internal (translated) token number. */
733 /* Three stacks and their tools:
734 `yyss': related to states,
735 `yyvs': related to semantic values,
736 `yyls': related to locations.
738 Refer to the stacks thru separate pointers, to allow yyoverflow
739 to reallocate them elsewhere. */
741 /* The state stack. */
742 short yyssa
[YYINITDEPTH
];
744 register short *yyssp
;
746 /* The semantic value stack. */
747 YYSTYPE yyvsa
[YYINITDEPTH
];
748 YYSTYPE
*yyvs
= yyvsa
;
749 register YYSTYPE
*yyvsp
;
752 /* The location stack. */
753 YYLTYPE yylsa
[YYINITDEPTH
];
754 YYLTYPE
*yyls
= yylsa
;
759 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
761 # define YYPOPSTACK (yyvsp--, yyssp--)
764 YYSIZE_T yystacksize
= YYINITDEPTH
;
767 /* The variables used to return semantic value and location from the
774 /* When reducing, the number of symbols on the RHS of the reduced
778 YYDPRINTF ((stderr
, "Starting parse\n"));
783 yychar
= YYEMPTY
; /* Cause a token to be read. */
785 /* Initialize stack pointers.
786 Waste one element of value and location stack
787 so that they stay on the same level as the state stack.
788 The wasted elements are never initialized. */
797 /*------------------------------------------------------------.
798 | yynewstate -- Push a new state, which is found in yystate. |
799 `------------------------------------------------------------*/
801 /* In all cases, when you get here, the value and location stacks
802 have just been pushed. so pushing a state here evens the stacks.
809 if (yyssp
>= yyss
+ yystacksize
- 1)
811 /* Get the current used size of the three stacks, in elements. */
812 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
816 /* Give user a chance to reallocate the stack. Use copies of
817 these so that the &'s don't force the real ones into
819 YYSTYPE
*yyvs1
= yyvs
;
822 /* Each stack pointer address is followed by the size of the
823 data in use in that stack, in bytes. */
825 YYLTYPE
*yyls1
= yyls
;
826 /* This used to be a conditional around just the two extra args,
827 but that might be undefined if yyoverflow is a macro. */
828 yyoverflow ("parser stack overflow",
829 &yyss1
, yysize
* sizeof (*yyssp
),
830 &yyvs1
, yysize
* sizeof (*yyvsp
),
831 &yyls1
, yysize
* sizeof (*yylsp
),
835 yyoverflow ("parser stack overflow",
836 &yyss1
, yysize
* sizeof (*yyssp
),
837 &yyvs1
, yysize
* sizeof (*yyvsp
),
843 #else /* no yyoverflow */
844 # ifndef YYSTACK_RELOCATE
847 /* Extend the stack our own way. */
848 if (yystacksize
>= YYMAXDEPTH
)
851 if (yystacksize
> YYMAXDEPTH
)
852 yystacksize
= YYMAXDEPTH
;
856 union yyalloc
*yyptr
=
857 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
860 YYSTACK_RELOCATE (yyss
);
861 YYSTACK_RELOCATE (yyvs
);
863 YYSTACK_RELOCATE (yyls
);
865 # undef YYSTACK_RELOCATE
867 YYSTACK_FREE (yyss1
);
870 #endif /* no yyoverflow */
872 yyssp
= yyss
+ yysize
- 1;
873 yyvsp
= yyvs
+ yysize
- 1;
875 yylsp
= yyls
+ yysize
- 1;
878 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
879 (unsigned long int) yystacksize
));
881 if (yyssp
>= yyss
+ yystacksize
- 1)
885 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
895 /* Do appropriate processing given the current state. */
896 /* Read a lookahead token if we need one and don't already have one. */
899 /* First try to decide what to do without reference to lookahead token. */
901 yyn
= yypact
[yystate
];
905 /* Not known => get a lookahead token if don't already have one. */
907 /* yychar is either YYEMPTY or YYEOF
908 or a valid token in external form. */
910 if (yychar
== YYEMPTY
)
912 YYDPRINTF ((stderr
, "Reading a token: "));
916 /* Convert token to internal form (in yychar1) for indexing tables with */
918 if (yychar
<= 0) /* This means end of input. */
921 yychar
= YYEOF
; /* Don't call YYLEX any more */
923 YYDPRINTF ((stderr
, "Now at end of input.\n"));
927 yychar1
= YYTRANSLATE (yychar
);
930 /* We have to keep this `#if YYDEBUG', since we use variables
931 which are defined only if `YYDEBUG' is set. */
934 YYFPRINTF (stderr
, "Next token is %d (%s",
935 yychar
, yytname
[yychar1
]);
936 /* Give the individual parser a way to print the precise
937 meaning of a token, for further debugging info. */
939 YYPRINT (stderr
, yychar
, yylval
);
941 YYFPRINTF (stderr
, ")\n");
947 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != yychar1
)
952 /* yyn is what to do for this token type in this state.
953 Negative => reduce, -yyn is rule number.
954 Positive => shift, yyn is new state.
955 New state is final state => don't bother to shift,
957 0, or most negative number => error. */
972 /* Shift the lookahead token. */
973 YYDPRINTF ((stderr
, "Shifting token %d (%s), ",
974 yychar
, yytname
[yychar1
]));
976 /* Discard the token being shifted unless it is eof. */
985 /* Count tokens shifted since error; after three, turn off error
994 /*-----------------------------------------------------------.
995 | yydefault -- do the default action for the current state. |
996 `-----------------------------------------------------------*/
998 yyn
= yydefact
[yystate
];
1004 /*-----------------------------.
1005 | yyreduce -- Do a reduction. |
1006 `-----------------------------*/
1008 /* yyn is the number of a rule to reduce with. */
1011 /* If YYLEN is nonzero, implement the default value of the action:
1014 Otherwise, the following line sets YYVAL to the semantic value of
1015 the lookahead token. This behavior is undocumented and Bison
1016 users should not rely upon it. Assigning to YYVAL
1017 unconditionally makes the parser a bit smaller, and it avoids a
1018 GCC warning that YYVAL may be used uninitialized. */
1019 yyval
= yyvsp
[1-yylen
];
1022 /* Similarly for the default location. Let the user run additional
1023 commands if for instance locations are ranges. */
1024 yyloc
= yylsp
[1-yylen
];
1025 YYLLOC_DEFAULT (yyloc
, (yylsp
- yylen
), yylen
);
1029 /* We have to keep this `#if YYDEBUG', since we use variables which
1030 are defined only if `YYDEBUG' is set. */
1035 YYFPRINTF (stderr
, "Reducing via rule %d (line %d), ",
1038 /* Print the symbols being reduced, and their result. */
1039 for (yyi
= yyprhs
[yyn
]; yyrhs
[yyi
] > 0; yyi
++)
1040 YYFPRINTF (stderr
, "%s ", yytname
[yyrhs
[yyi
]]);
1041 YYFPRINTF (stderr
, " -> %s\n", yytname
[yyr1
[yyn
]]);
1048 #line 134 "parse-gram.y"
1049 { LOCATION_RESET (yylloc
); }
1052 #line 136 "parse-gram.y"
1054 yycontrol
->errcode
= 0;
1055 epilogue_set (yyvsp
[0].string
, yylsp
[0]);
1059 #line 154 "parse-gram.y"
1060 { prologue_augment (yyvsp
[0].string
, yylsp
[0]); }
1063 #line 155 "parse-gram.y"
1067 #line 156 "parse-gram.y"
1068 { muscle_insert (yyvsp
[-1].string
, yyvsp
[0].string
); }
1071 #line 157 "parse-gram.y"
1072 { defines_flag
= 1; }
1075 #line 158 "parse-gram.y"
1076 { error_verbose
= 1; }
1079 #line 159 "parse-gram.y"
1080 { expected_conflicts
= yyvsp
[0].integer
; }
1083 #line 160 "parse-gram.y"
1084 { spec_file_prefix
= yyvsp
[0].string
; }
1087 #line 161 "parse-gram.y"
1088 { locations_flag
= 1; }
1091 #line 162 "parse-gram.y"
1092 { spec_name_prefix
= yyvsp
[0].string
; }
1095 #line 163 "parse-gram.y"
1096 { no_lines_flag
= 1; }
1099 #line 164 "parse-gram.y"
1100 { spec_outfile
= yyvsp
[0].string
; }
1103 #line 165 "parse-gram.y"
1104 { pure_parser
= 1; }
1107 #line 166 "parse-gram.y"
1108 { skeleton
= yyvsp
[0].string
; }
1111 #line 167 "parse-gram.y"
1112 { token_table_flag
= 1; }
1115 #line 168 "parse-gram.y"
1116 { report_flag
= 1; }
1119 #line 169 "parse-gram.y"
1123 #line 176 "parse-gram.y"
1125 grammar_start_symbol_set (yyvsp
[0].symbol
);
1129 #line 180 "parse-gram.y"
1132 MUSCLE_INSERT_INT ("stype_line", yylsp
[-1].first_line
);
1133 muscle_insert ("stype", yyvsp
[-1].string
);
1137 #line 188 "parse-gram.y"
1138 { current_class
= nterm_sym
; }
1141 #line 189 "parse-gram.y"
1143 current_class
= unknown_sym
;
1144 current_type
= NULL
;
1148 #line 193 "parse-gram.y"
1149 { current_class
= token_sym
; }
1152 #line 194 "parse-gram.y"
1154 current_class
= unknown_sym
;
1155 current_type
= NULL
;
1159 #line 198 "parse-gram.y"
1160 {current_type
= yyvsp
[0].string
; }
1163 #line 199 "parse-gram.y"
1165 current_type
= NULL
;
1169 #line 206 "parse-gram.y"
1170 { current_assoc
= yyvsp
[-1].assoc
; ++current_prec
; }
1173 #line 208 "parse-gram.y"
1174 { current_assoc
= non_assoc
; current_type
= NULL
; }
1177 #line 212 "parse-gram.y"
1178 { yyval
.assoc
= left_assoc
; }
1181 #line 213 "parse-gram.y"
1182 { yyval
.assoc
= right_assoc
; }
1185 #line 214 "parse-gram.y"
1186 { yyval
.assoc
= non_assoc
; }
1189 #line 218 "parse-gram.y"
1190 { current_type
= NULL
;}
1193 #line 219 "parse-gram.y"
1194 { current_type
= yyvsp
[0].string
; }
1197 #line 224 "parse-gram.y"
1198 { symbol_type_set (yyvsp
[0].symbol
, current_type
); }
1201 #line 225 "parse-gram.y"
1202 { symbol_type_set (yyvsp
[0].symbol
, current_type
); }
1205 #line 231 "parse-gram.y"
1207 symbol_type_set (yyvsp
[0].symbol
, current_type
);
1208 symbol_precedence_set (yyvsp
[0].symbol
, current_prec
, current_assoc
);
1212 #line 236 "parse-gram.y"
1214 symbol_type_set (yyvsp
[0].symbol
, current_type
);
1215 symbol_precedence_set (yyvsp
[0].symbol
, current_prec
, current_assoc
);
1219 #line 245 "parse-gram.y"
1221 current_type
= yyvsp
[0].string
;
1225 #line 249 "parse-gram.y"
1227 symbol_class_set (yyvsp
[0].symbol
, current_class
);
1228 symbol_type_set (yyvsp
[0].symbol
, current_type
);
1232 #line 254 "parse-gram.y"
1234 symbol_class_set (yyvsp
[-1].symbol
, current_class
);
1235 symbol_type_set (yyvsp
[-1].symbol
, current_type
);
1236 symbol_user_token_number_set (yyvsp
[-1].symbol
, yyvsp
[0].integer
);
1240 #line 260 "parse-gram.y"
1242 symbol_class_set (yyvsp
[-1].symbol
, current_class
);
1243 symbol_type_set (yyvsp
[-1].symbol
, current_type
);
1244 symbol_make_alias (yyvsp
[-1].symbol
, yyvsp
[0].symbol
);
1248 #line 266 "parse-gram.y"
1250 symbol_class_set (yyvsp
[-2].symbol
, current_class
);
1251 symbol_type_set (yyvsp
[-2].symbol
, current_type
);
1252 symbol_user_token_number_set (yyvsp
[-2].symbol
, yyvsp
[-1].integer
);
1253 symbol_make_alias (yyvsp
[-2].symbol
, yyvsp
[0].symbol
);
1257 #line 277 "parse-gram.y"
1261 #line 279 "parse-gram.y"
1265 #line 293 "parse-gram.y"
1266 { current_lhs
= yyvsp
[-1].symbol
; }
1269 #line 294 "parse-gram.y"
1273 #line 298 "parse-gram.y"
1274 { grammar_rule_end (); }
1277 #line 299 "parse-gram.y"
1278 { grammar_rule_end (); }
1281 #line 304 "parse-gram.y"
1282 { grammar_rule_begin (current_lhs
); }
1285 #line 306 "parse-gram.y"
1286 { grammar_current_rule_symbol_append (yyvsp
[0].symbol
); }
1289 #line 308 "parse-gram.y"
1290 { grammar_current_rule_action_append (yyvsp
[0].string
, yylsp
[0].first_line
); }
1293 #line 310 "parse-gram.y"
1294 { grammar_current_rule_prec_set (yyvsp
[0].symbol
); }
1297 #line 314 "parse-gram.y"
1298 { yyval
.symbol
= yyvsp
[0].symbol
; }
1301 #line 315 "parse-gram.y"
1302 { yyval
.symbol
= yyvsp
[0].symbol
; }
1305 #line 316 "parse-gram.y"
1306 { yyval
.symbol
= getsym (yyvsp
[0].string
); }
1309 #line 321 "parse-gram.y"
1310 { yyval
.string
= yyvsp
[0].string
; }
1313 #line 327 "parse-gram.y"
1315 yyval
.symbol
= getsym (yyvsp
[0].string
);
1316 symbol_class_set (yyval
.symbol
, token_sym
);
1320 #line 336 "parse-gram.y"
1322 yyval
.string
= yyvsp
[0].string
+ 1;
1323 yyval
.string
[strlen (yyval
.string
) - 1] = '\0';
1327 #line 344 "parse-gram.y"
1329 yyval
.string
= xstrdup ("");
1333 #line 348 "parse-gram.y"
1335 yyval
.string
= yyvsp
[0].string
;
1340 #line 705 "/usr/share/bison/bison.simple"
1352 short *yyssp1
= yyss
- 1;
1353 YYFPRINTF (stderr
, "state stack now");
1354 while (yyssp1
!= yyssp
)
1355 YYFPRINTF (stderr
, " %d", *++yyssp1
);
1356 YYFPRINTF (stderr
, "\n");
1365 /* Now `shift' the result of the reduction. Determine what state
1366 that goes to, based on the state we popped back to and the rule
1367 number reduced by. */
1371 yystate
= yypgoto
[yyn
- YYNTBASE
] + *yyssp
;
1372 if (yystate
>= 0 && yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1373 yystate
= yytable
[yystate
];
1375 yystate
= yydefgoto
[yyn
- YYNTBASE
];
1380 /*------------------------------------.
1381 | yyerrlab -- here on detecting error |
1382 `------------------------------------*/
1384 /* If not already recovering from an error, report this error. */
1389 #ifdef YYERROR_VERBOSE
1390 yyn
= yypact
[yystate
];
1392 if (yyn
> YYFLAG
&& yyn
< YYLAST
)
1394 YYSIZE_T yysize
= 0;
1399 /* Start YYX at -YYN if negative to avoid negative indexes in
1401 for (yyx
= yyn
< 0 ? -yyn
: 0;
1402 yyx
< (int) (sizeof (yytname
) / sizeof (char *)); yyx
++)
1403 if (yycheck
[yyx
+ yyn
] == yyx
)
1404 yysize
+= yystrlen (yytname
[yyx
]) + 15, yycount
++;
1405 yysize
+= yystrlen ("parse error, unexpected ") + 1;
1406 yysize
+= yystrlen (yytname
[YYTRANSLATE (yychar
)]);
1407 yymsg
= (char *) YYSTACK_ALLOC (yysize
);
1410 char *yyp
= yystpcpy (yymsg
, "parse error, unexpected ");
1411 yyp
= yystpcpy (yyp
, yytname
[YYTRANSLATE (yychar
)]);
1416 for (yyx
= yyn
< 0 ? -yyn
: 0;
1417 yyx
< (int) (sizeof (yytname
) / sizeof (char *));
1419 if (yycheck
[yyx
+ yyn
] == yyx
)
1421 const char *yyq
= ! yycount
? ", expecting " : " or ";
1422 yyp
= yystpcpy (yyp
, yyq
);
1423 yyp
= yystpcpy (yyp
, yytname
[yyx
]);
1428 YYSTACK_FREE (yymsg
);
1431 yyerror ("parse error; also virtual memory exhausted");
1434 #endif /* defined (YYERROR_VERBOSE) */
1435 yyerror ("parse error");
1440 /*--------------------------------------------------.
1441 | yyerrlab1 -- error raised explicitly by an action |
1442 `--------------------------------------------------*/
1444 if (yyerrstatus
== 3)
1446 /* If just tried and failed to reuse lookahead token after an
1447 error, discard it. */
1449 /* return failure if at end of input */
1450 if (yychar
== YYEOF
)
1452 YYDPRINTF ((stderr
, "Discarding token %d (%s).\n",
1453 yychar
, yytname
[yychar1
]));
1457 /* Else will try to reuse lookahead token after shifting the error
1460 yyerrstatus
= 3; /* Each real token shifted decrements this */
1465 /*-------------------------------------------------------------------.
1466 | yyerrdefault -- current state does not do anything special for the |
1468 `-------------------------------------------------------------------*/
1471 /* This is wrong; only states that explicitly want error tokens
1472 should shift them. */
1474 /* If its default is to accept any token, ok. Otherwise pop it. */
1475 yyn
= yydefact
[yystate
];
1481 /*---------------------------------------------------------------.
1482 | yyerrpop -- pop the current state because it cannot handle the |
1484 `---------------------------------------------------------------*/
1497 short *yyssp1
= yyss
- 1;
1498 YYFPRINTF (stderr
, "Error: state stack now");
1499 while (yyssp1
!= yyssp
)
1500 YYFPRINTF (stderr
, " %d", *++yyssp1
);
1501 YYFPRINTF (stderr
, "\n");
1509 yyn
= yypact
[yystate
];
1514 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != YYTERROR
)
1531 YYDPRINTF ((stderr
, "Shifting error token, "));
1542 /*-------------------------------------.
1543 | yyacceptlab -- YYACCEPT comes here. |
1544 `-------------------------------------*/
1549 /*-----------------------------------.
1550 | yyabortlab -- YYABORT comes here. |
1551 `-----------------------------------*/
1556 /*---------------------------------------------.
1557 | yyoverflowab -- parser overflow comes here. |
1558 `---------------------------------------------*/
1560 yyerror ("parser stack overflow");
1567 YYSTACK_FREE (yyss
);
1571 #line 357 "parse-gram.y"
1573 /*------------------------------------------------------------------.
1574 | When debugging the parser, display tokens' locations and values. |
1575 `------------------------------------------------------------------*/
1578 yyprint (FILE *file
,
1579 const location_t
*loc
, int type
, const yystype
*value
)
1582 LOCATION_PRINT (file
, *loc
);
1587 fprintf (file
, " = '%s'", value
->string
);
1591 fprintf (file
, " = %s", value
->symbol
->tag
);
1595 fprintf (file
, " = %d", value
->integer
);
1599 fprintf (file
, " = \"%s\"", value
->string
);
1603 fprintf (file
, " = <%s>", value
->string
);
1609 fprintf (file
, " = {{ %s }}", value
->string
);
1615 gram_error (gram_control_t
*control ATTRIBUTE_UNUSED
,
1616 location_t
*yylloc
, const char *msg
)
1618 LOCATION_PRINT (stderr
, *yylloc
);
1619 fprintf (stderr
, ": %s\n", msg
);