1 /* A Bison parser, made by GNU Bison 2.3. */
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
23 /* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
39 /* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
46 /* Identify Bison output. */
50 #define YYBISON_VERSION "2.3"
53 #define YYSKELETON_NAME "yacc.c"
58 /* Using locations. */
59 #define YYLSP_NEEDED 0
66 /* Put the tokens into the symbol table, so that GDB and other debuggers
92 /* Copy the first part of user declarations. */
96 * Copyright (c) 1998 - 2000 Kungliga Tekniska Högskolan
97 * (Royal Institute of Technology, Stockholm, Sweden).
98 * All rights reserved.
100 * Redistribution and use in source and binary forms, with or without
101 * modification, are permitted provided that the following conditions
104 * 1. Redistributions of source code must retain the above copyright
105 * notice, this list of conditions and the following disclaimer.
107 * 2. Redistributions in binary form must reproduce the above copyright
108 * notice, this list of conditions and the following disclaimer in the
109 * documentation and/or other materials provided with the distribution.
111 * 3. Neither the name of the Institute nor the names of its contributors
112 * may be used to endorse or promote products derived from this software
113 * without specific prior written permission.
115 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
116 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
117 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
118 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
119 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
120 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
121 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
122 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
123 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
124 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
128 #include "compile_et.h"
131 RCSID("$Id: parse.y 15426 2005-06-16 19:21:42Z lha $");
133 void yyerror (char *s);
134 static long name2number(const char *str);
138 /* This is for bison */
140 #if !defined(alloca) && !defined(HAVE_ALLOCA)
141 #define alloca(x) malloc(x)
146 /* Enabling traces. */
151 /* Enabling verbose error messages. */
152 #ifdef YYERROR_VERBOSE
153 # undef YYERROR_VERBOSE
154 # define YYERROR_VERBOSE 1
156 # define YYERROR_VERBOSE 0
159 /* Enabling the token table. */
160 #ifndef YYTOKEN_TABLE
161 # define YYTOKEN_TABLE 0
164 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
165 typedef union YYSTYPE
171 /* Line 193 of yacc.c. */
174 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
175 # define YYSTYPE_IS_DECLARED 1
176 # define YYSTYPE_IS_TRIVIAL 1
181 /* Copy the second part of user declarations. */
184 /* Line 216 of yacc.c. */
192 typedef YYTYPE_UINT8 yytype_uint8;
194 typedef unsigned char yytype_uint8;
198 typedef YYTYPE_INT8 yytype_int8;
199 #elif (defined __STDC__ || defined __C99__FUNC__ \
200 || defined __cplusplus || defined _MSC_VER)
201 typedef signed char yytype_int8;
203 typedef short int yytype_int8;
207 typedef YYTYPE_UINT16 yytype_uint16;
209 typedef unsigned short int yytype_uint16;
213 typedef YYTYPE_INT16 yytype_int16;
215 typedef short int yytype_int16;
219 # ifdef __SIZE_TYPE__
220 # define YYSIZE_T __SIZE_TYPE__
221 # elif defined size_t
222 # define YYSIZE_T size_t
223 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
224 || defined __cplusplus || defined _MSC_VER)
225 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
226 # define YYSIZE_T size_t
228 # define YYSIZE_T unsigned int
232 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
235 # if defined YYENABLE_NLS && YYENABLE_NLS
237 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
238 # define YY_(msgid) dgettext ("bison-runtime", msgid)
242 # define YY_(msgid) msgid
246 /* Suppress unused-variable warnings by "using" E. */
247 #if ! defined lint || defined __GNUC__
248 # define YYUSE(e) ((void) (e))
250 # define YYUSE(e) /* empty */
253 /* Identity function, used to suppress warnings about constant conditions. */
257 #if (defined __STDC__ || defined __C99__FUNC__ \
258 || defined __cplusplus || defined _MSC_VER)
271 #if ! defined yyoverflow || YYERROR_VERBOSE
273 /* The parser invokes alloca or malloc; define the necessary symbols. */
275 # ifdef YYSTACK_USE_ALLOCA
276 # if YYSTACK_USE_ALLOCA
278 # define YYSTACK_ALLOC __builtin_alloca
279 # elif defined __BUILTIN_VA_ARG_INCR
280 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
282 # define YYSTACK_ALLOC __alloca
283 # elif defined _MSC_VER
284 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
285 # define alloca _alloca
287 # define YYSTACK_ALLOC alloca
288 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
289 || defined __cplusplus || defined _MSC_VER)
290 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
299 # ifdef YYSTACK_ALLOC
300 /* Pacify GCC's `empty if-body' warning. */
301 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
302 # ifndef YYSTACK_ALLOC_MAXIMUM
303 /* The OS might guarantee only one guard page at the bottom of the stack,
304 and a page size can be as small as 4096 bytes. So we cannot safely
305 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
306 to allow for a few compiler-allocated temporary stack slots. */
307 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
310 # define YYSTACK_ALLOC YYMALLOC
311 # define YYSTACK_FREE YYFREE
312 # ifndef YYSTACK_ALLOC_MAXIMUM
313 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
315 # if (defined __cplusplus && ! defined _STDLIB_H \
316 && ! ((defined YYMALLOC || defined malloc) \
317 && (defined YYFREE || defined free)))
318 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
324 # define YYMALLOC malloc
325 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
326 || defined __cplusplus || defined _MSC_VER)
327 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
332 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
333 || defined __cplusplus || defined _MSC_VER)
334 void free (void *); /* INFRINGES ON USER NAME SPACE */
338 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
341 #if (! defined yyoverflow \
342 && (! defined __cplusplus \
343 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
345 /* A type that is properly aligned for any stack member. */
352 /* The size of the maximum gap between one aligned stack and the next. */
353 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
355 /* The size of an array large to enough to hold all stacks, each with
357 # define YYSTACK_BYTES(N) \
358 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
359 + YYSTACK_GAP_MAXIMUM)
361 /* Copy COUNT objects from FROM to TO. The source and destination do
364 # if defined __GNUC__ && 1 < __GNUC__
365 # define YYCOPY(To, From, Count) \
366 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
368 # define YYCOPY(To, From, Count) \
372 for (yyi = 0; yyi < (Count); yyi++) \
373 (To)[yyi] = (From)[yyi]; \
379 /* Relocate STACK from its old location to the new one. The
380 local variables YYSIZE and YYSTACKSIZE give the old and new number of
381 elements in the stack, and YYPTR gives the new location of the
382 stack. Advance YYPTR to a properly aligned location for the next
384 # define YYSTACK_RELOCATE(Stack) \
387 YYSIZE_T yynewbytes; \
388 YYCOPY (&yyptr->Stack, Stack, yysize); \
389 Stack = &yyptr->Stack; \
390 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
391 yyptr += yynewbytes / sizeof (*yyptr); \
397 /* YYFINAL -- State number of the termination state. */
399 /* YYLAST -- Last index in YYTABLE. */
402 /* YYNTOKENS -- Number of terminals. */
404 /* YYNNTS -- Number of nonterminals. */
406 /* YYNRULES -- Number of rules. */
408 /* YYNRULES -- Number of states. */
411 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
413 #define YYMAXUTOK 265
415 #define YYTRANSLATE(YYX) \
416 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
418 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
419 static const yytype_uint8 yytranslate[] =
421 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
422 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
423 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
424 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
425 2, 2, 2, 2, 11, 2, 2, 2, 2, 2,
426 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
427 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
428 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
429 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
430 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
431 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
432 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
433 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
434 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
435 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
436 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
437 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
438 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
439 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
440 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
441 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
442 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
443 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
444 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
445 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
446 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
451 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
453 static const yytype_uint8 yyprhs[] =
455 0, 0, 3, 4, 7, 10, 12, 15, 18, 22,
456 24, 27, 30, 33, 35, 40
459 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
460 static const yytype_int8 yyrhs[] =
462 13, 0, -1, -1, 14, 17, -1, 15, 16, -1,
463 16, -1, 7, 9, -1, 3, 9, -1, 3, 9,
464 9, -1, 18, -1, 17, 18, -1, 4, 10, -1,
465 5, 9, -1, 5, -1, 6, 9, 11, 9, -1,
469 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
470 static const yytype_uint8 yyrline[] =
472 0, 64, 64, 65, 68, 69, 72, 78, 84, 93,
473 94, 97, 101, 109, 116, 136
477 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
478 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
479 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
480 static const char *const yytname[] =
482 "$end", "error", "$undefined", "ET", "INDEX", "PREFIX", "EC", "ID",
483 "END", "STRING", "NUMBER", "','", "$accept", "file", "header", "id",
484 "et", "statements", "statement", 0
489 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
491 static const yytype_uint16 yytoknum[] =
493 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
498 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
499 static const yytype_uint8 yyr1[] =
501 0, 12, 13, 13, 14, 14, 15, 16, 16, 17,
502 17, 18, 18, 18, 18, 18
505 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
506 static const yytype_uint8 yyr2[] =
508 0, 2, 0, 2, 2, 1, 2, 2, 3, 1,
512 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
513 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
514 means the default is an error. */
515 static const yytype_uint8 yydefact[] =
517 2, 0, 0, 0, 0, 0, 5, 7, 6, 1,
518 0, 13, 0, 15, 3, 9, 4, 8, 11, 12,
522 /* YYDEFGOTO[NTERM-NUM]. */
523 static const yytype_int8 yydefgoto[] =
525 -1, 3, 4, 5, 6, 14, 15
528 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
530 #define YYPACT_NINF -5
531 static const yytype_int8 yypact[] =
533 0, -3, -1, 5, -4, 6, -5, 1, -5, -5,
534 2, 4, 7, -5, -4, -5, -5, -5, -5, -5,
538 /* YYPGOTO[NTERM-NUM]. */
539 static const yytype_int8 yypgoto[] =
541 -5, -5, -5, -5, 10, -5, 9
544 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
545 positive, shift that token. If negative, reduce the rule which
546 number is the opposite. If zero, do what YYDEFACT says.
547 If YYTABLE_NINF, syntax error. */
548 #define YYTABLE_NINF -1
549 static const yytype_uint8 yytable[] =
551 10, 11, 12, 1, 13, 9, 7, 2, 8, 1,
552 17, 0, 18, 19, 22, 16, 20, 23, 0, 0,
556 static const yytype_int8 yycheck[] =
558 4, 5, 6, 3, 8, 0, 9, 7, 9, 3,
559 9, -1, 10, 9, 11, 5, 9, 9, -1, -1,
563 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
564 symbol of state STATE-NUM. */
565 static const yytype_uint8 yystos[] =
567 0, 3, 7, 13, 14, 15, 16, 9, 9, 0,
568 4, 5, 6, 8, 17, 18, 16, 9, 10, 9,
572 #define yyerrok (yyerrstatus = 0)
573 #define yyclearin (yychar = YYEMPTY)
577 #define YYACCEPT goto yyacceptlab
578 #define YYABORT goto yyabortlab
579 #define YYERROR goto yyerrorlab
582 /* Like YYERROR except do call yyerror. This remains here temporarily
583 to ease the transition to the new meaning of YYERROR, for GCC.
584 Once GCC version 2 has supplanted version 1, this can go. */
586 #define YYFAIL goto yyerrlab
588 #define YYRECOVERING() (!!yyerrstatus)
590 #define YYBACKUP(Token, Value) \
592 if (yychar == YYEMPTY && yylen == 1) \
596 yytoken = YYTRANSLATE (yychar); \
602 yyerror (YY_("syntax error: cannot back up")); \
609 #define YYERRCODE 256
612 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
613 If N is 0, then set CURRENT to the empty location which ends
614 the previous symbol: RHS[0] (always defined). */
616 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
617 #ifndef YYLLOC_DEFAULT
618 # define YYLLOC_DEFAULT(Current, Rhs, N) \
622 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
623 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
624 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
625 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
629 (Current).first_line = (Current).last_line = \
630 YYRHSLOC (Rhs, 0).last_line; \
631 (Current).first_column = (Current).last_column = \
632 YYRHSLOC (Rhs, 0).last_column; \
638 /* YY_LOCATION_PRINT -- Print the location on the stream.
639 This macro was not mandated originally: define only if we know
640 we won't break user code: when these are the locations we know. */
642 #ifndef YY_LOCATION_PRINT
643 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
644 # define YY_LOCATION_PRINT(File, Loc) \
645 fprintf (File, "%d.%d-%d.%d", \
646 (Loc).first_line, (Loc).first_column, \
647 (Loc).last_line, (Loc).last_column)
649 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
654 /* YYLEX -- calling `yylex' with the right arguments. */
657 # define YYLEX yylex (YYLEX_PARAM)
659 # define YYLEX yylex ()
662 /* Enable debugging if requested. */
666 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
667 # define YYFPRINTF fprintf
670 # define YYDPRINTF(Args) \
676 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
680 YYFPRINTF (stderr, "%s ", Title); \
681 yy_symbol_print (stderr, \
683 YYFPRINTF (stderr, "\n"); \
688 /*--------------------------------.
689 | Print this symbol on YYOUTPUT. |
690 `--------------------------------*/
693 #if (defined __STDC__ || defined __C99__FUNC__ \
694 || defined __cplusplus || defined _MSC_VER)
696 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
699 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
702 YYSTYPE const * const yyvaluep;
708 if (yytype < YYNTOKENS)
709 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
721 /*--------------------------------.
722 | Print this symbol on YYOUTPUT. |
723 `--------------------------------*/
725 #if (defined __STDC__ || defined __C99__FUNC__ \
726 || defined __cplusplus || defined _MSC_VER)
728 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
731 yy_symbol_print (yyoutput, yytype, yyvaluep)
734 YYSTYPE const * const yyvaluep;
737 if (yytype < YYNTOKENS)
738 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
740 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
742 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
743 YYFPRINTF (yyoutput, ")");
746 /*------------------------------------------------------------------.
747 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
749 `------------------------------------------------------------------*/
751 #if (defined __STDC__ || defined __C99__FUNC__ \
752 || defined __cplusplus || defined _MSC_VER)
754 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
757 yy_stack_print (bottom, top)
758 yytype_int16 *bottom;
762 YYFPRINTF (stderr, "Stack now");
763 for (; bottom <= top; ++bottom)
764 YYFPRINTF (stderr, " %d", *bottom);
765 YYFPRINTF (stderr, "\n");
768 # define YY_STACK_PRINT(Bottom, Top) \
771 yy_stack_print ((Bottom), (Top)); \
775 /*------------------------------------------------.
776 | Report that the YYRULE is going to be reduced. |
777 `------------------------------------------------*/
779 #if (defined __STDC__ || defined __C99__FUNC__ \
780 || defined __cplusplus || defined _MSC_VER)
782 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
785 yy_reduce_print (yyvsp, yyrule)
790 int yynrhs = yyr2[yyrule];
792 unsigned long int yylno = yyrline[yyrule];
793 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
795 /* The symbols being reduced. */
796 for (yyi = 0; yyi < yynrhs; yyi++)
798 fprintf (stderr, " $%d = ", yyi + 1);
799 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
800 &(yyvsp[(yyi + 1) - (yynrhs)])
802 fprintf (stderr, "\n");
806 # define YY_REDUCE_PRINT(Rule) \
809 yy_reduce_print (yyvsp, Rule); \
812 /* Nonzero means print parse trace. It is left uninitialized so that
813 multiple parsers can coexist. */
816 # define YYDPRINTF(Args)
817 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
818 # define YY_STACK_PRINT(Bottom, Top)
819 # define YY_REDUCE_PRINT(Rule)
820 #endif /* !YYDEBUG */
823 /* YYINITDEPTH -- initial size of the parser's stacks. */
825 # define YYINITDEPTH 200
828 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
829 if the built-in stack extension method is used).
831 Do not make this value too large; the results are undefined if
832 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
833 evaluated with infinite-precision integer arithmetic. */
836 # define YYMAXDEPTH 10000
844 # if defined __GLIBC__ && defined _STRING_H
845 # define yystrlen strlen
847 /* Return the length of YYSTR. */
848 #if (defined __STDC__ || defined __C99__FUNC__ \
849 || defined __cplusplus || defined _MSC_VER)
851 yystrlen (const char *yystr)
859 for (yylen = 0; yystr[yylen]; yylen++)
867 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
868 # define yystpcpy stpcpy
870 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
872 #if (defined __STDC__ || defined __C99__FUNC__ \
873 || defined __cplusplus || defined _MSC_VER)
875 yystpcpy (char *yydest, const char *yysrc)
878 yystpcpy (yydest, yysrc)
884 const char *yys = yysrc;
886 while ((*yyd++ = *yys++) != '\0')
895 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
896 quotes and backslashes, so that it's suitable for yyerror. The
897 heuristic is that double-quoting is unnecessary unless the string
898 contains an apostrophe, a comma, or backslash (other than
899 backslash-backslash). YYSTR is taken from yytname. If YYRES is
900 null, do not copy; instead, return the length of what the result
903 yytnamerr (char *yyres, const char *yystr)
908 char const *yyp = yystr;
915 goto do_not_strip_quotes;
919 goto do_not_strip_quotes;
932 do_not_strip_quotes: ;
936 return yystrlen (yystr);
938 return yystpcpy (yyres, yystr) - yyres;
942 /* Copy into YYRESULT an error message about the unexpected token
943 YYCHAR while in state YYSTATE. Return the number of bytes copied,
944 including the terminating null byte. If YYRESULT is null, do not
945 copy anything; just return the number of bytes that would be
946 copied. As a special case, return 0 if an ordinary "syntax error"
947 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
950 yysyntax_error (char *yyresult, int yystate, int yychar)
952 int yyn = yypact[yystate];
954 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
958 int yytype = YYTRANSLATE (yychar);
959 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
960 YYSIZE_T yysize = yysize0;
962 int yysize_overflow = 0;
963 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
964 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
968 /* This is so xgettext sees the translatable formats that are
969 constructed on the fly. */
970 YY_("syntax error, unexpected %s");
971 YY_("syntax error, unexpected %s, expecting %s");
972 YY_("syntax error, unexpected %s, expecting %s or %s");
973 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
974 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
978 static char const yyunexpected[] = "syntax error, unexpected %s";
979 static char const yyexpecting[] = ", expecting %s";
980 static char const yyor[] = " or %s";
981 char yyformat[sizeof yyunexpected
982 + sizeof yyexpecting - 1
983 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
984 * (sizeof yyor - 1))];
985 char const *yyprefix = yyexpecting;
987 /* Start YYX at -YYN if negative to avoid negative indexes in
989 int yyxbegin = yyn < 0 ? -yyn : 0;
991 /* Stay within bounds of both yycheck and yytname. */
992 int yychecklim = YYLAST - yyn + 1;
993 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
996 yyarg[0] = yytname[yytype];
997 yyfmt = yystpcpy (yyformat, yyunexpected);
999 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1000 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1002 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1006 yyformat[sizeof yyunexpected - 1] = '\0';
1009 yyarg[yycount++] = yytname[yyx];
1010 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1011 yysize_overflow |= (yysize1 < yysize);
1013 yyfmt = yystpcpy (yyfmt, yyprefix);
1017 yyf = YY_(yyformat);
1018 yysize1 = yysize + yystrlen (yyf);
1019 yysize_overflow |= (yysize1 < yysize);
1022 if (yysize_overflow)
1023 return YYSIZE_MAXIMUM;
1027 /* Avoid sprintf, as that infringes on the user's name space.
1028 Don't have undefined behavior even if the translation
1029 produced a string with the wrong number of "%s"s. */
1030 char *yyp = yyresult;
1032 while ((*yyp = *yyf) != '\0')
1034 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1036 yyp += yytnamerr (yyp, yyarg[yyi++]);
1049 #endif /* YYERROR_VERBOSE */
1052 /*-----------------------------------------------.
1053 | Release the memory associated to this symbol. |
1054 `-----------------------------------------------*/
1057 #if (defined __STDC__ || defined __C99__FUNC__ \
1058 || defined __cplusplus || defined _MSC_VER)
1060 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1063 yydestruct (yymsg, yytype, yyvaluep)
1073 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1084 /* Prevent warnings from -Wmissing-prototypes. */
1086 #ifdef YYPARSE_PARAM
1087 #if defined __STDC__ || defined __cplusplus
1088 int yyparse (void *YYPARSE_PARAM);
1092 #else /* ! YYPARSE_PARAM */
1093 #if defined __STDC__ || defined __cplusplus
1098 #endif /* ! YYPARSE_PARAM */
1102 /* The look-ahead symbol. */
1105 /* The semantic value of the look-ahead symbol. */
1108 /* Number of syntax errors so far. */
1117 #ifdef YYPARSE_PARAM
1118 #if (defined __STDC__ || defined __C99__FUNC__ \
1119 || defined __cplusplus || defined _MSC_VER)
1121 yyparse (void *YYPARSE_PARAM)
1124 yyparse (YYPARSE_PARAM)
1125 void *YYPARSE_PARAM;
1127 #else /* ! YYPARSE_PARAM */
1128 #if (defined __STDC__ || defined __C99__FUNC__ \
1129 || defined __cplusplus || defined _MSC_VER)
1143 /* Number of tokens to shift before error messages enabled. */
1145 /* Look-ahead token as an internal (translated) token number. */
1148 /* Buffer for error messages, and its allocated size. */
1150 char *yymsg = yymsgbuf;
1151 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1154 /* Three stacks and their tools:
1155 `yyss': related to states,
1156 `yyvs': related to semantic values,
1157 `yyls': related to locations.
1159 Refer to the stacks thru separate pointers, to allow yyoverflow
1160 to reallocate them elsewhere. */
1162 /* The state stack. */
1163 yytype_int16 yyssa[YYINITDEPTH];
1164 yytype_int16 *yyss = yyssa;
1165 yytype_int16 *yyssp;
1167 /* The semantic value stack. */
1168 YYSTYPE yyvsa[YYINITDEPTH];
1169 YYSTYPE *yyvs = yyvsa;
1174 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1176 YYSIZE_T yystacksize = YYINITDEPTH;
1178 /* The variables used to return semantic value and location from the
1183 /* The number of symbols on the RHS of the reduced rule.
1184 Keep to zero when no symbol should be popped. */
1187 YYDPRINTF ((stderr, "Starting parse\n"));
1192 yychar = YYEMPTY; /* Cause a token to be read. */
1194 /* Initialize stack pointers.
1195 Waste one element of value and location stack
1196 so that they stay on the same level as the state stack.
1197 The wasted elements are never initialized. */
1204 /*------------------------------------------------------------.
1205 | yynewstate -- Push a new state, which is found in yystate. |
1206 `------------------------------------------------------------*/
1208 /* In all cases, when you get here, the value and location stacks
1209 have just been pushed. So pushing a state here evens the stacks. */
1215 if (yyss + yystacksize - 1 <= yyssp)
1217 /* Get the current used size of the three stacks, in elements. */
1218 YYSIZE_T yysize = yyssp - yyss + 1;
1222 /* Give user a chance to reallocate the stack. Use copies of
1223 these so that the &'s don't force the real ones into
1225 YYSTYPE *yyvs1 = yyvs;
1226 yytype_int16 *yyss1 = yyss;
1229 /* Each stack pointer address is followed by the size of the
1230 data in use in that stack, in bytes. This used to be a
1231 conditional around just the two extra args, but that might
1232 be undefined if yyoverflow is a macro. */
1233 yyoverflow (YY_("memory exhausted"),
1234 &yyss1, yysize * sizeof (*yyssp),
1235 &yyvs1, yysize * sizeof (*yyvsp),
1242 #else /* no yyoverflow */
1243 # ifndef YYSTACK_RELOCATE
1244 goto yyexhaustedlab;
1246 /* Extend the stack our own way. */
1247 if (YYMAXDEPTH <= yystacksize)
1248 goto yyexhaustedlab;
1250 if (YYMAXDEPTH < yystacksize)
1251 yystacksize = YYMAXDEPTH;
1254 yytype_int16 *yyss1 = yyss;
1255 union yyalloc *yyptr =
1256 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1258 goto yyexhaustedlab;
1259 YYSTACK_RELOCATE (yyss);
1260 YYSTACK_RELOCATE (yyvs);
1262 # undef YYSTACK_RELOCATE
1264 YYSTACK_FREE (yyss1);
1267 #endif /* no yyoverflow */
1269 yyssp = yyss + yysize - 1;
1270 yyvsp = yyvs + yysize - 1;
1273 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1274 (unsigned long int) yystacksize));
1276 if (yyss + yystacksize - 1 <= yyssp)
1280 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1289 /* Do appropriate processing given the current state. Read a
1290 look-ahead token if we need one and don't already have one. */
1292 /* First try to decide what to do without reference to look-ahead token. */
1293 yyn = yypact[yystate];
1294 if (yyn == YYPACT_NINF)
1297 /* Not known => get a look-ahead token if don't already have one. */
1299 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1300 if (yychar == YYEMPTY)
1302 YYDPRINTF ((stderr, "Reading a token: "));
1306 if (yychar <= YYEOF)
1308 yychar = yytoken = YYEOF;
1309 YYDPRINTF ((stderr, "Now at end of input.\n"));
1313 yytoken = YYTRANSLATE (yychar);
1314 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1317 /* If the proper action on seeing token YYTOKEN is to reduce or to
1318 detect an error, take that action. */
1320 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1325 if (yyn == 0 || yyn == YYTABLE_NINF)
1334 /* Count tokens shifted since error; after three, turn off error
1339 /* Shift the look-ahead token. */
1340 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1342 /* Discard the shifted token unless it is eof. */
1343 if (yychar != YYEOF)
1352 /*-----------------------------------------------------------.
1353 | yydefault -- do the default action for the current state. |
1354 `-----------------------------------------------------------*/
1356 yyn = yydefact[yystate];
1362 /*-----------------------------.
1363 | yyreduce -- Do a reduction. |
1364 `-----------------------------*/
1366 /* yyn is the number of a rule to reduce with. */
1369 /* If YYLEN is nonzero, implement the default value of the action:
1372 Otherwise, the following line sets YYVAL to garbage.
1373 This behavior is undocumented and Bison
1374 users should not rely upon it. Assigning to YYVAL
1375 unconditionally makes the parser a bit smaller, and it avoids a
1376 GCC warning that YYVAL may be used uninitialized. */
1377 yyval = yyvsp[1-yylen];
1380 YY_REDUCE_PRINT (yyn);
1386 id_str = (yyvsp[(2) - (2)].string);
1393 base_id = name2number((yyvsp[(2) - (2)].string));
1394 strlcpy(name, (yyvsp[(2) - (2)].string), sizeof(name));
1395 free((yyvsp[(2) - (2)].string));
1402 base_id = name2number((yyvsp[(2) - (3)].string));
1403 strlcpy(name, (yyvsp[(3) - (3)].string), sizeof(name));
1404 free((yyvsp[(2) - (3)].string));
1405 free((yyvsp[(3) - (3)].string));
1412 number = (yyvsp[(2) - (2)].number);
1420 asprintf (&prefix, "%s_", (yyvsp[(2) - (2)].string));
1423 free((yyvsp[(2) - (2)].string));
1430 prefix = realloc(prefix, 1);
1440 struct error_code *ec = malloc(sizeof(*ec));
1446 ec->number = number;
1447 if(prefix && *prefix != '\0') {
1448 asprintf (&ec->name, "%s%s", prefix, (yyvsp[(2) - (4)].string));
1449 if (ec->name == NULL)
1451 free((yyvsp[(2) - (4)].string));
1453 ec->name = (yyvsp[(2) - (4)].string);
1454 ec->string = (yyvsp[(4) - (4)].string);
1468 /* Line 1267 of yacc.c. */
1469 #line 1470 "parse.c"
1472 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1476 YY_STACK_PRINT (yyss, yyssp);
1481 /* Now `shift' the result of the reduction. Determine what state
1482 that goes to, based on the state we popped back to and the rule
1483 number reduced by. */
1487 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1488 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1489 yystate = yytable[yystate];
1491 yystate = yydefgoto[yyn - YYNTOKENS];
1496 /*------------------------------------.
1497 | yyerrlab -- here on detecting error |
1498 `------------------------------------*/
1500 /* If not already recovering from an error, report this error. */
1504 #if ! YYERROR_VERBOSE
1505 yyerror (YY_("syntax error"));
1508 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1509 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1511 YYSIZE_T yyalloc = 2 * yysize;
1512 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1513 yyalloc = YYSTACK_ALLOC_MAXIMUM;
1514 if (yymsg != yymsgbuf)
1515 YYSTACK_FREE (yymsg);
1516 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1518 yymsg_alloc = yyalloc;
1522 yymsg_alloc = sizeof yymsgbuf;
1526 if (0 < yysize && yysize <= yymsg_alloc)
1528 (void) yysyntax_error (yymsg, yystate, yychar);
1533 yyerror (YY_("syntax error"));
1535 goto yyexhaustedlab;
1543 if (yyerrstatus == 3)
1545 /* If just tried and failed to reuse look-ahead token after an
1546 error, discard it. */
1548 if (yychar <= YYEOF)
1550 /* Return failure if at end of input. */
1551 if (yychar == YYEOF)
1556 yydestruct ("Error: discarding",
1562 /* Else will try to reuse look-ahead token after shifting the error
1567 /*---------------------------------------------------.
1568 | yyerrorlab -- error raised explicitly by YYERROR. |
1569 `---------------------------------------------------*/
1572 /* Pacify compilers like GCC when the user code never invokes
1573 YYERROR and the label yyerrorlab therefore never appears in user
1575 if (/*CONSTCOND*/ 0)
1578 /* Do not reclaim the symbols of the rule which action triggered
1582 YY_STACK_PRINT (yyss, yyssp);
1587 /*-------------------------------------------------------------.
1588 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1589 `-------------------------------------------------------------*/
1591 yyerrstatus = 3; /* Each real token shifted decrements this. */
1595 yyn = yypact[yystate];
1596 if (yyn != YYPACT_NINF)
1599 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1607 /* Pop the current state because it cannot handle the error token. */
1612 yydestruct ("Error: popping",
1613 yystos[yystate], yyvsp);
1616 YY_STACK_PRINT (yyss, yyssp);
1625 /* Shift the error token. */
1626 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1632 /*-------------------------------------.
1633 | yyacceptlab -- YYACCEPT comes here. |
1634 `-------------------------------------*/
1639 /*-----------------------------------.
1640 | yyabortlab -- YYABORT comes here. |
1641 `-----------------------------------*/
1647 /*-------------------------------------------------.
1648 | yyexhaustedlab -- memory exhaustion comes here. |
1649 `-------------------------------------------------*/
1651 yyerror (YY_("memory exhausted"));
1657 if (yychar != YYEOF && yychar != YYEMPTY)
1658 yydestruct ("Cleanup: discarding lookahead",
1660 /* Do not reclaim the symbols of the rule which action triggered
1661 this YYABORT or YYACCEPT. */
1663 YY_STACK_PRINT (yyss, yyssp);
1664 while (yyssp != yyss)
1666 yydestruct ("Cleanup: popping",
1667 yystos[*yyssp], yyvsp);
1672 YYSTACK_FREE (yyss);
1675 if (yymsg != yymsgbuf)
1676 YYSTACK_FREE (yymsg);
1678 /* Make sure YYID is used. */
1679 return YYID (yyresult);
1687 name2number(const char *str)
1691 const char *x = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
1692 "abcdefghijklmnopqrstuvwxyz0123456789_";
1693 if(strlen(str) > 4) {
1694 yyerror("table name too long");
1697 for(p = str; *p; p++){
1698 char *q = strchr(x, *p);
1700 yyerror("invalid character in table name");
1703 num = (num << 6) + (q - x) + 1;
1706 if(num > 0x7fffffff)
1707 num = -(0xffffffff - num + 1);
1714 error_message ("%s\n", s);