/* original parser id follows */
/* parse_sccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93" */
/* (use parse_MAJOR/parse_MINOR for ifdefs dependent on parser version) */

#define parse_BYACC 1
#define parse_MAJOR 1
#define parse_MINOR 9

#define parse_EMPTY        (-1)
#define parse_clearin      (parse_char = parse_EMPTY)
#define parse_errok        (parse_errflag = 0)
#define parse_RECOVERING() (parse_errflag != 0)
#define parse_ENOMEM       (-2)
#define parse_EOF          0
#undef parse_BTYACC
#define parse_BTYACC 0
#define parse_DEBUGSTR parse_PREFIX "debug"
#define parse_PREFIX "parse_"

#define parse_PURE 0

#line 23 "fmtgen/parse.y"

#include <common/ac/ctype.h>
#include <common/ac/stdio.h>
#include <common/ac/stdlib.h>
#include <common/ac/string.h>

#include <common/error.h>
#include <common/mem.h>
#include <common/progname.h>
#include <common/str.h>
#include <common/str_list.h>
#include <common/symtab.h>
#include <common/trace.h>
#include <fmtgen/indent.h>
#include <fmtgen/lex.h>
#include <fmtgen/parse.h>
#include <fmtgen/type/boolean.h>
#include <fmtgen/type/enumeration.h>
#include <fmtgen/type/integer.h>
#include <fmtgen/type/list.h>
#include <fmtgen/type/real.h>
#include <fmtgen/type/string.h>
#include <fmtgen/type/structure.h>
#include <fmtgen/type/time.h>

#ifdef DEBUG
#define parse_DEBUG 1
extern int parse_debug;
#define printf lex_debug_printf
#define fprintf lex_debug_fprintf
#endif

#ifdef parse_STYPE
#undef  parse_STYPE_IS_DECLARED
#define parse_STYPE_IS_DECLARED 1
#endif
#ifndef parse_STYPE_IS_DECLARED
#define parse_STYPE_IS_DECLARED 1
#line 72 "fmtgen/parse.y"
typedef union
{
    string_ty       *lv_string;
    long            lv_integer;
    type *lv_type;
} parse_STYPE;
#endif /* !parse_STYPE_IS_DECLARED */
#line 84 "fmtgen/parse.y"

struct name_ty
{
    name_ty         *parent;
    string_ty       *name_short;
    string_ty       *name_long;
    type *name_type;
};

static name_ty	*current;
static size_t	emit_length;
static size_t	emit_length_max;
static type **emit_list;
static int	time_used;
static symtab_ty *typedef_symtab;
static string_list_ty	initialize;


static void
push_name(string_ty *s)
{
    name_ty         *np;

    trace(("push_name(s = \"%s\")\n{\n", s->str_text));
    np = (name_ty *)mem_alloc(sizeof(name_ty));
    np->name_short = str_copy(s);
    np->name_long =
	str_format("%s_%s", current->name_long->str_text, s->str_text);
    np->parent = current;
    np->name_type = 0;
    current = np;
    trace(("}\n"));
}


static void
push_name_abs(string_ty *s)
{
    name_ty         *np;

    trace(("push_name_abs(s = \"%s\")\n{\n", s->str_text));
    np = (name_ty *)mem_alloc(sizeof(name_ty));
    np->name_short = str_copy(s);
    np->name_long = str_copy(s);
    np->parent = current;
    np->name_type = 0;
    current = np;
    trace(("}\n"));
}


static void
pop_name(void)
{
    name_ty         *np;

    trace(("pop_name()\n{\n"));
    np = current;
    current = np->parent;
    str_free(np->name_short);
    str_free(np->name_long);
    mem_free(np);
    trace(("}\n"));
}


static void
define_type(type *defined_type)
{
    trace(("define_type(defined_type = %08lX)\n{\n", (long)defined_type));
    if (emit_length >= emit_length_max)
    {
	size_t new_emit_length_max = emit_length_max * 2 + 8;
	type **new_emit_list = new type * [new_emit_length_max];
	for (size_t j = 0; j < emit_length; ++j)
	    new_emit_list[j] = emit_list[j];
	delete [] emit_list;
	emit_list = new_emit_list;
	emit_length_max = new_emit_length_max;
    }
    emit_list[emit_length++] = defined_type;
    trace(("}\n"));
}


static const char *
base_name(const char *s)
{
    static char     buffer[256];
    const char      *cp;
    char            *bp;

    cp = strrchr(s, '/');
    if (cp)
	++cp;
    else
	cp = s;
    strendcpy(buffer, cp, buffer + sizeof(buffer));
    bp = strrchr(buffer, '.');
    if (bp)
	*bp = 0;
    for (bp = buffer; *bp; ++bp)
    {
	if (!isalnum((unsigned char)*bp))
    	    *bp = '_';
    }
    return buffer;
}


static const char *
calculate_include_define_name(const char *s)
{
    char            *bp;
    static char     buffer[256];

    bp = buffer;
    while (*s && bp < ENDOF(buffer) - 1)
    {
	unsigned char   c;

	c = *s++;
	if (!c)
	    break;
	if (islower(c))
	    c = toupper(c);
	else if (!isalnum(c))
	    c = '_';
	*bp++ = c;
    }
    *bp = 0;
    return buffer;
}


static void
this_file_is_generated(const char *definition_file)
{
    /*
     * DO NOT insert a timestamp in the generated files, it needlessly
     * changes the fingerprint.  This, in turn, causes cook to cook
     * too much, compiling several hundred files which do not need to
     * be compiled.
     */
    indent_printf
    (
	"//\n"
	"// This file is generated by %s from \"%s\".\n"
	"// If you want to change the contents of this file\n"
	"// you need to edit %s\n"
	"// or you need to enhance %s.\n"
	"//\n",
	progname_get(),
	definition_file,
	definition_file,
	progname_get()
    );
}


static void
generate_include_file(const char *include_file, const char *definition_file)
{
    const char      *cp1;
    size_t	    j;
    string_ty	    *s;

    trace(("generate_include_file(h = \"%s\")\n{\n", include_file));
    s = current->name_long;
    indent_open(include_file);
    this_file_is_generated(definition_file);
    cp1 = calculate_include_define_name(include_file);
    indent_putchar('\n');
    indent_printf("#ifndef %s\n", cp1);
    indent_printf("#define %s\n", cp1);
    indent_putchar('\n');
    if (time_used)
    {
	indent_printf("#include <common/ac/time.h>\n");
	indent_putchar('\n');
    }
    indent_printf("#include <common/str.h>\n");
    indent_printf("#include <libaegis/output.h>\n");
    indent_printf("#include <libaegis/meta_lex.h>\n");
    indent_printf("#include <libaegis/meta_parse.h>\n");
    indent_printf("#include <libaegis/meta_type.h>\n");
    indent_putchar('\n');
    indent_printf("class nstring; // forward\n");
    for (j = 0; j < emit_length; ++j)
	emit_list[j]->gen_include();
    indent_putchar('\n');
    indent_printf("/**\n");
    indent_printf("  * The %s_write_file function is used to\n", s->str_text);
    indent_printf("  * write %s meta data to the named file.\n", s->str_text);
    indent_printf("  *\n");
    indent_printf("  * @param filename\n");
    indent_printf("  *     The name of the file to be written.\n");
    indent_printf("  * @param value\n");
    indent_printf("  *     The value of the meta-data to be written.\n");
    indent_printf("  * @param comp\n");
    indent_printf("  *     true (non-zero) if data should be compressed.\n");
    indent_printf("  * @note\n");
    indent_printf("  *      If any errors are encountered, this\n");
    indent_printf("  *      function will not return.  All errors\n");
    indent_printf("  *      will print a fatal error message, and\n");
    indent_printf("  *      exit with an exit status of 1.\n");
    indent_printf("  */\n");
    indent_printf
    (
	"void %s_write_file(string_ty *filename, %s_ty *value, int comp);\n",
	s->str_text,
	s->str_text
    );

    indent_putchar('\n');
    indent_printf("/**\n");
    indent_printf("  * The %s_write_file function is used to\n", s->str_text);
    indent_printf("  * write %s meta data to the named file.\n", s->str_text);
    indent_printf("  *\n");
    indent_printf("  * @param filnam\n");
    indent_printf("  *     The name of the file to be written.\n");
    indent_printf("  * @param value\n");
    indent_printf("  *     The value of the meta-data to be written.\n");
    indent_printf("  * @param comp\n");
    indent_printf("  *     true if data should be compressed.\n");
    indent_printf("  * @note\n");
    indent_printf("  *      If any errors are encountered, this\n");
    indent_printf("  *      function will not return.  All errors\n");
    indent_printf("  *      will print a fatal error message, and\n");
    indent_printf("  *      exit with an exit status of 1.\n");
    indent_printf("  */\n");
    indent_printf
    (
	"void %s_write_file(const nstring &filnam, %s_ty *value, bool comp);\n",
	s->str_text,
	s->str_text
    );

    indent_putchar('\n');
    indent_printf("/**\n");
    indent_printf("  * The %s_read_file function is used to\n", s->str_text);
    indent_printf("  * read %s meta data from the named file.\n", s->str_text);
    indent_printf("  *\n");
    indent_printf("  * @param filename\n");
    indent_printf("  *     The name of the file to be read.\n");
    indent_printf("  * @returns\n");
    indent_printf("  *     a pointer to a dynamically allocated\n");
    indent_printf("  *     value read from the file.\n");
    indent_printf("  * @note\n");
    indent_printf("  *      If any errors are encountered, this\n");
    indent_printf("  *      function will not return.  All errors\n");
    indent_printf("  *      (including syntax errors) will print a\n");
    indent_printf("  *      fatal error message, and exit with an\n");
    indent_printf("  *      exit status of 1.\n");
    indent_printf("  */\n");
    indent_printf
    (
	"%s_ty *%s_read_file(string_ty *filename);\n",
	s->str_text,
	s->str_text
    );

    indent_putchar('\n');
    indent_printf("/**\n");
    indent_printf("  * The %s_read_file function is used to\n", s->str_text);
    indent_printf("  * read %s meta data from the named file.\n", s->str_text);
    indent_printf("  *\n");
    indent_printf("  * @param filename\n");
    indent_printf("  *     The name of the file to be read.\n");
    indent_printf("  * @returns\n");
    indent_printf("  *     a pointer to a dynamically allocated\n");
    indent_printf("  *     value read from the file.\n");
    indent_printf("  * @note\n");
    indent_printf("  *      If any errors are encountered, this\n");
    indent_printf("  *      function will not return.  All errors\n");
    indent_printf("  *      (including syntax errors) will print a\n");
    indent_printf("  *      fatal error message, and exit with an\n");
    indent_printf("  *      exit status of 1.\n");
    indent_printf("  */\n");
    indent_printf
    (
	"%s_ty *%s_read_file(const nstring &filename);\n",
	s->str_text,
	s->str_text
    );

    indent_printf("void %s__rpt_init(void);\n", s->str_text);
    indent_putchar('\n');
    indent_printf("#endif // %s\n", cp1);
    indent_close();
    trace(("}\n"));
}


