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