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 void yyerror (char *s);
132 static long name2number(const char *str);
136 /* This is for bison */
138 #if !defined(alloca) && !defined(HAVE_ALLOCA)
139 #define alloca(x) malloc(x)
142 #define YYMALLOC malloc
147 /* Enabling traces. */
152 /* Enabling verbose error messages. */
153 #ifdef YYERROR_VERBOSE
154 # undef YYERROR_VERBOSE
155 # define YYERROR_VERBOSE 1
157 # define YYERROR_VERBOSE 0
160 /* Enabling the token table. */
161 #ifndef YYTOKEN_TABLE
162 # define YYTOKEN_TABLE 0
165 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
166 typedef union YYSTYPE
172 /* Line 193 of yacc.c. */
175 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
176 # define YYSTYPE_IS_DECLARED 1
177 # define YYSTYPE_IS_TRIVIAL 1
182 /* Copy the second part of user declarations. */
185 /* Line 216 of yacc.c. */
193 typedef YYTYPE_UINT8 yytype_uint8;
195 typedef unsigned char yytype_uint8;
199 typedef YYTYPE_INT8 yytype_int8;
200 #elif (defined __STDC__ || defined __C99__FUNC__ \
201 || defined __cplusplus || defined _MSC_VER)
202 typedef signed char yytype_int8;
204 typedef short int yytype_int8;
208 typedef YYTYPE_UINT16 yytype_uint16;
210 typedef unsigned short int yytype_uint16;
214 typedef YYTYPE_INT16 yytype_int16;
216 typedef short int yytype_int16;
220 # ifdef __SIZE_TYPE__
221 # define YYSIZE_T __SIZE_TYPE__
222 # elif defined size_t
223 # define YYSIZE_T size_t
224 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
225 || defined __cplusplus || defined _MSC_VER)
226 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
227 # define YYSIZE_T size_t
229 # define YYSIZE_T unsigned int
233 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
236 # if defined YYENABLE_NLS && YYENABLE_NLS
238 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
239 # define YY_(msgid) dgettext ("bison-runtime", msgid)
243 # define YY_(msgid) msgid
247 /* Suppress unused-variable warnings by "using" E. */
248 #if ! defined lint || defined __GNUC__
249 # define YYUSE(e) ((void) (e))
251 # define YYUSE(e) /* empty */
254 /* Identity function, used to suppress warnings about constant conditions. */
258 #if (defined __STDC__ || defined __C99__FUNC__ \
259 || defined __cplusplus || defined _MSC_VER)
272 #if ! defined yyoverflow || YYERROR_VERBOSE
274 /* The parser invokes alloca or malloc; define the necessary symbols. */
276 # ifdef YYSTACK_USE_ALLOCA
277 # if YYSTACK_USE_ALLOCA
279 # define YYSTACK_ALLOC __builtin_alloca
280 # elif defined __BUILTIN_VA_ARG_INCR
281 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
283 # define YYSTACK_ALLOC __alloca
284 # elif defined _MSC_VER
285 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
286 # define alloca _alloca
288 # define YYSTACK_ALLOC alloca
289 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
290 || defined __cplusplus || defined _MSC_VER)
291 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
300 # ifdef YYSTACK_ALLOC
301 /* Pacify GCC's `empty if-body' warning. */
302 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
303 # ifndef YYSTACK_ALLOC_MAXIMUM
304 /* The OS might guarantee only one guard page at the bottom of the stack,
305 and a page size can be as small as 4096 bytes. So we cannot safely
306 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
307 to allow for a few compiler-allocated temporary stack slots. */
308 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
311 # define YYSTACK_ALLOC YYMALLOC
312 # define YYSTACK_FREE YYFREE
313 # ifndef YYSTACK_ALLOC_MAXIMUM
314 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
316 # if (defined __cplusplus && ! defined _STDLIB_H \
317 && ! ((defined YYMALLOC || defined malloc) \
318 && (defined YYFREE || defined free)))
319 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
325 # define YYMALLOC malloc
326 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
327 || defined __cplusplus || defined _MSC_VER)
328 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
333 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
334 || defined __cplusplus || defined _MSC_VER)
335 void free (void *); /* INFRINGES ON USER NAME SPACE */
339 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
342 #if (! defined yyoverflow \
343 && (! defined __cplusplus \
344 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
346 /* A type that is properly aligned for any stack member. */
353 /* The size of the maximum gap between one aligned stack and the next. */
354 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
356 /* The size of an array large to enough to hold all stacks, each with
358 # define YYSTACK_BYTES(N) \
359 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
360 + YYSTACK_GAP_MAXIMUM)
362 /* Copy COUNT objects from FROM to TO. The source and destination do
365 # if defined __GNUC__ && 1 < __GNUC__
366 # define YYCOPY(To, From, Count) \
367 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
369 # define YYCOPY(To, From, Count) \
373 for (yyi = 0; yyi < (Count); yyi++) \
374 (To)[yyi] = (From)[yyi]; \
380 /* Relocate STACK from its old location to the new one. The
381 local variables YYSIZE and YYSTACKSIZE give the old and new number of
382 elements in the stack, and YYPTR gives the new location of the
383 stack. Advance YYPTR to a properly aligned location for the next
385 # define YYSTACK_RELOCATE(Stack) \
388 YYSIZE_T yynewbytes; \
389 YYCOPY (&yyptr->Stack, Stack, yysize); \
390 Stack = &yyptr->Stack; \
391 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
392 yyptr += yynewbytes / sizeof (*yyptr); \
398 /* YYFINAL -- State number of the termination state. */
400 /* YYLAST -- Last index in YYTABLE. */
403 /* YYNTOKENS -- Number of terminals. */
405 /* YYNNTS -- Number of nonterminals. */
407 /* YYNRULES -- Number of rules. */
409 /* YYNRULES -- Number of states. */
412 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
414 #define YYMAXUTOK 265
416 #define YYTRANSLATE(YYX) \
417 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
419 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
420 static const yytype_uint8 yytranslate[] =
422 0, 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, 2, 2, 2, 2, 2, 2,
426 2, 2, 2, 2, 11, 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, 2, 2, 2, 2,
447 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
452 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
454 static const yytype_uint8 yyprhs[] =
456 0, 0, 3, 4, 7, 10, 12, 15, 18, 22,
457 24, 27, 30, 33, 35, 40
460 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
461 static const yytype_int8 yyrhs[] =
463 13, 0, -1, -1, 14, 17, -1, 15, 16, -1,
464 16, -1, 7, 9, -1, 3, 9, -1, 3, 9,
465 9, -1, 18, -1, 17, 18, -1, 4, 10, -1,
466 5, 9, -1, 5, -1, 6, 9, 11, 9, -1,
470 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
471 static const yytype_uint8 yyrline[] =
473 0, 65, 65, 66, 69, 70, 73, 79, 85, 94,
474 95, 98, 102, 110, 117, 137
478 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
479 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
480 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
481 static const char *const yytname[] =
483 "$end", "error", "$undefined", "ET", "INDEX", "PREFIX", "EC", "ID",
484 "END", "STRING", "NUMBER", "','", "$accept", "file", "header", "id",
485 "et", "statements", "statement", 0
490 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
492 static const yytype_uint16 yytoknum[] =
494 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
499 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
500 static const yytype_uint8 yyr1[] =
502 0, 12, 13, 13, 14, 14, 15, 16, 16, 17,
503 17, 18, 18, 18, 18, 18
506 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
507 static const yytype_uint8 yyr2[] =
509 0, 2, 0, 2, 2, 1, 2, 2, 3, 1,
513 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
514 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
515 means the default is an error. */
516 static const yytype_uint8 yydefact[] =
518 2, 0, 0, 0, 0, 0, 5, 7, 6, 1,
519 0, 13, 0, 15, 3, 9, 4, 8, 11, 12,
523 /* YYDEFGOTO[NTERM-NUM]. */
524 static const yytype_int8 yydefgoto[] =
526 -1, 3, 4, 5, 6, 14, 15
529 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
531 #define YYPACT_NINF -5
532 static const yytype_int8 yypact[] =
534 0, -3, -1, 5, -4, 6, -5, 1, -5, -5,
535 2, 4, 7, -5, -4, -5, -5, -5, -5, -5,
539 /* YYPGOTO[NTERM-NUM]. */
540 static const yytype_int8 yypgoto[] =
542 -5, -5, -5, -5, 10, -5, 9
545 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
546 positive, shift that token. If negative, reduce the rule which
547 number is the opposite. If zero, do what YYDEFACT says.
548 If YYTABLE_NINF, syntax error. */
549 #define YYTABLE_NINF -1
550 static const yytype_uint8 yytable[] =
552 10, 11, 12, 1, 13, 9, 7, 2, 8, 1,
553 17, 0, 18, 19, 22, 16, 20, 23, 0, 0,
557 static const yytype_int8 yycheck[] =
559 4, 5, 6, 3, 8, 0, 9, 7, 9, 3,
560 9, -1, 10, 9, 11, 5, 9, 9, -1, -1,
564 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
565 symbol of state STATE-NUM. */
566 static const yytype_uint8 yystos[] =
568 0, 3, 7, 13, 14, 15, 16, 9, 9, 0,
569 4, 5, 6, 8, 17, 18, 16, 9, 10, 9,
573 #define yyerrok (yyerrstatus = 0)
574 #define yyclearin (yychar = YYEMPTY)
578 #define YYACCEPT goto yyacceptlab
579 #define YYABORT goto yyabortlab
580 #define YYERROR goto yyerrorlab
583 /* Like YYERROR except do call yyerror. This remains here temporarily
584 to ease the transition to the new meaning of YYERROR, for GCC.
585 Once GCC version 2 has supplanted version 1, this can go. */
587 #define YYFAIL goto yyerrlab
589 #define YYRECOVERING() (!!yyerrstatus)
591 #define YYBACKUP(Token, Value) \
593 if (yychar == YYEMPTY && yylen == 1) \
597 yytoken = YYTRANSLATE (yychar); \
603 yyerror (YY_("syntax error: cannot back up")); \
610 #define YYERRCODE 256
613 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
614 If N is 0, then set CURRENT to the empty location which ends
615 the previous symbol: RHS[0] (always defined). */
617 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
618 #ifndef YYLLOC_DEFAULT
619 # define YYLLOC_DEFAULT(Current, Rhs, N) \
623 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
624 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
625 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
626 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
630 (Current).first_line = (Current).last_line = \
631 YYRHSLOC (Rhs, 0).last_line; \
632 (Current).first_column = (Current).last_column = \
633 YYRHSLOC (Rhs, 0).last_column; \
639 /* YY_LOCATION_PRINT -- Print the location on the stream.
640 This macro was not mandated originally: define only if we know
641 we won't break user code: when these are the locations we know. */
643 #ifndef YY_LOCATION_PRINT
644 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
645 # define YY_LOCATION_PRINT(File, Loc) \
646 fprintf (File, "%d.%d-%d.%d", \
647 (Loc).first_line, (Loc).first_column, \
648 (Loc).last_line, (Loc).last_column)
650 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
655 /* YYLEX -- calling `yylex' with the right arguments. */
658 # define YYLEX yylex (YYLEX_PARAM)
660 # define YYLEX yylex ()
663 /* Enable debugging if requested. */
667 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
668 # define YYFPRINTF fprintf
671 # define YYDPRINTF(Args) \
677 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
681 YYFPRINTF (stderr, "%s ", Title); \
682 yy_symbol_print (stderr, \
684 YYFPRINTF (stderr, "\n"); \
689 /*--------------------------------.
690 | Print this symbol on YYOUTPUT. |
691 `--------------------------------*/
694 #if (defined __STDC__ || defined __C99__FUNC__ \
695 || defined __cplusplus || defined _MSC_VER)
697 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
700 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
703 YYSTYPE const * const yyvaluep;
709 if (yytype < YYNTOKENS)
710 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
722 /*--------------------------------.
723 | Print this symbol on YYOUTPUT. |
724 `--------------------------------*/
726 #if (defined __STDC__ || defined __C99__FUNC__ \
727 || defined __cplusplus || defined _MSC_VER)
729 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
732 yy_symbol_print (yyoutput, yytype, yyvaluep)
735 YYSTYPE const * const yyvaluep;
738 if (yytype < YYNTOKENS)
739 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
741 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
743 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
744 YYFPRINTF (yyoutput, ")");
747 /*------------------------------------------------------------------.
748 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
750 `------------------------------------------------------------------*/
752 #if (defined __STDC__ || defined __C99__FUNC__ \
753 || defined __cplusplus || defined _MSC_VER)
755 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
758 yy_stack_print (bottom, top)
759 yytype_int16 *bottom;
763 YYFPRINTF (stderr, "Stack now");
764 for (; bottom <= top; ++bottom)
765 YYFPRINTF (stderr, " %d", *bottom);
766 YYFPRINTF (stderr, "\n");
769 # define YY_STACK_PRINT(Bottom, Top) \
772 yy_stack_print ((Bottom), (Top)); \
776 /*------------------------------------------------.
777 | Report that the YYRULE is going to be reduced. |
778 `------------------------------------------------*/
780 #if (defined __STDC__ || defined __C99__FUNC__ \
781 || defined __cplusplus || defined _MSC_VER)
783 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
786 yy_reduce_print (yyvsp, yyrule)
791 int yynrhs = yyr2[yyrule];
793 unsigned long int yylno = yyrline[yyrule];
794 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
796 /* The symbols being reduced. */
797 for (yyi = 0; yyi < yynrhs; yyi++)
799 fprintf (stderr, " $%d = ", yyi + 1);
800 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
801 &(yyvsp[(yyi + 1) - (yynrhs)])
803 fprintf (stderr, "\n");
807 # define YY_REDUCE_PRINT(Rule) \
810 yy_reduce_print (yyvsp, Rule); \
813 /* Nonzero means print parse trace. It is left uninitialized so that
814 multiple parsers can coexist. */
817 # define YYDPRINTF(Args)
818 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
819 # define YY_STACK_PRINT(Bottom, Top)
820 # define YY_REDUCE_PRINT(Rule)
821 #endif /* !YYDEBUG */
824 /* YYINITDEPTH -- initial size of the parser's stacks. */
826 # define YYINITDEPTH 200
829 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
830 if the built-in stack extension method is used).
832 Do not make this value too large; the results are undefined if
833 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
834 evaluated with infinite-precision integer arithmetic. */
837 # define YYMAXDEPTH 10000
845 # if defined __GLIBC__ && defined _STRING_H
846 # define yystrlen strlen
848 /* Return the length of YYSTR. */
849 #if (defined __STDC__ || defined __C99__FUNC__ \
850 || defined __cplusplus || defined _MSC_VER)
852 yystrlen (const char *yystr)
860 for (yylen = 0; yystr[yylen]; yylen++)
868 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
869 # define yystpcpy stpcpy
871 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
873 #if (defined __STDC__ || defined __C99__FUNC__ \
874 || defined __cplusplus || defined _MSC_VER)
876 yystpcpy (char *yydest, const char *yysrc)
879 yystpcpy (yydest, yysrc)
885 const char *yys = yysrc;
887 while ((*yyd++ = *yys++) != '\0')
896 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
897 quotes and backslashes, so that it's suitable for yyerror. The
898 heuristic is that double-quoting is unnecessary unless the string
899 contains an apostrophe, a comma, or backslash (other than
900 backslash-backslash). YYSTR is taken from yytname. If YYRES is
901 null, do not copy; instead, return the length of what the result
904 yytnamerr (char *yyres, const char *yystr)
909 char const *yyp = yystr;
916 goto do_not_strip_quotes;
920 goto do_not_strip_quotes;
933 do_not_strip_quotes: ;
937 return yystrlen (yystr);
939 return yystpcpy (yyres, yystr) - yyres;
943 /* Copy into YYRESULT an error message about the unexpected token
944 YYCHAR while in state YYSTATE. Return the number of bytes copied,
945 including the terminating null byte. If YYRESULT is null, do not
946 copy anything; just return the number of bytes that would be
947 copied. As a special case, return 0 if an ordinary "syntax error"
948 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
951 yysyntax_error (char *yyresult, int yystate, int yychar)
953 int yyn = yypact[yystate];
955 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
959 int yytype = YYTRANSLATE (yychar);
960 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
961 YYSIZE_T yysize = yysize0;
963 int yysize_overflow = 0;
964 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
965 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
969 /* This is so xgettext sees the translatable formats that are
970 constructed on the fly. */
971 YY_("syntax error, unexpected %s");
972 YY_("syntax error, unexpected %s, expecting %s");
973 YY_("syntax error, unexpected %s, expecting %s or %s");
974 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
975 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
979 static char const yyunexpected[] = "syntax error, unexpected %s";
980 static char const yyexpecting[] = ", expecting %s";
981 static char const yyor[] = " or %s";
982 char yyformat[sizeof yyunexpected
983 + sizeof yyexpecting - 1
984 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
985 * (sizeof yyor - 1))];
986 char const *yyprefix = yyexpecting;
988 /* Start YYX at -YYN if negative to avoid negative indexes in
990 int yyxbegin = yyn < 0 ? -yyn : 0;
992 /* Stay within bounds of both yycheck and yytname. */
993 int yychecklim = YYLAST - yyn + 1;
994 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
997 yyarg[0] = yytname[yytype];
998 yyfmt = yystpcpy (yyformat, yyunexpected);
1000 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1001 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1003 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1007 yyformat[sizeof yyunexpected - 1] = '\0';
1010 yyarg[yycount++] = yytname[yyx];
1011 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1012 yysize_overflow |= (yysize1 < yysize);
1014 yyfmt = yystpcpy (yyfmt, yyprefix);
1018 yyf = YY_(yyformat);
1019 yysize1 = yysize + yystrlen (yyf);
1020 yysize_overflow |= (yysize1 < yysize);
1023 if (yysize_overflow)
1024 return YYSIZE_MAXIMUM;
1028 /* Avoid sprintf, as that infringes on the user's name space.
1029 Don't have undefined behavior even if the translation
1030 produced a string with the wrong number of "%s"s. */
1031 char *yyp = yyresult;
1033 while ((*yyp = *yyf) != '\0')
1035 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1037 yyp += yytnamerr (yyp, yyarg[yyi++]);
1050 #endif /* YYERROR_VERBOSE */
1053 /*-----------------------------------------------.
1054 | Release the memory associated to this symbol. |
1055 `-----------------------------------------------*/
1058 #if (defined __STDC__ || defined __C99__FUNC__ \
1059 || defined __cplusplus || defined _MSC_VER)
1061 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1064 yydestruct (yymsg, yytype, yyvaluep)
1074 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1085 /* Prevent warnings from -Wmissing-prototypes. */
1087 #ifdef YYPARSE_PARAM
1088 #if defined __STDC__ || defined __cplusplus
1089 int yyparse (void *YYPARSE_PARAM);
1093 #else /* ! YYPARSE_PARAM */
1094 #if defined __STDC__ || defined __cplusplus
1099 #endif /* ! YYPARSE_PARAM */
1103 /* The look-ahead symbol. */
1106 /* The semantic value of the look-ahead symbol. */
1109 /* Number of syntax errors so far. */
1118 #ifdef YYPARSE_PARAM
1119 #if (defined __STDC__ || defined __C99__FUNC__ \
1120 || defined __cplusplus || defined _MSC_VER)
1122 yyparse (void *YYPARSE_PARAM)
1125 yyparse (YYPARSE_PARAM)
1126 void *YYPARSE_PARAM;
1128 #else /* ! YYPARSE_PARAM */
1129 #if (defined __STDC__ || defined __C99__FUNC__ \
1130 || defined __cplusplus || defined _MSC_VER)
1144 /* Number of tokens to shift before error messages enabled. */
1146 /* Look-ahead token as an internal (translated) token number. */
1149 /* Buffer for error messages, and its allocated size. */
1151 char *yymsg = yymsgbuf;
1152 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1155 /* Three stacks and their tools:
1156 `yyss': related to states,
1157 `yyvs': related to semantic values,
1158 `yyls': related to locations.
1160 Refer to the stacks thru separate pointers, to allow yyoverflow
1161 to reallocate them elsewhere. */
1163 /* The state stack. */
1164 yytype_int16 yyssa[YYINITDEPTH];
1165 yytype_int16 *yyss = yyssa;
1166 yytype_int16 *yyssp;
1168 /* The semantic value stack. */
1169 YYSTYPE yyvsa[YYINITDEPTH];
1170 YYSTYPE *yyvs = yyvsa;
1175 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1177 YYSIZE_T yystacksize = YYINITDEPTH;
1179 /* The variables used to return semantic value and location from the
1184 /* The number of symbols on the RHS of the reduced rule.
1185 Keep to zero when no symbol should be popped. */
1188 YYDPRINTF ((stderr, "Starting parse\n"));
1193 yychar = YYEMPTY; /* Cause a token to be read. */
1195 /* Initialize stack pointers.
1196 Waste one element of value and location stack
1197 so that they stay on the same level as the state stack.
1198 The wasted elements are never initialized. */
1205 /*------------------------------------------------------------.
1206 | yynewstate -- Push a new state, which is found in yystate. |
1207 `------------------------------------------------------------*/
1209 /* In all cases, when you get here, the value and location stacks
1210 have just been pushed. So pushing a state here evens the stacks. */
1216 if (yyss + yystacksize - 1 <= yyssp)
1218 /* Get the current used size of the three stacks, in elements. */
1219 YYSIZE_T yysize = yyssp - yyss + 1;
1223 /* Give user a chance to reallocate the stack. Use copies of
1224 these so that the &'s don't force the real ones into
1226 YYSTYPE *yyvs1 = yyvs;
1227 yytype_int16 *yyss1 = yyss;
1230 /* Each stack pointer address is followed by the size of the
1231 data in use in that stack, in bytes. This used to be a
1232 conditional around just the two extra args, but that might
1233 be undefined if yyoverflow is a macro. */
1234 yyoverflow (YY_("memory exhausted"),
1235 &yyss1, yysize * sizeof (*yyssp),
1236 &yyvs1, yysize * sizeof (*yyvsp),
1243 #else /* no yyoverflow */
1244 # ifndef YYSTACK_RELOCATE
1245 goto yyexhaustedlab;
1247 /* Extend the stack our own way. */
1248 if (YYMAXDEPTH <= yystacksize)
1249 goto yyexhaustedlab;
1251 if (YYMAXDEPTH < yystacksize)
1252 yystacksize = YYMAXDEPTH;
1255 yytype_int16 *yyss1 = yyss;
1256 union yyalloc *yyptr =
1257 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1259 goto yyexhaustedlab;
1260 YYSTACK_RELOCATE (yyss);
1261 YYSTACK_RELOCATE (yyvs);
1263 # undef YYSTACK_RELOCATE
1265 YYSTACK_FREE (yyss1);
1268 #endif /* no yyoverflow */
1270 yyssp = yyss + yysize - 1;
1271 yyvsp = yyvs + yysize - 1;
1274 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1275 (unsigned long int) yystacksize));
1277 if (yyss + yystacksize - 1 <= yyssp)
1281 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1290 /* Do appropriate processing given the current state. Read a
1291 look-ahead token if we need one and don't already have one. */
1293 /* First try to decide what to do without reference to look-ahead token. */
1294 yyn = yypact[yystate];
1295 if (yyn == YYPACT_NINF)
1298 /* Not known => get a look-ahead token if don't already have one. */
1300 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1301 if (yychar == YYEMPTY)
1303 YYDPRINTF ((stderr, "Reading a token: "));
1307 if (yychar <= YYEOF)
1309 yychar = yytoken = YYEOF;
1310 YYDPRINTF ((stderr, "Now at end of input.\n"));
1314 yytoken = YYTRANSLATE (yychar);
1315 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1318 /* If the proper action on seeing token YYTOKEN is to reduce or to
1319 detect an error, take that action. */
1321 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1326 if (yyn == 0 || yyn == YYTABLE_NINF)
1335 /* Count tokens shifted since error; after three, turn off error
1340 /* Shift the look-ahead token. */
1341 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1343 /* Discard the shifted token unless it is eof. */
1344 if (yychar != YYEOF)
1353 /*-----------------------------------------------------------.
1354 | yydefault -- do the default action for the current state. |
1355 `-----------------------------------------------------------*/
1357 yyn = yydefact[yystate];
1363 /*-----------------------------.
1364 | yyreduce -- Do a reduction. |
1365 `-----------------------------*/
1367 /* yyn is the number of a rule to reduce with. */
1370 /* If YYLEN is nonzero, implement the default value of the action:
1373 Otherwise, the following line sets YYVAL to garbage.
1374 This behavior is undocumented and Bison
1375 users should not rely upon it. Assigning to YYVAL
1376 unconditionally makes the parser a bit smaller, and it avoids a
1377 GCC warning that YYVAL may be used uninitialized. */
1378 yyval = yyvsp[1-yylen];
1381 YY_REDUCE_PRINT (yyn);
1387 id_str = (yyvsp[(2) - (2)].string);
1394 base_id = name2number((yyvsp[(2) - (2)].string));
1395 strlcpy(name, (yyvsp[(2) - (2)].string), sizeof(name));
1396 free((yyvsp[(2) - (2)].string));
1403 base_id = name2number((yyvsp[(2) - (3)].string));
1404 strlcpy(name, (yyvsp[(3) - (3)].string), sizeof(name));
1405 free((yyvsp[(2) - (3)].string));
1406 free((yyvsp[(3) - (3)].string));
1413 number = (yyvsp[(2) - (2)].number);
1421 asprintf (&prefix, "%s_", (yyvsp[(2) - (2)].string));
1424 free((yyvsp[(2) - (2)].string));
1431 prefix = realloc(prefix, 1);
1441 struct error_code *ec = malloc(sizeof(*ec));
1447 ec->number = number;
1448 if(prefix && *prefix != '\0') {
1449 asprintf (&ec->name, "%s%s", prefix, (yyvsp[(2) - (4)].string));
1450 if (ec->name == NULL)
1452 free((yyvsp[(2) - (4)].string));
1454 ec->name = (yyvsp[(2) - (4)].string);
1455 ec->string = (yyvsp[(4) - (4)].string);
1469 /* Line 1267 of yacc.c. */
1470 #line 1471 "parse.c"
1473 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1477 YY_STACK_PRINT (yyss, yyssp);
1482 /* Now `shift' the result of the reduction. Determine what state
1483 that goes to, based on the state we popped back to and the rule
1484 number reduced by. */
1488 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1489 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1490 yystate = yytable[yystate];
1492 yystate = yydefgoto[yyn - YYNTOKENS];
1497 /*------------------------------------.
1498 | yyerrlab -- here on detecting error |
1499 `------------------------------------*/
1501 /* If not already recovering from an error, report this error. */
1505 #if ! YYERROR_VERBOSE
1506 yyerror (YY_("syntax error"));
1509 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1510 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1512 YYSIZE_T yyalloc = 2 * yysize;
1513 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1514 yyalloc = YYSTACK_ALLOC_MAXIMUM;
1515 if (yymsg != yymsgbuf)
1516 YYSTACK_FREE (yymsg);
1517 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1519 yymsg_alloc = yyalloc;
1523 yymsg_alloc = sizeof yymsgbuf;
1527 if (0 < yysize && yysize <= yymsg_alloc)
1529 (void) yysyntax_error (yymsg, yystate, yychar);
1534 yyerror (YY_("syntax error"));
1536 goto yyexhaustedlab;
1544 if (yyerrstatus == 3)
1546 /* If just tried and failed to reuse look-ahead token after an
1547 error, discard it. */
1549 if (yychar <= YYEOF)
1551 /* Return failure if at end of input. */
1552 if (yychar == YYEOF)
1557 yydestruct ("Error: discarding",
1563 /* Else will try to reuse look-ahead token after shifting the error
1568 /*---------------------------------------------------.
1569 | yyerrorlab -- error raised explicitly by YYERROR. |
1570 `---------------------------------------------------*/
1573 /* Pacify compilers like GCC when the user code never invokes
1574 YYERROR and the label yyerrorlab therefore never appears in user
1576 if (/*CONSTCOND*/ 0)
1579 /* Do not reclaim the symbols of the rule which action triggered
1583 YY_STACK_PRINT (yyss, yyssp);
1588 /*-------------------------------------------------------------.
1589 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1590 `-------------------------------------------------------------*/
1592 yyerrstatus = 3; /* Each real token shifted decrements this. */
1596 yyn = yypact[yystate];
1597 if (yyn != YYPACT_NINF)
1600 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1608 /* Pop the current state because it cannot handle the error token. */
1613 yydestruct ("Error: popping",
1614 yystos[yystate], yyvsp);
1617 YY_STACK_PRINT (yyss, yyssp);
1626 /* Shift the error token. */
1627 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1633 /*-------------------------------------.
1634 | yyacceptlab -- YYACCEPT comes here. |
1635 `-------------------------------------*/
1640 /*-----------------------------------.
1641 | yyabortlab -- YYABORT comes here. |
1642 `-----------------------------------*/
1648 /*-------------------------------------------------.
1649 | yyexhaustedlab -- memory exhaustion comes here. |
1650 `-------------------------------------------------*/
1652 yyerror (YY_("memory exhausted"));
1658 if (yychar != YYEOF && yychar != YYEMPTY)
1659 yydestruct ("Cleanup: discarding lookahead",
1661 /* Do not reclaim the symbols of the rule which action triggered
1662 this YYABORT or YYACCEPT. */
1664 YY_STACK_PRINT (yyss, yyssp);
1665 while (yyssp != yyss)
1667 yydestruct ("Cleanup: popping",
1668 yystos[*yyssp], yyvsp);
1673 YYSTACK_FREE (yyss);
1676 if (yymsg != yymsgbuf)
1677 YYSTACK_FREE (yymsg);
1679 /* Make sure YYID is used. */
1680 return YYID (yyresult);
1688 name2number(const char *str)
1692 const char *x = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
1693 "abcdefghijklmnopqrstuvwxyz0123456789_";
1694 if(strlen(str) > 4) {
1695 yyerror("table name too long");
1698 for(p = str; *p; p++){
1699 char *q = strchr(x, *p);
1701 yyerror("invalid character in table name");
1704 num = (num << 6) + (q - x) + 1;
1707 if(num > 0x7fffffff)
1708 num = -(0xffffffff - num + 1);
1715 _lex_error_message ("%s\n", s);