static void
generate_code_file(const char *code_file, const char *include_file,
    const char *definition_file)
{
    size_t	    j;
    string_ty	    *s;

    trace(("generate_code_file(c = \"%s\", h = \"%s\")\n{\n", code_file,
	include_file));
    s = current->name_short;
    indent_open(code_file);
    this_file_is_generated(definition_file);
    indent_putchar('\n');
    indent_printf("#include <common/ac/stddef.h>\n");
    indent_printf("#include <common/ac/stdio.h>\n");
    indent_putchar('\n');
    indent_printf("#include <common/error.h>\n");
    indent_printf("#include <common/mem.h>\n");
    indent_printf("#include <common/trace.h>\n");
    indent_printf("#include <libaegis/io.h>\n");
    indent_printf("#include <libaegis/meta_type.h>\n");
    indent_printf("#include <libaegis/os.h>\n");
    indent_printf("#include <libaegis/output/file.h>\n");
    indent_printf("#include <libaegis/output/gzip.h>\n");
    indent_printf("#include <libaegis/output/indent.h>\n");
    indent_printf("#include <%s>\n", include_file);
    const char *cp1 = base_name(code_file);
    for (j = 0; j < emit_length; ++j)
    {
	type *tp = emit_list[j];
	if (!tp->is_in_include_file())
	    tp->gen_code();
    }
    indent_putchar('\n');
    indent_printf("%s_ty *\n", cp1);
    indent_printf("%s_read_file(const nstring &filename)\n", s->str_text);
    indent_printf("{\n");
    indent_printf("return %s_read_file(filename.get_ref());\n", s->str_text);
    indent_printf("}\n");
    indent_putchar('\n');
    indent_printf("%s_ty *\n", cp1);
    indent_printf("%s_read_file(string_ty *filename)\n", s->str_text);
    indent_printf("{\n");
    indent_printf("%s_ty\1*result;\n\n", cp1);
    indent_printf
    (
	"trace((\"%s_read_file(filename = \\\"%%s\\\")\\n{\\n\", "
	    "(filename ? filename->str_text : \"\")));\n",
	cp1
    );
    indent_printf("os_become_must_be_active();\n");
    indent_printf
    (
	"result = (%s_ty *)parse(filename, &%s_type);\n",
	cp1,
	s->str_text
    );
    indent_printf("trace((\"return %%08lX;\\n\", (long)result));\n");
    indent_printf("trace((\"}\\n\"));\n");
    indent_printf("return result;\n");
    indent_printf("}\n");
    indent_putchar('\n');
    indent_printf("void\n");
    indent_printf
    (
	"%s_write_file(const nstring &filename, %s_ty *value, "
	    "bool comp)\n",
	s->str_text,
	s->str_text
    );
    indent_printf("{\n");
    indent_printf
    (
	"%s_write_file(filename.get_ref(), value, comp);\n",
	s->str_text
    );
    indent_printf("}\n");
    indent_putchar('\n');
    indent_printf("void\n");
    indent_printf
    (
	"%s_write_file(string_ty *filename, %s_ty *value, "
	    "int needs_compression)\n",
	s->str_text,
	s->str_text
    );
    indent_printf("{\n");
    indent_printf
    (
	"trace((\"%s_write_file(filename = \\\"%%s\\\", value = %%08lX)\\n"
	    "{\\n\", (filename ? filename->str_text : \"\"), (long)value));\n",
	cp1
    );
    indent_printf("if (filename)\n");
    indent_more();
    indent_printf("os_become_must_be_active();\n");
    indent_less();
    indent_printf("output::pointer fp;\n");
    indent_printf("if (needs_compression)\n{\n");
    indent_printf("fp = output_file::binary_open(filename);\n");
    indent_printf("fp = output_gzip::create(fp);\n");
    indent_printf("}\nelse\n{\n");
    indent_printf("fp = output_file::text_open(filename);\n");
    indent_printf("}\n");
    indent_printf("fp = output_indent::create(fp);\n");
    indent_printf("io_comment_emit(fp);\n");
    indent_printf("%s_write(fp, value);\n", s->str_text);
    indent_printf("type_enum_option_clear();\n");
    indent_printf("trace((\"}\\n\"));\n");
    indent_printf("}\n");

    indent_putchar('\n');
    indent_printf("void\n");
    indent_printf("%s__rpt_init(void)\n", s->str_text);
    indent_printf("{\n");
    indent_printf("trace((\"%s__rpt_init()\\n{\\n\"));\n", cp1);
    for (j = 0; j < initialize.nstrings; ++j)
	indent_printf("%s\n", initialize.string[j]->str_text);
    indent_printf("trace((\"}\\n\"));\n");
    indent_printf("}\n");
    indent_close();
    trace(("}\n"));
}


void
generate_code__init(const nstring &s)
{
    initialize.push_back(s.get_ref());
}


void
parse(const char *definition_file, const char *code_file,
    const char *include_file)
{
    string_ty       *s;
    extern int      parse_parse(void);

    /*
     * initial name is the basename of the definition file
     */
    trace(("parse(def = \"%s\", c = \"%s\", h = \"%s\")\n{\n",
	definition_file, code_file, include_file));
#ifdef DEBUG
    parse_debug = trace_pretest_;
#endif
    s = str_from_c(base_name(definition_file));
    push_name_abs(s);
    str_free(s);
    typedef_symtab = symtab_alloc(10);

    /*
     * parse the definition file
     */
    lex_open(definition_file);
    trace(("parse_parse()\n{\n"));
    parse_parse();
    trace(("}\n"));
    lex_close();

    /*
     * remember to emit a structure containing its fields
     */
    current->name_type->toplevel();
    define_type(current->name_type);

    /*
     * generate the files
     */
    generate_include_file(include_file, definition_file);
    generate_code_file(code_file, include_file, definition_file);
    pop_name();
    trace(("}\n"));
}

#line 541 "y.tab.c"

/* compatibility with bison */
#ifdef parse_PARSE_PARAM
/* compatibility with FreeBSD */
# ifdef parse_PARSE_PARAM_TYPE
#  define parse_PARSE_DECL() parse_parse(parse_PARSE_PARAM_TYPE parse_PARSE_PARAM)
# else
#  define parse_PARSE_DECL() parse_parse(void *parse_PARSE_PARAM)
# endif
#else
# define parse_PARSE_DECL() parse_parse(void)
#endif

