2 /* A Bison parser, made from schema.y
3 by GNU Bison version 1.25
6 #define YYBISON 1 /* Identify Bison output. */
8 #define yyparse SchemaParserparse
9 #define yylex SchemaParserlex
10 #define yyerror SchemaParsererror
11 #define yylval SchemaParserlval
12 #define yychar SchemaParserchar
13 #define yydebug SchemaParserdebug
14 #define yynerrs SchemaParsernerrs
18 #define RIGHTBRACE 261
28 /* Some addn'l includes, necessary but not included by the
34 /* prototypes for the parser callbacks.
37 #include "parse_schema.h"
39 /* Interface to schemalexer */
41 void yyerror(char *s);
43 extern int flex_schema_lineno, flex_schema_ch;
46 extern table_list *Schema;
55 field_entry_list *field_list_t;
56 table_def *table_def_t;
57 table_list *table_list_t;
74 #define YYTRANSLATE(x) ((unsigned)(x) <= 263 ? yytranslate[x] : 19)
76 static const char yytranslate[] = { 0,
77 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
78 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
79 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
80 2, 2, 2, 2, 2, 2, 2, 2, 2, 9,
81 10, 2, 2, 11, 2, 2, 2, 2, 2, 2,
82 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
83 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
84 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
85 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
86 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
87 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
88 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
89 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
90 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
91 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
92 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
93 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
94 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
95 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
96 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
97 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
98 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
99 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
100 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
101 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
102 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
107 static const short yyprhs[] = { 0,
108 0, 2, 4, 7, 14, 21, 23, 26, 32, 33,
112 static const short yyrhs[] = { 13,
113 0, 14, 0, 13, 14, 0, 7, 3, 17, 5,
114 15, 6, 0, 8, 3, 17, 5, 15, 6, 0,
115 16, 0, 15, 16, 0, 3, 3, 3, 17, 4,
116 0, 0, 9, 18, 10, 0, 3, 0, 18, 11,
123 static const short yyrline[] = { 0,
124 68, 70, 71, 74, 76, 80, 81, 84, 88, 90,
130 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
132 static const char * const yytname[] = { "$","error","$undefined.","NAME","SEMICOLON",
133 "LEFTBRACE","RIGHTBRACE","TABLE","STREAM","'('","')'","','","result","table_list",
134 "table_def","field_list","field","opt_param_commalist","param_commalist", NULL
138 static const short yyr1[] = { 0,
139 12, 13, 13, 14, 14, 15, 15, 16, 17, 17,
143 static const short yyr2[] = { 0,
144 1, 1, 2, 6, 6, 1, 2, 5, 0, 3,
148 static const short yydefact[] = { 0,
149 0, 0, 1, 2, 9, 9, 3, 0, 0, 0,
150 11, 0, 0, 0, 10, 0, 0, 0, 6, 0,
151 12, 0, 4, 7, 5, 9, 0, 8, 0, 0,
155 static const short yydefgoto[] = { 29,
159 static const short yypact[] = { 2,
160 0, 4, 2,-32768, 5, 5,-32768, 10, 11, 12,
161 -32768, 1, 15, 15,-32768, 16, 18, -2,-32768, -1,
162 -32768, 19,-32768,-32768,-32768, 5, 20,-32768, 23, 25,
166 static const short yypgoto[] = {-32768,
167 -32768, 24, 14, -12, -6,-32768
174 static const short yytable[] = { 10,
175 17, 17, 5, 23, 25, 24, 6, 24, 1, 2,
176 15, 16, 11, 8, 0, 13, 14, 17, 21, 27,
177 22, 26, 30, 28, 31, 0, 7, 20
180 static const short yycheck[] = { 6,
181 3, 3, 3, 6, 6, 18, 3, 20, 7, 8,
182 10, 11, 3, 9, -1, 5, 5, 3, 3, 26,
183 3, 3, 0, 4, 0, -1, 3, 14
185 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
186 #line 3 "bison.simple"
188 /* Skeleton output parser for bison,
189 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
191 This program is free software; you can redistribute it and/or modify
192 it under the terms of the GNU General Public License as published by
193 the Free Software Foundation; either version 2, or (at your option)
196 This program is distributed in the hope that it will be useful,
197 but WITHOUT ANY WARRANTY; without even the implied warranty of
198 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
199 GNU General Public License for more details.
201 You should have received a copy of the GNU General Public License
202 along with this program; if not, write to the Free Software
203 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
205 /* As a special exception, when this file is copied by Bison into a
206 Bison output file, you may use that output file without restriction.
207 This special exception was added by the Free Software Foundation
208 in version 1.24 of Bison. */
212 #define alloca __builtin_alloca
213 #else /* not GNU C. */
214 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
216 #else /* not sparc */
217 #if defined (MSDOS) && !defined (__TURBOC__)
219 #else /* not MSDOS, or __TURBOC__ */
223 #else /* not MSDOS, __TURBOC__, or _AIX */
227 void *alloca (unsigned int);
229 #else /* not __cplusplus */
231 #endif /* not __cplusplus */
233 #endif /* not _AIX */
234 #endif /* not MSDOS, or __TURBOC__ */
235 #endif /* not sparc. */
236 #endif /* not GNU C. */
237 #endif /* alloca not defined. */
239 /* This is the parser code that is written into each bison parser
240 when the %semantic_parser declaration is not specified in the grammar.
241 It was written by Richard Stallman by simplifying the hairy parser
242 used when %semantic_parser is specified. */
244 /* Note: there must be only one dollar sign in this file.
245 It is replaced by the list of actions, each action
246 as one case of the switch. */
248 #define yyerrok (yyerrstatus = 0)
249 #define yyclearin (yychar = YYEMPTY)
252 #define YYACCEPT return(0)
253 #define YYABORT return(1)
254 #define YYERROR goto yyerrlab1
255 /* Like YYERROR except do call yyerror.
256 This remains here temporarily to ease the
257 transition to the new meaning of YYERROR, for GCC.
258 Once GCC version 2 has supplanted version 1, this can go. */
259 #define YYFAIL goto yyerrlab
260 #define YYRECOVERING() (!!yyerrstatus)
261 #define YYBACKUP(token, value) \
263 if (yychar == YYEMPTY && yylen == 1) \
264 { yychar = (token), yylval = (value); \
265 yychar1 = YYTRANSLATE (yychar); \
270 { yyerror ("syntax error: cannot back up"); YYERROR; } \
274 #define YYERRCODE 256
277 #define YYLEX yylex()
283 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
285 #define YYLEX yylex(&yylval, &yylloc)
287 #else /* not YYLSP_NEEDED */
289 #define YYLEX yylex(&yylval, YYLEX_PARAM)
291 #define YYLEX yylex(&yylval)
293 #endif /* not YYLSP_NEEDED */
296 /* If nonreentrant, generate the variables here */
300 int yychar; /* the lookahead symbol */
301 YYSTYPE yylval; /* the semantic value of the */
302 /* lookahead symbol */
305 YYLTYPE yylloc; /* location data for the lookahead */
309 int yynerrs; /* number of parse errors so far */
310 #endif /* not YYPURE */
313 int yydebug; /* nonzero means print parse trace */
314 /* Since this is uninitialized, it does not stop multiple parsers
318 /* YYINITDEPTH indicates the initial size of the parser's stacks */
321 #define YYINITDEPTH 200
324 /* YYMAXDEPTH is the maximum size the stacks can grow to
325 (effective only if the built-in stack extension method is used). */
332 #define YYMAXDEPTH 10000
335 /* Prevent warning if -Wstrict-prototypes. */
340 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
341 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
342 #else /* not GNU C or C++ */
345 /* This is the most reliable way to avoid incompatibilities
346 in available built-in functions on various systems. */
348 __yy_memcpy (to, from, count)
353 register char *f = from;
354 register char *t = to;
355 register int i = count;
361 #else /* __cplusplus */
363 /* This is the most reliable way to avoid incompatibilities
364 in available built-in functions on various systems. */
366 __yy_memcpy (char *to, char *from, int count)
368 register char *f = from;
369 register char *t = to;
370 register int i = count;
379 #line 196 "bison.simple"
381 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
382 into yyparse. The argument should have type void *.
383 It should actually point to an object.
384 Grammar actions can access the variable by casting it
385 to the proper pointer type. */
389 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
390 #define YYPARSE_PARAM_DECL
391 #else /* not __cplusplus */
392 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
393 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
394 #endif /* not __cplusplus */
395 #else /* not YYPARSE_PARAM */
396 #define YYPARSE_PARAM_ARG
397 #define YYPARSE_PARAM_DECL
398 #endif /* not YYPARSE_PARAM */
401 yyparse(YYPARSE_PARAM_ARG)
404 register int yystate;
406 register short *yyssp;
407 register YYSTYPE *yyvsp;
408 int yyerrstatus; /* number of tokens to shift before error messages enabled */
409 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
411 short yyssa[YYINITDEPTH]; /* the state stack */
412 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
414 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
415 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
418 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
419 YYLTYPE *yyls = yylsa;
422 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
424 #define YYPOPSTACK (yyvsp--, yyssp--)
427 int yystacksize = YYINITDEPTH;
438 YYSTYPE yyval; /* the variable used to return */
439 /* semantic values from the action */
446 fprintf(stderr, "Starting parse\n");
452 yychar = YYEMPTY; /* Cause a token to be read. */
454 /* Initialize stack pointers.
455 Waste one element of value and location stack
456 so that they stay on the same level as the state stack.
457 The wasted elements are never initialized. */
465 /* Push a new state, which is found in yystate . */
466 /* In all cases, when you get here, the value and location stacks
467 have just been pushed. so pushing a state here evens the stacks. */
472 if (yyssp >= yyss + yystacksize - 1)
474 /* Give user a chance to reallocate the stack */
475 /* Use copies of these so that the &'s don't force the real ones into memory. */
476 YYSTYPE *yyvs1 = yyvs;
479 YYLTYPE *yyls1 = yyls;
482 /* Get the current used size of the three stacks, in elements. */
483 int size = yyssp - yyss + 1;
486 /* Each stack pointer address is followed by the size of
487 the data in use in that stack, in bytes. */
489 /* This used to be a conditional around just the two extra args,
490 but that might be undefined if yyoverflow is a macro. */
491 yyoverflow("parser stack overflow",
492 &yyss1, size * sizeof (*yyssp),
493 &yyvs1, size * sizeof (*yyvsp),
494 &yyls1, size * sizeof (*yylsp),
497 yyoverflow("parser stack overflow",
498 &yyss1, size * sizeof (*yyssp),
499 &yyvs1, size * sizeof (*yyvsp),
503 yyss = yyss1; yyvs = yyvs1;
507 #else /* no yyoverflow */
508 /* Extend the stack our own way. */
509 if (yystacksize >= YYMAXDEPTH)
511 yyerror("parser stack overflow");
515 if (yystacksize > YYMAXDEPTH)
516 yystacksize = YYMAXDEPTH;
517 yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
518 __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
519 yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
520 __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
522 yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
523 __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
525 #endif /* no yyoverflow */
527 yyssp = yyss + size - 1;
528 yyvsp = yyvs + size - 1;
530 yylsp = yyls + size - 1;
535 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
538 if (yyssp >= yyss + yystacksize - 1)
544 fprintf(stderr, "Entering state %d\n", yystate);
550 /* Do appropriate processing given the current state. */
551 /* Read a lookahead token if we need one and don't already have one. */
554 /* First try to decide what to do without reference to lookahead token. */
556 yyn = yypact[yystate];
560 /* Not known => get a lookahead token if don't already have one. */
562 /* yychar is either YYEMPTY or YYEOF
563 or a valid token in external form. */
565 if (yychar == YYEMPTY)
569 fprintf(stderr, "Reading a token: ");
574 /* Convert token to internal form (in yychar1) for indexing tables with */
576 if (yychar <= 0) /* This means end of input. */
579 yychar = YYEOF; /* Don't call YYLEX any more */
583 fprintf(stderr, "Now at end of input.\n");
588 yychar1 = YYTRANSLATE(yychar);
593 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
594 /* Give the individual parser a way to print the precise meaning
595 of a token, for further debugging info. */
597 YYPRINT (stderr, yychar, yylval);
599 fprintf (stderr, ")\n");
605 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
610 /* yyn is what to do for this token type in this state.
611 Negative => reduce, -yyn is rule number.
612 Positive => shift, yyn is new state.
613 New state is final state => don't bother to shift,
615 0, or most negative number => error. */
630 /* Shift the lookahead token. */
634 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
637 /* Discard the token being shifted unless it is eof. */
646 /* count tokens shifted since error; after three, turn off error status. */
647 if (yyerrstatus) yyerrstatus--;
652 /* Do the default action for the current state. */
655 yyn = yydefact[yystate];
659 /* Do a reduction. yyn is the number of a rule to reduce with. */
663 yyval = yyvsp[1-yylen]; /* implement default value of the action */
670 fprintf (stderr, "Reducing via rule %d (line %d), ",
673 /* Print the symbols being reduced, and their result. */
674 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
675 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
676 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
685 {Schema = yyvsp[0].table_list_t;;
689 {yyval.table_list_t = new table_list(yyvsp[0].table_def_t);;
693 {yyval.table_list_t = yyvsp[-1].table_list_t->append_table(yyvsp[0].table_def_t);;
698 yyval.table_def_t=new table_def(yyvsp[-4].strval,yyvsp[-3].plist_t,yyvsp[-1].field_list_t, TABLE_SCHEMA); delete yyvsp[-1].field_list_t;;
703 yyval.table_def_t=new table_def(yyvsp[-4].strval,yyvsp[-3].plist_t,yyvsp[-1].field_list_t, STREAM_SCHEMA); delete yyvsp[-1].field_list_t;;
707 {yyval.field_list_t = new field_entry_list(yyvsp[0].field_t);;
711 {yyval.field_list_t = yyvsp[-1].field_list_t->append_field(yyvsp[0].field_t);;
715 {yyval.field_t = new field_entry(yyvsp[-4].strval,yyvsp[-3].strval,yyvsp[-2].strval,yyvsp[-1].plist_t);;
719 {yyval.plist_t = NULL;;
723 {yyval.plist_t = yyvsp[-1].plist_t;;
727 {yyval.plist_t = new param_list(yyvsp[0].strval);;
731 {yyval.plist_t = yyvsp[-2].plist_t->append(yyvsp[0].strval);;
734 /* the action file gets copied in in place of this dollarsign */
735 #line 498 "bison.simple"
746 short *ssp1 = yyss - 1;
747 fprintf (stderr, "state stack now");
748 while (ssp1 != yyssp)
749 fprintf (stderr, " %d", *++ssp1);
750 fprintf (stderr, "\n");
760 yylsp->first_line = yylloc.first_line;
761 yylsp->first_column = yylloc.first_column;
762 yylsp->last_line = (yylsp-1)->last_line;
763 yylsp->last_column = (yylsp-1)->last_column;
768 yylsp->last_line = (yylsp+yylen-1)->last_line;
769 yylsp->last_column = (yylsp+yylen-1)->last_column;
773 /* Now "shift" the result of the reduction.
774 Determine what state that goes to,
775 based on the state we popped back to
776 and the rule number reduced by. */
780 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
781 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
782 yystate = yytable[yystate];
784 yystate = yydefgoto[yyn - YYNTBASE];
788 yyerrlab: /* here on detecting error */
791 /* If not already recovering from an error, report this error. */
795 #ifdef YYERROR_VERBOSE
796 yyn = yypact[yystate];
798 if (yyn > YYFLAG && yyn < YYLAST)
805 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
806 for (x = (yyn < 0 ? -yyn : 0);
807 x < (sizeof(yytname) / sizeof(char *)); x++)
808 if (yycheck[x + yyn] == x)
809 size += strlen(yytname[x]) + 15, count++;
810 msg = (char *) malloc(size + 15);
813 strcpy(msg, "parse error");
818 for (x = (yyn < 0 ? -yyn : 0);
819 x < (sizeof(yytname) / sizeof(char *)); x++)
820 if (yycheck[x + yyn] == x)
822 strcat(msg, count == 0 ? ", expecting `" : " or `");
823 strcat(msg, yytname[x]);
832 yyerror ("parse error; also virtual memory exceeded");
835 #endif /* YYERROR_VERBOSE */
836 yyerror("parse error");
840 yyerrlab1: /* here on error raised explicitly by an action */
842 if (yyerrstatus == 3)
844 /* if just tried and failed to reuse lookahead token after an error, discard it. */
846 /* return failure if at end of input */
852 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
858 /* Else will try to reuse lookahead token
859 after shifting the error token. */
861 yyerrstatus = 3; /* Each real token shifted decrements this */
865 yyerrdefault: /* current state does not do anything special for the error token. */
868 /* This is wrong; only states that explicitly want error tokens
869 should shift them. */
870 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
871 if (yyn) goto yydefault;
874 yyerrpop: /* pop the current state because it cannot handle the error token */
876 if (yyssp == yyss) YYABORT;
886 short *ssp1 = yyss - 1;
887 fprintf (stderr, "Error: state stack now");
888 while (ssp1 != yyssp)
889 fprintf (stderr, " %d", *++ssp1);
890 fprintf (stderr, "\n");
896 yyn = yypact[yystate];
901 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
920 fprintf(stderr, "Shifting error token, ");