]> git.saurik.com Git - bison.git/blame - src/bison.s1
Improve the readability of the produced parsers.
[bison.git] / src / bison.s1
CommitLineData
10fa2066 1/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
dc08c1d5 2#line
7d369561 3/* This file comes from bison-@bison_version@. */
10fa2066
RS
4
5/* Skeleton output parser for bison,
21b14802 6 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
10fa2066
RS
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
21b14802 10 the Free Software Foundation; either version 2, or (at your option)
10fa2066
RS
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
c49a8e71
JT
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
10fa2066 22
c71f8bba
RS
23/* As a special exception, when this file is copied by Bison into a
24 Bison output file, you may use that output file without restriction.
25 This special exception was added by the Free Software Foundation
cfeaeb52 26 in version 1.24 of Bison. */
10fa2066 27
71da9eea
AD
28/* This is the parser code that is written into each bison parser when
29 the %semantic_parser declaration is not specified in the grammar.
30 It was written by Richard Stallman by simplifying the hairy parser
31 used when %semantic_parser is specified. */
444fbf65 32
70ddf897 33#ifndef YYSTACK_USE_ALLOCA
361f60b3
AD
34# ifdef alloca
35# define YYSTACK_USE_ALLOCA
36# else /* alloca not defined */
37# ifdef __GNUC__
38# define YYSTACK_USE_ALLOCA
39# define alloca __builtin_alloca
40# else /* not GNU C. */
41# if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
42# define YYSTACK_USE_ALLOCA
43# include <alloca.h>
44# else /* not sparc */
45 /* We think this test detects Watcom and Microsoft C. */
46 /* This used to test MSDOS, but that is a bad idea since that
47 symbol is in the user namespace. */
48# if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
49# if 0
50 /* No need for malloc.h, which pollutes the namespace; instead,
51 just don't use alloca. */
52# include <malloc.h>
53# endif
54# else /* not MSDOS, or __TURBOC__ */
55# if defined(_AIX)
56 /* I don't know what this was needed for, but it pollutes the
57 namespace. So I turned it off. rms, 2 May 1997. */
58 /* #include <malloc.h> */
10fa2066 59 #pragma alloca
361f60b3
AD
60# define YYSTACK_USE_ALLOCA
61# else /* not MSDOS, or __TURBOC__, or _AIX */
62# if 0
63 /* haible@ilog.fr says this works for HPUX 9.05 and up, and on
64 HPUX 10. Eventually we can turn this on. */
65# ifdef __hpux
66# define YYSTACK_USE_ALLOCA
67# define alloca __builtin_alloca
68# endif /* __hpux */
69# endif
70# endif /* not _AIX */
71# endif /* not MSDOS, or __TURBOC__ */
72# endif /* not sparc */
73# endif /* not GNU C */
74# endif /* alloca not defined */
70ddf897
RS
75#endif /* YYSTACK_USE_ALLOCA not defined */
76
77#ifdef YYSTACK_USE_ALLOCA
361f60b3 78# define YYSTACK_ALLOC alloca
70ddf897 79#else
361f60b3 80# define YYSTACK_ALLOC malloc
70ddf897 81#endif
10fa2066 82
10fa2066
RS
83/* Note: there must be only one dollar sign in this file.
84 It is replaced by the list of actions, each action
85 as one case of the switch. */
86
87#define yyerrok (yyerrstatus = 0)
88#define yyclearin (yychar = YYEMPTY)
89#define YYEMPTY -2
90#define YYEOF 0
70ddf897
RS
91#define YYACCEPT goto yyacceptlab
92#define YYABORT goto yyabortlab
10fa2066 93#define YYERROR goto yyerrlab1
71da9eea
AD
94/* Like YYERROR except do call yyerror. This remains here temporarily
95 to ease the transition to the new meaning of YYERROR, for GCC.
10fa2066
RS
96 Once GCC version 2 has supplanted version 1, this can go. */
97#define YYFAIL goto yyerrlab
98#define YYRECOVERING() (!!yyerrstatus)
71da9eea 99#define YYBACKUP(Token, Value) \
10fa2066
RS
100do \
101 if (yychar == YYEMPTY && yylen == 1) \
71da9eea
AD
102 { \
103 yychar = (Token); \
104 yylval = (Value); \
10fa2066
RS
105 yychar1 = YYTRANSLATE (yychar); \
106 YYPOPSTACK; \
107 goto yybackup; \
108 } \
109 else \
71da9eea
AD
110 { \
111 yyerror ("syntax error: cannot back up"); \
112 YYERROR; \
113 } \
10fa2066
RS
114while (0)
115
116#define YYTERROR 1
117#define YYERRCODE 256
118
119#ifndef YYPURE
71da9eea 120# define YYLEX yylex ()
10fa2066
RS
121#endif
122
123#ifdef YYPURE
b07b484a
AD
124# ifdef YYLSP_NEEDED
125# ifdef YYLEX_PARAM
71da9eea 126# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
b07b484a 127# else
71da9eea 128# define YYLEX yylex (&yylval, &yylloc)
b07b484a 129# endif
71da9eea 130# else /* !YYLSP_NEEDED */
b07b484a 131# ifdef YYLEX_PARAM
71da9eea 132# define YYLEX yylex (&yylval, YYLEX_PARAM)
b07b484a 133# else
71da9eea 134# define YYLEX yylex (&yylval)
b07b484a 135# endif
71da9eea 136# endif /* !YYLSP_NEEDED */
10fa2066
RS
137#endif
138
41aca2e0 139/* If nonreentrant, generate the variables here. */
10fa2066
RS
140
141#ifndef YYPURE
41aca2e0 142/* The lookahead symbol. */
71da9eea 143int yychar;
10fa2066 144
41aca2e0 145/* The semantic value of the lookahead symbol. */
71da9eea 146YYSTYPE yylval;
10fa2066 147
b07b484a 148# ifdef YYLSP_NEEDED
41aca2e0
AD
149/* Location data for the lookahead symbol. */
150YYLTYPE yylloc;
b07b484a 151# endif
10fa2066 152
41aca2e0
AD
153/* Number of parse errors so far. */
154int yynerrs;
71da9eea 155#endif /* !YYPURE */
10fa2066 156
0de741ca 157
0d533154 158#if YYDEBUG
10fa2066 159int yydebug; /* nonzero means print parse trace */
0de741ca
AD
160
161 /* [The following comment makes no sense to me. Could someone
162 clarify it? --akim] Since this is uninitialized, it does not
163 stop multiple parsers from coexisting. */
164#else
165 /* To avoid crippling this file with `#if YYDEBUG', define `yydebug'
166 as `0', so that the `if (yydebug)' be removed as dead code. */
167# define yydebug 0
10fa2066
RS
168#endif
169
170/* YYINITDEPTH indicates the initial size of the parser's stacks */
171
172#ifndef YYINITDEPTH
b07b484a 173# define YYINITDEPTH 200
10fa2066
RS
174#endif
175
176/* YYMAXDEPTH is the maximum size the stacks can grow to
177 (effective only if the built-in stack extension method is used). */
178
179#if YYMAXDEPTH == 0
b07b484a 180# undef YYMAXDEPTH
10fa2066
RS
181#endif
182
183#ifndef YYMAXDEPTH
b07b484a 184# define YYMAXDEPTH 10000
10fa2066 185#endif
10fa2066 186\f
5e02f2ad
RS
187/* Define __yy_memcpy. Note that the size argument
188 should be passed with type unsigned int, because that is what the non-GCC
189 definitions require. With GCC, __builtin_memcpy takes an arg
190 of type size_t, but it can handle unsigned int. */
191
10fa2066 192#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
71da9eea 193# define __yy_memcpy(To,From,Count) __builtin_memcpy (To,From,Count)
10fa2066 194#else /* not GNU C or C++ */
b07b484a 195# ifndef __cplusplus
10fa2066
RS
196
197/* This is the most reliable way to avoid incompatibilities
198 in available built-in functions on various systems. */
199static void
c245d0d3 200__yy_memcpy (to, from, count)
10fa2066 201 char *to;
c245d0d3 202 char *from;
5e02f2ad 203 unsigned int count;
10fa2066
RS
204{
205 register char *f = from;
206 register char *t = to;
207 register int i = count;
208
209 while (i-- > 0)
210 *t++ = *f++;
211}
212
b07b484a 213# else /* __cplusplus */
10fa2066
RS
214
215/* This is the most reliable way to avoid incompatibilities
216 in available built-in functions on various systems. */
217static void
5e02f2ad 218__yy_memcpy (char *to, char *from, unsigned int count)
10fa2066 219{
10fa2066 220 register char *t = to;
4cf401b2 221 register char *f = from;
10fa2066
RS
222 register int i = count;
223
224 while (i-- > 0)
225 *t++ = *f++;
226}
227
b07b484a 228# endif
10fa2066
RS
229#endif
230\f
dc08c1d5 231#line
b658bf92
RS
232
233/* The user can define YYPARSE_PARAM as the name of an argument to be passed
234 into yyparse. The argument should have type void *.
235 It should actually point to an object.
236 Grammar actions can access the variable by casting it
237 to the proper pointer type. */
238
239#ifdef YYPARSE_PARAM
b07b484a
AD
240# ifdef __cplusplus
241# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
242# define YYPARSE_PARAM_DECL
71da9eea 243# else /* !__cplusplus */
b07b484a
AD
244# define YYPARSE_PARAM_ARG YYPARSE_PARAM
245# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
71da9eea
AD
246# endif /* !__cplusplus */
247#else /* !YYPARSE_PARAM */
b07b484a
AD
248# define YYPARSE_PARAM_ARG
249# define YYPARSE_PARAM_DECL
71da9eea 250#endif /* !YYPARSE_PARAM */
b658bf92 251
1b181651
PE
252/* Prevent warning if -Wstrict-prototypes. */
253#ifdef __GNUC__
b07b484a 254# ifdef YYPARSE_PARAM
1b181651 255int yyparse (void *);
b07b484a 256# else
1b181651 257int yyparse (void);
b07b484a 258# endif
1b181651
PE
259#endif
260
10fa2066 261int
71da9eea 262yyparse (YYPARSE_PARAM_ARG)
b658bf92 263 YYPARSE_PARAM_DECL
10fa2066
RS
264{
265 register int yystate;
266 register int yyn;
b07b484a
AD
267 /* Number of tokens to shift before error messages enabled. */
268 int yyerrstatus;
269 /* Lookahead token as an internal (translated) token number. */
270 int yychar1 = 0;
10fa2066 271
bb10be54
AD
272 /* Three stacks and their tools:
273 `yyss': related to states,
274 `yysv': related to semantic values,
275 `yyls': related to locations.
276
277 Refer to the stacks thru separate pointers, to allow yyoverflow
278 to reallocate them elsewhere. */
279
b07b484a
AD
280 /* The state stack. */
281 short yyssa[YYINITDEPTH];
bb10be54
AD
282 short *yyss = yyssa;
283 register short *yyssp;
284
b07b484a
AD
285 /* The semantic value stack. */
286 YYSTYPE yyvsa[YYINITDEPTH];
b07b484a 287 YYSTYPE *yyvs = yyvsa;
bb10be54 288 register YYSTYPE *yyvsp;
10fa2066
RS
289
290#ifdef YYLSP_NEEDED
b07b484a
AD
291 /* The location stack. */
292 YYLTYPE yylsa[YYINITDEPTH];
10fa2066
RS
293 YYLTYPE *yyls = yylsa;
294 YYLTYPE *yylsp;
bb10be54 295#endif
10fa2066 296
bb10be54 297#ifdef YYLSP_NEEDED
b07b484a 298# define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
10fa2066 299#else
b07b484a 300# define YYPOPSTACK (yyvsp--, yyssp--)
10fa2066
RS
301#endif
302
303 int yystacksize = YYINITDEPTH;
70ddf897 304 int yyfree_stacks = 0;
10fa2066
RS
305
306#ifdef YYPURE
307 int yychar;
308 YYSTYPE yylval;
309 int yynerrs;
b07b484a 310# ifdef YYLSP_NEEDED
10fa2066 311 YYLTYPE yylloc;
b07b484a 312# endif
10fa2066
RS
313#endif
314
bb10be54 315
6666f98f
AD
316 /* The variables used to return semantic value and location from the
317 action routines. */
bb10be54 318 YYSTYPE yyval;
6666f98f
AD
319# ifdef YYLSP_NEEDED
320 YYLTYPE yyloc;
321# endif
10fa2066 322
6666f98f
AD
323 /* When reducing, the number of symbols on the RHS of the reduced
324 rule. */
10fa2066
RS
325 int yylen;
326
10fa2066 327 if (yydebug)
0de741ca 328 fprintf (stderr, "Starting parse\n");
10fa2066
RS
329
330 yystate = 0;
331 yyerrstatus = 0;
332 yynerrs = 0;
333 yychar = YYEMPTY; /* Cause a token to be read. */
334
335 /* Initialize stack pointers.
336 Waste one element of value and location stack
337 so that they stay on the same level as the state stack.
338 The wasted elements are never initialized. */
339
340 yyssp = yyss - 1;
341 yyvsp = yyvs;
342#ifdef YYLSP_NEEDED
343 yylsp = yyls;
344#endif
345
10fa2066 346
71da9eea
AD
347/*------------------------------------------------------------.
348| yynewstate -- Push a new state, which is found in yystate. |
349`------------------------------------------------------------*/
350yynewstate:
351 /* In all cases, when you get here, the value and location stacks
352 have just been pushed. so pushing a state here evens the stacks.
353 */
10fa2066
RS
354 *++yyssp = yystate;
355
356 if (yyssp >= yyss + yystacksize - 1)
357 {
71da9eea
AD
358 /* Give user a chance to reallocate the stack. Use copies of
359 these so that the &'s don't force the real ones into memory.
360 */
10fa2066
RS
361 YYSTYPE *yyvs1 = yyvs;
362 short *yyss1 = yyss;
363#ifdef YYLSP_NEEDED
364 YYLTYPE *yyls1 = yyls;
365#endif
366
367 /* Get the current used size of the three stacks, in elements. */
368 int size = yyssp - yyss + 1;
369
370#ifdef yyoverflow
371 /* Each stack pointer address is followed by the size of
372 the data in use in that stack, in bytes. */
b07b484a 373# ifdef YYLSP_NEEDED
be4bf877
RS
374 /* This used to be a conditional around just the two extra args,
375 but that might be undefined if yyoverflow is a macro. */
bb10be54
AD
376 yyoverflow ("parser stack overflow",
377 &yyss1, size * sizeof (*yyssp),
378 &yyvs1, size * sizeof (*yyvsp),
379 &yyls1, size * sizeof (*yylsp),
380 &yystacksize);
b07b484a 381# else
bb10be54
AD
382 yyoverflow ("parser stack overflow",
383 &yyss1, size * sizeof (*yyssp),
384 &yyvs1, size * sizeof (*yyvsp),
385 &yystacksize);
b07b484a 386# endif
10fa2066
RS
387
388 yyss = yyss1; yyvs = yyvs1;
b07b484a 389# ifdef YYLSP_NEEDED
10fa2066 390 yyls = yyls1;
b07b484a 391# endif
10fa2066
RS
392#else /* no yyoverflow */
393 /* Extend the stack our own way. */
394 if (yystacksize >= YYMAXDEPTH)
395 {
71da9eea 396 yyerror ("parser stack overflow");
70ddf897
RS
397 if (yyfree_stacks)
398 {
399 free (yyss);
400 free (yyvs);
b07b484a 401# ifdef YYLSP_NEEDED
70ddf897 402 free (yyls);
b07b484a 403# endif
70ddf897 404 }
10fa2066
RS
405 return 2;
406 }
407 yystacksize *= 2;
408 if (yystacksize > YYMAXDEPTH)
409 yystacksize = YYMAXDEPTH;
b07b484a 410# ifndef YYSTACK_USE_ALLOCA
70ddf897 411 yyfree_stacks = 1;
b07b484a 412# endif
70ddf897 413 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
5e02f2ad
RS
414 __yy_memcpy ((char *)yyss, (char *)yyss1,
415 size * (unsigned int) sizeof (*yyssp));
70ddf897 416 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
5e02f2ad
RS
417 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
418 size * (unsigned int) sizeof (*yyvsp));
b07b484a 419# ifdef YYLSP_NEEDED
70ddf897 420 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
5e02f2ad
RS
421 __yy_memcpy ((char *)yyls, (char *)yyls1,
422 size * (unsigned int) sizeof (*yylsp));
b07b484a 423# endif
10fa2066
RS
424#endif /* no yyoverflow */
425
426 yyssp = yyss + size - 1;
427 yyvsp = yyvs + size - 1;
428#ifdef YYLSP_NEEDED
429 yylsp = yyls + size - 1;
430#endif
431
10fa2066 432 if (yydebug)
0de741ca 433 fprintf (stderr, "Stack size increased to %d\n", yystacksize);
10fa2066
RS
434
435 if (yyssp >= yyss + yystacksize - 1)
436 YYABORT;
437 }
438
10fa2066 439 if (yydebug)
0de741ca 440 fprintf (stderr, "Entering state %d\n", yystate);
10fa2066
RS
441
442 goto yybackup;
71da9eea
AD
443
444
445/*-----------.
446| yybackup. |
447`-----------*/
448yybackup:
10fa2066
RS
449
450/* Do appropriate processing given the current state. */
451/* Read a lookahead token if we need one and don't already have one. */
452/* yyresume: */
453
454 /* First try to decide what to do without reference to lookahead token. */
455
456 yyn = yypact[yystate];
457 if (yyn == YYFLAG)
458 goto yydefault;
459
460 /* Not known => get a lookahead token if don't already have one. */
461
462 /* yychar is either YYEMPTY or YYEOF
463 or a valid token in external form. */
464
465 if (yychar == YYEMPTY)
466 {
10fa2066 467 if (yydebug)
0de741ca 468 fprintf (stderr, "Reading a token: ");
10fa2066
RS
469 yychar = YYLEX;
470 }
471
472 /* Convert token to internal form (in yychar1) for indexing tables with */
473
474 if (yychar <= 0) /* This means end of input. */
475 {
476 yychar1 = 0;
477 yychar = YYEOF; /* Don't call YYLEX any more */
478
10fa2066 479 if (yydebug)
0de741ca 480 fprintf (stderr, "Now at end of input.\n");
10fa2066
RS
481 }
482 else
483 {
71da9eea 484 yychar1 = YYTRANSLATE (yychar);
10fa2066 485
0d533154
AD
486#if YYDEBUG
487 /* We have to keep this `#if YYDEBUG', since we use variables
488 which are defined only if `YYDEBUG' is set. */
10fa2066
RS
489 if (yydebug)
490 {
491 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
0d533154
AD
492 /* Give the individual parser a way to print the precise
493 meaning of a token, for further debugging info. */
b07b484a 494# ifdef YYPRINT
10fa2066 495 YYPRINT (stderr, yychar, yylval);
b07b484a 496# endif
10fa2066
RS
497 fprintf (stderr, ")\n");
498 }
0d533154 499#endif
10fa2066
RS
500 }
501
502 yyn += yychar1;
503 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
504 goto yydefault;
505
506 yyn = yytable[yyn];
507
508 /* yyn is what to do for this token type in this state.
509 Negative => reduce, -yyn is rule number.
510 Positive => shift, yyn is new state.
511 New state is final state => don't bother to shift,
512 just return success.
513 0, or most negative number => error. */
514
515 if (yyn < 0)
516 {
517 if (yyn == YYFLAG)
518 goto yyerrlab;
519 yyn = -yyn;
520 goto yyreduce;
521 }
522 else if (yyn == 0)
523 goto yyerrlab;
524
525 if (yyn == YYFINAL)
526 YYACCEPT;
527
528 /* Shift the lookahead token. */
0d533154 529#if YYDEBUG
10fa2066 530 if (yydebug)
0de741ca 531 fprintf (stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
0d533154 532#endif
10fa2066
RS
533
534 /* Discard the token being shifted unless it is eof. */
535 if (yychar != YYEOF)
536 yychar = YYEMPTY;
537
538 *++yyvsp = yylval;
539#ifdef YYLSP_NEEDED
540 *++yylsp = yylloc;
541#endif
542
71da9eea
AD
543 /* Count tokens shifted since error; after three, turn off error
544 status. */
545 if (yyerrstatus)
546 yyerrstatus--;
10fa2066
RS
547
548 yystate = yyn;
549 goto yynewstate;
550
10fa2066 551
71da9eea
AD
552/*-----------------------------------------------------------.
553| yydefault -- do the default action for the current state. |
554`-----------------------------------------------------------*/
555yydefault:
10fa2066
RS
556 yyn = yydefact[yystate];
557 if (yyn == 0)
558 goto yyerrlab;
71da9eea 559 goto yyreduce;
10fa2066 560
71da9eea
AD
561
562/*-----------------------------.
563| yyreduce -- Do a reduction. |
564`-----------------------------*/
10fa2066 565yyreduce:
71da9eea 566 /* yyn is the number of a rule to reduce with. */
10fa2066 567 yylen = yyr2[yyn];
6666f98f
AD
568 /* Implement default value of the action:
569 `{dollar}{dollar} = {dollar}1'. */
570 if (yylen > 0)
571 yyval = yyvsp[1-yylen];
572#ifdef YYLSP_NEEDED
573 /* Implement default location. If the rhs is empty, extend YYLOC to
574 YYLLOC, which corresponds to the current token, otherwise
575 implement `@{dollar} = Starts at @1, ends at @YYLEN'. */
fb75fa82 576 if (yylen > 0)
6666f98f
AD
577 {
578 yyloc = yylsp[1-yylen];
579 yyloc.last_line = yylsp[0].last_line;
580 yyloc.last_column = yylsp[0].last_column;
581 }
582 else
583 {
584 yyloc.last_line = yylsp[0].last_line;
585 yyloc.last_column = yylsp[0].last_column;
586 yyloc.text = 0;
587 }
588#endif
10fa2066 589
0de741ca
AD
590#if YYDEBUG
591 /* We have to keep this `#if YYDEBUG', since we use variables which
592 are defined only if `YYDEBUG' is set. */
10fa2066
RS
593 if (yydebug)
594 {
595 int i;
596
597 fprintf (stderr, "Reducing via rule %d (line %d), ",
598 yyn, yyrline[yyn]);
599
600 /* Print the symbols being reduced, and their result. */
601 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
602 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
603 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
604 }
605#endif
71da9eea 606$ /* The action file replaces this line marked with this dollarsign. */
dc08c1d5 607#line
10fa2066
RS
608\f
609 yyvsp -= yylen;
610 yyssp -= yylen;
611#ifdef YYLSP_NEEDED
612 yylsp -= yylen;
613#endif
614
10fa2066
RS
615 if (yydebug)
616 {
617 short *ssp1 = yyss - 1;
618 fprintf (stderr, "state stack now");
619 while (ssp1 != yyssp)
620 fprintf (stderr, " %d", *++ssp1);
621 fprintf (stderr, "\n");
622 }
10fa2066
RS
623
624 *++yyvsp = yyval;
10fa2066 625#ifdef YYLSP_NEEDED
6666f98f 626 *++yylsp = yyloc;
10fa2066
RS
627#endif
628
41aca2e0
AD
629 /* Now `shift' the result of the reduction. Determine what state
630 that goes to, based on the state we popped back to and the rule
631 number reduced by. */
10fa2066
RS
632
633 yyn = yyr1[yyn];
634
635 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
636 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
637 yystate = yytable[yystate];
638 else
639 yystate = yydefgoto[yyn - YYNTBASE];
640
641 goto yynewstate;
642
10fa2066 643
71da9eea
AD
644/*------------------------------------.
645| yyerrlab -- here on detecting error |
646`------------------------------------*/
647yyerrlab:
648 /* If not already recovering from an error, report this error. */
649 if (!yyerrstatus)
10fa2066
RS
650 {
651 ++yynerrs;
652
653#ifdef YYERROR_VERBOSE
654 yyn = yypact[yystate];
655
656 if (yyn > YYFLAG && yyn < YYLAST)
657 {
658 int size = 0;
659 char *msg;
660 int x, count;
661
662 count = 0;
663 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
664 for (x = (yyn < 0 ? -yyn : 0);
71da9eea 665 x < (sizeof (yytname) / sizeof (char *)); x++)
10fa2066 666 if (yycheck[x + yyn] == x)
71da9eea 667 size += strlen (yytname[x]) + 15, count++;
75bbe78d
AD
668 size += strlen ("parse error, unexpected `") + 1;
669 size += strlen (yytname[YYTRANSLATE (yychar)]);
670 msg = (char *) malloc (size);
10fa2066
RS
671 if (msg != 0)
672 {
75bbe78d
AD
673 strcpy (msg, "parse error, unexpected `");
674 strcat (msg, yytname[YYTRANSLATE (yychar)]);
675 strcat (msg, "'");
10fa2066
RS
676
677 if (count < 5)
678 {
679 count = 0;
680 for (x = (yyn < 0 ? -yyn : 0);
71da9eea 681 x < (sizeof (yytname) / sizeof (char *)); x++)
10fa2066
RS
682 if (yycheck[x + yyn] == x)
683 {
75bbe78d
AD
684 strcat (msg, count == 0 ? ", expecting `" : " or `");
685 strcat (msg, yytname[x]);
686 strcat (msg, "'");
10fa2066
RS
687 count++;
688 }
689 }
75bbe78d
AD
690 yyerror (msg);
691 free (msg);
10fa2066
RS
692 }
693 else
694 yyerror ("parse error; also virtual memory exceeded");
695 }
696 else
697#endif /* YYERROR_VERBOSE */
75bbe78d 698 yyerror ("parse error");
10fa2066 699 }
10fa2066 700 goto yyerrlab1;
10fa2066 701
71da9eea
AD
702
703/*--------------------------------------------------.
704| yyerrlab1 -- error raised explicitly by an action |
705`--------------------------------------------------*/
706yyerrlab1:
10fa2066
RS
707 if (yyerrstatus == 3)
708 {
71da9eea
AD
709 /* If just tried and failed to reuse lookahead token after an
710 error, discard it. */
10fa2066
RS
711
712 /* return failure if at end of input */
713 if (yychar == YYEOF)
714 YYABORT;
0d533154 715#if YYDEBUG
10fa2066 716 if (yydebug)
0de741ca
AD
717 fprintf (stderr, "Discarding token %d (%s).\n",
718 yychar, yytname[yychar1]);
0d533154 719#endif
10fa2066
RS
720 yychar = YYEMPTY;
721 }
722
71da9eea
AD
723 /* Else will try to reuse lookahead token after shifting the error
724 token. */
10fa2066
RS
725
726 yyerrstatus = 3; /* Each real token shifted decrements this */
727
728 goto yyerrhandle;
729
10fa2066 730
71da9eea
AD
731/*-------------------------------------------------------------------.
732| yyerrdefault -- current state does not do anything special for the |
733| error token. |
734`-------------------------------------------------------------------*/
735yyerrdefault:
10fa2066
RS
736#if 0
737 /* This is wrong; only states that explicitly want error tokens
738 should shift them. */
71da9eea
AD
739
740 /* If its default is to accept any token, ok. Otherwise pop it. */
741 yyn = yydefact[yystate];
742 if (yyn)
743 goto yydefault;
10fa2066
RS
744#endif
745
10fa2066 746
71da9eea
AD
747/*---------------------------------------------------------------.
748| yyerrpop -- pop the current state because it cannot handle the |
749| error token |
750`---------------------------------------------------------------*/
751yyerrpop:
752 if (yyssp == yyss)
753 YYABORT;
10fa2066
RS
754 yyvsp--;
755 yystate = *--yyssp;
756#ifdef YYLSP_NEEDED
757 yylsp--;
758#endif
759
10fa2066
RS
760 if (yydebug)
761 {
762 short *ssp1 = yyss - 1;
763 fprintf (stderr, "Error: state stack now");
764 while (ssp1 != yyssp)
765 fprintf (stderr, " %d", *++ssp1);
766 fprintf (stderr, "\n");
767 }
10fa2066 768
10fa2066 769
71da9eea
AD
770/*--------------.
771| yyerrhandle. |
772`--------------*/
773yyerrhandle:
10fa2066
RS
774 yyn = yypact[yystate];
775 if (yyn == YYFLAG)
776 goto yyerrdefault;
777
778 yyn += YYTERROR;
779 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
780 goto yyerrdefault;
781
782 yyn = yytable[yyn];
783 if (yyn < 0)
784 {
785 if (yyn == YYFLAG)
786 goto yyerrpop;
787 yyn = -yyn;
788 goto yyreduce;
789 }
790 else if (yyn == 0)
791 goto yyerrpop;
792
793 if (yyn == YYFINAL)
794 YYACCEPT;
795
10fa2066 796 if (yydebug)
0de741ca 797 fprintf (stderr, "Shifting error token, ");
10fa2066
RS
798
799 *++yyvsp = yylval;
800#ifdef YYLSP_NEEDED
801 *++yylsp = yylloc;
802#endif
803
804 yystate = yyn;
805 goto yynewstate;
70ddf897 806
71da9eea
AD
807
808/*-------------------------------------.
809| yyacceptlab -- YYACCEPT comes here. |
810`-------------------------------------*/
811yyacceptlab:
70ddf897
RS
812 if (yyfree_stacks)
813 {
814 free (yyss);
815 free (yyvs);
816#ifdef YYLSP_NEEDED
817 free (yyls);
818#endif
819 }
820 return 0;
821
71da9eea
AD
822
823/*-----------------------------------.
824| yyabortlab -- YYABORT comes here. |
825`-----------------------------------*/
826yyabortlab:
70ddf897
RS
827 if (yyfree_stacks)
828 {
829 free (yyss);
830 free (yyvs);
831#ifdef YYLSP_NEEDED
832 free (yyls);
833#endif
834 }
835 return 1;
10fa2066 836}