/* Parameters sent to lex. */
#ifdef parse_LEX_PARAM
# define parse_LEX_DECL() parse_lex(void *parse_LEX_PARAM)
# define parse_LEX parse_lex(parse_LEX_PARAM)
#else
# define parse_LEX_DECL() parse_lex(void)
# define parse_LEX parse_lex()
#endif

#if !(defined(parse_lex) || defined(parse_STATE))
int parse_LEX_DECL();
#endif

/* Parameters sent to parse_error. */
#ifndef parse_ERROR_DECL
#define parse_ERROR_DECL() parse_error(const char *s)
#endif
#ifndef parse_ERROR_CALL
#define parse_ERROR_CALL(msg) parse_error(msg)
#endif

extern int parse_PARSE_DECL();

#define BOOLEAN 257
#define BOOLEAN_CONSTANT 258
#define HIDE_IF_DEFAULT 259
#define INCLUDE 260
#define INTEGER 261
#define INTEGER_CONSTANT 262
#define NAME 263
#define REAL 264
#define REDEFINITION_OK 265
#define SHOW_IF_DEFAULT 266
#define STRING 267
#define STRING_CONSTANT 268
#define TIME 269
#define TYPE 270
#define parse_ERRCODE 256
typedef int parse_INT;
static const parse_INT parse_lhs[] = {                           -1,
    0,    7,    7,    9,    9,    9,   10,   11,   11,   12,
    2,    2,    2,    2,    2,    2,    2,    2,    2,    3,
    8,    8,    4,    5,    6,   13,   13,   15,   14,   14,
    1,    1,    1,    1,
};
static const parse_INT parse_len[] = {                            2,
    2,    0,    2,    5,    3,    1,    1,    5,    2,    1,
    1,    1,    1,    1,    1,    1,    1,    1,    1,    3,
    0,    2,    3,    5,    0,    1,    3,    1,    0,    1,
    0,    2,    2,    2,
};
static const parse_INT parse_defred[] = {                         2,
    0,    0,    6,    0,    0,    0,    3,    7,    0,    0,
   10,   22,    0,    0,    5,    9,    0,   12,   13,   16,
   14,   11,   15,   21,    0,   25,    0,   17,   18,   19,
   31,    0,    0,    0,    4,    0,   20,   23,   28,    0,
   26,   34,   32,   33,    8,    0,    0,   27,   24,
};
#if defined(parse_DESTRUCT_CALL) || defined(parse_STYPE_TOSTRING)
static const parse_INT parse_stos[] = {                           0,
  272,  279,  256,  270,   35,  280,  281,  263,  282,  260,
  263,  283,  284,   61,  268,  256,   61,  257,  261,  263,
  264,  267,  269,  123,   91,   40,  274,  275,  276,  277,
  274,  280,  274,  278,   59,  273,  125,   93,  263,  285,
  287,  259,  265,  266,   59,   44,  286,  287,   41,
};
#endif /* parse_DESTRUCT_CALL || parse_STYPE_TOSTRING */
static const parse_INT parse_dgoto[] = {                          1,
   36,   27,   28,   29,   30,   34,    2,    6,    7,    9,
   12,   13,   40,   47,   41,
};
static const parse_INT parse_sindex[] = {                         0,
    0,  -35,    0, -256, -252, -254,    0,    0,  -51, -257,
    0,    0,  -57,  -38,    0,    0,  -38,    0,    0,    0,
    0,    0,    0,    0,  -38,    0,  -47,    0,    0,    0,
    0, -120,  -80, -248,    0,  -56,    0,    0,    0,  -28,
    0,    0,    0,    0,    0, -248,  -24,    0,    0,
};
static const parse_INT parse_rindex[] = {                         0,
    0,    1,    0,    0,    0,   18,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,  -22,
    0,    0,    0,    0,    0,  -21,    0,    0,    0,
};
#if parse_BTYACC
static const parse_INT parse_cindex[] = {                         0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,
};
#endif
static const parse_INT parse_gindex[] = {                         0,
    0,  -11,    0,    0,    0,    0,    0,   -3,    0,    0,
    0,    0,    0,    0,  -23,
};
#define parse_TABLESIZE 264
static const parse_INT parse_table[] = {                          5,
   21,   26,   45,   17,   37,   31,    8,   10,   11,   14,
   15,   35,   38,   33,   39,   46,   49,    1,   29,   30,
   32,    0,   48,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,   25,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,   24,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,   11,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,   16,    0,
    0,    0,   42,    0,    0,    0,    0,    0,   43,   44,
    0,    0,    0,    0,    0,    0,    0,    0,   18,    0,
    3,    0,   19,    0,   20,   21,    0,    0,   22,    0,
   23,    0,    0,    0,    4,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,   21,
};
static const parse_INT parse_check[] = {                         35,
    0,   40,   59,   61,  125,   17,  263,  260,  263,   61,
  268,   59,   93,   25,  263,   44,   41,    0,   41,   41,
   24,   -1,   46,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   91,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,  123,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,  263,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  256,   -1,
   -1,   -1,  259,   -1,   -1,   -1,   -1,   -1,  265,  266,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  257,   -1,
  256,   -1,  261,   -1,  263,  264,   -1,   -1,  267,   -1,
  269,   -1,   -1,   -1,  270,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,  263,
};
#if parse_BTYACC
static const parse_INT parse_ctable[] = {                        -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,
};
#endif
#define parse_FINAL 1
#ifndef parse_DEBUG
#define parse_DEBUG 0
#endif
#define parse_MAXTOKEN 270
#define parse_UNDFTOKEN 288
#define parse_TRANSLATE(a) ((a) > parse_MAXTOKEN ? parse_UNDFTOKEN : (a))
#if parse_DEBUG
static const char *const parse_name[] = {

"$end",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
"'#'",0,0,0,0,"'('","')'",0,0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,"';'",0,"'='",0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'['",0,"']'",0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,"error","BOOLEAN","BOOLEAN_CONSTANT","HIDE_IF_DEFAULT","INCLUDE","INTEGER",
"INTEGER_CONSTANT","NAME","REAL","REDEFINITION_OK","SHOW_IF_DEFAULT","STRING",
"STRING_CONSTANT","TIME","TYPE","$accept","description","attributes","type",
"structure","list","enumeration","enum_list_begin","typedef_list","field_list",
"typedef","type_name","field","field_name","enum_list","optional_comma",
"enum_name","illegal-symbol",
};
static const char *const parse_rule[] = {
"$accept : description",
"description : typedef_list field_list",
"typedef_list :",
"typedef_list : typedef_list typedef",
"typedef : TYPE type_name '=' type ';'",
"typedef : '#' INCLUDE STRING_CONSTANT",
"typedef : error",
"type_name : NAME",
"field : field_name '=' type attributes ';'",
"field : field_name error",
"field_name : NAME",
"type : STRING",
"type : BOOLEAN",
"type : INTEGER",
"type : REAL",
"type : TIME",
"type : NAME",
"type : structure",
"type : list",
"type : enumeration",
"structure : '{' field_list '}'",
"field_list :",
"field_list : field_list field",
"list : '[' type ']'",
"enumeration : '(' enum_list_begin enum_list optional_comma ')'",
"enum_list_begin :",
"enum_list : enum_name",
"enum_list : enum_list ',' enum_name",
"enum_name : NAME",
"optional_comma :",
"optional_comma : ','",
"attributes :",
"attributes : attributes REDEFINITION_OK",
"attributes : attributes SHOW_IF_DEFAULT",
"attributes : attributes HIDE_IF_DEFAULT",

};
#endif

#if parse_DEBUG
int      parse_debug;
#endif

int      parse_errflag;
int      parse_char;
parse_STYPE  parse_val;
parse_STYPE  parse_lval;
int      parse_nerrs;

#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
parse_LTYPE  parse_loc; /* position returned by actions */
parse_LTYPE  parse_lloc; /* position from the lexer */
#endif

#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
#ifndef parse_LLOC_DEFAULT
#define parse_LLOC_DEFAULT(loc, rhs, n) \
do \
{ \
    if (n == 0) \
    { \
        (loc).first_line   = parse_RHSLOC(rhs, 0).last_line; \
        (loc).first_column = parse_RHSLOC(rhs, 0).last_column; \
        (loc).last_line    = parse_RHSLOC(rhs, 0).last_line; \
        (loc).last_column  = parse_RHSLOC(rhs, 0).last_column; \
    } \
    else \
    { \
        (loc).first_line   = parse_RHSLOC(rhs, 1).first_line; \
        (loc).first_column = parse_RHSLOC(rhs, 1).first_column; \
        (loc).last_line    = parse_RHSLOC(rhs, n).last_line; \
        (loc).last_column  = parse_RHSLOC(rhs, n).last_column; \
    } \
} while (0)
#endif /* parse_LLOC_DEFAULT */
#endif /* defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED) */
#if parse_BTYACC

