/* A Bison parser, made by GNU Bison 2.5. */
/* Bison implementation for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* C LALR(1) parser skeleton written by Richard Stallman, by
simplifying the original so-called "semantic" parser. */
/* All symbols defined below should begin with gram_ or gram_, to avoid
infringing on user name space. This should be done even for local
variables, as they might otherwise be expanded by user macros.
There are some unavoidable exceptions within include files to
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
/* Identify Bison output. */
#define gram_BISON 1
/* Bison version. */
#define gram_BISON_VERSION "2.5"
/* Skeleton name. */
#define gram_SKELETON_NAME "yacc.c"
/* Pure parsers. */
#define gram_PURE 0
/* Push parsers. */
#define gram_PUSH 0
/* Pull parsers. */
#define gram_PULL 1
/* Using locations. */
#define gram_LSP_NEEDED 0
/* Copy the first part of user declarations. */
/* Line 268 of yacc.c */
#line 20 "codegen/gram.y"
#include
#include
#include
#include
#include
#include
#define gram_DEBUG 0
#define gram_ERROR_VERBOSE 1
/* Line 268 of yacc.c */
#line 88 "y.tab.c"
/* Enabling traces. */
#ifndef gram_DEBUG
# define gram_DEBUG 0
#endif
/* Enabling verbose error messages. */
#ifdef gram_ERROR_VERBOSE
# undef gram_ERROR_VERBOSE
# define gram_ERROR_VERBOSE 1
#else
# define gram_ERROR_VERBOSE 0
#endif
/* Enabling the token table. */
#ifndef gram_TOKEN_TABLE
# define gram_TOKEN_TABLE 0
#endif
/* Tokens. */
#ifndef gram_TOKENTYPE
# define gram_TOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum gram_tokentype {
AUTO = 258,
CHAR = 259,
CONST = 260,
DOUBLE = 261,
ELLIPSIS = 262,
ENUM = 263,
EXTERN = 264,
FLOAT = 265,
IDENTIFIER = 266,
INT = 267,
JUNK = 268,
LONG = 269,
REGISTER = 270,
SHORT = 271,
SIGNED = 272,
STATIC = 273,
STRUCT = 274,
TYPEDEF = 275,
TYPE_NAME = 276,
UNION = 277,
UNSIGNED = 278,
VOID = 279,
VOLATILE = 280
};
#endif
/* Tokens. */
#define AUTO 258
#define CHAR 259
#define CONST 260
#define DOUBLE 261
#define ELLIPSIS 262
#define ENUM 263
#define EXTERN 264
#define FLOAT 265
#define IDENTIFIER 266
#define INT 267
#define JUNK 268
#define LONG 269
#define REGISTER 270
#define SHORT 271
#define SIGNED 272
#define STATIC 273
#define STRUCT 274
#define TYPEDEF 275
#define TYPE_NAME 276
#define UNION 277
#define UNSIGNED 278
#define VOID 279
#define VOLATILE 280
#if ! defined gram_STYPE && ! defined gram_STYPE_IS_DECLARED
typedef union gram_STYPE
{
/* Line 293 of yacc.c */
#line 61 "codegen/gram.y"
struct node_t *lv_node;
const char *lv_string;
/* Line 293 of yacc.c */
#line 181 "y.tab.c"
} gram_STYPE;
# define gram_STYPE_IS_TRIVIAL 1
# define gram_stype gram_STYPE /* obsolescent; will be withdrawn */
# define gram_STYPE_IS_DECLARED 1
#endif
/* Copy the second part of user declarations. */
/* Line 343 of yacc.c */
#line 87 "codegen/gram.y"
extern gram_STYPE gram_lval;
static const char *pos;
static void
lex_open(const char *text)
{
pos = text;
}
static void
lex_close(void)
{
pos = 0;
}
typedef struct res_tab_t res_tab_t;
struct res_tab_t
{
const char *name;
int value;
};
/*
* Keep thid table in strcmp order
* so that bsearch will work
*/
static const res_tab_t res_tab[] =
{
{ "...", ELLIPSIS },
{ "acl_t", TYPE_NAME },
{ "acl_type_t", TYPE_NAME },
{ "auto", AUTO },
{ "char", CHAR },
{ "class", JUNK }, // avoid so C++ doesn't barf
{ "const", CONST },
{ "dev_t", TYPE_NAME },
{ "double", DOUBLE },
{ "enum", ENUM },
{ "extern", EXTERN },
{ "fd_set", TYPE_NAME },
{ "float", FLOAT },
{ "fpos_t", TYPE_NAME },
{ "gid_t", TYPE_NAME },
{ "iconv_t", TYPE_NAME },
{ "int", INT },
{ "long", LONG },
{ "mode_t", TYPE_NAME },
{ "off_t", TYPE_NAME },
{ "operator", JUNK }, // avoid so C++ doesn't barf
{ "pid_t", TYPE_NAME },
{ "private", JUNK }, // avoid so C++ doesn't barf
{ "protected", JUNK }, // avoid so C++ doesn't barf
{ "ptrdiff_t", TYPE_NAME },
{ "public", JUNK }, // avoid so C++ doesn't barf
{ "register", REGISTER },
{ "short", SHORT },
{ "signed", SIGNED },
{ "sigset_t", TYPE_NAME },
{ "size_t", TYPE_NAME },
{ "socklen_t", TYPE_NAME },
{ "ssize_t", TYPE_NAME },
{ "static", STATIC },
{ "struct", STRUCT },
{ "template", JUNK }, // avoid so C++ doesn't barf
{ "time_t", TYPE_NAME },
{ "typedef", TYPEDEF },
{ "uid_t", TYPE_NAME },
{ "union", UNION },
{ "unsigned", UNSIGNED },
{ "useconds_t", TYPE_NAME },
{ "va_list", TYPE_NAME },
{ "void", VOID },
{ "volatile", VOLATILE },
};
static int
reserved(const char *s)
{
const res_tab_t *tp;
/* FIXME: use bearch */
for (tp = res_tab; tp < ENDOF(res_tab); ++tp)
{
if (0 == strcmp(s, tp->name))
return tp->value;
}
return IDENTIFIER;
}
static int
gram_lex(void)
{
static char buf[256];
for (;;)
{
char *bp = buf;
unsigned char c;
c = *pos++;
switch (c)
{
case '\0':
--pos;
return 0;
case ' ':
case '\t':
case '\n':
break;
default:
return c;
case '.':
if (pos[0] == '.' && pos[1] == '.')
{
pos += 2;
return ELLIPSIS;
}
return c;
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g':
case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u':
case 'v': case 'w': case 'x': case 'y': case 'z':
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N':
case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U':
case 'V': case 'W': case 'X': case 'Y': case 'Z':
case '_':
for (;;)
{
if (bp < buf + sizeof(buf) - 1)
*bp++ = c;
c = *pos++;
switch (c)
{
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
case 's': case 't': case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
case 'Y': case 'Z':
case '_':
continue;
default:
--pos;
break;
}
break;
}
*bp = '\0';
gram_lval.lv_string = buf;
return reserved(buf);
}
}
}
static void
gram_error(const char *s)
{
fprintf(stderr, "parsing declaration: %s\n", s);
exit(EXIT_FAILURE);
}
// Different versions of bison and yacc emit code chunks and function
// prototypes in different orders. We need this prototype declaration
// because the call to gram_parse, below, would complain in the cases where
// there is not yet a gram_parse prototype in scope.
int gram_parse(void);
static node_t *result;
#if gram_DEBUG
extern int gram_debug;
#endif
node_t *
grammar(const char *text)
{
#if gram_DEBUG
gram_debug = 1;
#endif
lex_open(text);
gram_parse();
lex_close();
return result;
}
/* Line 343 of yacc.c */
#line 401 "y.tab.c"
#ifdef short
# undef short
#endif
#ifdef gram_TYPE_UINT8
typedef gram_TYPE_UINT8 gram_type_uint8;
#else
typedef unsigned char gram_type_uint8;
#endif
#ifdef gram_TYPE_INT8
typedef gram_TYPE_INT8 gram_type_int8;
#elif (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
typedef signed char gram_type_int8;
#else
typedef short int gram_type_int8;
#endif
#ifdef gram_TYPE_UINT16
typedef gram_TYPE_UINT16 gram_type_uint16;
#else
typedef unsigned short int gram_type_uint16;
#endif
#ifdef gram_TYPE_INT16
typedef gram_TYPE_INT16 gram_type_int16;
#else
typedef short int gram_type_int16;
#endif
#ifndef gram_SIZE_T
# ifdef __SIZE_TYPE__
# define gram_SIZE_T __SIZE_TYPE__
# elif defined size_t
# define gram_SIZE_T size_t
# elif ! defined gram_SIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
# define gram_SIZE_T size_t
# else
# define gram_SIZE_T unsigned int
# endif
#endif
#define gram_SIZE_MAXIMUM ((gram_SIZE_T) -1)
#ifndef gram__
# if defined gram_ENABLE_NLS && gram_ENABLE_NLS
# if ENABLE_NLS
# include /* INFRINGES ON USER NAME SPACE */
# define gram__(msgid) dgettext ("bison-runtime", msgid)
# endif
# endif
# ifndef gram__
# define gram__(msgid) msgid
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define gram_USE(e) ((void) (e))
#else
# define gram_USE(e) /* empty */
#endif
/* Identity function, used to suppress warnings about constant conditions. */
#ifndef lint
# define gram_ID(n) (n)
#else
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static int
gram_ID (int gram_i)
#else
static int
gram_ID (gram_i)
int gram_i;
#endif
{
return gram_i;
}
#endif
#if ! defined gram_overflow || gram_ERROR_VERBOSE
/* The parser invokes alloca or malloc; define the necessary symbols. */
# ifdef gram_STACK_USE_ALLOCA
# if gram_STACK_USE_ALLOCA
# ifdef __GNUC__
# define gram_STACK_ALLOC __builtin_alloca
# elif defined __BUILTIN_VA_ARG_INCR
# include /* INFRINGES ON USER NAME SPACE */
# elif defined _AIX
# define gram_STACK_ALLOC __alloca
# elif defined _MSC_VER
# include /* INFRINGES ON USER NAME SPACE */
# define alloca _alloca
# else
# define gram_STACK_ALLOC alloca
# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# endif
# endif
# endif
# endif
# endif
# ifdef gram_STACK_ALLOC
/* Pacify GCC's `empty if-body' warning. */
# define gram_STACK_FREE(Ptr) do { /* empty */; } while (gram_ID (0))
# ifndef gram_STACK_ALLOC_MAXIMUM
/* The OS might guarantee only one guard page at the bottom of the stack,
and a page size can be as small as 4096 bytes. So we cannot safely
invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
to allow for a few compiler-allocated temporary stack slots. */
# define gram_STACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
# endif
# else
# define gram_STACK_ALLOC gram_MALLOC
# define gram_STACK_FREE gram_FREE
# ifndef gram_STACK_ALLOC_MAXIMUM
# define gram_STACK_ALLOC_MAXIMUM gram_SIZE_MAXIMUM
# endif
# if (defined __cplusplus && ! defined EXIT_SUCCESS \
&& ! ((defined gram_MALLOC || defined malloc) \
&& (defined gram_FREE || defined free)))
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# endif
# endif
# ifndef gram_MALLOC
# define gram_MALLOC malloc
# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
void *malloc (gram_SIZE_T); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# ifndef gram_FREE
# define gram_FREE free
# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# endif
#endif /* ! defined gram_overflow || gram_ERROR_VERBOSE */
#if (! defined gram_overflow \
&& (! defined __cplusplus \
|| (defined gram_STYPE_IS_TRIVIAL && gram_STYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union gram_alloc
{
gram_type_int16 gram_ss_alloc;
gram_STYPE gram_vs_alloc;
};
/* The size of the maximum gap between one aligned stack and the next. */
# define gram_STACK_GAP_MAXIMUM (sizeof (union gram_alloc) - 1)
/* The size of an array large to enough to hold all stacks, each with
N elements. */
# define gram_STACK_BYTES(N) \
((N) * (sizeof (gram_type_int16) + sizeof (gram_STYPE)) \
+ gram_STACK_GAP_MAXIMUM)
# define gram_COPY_NEEDED 1
/* Relocate STACK from its old location to the new one. The
local variables gram_SIZE and gram_STACKSIZE give the old and new number of
elements in the stack, and gram_PTR gives the new location of the
stack. Advance gram_PTR to a properly aligned location for the next
stack. */
# define gram_STACK_RELOCATE(Stack_alloc, Stack) \
do \
{ \
gram_SIZE_T gram_newbytes; \
gram_COPY (&gram_ptr->Stack_alloc, Stack, gram_size); \
Stack = &gram_ptr->Stack_alloc; \
gram_newbytes = gram_stacksize * sizeof (*Stack) + gram_STACK_GAP_MAXIMUM; \
gram_ptr += gram_newbytes / sizeof (*gram_ptr); \
} \
while (gram_ID (0))
#endif
#if defined gram_COPY_NEEDED && gram_COPY_NEEDED
/* Copy COUNT objects from FROM to TO. The source and destination do
not overlap. */
# ifndef gram_COPY
# if defined __GNUC__ && 1 < __GNUC__
# define gram_COPY(To, From, Count) \
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
# else
# define gram_COPY(To, From, Count) \
do \
{ \
gram_SIZE_T gram_i; \
for (gram_i = 0; gram_i < (Count); gram_i++) \
(To)[gram_i] = (From)[gram_i]; \
} \
while (gram_ID (0))
# endif
# endif
#endif /* !gram_COPY_NEEDED */
/* gram_FINAL -- State number of the termination state. */
#define gram_FINAL 31
/* gram_LAST -- Last index in gram_TABLE. */
#define gram_LAST 103
/* gram_NTOKENS -- Number of terminals. */
#define gram_NTOKENS 33
/* gram_NNTS -- Number of nonterminals. */
#define gram_NNTS 20
/* gram_NRULES -- Number of rules. */
#define gram_NRULES 57
/* gram_NRULES -- Number of states. */
#define gram_NSTATES 71
/* gram_TRANSLATE(gram_LEX) -- Bison symbol number corresponding to gram_LEX. */
#define gram_UNDEFTOK 2
#define gram_MAXUTOK 280
#define gram_TRANSLATE(gram_X) \
((unsigned int) (gram_X) <= gram_MAXUTOK ? gram_translate[gram_X] : gram_UNDEFTOK)
/* gram_TRANSLATE[gram_LEX] -- Bison symbol number corresponding to gram_LEX. */
static const gram_type_uint8 gram_translate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
28, 29, 32, 2, 27, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 26,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 30, 2, 31, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25
};
#if gram_DEBUG
/* gram_PRHS[gram_N] -- Index of the first RHS symbol of rule number gram_N in
gram_RHS. */
static const gram_type_uint8 gram_prhs[] =
{
0, 0, 3, 5, 8, 12, 13, 15, 17, 20,
22, 25, 27, 30, 32, 36, 38, 40, 42, 44,
46, 48, 50, 52, 54, 56, 58, 60, 62, 64,
66, 68, 70, 72, 75, 77, 79, 82, 84, 86,
89, 91, 93, 97, 101, 106, 110, 112, 115, 118,
122, 124, 127, 129, 131, 135, 137, 141
};
/* gram_RHS -- A `-1'-separated list of the rules' RHS. */
static const gram_type_int8 gram_rhs[] =
{
34, 0, -1, 35, -1, 37, 36, -1, 37, 38,
36, -1, -1, 26, -1, 40, -1, 40, 37, -1,
41, -1, 41, 37, -1, 45, -1, 45, 37, -1,
39, -1, 38, 27, 39, -1, 46, -1, 20, -1,
9, -1, 18, -1, 3, -1, 15, -1, 24, -1,
4, -1, 16, -1, 12, -1, 14, -1, 10, -1,
6, -1, 17, -1, 23, -1, 42, -1, 44, -1,
21, -1, 43, 11, -1, 19, -1, 22, -1, 8,
11, -1, 5, -1, 25, -1, 48, 47, -1, 47,
-1, 11, -1, 28, 46, 29, -1, 47, 30, 31,
-1, 47, 28, 50, 29, -1, 47, 28, 29, -1,
32, -1, 32, 49, -1, 32, 48, -1, 32, 49,
48, -1, 45, -1, 49, 45, -1, 24, -1, 51,
-1, 51, 27, 7, -1, 52, -1, 51, 27, 52,
-1, 37, 46, -1
};
/* gram_RLINE[gram_N] -- source line where rule number gram_N was defined. */
static const gram_type_uint16 gram_rline[] =
{
0, 297, 297, 304, 310, 321, 322, 327, 332, 338,
343, 349, 354, 363, 368, 377, 385, 390, 395, 400,
405, 413, 418, 423, 428, 433, 438, 443, 448, 453,
458, 463, 468, 476, 485, 490, 498, 507, 512, 520,
526, 534, 539, 546, 553, 561, 571, 576, 582, 588,
598, 603, 611, 616, 621, 630, 635, 644
};
#endif
#if gram_DEBUG || gram_ERROR_VERBOSE || gram_TOKEN_TABLE
/* gram_TNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at gram_NTOKENS, nonterminals. */
static const char *const gram_tname[] =
{
"$end", "error", "$undefined", "AUTO", "CHAR", "CONST", "DOUBLE",
"ELLIPSIS", "ENUM", "EXTERN", "FLOAT", "IDENTIFIER", "INT", "JUNK",
"LONG", "REGISTER", "SHORT", "SIGNED", "STATIC", "STRUCT", "TYPEDEF",
"TYPE_NAME", "UNION", "UNSIGNED", "VOID", "VOLATILE", "';'", "','",
"'('", "')'", "'['", "']'", "'*'", "$accept", "success", "declaration",
"optional_semicolon", "declaration_specifiers", "init_declarator_list",
"init_declarator", "storage_class_specifier", "type_specifier",
"struct_or_union_specifier", "struct_or_union", "enum_specifier",
"type_qualifier", "declarator", "direct_declarator", "pointer",
"type_qualifier_list", "parameter_type_list", "parameter_list",
"parameter_declaration", 0
};
#endif
# ifdef gram_PRINT
/* gram_TOKNUM[gram_LEX-NUM] -- Internal token number corresponding to
token gram_LEX-NUM. */
static const gram_type_uint16 gram_toknum[] =
{
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
275, 276, 277, 278, 279, 280, 59, 44, 40, 41,
91, 93, 42
};
# endif
/* gram_R1[gram_N] -- Symbol number of symbol that rule gram_N derives. */
static const gram_type_uint8 gram_r1[] =
{
0, 33, 34, 35, 35, 36, 36, 37, 37, 37,
37, 37, 37, 38, 38, 39, 40, 40, 40, 40,
40, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 42, 43, 43, 44, 45, 45, 46,
46, 47, 47, 47, 47, 47, 48, 48, 48, 48,
49, 49, 50, 50, 50, 51, 51, 52
};
/* gram_R2[gram_N] -- Number of symbols composing right hand side of rule gram_N. */
static const gram_type_uint8 gram_r2[] =
{
0, 2, 1, 2, 3, 0, 1, 1, 2, 1,
2, 1, 2, 1, 3, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 2, 1, 1, 2, 1, 1, 2,
1, 1, 3, 3, 4, 3, 1, 2, 2, 3,
1, 2, 1, 1, 3, 1, 3, 2
};
/* gram_DEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
Performed when gram_TABLE doesn't specify something else to do. Zero
means the default is an error. */
static const gram_type_uint8 gram_defact[] =
{
0, 19, 22, 37, 27, 0, 17, 26, 24, 25,
20, 23, 28, 18, 34, 16, 32, 35, 29, 21,
38, 0, 2, 5, 7, 9, 30, 0, 31, 11,
36, 1, 41, 6, 0, 46, 3, 5, 13, 15,
40, 0, 8, 10, 33, 12, 0, 50, 48, 47,
0, 4, 0, 0, 39, 42, 51, 49, 14, 21,
45, 0, 0, 53, 55, 43, 57, 44, 0, 54,
56
};
/* gram_DEFGOTO[NTERM-NUM]. */
static const gram_type_int8 gram_defgoto[] =
{
-1, 21, 22, 36, 61, 37, 38, 24, 25, 26,
27, 28, 29, 39, 40, 41, 49, 62, 63, 64
};
/* gram_PACT[STATE-NUM] -- Index in gram_TABLE of the portion describing
STATE-NUM. */
#define gram_PACT_NINF -32
static const gram_type_int8 gram_pact[] =
{
78, -32, -32, -32, -32, -7, -32, -32, -32, -32,
-32, -32, -32, -32, -32, -32, -32, -32, -32, -32,
-32, 8, -32, -9, 78, 78, -32, 2, -32, 78,
-32, -32, -32, -32, -6, -4, -32, -15, -32, -32,
-21, -1, -32, -32, -32, -32, -14, -32, -32, -4,
-6, -32, 28, -17, -21, -32, -32, -32, -32, -13,
-32, -6, -11, 12, -32, -32, -32, -32, 55, -32,
-32
};
/* gram_PGOTO[NTERM-NUM]. */
static const gram_type_int8 gram_pgoto[] =
{
-32, -32, -32, -2, 0, -32, 4, -32, -32, -32,
-32, -32, -29, -31, 15, 6, -32, -32, -32, 17
};
/* gram_TABLE[gram_PACT[STATE-NUM]]. What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule which
number is the opposite. If gram_TABLE_NINF, syntax error. */
#define gram_TABLE_NINF -53
static const gram_type_int8 gram_table[] =
{
23, 3, 32, 46, 30, 32, 47, 52, 31, 53,
32, 33, 50, 44, 65, 55, -52, 33, 67, 34,
56, 20, 34, 35, 42, 43, 35, 34, 35, 45,
66, 1, 2, 3, 4, 51, 5, 6, 7, 68,
8, 48, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 59, 20, 58, 57, 54, 60, 1, 2,
3, 4, 69, 5, 6, 7, 0, 8, 0, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 1, 2, 3, 4, 70, 5, 6, 7, 0,
8, 0, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20
};
#define gram_pact_value_is_default(gram_state) \
((gram_state) == (-32))
#define gram_table_value_is_error(gram_table_value) \
gram_ID (0)
static const gram_type_int8 gram_check[] =
{
0, 5, 11, 34, 11, 11, 35, 28, 0, 30,
11, 26, 27, 11, 31, 29, 29, 26, 29, 28,
49, 25, 28, 32, 24, 25, 32, 28, 32, 29,
61, 3, 4, 5, 6, 37, 8, 9, 10, 27,
12, 35, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24, 25, 50, 49, 41, 29, 3, 4,
5, 6, 7, 8, 9, 10, -1, 12, -1, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 3, 4, 5, 6, 68, 8, 9, 10, -1,
12, -1, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24, 25
};
/* gram_STOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
static const gram_type_uint8 gram_stos[] =
{
0, 3, 4, 5, 6, 8, 9, 10, 12, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 34, 35, 37, 40, 41, 42, 43, 44, 45,
11, 0, 11, 26, 28, 32, 36, 38, 39, 46,
47, 48, 37, 37, 11, 37, 46, 45, 48, 49,
27, 36, 28, 30, 47, 29, 45, 48, 39, 24,
29, 37, 50, 51, 52, 31, 46, 29, 27, 7,
52
};
#define gram_errok (gram_errstatus = 0)
#define gram_clearin (gram_char = gram_EMPTY)
#define gram_EMPTY (-2)
#define gram_EOF 0
#define gram_ACCEPT goto gram_acceptlab
#define gram_ABORT goto gram_abortlab
#define gram_ERROR goto gram_errorlab
/* Like gram_ERROR except do call gram_error. This remains here temporarily
to ease the transition to the new meaning of gram_ERROR, for GCC.
Once GCC version 2 has supplanted version 1, this can go. However,
gram_FAIL appears to be in use. Nevertheless, it is formally deprecated
in Bison 2.4.2's NEWS entry, where a plan to phase it out is
discussed. */
#define gram_FAIL goto gram_errlab
#if defined gram_FAIL
/* This is here to suppress warnings from the GCC cpp's
-Wunused-macros. Normally we don't worry about that warning, but
some users do, and we want to make it easy for users to remove
gram_FAIL uses, which will produce warnings from Bison 2.5. */
#endif
#define gram_RECOVERING() (!!gram_errstatus)
#define gram_BACKUP(Token, Value) \
do \
if (gram_char == gram_EMPTY && gram_len == 1) \
{ \
gram_char = (Token); \
gram_lval = (Value); \
gram_POPSTACK (1); \
goto gram_backup; \
} \
else \
{ \
gram_error (gram__("syntax error: cannot back up")); \
gram_ERROR; \
} \
while (gram_ID (0))
#define gram_TERROR 1
#define gram_ERRCODE 256
/* gram_LLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
If N is 0, then set CURRENT to the empty location which ends
the previous symbol: RHS[0] (always defined). */
#define gram_RHSLOC(Rhs, K) ((Rhs)[K])
#ifndef gram_LLOC_DEFAULT
# define gram_LLOC_DEFAULT(Current, Rhs, N) \
do \
if (gram_ID (N)) \
{ \
(Current).first_line = gram_RHSLOC (Rhs, 1).first_line; \
(Current).first_column = gram_RHSLOC (Rhs, 1).first_column; \
(Current).last_line = gram_RHSLOC (Rhs, N).last_line; \
(Current).last_column = gram_RHSLOC (Rhs, N).last_column; \
} \
else \
{ \
(Current).first_line = (Current).last_line = \
gram_RHSLOC (Rhs, 0).last_line; \
(Current).first_column = (Current).last_column = \
gram_RHSLOC (Rhs, 0).last_column; \
} \
while (gram_ID (0))
#endif
/* This macro is provided for backward compatibility. */
#ifndef gram__LOCATION_PRINT
# define gram__LOCATION_PRINT(File, Loc) ((void) 0)
#endif
/* gram_LEX -- calling `gram_lex' with the right arguments. */
#ifdef gram_LEX_PARAM
# define gram_LEX gram_lex (gram_LEX_PARAM)
#else
# define gram_LEX gram_lex ()
#endif
/* Enable debugging if requested. */
#if gram_DEBUG
# ifndef gram_FPRINTF
# define gram_FPRINTF fprintf
# endif
# define gram_DPRINTF(Args) \
do { \
if (gram_debug) \
gram_FPRINTF Args; \
} while (gram_ID (0))
# define gram__SYMBOL_PRINT(Title, Type, Value, Location) \
do { \
if (gram_debug) \
{ \
gram_FPRINTF (stderr, "%s ", Title); \
gram__symbol_print (stderr, \
Type, Value); \
gram_FPRINTF (stderr, "\n"); \
} \
} while (gram_ID (0))
/*--------------------------------.
| Print this symbol on gram_OUTPUT. |
`--------------------------------*/
/*ARGSUSED*/
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
gram__symbol_value_print (FILE *gram_output, int gram_type, gram_STYPE const * const gram_valuep)
#else
static void
gram__symbol_value_print (gram_output, gram_type, gram_valuep)
FILE *gram_output;
int gram_type;
gram_STYPE const * const gram_valuep;
#endif
{
if (!gram_valuep)
return;
# ifdef gram_PRINT
if (gram_type < gram_NTOKENS)
gram_PRINT (gram_output, gram_toknum[gram_type], *gram_valuep);
# else
gram_USE (gram_output);
# endif
switch (gram_type)
{
default:
break;
}
}
/*--------------------------------.
| Print this symbol on gram_OUTPUT. |
`--------------------------------*/
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
gram__symbol_print (FILE *gram_output, int gram_type, gram_STYPE const * const gram_valuep)
#else
static void
gram__symbol_print (gram_output, gram_type, gram_valuep)
FILE *gram_output;
int gram_type;
gram_STYPE const * const gram_valuep;
#endif
{
if (gram_type < gram_NTOKENS)
gram_FPRINTF (gram_output, "token %s (", gram_tname[gram_type]);
else
gram_FPRINTF (gram_output, "nterm %s (", gram_tname[gram_type]);
gram__symbol_value_print (gram_output, gram_type, gram_valuep);
gram_FPRINTF (gram_output, ")");
}
/*------------------------------------------------------------------.
| gram__stack_print -- Print the state stack from its BOTTOM up to its |
| TOP (included). |
`------------------------------------------------------------------*/
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
gram__stack_print (gram_type_int16 *gram_bottom, gram_type_int16 *gram_top)
#else
static void
gram__stack_print (gram_bottom, gram_top)
gram_type_int16 *gram_bottom;
gram_type_int16 *gram_top;
#endif
{
gram_FPRINTF (stderr, "Stack now");
for (; gram_bottom <= gram_top; gram_bottom++)
{
int gram_bot = *gram_bottom;
gram_FPRINTF (stderr, " %d", gram_bot);
}
gram_FPRINTF (stderr, "\n");
}
# define gram__STACK_PRINT(Bottom, Top) \
do { \
if (gram_debug) \
gram__stack_print ((Bottom), (Top)); \
} while (gram_ID (0))
/*------------------------------------------------.
| Report that the gram_RULE is going to be reduced. |
`------------------------------------------------*/
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
gram__reduce_print (gram_STYPE *gram_vsp, int gram_rule)
#else
static void
gram__reduce_print (gram_vsp, gram_rule)
gram_STYPE *gram_vsp;
int gram_rule;
#endif
{
int gram_nrhs = gram_r2[gram_rule];
int gram_i;
unsigned long int gram_lno = gram_rline[gram_rule];
gram_FPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
gram_rule - 1, gram_lno);
/* The symbols being reduced. */
for (gram_i = 0; gram_i < gram_nrhs; gram_i++)
{
gram_FPRINTF (stderr, " $%d = ", gram_i + 1);
gram__symbol_print (stderr, gram_rhs[gram_prhs[gram_rule] + gram_i],
&(gram_vsp[(gram_i + 1) - (gram_nrhs)])
);
gram_FPRINTF (stderr, "\n");
}
}
# define gram__REDUCE_PRINT(Rule) \
do { \
if (gram_debug) \
gram__reduce_print (gram_vsp, Rule); \
} while (gram_ID (0))
/* Nonzero means print parse trace. It is left uninitialized so that
multiple parsers can coexist. */
int gram_debug;
#else /* !gram_DEBUG */
# define gram_DPRINTF(Args)
# define gram__SYMBOL_PRINT(Title, Type, Value, Location)
# define gram__STACK_PRINT(Bottom, Top)
# define gram__REDUCE_PRINT(Rule)
#endif /* !gram_DEBUG */
/* gram_INITDEPTH -- initial size of the parser's stacks. */
#ifndef gram_INITDEPTH
# define gram_INITDEPTH 200
#endif
/* gram_MAXDEPTH -- maximum size the stacks can grow to (effective only
if the built-in stack extension method is used).
Do not make this value too large; the results are undefined if
gram_STACK_ALLOC_MAXIMUM < gram_STACK_BYTES (gram_MAXDEPTH)
evaluated with infinite-precision integer arithmetic. */
#ifndef gram_MAXDEPTH
# define gram_MAXDEPTH 10000
#endif
#if gram_ERROR_VERBOSE
# ifndef gram_strlen
# if defined __GLIBC__ && defined _STRING_H
# define gram_strlen strlen
# else
/* Return the length of gram_STR. */
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static gram_SIZE_T
gram_strlen (const char *gram_str)
#else
static gram_SIZE_T
gram_strlen (gram_str)
const char *gram_str;
#endif
{
gram_SIZE_T gram_len;
for (gram_len = 0; gram_str[gram_len]; gram_len++)
continue;
return gram_len;
}
# endif
# endif
# ifndef gram_stpcpy
# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
# define gram_stpcpy stpcpy
# else
/* Copy gram_SRC to gram_DEST, returning the address of the terminating '\0' in
gram_DEST. */
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static char *
gram_stpcpy (char *gram_dest, const char *gram_src)
#else
static char *
gram_stpcpy (gram_dest, gram_src)
char *gram_dest;
const char *gram_src;
#endif
{
char *gram_d = gram_dest;
const char *gram_s = gram_src;
while ((*gram_d++ = *gram_s++) != '\0')
continue;
return gram_d - 1;
}
# endif
# endif
# ifndef gram_tnamerr
/* Copy to gram_RES the contents of gram_STR after stripping away unnecessary
quotes and backslashes, so that it's suitable for gram_error. The
heuristic is that double-quoting is unnecessary unless the string
contains an apostrophe, a comma, or backslash (other than
backslash-backslash). gram_STR is taken from gram_tname. If gram_RES is
null, do not copy; instead, return the length of what the result
would have been. */
static gram_SIZE_T
gram_tnamerr (char *gram_res, const char *gram_str)
{
if (*gram_str == '"')
{
gram_SIZE_T gram_n = 0;
char const *gram_p = gram_str;
for (;;)
switch (*++gram_p)
{
case '\'':
case ',':
goto do_not_strip_quotes;
case '\\':
if (*++gram_p != '\\')
goto do_not_strip_quotes;
/* Fall through. */
default:
if (gram_res)
gram_res[gram_n] = *gram_p;
gram_n++;
break;
case '"':
if (gram_res)
gram_res[gram_n] = '\0';
return gram_n;
}
do_not_strip_quotes: ;
}
if (! gram_res)
return gram_strlen (gram_str);
return gram_stpcpy (gram_res, gram_str) - gram_res;
}
# endif
/* Copy into *gram_MSG, which is of size *gram_MSG_ALLOC, an error message
about the unexpected token gram_TOKEN for the state stack whose top is
gram_SSP.
Return 0 if *gram_MSG was successfully written. Return 1 if *gram_MSG is
not large enough to hold the message. In that case, also set
*gram_MSG_ALLOC to the required number of bytes. Return 2 if the
required number of bytes is too large to store. */
static int
gram_syntax_error (gram_SIZE_T *gram_msg_alloc, char **gram_msg,
gram_type_int16 *gram_ssp, int gram_token)
{
gram_SIZE_T gram_size0 = gram_tnamerr (0, gram_tname[gram_token]);
gram_SIZE_T gram_size = gram_size0;
gram_SIZE_T gram_size1;
enum { gram_ERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Internationalized format string. */
const char *gram_format = 0;
/* Arguments of gram_format. */
char const *gram_arg[gram_ERROR_VERBOSE_ARGS_MAXIMUM];
/* Number of reported tokens (one for the "unexpected", one per
"expected"). */
int gram_count = 0;
/* There are many possibilities here to consider:
- Assume gram_FAIL is not used. It's too flawed to consider. See
for details. gram_ERROR is fine as it does not invoke this
function.
- If this state is a consistent state with a default action, then
the only way this function was invoked is if the default action
is an error action. In that case, don't check for expected
tokens because there are none.
- The only way there can be no lookahead present (in gram_char) is if
this state is a consistent state with a default action. Thus,
detecting the absence of a lookahead is sufficient to determine
that there is no unexpected or expected token to report. In that
case, just report a simple "syntax error".
- Don't assume there isn't a lookahead just because this state is a
consistent state with a default action. There might have been a
previous inconsistent state, consistent state with a non-default
action, or user semantic action that manipulated gram_char.
- Of course, the expected token list depends on states to have
correct lookahead information, and it depends on the parser not
to perform extra reductions after fetching a lookahead from the
scanner and before detecting a syntax error. Thus, state merging
(from LALR or IELR) and default reductions corrupt the expected
token list. However, the list is correct for canonical LR with
one exception: it will still contain any token that will not be
accepted due to an error action in a later state.
*/
if (gram_token != gram_EMPTY)
{
int gram_n = gram_pact[*gram_ssp];
gram_arg[gram_count++] = gram_tname[gram_token];
if (!gram_pact_value_is_default (gram_n))
{
/* Start gram_X at -gram_N if negative to avoid negative indexes in
gram_CHECK. In other words, skip the first -gram_N actions for
this state because they are default actions. */
int gram_xbegin = gram_n < 0 ? -gram_n : 0;
/* Stay within bounds of both gram_check and gram_tname. */
int gram_checklim = gram_LAST - gram_n + 1;
int gram_xend = gram_checklim < gram_NTOKENS ? gram_checklim : gram_NTOKENS;
int gram_x;
for (gram_x = gram_xbegin; gram_x < gram_xend; ++gram_x)
if (gram_check[gram_x + gram_n] == gram_x && gram_x != gram_TERROR
&& !gram_table_value_is_error (gram_table[gram_x + gram_n]))
{
if (gram_count == gram_ERROR_VERBOSE_ARGS_MAXIMUM)
{
gram_count = 1;
gram_size = gram_size0;
break;
}
gram_arg[gram_count++] = gram_tname[gram_x];
gram_size1 = gram_size + gram_tnamerr (0, gram_tname[gram_x]);
if (! (gram_size <= gram_size1
&& gram_size1 <= gram_STACK_ALLOC_MAXIMUM))
return 2;
gram_size = gram_size1;
}
}
}
switch (gram_count)
{
# define gram_CASE_(N, S) \
case N: \
gram_format = S; \
break
gram_CASE_(0, gram__("syntax error"));
gram_CASE_(1, gram__("syntax error, unexpected %s"));
gram_CASE_(2, gram__("syntax error, unexpected %s, expecting %s"));
gram_CASE_(3, gram__("syntax error, unexpected %s, expecting %s or %s"));
gram_CASE_(4, gram__("syntax error, unexpected %s, expecting %s or %s or %s"));
gram_CASE_(5, gram__("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
# undef gram_CASE_
}
gram_size1 = gram_size + gram_strlen (gram_format);
if (! (gram_size <= gram_size1 && gram_size1 <= gram_STACK_ALLOC_MAXIMUM))
return 2;
gram_size = gram_size1;
if (*gram_msg_alloc < gram_size)
{
*gram_msg_alloc = 2 * gram_size;
if (! (gram_size <= *gram_msg_alloc
&& *gram_msg_alloc <= gram_STACK_ALLOC_MAXIMUM))
*gram_msg_alloc = gram_STACK_ALLOC_MAXIMUM;
return 1;
}
/* Avoid sprintf, as that infringes on the user's name space.
Don't have undefined behavior even if the translation
produced a string with the wrong number of "%s"s. */
{
char *gram_p = *gram_msg;
int gram_i = 0;
while ((*gram_p = *gram_format) != '\0')
if (*gram_p == '%' && gram_format[1] == 's' && gram_i < gram_count)
{
gram_p += gram_tnamerr (gram_p, gram_arg[gram_i++]);
gram_format += 2;
}
else
{
gram_p++;
gram_format++;
}
}
return 0;
}
#endif /* gram_ERROR_VERBOSE */
/*-----------------------------------------------.
| Release the memory associated to this symbol. |
`-----------------------------------------------*/
/*ARGSUSED*/
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
gram_destruct (const char *gram_msg, int gram_type, gram_STYPE *gram_valuep)
#else
static void
gram_destruct (gram_msg, gram_type, gram_valuep)
const char *gram_msg;
int gram_type;
gram_STYPE *gram_valuep;
#endif
{
gram_USE (gram_valuep);
if (!gram_msg)
gram_msg = "Deleting";
gram__SYMBOL_PRINT (gram_msg, gram_type, gram_valuep, gram_locationp);
switch (gram_type)
{
default:
break;
}
}
/* Prevent warnings from -Wmissing-prototypes. */
#ifdef gram_PARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int gram_parse (void *gram_PARSE_PARAM);
#else
int gram_parse ();
#endif
#else /* ! gram_PARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int gram_parse (void);
#else
int gram_parse ();
#endif
#endif /* ! gram_PARSE_PARAM */
/* The lookahead symbol. */
int gram_char;
/* The semantic value of the lookahead symbol. */
gram_STYPE gram_lval;
/* Number of syntax errors so far. */
int gram_nerrs;
/*----------.
| gram_parse. |
`----------*/
#ifdef gram_PARSE_PARAM
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
int
gram_parse (void *gram_PARSE_PARAM)
#else
int
gram_parse (gram_PARSE_PARAM)
void *gram_PARSE_PARAM;
#endif
#else /* ! gram_PARSE_PARAM */
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
int
gram_parse (void)
#else
int
gram_parse ()
#endif
#endif
{
int gram_state;
/* Number of tokens to shift before error messages enabled. */
int gram_errstatus;
/* The stacks and their tools:
`gram_ss': related to states.
`gram_vs': related to semantic values.
Refer to the stacks thru separate pointers, to allow gram_overflow
to reallocate them elsewhere. */
/* The state stack. */
gram_type_int16 gram_ssa[gram_INITDEPTH];
gram_type_int16 *gram_ss;
gram_type_int16 *gram_ssp;
/* The semantic value stack. */
gram_STYPE gram_vsa[gram_INITDEPTH];
gram_STYPE *gram_vs;
gram_STYPE *gram_vsp;
gram_SIZE_T gram_stacksize;
int gram_n;
int gram_result;
/* Lookahead token as an internal (translated) token number. */
int gram_token;
/* The variables used to return semantic value and location from the
action routines. */
gram_STYPE gram_val;
#if gram_ERROR_VERBOSE
/* Buffer for error messages, and its allocated size. */
char gram_msgbuf[128];
char *gram_msg = gram_msgbuf;
gram_SIZE_T gram_msg_alloc = sizeof gram_msgbuf;
#endif
#define gram_POPSTACK(N) (gram_vsp -= (N), gram_ssp -= (N))
/* The number of symbols on the RHS of the reduced rule.
Keep to zero when no symbol should be popped. */
int gram_len = 0;
gram_token = 0;
gram_ss = gram_ssa;
gram_vs = gram_vsa;
gram_stacksize = gram_INITDEPTH;
gram_DPRINTF ((stderr, "Starting parse\n"));
gram_state = 0;
gram_errstatus = 0;
gram_nerrs = 0;
gram_char = gram_EMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
gram_ssp = gram_ss;
gram_vsp = gram_vs;
goto gram_setstate;
/*------------------------------------------------------------.
| gram_newstate -- Push a new state, which is found in gram_state. |
`------------------------------------------------------------*/
gram_newstate:
/* In all cases, when you get here, the value and location stacks
have just been pushed. So pushing a state here evens the stacks. */
gram_ssp++;
gram_setstate:
*gram_ssp = gram_state;
if (gram_ss + gram_stacksize - 1 <= gram_ssp)
{
/* Get the current used size of the three stacks, in elements. */
gram_SIZE_T gram_size = gram_ssp - gram_ss + 1;
#ifdef gram_overflow
{
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
memory. */
gram_STYPE *gram_vs1 = gram_vs;
gram_type_int16 *gram_ss1 = gram_ss;
/* Each stack pointer address is followed by the size of the
data in use in that stack, in bytes. This used to be a
conditional around just the two extra args, but that might
be undefined if gram_overflow is a macro. */
gram_overflow (gram__("memory exhausted"),
&gram_ss1, gram_size * sizeof (*gram_ssp),
&gram_vs1, gram_size * sizeof (*gram_vsp),
&gram_stacksize);
gram_ss = gram_ss1;
gram_vs = gram_vs1;
}
#else /* no gram_overflow */
# ifndef gram_STACK_RELOCATE
goto gram_exhaustedlab;
# else
/* Extend the stack our own way. */
if (gram_MAXDEPTH <= gram_stacksize)
goto gram_exhaustedlab;
gram_stacksize *= 2;
if (gram_MAXDEPTH < gram_stacksize)
gram_stacksize = gram_MAXDEPTH;
{
gram_type_int16 *gram_ss1 = gram_ss;
union gram_alloc *gram_ptr =
(union gram_alloc *) gram_STACK_ALLOC (gram_STACK_BYTES (gram_stacksize));
if (! gram_ptr)
goto gram_exhaustedlab;
gram_STACK_RELOCATE (gram_ss_alloc, gram_ss);
gram_STACK_RELOCATE (gram_vs_alloc, gram_vs);
# undef gram_STACK_RELOCATE
if (gram_ss1 != gram_ssa)
gram_STACK_FREE (gram_ss1);
}
# endif
#endif /* no gram_overflow */
gram_ssp = gram_ss + gram_size - 1;
gram_vsp = gram_vs + gram_size - 1;
gram_DPRINTF ((stderr, "Stack size increased to %lu\n",
(unsigned long int) gram_stacksize));
if (gram_ss + gram_stacksize - 1 <= gram_ssp)
gram_ABORT;
}
gram_DPRINTF ((stderr, "Entering state %d\n", gram_state));
if (gram_state == gram_FINAL)
gram_ACCEPT;
goto gram_backup;
/*-----------.
| gram_backup. |
`-----------*/
gram_backup:
/* Do appropriate processing given the current state. Read a
lookahead token if we need one and don't already have one. */
/* First try to decide what to do without reference to lookahead token. */
gram_n = gram_pact[gram_state];
if (gram_pact_value_is_default (gram_n))
goto gram_default;
/* Not known => get a lookahead token if don't already have one. */
/* gram_CHAR is either gram_EMPTY or gram_EOF or a valid lookahead symbol. */
if (gram_char == gram_EMPTY)
{
gram_DPRINTF ((stderr, "Reading a token: "));
gram_char = gram_LEX;
}
if (gram_char <= gram_EOF)
{
gram_char = gram_token = gram_EOF;
gram_DPRINTF ((stderr, "Now at end of input.\n"));
}
else
{
gram_token = gram_TRANSLATE (gram_char);
gram__SYMBOL_PRINT ("Next token is", gram_token, &gram_lval, &gram_lloc);
}
/* If the proper action on seeing token gram_TOKEN is to reduce or to
detect an error, take that action. */
gram_n += gram_token;
if (gram_n < 0 || gram_LAST < gram_n || gram_check[gram_n] != gram_token)
goto gram_default;
gram_n = gram_table[gram_n];
if (gram_n <= 0)
{
if (gram_table_value_is_error (gram_n))
goto gram_errlab;
gram_n = -gram_n;
goto gram_reduce;
}
/* Count tokens shifted since error; after three, turn off error
status. */
if (gram_errstatus)
gram_errstatus--;
/* Shift the lookahead token. */
gram__SYMBOL_PRINT ("Shifting", gram_token, &gram_lval, &gram_lloc);
/* Discard the shifted token. */
gram_char = gram_EMPTY;
gram_state = gram_n;
*++gram_vsp = gram_lval;
goto gram_newstate;
/*-----------------------------------------------------------.
| gram_default -- do the default action for the current state. |
`-----------------------------------------------------------*/
gram_default:
gram_n = gram_defact[gram_state];
if (gram_n == 0)
goto gram_errlab;
goto gram_reduce;
/*-----------------------------.
| gram_reduce -- Do a reduction. |
`-----------------------------*/
gram_reduce:
/* gram_n is the number of a rule to reduce with. */
gram_len = gram_r2[gram_n];
/* If gram_LEN is nonzero, implement the default value of the action:
`$$ = $1'.
Otherwise, the following line sets gram_VAL to garbage.
This behavior is undocumented and Bison
users should not rely upon it. Assigning to gram_VAL
unconditionally makes the parser a bit smaller, and it avoids a
GCC warning that gram_VAL may be used uninitialized. */
gram_val = gram_vsp[1-gram_len];
gram__REDUCE_PRINT (gram_n);
switch (gram_n)
{
case 2:
/* Line 1806 of yacc.c */
#line 298 "codegen/gram.y"
{
result = (gram_vsp[(1) - (1)].lv_node);
}
break;
case 3:
/* Line 1806 of yacc.c */
#line 305 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("declaration");
node_push_back((gram_val.lv_node), (gram_vsp[(1) - (2)].lv_node));
node_push_back((gram_val.lv_node), (gram_vsp[(2) - (2)].lv_node));
}
break;
case 4:
/* Line 1806 of yacc.c */
#line 311 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("declaration");
node_push_back((gram_val.lv_node), (gram_vsp[(1) - (3)].lv_node));
node_push_back((gram_val.lv_node), (gram_vsp[(2) - (3)].lv_node));
node_push_back((gram_val.lv_node), (gram_vsp[(3) - (3)].lv_node));
}
break;
case 5:
/* Line 1806 of yacc.c */
#line 321 "codegen/gram.y"
{ (gram_val.lv_node) = node_new_literal(";"); }
break;
case 6:
/* Line 1806 of yacc.c */
#line 323 "codegen/gram.y"
{ (gram_val.lv_node) = node_new_literal(";"); }
break;
case 7:
/* Line 1806 of yacc.c */
#line 328 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("declaration_specifiers");
node_push_back((gram_val.lv_node), (gram_vsp[(1) - (1)].lv_node));
}
break;
case 8:
/* Line 1806 of yacc.c */
#line 333 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("declaration_specifiers");
node_push_back((gram_val.lv_node), (gram_vsp[(1) - (2)].lv_node));
node_push_back((gram_val.lv_node), (gram_vsp[(2) - (2)].lv_node));
}
break;
case 9:
/* Line 1806 of yacc.c */
#line 339 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("declaration_specifiers");
node_push_back((gram_val.lv_node), (gram_vsp[(1) - (1)].lv_node));
}
break;
case 10:
/* Line 1806 of yacc.c */
#line 344 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("declaration_specifiers");
node_push_back((gram_val.lv_node), (gram_vsp[(1) - (2)].lv_node));
node_push_back((gram_val.lv_node), (gram_vsp[(2) - (2)].lv_node));
}
break;
case 11:
/* Line 1806 of yacc.c */
#line 350 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("declaration_specifiers");
node_push_back((gram_val.lv_node), (gram_vsp[(1) - (1)].lv_node));
}
break;
case 12:
/* Line 1806 of yacc.c */
#line 355 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("declaration_specifiers");
node_push_back((gram_val.lv_node), (gram_vsp[(1) - (2)].lv_node));
node_push_back((gram_val.lv_node), (gram_vsp[(2) - (2)].lv_node));
}
break;
case 13:
/* Line 1806 of yacc.c */
#line 364 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("init_declarator_list");
node_push_back((gram_val.lv_node), (gram_vsp[(1) - (1)].lv_node));
}
break;
case 14:
/* Line 1806 of yacc.c */
#line 369 "codegen/gram.y"
{
(gram_val.lv_node) = (gram_vsp[(1) - (3)].lv_node);
node_push_back((gram_val.lv_node), node_new_literal(","));
node_push_back((gram_val.lv_node), (gram_vsp[(3) - (3)].lv_node));
}
break;
case 15:
/* Line 1806 of yacc.c */
#line 378 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("init_declarator");
node_push_back((gram_val.lv_node), (gram_vsp[(1) - (1)].lv_node));
}
break;
case 16:
/* Line 1806 of yacc.c */
#line 386 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("init_declarator");
node_push_back((gram_val.lv_node), node_new_literal("typedef"));
}
break;
case 17:
/* Line 1806 of yacc.c */
#line 391 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("init_declarator");
node_push_back((gram_val.lv_node), node_new_literal("extern"));
}
break;
case 18:
/* Line 1806 of yacc.c */
#line 396 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("init_declarator");
node_push_back((gram_val.lv_node), node_new_literal("static"));
}
break;
case 19:
/* Line 1806 of yacc.c */
#line 401 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("init_declarator");
node_push_back((gram_val.lv_node), node_new_literal("auto"));
}
break;
case 20:
/* Line 1806 of yacc.c */
#line 406 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("init_declarator");
node_push_back((gram_val.lv_node), node_new_literal("register"));
}
break;
case 21:
/* Line 1806 of yacc.c */
#line 414 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("type_specifier");
node_push_back((gram_val.lv_node), node_new_literal("void"));
}
break;
case 22:
/* Line 1806 of yacc.c */
#line 419 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("type_specifier");
node_push_back((gram_val.lv_node), node_new_literal("char"));
}
break;
case 23:
/* Line 1806 of yacc.c */
#line 424 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("type_specifier");
node_push_back((gram_val.lv_node), node_new_literal("short"));
}
break;
case 24:
/* Line 1806 of yacc.c */
#line 429 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("type_specifier");
node_push_back((gram_val.lv_node), node_new_literal("int"));
}
break;
case 25:
/* Line 1806 of yacc.c */
#line 434 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("type_specifier");
node_push_back((gram_val.lv_node), node_new_literal("long"));
}
break;
case 26:
/* Line 1806 of yacc.c */
#line 439 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("type_specifier");
node_push_back((gram_val.lv_node), node_new_literal("float"));
}
break;
case 27:
/* Line 1806 of yacc.c */
#line 444 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("type_specifier");
node_push_back((gram_val.lv_node), node_new_literal("double"));
}
break;
case 28:
/* Line 1806 of yacc.c */
#line 449 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("type_specifier");
node_push_back((gram_val.lv_node), node_new_literal("signed"));
}
break;
case 29:
/* Line 1806 of yacc.c */
#line 454 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("type_specifier");
node_push_back((gram_val.lv_node), node_new_literal("unsigned"));
}
break;
case 30:
/* Line 1806 of yacc.c */
#line 459 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("type_specifier");
node_push_back((gram_val.lv_node), (gram_vsp[(1) - (1)].lv_node));
}
break;
case 31:
/* Line 1806 of yacc.c */
#line 464 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("type_specifier");
node_push_back((gram_val.lv_node), (gram_vsp[(1) - (1)].lv_node));
}
break;
case 32:
/* Line 1806 of yacc.c */
#line 469 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("type_specifier");
node_push_back((gram_val.lv_node), node_new_literal((gram_vsp[(1) - (1)].lv_string)));
}
break;
case 33:
/* Line 1806 of yacc.c */
#line 477 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("struct_or_union_specifier");
node_push_back((gram_val.lv_node), (gram_vsp[(1) - (2)].lv_node));
node_push_back((gram_val.lv_node), node_new_literal((gram_vsp[(2) - (2)].lv_string)));
}
break;
case 34:
/* Line 1806 of yacc.c */
#line 486 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("struct_or_union");
node_push_back((gram_val.lv_node), node_new_literal("struct"));
}
break;
case 35:
/* Line 1806 of yacc.c */
#line 491 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("struct_or_union");
node_push_back((gram_val.lv_node), node_new_literal("union"));
}
break;
case 36:
/* Line 1806 of yacc.c */
#line 499 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("enum_specifier");
node_push_back((gram_val.lv_node), node_new_literal("enum"));
node_push_back((gram_val.lv_node), node_new_literal((gram_vsp[(2) - (2)].lv_string)));
}
break;
case 37:
/* Line 1806 of yacc.c */
#line 508 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("type_qualifier");
node_push_back((gram_val.lv_node), node_new_literal("const"));
}
break;
case 38:
/* Line 1806 of yacc.c */
#line 513 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("type_qualifier");
node_push_back((gram_val.lv_node), node_new_literal("volatile"));
}
break;
case 39:
/* Line 1806 of yacc.c */
#line 521 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("declarator");
node_push_back((gram_val.lv_node), (gram_vsp[(1) - (2)].lv_node));
node_push_back((gram_val.lv_node), (gram_vsp[(2) - (2)].lv_node));
}
break;
case 40:
/* Line 1806 of yacc.c */
#line 527 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("declarator");
node_push_back((gram_val.lv_node), (gram_vsp[(1) - (1)].lv_node));
}
break;
case 41:
/* Line 1806 of yacc.c */
#line 535 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("direct_declarator");
node_push_back((gram_val.lv_node), node_new_literal((gram_vsp[(1) - (1)].lv_string)));
}
break;
case 42:
/* Line 1806 of yacc.c */
#line 540 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("direct_declarator");
node_push_back((gram_val.lv_node), node_new_literal("("));
node_push_back((gram_val.lv_node), (gram_vsp[(2) - (3)].lv_node));
node_push_back((gram_val.lv_node), node_new_literal(")"));
}
break;
case 43:
/* Line 1806 of yacc.c */
#line 547 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("direct_declarator");
node_push_back((gram_val.lv_node), (gram_vsp[(1) - (3)].lv_node));
node_push_back((gram_val.lv_node), node_new_literal("["));
node_push_back((gram_val.lv_node), node_new_literal("]"));
}
break;
case 44:
/* Line 1806 of yacc.c */
#line 554 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("direct_declarator");
node_push_back((gram_val.lv_node), (gram_vsp[(1) - (4)].lv_node));
node_push_back((gram_val.lv_node), node_new_literal("("));
node_push_back((gram_val.lv_node), (gram_vsp[(3) - (4)].lv_node));
node_push_back((gram_val.lv_node), node_new_literal(")"));
}
break;
case 45:
/* Line 1806 of yacc.c */
#line 562 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("direct_declarator");
node_push_back((gram_val.lv_node), (gram_vsp[(1) - (3)].lv_node));
node_push_back((gram_val.lv_node), node_new_literal("("));
node_push_back((gram_val.lv_node), node_new_literal(")"));
}
break;
case 46:
/* Line 1806 of yacc.c */
#line 572 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("pointer");
node_push_back((gram_val.lv_node), node_new_literal("*"));
}
break;
case 47:
/* Line 1806 of yacc.c */
#line 577 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("pointer");
node_push_back((gram_val.lv_node), node_new_literal("*"));
node_push_back((gram_val.lv_node), (gram_vsp[(2) - (2)].lv_node));
}
break;
case 48:
/* Line 1806 of yacc.c */
#line 583 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("pointer");
node_push_back((gram_val.lv_node), node_new_literal("*"));
node_push_back((gram_val.lv_node), (gram_vsp[(2) - (2)].lv_node));
}
break;
case 49:
/* Line 1806 of yacc.c */
#line 589 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("pointer");
node_push_back((gram_val.lv_node), node_new_literal("*"));
node_push_back((gram_val.lv_node), (gram_vsp[(2) - (3)].lv_node));
node_push_back((gram_val.lv_node), (gram_vsp[(3) - (3)].lv_node));
}
break;
case 50:
/* Line 1806 of yacc.c */
#line 599 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("type_qualifier_list");
node_push_back((gram_val.lv_node), (gram_vsp[(1) - (1)].lv_node));
}
break;
case 51:
/* Line 1806 of yacc.c */
#line 604 "codegen/gram.y"
{
(gram_val.lv_node) = (gram_vsp[(1) - (2)].lv_node);
node_push_back((gram_val.lv_node), (gram_vsp[(2) - (2)].lv_node));
}
break;
case 52:
/* Line 1806 of yacc.c */
#line 612 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("parameter_type_list");
node_push_back((gram_val.lv_node), node_new_literal("void"));
}
break;
case 53:
/* Line 1806 of yacc.c */
#line 617 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("parameter_type_list");
node_push_back((gram_val.lv_node), (gram_vsp[(1) - (1)].lv_node));
}
break;
case 54:
/* Line 1806 of yacc.c */
#line 622 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("parameter_type_list");
node_push_back((gram_val.lv_node), node_new_literal(","));
node_push_back((gram_val.lv_node), node_new_literal("..."));
}
break;
case 55:
/* Line 1806 of yacc.c */
#line 631 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("parameter_list");
node_push_back((gram_val.lv_node), (gram_vsp[(1) - (1)].lv_node));
}
break;
case 56:
/* Line 1806 of yacc.c */
#line 636 "codegen/gram.y"
{
(gram_val.lv_node) = (gram_vsp[(1) - (3)].lv_node);
node_push_back((gram_val.lv_node), node_new_literal(","));
node_push_back((gram_val.lv_node), (gram_vsp[(3) - (3)].lv_node));
}
break;
case 57:
/* Line 1806 of yacc.c */
#line 645 "codegen/gram.y"
{
(gram_val.lv_node) = node_new("parameter_declaration");
node_push_back((gram_val.lv_node), (gram_vsp[(1) - (2)].lv_node));
node_push_back((gram_val.lv_node), (gram_vsp[(2) - (2)].lv_node));
}
break;
/* Line 1806 of yacc.c */
#line 2281 "y.tab.c"
default: break;
}
/* User semantic actions sometimes alter gram_char, and that requires
that gram_token be updated with the new translation. We take the
approach of translating immediately before every use of gram_token.
One alternative is translating here after every semantic action,
but that translation would be missed if the semantic action invokes
gram_ABORT, gram_ACCEPT, or gram_ERROR immediately after altering gram_char or
if it invokes gram_BACKUP. In the case of gram_ABORT or gram_ACCEPT, an
incorrect destructor might then be invoked immediately. In the
case of gram_ERROR or gram_BACKUP, subsequent parser actions might lead
to an incorrect destructor call or verbose syntax error message
before the lookahead is translated. */
gram__SYMBOL_PRINT ("-> $$ =", gram_r1[gram_n], &gram_val, &gram_loc);
gram_POPSTACK (gram_len);
gram_len = 0;
gram__STACK_PRINT (gram_ss, gram_ssp);
*++gram_vsp = gram_val;
/* Now `shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
gram_n = gram_r1[gram_n];
gram_state = gram_pgoto[gram_n - gram_NTOKENS] + *gram_ssp;
if (0 <= gram_state && gram_state <= gram_LAST && gram_check[gram_state] == *gram_ssp)
gram_state = gram_table[gram_state];
else
gram_state = gram_defgoto[gram_n - gram_NTOKENS];
goto gram_newstate;
/*------------------------------------.
| gram_errlab -- here on detecting error |
`------------------------------------*/
gram_errlab:
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
gram_token = gram_char == gram_EMPTY ? gram_EMPTY : gram_TRANSLATE (gram_char);
/* If not already recovering from an error, report this error. */
if (!gram_errstatus)
{
++gram_nerrs;
#if ! gram_ERROR_VERBOSE
gram_error (gram__("syntax error"));
#else
# define gram_SYNTAX_ERROR gram_syntax_error (&gram_msg_alloc, &gram_msg, \
gram_ssp, gram_token)
{
char const *gram_msgp = gram__("syntax error");
int gram_syntax_error_status;
gram_syntax_error_status = gram_SYNTAX_ERROR;
if (gram_syntax_error_status == 0)
gram_msgp = gram_msg;
else if (gram_syntax_error_status == 1)
{
if (gram_msg != gram_msgbuf)
gram_STACK_FREE (gram_msg);
gram_msg = (char *) gram_STACK_ALLOC (gram_msg_alloc);
if (!gram_msg)
{
gram_msg = gram_msgbuf;
gram_msg_alloc = sizeof gram_msgbuf;
gram_syntax_error_status = 2;
}
else
{
gram_syntax_error_status = gram_SYNTAX_ERROR;
gram_msgp = gram_msg;
}
}
gram_error (gram_msgp);
if (gram_syntax_error_status == 2)
goto gram_exhaustedlab;
}
# undef gram_SYNTAX_ERROR
#endif
}
if (gram_errstatus == 3)
{
/* If just tried and failed to reuse lookahead token after an
error, discard it. */
if (gram_char <= gram_EOF)
{
/* Return failure if at end of input. */
if (gram_char == gram_EOF)
gram_ABORT;
}
else
{
gram_destruct ("Error: discarding",
gram_token, &gram_lval);
gram_char = gram_EMPTY;
}
}
/* Else will try to reuse lookahead token after shifting the error
token. */
goto gram_errlab1;
/*---------------------------------------------------.
| gram_errorlab -- error raised explicitly by gram_ERROR. |
`---------------------------------------------------*/
gram_errorlab:
/* Pacify compilers like GCC when the user code never invokes
gram_ERROR and the label gram_errorlab therefore never appears in user
code. */
if (/*CONSTCOND*/ 0)
goto gram_errorlab;
/* Do not reclaim the symbols of the rule which action triggered
this gram_ERROR. */
gram_POPSTACK (gram_len);
gram_len = 0;
gram__STACK_PRINT (gram_ss, gram_ssp);
gram_state = *gram_ssp;
goto gram_errlab1;
/*-------------------------------------------------------------.
| gram_errlab1 -- common code for both syntax error and gram_ERROR. |
`-------------------------------------------------------------*/
gram_errlab1:
gram_errstatus = 3; /* Each real token shifted decrements this. */
for (;;)
{
gram_n = gram_pact[gram_state];
if (!gram_pact_value_is_default (gram_n))
{
gram_n += gram_TERROR;
if (0 <= gram_n && gram_n <= gram_LAST && gram_check[gram_n] == gram_TERROR)
{
gram_n = gram_table[gram_n];
if (0 < gram_n)
break;
}
}
/* Pop the current state because it cannot handle the error token. */
if (gram_ssp == gram_ss)
gram_ABORT;
gram_destruct ("Error: popping",
gram_stos[gram_state], gram_vsp);
gram_POPSTACK (1);
gram_state = *gram_ssp;
gram__STACK_PRINT (gram_ss, gram_ssp);
}
*++gram_vsp = gram_lval;
/* Shift the error token. */
gram__SYMBOL_PRINT ("Shifting", gram_stos[gram_n], gram_vsp, gram_lsp);
gram_state = gram_n;
goto gram_newstate;
/*-------------------------------------.
| gram_acceptlab -- gram_ACCEPT comes here. |
`-------------------------------------*/
gram_acceptlab:
gram_result = 0;
goto gram_return;
/*-----------------------------------.
| gram_abortlab -- gram_ABORT comes here. |
`-----------------------------------*/
gram_abortlab:
gram_result = 1;
goto gram_return;
#if !defined(gram_overflow) || gram_ERROR_VERBOSE
/*-------------------------------------------------.
| gram_exhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
gram_exhaustedlab:
gram_error (gram__("memory exhausted"));
gram_result = 2;
/* Fall through. */
#endif
gram_return:
if (gram_char != gram_EMPTY)
{
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
gram_token = gram_TRANSLATE (gram_char);
gram_destruct ("Cleanup: discarding lookahead",
gram_token, &gram_lval);
}
/* Do not reclaim the symbols of the rule which action triggered
this gram_ABORT or gram_ACCEPT. */
gram_POPSTACK (gram_len);
gram__STACK_PRINT (gram_ss, gram_ssp);
while (gram_ssp != gram_ss)
{
gram_destruct ("Cleanup: popping",
gram_stos[*gram_ssp], gram_vsp);
gram_POPSTACK (1);
}
#ifndef gram_overflow
if (gram_ss != gram_ssa)
gram_STACK_FREE (gram_ss);
#endif
#if gram_ERROR_VERBOSE
if (gram_msg != gram_msgbuf)
gram_STACK_FREE (gram_msg);
#endif
/* Make sure gram_ID is used. */
return gram_ID (gram_result);
}