]> git.saurik.com Git - bison.git/blame - bison.simple
Describe literal string tokens, %raw, %no_lines, %token_table.
[bison.git] / bison.simple
CommitLineData
10fa2066
RS
1/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
2#line 3 "bison.simple"
3
4/* Skeleton output parser for bison,
21b14802 5 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
10fa2066
RS
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
21b14802 9 the Free Software Foundation; either version 2, or (at your option)
10fa2066
RS
10 any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
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
RS
25
26#ifndef alloca
27#ifdef __GNUC__
28#define alloca __builtin_alloca
29#else /* not GNU C. */
30#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
31#include <alloca.h>
32#else /* not sparc */
33#if defined (MSDOS) && !defined (__TURBOC__)
34#include <malloc.h>
35#else /* not MSDOS, or __TURBOC__ */
36#if defined(_AIX)
37#include <malloc.h>
38 #pragma alloca
39#else /* not MSDOS, __TURBOC__, or _AIX */
40#ifdef __hpux
41#ifdef __cplusplus
42extern "C" {
43void *alloca (unsigned int);
44};
45#else /* not __cplusplus */
46void *alloca ();
47#endif /* not __cplusplus */
48#endif /* __hpux */
49#endif /* not _AIX */
50#endif /* not MSDOS, or __TURBOC__ */
51#endif /* not sparc. */
52#endif /* not GNU C. */
53#endif /* alloca not defined. */
54
55/* This is the parser code that is written into each bison parser
56 when the %semantic_parser declaration is not specified in the grammar.
57 It was written by Richard Stallman by simplifying the hairy parser
58 used when %semantic_parser is specified. */
59
60/* Note: there must be only one dollar sign in this file.
61 It is replaced by the list of actions, each action
62 as one case of the switch. */
63
64#define yyerrok (yyerrstatus = 0)
65#define yyclearin (yychar = YYEMPTY)
66#define YYEMPTY -2
67#define YYEOF 0
68#define YYACCEPT return(0)
69#define YYABORT return(1)
70#define YYERROR goto yyerrlab1
71/* Like YYERROR except do call yyerror.
72 This remains here temporarily to ease the
73 transition to the new meaning of YYERROR, for GCC.
74 Once GCC version 2 has supplanted version 1, this can go. */
75#define YYFAIL goto yyerrlab
76#define YYRECOVERING() (!!yyerrstatus)
77#define YYBACKUP(token, value) \
78do \
79 if (yychar == YYEMPTY && yylen == 1) \
80 { yychar = (token), yylval = (value); \
81 yychar1 = YYTRANSLATE (yychar); \
82 YYPOPSTACK; \
83 goto yybackup; \
84 } \
85 else \
86 { yyerror ("syntax error: cannot back up"); YYERROR; } \
87while (0)
88
89#define YYTERROR 1
90#define YYERRCODE 256
91
92#ifndef YYPURE
93#define YYLEX yylex()
94#endif
95
96#ifdef YYPURE
97#ifdef YYLSP_NEEDED
e425e872
RS
98#ifdef YYLEX_PARAM
99#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
100#else
10fa2066 101#define YYLEX yylex(&yylval, &yylloc)
e425e872
RS
102#endif
103#else /* not YYLSP_NEEDED */
104#ifdef YYLEX_PARAM
105#define YYLEX yylex(&yylval, YYLEX_PARAM)
10fa2066
RS
106#else
107#define YYLEX yylex(&yylval)
108#endif
e425e872 109#endif /* not YYLSP_NEEDED */
10fa2066
RS
110#endif
111
112/* If nonreentrant, generate the variables here */
113
114#ifndef YYPURE
115
116int yychar; /* the lookahead symbol */
117YYSTYPE yylval; /* the semantic value of the */
118 /* lookahead symbol */
119
120#ifdef YYLSP_NEEDED
121YYLTYPE yylloc; /* location data for the lookahead */
122 /* symbol */
123#endif
124
125int yynerrs; /* number of parse errors so far */
126#endif /* not YYPURE */
127
128#if YYDEBUG != 0
129int yydebug; /* nonzero means print parse trace */
130/* Since this is uninitialized, it does not stop multiple parsers
131 from coexisting. */
132#endif
133
134/* YYINITDEPTH indicates the initial size of the parser's stacks */
135
136#ifndef YYINITDEPTH
137#define YYINITDEPTH 200
138#endif
139
140/* YYMAXDEPTH is the maximum size the stacks can grow to
141 (effective only if the built-in stack extension method is used). */
142
143#if YYMAXDEPTH == 0
144#undef YYMAXDEPTH
145#endif
146
147#ifndef YYMAXDEPTH
148#define YYMAXDEPTH 10000
149#endif
150
151/* Prevent warning if -Wstrict-prototypes. */
152#ifdef __GNUC__
153int yyparse (void);
154#endif
155\f
156#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
ba39f603 157#define __yy_memcpy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT)
10fa2066
RS
158#else /* not GNU C or C++ */
159#ifndef __cplusplus
160
161/* This is the most reliable way to avoid incompatibilities
162 in available built-in functions on various systems. */
163static void
ba39f603 164__yy_memcpy (from, to, count)
10fa2066
RS
165 char *from;
166 char *to;
167 int count;
168{
169 register char *f = from;
170 register char *t = to;
171 register int i = count;
172
173 while (i-- > 0)
174 *t++ = *f++;
175}
176
177#else /* __cplusplus */
178
179/* This is the most reliable way to avoid incompatibilities
180 in available built-in functions on various systems. */
181static void
ba39f603 182__yy_memcpy (char *from, char *to, int count)
10fa2066
RS
183{
184 register char *f = from;
185 register char *t = to;
186 register int i = count;
187
188 while (i-- > 0)
189 *t++ = *f++;
190}
191
192#endif
193#endif
194\f
cc90caac 195#line 192 "bison.simple"
b658bf92
RS
196
197/* The user can define YYPARSE_PARAM as the name of an argument to be passed
198 into yyparse. The argument should have type void *.
199 It should actually point to an object.
200 Grammar actions can access the variable by casting it
201 to the proper pointer type. */
202
203#ifdef YYPARSE_PARAM
204#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
205#else
206#define YYPARSE_PARAM
21b3ea15 207#define YYPARSE_PARAM_DECL
b658bf92
RS
208#endif
209
10fa2066 210int
b658bf92
RS
211yyparse(YYPARSE_PARAM)
212 YYPARSE_PARAM_DECL
10fa2066
RS
213{
214 register int yystate;
215 register int yyn;
216 register short *yyssp;
217 register YYSTYPE *yyvsp;
218 int yyerrstatus; /* number of tokens to shift before error messages enabled */
c6c88451 219 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
10fa2066
RS
220
221 short yyssa[YYINITDEPTH]; /* the state stack */
222 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
223
224 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
225 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
226
227#ifdef YYLSP_NEEDED
228 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
229 YYLTYPE *yyls = yylsa;
230 YYLTYPE *yylsp;
231
232#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
233#else
234#define YYPOPSTACK (yyvsp--, yyssp--)
235#endif
236
237 int yystacksize = YYINITDEPTH;
238
239#ifdef YYPURE
240 int yychar;
241 YYSTYPE yylval;
242 int yynerrs;
243#ifdef YYLSP_NEEDED
244 YYLTYPE yylloc;
245#endif
246#endif
247
248 YYSTYPE yyval; /* the variable used to return */
249 /* semantic values from the action */
250 /* routines */
251
252 int yylen;
253
254#if YYDEBUG != 0
255 if (yydebug)
256 fprintf(stderr, "Starting parse\n");
257#endif
258
259 yystate = 0;
260 yyerrstatus = 0;
261 yynerrs = 0;
262 yychar = YYEMPTY; /* Cause a token to be read. */
263
264 /* Initialize stack pointers.
265 Waste one element of value and location stack
266 so that they stay on the same level as the state stack.
267 The wasted elements are never initialized. */
268
269 yyssp = yyss - 1;
270 yyvsp = yyvs;
271#ifdef YYLSP_NEEDED
272 yylsp = yyls;
273#endif
274
275/* Push a new state, which is found in yystate . */
276/* In all cases, when you get here, the value and location stacks
277 have just been pushed. so pushing a state here evens the stacks. */
278yynewstate:
279
280 *++yyssp = yystate;
281
282 if (yyssp >= yyss + yystacksize - 1)
283 {
284 /* Give user a chance to reallocate the stack */
285 /* Use copies of these so that the &'s don't force the real ones into memory. */
286 YYSTYPE *yyvs1 = yyvs;
287 short *yyss1 = yyss;
288#ifdef YYLSP_NEEDED
289 YYLTYPE *yyls1 = yyls;
290#endif
291
292 /* Get the current used size of the three stacks, in elements. */
293 int size = yyssp - yyss + 1;
294
295#ifdef yyoverflow
296 /* Each stack pointer address is followed by the size of
297 the data in use in that stack, in bytes. */
be4bf877
RS
298#ifdef YYLSP_NEEDED
299 /* This used to be a conditional around just the two extra args,
300 but that might be undefined if yyoverflow is a macro. */
10fa2066
RS
301 yyoverflow("parser stack overflow",
302 &yyss1, size * sizeof (*yyssp),
303 &yyvs1, size * sizeof (*yyvsp),
10fa2066 304 &yyls1, size * sizeof (*yylsp),
10fa2066 305 &yystacksize);
be4bf877
RS
306#else
307 yyoverflow("parser stack overflow",
308 &yyss1, size * sizeof (*yyssp),
309 &yyvs1, size * sizeof (*yyvsp),
310 &yystacksize);
311#endif
10fa2066
RS
312
313 yyss = yyss1; yyvs = yyvs1;
314#ifdef YYLSP_NEEDED
315 yyls = yyls1;
316#endif
317#else /* no yyoverflow */
318 /* Extend the stack our own way. */
319 if (yystacksize >= YYMAXDEPTH)
320 {
321 yyerror("parser stack overflow");
322 return 2;
323 }
324 yystacksize *= 2;
325 if (yystacksize > YYMAXDEPTH)
326 yystacksize = YYMAXDEPTH;
327 yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
ba39f603 328 __yy_memcpy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
10fa2066 329 yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
ba39f603 330 __yy_memcpy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
10fa2066
RS
331#ifdef YYLSP_NEEDED
332 yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
ba39f603 333 __yy_memcpy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
10fa2066
RS
334#endif
335#endif /* no yyoverflow */
336
337 yyssp = yyss + size - 1;
338 yyvsp = yyvs + size - 1;
339#ifdef YYLSP_NEEDED
340 yylsp = yyls + size - 1;
341#endif
342
343#if YYDEBUG != 0
344 if (yydebug)
345 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
346#endif
347
348 if (yyssp >= yyss + yystacksize - 1)
349 YYABORT;
350 }
351
352#if YYDEBUG != 0
353 if (yydebug)
354 fprintf(stderr, "Entering state %d\n", yystate);
355#endif
356
357 goto yybackup;
358 yybackup:
359
360/* Do appropriate processing given the current state. */
361/* Read a lookahead token if we need one and don't already have one. */
362/* yyresume: */
363
364 /* First try to decide what to do without reference to lookahead token. */
365
366 yyn = yypact[yystate];
367 if (yyn == YYFLAG)
368 goto yydefault;
369
370 /* Not known => get a lookahead token if don't already have one. */
371
372 /* yychar is either YYEMPTY or YYEOF
373 or a valid token in external form. */
374
375 if (yychar == YYEMPTY)
376 {
377#if YYDEBUG != 0
378 if (yydebug)
379 fprintf(stderr, "Reading a token: ");
380#endif
381 yychar = YYLEX;
382 }
383
384 /* Convert token to internal form (in yychar1) for indexing tables with */
385
386 if (yychar <= 0) /* This means end of input. */
387 {
388 yychar1 = 0;
389 yychar = YYEOF; /* Don't call YYLEX any more */
390
391#if YYDEBUG != 0
392 if (yydebug)
393 fprintf(stderr, "Now at end of input.\n");
394#endif
395 }
396 else
397 {
398 yychar1 = YYTRANSLATE(yychar);
399
400#if YYDEBUG != 0
401 if (yydebug)
402 {
403 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
404 /* Give the individual parser a way to print the precise meaning
405 of a token, for further debugging info. */
406#ifdef YYPRINT
407 YYPRINT (stderr, yychar, yylval);
408#endif
409 fprintf (stderr, ")\n");
410 }
411#endif
412 }
413
414 yyn += yychar1;
415 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
416 goto yydefault;
417
418 yyn = yytable[yyn];
419
420 /* yyn is what to do for this token type in this state.
421 Negative => reduce, -yyn is rule number.
422 Positive => shift, yyn is new state.
423 New state is final state => don't bother to shift,
424 just return success.
425 0, or most negative number => error. */
426
427 if (yyn < 0)
428 {
429 if (yyn == YYFLAG)
430 goto yyerrlab;
431 yyn = -yyn;
432 goto yyreduce;
433 }
434 else if (yyn == 0)
435 goto yyerrlab;
436
437 if (yyn == YYFINAL)
438 YYACCEPT;
439
440 /* Shift the lookahead token. */
441
442#if YYDEBUG != 0
443 if (yydebug)
444 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
445#endif
446
447 /* Discard the token being shifted unless it is eof. */
448 if (yychar != YYEOF)
449 yychar = YYEMPTY;
450
451 *++yyvsp = yylval;
452#ifdef YYLSP_NEEDED
453 *++yylsp = yylloc;
454#endif
455
456 /* count tokens shifted since error; after three, turn off error status. */
457 if (yyerrstatus) yyerrstatus--;
458
459 yystate = yyn;
460 goto yynewstate;
461
462/* Do the default action for the current state. */
463yydefault:
464
465 yyn = yydefact[yystate];
466 if (yyn == 0)
467 goto yyerrlab;
468
469/* Do a reduction. yyn is the number of a rule to reduce with. */
470yyreduce:
471 yylen = yyr2[yyn];
fb75fa82
RS
472 if (yylen > 0)
473 yyval = yyvsp[1-yylen]; /* implement default value of the action */
10fa2066
RS
474
475#if YYDEBUG != 0
476 if (yydebug)
477 {
478 int i;
479
480 fprintf (stderr, "Reducing via rule %d (line %d), ",
481 yyn, yyrline[yyn]);
482
483 /* Print the symbols being reduced, and their result. */
484 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
485 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
486 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
487 }
488#endif
489
490$ /* the action file gets copied in in place of this dollarsign */
cc90caac 491#line 487 "bison.simple"
10fa2066
RS
492\f
493 yyvsp -= yylen;
494 yyssp -= yylen;
495#ifdef YYLSP_NEEDED
496 yylsp -= yylen;
497#endif
498
499#if YYDEBUG != 0
500 if (yydebug)
501 {
502 short *ssp1 = yyss - 1;
503 fprintf (stderr, "state stack now");
504 while (ssp1 != yyssp)
505 fprintf (stderr, " %d", *++ssp1);
506 fprintf (stderr, "\n");
507 }
508#endif
509
510 *++yyvsp = yyval;
511
512#ifdef YYLSP_NEEDED
513 yylsp++;
514 if (yylen == 0)
515 {
516 yylsp->first_line = yylloc.first_line;
517 yylsp->first_column = yylloc.first_column;
518 yylsp->last_line = (yylsp-1)->last_line;
519 yylsp->last_column = (yylsp-1)->last_column;
520 yylsp->text = 0;
521 }
522 else
523 {
524 yylsp->last_line = (yylsp+yylen-1)->last_line;
525 yylsp->last_column = (yylsp+yylen-1)->last_column;
526 }
527#endif
528
529 /* Now "shift" the result of the reduction.
530 Determine what state that goes to,
531 based on the state we popped back to
532 and the rule number reduced by. */
533
534 yyn = yyr1[yyn];
535
536 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
537 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
538 yystate = yytable[yystate];
539 else
540 yystate = yydefgoto[yyn - YYNTBASE];
541
542 goto yynewstate;
543
544yyerrlab: /* here on detecting error */
545
546 if (! yyerrstatus)
547 /* If not already recovering from an error, report this error. */
548 {
549 ++yynerrs;
550
551#ifdef YYERROR_VERBOSE
552 yyn = yypact[yystate];
553
554 if (yyn > YYFLAG && yyn < YYLAST)
555 {
556 int size = 0;
557 char *msg;
558 int x, count;
559
560 count = 0;
561 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
562 for (x = (yyn < 0 ? -yyn : 0);
563 x < (sizeof(yytname) / sizeof(char *)); x++)
564 if (yycheck[x + yyn] == x)
565 size += strlen(yytname[x]) + 15, count++;
566 msg = (char *) malloc(size + 15);
567 if (msg != 0)
568 {
569 strcpy(msg, "parse error");
570
571 if (count < 5)
572 {
573 count = 0;
574 for (x = (yyn < 0 ? -yyn : 0);
575 x < (sizeof(yytname) / sizeof(char *)); x++)
576 if (yycheck[x + yyn] == x)
577 {
578 strcat(msg, count == 0 ? ", expecting `" : " or `");
579 strcat(msg, yytname[x]);
580 strcat(msg, "'");
581 count++;
582 }
583 }
584 yyerror(msg);
585 free(msg);
586 }
587 else
588 yyerror ("parse error; also virtual memory exceeded");
589 }
590 else
591#endif /* YYERROR_VERBOSE */
592 yyerror("parse error");
593 }
594
595 goto yyerrlab1;
596yyerrlab1: /* here on error raised explicitly by an action */
597
598 if (yyerrstatus == 3)
599 {
600 /* if just tried and failed to reuse lookahead token after an error, discard it. */
601
602 /* return failure if at end of input */
603 if (yychar == YYEOF)
604 YYABORT;
605
606#if YYDEBUG != 0
607 if (yydebug)
608 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
609#endif
610
611 yychar = YYEMPTY;
612 }
613
614 /* Else will try to reuse lookahead token
615 after shifting the error token. */
616
617 yyerrstatus = 3; /* Each real token shifted decrements this */
618
619 goto yyerrhandle;
620
621yyerrdefault: /* current state does not do anything special for the error token. */
622
623#if 0
624 /* This is wrong; only states that explicitly want error tokens
625 should shift them. */
626 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
627 if (yyn) goto yydefault;
628#endif
629
630yyerrpop: /* pop the current state because it cannot handle the error token */
631
632 if (yyssp == yyss) YYABORT;
633 yyvsp--;
634 yystate = *--yyssp;
635#ifdef YYLSP_NEEDED
636 yylsp--;
637#endif
638
639#if YYDEBUG != 0
640 if (yydebug)
641 {
642 short *ssp1 = yyss - 1;
643 fprintf (stderr, "Error: state stack now");
644 while (ssp1 != yyssp)
645 fprintf (stderr, " %d", *++ssp1);
646 fprintf (stderr, "\n");
647 }
648#endif
649
650yyerrhandle:
651
652 yyn = yypact[yystate];
653 if (yyn == YYFLAG)
654 goto yyerrdefault;
655
656 yyn += YYTERROR;
657 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
658 goto yyerrdefault;
659
660 yyn = yytable[yyn];
661 if (yyn < 0)
662 {
663 if (yyn == YYFLAG)
664 goto yyerrpop;
665 yyn = -yyn;
666 goto yyreduce;
667 }
668 else if (yyn == 0)
669 goto yyerrpop;
670
671 if (yyn == YYFINAL)
672 YYACCEPT;
673
674#if YYDEBUG != 0
675 if (yydebug)
676 fprintf(stderr, "Shifting error token, ");
677#endif
678
679 *++yyvsp = yylval;
680#ifdef YYLSP_NEEDED
681 *++yylsp = yylloc;
682#endif
683
684 yystate = yyn;
685 goto yynewstate;
686}