#ifndef parse_LVQUEUEGROWTH
#define parse_LVQUEUEGROWTH 32
#endif
#endif /* parse_BTYACC */

/* define the initial stack-sizes */
#ifdef parse_STACKSIZE
#undef parse_MAXDEPTH
#define parse_MAXDEPTH  parse_STACKSIZE
#else
#ifdef parse_MAXDEPTH
#define parse_STACKSIZE parse_MAXDEPTH
#else
#define parse_STACKSIZE 10000
#define parse_MAXDEPTH  10000
#endif
#endif

#ifndef parse_INITSTACKSIZE
#define parse_INITSTACKSIZE 200
#endif

typedef struct {
    unsigned stacksize;
    parse_INT    *s_base;
    parse_INT    *s_mark;
    parse_INT    *s_last;
    parse_STYPE  *l_base;
    parse_STYPE  *l_mark;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
    parse_LTYPE  *p_base;
    parse_LTYPE  *p_mark;
#endif
} parse_STACKDATA;
#if parse_BTYACC

struct parse_ParseState_s
{
    struct parse_ParseState_s *save;    /* Previously saved parser state */
    parse_STACKDATA            parse_stack; /* saved parser stack */
    int                    state;   /* saved parser state */
    int                    errflag; /* saved error recovery status */
    int                    lexeme;  /* saved index of the conflict lexeme in the lexical queue */
    parse_INT                  ctry;    /* saved index in parse_ctable[] for this conflict */
};
typedef struct parse_ParseState_s parse_ParseState;
#endif /* parse_BTYACC */
/* variables for the parser stack */
static parse_STACKDATA parse_stack;
#if parse_BTYACC

/* Current parser state */
static parse_ParseState *parse_ps = 0;

/* parse_path != NULL: do the full parse, starting at *parse_path parser state. */
static parse_ParseState *parse_path = 0;

/* Base of the lexical value queue */
static parse_STYPE *parse_lvals = 0;

/* Current position at lexical value queue */
static parse_STYPE *parse_lvp = 0;

/* End position of lexical value queue */
static parse_STYPE *parse_lve = 0;

/* The last allocated position at the lexical value queue */
static parse_STYPE *parse_lvlim = 0;

#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
/* Base of the lexical position queue */
static parse_LTYPE *parse_lpsns = 0;

/* Current position at lexical position queue */
static parse_LTYPE *parse_lpp = 0;

/* End position of lexical position queue */
static parse_LTYPE *parse_lpe = 0;

/* The last allocated position at the lexical position queue */
static parse_LTYPE *parse_lplim = 0;
#endif

/* Current position at lexical token queue */
static parse_INT  *parse_lexp = 0;

static parse_INT  *parse_lexemes = 0;
#endif /* parse_BTYACC */

/* For use in generated program */
#define parse_depth (int)(parse_stack.s_mark - parse_stack.s_base)
#if parse_BTYACC
#define parse_trial (parse_ps->save)
#endif /* parse_BTYACC */

#if parse_DEBUG
#endif

#include <string.h>	/* needed for memset */

/* allocate initial stack or double stack size, up to parse_MAXDEPTH */
static int parse_growstack(parse_STACKDATA *data)
{
    int i;
    unsigned newsize;
    parse_INT *newss;
    parse_STYPE *newvs;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
    parse_LTYPE *newps;
#endif

    if ((newsize = data->stacksize) == 0)
        newsize = parse_INITSTACKSIZE;
    else if (newsize >= parse_MAXDEPTH)
        return parse_ENOMEM;
    else if ((newsize *= 2) > parse_MAXDEPTH)
        newsize = parse_MAXDEPTH;

    i = (int) (data->s_mark - data->s_base);
    newss = (parse_INT *)realloc(data->s_base, newsize * sizeof(*newss));
    if (newss == 0)
        return parse_ENOMEM;

    data->s_base = newss;
    data->s_mark = newss + i;

    newvs = (parse_STYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
    if (newvs == 0)
        return parse_ENOMEM;

    data->l_base = newvs;
    data->l_mark = newvs + i;

#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
    newps = (parse_LTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
    if (newps == 0)
        return parse_ENOMEM;

    data->p_base = newps;
    data->p_mark = newps + i;
#endif

    data->stacksize = newsize;
    data->s_last = data->s_base + newsize - 1;

#if parse_DEBUG
    if (parse_debug)
        fprintf(stderr, "%sdebug: stack size increased to %d\n", parse_PREFIX, newsize);
#endif
    return 0;
}

#if parse_PURE || defined(parse__NO_LEAKS)
static void parse_freestack(parse_STACKDATA *data)
{
    free(data->s_base);
    free(data->l_base);
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
    free(data->p_base);
#endif
    memset(data, 0, sizeof(*data));
}
#else
#define parse_freestack(data) /* nothing */
#endif /* parse_PURE || defined(parse__NO_LEAKS) */
#if parse_BTYACC

static parse_ParseState *
parse_NewState(unsigned size)
{
    parse_ParseState *p = (parse_ParseState *) malloc(sizeof(parse_ParseState));
    if (p == NULL) return NULL;

    p->parse_stack.stacksize = size;
    if (size == 0)
    {
        p->parse_stack.s_base = NULL;
        p->parse_stack.l_base = NULL;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
        p->parse_stack.p_base = NULL;
#endif
        return p;
    }
    p->parse_stack.s_base    = (parse_INT *) malloc(size * sizeof(parse_INT));
    if (p->parse_stack.s_base == NULL) return NULL;
    p->parse_stack.l_base    = (parse_STYPE *) malloc(size * sizeof(parse_STYPE));
    if (p->parse_stack.l_base == NULL) return NULL;
    memset(p->parse_stack.l_base, 0, size * sizeof(parse_STYPE));
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
    p->parse_stack.p_base    = (parse_LTYPE *) malloc(size * sizeof(parse_LTYPE));
    if (p->parse_stack.p_base == NULL) return NULL;
    memset(p->parse_stack.p_base, 0, size * sizeof(parse_LTYPE));
#endif

    return p;
}

static void
parse_FreeState(parse_ParseState *p)
{
    parse_freestack(&p->parse_stack);
    free(p);
}
#endif /* parse_BTYACC */

#define parse_ABORT  goto parse_abort
#define parse_REJECT goto parse_abort
#define parse_ACCEPT goto parse_accept
#define parse_ERROR  goto parse_errlab
#if parse_BTYACC
#define parse_VALID        do { if (parse_ps->save)            goto parse_valid; } while(0)
#define parse_VALID_NESTED do { if (parse_ps->save && \
                                parse_ps->save->save == 0) goto parse_valid; } while(0)
#endif /* parse_BTYACC */

