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