int
parse_PARSE_DECL()
{
    int parse_m, parse_n, parse_state, parse_result;
#if parse_BTYACC
    int parse_newerrflag;
    parse_ParseState *parse_errctx = NULL;
#endif /* parse_BTYACC */
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
    parse_LTYPE  parse_error_loc_range[3]; /* position of error start/end (0 unused) */
#endif
#if parse_DEBUG
    const char *parse_s;

    if ((parse_s = getenv("parse_DEBUG")) != 0)
    {
        parse_n = *parse_s;
        if (parse_n >= '0' && parse_n <= '9')
            parse_debug = parse_n - '0';
    }
    if (parse_debug)
        fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", parse_PREFIX);
#endif
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
    memset(parse_error_loc_range, 0, sizeof(parse_error_loc_range));
#endif

#if parse_BTYACC
    parse_ps = parse_NewState(0); if (parse_ps == 0) goto parse_enomem;
    parse_ps->save = 0;
#endif /* parse_BTYACC */
    parse_m = 0;
    parse_n = 0;
    parse_nerrs = 0;
    parse_errflag = 0;
    parse_char = parse_EMPTY;
    parse_state = 0;

#if parse_PURE
    memset(&parse_stack, 0, sizeof(parse_stack));
#endif

    if (parse_stack.s_base == NULL && parse_growstack(&parse_stack) == parse_ENOMEM) goto parse_overflow;
    parse_stack.s_mark = parse_stack.s_base;
    parse_stack.l_mark = parse_stack.l_base;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
    parse_stack.p_mark = parse_stack.p_base;
#endif
    parse_state = 0;
    *parse_stack.s_mark = 0;

parse_loop:
    if ((parse_n = parse_defred[parse_state]) != 0) goto parse_reduce;
    if (parse_char < 0)
    {
#if parse_BTYACC
        do {
        if (parse_lvp < parse_lve)
        {
            /* we're currently re-reading tokens */
            parse_lval = *parse_lvp++;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
            parse_lloc = *parse_lpp++;
#endif
            parse_char = *parse_lexp++;
            break;
        }
        if (parse_ps->save)
        {
            /* in trial mode; save scanner results for future parse attempts */
            if (parse_lvp == parse_lvlim)
            {   /* Enlarge lexical value queue */
                size_t p = (size_t) (parse_lvp - parse_lvals);
                size_t s = (size_t) (parse_lvlim - parse_lvals);

                s += parse_LVQUEUEGROWTH;
                if ((parse_lexemes = (parse_INT *)realloc(parse_lexemes, s * sizeof(parse_INT))) == NULL) goto parse_enomem;
                if ((parse_lvals   = (parse_STYPE *)realloc(parse_lvals, s * sizeof(parse_STYPE))) == NULL) goto parse_enomem;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
                if ((parse_lpsns   = (parse_LTYPE *)realloc(parse_lpsns, s * sizeof(parse_LTYPE))) == NULL) goto parse_enomem;
#endif
                parse_lvp   = parse_lve = parse_lvals + p;
                parse_lvlim = parse_lvals + s;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
                parse_lpp   = parse_lpe = parse_lpsns + p;
                parse_lplim = parse_lpsns + s;
#endif
                parse_lexp  = parse_lexemes + p;
            }
            *parse_lexp = (parse_INT) parse_LEX;
            *parse_lvp++ = parse_lval;
            parse_lve++;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
            *parse_lpp++ = parse_lloc;
            parse_lpe++;
#endif
            parse_char = *parse_lexp++;
            break;
        }
        /* normal operation, no conflict encountered */
#endif /* parse_BTYACC */
        parse_char = parse_LEX;
#if parse_BTYACC
        } while (0);
#endif /* parse_BTYACC */
        if (parse_char < 0) parse_char = parse_EOF;
#if parse_DEBUG
        if (parse_debug)
        {
            if ((parse_s = parse_name[parse_TRANSLATE(parse_char)]) == NULL) parse_s = parse_name[parse_UNDFTOKEN];
            fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
                            parse_DEBUGSTR, parse_depth, parse_state, parse_char, parse_s);
#ifdef parse_STYPE_TOSTRING
#if parse_BTYACC
            if (!parse_trial)
#endif /* parse_BTYACC */
                fprintf(stderr, " <%s>", parse_STYPE_TOSTRING(parse_char, parse_lval));
#endif
            fputc('\n', stderr);
        }
#endif
    }
#if parse_BTYACC

    /* Do we have a conflict? */
    if (((parse_n = parse_cindex[parse_state]) != 0) && (parse_n += parse_char) >= 0 &&
        parse_n <= parse_TABLESIZE && parse_check[parse_n] == (parse_INT) parse_char)
    {
        parse_INT ctry;

        if (parse_path)
        {
            parse_ParseState *save;
#if parse_DEBUG
            if (parse_debug)
                fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
                                parse_DEBUGSTR, parse_depth, parse_state);
#endif
            /* Switch to the next conflict context */
            save = parse_path;
            parse_path = save->save;
            save->save = NULL;
            ctry = save->ctry;
            if (save->state != parse_state) parse_ABORT;
            parse_FreeState(save);

        }
        else
        {

            /* Unresolved conflict - start/continue trial parse */
            parse_ParseState *save;
#if parse_DEBUG
            if (parse_debug)
            {
                fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", parse_DEBUGSTR, parse_depth, parse_state);
                if (parse_ps->save)
                    fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
                else
                    fputs("Starting trial parse.\n", stderr);
            }
#endif
            save                  = parse_NewState((unsigned)(parse_stack.s_mark - parse_stack.s_base + 1));
            if (save == NULL) goto parse_enomem;
            save->save            = parse_ps->save;
            save->state           = parse_state;
            save->errflag         = parse_errflag;
            save->parse_stack.s_mark  = save->parse_stack.s_base + (parse_stack.s_mark - parse_stack.s_base);
            memcpy (save->parse_stack.s_base, parse_stack.s_base, (size_t) (parse_stack.s_mark - parse_stack.s_base + 1) * sizeof(parse_INT));
            save->parse_stack.l_mark  = save->parse_stack.l_base + (parse_stack.l_mark - parse_stack.l_base);
            memcpy (save->parse_stack.l_base, parse_stack.l_base, (size_t) (parse_stack.l_mark - parse_stack.l_base + 1) * sizeof(parse_STYPE));
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
            save->parse_stack.p_mark  = save->parse_stack.p_base + (parse_stack.p_mark - parse_stack.p_base);
            memcpy (save->parse_stack.p_base, parse_stack.p_base, (size_t) (parse_stack.p_mark - parse_stack.p_base + 1) * sizeof(parse_LTYPE));
#endif
            ctry                  = parse_table[parse_n];
            if (parse_ctable[ctry] == -1)
            {
#if parse_DEBUG
                if (parse_debug && parse_char >= parse_EOF)
                    fprintf(stderr, "%s[%d]: backtracking 1 token\n", parse_DEBUGSTR, parse_depth);
#endif
                ctry++;
            }
            save->ctry = ctry;
            if (parse_ps->save == NULL)
            {
                /* If this is a first conflict in the stack, start saving lexemes */
                if (!parse_lexemes)
                {
                    parse_lexemes = (parse_INT *) malloc((parse_LVQUEUEGROWTH) * sizeof(parse_INT));
                    if (parse_lexemes == NULL) goto parse_enomem;
                    parse_lvals   = (parse_STYPE *) malloc((parse_LVQUEUEGROWTH) * sizeof(parse_STYPE));
                    if (parse_lvals == NULL) goto parse_enomem;
                    parse_lvlim   = parse_lvals + parse_LVQUEUEGROWTH;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
                    parse_lpsns   = (parse_LTYPE *) malloc((parse_LVQUEUEGROWTH) * sizeof(parse_LTYPE));
                    if (parse_lpsns == NULL) goto parse_enomem;
                    parse_lplim   = parse_lpsns + parse_LVQUEUEGROWTH;
#endif
                }
                if (parse_lvp == parse_lve)
                {
                    parse_lvp  = parse_lve = parse_lvals;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
                    parse_lpp  = parse_lpe = parse_lpsns;
#endif
                    parse_lexp = parse_lexemes;
                    if (parse_char >= parse_EOF)
                    {
                        *parse_lve++ = parse_lval;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
                        *parse_lpe++ = parse_lloc;
#endif
                        *parse_lexp  = (parse_INT) parse_char;
                        parse_char   = parse_EMPTY;
                    }
                }
            }
            if (parse_char >= parse_EOF)
            {
                parse_lvp--;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
                parse_lpp--;
#endif
                parse_lexp--;
                parse_char = parse_EMPTY;
            }
            save->lexeme = (int) (parse_lvp - parse_lvals);
            parse_ps->save   = save;
        }
        if (parse_table[parse_n] == ctry)
        {
#if parse_DEBUG
            if (parse_debug)
                fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
                                parse_DEBUGSTR, parse_depth, parse_state, parse_ctable[ctry]);
#endif
            if (parse_char < 0)
            {
                parse_lvp++;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
                parse_lpp++;
#endif
                parse_lexp++;
            }
            if (parse_stack.s_mark >= parse_stack.s_last && parse_growstack(&parse_stack) == parse_ENOMEM)
                goto parse_overflow;
            parse_state = parse_ctable[ctry];
            *++parse_stack.s_mark = (parse_INT) parse_state;
            *++parse_stack.l_mark = parse_lval;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
            *++parse_stack.p_mark = parse_lloc;
#endif
            parse_char  = parse_EMPTY;
            if (parse_errflag > 0) --parse_errflag;
            goto parse_loop;
        }
        else
        {
            parse_n = parse_ctable[ctry];
            goto parse_reduce;
        }
    } /* End of code dealing with conflicts */
#endif /* parse_BTYACC */
    if (((parse_n = parse_sindex[parse_state]) != 0) && (parse_n += parse_char) >= 0 &&
            parse_n <= parse_TABLESIZE && parse_check[parse_n] == (parse_INT) parse_char)
    {
#if parse_DEBUG
        if (parse_debug)
            fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
                            parse_DEBUGSTR, parse_depth, parse_state, parse_table[parse_n]);
#endif
        if (parse_stack.s_mark >= parse_stack.s_last && parse_growstack(&parse_stack) == parse_ENOMEM) goto parse_overflow;
        parse_state = parse_table[parse_n];
        *++parse_stack.s_mark = parse_table[parse_n];
        *++parse_stack.l_mark = parse_lval;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
        *++parse_stack.p_mark = parse_lloc;
#endif
        parse_char = parse_EMPTY;
        if (parse_errflag > 0)  --parse_errflag;
        goto parse_loop;
    }
    if (((parse_n = parse_rindex[parse_state]) != 0) && (parse_n += parse_char) >= 0 &&
            parse_n <= parse_TABLESIZE && parse_check[parse_n] == (parse_INT) parse_char)
    {
        parse_n = parse_table[parse_n];
        goto parse_reduce;
    }
    if (parse_errflag != 0) goto parse_inrecovery;
#if parse_BTYACC

    parse_newerrflag = 1;
    goto parse_errhandler;
    goto parse_errlab; /* redundant goto avoids 'unused label' warning */

parse_errlab:
    /* explicit parse_ERROR from an action -- pop the rhs of the rule reduced
     * before looking for error recovery */
    parse_stack.s_mark -= parse_m;
    parse_state = *parse_stack.s_mark;
    parse_stack.l_mark -= parse_m;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
    parse_stack.p_mark -= parse_m;
#endif

    parse_newerrflag = 0;
parse_errhandler:
    while (parse_ps->save)
    {
        int ctry;
        parse_ParseState *save = parse_ps->save;
#if parse_DEBUG
        if (parse_debug)
            fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
                            parse_DEBUGSTR, parse_depth, parse_state, parse_ps->save->state,
                    (int)(parse_lvp - parse_lvals - parse_ps->save->lexeme));
#endif
        /* Memorize most forward-looking error state in case it's really an error. */
        if (parse_errctx == NULL || parse_errctx->lexeme < parse_lvp - parse_lvals)
        {
            /* Free old saved error context state */
            if (parse_errctx) parse_FreeState(parse_errctx);
            /* Create and fill out new saved error context state */
            parse_errctx                 = parse_NewState((unsigned)(parse_stack.s_mark - parse_stack.s_base + 1));
            if (parse_errctx == NULL) goto parse_enomem;
            parse_errctx->save           = parse_ps->save;
            parse_errctx->state          = parse_state;
            parse_errctx->errflag        = parse_errflag;
            parse_errctx->parse_stack.s_mark = parse_errctx->parse_stack.s_base + (parse_stack.s_mark - parse_stack.s_base);
            memcpy (parse_errctx->parse_stack.s_base, parse_stack.s_base, (size_t) (parse_stack.s_mark - parse_stack.s_base + 1) * sizeof(parse_INT));
            parse_errctx->parse_stack.l_mark = parse_errctx->parse_stack.l_base + (parse_stack.l_mark - parse_stack.l_base);
            memcpy (parse_errctx->parse_stack.l_base, parse_stack.l_base, (size_t) (parse_stack.l_mark - parse_stack.l_base + 1) * sizeof(parse_STYPE));
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
            parse_errctx->parse_stack.p_mark = parse_errctx->parse_stack.p_base + (parse_stack.p_mark - parse_stack.p_base);
            memcpy (parse_errctx->parse_stack.p_base, parse_stack.p_base, (size_t) (parse_stack.p_mark - parse_stack.p_base + 1) * sizeof(parse_LTYPE));
#endif
            parse_errctx->lexeme         = (int) (parse_lvp - parse_lvals);
        }
        parse_lvp          = parse_lvals   + save->lexeme;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
        parse_lpp          = parse_lpsns   + save->lexeme;
#endif
        parse_lexp         = parse_lexemes + save->lexeme;
        parse_char         = parse_EMPTY;
        parse_stack.s_mark = parse_stack.s_base + (save->parse_stack.s_mark - save->parse_stack.s_base);
        memcpy (parse_stack.s_base, save->parse_stack.s_base, (size_t) (parse_stack.s_mark - parse_stack.s_base + 1) * sizeof(parse_INT));
        parse_stack.l_mark = parse_stack.l_base + (save->parse_stack.l_mark - save->parse_stack.l_base);
        memcpy (parse_stack.l_base, save->parse_stack.l_base, (size_t) (parse_stack.l_mark - parse_stack.l_base + 1) * sizeof(parse_STYPE));
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
        parse_stack.p_mark = parse_stack.p_base + (save->parse_stack.p_mark - save->parse_stack.p_base);
        memcpy (parse_stack.p_base, save->parse_stack.p_base, (size_t) (parse_stack.p_mark - parse_stack.p_base + 1) * sizeof(parse_LTYPE));
#endif
        ctry           = ++save->ctry;
        parse_state        = save->state;
        /* We tried shift, try reduce now */
        if ((parse_n = parse_ctable[ctry]) >= 0) goto parse_reduce;
        parse_ps->save     = save->save;
        save->save     = NULL;
        parse_FreeState(save);

        /* Nothing left on the stack -- error */
        if (!parse_ps->save)
        {
#if parse_DEBUG
            if (parse_debug)
                fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
                                parse_PREFIX, parse_depth);
#endif
            /* Restore state as it was in the most forward-advanced error */
            parse_lvp          = parse_lvals   + parse_errctx->lexeme;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
            parse_lpp          = parse_lpsns   + parse_errctx->lexeme;
#endif
            parse_lexp         = parse_lexemes + parse_errctx->lexeme;
            parse_char         = parse_lexp[-1];
            parse_lval         = parse_lvp[-1];
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
            parse_lloc         = parse_lpp[-1];
#endif
            parse_stack.s_mark = parse_stack.s_base + (parse_errctx->parse_stack.s_mark - parse_errctx->parse_stack.s_base);
            memcpy (parse_stack.s_base, parse_errctx->parse_stack.s_base, (size_t) (parse_stack.s_mark - parse_stack.s_base + 1) * sizeof(parse_INT));
            parse_stack.l_mark = parse_stack.l_base + (parse_errctx->parse_stack.l_mark - parse_errctx->parse_stack.l_base);
            memcpy (parse_stack.l_base, parse_errctx->parse_stack.l_base, (size_t) (parse_stack.l_mark - parse_stack.l_base + 1) * sizeof(parse_STYPE));
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
            parse_stack.p_mark = parse_stack.p_base + (parse_errctx->parse_stack.p_mark - parse_errctx->parse_stack.p_base);
            memcpy (parse_stack.p_base, parse_errctx->parse_stack.p_base, (size_t) (parse_stack.p_mark - parse_stack.p_base + 1) * sizeof(parse_LTYPE));
#endif
            parse_state        = parse_errctx->state;
            parse_FreeState(parse_errctx);
            parse_errctx       = NULL;
        }
        parse_newerrflag = 1;
    }
    if (parse_newerrflag == 0) goto parse_inrecovery;
#endif /* parse_BTYACC */

    parse_ERROR_CALL("syntax error");
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
    parse_error_loc_range[1] = parse_lloc; /* lookahead position is error start position */
#endif

#if !parse_BTYACC
    goto parse_errlab; /* redundant goto avoids 'unused label' warning */
parse_errlab:
#endif
    ++parse_nerrs;

parse_inrecovery:
    if (parse_errflag < 3)
    {
        parse_errflag = 3;
        for (;;)
        {
            if (((parse_n = parse_sindex[*parse_stack.s_mark]) != 0) && (parse_n += parse_ERRCODE) >= 0 &&
                    parse_n <= parse_TABLESIZE && parse_check[parse_n] == (parse_INT) parse_ERRCODE)
            {
#if parse_DEBUG
                if (parse_debug)
                    fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
                                    parse_DEBUGSTR, parse_depth, *parse_stack.s_mark, parse_table[parse_n]);
#endif
                if (parse_stack.s_mark >= parse_stack.s_last && parse_growstack(&parse_stack) == parse_ENOMEM) goto parse_overflow;
                parse_state = parse_table[parse_n];
                *++parse_stack.s_mark = parse_table[parse_n];
                *++parse_stack.l_mark = parse_lval;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
                /* lookahead position is error end position */
                parse_error_loc_range[2] = parse_lloc;
                parse_LLOC_DEFAULT(parse_loc, parse_error_loc_range, 2); /* position of error span */
                *++parse_stack.p_mark = parse_loc;
#endif
                goto parse_loop;
            }
            else
            {
#if parse_DEBUG
                if (parse_debug)
                    fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
                                    parse_DEBUGSTR, parse_depth, *parse_stack.s_mark);
#endif
                if (parse_stack.s_mark <= parse_stack.s_base) goto parse_abort;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
                /* the current TOS position is the error start position */
                parse_error_loc_range[1] = *parse_stack.p_mark;
#endif
#if defined(parse_DESTRUCT_CALL)
#if parse_BTYACC
                if (!parse_trial)
#endif /* parse_BTYACC */
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
                    parse_DESTRUCT_CALL("error: discarding state",
                                    parse_stos[*parse_stack.s_mark], parse_stack.l_mark, parse_stack.p_mark);
#else
                    parse_DESTRUCT_CALL("error: discarding state",
                                    parse_stos[*parse_stack.s_mark], parse_stack.l_mark);
#endif /* defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED) */
#endif /* defined(parse_DESTRUCT_CALL) */
                --parse_stack.s_mark;
                --parse_stack.l_mark;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
                --parse_stack.p_mark;
#endif
            }
        }
    }
    else
    {
        if (parse_char == parse_EOF) goto parse_abort;
#if parse_DEBUG
        if (parse_debug)
        {
            if ((parse_s = parse_name[parse_TRANSLATE(parse_char)]) == NULL) parse_s = parse_name[parse_UNDFTOKEN];
            fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
                            parse_DEBUGSTR, parse_depth, parse_state, parse_char, parse_s);
        }
#endif
#if defined(parse_DESTRUCT_CALL)
#if parse_BTYACC
        if (!parse_trial)
#endif /* parse_BTYACC */
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
            parse_DESTRUCT_CALL("error: discarding token", parse_char, &parse_lval, &parse_lloc);
#else
            parse_DESTRUCT_CALL("error: discarding token", parse_char, &parse_lval);
#endif /* defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED) */
#endif /* defined(parse_DESTRUCT_CALL) */
        parse_char = parse_EMPTY;
        goto parse_loop;
    }

parse_reduce:
    parse_m = parse_len[parse_n];
#if parse_DEBUG
    if (parse_debug)
    {
        fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
                        parse_DEBUGSTR, parse_depth, parse_state, parse_n, parse_rule[parse_n]);
#ifdef parse_STYPE_TOSTRING
#if parse_BTYACC
        if (!parse_trial)
#endif /* parse_BTYACC */
            if (parse_m > 0)
            {
                int i;
                fputc('<', stderr);
                for (i = parse_m; i > 0; i--)
                {
                    if (i != parse_m) fputs(", ", stderr);
                    fputs(parse_STYPE_TOSTRING(parse_stos[parse_stack.s_mark[1-i]],
                                           parse_stack.l_mark[1-i]), stderr);
                }
                fputc('>', stderr);
            }
#endif
        fputc('\n', stderr);
    }
#endif
    if (parse_m > 0)
        parse_val = parse_stack.l_mark[1-parse_m];
    else
        memset(&parse_val, 0, sizeof parse_val);
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)

    /* Perform position reduction */
    memset(&parse_loc, 0, sizeof(parse_loc));
#if parse_BTYACC
    if (!parse_trial)
#endif /* parse_BTYACC */
    {
        parse_LLOC_DEFAULT(parse_loc, &parse_stack.p_mark[-parse_m], parse_m);
        /* just in case parse_ERROR is invoked within the action, save
           the start of the rhs as the error start position */
        parse_error_loc_range[1] = parse_stack.p_mark[1-parse_m];
    }
#endif

    switch (parse_n)
    {
case 4:
#line 569 "fmtgen/parse.y"
	{
	    parse_stack.l_mark[-1].lv_type->typedef_set();
	    symtab_assign(typedef_symtab, current->name_long, parse_stack.l_mark[-1].lv_type);
	    pop_name();
	    if (lex_in_include_file())
		parse_stack.l_mark[-1].lv_type->in_include_file();
	}
break;
case 5:
#line 577 "fmtgen/parse.y"
	{
	    lex_open(parse_stack.l_mark[0].lv_string->str_text);
	    str_free(parse_stack.l_mark[0].lv_string);
	}
break;
case 7:
#line 586 "fmtgen/parse.y"
	{
	    push_name_abs(parse_stack.l_mark[0].lv_string);
	}
break;
case 8:
#line 593 "fmtgen/parse.y"
	{
	    current->parent->name_type->member_add
	    (
		nstring(current->name_short),
		parse_stack.l_mark[-2].lv_type,
		parse_stack.l_mark[-1].lv_integer
	    );
	    pop_name();
	}
break;
case 9:
#line 603 "fmtgen/parse.y"
	{
	    pop_name();
	}
break;
case 10:
#line 610 "fmtgen/parse.y"
	{
	    push_name(parse_stack.l_mark[0].lv_string);
	    str_free(parse_stack.l_mark[0].lv_string);
	}
break;
case 11:
#line 618 "fmtgen/parse.y"
	{
	    parse_val.lv_type = new type_string();
	}
break;
case 12:
#line 622 "fmtgen/parse.y"
	{
	    parse_val.lv_type = new type_boolean();
	}
break;
case 13:
#line 626 "fmtgen/parse.y"
	{
	    parse_val.lv_type = new type_integer();
	}
break;
case 14:
#line 630 "fmtgen/parse.y"
	{
	    parse_val.lv_type = new type_real();
	}
break;
case 15:
#line 634 "fmtgen/parse.y"
	{
	    time_used = 1;
	    parse_val.lv_type = new type_time();
	}
break;
case 16:
#line 639 "fmtgen/parse.y"
	{
	    type *data = (type *)symtab_query(typedef_symtab, parse_stack.l_mark[0].lv_string);
	    if (data)
		parse_val.lv_type = data;
	    else
	    {
		parse_error("type \"%s\" undefined", parse_stack.l_mark[0].lv_string->str_text);
		parse_val.lv_type = new type_integer();
	    }
	    str_free(parse_stack.l_mark[0].lv_string);
	}
break;
case 17:
#line 651 "fmtgen/parse.y"
	{
	    parse_val.lv_type = parse_stack.l_mark[0].lv_type;
	    define_type(parse_val.lv_type);
	}
break;
case 18:
#line 656 "fmtgen/parse.y"
	{
	    parse_val.lv_type = parse_stack.l_mark[0].lv_type;
	    define_type(parse_val.lv_type);
	}
break;
case 19:
#line 661 "fmtgen/parse.y"
	{
	    parse_val.lv_type = parse_stack.l_mark[0].lv_type;
	    define_type(parse_val.lv_type);
	}
break;
case 20:
#line 669 "fmtgen/parse.y"
	{
	    parse_val.lv_type = current->name_type;
	}
break;
case 21:
#line 676 "fmtgen/parse.y"
	{
	    current->name_type =
                new type_structure(nstring(current->name_long));
	}
break;
case 23:
#line 685 "fmtgen/parse.y"
	{
	    static string_ty    *list;

	    if (!list)
		list = str_from_c("list");
	    push_name(list);
	    parse_val.lv_type = new type_list(nstring(current->name_long), parse_stack.l_mark[-1].lv_type);
	    pop_name();
	}
break;
case 24:
#line 698 "fmtgen/parse.y"
	{
	    parse_val.lv_type = parse_stack.l_mark[-3].lv_type;
	}
break;
case 25:
#line 705 "fmtgen/parse.y"
	{
	    parse_val.lv_type = new type_enumeration(nstring(current->name_long));
	    current->name_type = parse_val.lv_type;
	}
break;
case 28:
#line 718 "fmtgen/parse.y"
	{
	    push_name(parse_stack.l_mark[0].lv_string);
	    str_free(parse_stack.l_mark[0].lv_string);
	    current->parent->name_type->member_add
	    (
		nstring(current->name_short),
		(type *)0,
		1
	    );
	    pop_name();
	}
break;
case 31:
#line 738 "fmtgen/parse.y"
	{ parse_val.lv_integer = 0; }
break;
case 32:
#line 740 "fmtgen/parse.y"
	{ parse_val.lv_integer = parse_stack.l_mark[-1].lv_integer | ATTRIBUTE_REDEFINITION_OK; }
break;
case 33:
#line 742 "fmtgen/parse.y"
	{ parse_val.lv_integer = parse_stack.l_mark[-1].lv_integer | ATTRIBUTE_SHOW_IF_DEFAULT; }
break;
case 34:
#line 744 "fmtgen/parse.y"
	{ parse_val.lv_integer = parse_stack.l_mark[-1].lv_integer | ATTRIBUTE_HIDE_IF_DEFAULT; }
break;
#line 1785 "y.tab.c"
    default:
        break;
    }
    parse_stack.s_mark -= parse_m;
    parse_state = *parse_stack.s_mark;
    parse_stack.l_mark -= parse_m;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
    parse_stack.p_mark -= parse_m;
#endif
    parse_m = parse_lhs[parse_n];
    if (parse_state == 0 && parse_m == 0)
    {
#if parse_DEBUG
        if (parse_debug)
        {
            fprintf(stderr, "%s[%d]: after reduction, ", parse_DEBUGSTR, parse_depth);
#ifdef parse_STYPE_TOSTRING
#if parse_BTYACC
            if (!parse_trial)
#endif /* parse_BTYACC */
                fprintf(stderr, "result is <%s>, ", parse_STYPE_TOSTRING(parse_stos[parse_FINAL], parse_val));
#endif
            fprintf(stderr, "shifting from state 0 to final state %d\n", parse_FINAL);
        }
#endif
        parse_state = parse_FINAL;
        *++parse_stack.s_mark = parse_FINAL;
        *++parse_stack.l_mark = parse_val;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
        *++parse_stack.p_mark = parse_loc;
#endif
        if (parse_char < 0)
        {
#if parse_BTYACC
            do {
            if (parse_lvp < parse_lve)
            {
                /* we're currently re-reading tokens */
                parse_lval = *parse_lvp++;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
                parse_lloc = *parse_lpp++;
#endif
                parse_char = *parse_lexp++;
                break;
            }
            if (parse_ps->save)
            {
                /* in trial mode; save scanner results for future parse attempts */
                if (parse_lvp == parse_lvlim)
                {   /* Enlarge lexical value queue */
                    size_t p = (size_t) (parse_lvp - parse_lvals);
                    size_t s = (size_t) (parse_lvlim - parse_lvals);

                    s += parse_LVQUEUEGROWTH;
                    if ((parse_lexemes = (parse_INT *)realloc(parse_lexemes, s * sizeof(parse_INT))) == NULL)
                        goto parse_enomem;
                    if ((parse_lvals   = (parse_STYPE *)realloc(parse_lvals, s * sizeof(parse_STYPE))) == NULL)
                        goto parse_enomem;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
                    if ((parse_lpsns   = (parse_LTYPE *)realloc(parse_lpsns, s * sizeof(parse_LTYPE))) == NULL)
                        goto parse_enomem;
#endif
                    parse_lvp   = parse_lve = parse_lvals + p;
                    parse_lvlim = parse_lvals + s;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
                    parse_lpp   = parse_lpe = parse_lpsns + p;
                    parse_lplim = parse_lpsns + s;
#endif
                    parse_lexp  = parse_lexemes + p;
                }
                *parse_lexp = (parse_INT) parse_LEX;
                *parse_lvp++ = parse_lval;
                parse_lve++;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
                *parse_lpp++ = parse_lloc;
                parse_lpe++;
#endif
                parse_char = *parse_lexp++;
                break;
            }
            /* normal operation, no conflict encountered */
#endif /* parse_BTYACC */
            parse_char = parse_LEX;
#if parse_BTYACC
            } while (0);
#endif /* parse_BTYACC */
            if (parse_char < 0) parse_char = parse_EOF;
#if parse_DEBUG
            if (parse_debug)
            {
                if ((parse_s = parse_name[parse_TRANSLATE(parse_char)]) == NULL) parse_s = parse_name[parse_UNDFTOKEN];
                fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
                                parse_DEBUGSTR, parse_depth, parse_FINAL, parse_char, parse_s);
            }
#endif
        }
        if (parse_char == parse_EOF) goto parse_accept;
        goto parse_loop;
    }
    if (((parse_n = parse_gindex[parse_m]) != 0) && (parse_n += parse_state) >= 0 &&
            parse_n <= parse_TABLESIZE && parse_check[parse_n] == (parse_INT) parse_state)
        parse_state = parse_table[parse_n];
    else
        parse_state = parse_dgoto[parse_m];
#if parse_DEBUG
    if (parse_debug)
    {
        fprintf(stderr, "%s[%d]: after reduction, ", parse_DEBUGSTR, parse_depth);
#ifdef parse_STYPE_TOSTRING
#if parse_BTYACC
        if (!parse_trial)
#endif /* parse_BTYACC */
            fprintf(stderr, "result is <%s>, ", parse_STYPE_TOSTRING(parse_stos[parse_state], parse_val));
#endif
        fprintf(stderr, "shifting from state %d to state %d\n", *parse_stack.s_mark, parse_state);
    }
#endif
    if (parse_stack.s_mark >= parse_stack.s_last && parse_growstack(&parse_stack) == parse_ENOMEM) goto parse_overflow;
    *++parse_stack.s_mark = (parse_INT) parse_state;
    *++parse_stack.l_mark = parse_val;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
    *++parse_stack.p_mark = parse_loc;
#endif
    goto parse_loop;
#if parse_BTYACC

    /* Reduction declares that this path is valid. Set parse_path and do a full parse */
parse_valid:
    if (parse_path) parse_ABORT;
    while (parse_ps->save)
    {
        parse_ParseState *save = parse_ps->save;
        parse_ps->save = save->save;
        save->save = parse_path;
        parse_path = save;
    }
#if parse_DEBUG
    if (parse_debug)
        fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
                        parse_DEBUGSTR, parse_depth, parse_state, parse_path->state, (int)(parse_lvp - parse_lvals - parse_path->lexeme));
#endif
    if (parse_errctx)
    {
        parse_FreeState(parse_errctx);
        parse_errctx = NULL;
    }
    parse_lvp          = parse_lvals + parse_path->lexeme;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
    parse_lpp          = parse_lpsns + parse_path->lexeme;
#endif
    parse_lexp         = parse_lexemes + parse_path->lexeme;
    parse_char         = parse_EMPTY;
    parse_stack.s_mark = parse_stack.s_base + (parse_path->parse_stack.s_mark - parse_path->parse_stack.s_base);
    memcpy (parse_stack.s_base, parse_path->parse_stack.s_base, (size_t) (parse_stack.s_mark - parse_stack.s_base + 1) * sizeof(parse_INT));
    parse_stack.l_mark = parse_stack.l_base + (parse_path->parse_stack.l_mark - parse_path->parse_stack.l_base);
    memcpy (parse_stack.l_base, parse_path->parse_stack.l_base, (size_t) (parse_stack.l_mark - parse_stack.l_base + 1) * sizeof(parse_STYPE));
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
    parse_stack.p_mark = parse_stack.p_base + (parse_path->parse_stack.p_mark - parse_path->parse_stack.p_base);
    memcpy (parse_stack.p_base, parse_path->parse_stack.p_base, (size_t) (parse_stack.p_mark - parse_stack.p_base + 1) * sizeof(parse_LTYPE));
#endif
    parse_state        = parse_path->state;
    goto parse_loop;
#endif /* parse_BTYACC */

parse_overflow:
    parse_ERROR_CALL("yacc stack overflow");
#if parse_BTYACC
    goto parse_abort_nomem;
parse_enomem:
    parse_ERROR_CALL("memory exhausted");
parse_abort_nomem:
#endif /* parse_BTYACC */
    parse_result = 2;
    goto parse_return;

parse_abort:
    parse_result = 1;
    goto parse_return;

parse_accept:
#if parse_BTYACC
    if (parse_ps->save) goto parse_valid;
#endif /* parse_BTYACC */
    parse_result = 0;

parse_return:
#if defined(parse_DESTRUCT_CALL)
    if (parse_char != parse_EOF && parse_char != parse_EMPTY)
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
        parse_DESTRUCT_CALL("cleanup: discarding token", parse_char, &parse_lval, &parse_lloc);
#else
        parse_DESTRUCT_CALL("cleanup: discarding token", parse_char, &parse_lval);
#endif /* defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED) */

    {
        parse_STYPE *pv;
#if defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED)
        parse_LTYPE *pp;

        for (pv = parse_stack.l_base, pp = parse_stack.p_base; pv <= parse_stack.l_mark; ++pv, ++pp)
             parse_DESTRUCT_CALL("cleanup: discarding state",
                             parse_stos[*(parse_stack.s_base + (pv - parse_stack.l_base))], pv, pp);
#else
        for (pv = parse_stack.l_base; pv <= parse_stack.l_mark; ++pv)
             parse_DESTRUCT_CALL("cleanup: discarding state",
                             parse_stos[*(parse_stack.s_base + (pv - parse_stack.l_base))], pv);
#endif /* defined(parse_LTYPE) || defined(parse_LTYPE_IS_DECLARED) */
    }
#endif /* defined(parse_DESTRUCT_CALL) */

#if parse_BTYACC
    if (parse_errctx)
    {
        parse_FreeState(parse_errctx);
        parse_errctx = NULL;
    }
    while (parse_ps)
    {
        parse_ParseState *save = parse_ps;
        parse_ps = save->save;
        save->save = NULL;
        parse_FreeState(save);
    }
    while (parse_path)
    {
        parse_ParseState *save = parse_path;
        parse_path = save->save;
        save->save = NULL;
        parse_FreeState(save);
    }
#endif /* parse_BTYACC */
    parse_freestack(&parse_stack);
    return (parse_result);
}
