auto import from //depot/cupcake/@135843
diff --git a/src/LR0.c b/src/LR0.c
new file mode 100644
index 0000000..259b891
--- /dev/null
+++ b/src/LR0.c
@@ -0,0 +1,377 @@
+/* Generate the nondeterministic finite state machine for Bison.
+
+   Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002, 2004, 2005 Free
+   Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+
+/* See comments in state.h for the data structures that represent it.
+   The entry point is generate_states.  */
+
+#include <config.h>
+#include "system.h"
+
+#include <bitset.h>
+#include <quotearg.h>
+
+#include "LR0.h"
+#include "closure.h"
+#include "complain.h"
+#include "getargs.h"
+#include "gram.h"
+#include "gram.h"
+#include "lalr.h"
+#include "reader.h"
+#include "reduce.h"
+#include "state.h"
+#include "symtab.h"
+
+typedef struct state_list
+{
+  struct state_list *next;
+  state *state;
+} state_list;
+
+static state_list *first_state = NULL;
+static state_list *last_state = NULL;
+
+
+/*------------------------------------------------------------------.
+| A state was just discovered from another state.  Queue it for     |
+| later examination, in order to find its transitions.  Return it.  |
+`------------------------------------------------------------------*/
+
+static state *
+state_list_append (symbol_number sym, size_t core_size, item_number *core)
+{
+  state_list *node = xmalloc (sizeof *node);
+  state *s = state_new (sym, core_size, core);
+
+  if (trace_flag & trace_automaton)
+    fprintf (stderr, "state_list_append (state = %d, symbol = %d (%s))\n",
+	     nstates, sym, symbols[sym]->tag);
+
+  node->next = NULL;
+  node->state = s;
+
+  if (!first_state)
+    first_state = node;
+  if (last_state)
+    last_state->next = node;
+  last_state = node;
+
+  return s;
+}
+
+static int nshifts;
+static symbol_number *shift_symbol;
+
+static rule **redset;
+static state **shiftset;
+
+static item_number **kernel_base;
+static int *kernel_size;
+static item_number *kernel_items;
+
+
+static void
+allocate_itemsets (void)
+{
+  symbol_number i;
+  rule_number r;
+  item_number *rhsp;
+
+  /* Count the number of occurrences of all the symbols in RITEMS.
+     Note that useless productions (hence useless nonterminals) are
+     browsed too, hence we need to allocate room for _all_ the
+     symbols.  */
+  size_t count = 0;
+  size_t *symbol_count = xcalloc (nsyms + nuseless_nonterminals,
+				  sizeof *symbol_count);
+
+  for (r = 0; r < nrules; ++r)
+    for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
+      {
+	count++;
+	symbol_count[*rhsp]++;
+      }
+
+  /* See comments before new_itemsets.  All the vectors of items
+     live inside KERNEL_ITEMS.  The number of active items after
+     some symbol S cannot be more than the number of times that S
+     appears as an item, which is SYMBOL_COUNT[S].
+     We allocate that much space for each symbol.  */
+
+  kernel_base = xnmalloc (nsyms, sizeof *kernel_base);
+  kernel_items = xnmalloc (count, sizeof *kernel_items);
+
+  count = 0;
+  for (i = 0; i < nsyms; i++)
+    {
+      kernel_base[i] = kernel_items + count;
+      count += symbol_count[i];
+    }
+
+  free (symbol_count);
+  kernel_size = xnmalloc (nsyms, sizeof *kernel_size);
+}
+
+
+static void
+allocate_storage (void)
+{
+  allocate_itemsets ();
+
+  shiftset = xnmalloc (nsyms, sizeof *shiftset);
+  redset = xnmalloc (nrules, sizeof *redset);
+  state_hash_new ();
+  shift_symbol = xnmalloc (nsyms, sizeof *shift_symbol);
+}
+
+
+static void
+free_storage (void)
+{
+  free (shift_symbol);
+  free (redset);
+  free (shiftset);
+  free (kernel_base);
+  free (kernel_size);
+  free (kernel_items);
+  state_hash_free ();
+}
+
+
+
+
+/*---------------------------------------------------------------.
+| Find which symbols can be shifted in S, and for each one       |
+| record which items would be active after that shift.  Uses the |
+| contents of itemset.                                           |
+|                                                                |
+| shift_symbol is set to a vector of the symbols that can be     |
+| shifted.  For each symbol in the grammar, kernel_base[symbol]  |
+| points to a vector of item numbers activated if that symbol is |
+| shifted, and kernel_size[symbol] is their numbers.             |
+`---------------------------------------------------------------*/
+
+static void
+new_itemsets (state *s)
+{
+  size_t i;
+
+  if (trace_flag & trace_automaton)
+    fprintf (stderr, "Entering new_itemsets, state = %d\n", s->number);
+
+  memset (kernel_size, 0, nsyms * sizeof *kernel_size);
+
+  nshifts = 0;
+
+  for (i = 0; i < nritemset; ++i)
+    if (ritem[itemset[i]] >= 0)
+      {
+	symbol_number sym = item_number_as_symbol_number (ritem[itemset[i]]);
+	if (!kernel_size[sym])
+	  {
+	    shift_symbol[nshifts] = sym;
+	    nshifts++;
+	  }
+
+	kernel_base[sym][kernel_size[sym]] = itemset[i] + 1;
+	kernel_size[sym]++;
+      }
+}
+
+
+
+/*--------------------------------------------------------------.
+| Find the state we would get to (from the current state) by    |
+| shifting SYM.  Create a new state if no equivalent one exists |
+| already.  Used by append_states.                              |
+`--------------------------------------------------------------*/
+
+static state *
+get_state (symbol_number sym, size_t core_size, item_number *core)
+{
+  state *s;
+
+  if (trace_flag & trace_automaton)
+    fprintf (stderr, "Entering get_state, symbol = %d (%s)\n",
+	     sym, symbols[sym]->tag);
+
+  s = state_hash_lookup (core_size, core);
+  if (!s)
+    s = state_list_append (sym, core_size, core);
+
+  if (trace_flag & trace_automaton)
+    fprintf (stderr, "Exiting get_state => %d\n", s->number);
+
+  return s;
+}
+
+/*---------------------------------------------------------------.
+| Use the information computed by new_itemsets to find the state |
+| numbers reached by each shift transition from S.		 |
+|                                                                |
+| SHIFTSET is set up as a vector of those states.                |
+`---------------------------------------------------------------*/
+
+static void
+append_states (state *s)
+{
+  int i;
+
+  if (trace_flag & trace_automaton)
+    fprintf (stderr, "Entering append_states, state = %d\n", s->number);
+
+  /* First sort shift_symbol into increasing order.  */
+
+  for (i = 1; i < nshifts; i++)
+    {
+      symbol_number sym = shift_symbol[i];
+      int j;
+      for (j = i; 0 < j && sym < shift_symbol[j - 1]; j--)
+	shift_symbol[j] = shift_symbol[j - 1];
+      shift_symbol[j] = sym;
+    }
+
+  for (i = 0; i < nshifts; i++)
+    {
+      symbol_number sym = shift_symbol[i];
+      shiftset[i] = get_state (sym, kernel_size[sym], kernel_base[sym]);
+    }
+}
+
+
+/*----------------------------------------------------------------.
+| Find which rules can be used for reduction transitions from the |
+| current state and make a reductions structure for the state to  |
+| record their rule numbers.                                      |
+`----------------------------------------------------------------*/
+
+static void
+save_reductions (state *s)
+{
+  int count = 0;
+  size_t i;
+
+  /* Find and count the active items that represent ends of rules. */
+  for (i = 0; i < nritemset; ++i)
+    {
+      item_number item = ritem[itemset[i]];
+      if (item_number_is_rule_number (item))
+	{
+	  rule_number r = item_number_as_rule_number (item);
+	  redset[count++] = &rules[r];
+	  if (r == 0)
+	    {
+	      /* This is "reduce 0", i.e., accept. */
+	      assert (!final_state);
+	      final_state = s;
+	    }
+	}
+    }
+
+  /* Make a reductions structure and copy the data into it.  */
+  state_reductions_set (s, count, redset);
+}
+
+
+/*---------------.
+| Build STATES.  |
+`---------------*/
+
+static void
+set_states (void)
+{
+  states = xcalloc (nstates, sizeof *states);
+
+  while (first_state)
+    {
+      state_list *this = first_state;
+
+      /* Pessimization, but simplification of the code: make sure all
+	 the states have valid transitions and reductions members,
+	 even if reduced to 0.  It is too soon for errs, which are
+	 computed later, but set_conflicts.  */
+      state *s = this->state;
+      if (!s->transitions)
+	state_transitions_set (s, 0, 0);
+      if (!s->reductions)
+	state_reductions_set (s, 0, 0);
+
+      states[s->number] = s;
+
+      first_state = this->next;
+      free (this);
+    }
+  first_state = NULL;
+  last_state = NULL;
+}
+
+
+/*-------------------------------------------------------------------.
+| Compute the nondeterministic finite state machine (see state.h for |
+| details) from the grammar.                                         |
+`-------------------------------------------------------------------*/
+
+void
+generate_states (void)
+{
+  item_number initial_core = 0;
+  state_list *list = NULL;
+  allocate_storage ();
+  new_closure (nritems);
+
+  /* Create the initial state.  The 0 at the lhs is the index of the
+     item of this initial rule.  */
+  state_list_append (0, 1, &initial_core);
+
+  /* States are queued when they are created; process them all.  */
+  for (list = first_state; list; list = list->next)
+    {
+      state *s = list->state;
+      if (trace_flag & trace_automaton)
+	fprintf (stderr, "Processing state %d (reached by %s)\n",
+		 s->number,
+		 symbols[s->accessing_symbol]->tag);
+      /* Set up ruleset and itemset for the transitions out of this
+         state.  ruleset gets a 1 bit for each rule that could reduce
+         now.  itemset gets a vector of all the items that could be
+         accepted next.  */
+      closure (s->items, s->nitems);
+      /* Record the reductions allowed out of this state.  */
+      save_reductions (s);
+      /* Find the itemsets of the states that shifts can reach.  */
+      new_itemsets (s);
+      /* Find or create the core structures for those states.  */
+      append_states (s);
+
+      /* Create the shifts structures for the shifts to those states,
+	 now that the state numbers transitioning to are known.  */
+      state_transitions_set (s, nshifts, shiftset);
+    }
+
+  /* discard various storage */
+  free_closure ();
+  free_storage ();
+
+  /* Set up STATES. */
+  set_states ();
+}
diff --git a/src/LR0.h b/src/LR0.h
new file mode 100644
index 0000000..6004538
--- /dev/null
+++ b/src/LR0.h
@@ -0,0 +1,28 @@
+/* Generate the nondeterministic finite state machine for bison,
+   Copyright 1984, 1986, 1989, 2000, 2001, 2002  Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#ifndef LR0_H_
+# define LR0_H_
+
+# include "state.h"
+
+void generate_states (void);
+
+#endif /* !LR0_H_ */
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..eeb1d5b
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,655 @@
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# src/Makefile.  Generated from Makefile.in by configure.
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+
+
+srcdir = .
+top_srcdir = ..
+
+pkgdatadir = $(datadir)/bison
+pkglibdir = $(libdir)/bison
+pkgincludedir = $(includedir)/bison
+top_builddir = ..
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = /usr/bin/install -c
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = x86_64-unknown-linux-gnu
+host_triplet = x86_64-unknown-linux-gnu
+bin_PROGRAMS = bison$(EXEEXT)
+subdir = src
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in parse-gram.c \
+	scan-gram.c scan-skel.c
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/bison-i18n.m4 \
+	$(top_srcdir)/m4/c-working.m4 $(top_srcdir)/m4/cxx.m4 \
+	$(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dmalloc.m4 \
+	$(top_srcdir)/m4/dos.m4 $(top_srcdir)/m4/error.m4 \
+	$(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/extensions.m4 \
+	$(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/gettext_gl.m4 \
+	$(top_srcdir)/m4/gnulib.m4 $(top_srcdir)/m4/hard-locale.m4 \
+	$(top_srcdir)/m4/hash.m4 $(top_srcdir)/m4/iconv.m4 \
+	$(top_srcdir)/m4/inttypes_h_gl.m4 \
+	$(top_srcdir)/m4/lib-ld_gl.m4 $(top_srcdir)/m4/lib-link.m4 \
+	$(top_srcdir)/m4/lib-prefix_gl.m4 $(top_srcdir)/m4/m4.m4 \
+	$(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbstate_t.m4 \
+	$(top_srcdir)/m4/mbswidth.m4 $(top_srcdir)/m4/nls.m4 \
+	$(top_srcdir)/m4/obstack.m4 $(top_srcdir)/m4/onceonly.m4 \
+	$(top_srcdir)/m4/po_gl.m4 $(top_srcdir)/m4/progtest.m4 \
+	$(top_srcdir)/m4/quote.m4 $(top_srcdir)/m4/quotearg.m4 \
+	$(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stdint_h_gl.m4 \
+	$(top_srcdir)/m4/stdio-safer.m4 $(top_srcdir)/m4/stpcpy.m4 \
+	$(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \
+	$(top_srcdir)/m4/strndup.m4 $(top_srcdir)/m4/strnlen.m4 \
+	$(top_srcdir)/m4/strtol.m4 $(top_srcdir)/m4/strtoul.m4 \
+	$(top_srcdir)/m4/strverscmp.m4 $(top_srcdir)/m4/subpipe.m4 \
+	$(top_srcdir)/m4/timevar.m4 $(top_srcdir)/m4/uintmax_t_gl.m4 \
+	$(top_srcdir)/m4/ulonglong_gl.m4 \
+	$(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/unistd_h.m4 \
+	$(top_srcdir)/m4/unlocked-io.m4 $(top_srcdir)/m4/warning.m4 \
+	$(top_srcdir)/m4/xalloc.m4 $(top_srcdir)/m4/xstrndup.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/build-aux/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_bison_OBJECTS = LR0.$(OBJEXT) assoc.$(OBJEXT) closure.$(OBJEXT) \
+	complain.$(OBJEXT) conflicts.$(OBJEXT) derives.$(OBJEXT) \
+	files.$(OBJEXT) getargs.$(OBJEXT) gram.$(OBJEXT) \
+	lalr.$(OBJEXT) location.$(OBJEXT) main.$(OBJEXT) \
+	muscle_tab.$(OBJEXT) nullable.$(OBJEXT) output.$(OBJEXT) \
+	parse-gram.$(OBJEXT) print.$(OBJEXT) print_graph.$(OBJEXT) \
+	reader.$(OBJEXT) reduce.$(OBJEXT) relation.$(OBJEXT) \
+	scan-gram-c.$(OBJEXT) scan-skel-c.$(OBJEXT) state.$(OBJEXT) \
+	symlist.$(OBJEXT) symtab.$(OBJEXT) tables.$(OBJEXT) \
+	uniqstr.$(OBJEXT) vcg.$(OBJEXT)
+bison_OBJECTS = $(am_bison_OBJECTS)
+bison_LDADD = $(LDADD)
+am__DEPENDENCIES_1 =
+bison_DEPENDENCIES = ../lib/libbison.a $(am__DEPENDENCIES_1)
+binSCRIPT_INSTALL = $(INSTALL_SCRIPT)
+SCRIPTS = $(bin_SCRIPTS)
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS)
+YLWRAP = $(top_srcdir)/build-aux/ylwrap
+YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS)
+SOURCES = $(bison_SOURCES) $(EXTRA_bison_SOURCES)
+DIST_SOURCES = $(bison_SOURCES) $(EXTRA_bison_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = ${SHELL} /usr/local/google/workspace/WebKit/tools/bison-2.3/build-aux/missing --run aclocal-1.9
+AMDEP_FALSE = #
+AMDEP_TRUE = 
+AMTAR = ${SHELL} /usr/local/google/workspace/WebKit/tools/bison-2.3/build-aux/missing --run tar
+AUTOCONF = ${SHELL} /usr/local/google/workspace/WebKit/tools/bison-2.3/build-aux/missing --run autoconf
+AUTOHEADER = ${SHELL} /usr/local/google/workspace/WebKit/tools/bison-2.3/build-aux/missing --run autoheader
+AUTOM4TE = ${SHELL} /usr/local/google/workspace/WebKit/tools/bison-2.3/build-aux/missing --run autom4te
+AUTOMAKE = ${SHELL} /usr/local/google/workspace/WebKit/tools/bison-2.3/build-aux/missing --run automake-1.9
+AWK = gawk
+BISON_CXX_WORKS = :
+BISON_CXX_WORKS_FALSE = #
+BISON_CXX_WORKS_TRUE = 
+BISON_LOCALEDIR = /usr/share/locale
+CC = gcc
+CCDEPMODE = depmode=gcc3
+CFLAGS = -g -O2
+CPP = gcc -E
+CPPFLAGS = 
+CXX = g++
+CXXDEPMODE = depmode=gcc3
+CXXFLAGS = -g -O2
+CYGPATH_W = echo
+DEFS = -DHAVE_CONFIG_H -DPKGDATADIR=\"$(pkgdatadir)\" \
+	-DLOCALEDIR=\"$(datadir)/locale\"
+DEPDIR = .deps
+ECHO_C = 
+ECHO_N = -n
+ECHO_T = 
+EGREP = grep -E
+EXEEXT = 
+GCC = yes
+GETOPT_H = 
+GMSGFMT = /usr/bin/msgfmt
+HAVE__BOOL = 1
+INSTALL_DATA = ${INSTALL} -m 644
+INSTALL_PROGRAM = ${INSTALL}
+INSTALL_SCRIPT = ${INSTALL}
+INSTALL_STRIP_PROGRAM = ${SHELL} $(install_sh) -c -s
+INTLLIBS = 
+INTL_MACOSX_LIBS = 
+LDFLAGS = 
+LEX = flex
+LEXLIB = -lfl
+LEX_OUTPUT_ROOT = lex.yy
+LIBICONV = -liconv
+LIBINTL = 
+LIBOBJS =  dirname$U.o exitfail$U.o hard-locale$U.o hash$U.o quote$U.o quotearg$U.o fopen-safer$U.o dup-safer$U.o fd-safer$U.o pipe-safer$U.o xmalloc$U.o
+LIBS = 
+LTLIBICONV = -liconv
+LTLIBINTL = 
+LTLIBOBJS =  dirname$U.lo exitfail$U.lo hard-locale$U.lo hash$U.lo quote$U.lo quotearg$U.lo fopen-safer$U.lo dup-safer$U.lo fd-safer$U.lo pipe-safer$U.lo xmalloc$U.lo
+M4 = /usr/bin/m4
+MAKEINFO = ${SHELL} /usr/local/google/workspace/WebKit/tools/bison-2.3/build-aux/missing --run makeinfo
+MKINSTALLDIRS = $(top_builddir)/build-aux/mkinstalldirs
+MSGFMT = /usr/bin/msgfmt
+MSGMERGE = /usr/bin/msgmerge
+O0CFLAGS = -g 
+O0CXXFLAGS = -g 
+OBJEXT = o
+PACKAGE = bison
+PACKAGE_BUGREPORT = bug-bison@gnu.org
+PACKAGE_NAME = GNU Bison
+PACKAGE_STRING = GNU Bison 2.3
+PACKAGE_TARNAME = bison
+PACKAGE_VERSION = 2.3
+PATH_SEPARATOR = :
+POSUB = po
+RANLIB = ranlib
+SET_MAKE = 
+SHELL = /bin/sh
+STDBOOL_H = 
+STRIP = 
+UNISTD_H = 
+USE_NLS = yes
+VALGRIND = 
+VERSION = 2.3
+WARNING_CFLAGS = 
+WARNING_CXXFLAGS = 
+WERROR_CFLAGS = 
+XGETTEXT = /usr/bin/xgettext
+
+# Use our own Bison to build the parser.  Of course, you ought to
+# keep a sane version of Bison nearby...
+YACC = ../tests/bison -y
+YACC_LIBRARY = liby.a
+YACC_SCRIPT = yacc
+ac_ct_CC = gcc
+ac_ct_CXX = g++
+ac_ct_RANLIB = ranlib
+ac_ct_STRIP = 
+aclocaldir = ${datadir}/aclocal
+am__fastdepCC_FALSE = #
+am__fastdepCC_TRUE = 
+am__fastdepCXX_FALSE = #
+am__fastdepCXX_TRUE = 
+am__include = include
+am__leading_dot = .
+am__quote = 
+am__tar = ${AMTAR} chof - "$$tardir"
+am__untar = ${AMTAR} xf -
+bindir = ${exec_prefix}/bin
+build = x86_64-unknown-linux-gnu
+build_alias = 
+build_cpu = x86_64
+build_os = linux-gnu
+build_vendor = unknown
+datadir = ${prefix}/share
+exec_prefix = ${prefix}
+host = x86_64-unknown-linux-gnu
+host_alias = 
+host_cpu = x86_64
+host_os = linux-gnu
+host_vendor = unknown
+includedir = ${prefix}/include
+infodir = ${prefix}/info
+install_sh = /usr/local/google/workspace/WebKit/tools/bison-2.3/build-aux/install-sh
+libdir = ${exec_prefix}/lib
+libexecdir = ${exec_prefix}/libexec
+localstatedir = ${prefix}/var
+mandir = ${prefix}/man
+mkdir_p = mkdir -p --
+oldincludedir = /usr/include
+prefix = /home/phanna/src/bison
+program_transform_name = s,x,x,
+sbindir = ${exec_prefix}/sbin
+sharedstatedir = ${prefix}/com
+sysconfdir = ${prefix}/etc
+target_alias = 
+AM_CFLAGS = $(WARNING_CFLAGS) $(WERROR_CFLAGS)
+AM_CPPFLAGS = -I$(top_srcdir)/lib -I../lib
+AM_YFLAGS = "-dv"
+LDADD = ../lib/libbison.a $(LIBINTL)
+bin_SCRIPTS = $(YACC_SCRIPT)
+EXTRA_SCRIPTS = yacc
+bison_SOURCES = \
+	LR0.c LR0.h				  \
+	assoc.c assoc.h				  \
+	closure.c closure.h			  \
+	complain.c complain.h			  \
+	conflicts.c conflicts.h			  \
+	derives.c derives.h			  \
+	files.c files.h				  \
+	getargs.c getargs.h			  \
+	gram.c gram.h				  \
+	lalr.h lalr.c				  \
+	location.c location.h			  \
+	main.c					  \
+	muscle_tab.c muscle_tab.h		  \
+	nullable.c nullable.h			  \
+	output.c output.h			  \
+	parse-gram.h parse-gram.y		  \
+	print.c print.h				  \
+	print_graph.c print_graph.h		  \
+	reader.c reader.h			  \
+	reduce.c reduce.h			  \
+	relation.c relation.h			  \
+	scan-gram-c.c				  \
+	scan-skel-c.c scan-skel.h		  \
+	state.c state.h				  \
+	symlist.c symlist.h			  \
+	symtab.c symtab.h			  \
+	system.h				  \
+	tables.h tables.c			  \
+	uniqstr.c uniqstr.h			  \
+	vcg.c vcg.h				  \
+	vcg_defaults.h
+
+EXTRA_bison_SOURCES = scan-skel.l scan-gram.l
+BUILT_SOURCES = scan-skel.c scan-gram.c parse-gram.c parse-gram.h
+MOSTLYCLEANFILES = yacc
+all: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .l .o .obj .y
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  src/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-binPROGRAMS: $(bin_PROGRAMS)
+	@$(NORMAL_INSTALL)
+	test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
+	@list='$(bin_PROGRAMS)'; for p in $$list; do \
+	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  if test -f $$p \
+	  ; then \
+	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+	  else :; fi; \
+	done
+
+uninstall-binPROGRAMS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(bin_PROGRAMS)'; for p in $$list; do \
+	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
+	done
+
+clean-binPROGRAMS:
+	-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
+bison$(EXEEXT): $(bison_OBJECTS) $(bison_DEPENDENCIES) 
+	@rm -f bison$(EXEEXT)
+	$(LINK) $(bison_LDFLAGS) $(bison_OBJECTS) $(bison_LDADD) $(LIBS)
+install-binSCRIPTS: $(bin_SCRIPTS)
+	@$(NORMAL_INSTALL)
+	test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
+	@list='$(bin_SCRIPTS)'; for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  if test -f $$d$$p; then \
+	    f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
+	    echo " $(binSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	    $(binSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(bindir)/$$f"; \
+	  else :; fi; \
+	done
+
+uninstall-binSCRIPTS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(bin_SCRIPTS)'; for p in $$list; do \
+	  f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
+	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
+	done
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+include ./$(DEPDIR)/LR0.Po
+include ./$(DEPDIR)/assoc.Po
+include ./$(DEPDIR)/closure.Po
+include ./$(DEPDIR)/complain.Po
+include ./$(DEPDIR)/conflicts.Po
+include ./$(DEPDIR)/derives.Po
+include ./$(DEPDIR)/files.Po
+include ./$(DEPDIR)/getargs.Po
+include ./$(DEPDIR)/gram.Po
+include ./$(DEPDIR)/lalr.Po
+include ./$(DEPDIR)/location.Po
+include ./$(DEPDIR)/main.Po
+include ./$(DEPDIR)/muscle_tab.Po
+include ./$(DEPDIR)/nullable.Po
+include ./$(DEPDIR)/output.Po
+include ./$(DEPDIR)/parse-gram.Po
+include ./$(DEPDIR)/print.Po
+include ./$(DEPDIR)/print_graph.Po
+include ./$(DEPDIR)/reader.Po
+include ./$(DEPDIR)/reduce.Po
+include ./$(DEPDIR)/relation.Po
+include ./$(DEPDIR)/scan-gram-c.Po
+include ./$(DEPDIR)/scan-gram.Po
+include ./$(DEPDIR)/scan-skel-c.Po
+include ./$(DEPDIR)/scan-skel.Po
+include ./$(DEPDIR)/state.Po
+include ./$(DEPDIR)/symlist.Po
+include ./$(DEPDIR)/symtab.Po
+include ./$(DEPDIR)/tables.Po
+include ./$(DEPDIR)/uniqstr.Po
+include ./$(DEPDIR)/vcg.Po
+
+.c.o:
+	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+#	source='$<' object='$@' libtool=no \
+#	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+#	$(COMPILE) -c $<
+
+.c.obj:
+	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
+	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+#	source='$<' object='$@' libtool=no \
+#	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+#	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.l.c:
+	$(SHELL) $(YLWRAP) $< $(LEX_OUTPUT_ROOT).c $@ -- $(LEXCOMPILE)
+
+.y.c:
+	$(YACCCOMPILE) $<
+	if test -f y.tab.h; then \
+	  to=`echo "$*_H" | sed \
+                -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
+                -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`; \
+	  sed -e "/^#/!b" -e "s/Y_TAB_H/$$to/g" -e "s|y\.tab\.h|$*.h|" \
+            y.tab.h >$*.ht; \
+	  rm -f y.tab.h; \
+	  if cmp -s $*.ht $*.h; then \
+	    rm -f $*.ht ;\
+	  else \
+	    mv $*.ht $*.h; \
+	  fi; \
+	fi
+	if test -f y.output; then \
+	  mv y.output $*.output; \
+	fi
+	sed '/^#/ s|y\.tab\.c|$@|' y.tab.c >$@t && mv $@t $@
+	rm -f y.tab.c
+uninstall-info-am:
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkdir_p) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
+	  if test -d $$d/$$file; then \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(PROGRAMS) $(SCRIPTS)
+installdirs:
+	for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"; do \
+	  test -z "$$dir" || $(mkdir_p) "$$dir"; \
+	done
+install: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+	-test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+	-rm -f parse-gram.c
+	-rm -f scan-gram.c
+	-rm -f scan-skel.c
+	-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am: install-binPROGRAMS install-binSCRIPTS
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS \
+	uninstall-info-am
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+	clean-generic ctags distclean distclean-compile \
+	distclean-generic distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-binPROGRAMS \
+	install-binSCRIPTS install-data install-data-am install-exec \
+	install-exec-am install-info install-info-am install-man \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-binPROGRAMS \
+	uninstall-binSCRIPTS uninstall-info-am
+
+
+yacc:
+	echo '#! /bin/sh' >$@
+	echo 'exec $(bindir)/bison -y "$$@"' >>$@
+	chmod a+x $@
+
+echo:
+	echo $(bison_SOURCES) $(noinst_HEADERS)
+
+# The following rule is not designed to be portable,
+# and relies on tools that not everyone has.
+
+# Most functions in src/*.c should have static scope.
+# Any that don't must be marked with `extern', but `main'
+# and `usage' are exceptions.  They're always extern, but
+# don't need to be marked.
+#
+# The second nm|grep checks for file-scope variables with `extern' scope.
+sc_tight_scope: $(all_programs)
+	@t=exceptions-$$$$;						\
+	trap 's=$$?; rm -f $$t; exit $$s' 0 1 2 13 15;			\
+	( printf '^main$$\n^usage$$\n';					\
+	  grep -h -A1 '^extern .*[^;]$$' $(SOURCES)			\
+	    | grep -vE '^(extern |--)' |sed 's/^/^/;s/ .*/$$/' ) > $$t;	\
+	if nm -e *.$(OBJEXT)						\
+	    | sed -n 's/.* T //p'					\
+	    | grep -Ev -f $$t; then					\
+	  echo 'the above functions should have static scope' 1>&2;	\
+	  exit 1;							\
+	fi;								\
+	( printf '^program_name$$\n';					\
+	  sed -n 's/^extern .*[* ]\([a-zA-Z_][a-zA-Z_0-9]*\);$$/^\1$$/p' \
+	    $$(ls $(SOURCES) | grep '\.h$$') /dev/null) > $$t;		\
+	if nm -e *.$(OBJEXT)						\
+	    | sed -n 's/.* [BD] //p'					\
+	    | grep -Ev -f $$t; then					\
+	  echo 'the above variables should have static scope' 1>&2;	\
+	  exit 1;							\
+	fi
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..c973e9e
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,110 @@
+## Copyright (C) 2001, 2002, 2003, 2004, 2005 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 2 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, write to the Free Software
+## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+## 02110-1301  USA
+
+DEFS += -DPKGDATADIR=\"$(pkgdatadir)\" -DLOCALEDIR=\"$(datadir)/locale\"
+
+AM_CFLAGS = $(WARNING_CFLAGS) $(WERROR_CFLAGS)
+AM_CPPFLAGS = -I$(top_srcdir)/lib -I../lib
+AM_YFLAGS = "-dv"
+
+LDADD = ../lib/libbison.a $(LIBINTL)
+
+# Use our own Bison to build the parser.  Of course, you ought to
+# keep a sane version of Bison nearby...
+YACC = ../tests/bison -y
+
+bin_PROGRAMS = bison
+bin_SCRIPTS = $(YACC_SCRIPT)
+EXTRA_SCRIPTS = yacc
+
+bison_SOURCES =					  \
+	LR0.c LR0.h				  \
+	assoc.c assoc.h				  \
+	closure.c closure.h			  \
+	complain.c complain.h			  \
+	conflicts.c conflicts.h			  \
+	derives.c derives.h			  \
+	files.c files.h				  \
+	getargs.c getargs.h			  \
+	gram.c gram.h				  \
+	lalr.h lalr.c				  \
+	location.c location.h			  \
+	main.c					  \
+	muscle_tab.c muscle_tab.h		  \
+	nullable.c nullable.h			  \
+	output.c output.h			  \
+	parse-gram.h parse-gram.y		  \
+	print.c print.h				  \
+	print_graph.c print_graph.h		  \
+	reader.c reader.h			  \
+	reduce.c reduce.h			  \
+	relation.c relation.h			  \
+	scan-gram-c.c				  \
+	scan-skel-c.c scan-skel.h		  \
+	state.c state.h				  \
+	symlist.c symlist.h			  \
+	symtab.c symtab.h			  \
+	system.h				  \
+	tables.h tables.c			  \
+	uniqstr.c uniqstr.h			  \
+	vcg.c vcg.h				  \
+	vcg_defaults.h
+
+EXTRA_bison_SOURCES = scan-skel.l scan-gram.l
+
+BUILT_SOURCES = scan-skel.c scan-gram.c parse-gram.c parse-gram.h
+
+MOSTLYCLEANFILES = yacc
+
+yacc:
+	echo '#! /bin/sh' >$@
+	echo 'exec $(bindir)/bison -y "$$@"' >>$@
+	chmod a+x $@
+
+echo:
+	echo $(bison_SOURCES) $(noinst_HEADERS)
+
+# The following rule is not designed to be portable,
+# and relies on tools that not everyone has.
+
+# Most functions in src/*.c should have static scope.
+# Any that don't must be marked with `extern', but `main'
+# and `usage' are exceptions.  They're always extern, but
+# don't need to be marked.
+#
+# The second nm|grep checks for file-scope variables with `extern' scope.
+sc_tight_scope: $(all_programs)
+	@t=exceptions-$$$$;						\
+	trap 's=$$?; rm -f $$t; exit $$s' 0 1 2 13 15;			\
+	( printf '^main$$\n^usage$$\n';					\
+	  grep -h -A1 '^extern .*[^;]$$' $(SOURCES)			\
+	    | grep -vE '^(extern |--)' |sed 's/^/^/;s/ .*/$$/' ) > $$t;	\
+	if nm -e *.$(OBJEXT)						\
+	    | sed -n 's/.* T //p'					\
+	    | grep -Ev -f $$t; then					\
+	  echo 'the above functions should have static scope' 1>&2;	\
+	  exit 1;							\
+	fi;								\
+	( printf '^program_name$$\n';					\
+	  sed -n 's/^extern .*[* ]\([a-zA-Z_][a-zA-Z_0-9]*\);$$/^\1$$/p' \
+	    $$(ls $(SOURCES) | grep '\.h$$') /dev/null) > $$t;		\
+	if nm -e *.$(OBJEXT)						\
+	    | sed -n 's/.* [BD] //p'					\
+	    | grep -Ev -f $$t; then					\
+	  echo 'the above variables should have static scope' 1>&2;	\
+	  exit 1;							\
+	fi
diff --git a/src/Makefile.in b/src/Makefile.in
new file mode 100644
index 0000000..7de9081
--- /dev/null
+++ b/src/Makefile.in
@@ -0,0 +1,655 @@
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = bison$(EXEEXT)
+subdir = src
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in parse-gram.c \
+	scan-gram.c scan-skel.c
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/bison-i18n.m4 \
+	$(top_srcdir)/m4/c-working.m4 $(top_srcdir)/m4/cxx.m4 \
+	$(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dmalloc.m4 \
+	$(top_srcdir)/m4/dos.m4 $(top_srcdir)/m4/error.m4 \
+	$(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/extensions.m4 \
+	$(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/gettext_gl.m4 \
+	$(top_srcdir)/m4/gnulib.m4 $(top_srcdir)/m4/hard-locale.m4 \
+	$(top_srcdir)/m4/hash.m4 $(top_srcdir)/m4/iconv.m4 \
+	$(top_srcdir)/m4/inttypes_h_gl.m4 \
+	$(top_srcdir)/m4/lib-ld_gl.m4 $(top_srcdir)/m4/lib-link.m4 \
+	$(top_srcdir)/m4/lib-prefix_gl.m4 $(top_srcdir)/m4/m4.m4 \
+	$(top_srcdir)/m4/mbrtowc.m4 $(top_srcdir)/m4/mbstate_t.m4 \
+	$(top_srcdir)/m4/mbswidth.m4 $(top_srcdir)/m4/nls.m4 \
+	$(top_srcdir)/m4/obstack.m4 $(top_srcdir)/m4/onceonly.m4 \
+	$(top_srcdir)/m4/po_gl.m4 $(top_srcdir)/m4/progtest.m4 \
+	$(top_srcdir)/m4/quote.m4 $(top_srcdir)/m4/quotearg.m4 \
+	$(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stdint_h_gl.m4 \
+	$(top_srcdir)/m4/stdio-safer.m4 $(top_srcdir)/m4/stpcpy.m4 \
+	$(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \
+	$(top_srcdir)/m4/strndup.m4 $(top_srcdir)/m4/strnlen.m4 \
+	$(top_srcdir)/m4/strtol.m4 $(top_srcdir)/m4/strtoul.m4 \
+	$(top_srcdir)/m4/strverscmp.m4 $(top_srcdir)/m4/subpipe.m4 \
+	$(top_srcdir)/m4/timevar.m4 $(top_srcdir)/m4/uintmax_t_gl.m4 \
+	$(top_srcdir)/m4/ulonglong_gl.m4 \
+	$(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/unistd_h.m4 \
+	$(top_srcdir)/m4/unlocked-io.m4 $(top_srcdir)/m4/warning.m4 \
+	$(top_srcdir)/m4/xalloc.m4 $(top_srcdir)/m4/xstrndup.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/build-aux/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_bison_OBJECTS = LR0.$(OBJEXT) assoc.$(OBJEXT) closure.$(OBJEXT) \
+	complain.$(OBJEXT) conflicts.$(OBJEXT) derives.$(OBJEXT) \
+	files.$(OBJEXT) getargs.$(OBJEXT) gram.$(OBJEXT) \
+	lalr.$(OBJEXT) location.$(OBJEXT) main.$(OBJEXT) \
+	muscle_tab.$(OBJEXT) nullable.$(OBJEXT) output.$(OBJEXT) \
+	parse-gram.$(OBJEXT) print.$(OBJEXT) print_graph.$(OBJEXT) \
+	reader.$(OBJEXT) reduce.$(OBJEXT) relation.$(OBJEXT) \
+	scan-gram-c.$(OBJEXT) scan-skel-c.$(OBJEXT) state.$(OBJEXT) \
+	symlist.$(OBJEXT) symtab.$(OBJEXT) tables.$(OBJEXT) \
+	uniqstr.$(OBJEXT) vcg.$(OBJEXT)
+bison_OBJECTS = $(am_bison_OBJECTS)
+bison_LDADD = $(LDADD)
+am__DEPENDENCIES_1 =
+bison_DEPENDENCIES = ../lib/libbison.a $(am__DEPENDENCIES_1)
+binSCRIPT_INSTALL = $(INSTALL_SCRIPT)
+SCRIPTS = $(bin_SCRIPTS)
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS)
+YLWRAP = $(top_srcdir)/build-aux/ylwrap
+YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS)
+SOURCES = $(bison_SOURCES) $(EXTRA_bison_SOURCES)
+DIST_SOURCES = $(bison_SOURCES) $(EXTRA_bison_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOM4TE = @AUTOM4TE@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BISON_CXX_WORKS = @BISON_CXX_WORKS@
+BISON_CXX_WORKS_FALSE = @BISON_CXX_WORKS_FALSE@
+BISON_CXX_WORKS_TRUE = @BISON_CXX_WORKS_TRUE@
+BISON_LOCALEDIR = @BISON_LOCALEDIR@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@ -DPKGDATADIR=\"$(pkgdatadir)\" \
+	-DLOCALEDIR=\"$(datadir)/locale\"
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GCC = @GCC@
+GETOPT_H = @GETOPT_H@
+GMSGFMT = @GMSGFMT@
+HAVE__BOOL = @HAVE__BOOL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTLLIBS = @INTLLIBS@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LDFLAGS = @LDFLAGS@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+M4 = @M4@
+MAKEINFO = @MAKEINFO@
+MKINSTALLDIRS = @MKINSTALLDIRS@
+MSGFMT = @MSGFMT@
+MSGMERGE = @MSGMERGE@
+O0CFLAGS = @O0CFLAGS@
+O0CXXFLAGS = @O0CXXFLAGS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+POSUB = @POSUB@
+RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STDBOOL_H = @STDBOOL_H@
+STRIP = @STRIP@
+UNISTD_H = @UNISTD_H@
+USE_NLS = @USE_NLS@
+VALGRIND = @VALGRIND@
+VERSION = @VERSION@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+WARNING_CXXFLAGS = @WARNING_CXXFLAGS@
+WERROR_CFLAGS = @WERROR_CFLAGS@
+XGETTEXT = @XGETTEXT@
+
+# Use our own Bison to build the parser.  Of course, you ought to
+# keep a sane version of Bison nearby...
+YACC = ../tests/bison -y
+YACC_LIBRARY = @YACC_LIBRARY@
+YACC_SCRIPT = @YACC_SCRIPT@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+aclocaldir = @aclocaldir@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+AM_CFLAGS = $(WARNING_CFLAGS) $(WERROR_CFLAGS)
+AM_CPPFLAGS = -I$(top_srcdir)/lib -I../lib
+AM_YFLAGS = "-dv"
+LDADD = ../lib/libbison.a $(LIBINTL)
+bin_SCRIPTS = $(YACC_SCRIPT)
+EXTRA_SCRIPTS = yacc
+bison_SOURCES = \
+	LR0.c LR0.h				  \
+	assoc.c assoc.h				  \
+	closure.c closure.h			  \
+	complain.c complain.h			  \
+	conflicts.c conflicts.h			  \
+	derives.c derives.h			  \
+	files.c files.h				  \
+	getargs.c getargs.h			  \
+	gram.c gram.h				  \
+	lalr.h lalr.c				  \
+	location.c location.h			  \
+	main.c					  \
+	muscle_tab.c muscle_tab.h		  \
+	nullable.c nullable.h			  \
+	output.c output.h			  \
+	parse-gram.h parse-gram.y		  \
+	print.c print.h				  \
+	print_graph.c print_graph.h		  \
+	reader.c reader.h			  \
+	reduce.c reduce.h			  \
+	relation.c relation.h			  \
+	scan-gram-c.c				  \
+	scan-skel-c.c scan-skel.h		  \
+	state.c state.h				  \
+	symlist.c symlist.h			  \
+	symtab.c symtab.h			  \
+	system.h				  \
+	tables.h tables.c			  \
+	uniqstr.c uniqstr.h			  \
+	vcg.c vcg.h				  \
+	vcg_defaults.h
+
+EXTRA_bison_SOURCES = scan-skel.l scan-gram.l
+BUILT_SOURCES = scan-skel.c scan-gram.c parse-gram.c parse-gram.h
+MOSTLYCLEANFILES = yacc
+all: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .l .o .obj .y
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  src/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-binPROGRAMS: $(bin_PROGRAMS)
+	@$(NORMAL_INSTALL)
+	test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
+	@list='$(bin_PROGRAMS)'; for p in $$list; do \
+	  p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+	  if test -f $$p \
+	  ; then \
+	    f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+	   echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	   $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+	  else :; fi; \
+	done
+
+uninstall-binPROGRAMS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(bin_PROGRAMS)'; for p in $$list; do \
+	  f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
+	done
+
+clean-binPROGRAMS:
+	-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
+bison$(EXEEXT): $(bison_OBJECTS) $(bison_DEPENDENCIES) 
+	@rm -f bison$(EXEEXT)
+	$(LINK) $(bison_LDFLAGS) $(bison_OBJECTS) $(bison_LDADD) $(LIBS)
+install-binSCRIPTS: $(bin_SCRIPTS)
+	@$(NORMAL_INSTALL)
+	test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
+	@list='$(bin_SCRIPTS)'; for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  if test -f $$d$$p; then \
+	    f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
+	    echo " $(binSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+	    $(binSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(bindir)/$$f"; \
+	  else :; fi; \
+	done
+
+uninstall-binSCRIPTS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(bin_SCRIPTS)'; for p in $$list; do \
+	  f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
+	  echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+	  rm -f "$(DESTDIR)$(bindir)/$$f"; \
+	done
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LR0.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/assoc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/closure.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/complain.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conflicts.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/derives.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/files.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getargs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gram.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lalr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/location.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/muscle_tab.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nullable.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/output.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse-gram.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print_graph.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reader.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reduce.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/relation.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scan-gram-c.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scan-gram.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scan-skel-c.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scan-skel.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/state.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symlist.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symtab.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tables.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uniqstr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vcg.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
+@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.l.c:
+	$(SHELL) $(YLWRAP) $< $(LEX_OUTPUT_ROOT).c $@ -- $(LEXCOMPILE)
+
+.y.c:
+	$(YACCCOMPILE) $<
+	if test -f y.tab.h; then \
+	  to=`echo "$*_H" | sed \
+                -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
+                -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`; \
+	  sed -e "/^#/!b" -e "s/Y_TAB_H/$$to/g" -e "s|y\.tab\.h|$*.h|" \
+            y.tab.h >$*.ht; \
+	  rm -f y.tab.h; \
+	  if cmp -s $*.ht $*.h; then \
+	    rm -f $*.ht ;\
+	  else \
+	    mv $*.ht $*.h; \
+	  fi; \
+	fi
+	if test -f y.output; then \
+	  mv y.output $*.output; \
+	fi
+	sed '/^#/ s|y\.tab\.c|$@|' y.tab.c >$@t && mv $@t $@
+	rm -f y.tab.c
+uninstall-info-am:
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkdir_p) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
+	  if test -d $$d/$$file; then \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(PROGRAMS) $(SCRIPTS)
+installdirs:
+	for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"; do \
+	  test -z "$$dir" || $(mkdir_p) "$$dir"; \
+	done
+install: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+	-test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+	-rm -f parse-gram.c
+	-rm -f scan-gram.c
+	-rm -f scan-skel.c
+	-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am: install-binPROGRAMS install-binSCRIPTS
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS \
+	uninstall-info-am
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+	clean-generic ctags distclean distclean-compile \
+	distclean-generic distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-binPROGRAMS \
+	install-binSCRIPTS install-data install-data-am install-exec \
+	install-exec-am install-info install-info-am install-man \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
+	tags uninstall uninstall-am uninstall-binPROGRAMS \
+	uninstall-binSCRIPTS uninstall-info-am
+
+
+yacc:
+	echo '#! /bin/sh' >$@
+	echo 'exec $(bindir)/bison -y "$$@"' >>$@
+	chmod a+x $@
+
+echo:
+	echo $(bison_SOURCES) $(noinst_HEADERS)
+
+# The following rule is not designed to be portable,
+# and relies on tools that not everyone has.
+
+# Most functions in src/*.c should have static scope.
+# Any that don't must be marked with `extern', but `main'
+# and `usage' are exceptions.  They're always extern, but
+# don't need to be marked.
+#
+# The second nm|grep checks for file-scope variables with `extern' scope.
+sc_tight_scope: $(all_programs)
+	@t=exceptions-$$$$;						\
+	trap 's=$$?; rm -f $$t; exit $$s' 0 1 2 13 15;			\
+	( printf '^main$$\n^usage$$\n';					\
+	  grep -h -A1 '^extern .*[^;]$$' $(SOURCES)			\
+	    | grep -vE '^(extern |--)' |sed 's/^/^/;s/ .*/$$/' ) > $$t;	\
+	if nm -e *.$(OBJEXT)						\
+	    | sed -n 's/.* T //p'					\
+	    | grep -Ev -f $$t; then					\
+	  echo 'the above functions should have static scope' 1>&2;	\
+	  exit 1;							\
+	fi;								\
+	( printf '^program_name$$\n';					\
+	  sed -n 's/^extern .*[* ]\([a-zA-Z_][a-zA-Z_0-9]*\);$$/^\1$$/p' \
+	    $$(ls $(SOURCES) | grep '\.h$$') /dev/null) > $$t;		\
+	if nm -e *.$(OBJEXT)						\
+	    | sed -n 's/.* [BD] //p'					\
+	    | grep -Ev -f $$t; then					\
+	  echo 'the above variables should have static scope' 1>&2;	\
+	  exit 1;							\
+	fi
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/assoc.c b/src/assoc.c
new file mode 100644
index 0000000..6f9a3b5
--- /dev/null
+++ b/src/assoc.c
@@ -0,0 +1,47 @@
+/* Associativity information.
+   Copyright (C) 2002, 2005, 2006 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+#include "system.h"
+
+#include "assoc.h"
+
+
+const char *
+assoc_to_string (assoc a)
+{
+  switch (a)
+    {
+    default:
+      abort ();
+
+    case undef_assoc:
+      return "undefined associativity";
+
+    case right_assoc:
+      return "%right";
+
+    case left_assoc:
+      return "%left";
+
+    case non_assoc:
+      return "%nonassoc";
+    }
+}
diff --git a/src/assoc.h b/src/assoc.h
new file mode 100644
index 0000000..778a451
--- /dev/null
+++ b/src/assoc.h
@@ -0,0 +1,35 @@
+/* Associativity information.
+   Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#ifndef ASSOC_H_
+# define ASSOC_H_
+
+/* Associativity values for tokens and rules.  */
+typedef enum
+{
+  undef_assoc,
+  right_assoc,
+  left_assoc,
+  non_assoc
+} assoc;
+
+char const *assoc_to_string (assoc a);
+
+#endif /* !ASSOC_H_ */
diff --git a/src/closure.c b/src/closure.c
new file mode 100644
index 0000000..001b831
--- /dev/null
+++ b/src/closure.c
@@ -0,0 +1,249 @@
+/* Closures for Bison
+
+   Copyright (C) 1984, 1989, 2000, 2001, 2002, 2004, 2005 Free
+   Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+
+#include <config.h>
+#include "system.h"
+
+#include <bitset.h>
+#include <bitsetv-print.h>
+#include <bitsetv.h>
+#include <quotearg.h>
+
+#include "closure.h"
+#include "derives.h"
+#include "getargs.h"
+#include "gram.h"
+#include "reader.h"
+#include "symtab.h"
+
+/* NITEMSET is the size of the array ITEMSET.  */
+item_number *itemset;
+size_t nritemset;
+
+static bitset ruleset;
+
+/* internal data.  See comments before set_fderives and set_firsts.  */
+static bitsetv fderives = NULL;
+static bitsetv firsts = NULL;
+
+/* Retrieve the FDERIVES/FIRSTS sets of the nonterminals numbered Var.  */
+#define FDERIVES(Var)   fderives[(Var) - ntokens]
+#define   FIRSTS(Var)   firsts[(Var) - ntokens]
+
+
+/*-----------------.
+| Debugging code.  |
+`-----------------*/
+
+static void
+print_closure (char const *title, item_number *array, size_t size)
+{
+  size_t i;
+  fprintf (stderr, "Closure: %s\n", title);
+  for (i = 0; i < size; ++i)
+    {
+      item_number *rp;
+      fprintf (stderr, "  %2d: .", array[i]);
+      for (rp = &ritem[array[i]]; *rp >= 0; ++rp)
+	fprintf (stderr, " %s", symbols[*rp]->tag);
+      fprintf (stderr, "  (rule %d)\n", -*rp - 1);
+    }
+  fputs ("\n\n", stderr);
+}
+
+
+static void
+print_firsts (void)
+{
+  symbol_number i, j;
+
+  fprintf (stderr, "FIRSTS\n");
+  for (i = ntokens; i < nsyms; i++)
+    {
+      bitset_iterator iter;
+      fprintf (stderr, "\t%s firsts\n", symbols[i]->tag);
+      BITSET_FOR_EACH (iter, FIRSTS (i), j, 0)
+	{
+	  fprintf (stderr, "\t\t%s\n",
+		   symbols[j + ntokens]->tag);
+	}
+    }
+  fprintf (stderr, "\n\n");
+}
+
+
+static void
+print_fderives (void)
+{
+  int i;
+  rule_number r;
+
+  fprintf (stderr, "FDERIVES\n");
+  for (i = ntokens; i < nsyms; i++)
+    {
+      bitset_iterator iter;
+      fprintf (stderr, "\t%s derives\n", symbols[i]->tag);
+      BITSET_FOR_EACH (iter, FDERIVES (i), r, 0)
+	{
+	  fprintf (stderr, "\t\t%3d ", r);
+	  rule_rhs_print (&rules[r], stderr);
+	}
+    }
+  fprintf (stderr, "\n\n");
+}
+
+/*------------------------------------------------------------------.
+| Set FIRSTS to be an NVARS array of NVARS bitsets indicating which |
+| items can represent the beginning of the input corresponding to   |
+| which other items.                                                |
+|                                                                   |
+| For example, if some rule expands symbol 5 into the sequence of   |
+| symbols 8 3 20, the symbol 8 can be the beginning of the data for |
+| symbol 5, so the bit [8 - ntokens] in first[5 - ntokens] (= FIRST |
+| (5)) is set.                                                      |
+`------------------------------------------------------------------*/
+
+static void
+set_firsts (void)
+{
+  symbol_number i, j;
+
+  firsts = bitsetv_create (nvars, nvars, BITSET_FIXED);
+
+  for (i = ntokens; i < nsyms; i++)
+    for (j = 0; derives[i - ntokens][j]; ++j)
+      {
+	item_number sym = derives[i - ntokens][j]->rhs[0];
+	if (ISVAR (sym))
+	  bitset_set (FIRSTS (i), sym - ntokens);
+      }
+
+  if (trace_flag & trace_sets)
+    bitsetv_matrix_dump (stderr, "RTC: Firsts Input", firsts);
+  bitsetv_reflexive_transitive_closure (firsts);
+  if (trace_flag & trace_sets)
+    bitsetv_matrix_dump (stderr, "RTC: Firsts Output", firsts);
+
+  if (trace_flag & trace_sets)
+    print_firsts ();
+}
+
+/*-------------------------------------------------------------------.
+| Set FDERIVES to an NVARS by NRULES matrix of bits indicating which |
+| rules can help derive the beginning of the data for each           |
+| nonterminal.                                                       |
+|                                                                    |
+| For example, if symbol 5 can be derived as the sequence of symbols |
+| 8 3 20, and one of the rules for deriving symbol 8 is rule 4, then |
+| the [5 - NTOKENS, 4] bit in FDERIVES is set.                       |
+`-------------------------------------------------------------------*/
+
+static void
+set_fderives (void)
+{
+  symbol_number i, j;
+  rule_number k;
+
+  fderives = bitsetv_create (nvars, nrules, BITSET_FIXED);
+
+  set_firsts ();
+
+  for (i = ntokens; i < nsyms; ++i)
+    for (j = ntokens; j < nsyms; ++j)
+      if (bitset_test (FIRSTS (i), j - ntokens))
+	for (k = 0; derives[j - ntokens][k]; ++k)
+	  bitset_set (FDERIVES (i), derives[j - ntokens][k]->number);
+
+  if (trace_flag & trace_sets)
+    print_fderives ();
+
+  bitsetv_free (firsts);
+}
+
+
+
+void
+new_closure (unsigned int n)
+{
+  itemset = xnmalloc (n, sizeof *itemset);
+
+  ruleset = bitset_create (nrules, BITSET_FIXED);
+
+  set_fderives ();
+}
+
+
+
+void
+closure (item_number *core, size_t n)
+{
+  /* Index over CORE. */
+  size_t c;
+
+  /* A bit index over RULESET. */
+  rule_number ruleno;
+
+  bitset_iterator iter;
+
+  if (trace_flag & trace_sets)
+    print_closure ("input", core, n);
+
+  bitset_zero (ruleset);
+
+  for (c = 0; c < n; ++c)
+    if (ISVAR (ritem[core[c]]))
+      bitset_or (ruleset, ruleset, FDERIVES (ritem[core[c]]));
+
+  nritemset = 0;
+  c = 0;
+  BITSET_FOR_EACH (iter, ruleset, ruleno, 0)
+    {
+      item_number itemno = rules[ruleno].rhs - ritem;
+      while (c < n && core[c] < itemno)
+	{
+	  itemset[nritemset] = core[c];
+	  nritemset++;
+	  c++;
+	}
+      itemset[nritemset] = itemno;
+      nritemset++;
+    };
+
+  while (c < n)
+    {
+      itemset[nritemset] = core[c];
+      nritemset++;
+      c++;
+    }
+
+  if (trace_flag & trace_sets)
+    print_closure ("output", itemset, nritemset);
+}
+
+
+void
+free_closure (void)
+{
+  free (itemset);
+  bitset_free (ruleset);
+  bitsetv_free (fderives);
+}
diff --git a/src/closure.h b/src/closure.h
new file mode 100644
index 0000000..a2582e8
--- /dev/null
+++ b/src/closure.h
@@ -0,0 +1,59 @@
+/* Subroutines for bison
+
+   Copyright (C) 1984, 1989, 2000, 2001, 2002 Free Software
+   Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+
+#ifndef CLOSURE_H_
+# define CLOSURE_H_
+
+# include "gram.h"
+
+/* Allocates the itemset and ruleset vectors, and precomputes useful
+   data so that closure can be called.  n is the number of elements to
+   allocate for itemset.  */
+
+void new_closure (unsigned int n);
+
+
+/* Given the kernel (aka core) of a state (a vector of item numbers
+   ITEMS, of length N), set up RULESET and ITEMSET to indicate what
+   rules could be run and which items could be accepted when those
+   items are the active ones.
+
+   RULESET contains a bit for each rule.  CLOSURE sets the bits for
+   all rules which could potentially describe the next input to be
+   read.
+
+   ITEMSET is a vector of item numbers; NITEMSET is its size
+   (actually, points to just beyond the end of the part of it that is
+   significant).  CLOSURE places there the indices of all items which
+   represent units of input that could arrive next.  */
+
+void closure (item_number *items, size_t n);
+
+
+/* Frees ITEMSET, RULESET and internal data.  */
+
+void free_closure (void);
+
+extern item_number *itemset;
+extern size_t nritemset;
+
+#endif /* !CLOSURE_H_ */
diff --git a/src/complain.c b/src/complain.c
new file mode 100644
index 0000000..927dbb6
--- /dev/null
+++ b/src/complain.c
@@ -0,0 +1,147 @@
+/* Declaration for error-reporting function for Bison.
+
+   Copyright (C) 2000, 2001, 2002, 2004, 2005 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 2, 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, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+   USA.  */
+
+/* Based on error.c and error.h,
+   written by David MacKenzie <djm@gnu.ai.mit.edu>.  */
+
+#include <config.h>
+#include "system.h"
+
+#include <stdarg.h>
+
+#include "complain.h"
+#include "files.h"
+
+/* The calling program should define program_name and set it to the
+   name of the executing program.  */
+extern char *program_name;
+
+/* This variable is set each time `warn' is called.  */
+bool warning_issued;
+
+/* This variable is set each time `complain' is called.  */
+bool complaint_issued;
+
+
+/*--------------------------------.
+| Report a warning, and proceed.  |
+`--------------------------------*/
+
+void
+warn_at (location loc, const char *message, ...)
+{
+  va_list args;
+
+  location_print (stderr, loc);
+  fputs (": ", stderr);
+  fputs (_("warning: "), stderr);
+
+  va_start (args, message);
+  vfprintf (stderr, message, args);
+  va_end (args);
+
+  warning_issued = true;
+  putc ('\n', stderr);
+}
+
+void
+warn (const char *message, ...)
+{
+  va_list args;
+
+  fprintf (stderr, "%s: %s", current_file ? current_file : program_name, _("warning: "));
+
+  va_start (args, message);
+  vfprintf (stderr, message, args);
+  va_end (args);
+
+  warning_issued = true;
+  putc ('\n', stderr);
+}
+
+/*-----------------------------------------------------------.
+| An error has occurred, but we can proceed, and die later.  |
+`-----------------------------------------------------------*/
+
+void
+complain_at (location loc, const char *message, ...)
+{
+  va_list args;
+
+  location_print (stderr, loc);
+  fputs (": ", stderr);
+
+  va_start (args, message);
+  vfprintf (stderr, message, args);
+  va_end (args);
+
+  complaint_issued = true;
+  putc ('\n', stderr);
+}
+
+void
+complain (const char *message, ...)
+{
+  va_list args;
+
+  fprintf (stderr, "%s: ", current_file ? current_file : program_name);
+
+  va_start (args, message);
+  vfprintf (stderr, message, args);
+  va_end (args);
+
+  complaint_issued = true;
+  putc ('\n', stderr);
+}
+
+/*-------------------------------------------------.
+| A severe error has occurred, we cannot proceed.  |
+`-------------------------------------------------*/
+
+void
+fatal_at (location loc, const char *message, ...)
+{
+  va_list args;
+
+  location_print (stderr, loc);
+  fputs (": ", stderr);
+  fputs (_("fatal error: "), stderr);
+
+  va_start (args, message);
+  vfprintf (stderr, message, args);
+  va_end (args);
+  putc ('\n', stderr);
+  exit (EXIT_FAILURE);
+}
+
+void
+fatal (const char *message, ...)
+{
+  va_list args;
+
+  fprintf (stderr, "%s: ", current_file ? current_file : program_name);
+
+  fputs (_("fatal error: "), stderr);
+
+  va_start (args, message);
+  vfprintf (stderr, message, args);
+  va_end (args);
+  putc ('\n', stderr);
+  exit (EXIT_FAILURE);
+}
diff --git a/src/complain.h b/src/complain.h
new file mode 100644
index 0000000..9ae334a
--- /dev/null
+++ b/src/complain.h
@@ -0,0 +1,62 @@
+/* Declaration for error-reporting function for Bison.
+   Copyright (C) 2000, 2001, 2002 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 2, 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, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+   USA.  */
+
+#ifndef COMPLAIN_H_
+# define COMPLAIN_H_ 1
+
+# include "location.h"
+
+# ifdef	__cplusplus
+extern "C" {
+# endif
+
+/* Informative messages, but we proceed.  */
+
+void warn (char const *format, ...)
+  __attribute__ ((__format__ (__printf__, 1, 2)));
+
+void warn_at (location loc, char const *format, ...)
+  __attribute__ ((__format__ (__printf__, 2, 3)));
+
+/* Something bad happened, but let's continue and die later.  */
+
+void complain (char const *format, ...)
+  __attribute__ ((__format__ (__printf__, 1, 2)));
+
+void complain_at (location loc, char const *format, ...)
+  __attribute__ ((__format__ (__printf__, 2, 3)));
+
+/* Something bad happened, and let's die now.  */
+
+void fatal (char const *format, ...)
+  __attribute__ ((__noreturn__, __format__ (__printf__, 1, 2)));
+
+void fatal_at (location loc, char const *format, ...)
+  __attribute__ ((__noreturn__, __format__ (__printf__, 2, 3)));
+
+/* This variable is set each time `warn' is called.  */
+extern bool warning_issued;
+
+/* This variable is set each time `complain' is called.  */
+extern bool complaint_issued;
+
+# ifdef	__cplusplus
+}
+# endif
+
+#endif /* !COMPLAIN_H_ */
diff --git a/src/conflicts.c b/src/conflicts.c
new file mode 100644
index 0000000..13121f6
--- /dev/null
+++ b/src/conflicts.c
@@ -0,0 +1,535 @@
+/* Find and resolve or report look-ahead conflicts for bison,
+
+   Copyright (C) 1984, 1989, 1992, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+   Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+
+#include <config.h>
+#include "system.h"
+
+#include <bitset.h>
+
+#include "LR0.h"
+#include "complain.h"
+#include "conflicts.h"
+#include "files.h"
+#include "getargs.h"
+#include "gram.h"
+#include "lalr.h"
+#include "reader.h"
+#include "state.h"
+#include "symtab.h"
+
+/* -1 stands for not specified. */
+int expected_sr_conflicts = -1;
+int expected_rr_conflicts = -1;
+static char *conflicts;
+static struct obstack solved_conflicts_obstack;
+
+static bitset shift_set;
+static bitset look_ahead_set;
+
+
+
+enum conflict_resolution
+  {
+    shift_resolution,
+    reduce_resolution,
+    left_resolution,
+    right_resolution,
+    nonassoc_resolution
+  };
+
+
+/*----------------------------------------------------------------.
+| Explain how an SR conflict between TOKEN and RULE was resolved: |
+| RESOLUTION.                                                     |
+`----------------------------------------------------------------*/
+
+static inline void
+log_resolution (rule *r, symbol_number token,
+		enum conflict_resolution resolution)
+{
+  if (report_flag & report_solved_conflicts)
+    {
+      /* The description of the resolution. */
+      switch (resolution)
+	{
+	case shift_resolution:
+	case right_resolution:
+	  obstack_fgrow2 (&solved_conflicts_obstack,
+			  _("\
+    Conflict between rule %d and token %s resolved as shift"),
+			  r->number,
+			  symbols[token]->tag);
+	  break;
+	case reduce_resolution:
+	case left_resolution:
+	  obstack_fgrow2 (&solved_conflicts_obstack,
+			  _("\
+    Conflict between rule %d and token %s resolved as reduce"),
+			  r->number,
+			  symbols[token]->tag);
+	  break;
+	case nonassoc_resolution:
+	  obstack_fgrow2 (&solved_conflicts_obstack,
+			  _("\
+    Conflict between rule %d and token %s resolved as an error"),
+			  r->number,
+			  symbols[token]->tag);
+	  break;
+	}
+
+      /* The reason. */
+      switch (resolution)
+	{
+	case shift_resolution:
+	  obstack_fgrow2 (&solved_conflicts_obstack,
+			  " (%s < %s)",
+			  r->prec->tag,
+			  symbols[token]->tag);
+	  break;
+
+	case reduce_resolution:
+	  obstack_fgrow2 (&solved_conflicts_obstack,
+			  " (%s < %s)",
+			  symbols[token]->tag,
+			  r->prec->tag);
+	  break;
+
+	case left_resolution:
+	  obstack_fgrow1 (&solved_conflicts_obstack,
+			  " (%%left %s)",
+			  symbols[token]->tag);
+	  break;
+
+	case right_resolution:
+	  obstack_fgrow1 (&solved_conflicts_obstack,
+			  " (%%right %s)",
+			  symbols[token]->tag);
+	  break;
+	case nonassoc_resolution:
+	  obstack_fgrow1 (&solved_conflicts_obstack,
+			  " (%%nonassoc %s)",
+			  symbols[token]->tag);
+	  break;
+	}
+      obstack_sgrow (&solved_conflicts_obstack, ".\n");
+    }
+}
+
+
+/*------------------------------------------------------------------.
+| Turn off the shift recorded for the specified token in the        |
+| specified state.  Used when we resolve a shift-reduce conflict in |
+| favor of the reduction.                                           |
+`------------------------------------------------------------------*/
+
+static void
+flush_shift (state *s, int token)
+{
+  transitions *trans = s->transitions;
+  int i;
+
+  bitset_reset (look_ahead_set, token);
+  for (i = 0; i < trans->num; i++)
+    if (!TRANSITION_IS_DISABLED (trans, i)
+	&& TRANSITION_SYMBOL (trans, i) == token)
+      TRANSITION_DISABLE (trans, i);
+}
+
+
+/*--------------------------------------------------------------------.
+| Turn off the reduce recorded for the specified token for the        |
+| specified look-ahead.  Used when we resolve a shift-reduce conflict |
+| in favor of the shift.                                              |
+`--------------------------------------------------------------------*/
+
+static void
+flush_reduce (bitset look_ahead_tokens, int token)
+{
+  bitset_reset (look_ahead_tokens, token);
+}
+
+
+/*------------------------------------------------------------------.
+| Attempt to resolve shift-reduce conflict for one rule by means of |
+| precedence declarations.  It has already been checked that the    |
+| rule has a precedence.  A conflict is resolved by modifying the   |
+| shift or reduce tables so that there is no longer a conflict.     |
+|                                                                   |
+| RULENO is the number of the look-ahead bitset to consider.      |
+|                                                                   |
+| ERRORS can be used to store discovered explicit errors.           |
+`------------------------------------------------------------------*/
+
+static void
+resolve_sr_conflict (state *s, int ruleno, symbol **errors)
+{
+  symbol_number i;
+  reductions *reds = s->reductions;
+  /* Find the rule to reduce by to get precedence of reduction.  */
+  rule *redrule = reds->rules[ruleno];
+  int redprec = redrule->prec->prec;
+  bitset look_ahead_tokens = reds->look_ahead_tokens[ruleno];
+  int nerrs = 0;
+
+  for (i = 0; i < ntokens; i++)
+    if (bitset_test (look_ahead_tokens, i)
+	&& bitset_test (look_ahead_set, i)
+	&& symbols[i]->prec)
+      {
+	/* Shift-reduce conflict occurs for token number i
+	   and it has a precedence.
+	   The precedence of shifting is that of token i.  */
+	if (symbols[i]->prec < redprec)
+	  {
+	    log_resolution (redrule, i, reduce_resolution);
+	    flush_shift (s, i);
+	  }
+	else if (symbols[i]->prec > redprec)
+	  {
+	    log_resolution (redrule, i, shift_resolution);
+	    flush_reduce (look_ahead_tokens, i);
+	  }
+	else
+	  /* Matching precedence levels.
+	     For left association, keep only the reduction.
+	     For right association, keep only the shift.
+	     For nonassociation, keep neither.  */
+
+	  switch (symbols[i]->assoc)
+	    {
+	    default:
+	      abort ();
+
+	    case right_assoc:
+	      log_resolution (redrule, i, right_resolution);
+	      flush_reduce (look_ahead_tokens, i);
+	      break;
+
+	    case left_assoc:
+	      log_resolution (redrule, i, left_resolution);
+	      flush_shift (s, i);
+	      break;
+
+	    case non_assoc:
+	      log_resolution (redrule, i, nonassoc_resolution);
+	      flush_shift (s, i);
+	      flush_reduce (look_ahead_tokens, i);
+	      /* Record an explicit error for this token.  */
+	      errors[nerrs++] = symbols[i];
+	      break;
+	    }
+      }
+
+  if (nerrs)
+    {
+      /* Some tokens have been explicitly made errors.  Allocate a
+	 permanent errs structure for this state, to record them.  */
+      state_errs_set (s, nerrs, errors);
+    }
+
+  if (obstack_object_size (&solved_conflicts_obstack))
+    {
+      obstack_1grow (&solved_conflicts_obstack, '\0');
+      s->solved_conflicts = obstack_finish (&solved_conflicts_obstack);
+    }
+}
+
+
+/*-------------------------------------------------------------------.
+| Solve the S/R conflicts of state S using the                       |
+| precedence/associativity, and flag it inconsistent if it still has |
+| conflicts.  ERRORS can be used as storage to compute the list of   |
+| look-ahead tokens on which S raises a syntax error (%nonassoc).    |
+`-------------------------------------------------------------------*/
+
+static void
+set_conflicts (state *s, symbol **errors)
+{
+  int i;
+  transitions *trans = s->transitions;
+  reductions *reds = s->reductions;
+
+  if (s->consistent)
+    return;
+
+  bitset_zero (look_ahead_set);
+
+  FOR_EACH_SHIFT (trans, i)
+    bitset_set (look_ahead_set, TRANSITION_SYMBOL (trans, i));
+
+  /* Loop over all rules which require look-ahead in this state.  First
+     check for shift-reduce conflict, and try to resolve using
+     precedence.  */
+  for (i = 0; i < reds->num; ++i)
+    if (reds->rules[i]->prec && reds->rules[i]->prec->prec
+	&& !bitset_disjoint_p (reds->look_ahead_tokens[i], look_ahead_set))
+      resolve_sr_conflict (s, i, errors);
+
+  /* Loop over all rules which require look-ahead in this state.  Check
+     for conflicts not resolved above.  */
+  for (i = 0; i < reds->num; ++i)
+    {
+      if (!bitset_disjoint_p (reds->look_ahead_tokens[i], look_ahead_set))
+	conflicts[s->number] = 1;
+
+      bitset_or (look_ahead_set, look_ahead_set, reds->look_ahead_tokens[i]);
+    }
+}
+
+
+/*----------------------------------------------------------------.
+| Solve all the S/R conflicts using the precedence/associativity, |
+| and flag as inconsistent the states that still have conflicts.  |
+`----------------------------------------------------------------*/
+
+void
+conflicts_solve (void)
+{
+  state_number i;
+  /* List of look-ahead tokens on which we explicitly raise a syntax error.  */
+  symbol **errors = xnmalloc (ntokens + 1, sizeof *errors);
+
+  conflicts = xcalloc (nstates, sizeof *conflicts);
+  shift_set = bitset_create (ntokens, BITSET_FIXED);
+  look_ahead_set = bitset_create (ntokens, BITSET_FIXED);
+  obstack_init (&solved_conflicts_obstack);
+
+  for (i = 0; i < nstates; i++)
+    {
+      set_conflicts (states[i], errors);
+
+      /* For uniformity of the code, make sure all the states have a valid
+	 `errs' member.  */
+      if (!states[i]->errs)
+	states[i]->errs = errs_new (0, 0);
+    }
+
+  free (errors);
+}
+
+
+/*---------------------------------------------.
+| Count the number of shift/reduce conflicts.  |
+`---------------------------------------------*/
+
+static int
+count_sr_conflicts (state *s)
+{
+  int i;
+  int src_count = 0;
+  transitions *trans = s->transitions;
+  reductions *reds = s->reductions;
+
+  if (!trans)
+    return 0;
+
+  bitset_zero (look_ahead_set);
+  bitset_zero (shift_set);
+
+  FOR_EACH_SHIFT (trans, i)
+    bitset_set (shift_set, TRANSITION_SYMBOL (trans, i));
+
+  for (i = 0; i < reds->num; ++i)
+    bitset_or (look_ahead_set, look_ahead_set, reds->look_ahead_tokens[i]);
+
+  bitset_and (look_ahead_set, look_ahead_set, shift_set);
+
+  src_count = bitset_count (look_ahead_set);
+
+  return src_count;
+}
+
+
+/*----------------------------------------------------------------.
+| Count the number of reduce/reduce conflicts.  If ONE_PER_TOKEN, |
+| count one conflict for each token that has any reduce/reduce    |
+| conflicts.  Otherwise, count one conflict for each pair of      |
+| conflicting reductions.                                         |
++`----------------------------------------------------------------*/
+
+static int
+count_rr_conflicts (state *s, bool one_per_token)
+{
+  int i;
+  reductions *reds = s->reductions;
+  int rrc_count = 0;
+
+  for (i = 0; i < ntokens; i++)
+    {
+      int count = 0;
+      int j;
+      for (j = 0; j < reds->num; ++j)
+	if (bitset_test (reds->look_ahead_tokens[j], i))
+	  count++;
+
+      if (count >= 2)
+	rrc_count += one_per_token ? 1 : count-1;
+    }
+
+  return rrc_count;
+}
+
+
+/*--------------------------------------------------------.
+| Report the number of conflicts, using the Yacc format.  |
+`--------------------------------------------------------*/
+
+static void
+conflict_report (FILE *out, int src_num, int rrc_num)
+{
+  if (src_num && rrc_num)
+    fprintf (out, _("conflicts: %d shift/reduce, %d reduce/reduce\n"),
+	     src_num, rrc_num);
+  else if (src_num)
+    fprintf (out, _("conflicts: %d shift/reduce\n"), src_num);
+  else if (rrc_num)
+    fprintf (out, _("conflicts: %d reduce/reduce\n"), rrc_num);
+}
+
+
+/*-----------------------------------------------------------.
+| Output the detailed description of states with conflicts.  |
+`-----------------------------------------------------------*/
+
+void
+conflicts_output (FILE *out)
+{
+  bool printed_sth = false;
+  state_number i;
+  for (i = 0; i < nstates; i++)
+    {
+      state *s = states[i];
+      if (conflicts[i])
+	{
+	  fprintf (out, _("State %d "), i);
+	  conflict_report (out, count_sr_conflicts (s),
+			   count_rr_conflicts (s, true));
+	  printed_sth = true;
+	}
+    }
+  if (printed_sth)
+    fputs ("\n\n", out);
+}
+
+/*--------------------------------------------------------.
+| Total the number of S/R and R/R conflicts.  Unlike the  |
+| code in conflicts_output, however, count EACH pair of   |
+| reductions for the same state and look-ahead as one     |
+| conflict.						  |
+`--------------------------------------------------------*/
+
+int
+conflicts_total_count (void)
+{
+  state_number i;
+  int count;
+
+  /* Conflicts by state.  */
+  count = 0;
+  for (i = 0; i < nstates; i++)
+    if (conflicts[i])
+      {
+	count += count_sr_conflicts (states[i]);
+	count += count_rr_conflicts (states[i], false);
+      }
+  return count;
+}
+
+
+/*------------------------------------------.
+| Reporting the total number of conflicts.  |
+`------------------------------------------*/
+
+void
+conflicts_print (void)
+{
+  /* Is the number of SR conflicts OK?  Either EXPECTED_CONFLICTS is
+     not set, and then we want 0 SR, or else it is specified, in which
+     case we want equality.  */
+  bool src_ok;
+  bool rrc_ok;
+
+  int src_total = 0;
+  int rrc_total = 0;
+  int src_expected;
+  int rrc_expected;
+
+  /* Conflicts by state.  */
+  {
+    state_number i;
+
+    for (i = 0; i < nstates; i++)
+      if (conflicts[i])
+	{
+	  src_total += count_sr_conflicts (states[i]);
+	  rrc_total += count_rr_conflicts (states[i], true);
+	}
+  }
+
+  if (! glr_parser && rrc_total > 0 && expected_rr_conflicts != -1)
+    {
+      warn (_("%%expect-rr applies only to GLR parsers"));
+      expected_rr_conflicts = -1;
+    }
+
+  src_expected = expected_sr_conflicts == -1 ? 0 : expected_sr_conflicts;
+  rrc_expected = expected_rr_conflicts == -1 ? 0 : expected_rr_conflicts;
+  src_ok = src_total == src_expected;
+  rrc_ok = rrc_total == rrc_expected;
+
+  /* If there are as many RR conflicts and SR conflicts as
+     expected, then there is nothing to report.  */
+  if (rrc_ok & src_ok)
+    return;
+
+  /* Report the total number of conflicts on STDERR.  */
+  if (src_total | rrc_total)
+    {
+      if (! yacc_flag)
+	fprintf (stderr, "%s: ", current_file);
+      conflict_report (stderr, src_total, rrc_total);
+    }
+
+  if (expected_sr_conflicts != -1 || expected_rr_conflicts != -1)
+    {
+      if (! src_ok)
+	complain (ngettext ("expected %d shift/reduce conflict",
+			    "expected %d shift/reduce conflicts",
+			    src_expected),
+		  src_expected);
+      if (! rrc_ok)
+	complain (ngettext ("expected %d reduce/reduce conflict",
+			    "expected %d reduce/reduce conflicts",
+			    rrc_expected),
+		  rrc_expected);
+    }
+}
+
+
+void
+conflicts_free (void)
+{
+  free (conflicts);
+  bitset_free (shift_set);
+  bitset_free (look_ahead_set);
+  obstack_free (&solved_conflicts_obstack, NULL);
+}
diff --git a/src/conflicts.h b/src/conflicts.h
new file mode 100644
index 0000000..4389e5e
--- /dev/null
+++ b/src/conflicts.h
@@ -0,0 +1,34 @@
+/* Find and resolve or report look-ahead conflicts for bison,
+   Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+
+#ifndef CONFLICTS_H_
+# define CONFLICTS_H_
+# include "state.h"
+
+void conflicts_solve (void);
+void conflicts_print (void);
+int conflicts_total_count (void);
+void conflicts_output (FILE *out);
+void conflicts_free (void);
+
+/* Were there conflicts? */
+extern int expected_sr_conflicts;
+extern int expected_rr_conflicts;
+#endif /* !CONFLICTS_H_ */
diff --git a/src/derives.c b/src/derives.c
new file mode 100644
index 0000000..2e4ff31
--- /dev/null
+++ b/src/derives.c
@@ -0,0 +1,121 @@
+/* Match rules with nonterminals for bison,
+
+   Copyright (C) 1984, 1989, 2000, 2001, 2002, 2003, 2005 Free
+   Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+#include "system.h"
+
+#include "getargs.h"
+
+#include "derives.h"
+#include "gram.h"
+#include "reader.h"
+#include "symtab.h"
+
+/* Linked list of rule numbers.  */
+typedef struct rule_list
+{
+  struct rule_list *next;
+  rule *value;
+} rule_list;
+
+rule ***derives;
+
+static void
+print_derives (void)
+{
+  int i;
+
+  fputs ("DERIVES\n", stderr);
+
+  for (i = ntokens; i < nsyms; i++)
+    {
+      rule **rp;
+      fprintf (stderr, "\t%s derives\n", symbols[i]->tag);
+      for (rp = derives[i - ntokens]; *rp; ++rp)
+	{
+	  fprintf (stderr, "\t\t%3d ", (*rp)->user_number);
+	  rule_rhs_print (*rp, stderr);
+	}
+    }
+
+  fputs ("\n\n", stderr);
+}
+
+
+void
+derives_compute (void)
+{
+  symbol_number i;
+  rule_number r;
+  rule **q;
+
+  /* DSET[NTERM - NTOKENS] -- A linked list of the numbers of the rules
+     whose LHS is NTERM.  */
+  rule_list **dset = xcalloc (nvars, sizeof *dset);
+
+  /* DELTS[RULE] -- There are NRULES rule number to attach to nterms.
+     Instead of performing NRULES allocations for each, have an array
+     indexed by rule numbers.  */
+  rule_list *delts = xnmalloc (nrules, sizeof *delts);
+
+  for (r = nrules - 1; r >= 0; --r)
+    {
+      symbol_number lhs = rules[r].lhs->number;
+      rule_list *p = &delts[r];
+      /* A new LHS is found.  */
+      p->next = dset[lhs - ntokens];
+      p->value = &rules[r];
+      dset[lhs - ntokens] = p;
+    }
+
+  /* DSET contains what we need under the form of a linked list.  Make
+     it a single array.  */
+
+  derives = xnmalloc (nvars, sizeof *derives);
+  q = xnmalloc (nvars + nrules, sizeof *q);
+
+  for (i = ntokens; i < nsyms; i++)
+    {
+      rule_list *p = dset[i - ntokens];
+      derives[i - ntokens] = q;
+      while (p)
+	{
+	  *q++ = p->value;
+	  p = p->next;
+	}
+      *q++ = NULL;
+    }
+
+  if (trace_flag & trace_sets)
+    print_derives ();
+
+  free (dset);
+  free (delts);
+}
+
+
+void
+derives_free (void)
+{
+  free (derives[0]);
+  free (derives);
+}
diff --git a/src/derives.h b/src/derives.h
new file mode 100644
index 0000000..9a45dc9
--- /dev/null
+++ b/src/derives.h
@@ -0,0 +1,37 @@
+/* Match rules with nonterminals for bison,
+
+   Copyright (C) 1984, 1989, 2000, 2001, 2002 Free Software
+   Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#ifndef DERIVES_H_
+# define DERIVES_H_
+
+# include "gram.h"
+
+/* DERIVES[SYMBOL - NTOKENS] points to a vector of the rules that
+   SYMBOL derives, terminated with NULL.  */
+extern rule ***derives;
+
+/* Compute DERIVES.  */
+
+void derives_compute (void);
+void derives_free (void);
+
+#endif /* !DERIVES_H_ */
diff --git a/src/files.c b/src/files.c
new file mode 100644
index 0000000..f3bb0f9
--- /dev/null
+++ b/src/files.c
@@ -0,0 +1,340 @@
+/* Open and close files for Bison.
+
+   Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003, 2004, 2005
+   Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+
+#include <config.h>
+#include "system.h"
+
+#include <error.h>
+#include <get-errno.h>
+#include <quote.h>
+#include <xstrndup.h>
+
+#include "complain.h"
+#include "dirname.h"
+#include "files.h"
+#include "getargs.h"
+#include "gram.h"
+#include "stdio-safer.h"
+
+struct obstack pre_prologue_obstack;
+struct obstack post_prologue_obstack;
+
+/* Initializing some values below (such SPEC_NAME_PREFIX to `yy') is
+   tempting, but don't do that: for the time being our handling of the
+   %directive vs --option leaves precedence to the options by deciding
+   that if a %directive sets a variable which is really set (i.e., not
+   NULL), then the %directive is ignored.  As a result, %name-prefix,
+   for instance, will not be honored.  */
+
+char const *spec_outfile = NULL;       /* for -o. */
+char const *spec_file_prefix = NULL;   /* for -b. */
+char const *spec_name_prefix = NULL;   /* for -p. */
+char const *spec_verbose_file = NULL;  /* for --verbose. */
+char const *spec_graph_file = NULL;    /* for -g. */
+char const *spec_defines_file = NULL;  /* for --defines. */
+char const *parser_file_name;
+
+uniqstr grammar_file = NULL;
+uniqstr current_file = NULL;
+
+/* If --output=dir/foo.c was specified,
+   DIR_PREFIX is `dir/' and ALL_BUT_EXT and ALL_BUT_TAB_EXT are `dir/foo'.
+
+   If --output=dir/foo.tab.c was specified, DIR_PREFIX is `dir/',
+   ALL_BUT_EXT is `dir/foo.tab', and ALL_BUT_TAB_EXT is `dir/foo'.
+
+   If --output was not specified but --file-prefix=dir/foo was specified,
+   ALL_BUT_EXT = `foo.tab' and ALL_BUT_TAB_EXT = `foo'.
+
+   If neither --output nor --file was specified but the input grammar
+   is name dir/foo.y, ALL_BUT_EXT and ALL_BUT_TAB_EXT are `foo'.
+
+   If neither --output nor --file was specified, DIR_PREFIX is the
+   empty string (meaning the current directory); otherwise it is
+   `dir/'.  */
+
+static char const *all_but_ext;
+static char const *all_but_tab_ext;
+char const *dir_prefix;
+
+/* C source file extension (the parser source).  */
+static char const *src_extension = NULL;
+/* Header file extension (if option ``-d'' is specified).  */
+static char const *header_extension = NULL;
+
+/*-----------------------------------------------------------------.
+| Return a newly allocated string composed of the concatenation of |
+| STR1, and STR2.                                                  |
+`-----------------------------------------------------------------*/
+
+static char *
+concat2 (char const *str1, char const *str2)
+{
+  size_t len = strlen (str1) + strlen (str2);
+  char *res = xmalloc (len + 1);
+  char *cp;
+  cp = stpcpy (res, str1);
+  cp = stpcpy (cp, str2);
+  return res;
+}
+
+/*-----------------------------------------------------------------.
+| Try to open file NAME with mode MODE, and print an error message |
+| if fails.                                                        |
+`-----------------------------------------------------------------*/
+
+FILE *
+xfopen (const char *name, const char *mode)
+{
+  FILE *ptr;
+
+  ptr = fopen_safer (name, mode);
+  if (!ptr)
+    error (EXIT_FAILURE, get_errno (), _("cannot open file `%s'"), name);
+
+  return ptr;
+}
+
+/*-------------------------------------------------------------.
+| Try to close file PTR, and print an error message if fails.  |
+`-------------------------------------------------------------*/
+
+void
+xfclose (FILE *ptr)
+{
+  if (ptr == NULL)
+    return;
+
+  if (ferror (ptr))
+    error (EXIT_FAILURE, 0, _("I/O error"));
+
+  if (fclose (ptr) != 0)
+    error (EXIT_FAILURE, get_errno (), _("cannot close file"));
+}
+
+
+/*------------------------------------------------------------------.
+| Compute ALL_BUT_EXT, ALL_BUT_TAB_EXT and output files extensions. |
+`------------------------------------------------------------------*/
+
+/* Replace all characters FROM by TO in the string IN.
+   and returns a new allocated string.  */
+static char *
+tr (const char *in, char from, char to)
+{
+  char *temp;
+  char *out = xmalloc (strlen (in) + 1);
+
+  for (temp = out; *in; in++, out++)
+    if (*in == from)
+      *out = to;
+    else
+      *out = *in;
+  *out = 0;
+  return (temp);
+}
+
+/* Compute extensions from the grammar file extension.  */
+static void
+compute_exts_from_gf (const char *ext)
+{
+  src_extension = tr (ext, 'y', 'c');
+  src_extension = tr (src_extension, 'Y', 'C');
+  header_extension = tr (ext, 'y', 'h');
+  header_extension = tr (header_extension, 'Y', 'H');
+}
+
+/* Compute extensions from the given c source file extension.  */
+static void
+compute_exts_from_src (const char *ext)
+{
+  /* We use this function when the user specifies `-o' or `--output',
+     so the extenions must be computed unconditionally from the file name
+     given by this option.  */
+  src_extension = xstrdup (ext);
+  header_extension = tr (ext, 'c', 'h');
+  header_extension = tr (header_extension, 'C', 'H');
+}
+
+
+/* Decompose FILE_NAME in four parts: *BASE, *TAB, and *EXT, the fourth
+   part, (the directory) is ranging from FILE_NAME to the char before
+   *BASE, so we don't need an additional parameter.
+
+   *EXT points to the last period in the basename, or NULL if none.
+
+   If there is no *EXT, *TAB is NULL.  Otherwise, *TAB points to
+   `.tab' or `_tab' if present right before *EXT, or is NULL. *TAB
+   cannot be equal to *BASE.
+
+   None are allocated, they are simply pointers to parts of FILE_NAME.
+   Examples:
+
+   '/tmp/foo.tab.c' -> *BASE = 'foo.tab.c', *TAB = '.tab.c', *EXT =
+   '.c'
+
+   'foo.c' -> *BASE = 'foo.c', *TAB = NULL, *EXT = '.c'
+
+   'tab.c' -> *BASE = 'tab.c', *TAB = NULL, *EXT = '.c'
+
+   '.tab.c' -> *BASE = '.tab.c', *TAB = NULL, *EXT = '.c'
+
+   'foo.tab' -> *BASE = 'foo.tab', *TAB = NULL, *EXT = '.tab'
+
+   'foo_tab' -> *BASE = 'foo_tab', *TAB = NULL, *EXT = NULL
+
+   'foo' -> *BASE = 'foo', *TAB = NULL, *EXT = NULL.  */
+
+static void
+file_name_split (const char *file_name,
+		 const char **base, const char **tab, const char **ext)
+{
+  *base = base_name (file_name);
+
+  /* Look for the extension, i.e., look for the last dot. */
+  *ext = strrchr (*base, '.');
+  *tab = NULL;
+
+  /* If there is an extension, check if there is a `.tab' part right
+     before.  */
+  if (*ext)
+    {
+      size_t baselen = *ext - *base;
+      size_t dottablen = 4;
+      if (dottablen < baselen
+	  && (strncmp (*ext - dottablen, ".tab", dottablen) == 0
+	      || strncmp (*ext - dottablen, "_tab", dottablen) == 0))
+	*tab = *ext - dottablen;
+    }
+}
+
+
+static void
+compute_file_name_parts (void)
+{
+  const char *base, *tab, *ext;
+
+  /* Compute ALL_BUT_EXT and ALL_BUT_TAB_EXT from SPEC_OUTFILE
+     or GRAMMAR_FILE.
+
+     The precise -o name will be used for FTABLE.  For other output
+     files, remove the ".c" or ".tab.c" suffix.  */
+  if (spec_outfile)
+    {
+      file_name_split (spec_outfile, &base, &tab, &ext);
+      dir_prefix = xstrndup (spec_outfile, base - spec_outfile);
+
+      /* ALL_BUT_EXT goes up the EXT, excluding it. */
+      all_but_ext =
+	xstrndup (spec_outfile,
+		  (strlen (spec_outfile) - (ext ? strlen (ext) : 0)));
+
+      /* ALL_BUT_TAB_EXT goes up to TAB, excluding it.  */
+      all_but_tab_ext =
+	xstrndup (spec_outfile,
+		  (strlen (spec_outfile)
+		   - (tab ? strlen (tab) : (ext ? strlen (ext) : 0))));
+
+      if (ext)
+	compute_exts_from_src (ext);
+    }
+  else
+    {
+      file_name_split (grammar_file, &base, &tab, &ext);
+
+      if (spec_file_prefix)
+	{
+	  /* If --file-prefix=foo was specified, ALL_BUT_TAB_EXT = `foo'.  */
+	  dir_prefix = xstrndup (grammar_file, base - grammar_file);
+	  all_but_tab_ext = xstrdup (spec_file_prefix);
+	}
+      else if (yacc_flag)
+	{
+	  /* If --yacc, then the output is `y.tab.c'.  */
+	  dir_prefix = "";
+	  all_but_tab_ext = "y";
+	}
+      else
+	{
+	  /* Otherwise, ALL_BUT_TAB_EXT is computed from the input
+	     grammar: `foo/bar.yy' => `bar'.  */
+	  dir_prefix = "";
+	  all_but_tab_ext =
+	    xstrndup (base, (strlen (base) - (ext ? strlen (ext) : 0)));
+	}
+
+      all_but_ext = concat2 (all_but_tab_ext, TAB_EXT);
+
+      /* Compute the extensions from the grammar file name.  */
+      if (ext && !yacc_flag)
+	compute_exts_from_gf (ext);
+    }
+}
+
+
+/* Compute the output file names.  Warn if we detect conflicting
+   outputs to the same file.  */
+
+void
+compute_output_file_names (void)
+{
+  char const *name[4];
+  int i;
+  int j;
+  int names = 0;
+
+  compute_file_name_parts ();
+
+  /* If not yet done. */
+  if (!src_extension)
+    src_extension = ".c";
+  if (!header_extension)
+    header_extension = ".h";
+
+  name[names++] = parser_file_name =
+    spec_outfile ? spec_outfile : concat2 (all_but_ext, src_extension);
+
+  if (defines_flag)
+    {
+      if (! spec_defines_file)
+	spec_defines_file = concat2 (all_but_ext, header_extension);
+      name[names++] = spec_defines_file;
+    }
+
+  if (graph_flag)
+    {
+      if (! spec_graph_file)
+	spec_graph_file = concat2 (all_but_tab_ext, ".vcg");
+      name[names++] = spec_graph_file;
+    }
+
+  if (report_flag)
+    {
+      spec_verbose_file = concat2 (all_but_tab_ext, OUTPUT_EXT);
+      name[names++] = spec_verbose_file;
+    }
+
+  for (j = 0; j < names; j++)
+    for (i = 0; i < j; i++)
+      if (strcmp (name[i], name[j]) == 0)
+	warn (_("conflicting outputs to file %s"), quote (name[i]));
+}
diff --git a/src/files.h b/src/files.h
new file mode 100644
index 0000000..ba9fec2
--- /dev/null
+++ b/src/files.h
@@ -0,0 +1,68 @@
+/* File names and variables for bison,
+   Copyright (C) 1984, 1989, 2000, 2001, 2002 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#ifndef FILES_H_
+# define FILES_H_
+
+# include "uniqstr.h"
+
+/* File name specified with -o for the output file, or 0 if no -o.  */
+extern char const *spec_outfile;
+
+/* File name for the parser (i.e., the one above, or its default.) */
+extern char const *parser_file_name;
+
+/* Symbol prefix specified with -p, or 0 if no -p.  */
+extern const char *spec_name_prefix;
+
+/* File name prefix specified with -b, or 0 if no -b.  */
+extern char const *spec_file_prefix;
+
+/* --verbose. */
+extern char const *spec_verbose_file;
+
+/* File name specified for the output VCG graph.  */
+extern char const *spec_graph_file;
+
+/* File name specified with --defines.  */
+extern char const *spec_defines_file;
+
+/* Directory prefix of output file names.  */
+extern char const *dir_prefix;
+
+
+/* If semantic parser, output a .h file that defines YYSTYPE... */
+extern struct obstack pre_prologue_obstack;
+extern struct obstack post_prologue_obstack;
+
+/* The file name as given on the command line.
+   Not named "input_file" because Flex uses this name for an argument,
+   and therefore GCC warns about a name clash. */
+extern uniqstr grammar_file;
+
+/* The current file name.  Might change with %include, or with #line.  */
+extern uniqstr current_file;
+
+void compute_output_file_names (void);
+
+FILE *xfopen (const char *name, const char *mode);
+void xfclose (FILE *ptr);
+
+#endif /* !FILES_H_ */
diff --git a/src/getargs.c b/src/getargs.c
new file mode 100644
index 0000000..13b0d32
--- /dev/null
+++ b/src/getargs.c
@@ -0,0 +1,460 @@
+/* Parse command line arguments for Bison.
+
+   Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003, 2004,
+   2005, 2006 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+
+#include <config.h>
+#include "system.h"
+
+#include <argmatch.h>
+#include <error.h>
+
+/* Hack to get <getopt.h> to declare getopt with a prototype.  */
+#if lint && ! defined __GNU_LIBRARY__
+# define __GNU_LIBRARY__
+# define HACK_FOR___GNU_LIBRARY___PROTOTYPE 1
+#endif
+
+#include <getopt.h>
+
+#ifdef HACK_FOR___GNU_LIBRARY___PROTOTYPE
+# undef __GNU_LIBRARY__
+# undef HACK_FOR___GNU_LIBRARY___PROTOTYPE
+#endif
+
+#include "complain.h"
+#include "files.h"
+#include "getargs.h"
+#include "uniqstr.h"
+
+bool debug_flag;
+bool defines_flag;
+bool graph_flag;
+bool locations_flag;
+bool no_lines_flag;
+bool no_parser_flag;
+bool token_table_flag;
+bool yacc_flag;	/* for -y */
+
+bool error_verbose = false;
+
+bool nondeterministic_parser = false;
+bool glr_parser = false;
+bool pure_parser = false;
+
+int report_flag = report_none;
+int trace_flag = trace_none;
+
+const char *skeleton = NULL;
+const char *include = NULL;
+
+extern char *program_name;
+
+
+/*---------------------.
+| --trace's handling.  |
+`---------------------*/
+
+static const char * const trace_args[] =
+{
+  /* In a series of synonyms, present the most meaningful first, so
+     that argmatch_valid be more readable.  */
+  "none       - no report",
+  "scan       - grammar scanner traces",
+  "parse      - grammar parser traces",
+  "automaton  - contruction of the automaton",
+  "bitsets    - use of bitsets",
+  "grammar    - reading, reducing of the grammar",
+  "resource   - memory consumption (where available)",
+  "sets       - grammar sets: firsts, nullable etc.",
+  "tools      - m4 invocation",
+  "m4         - m4 traces",
+  "skeleton   - skeleton postprocessing",
+  "time       - time consumption",
+  "all        - all of the above",
+  0
+};
+
+static const int trace_types[] =
+{
+  trace_none,
+  trace_scan,
+  trace_parse,
+  trace_automaton,
+  trace_bitsets,
+  trace_grammar,
+  trace_resource,
+  trace_sets,
+  trace_tools,
+  trace_m4,
+  trace_skeleton,
+  trace_time,
+  trace_all
+};
+
+ARGMATCH_VERIFY (trace_args, trace_types);
+
+static void
+trace_argmatch (char *args)
+{
+  if (args)
+    {
+      args = strtok (args, ",");
+      do
+	{
+	  int trace = XARGMATCH ("--trace", args,
+				 trace_args, trace_types);
+	  if (trace == trace_none)
+	    trace_flag = trace_none;
+	  else
+	    trace_flag |= trace;
+	}
+      while ((args = strtok (NULL, ",")));
+    }
+  else
+    trace_flag = trace_all;
+}
+
+
+/*----------------------.
+| --report's handling.  |
+`----------------------*/
+
+static const char * const report_args[] =
+{
+  /* In a series of synonyms, present the most meaningful first, so
+     that argmatch_valid be more readable.  */
+  "none",
+  "state", "states",
+  "itemset", "itemsets",
+  "look-ahead", "lookahead", "lookaheads",
+  "solved",
+  "all",
+  0
+};
+
+static const int report_types[] =
+{
+  report_none,
+  report_states, report_states,
+  report_states | report_itemsets, report_states | report_itemsets,
+  report_states | report_look_ahead_tokens,
+  report_states | report_look_ahead_tokens,
+  report_states | report_look_ahead_tokens,
+  report_states | report_solved_conflicts,
+  report_all
+};
+
+ARGMATCH_VERIFY (report_args, report_types);
+
+static void
+report_argmatch (char *args)
+{
+  args = strtok (args, ",");
+  do
+    {
+      int report = XARGMATCH ("--report", args,
+			      report_args, report_types);
+      if (report == report_none)
+	report_flag = report_none;
+      else
+	report_flag |= report;
+    }
+  while ((args = strtok (NULL, ",")));
+}
+
+
+/*-------------------------------------------.
+| Display the help message and exit STATUS.  |
+`-------------------------------------------*/
+
+static void usage (int) ATTRIBUTE_NORETURN;
+
+static void
+usage (int status)
+{
+  if (status != 0)
+    fprintf (stderr, _("Try `%s --help' for more information.\n"),
+	     program_name);
+  else
+    {
+      /* Some efforts were made to ease the translators' task, please
+	 continue.  */
+      fputs (_("\
+GNU bison generates parsers for LALR(1) grammars.\n"), stdout);
+      putc ('\n', stdout);
+
+      fprintf (stdout, _("\
+Usage: %s [OPTION]... FILE\n"), program_name);
+      putc ('\n', stdout);
+
+      fputs (_("\
+If a long option shows an argument as mandatory, then it is mandatory\n\
+for the equivalent short option also.  Similarly for optional arguments.\n"),
+	     stdout);
+      putc ('\n', stdout);
+
+      fputs (_("\
+Operation modes:\n\
+  -h, --help                 display this help and exit\n\
+  -V, --version              output version information and exit\n\
+      --print-localedir      output directory containing locale-dependent data\n\
+  -y, --yacc                 emulate POSIX yacc\n"), stdout);
+      putc ('\n', stdout);
+
+      fputs (_("\
+Parser:\n\
+  -S, --skeleton=FILE        specify the skeleton to use\n\
+  -t, --debug                instrument the parser for debugging\n\
+      --locations            enable locations computation\n\
+  -p, --name-prefix=PREFIX   prepend PREFIX to the external symbols\n\
+  -l, --no-lines             don't generate `#line' directives\n\
+  -n, --no-parser            generate the tables only\n\
+  -k, --token-table          include a table of token names\n\
+"), stdout);
+      putc ('\n', stdout);
+
+      fputs (_("\
+Output:\n\
+  -d, --defines              also produce a header file\n\
+  -r, --report=THINGS        also produce details on the automaton\n\
+  -v, --verbose              same as `--report=state'\n\
+  -b, --file-prefix=PREFIX   specify a PREFIX for output files\n\
+  -o, --output=FILE          leave output to FILE\n\
+  -g, --graph                also produce a VCG description of the automaton\n\
+"), stdout);
+      putc ('\n', stdout);
+
+      fputs (_("\
+THINGS is a list of comma separated words that can include:\n\
+  `state'        describe the states\n\
+  `itemset'      complete the core item sets with their closure\n\
+  `look-ahead'   explicitly associate look-ahead tokens to items\n\
+  `solved'       describe shift/reduce conflicts solving\n\
+  `all'          include all the above information\n\
+  `none'         disable the report\n\
+"), stdout);
+      putc ('\n', stdout);
+
+      fputs (_("\
+Report bugs to <bug-bison@gnu.org>.\n"), stdout);
+    }
+
+  exit (status);
+}
+
+
+/*------------------------------.
+| Display the version message.  |
+`------------------------------*/
+
+static void
+version (void)
+{
+  /* Some efforts were made to ease the translators' task, please
+     continue.  */
+  printf (_("bison (GNU Bison) %s"), VERSION);
+  putc ('\n', stdout);
+  fputs (_("Written by Robert Corbett and Richard Stallman.\n"), stdout);
+  putc ('\n', stdout);
+
+  fprintf (stdout,
+	   _("Copyright (C) %d Free Software Foundation, Inc.\n"), 2006);
+
+  fputs (_("\
+This is free software; see the source for copying conditions.  There is NO\n\
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
+"),
+	 stdout);
+}
+
+
+/*----------------------.
+| Process the options.  |
+`----------------------*/
+
+/* Shorts options.  */
+static char const short_options[] = "yvegdhr:ltknVo:b:p:S:T::";
+
+/* Values for long options that do not have single-letter equivalents.  */
+enum
+{
+  LOCATIONS_OPTION = CHAR_MAX + 1,
+  PRINT_LOCALEDIR_OPTION
+};
+
+static struct option const long_options[] =
+{
+  /* Operation modes. */
+  { "help",            no_argument,	0,   'h' },
+  { "version",         no_argument,	0,   'V' },
+  { "print-localedir", no_argument,	0,   PRINT_LOCALEDIR_OPTION },
+
+  /* Parser. */
+  { "name-prefix",   required_argument,	  0,   'p' },
+  { "include",       required_argument,   0,   'I' },
+
+  /* Output. */
+  { "file-prefix", required_argument,	0,   'b' },
+  { "output",	   required_argument,	0,   'o' },
+  { "output-file", required_argument,	0,   'o' },
+  { "graph",	   optional_argument,	0,   'g' },
+  { "report",	   required_argument,   0,   'r' },
+  { "verbose",	   no_argument,	        0,   'v' },
+
+  /* Hidden. */
+  { "trace",         optional_argument,   0,     'T' },
+
+  /* Output.  */
+  { "defines",     optional_argument,   0,   'd' },
+
+  /* Operation modes.  */
+  { "fixed-output-files", no_argument,  0,   'y' },
+  { "yacc",	          no_argument,  0,   'y' },
+
+  /* Parser.  */
+  { "debug",	      no_argument,               0,   't' },
+  { "locations",      no_argument,		 0, LOCATIONS_OPTION },
+  { "no-lines",       no_argument,               0,   'l' },
+  { "no-parser",      no_argument,               0,   'n' },
+  { "raw",            no_argument,               0,     0 },
+  { "skeleton",       required_argument,         0,   'S' },
+  { "token-table",    no_argument,               0,   'k' },
+
+  {0, 0, 0, 0}
+};
+
+/* Under DOS, there is no difference on the case.  This can be
+   troublesome when looking for `.tab' etc.  */
+#ifdef MSDOS
+# define AS_FILE_NAME(File) (strlwr (File), (File))
+#else
+# define AS_FILE_NAME(File) (File)
+#endif
+
+void
+getargs (int argc, char *argv[])
+{
+  int c;
+
+  while ((c = getopt_long (argc, argv, short_options, long_options, NULL))
+	 != -1)
+    switch (c)
+      {
+      case 0:
+	/* Certain long options cause getopt_long to return 0.  */
+	break;
+
+      case 'y':
+	yacc_flag = true;
+	break;
+
+      case 'h':
+	usage (EXIT_SUCCESS);
+
+      case 'V':
+	version ();
+	exit (EXIT_SUCCESS);
+
+      case PRINT_LOCALEDIR_OPTION:
+	printf ("%s\n", LOCALEDIR);
+	exit (EXIT_SUCCESS);
+
+      case 'g':
+	/* Here, the -g and --graph=FILE options are differentiated.  */
+	graph_flag = true;
+	if (optarg)
+	  spec_graph_file = AS_FILE_NAME (optarg);
+	break;
+
+      case 'v':
+	report_flag |= report_states;
+	break;
+
+      case 'S':
+	skeleton = AS_FILE_NAME (optarg);
+	break;
+
+      case 'I':
+	include = AS_FILE_NAME (optarg);
+	break;
+
+      case 'd':
+	/* Here, the -d and --defines options are differentiated.  */
+	defines_flag = true;
+	if (optarg)
+	  spec_defines_file = AS_FILE_NAME (optarg);
+	break;
+
+      case 'l':
+	no_lines_flag = true;
+	break;
+
+      case LOCATIONS_OPTION:
+	locations_flag = true;
+	break;
+
+      case 'k':
+	token_table_flag = true;
+	break;
+
+      case 'n':
+	no_parser_flag = true;
+	break;
+
+      case 't':
+	debug_flag = true;
+	break;
+
+      case 'o':
+	spec_outfile = AS_FILE_NAME (optarg);
+	break;
+
+      case 'b':
+	spec_file_prefix = AS_FILE_NAME (optarg);
+	break;
+
+      case 'p':
+	spec_name_prefix = optarg;
+	break;
+
+      case 'r':
+	report_argmatch (optarg);
+	break;
+
+      case 'T':
+	trace_argmatch (optarg);
+	break;
+
+      default:
+	usage (EXIT_FAILURE);
+      }
+
+  if (argc - optind != 1)
+    {
+      if (argc - optind < 1)
+	error (0, 0, _("missing operand after `%s'"), argv[argc - 1]);
+      else
+	error (0, 0, _("extra operand `%s'"), argv[optind + 1]);
+      usage (EXIT_FAILURE);
+    }
+
+  current_file = grammar_file = uniqstr_new (argv[optind]);
+}
diff --git a/src/getargs.h b/src/getargs.h
new file mode 100644
index 0000000..816eb95
--- /dev/null
+++ b/src/getargs.h
@@ -0,0 +1,95 @@
+/* Parse command line arguments for bison.
+   Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+   Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+
+#ifndef GETARGS_H_
+# define GETARGS_H_
+
+/* flags set by % directives */
+
+/* for -S */
+extern char const *skeleton;
+
+/* for -I */
+extern char const *include;
+
+extern bool debug_flag;			/* for -t */
+extern bool defines_flag;		/* for -d */
+extern bool graph_flag;			/* for -g */
+extern bool locations_flag;
+extern bool no_lines_flag;		/* for -l */
+extern bool no_parser_flag;		/* for -n */
+extern bool token_table_flag;		/* for -k */
+extern bool yacc_flag;			/* for -y */
+
+extern bool error_verbose;
+
+
+/* GLR_PARSER is true if the input file says to use the GLR
+   (Generalized LR) parser, and to output some additional information
+   used by the GLR algorithm.  */
+
+extern bool glr_parser;
+
+/* PURE_PARSER is true if should generate a parser that is all pure
+   and reentrant.  */
+
+extern bool pure_parser;
+
+/* NONDETERMINISTIC_PARSER is true iff conflicts are accepted.  This
+   is used by the GLR parser, and might be used in BackTracking
+   parsers too.  */
+
+extern bool nondeterministic_parser;
+
+/* --trace.  */
+enum trace
+  {
+    trace_none      = 0,
+    trace_scan      = 1 << 0,
+    trace_parse     = 1 << 1,
+    trace_resource  = 1 << 2,
+    trace_sets      = 1 << 3,
+    trace_bitsets   = 1 << 4,
+    trace_tools     = 1 << 5,
+    trace_automaton = 1 << 6,
+    trace_grammar   = 1 << 7,
+    trace_time      = 1 << 8,
+    trace_skeleton  = 1 << 9,
+    trace_m4        = 1 << 10,
+    trace_all       = ~0
+  };
+extern int trace_flag;
+
+/* --report.  */
+enum report
+  {
+    report_none             = 0,
+    report_states           = 1 << 0,
+    report_itemsets         = 1 << 1,
+    report_look_ahead_tokens= 1 << 2,
+    report_solved_conflicts = 1 << 3,
+    report_all              = ~0
+  };
+extern int report_flag;
+
+void getargs (int argc, char *argv[]);
+
+#endif /* !GETARGS_H_ */
diff --git a/src/gram.c b/src/gram.c
new file mode 100644
index 0000000..28666b0
--- /dev/null
+++ b/src/gram.c
@@ -0,0 +1,335 @@
+/* Allocate input grammar variables for Bison.
+
+   Copyright (C) 1984, 1986, 1989, 2001, 2002, 2003, 2005, 2006 Free
+   Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+#include "system.h"
+
+#include <quotearg.h>
+
+#include "gram.h"
+#include "reader.h"
+#include "reduce.h"
+#include "symtab.h"
+
+/* Comments for these variables are in gram.h.  */
+
+item_number *ritem = NULL;
+unsigned int nritems = 0;
+
+rule *rules = NULL;
+rule_number nrules = 0;
+
+symbol **symbols = NULL;
+int nsyms = 0;
+int ntokens = 1;
+int nvars = 0;
+
+symbol_number *token_translations = NULL;
+
+int max_user_token_number = 256;
+
+/*--------------------------------------------------------------.
+| Return true IFF the rule has a `number' smaller than NRULES.  |
+`--------------------------------------------------------------*/
+
+bool
+rule_useful_p (rule *r)
+{
+  return r->number < nrules;
+}
+
+
+/*-------------------------------------------------------------.
+| Return true IFF the rule has a `number' higher than NRULES.  |
+`-------------------------------------------------------------*/
+
+bool
+rule_useless_p (rule *r)
+{
+  return !rule_useful_p (r);
+}
+
+
+/*--------------------------------------------------------------------.
+| Return true IFF the rule is not flagged as useful *and* is useful.  |
+| In other words, it was discarded because of conflicts.              |
+`--------------------------------------------------------------------*/
+
+bool
+rule_never_reduced_p (rule *r)
+{
+  return !r->useful && rule_useful_p (r);
+}
+
+
+/*----------------------------------------------------------------.
+| Print this RULE's number and lhs on OUT.  If a PREVIOUS_LHS was |
+| already displayed (by a previous call for another rule), avoid  |
+| useless repetitions.                                            |
+`----------------------------------------------------------------*/
+
+void
+rule_lhs_print (rule *r, symbol *previous_lhs, FILE *out)
+{
+  fprintf (out, "  %3d ", r->number);
+  if (previous_lhs != r->lhs)
+    {
+      fprintf (out, "%s:", r->lhs->tag);
+    }
+  else
+    {
+      int n;
+      for (n = strlen (previous_lhs->tag); n > 0; --n)
+	fputc (' ', out);
+      fputc ('|', out);
+    }
+}
+
+
+/*--------------------------------------.
+| Return the number of symbols in RHS.  |
+`--------------------------------------*/
+
+int
+rule_rhs_length (rule *r)
+{
+  int res = 0;
+  item_number *rhsp;
+  for (rhsp = r->rhs; *rhsp >= 0; ++rhsp)
+    ++res;
+  return res;
+}
+
+
+/*-------------------------------.
+| Print this rule's RHS on OUT.  |
+`-------------------------------*/
+
+void
+rule_rhs_print (rule *r, FILE *out)
+{
+  if (*r->rhs >= 0)
+    {
+      item_number *rp;
+      for (rp = r->rhs; *rp >= 0; rp++)
+	fprintf (out, " %s", symbols[*rp]->tag);
+      fputc ('\n', out);
+    }
+  else
+    {
+      fprintf (out, " /* %s */\n", _("empty"));
+    }
+}
+
+
+/*-------------------------.
+| Print this rule on OUT.  |
+`-------------------------*/
+
+void
+rule_print (rule *r, FILE *out)
+{
+  fprintf (out, "%s:", r->lhs->tag);
+  rule_rhs_print (r, out);
+}
+
+
+/*------------------------.
+| Dump RITEM for traces.  |
+`------------------------*/
+
+void
+ritem_print (FILE *out)
+{
+  unsigned int i;
+  fputs ("RITEM\n", out);
+  for (i = 0; i < nritems; ++i)
+    if (ritem[i] >= 0)
+      fprintf (out, "  %s", symbols[ritem[i]]->tag);
+    else
+      fprintf (out, "  (rule %d)\n", item_number_as_rule_number (ritem[i]));
+  fputs ("\n\n", out);
+}
+
+
+/*------------------------------------------.
+| Return the size of the longest rule RHS.  |
+`------------------------------------------*/
+
+size_t
+ritem_longest_rhs (void)
+{
+  int max = 0;
+  rule_number r;
+
+  for (r = 0; r < nrules; ++r)
+    {
+      int length = rule_rhs_length (&rules[r]);
+      if (length > max)
+	max = length;
+    }
+
+  return max;
+}
+
+
+/*-----------------------------------------------------------------.
+| Print the grammar's rules that match FILTER on OUT under TITLE.  |
+`-----------------------------------------------------------------*/
+
+void
+grammar_rules_partial_print (FILE *out, const char *title,
+			     rule_filter filter)
+{
+  rule_number r;
+  bool first = true;
+  symbol *previous_lhs = NULL;
+
+  /* rule # : LHS -> RHS */
+  for (r = 0; r < nrules + nuseless_productions; r++)
+    {
+      if (filter && !filter (&rules[r]))
+	continue;
+      if (first)
+	fprintf (out, "%s\n\n", title);
+      else if (previous_lhs && previous_lhs != rules[r].lhs)
+	fputc ('\n', out);
+      first = false;
+      rule_lhs_print (&rules[r], previous_lhs, out);
+      rule_rhs_print (&rules[r], out);
+      previous_lhs = rules[r].lhs;
+    }
+  if (!first)
+    fputs ("\n\n", out);
+}
+
+
+/*------------------------------------------.
+| Print the grammar's useful rules on OUT.  |
+`------------------------------------------*/
+
+void
+grammar_rules_print (FILE *out)
+{
+  grammar_rules_partial_print (out, _("Grammar"), rule_useful_p);
+}
+
+
+/*-------------------.
+| Dump the grammar.  |
+`-------------------*/
+
+void
+grammar_dump (FILE *out, const char *title)
+{
+  fprintf (out, "%s\n\n", title);
+  fprintf (out,
+	   "ntokens = %d, nvars = %d, nsyms = %d, nrules = %d, nritems = %d\n\n",
+	   ntokens, nvars, nsyms, nrules, nritems);
+
+
+  fprintf (out, "Variables\n---------\n\n");
+  {
+    symbol_number i;
+    fprintf (out, "Value  Sprec  Sassoc  Tag\n");
+
+    for (i = ntokens; i < nsyms; i++)
+      fprintf (out, "%5d  %5d   %5d  %s\n",
+	       i,
+	       symbols[i]->prec, symbols[i]->assoc,
+	       symbols[i]->tag);
+    fprintf (out, "\n\n");
+  }
+
+  fprintf (out, "Rules\n-----\n\n");
+  {
+    rule_number i;
+    fprintf (out, "Num (Prec, Assoc, Useful, Ritem Range) Lhs -> Rhs (Ritem range) [Num]\n");
+    for (i = 0; i < nrules + nuseless_productions; i++)
+      {
+	rule *rule_i = &rules[i];
+	item_number *rp = NULL;
+	unsigned int rhs_itemno = rule_i->rhs - ritem;
+	unsigned int rhs_count = 0;
+	/* Find the last RHS index in ritems. */
+	for (rp = rule_i->rhs; *rp >= 0; ++rp)
+	  ++rhs_count;
+	fprintf (out, "%3d (%2d, %2d, %2d, %2u-%2u)   %2d ->",
+		 i,
+		 rule_i->prec ? rule_i->prec->prec : 0,
+		 rule_i->prec ? rule_i->prec->assoc : 0,
+		 rule_i->useful,
+		 rhs_itemno,
+		 rhs_itemno + rhs_count - 1,
+		 rule_i->lhs->number);
+	/* Dumped the RHS. */
+	for (rp = rule_i->rhs; *rp >= 0; rp++)
+	  fprintf (out, " %3d", *rp);
+	fprintf (out, "  [%d]\n", item_number_as_rule_number (*rp));
+      }
+  }
+  fprintf (out, "\n\n");
+
+  fprintf (out, "Rules interpreted\n-----------------\n\n");
+  {
+    rule_number r;
+    for (r = 0; r < nrules + nuseless_productions; r++)
+      {
+	fprintf (out, "%-5d  ", r);
+	rule_print (&rules[r], out);
+      }
+  }
+  fprintf (out, "\n\n");
+}
+
+
+/*------------------------------------------------------------------.
+| Report on STDERR the rules that are not flagged USEFUL, using the |
+| MESSAGE (which can be `useless rule' when invoked after grammar   |
+| reduction, or `never reduced' after conflicts were taken into     |
+| account).                                                         |
+`------------------------------------------------------------------*/
+
+void
+grammar_rules_never_reduced_report (const char *message)
+{
+  rule_number r;
+  for (r = 0; r < nrules ; ++r)
+    if (!rules[r].useful)
+      {
+	location_print (stderr, rules[r].location);
+	fprintf (stderr, ": %s: %s: ", _("warning"), message);
+	rule_print (&rules[r], stderr);
+      }
+}
+
+void
+grammar_free (void)
+{
+  if (ritem)
+    free (ritem - 1);
+  free (rules);
+  free (token_translations);
+  /* Free the symbol table data structure.  */
+  symbols_free ();
+  free_merger_functions ();
+}
diff --git a/src/gram.h b/src/gram.h
new file mode 100644
index 0000000..b8f316a
--- /dev/null
+++ b/src/gram.h
@@ -0,0 +1,271 @@
+/* Data definitions for internal representation of Bison's input.
+
+   Copyright (C) 1984, 1986, 1989, 1992, 2001, 2002, 2003, 2004, 2005
+   Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#ifndef GRAM_H_
+# define GRAM_H_
+
+/* Representation of the grammar rules:
+
+   NTOKENS is the number of tokens, and NVARS is the number of
+   variables (nonterminals).  NSYMS is the total number, ntokens +
+   nvars.
+
+   Each symbol (either token or variable) receives a symbol number.
+   Numbers 0 to NTOKENS - 1 are for tokens, and NTOKENS to NSYMS - 1
+   are for variables.  Symbol number zero is the end-of-input token.
+   This token is counted in ntokens.  The true number of token values
+   assigned is NTOKENS reduced by one for each alias declaration.
+
+   The rules receive rule numbers 1 to NRULES in the order they are
+   written.  More precisely Bison augments the grammar with the
+   initial rule, `$accept: START-SYMBOL $end', which is numbered 1,
+   all the user rules are 2, 3 etc.  Each time a rule number is
+   presented to the user, we subtract 1, so *displayed* rule numbers
+   are 0, 1, 2...
+
+   Internally, we cannot use the number 0 for a rule because for
+   instance RITEM stores both symbol (the RHS) and rule numbers: the
+   symbols are shorts >= 0, and rule number are stored negative.
+   Therefore 0 cannot be used, since it would be both the rule number
+   0, and the token $end).
+
+   Actions are accessed via the rule number.
+
+   The rules themselves are described by several arrays: amongst which
+   RITEM, and RULES.
+
+   RULES is an array of rules, whose members are:
+
+   RULES[R].lhs -- the symbol of the left hand side of rule R.
+
+   RULES[R].rhs -- the index in RITEM of the beginning of the portion
+   for rule R.
+
+   RULES[R].prec -- the symbol providing the precedence level of R.
+
+   RULES[R].precsym -- the symbol attached (via %prec) to give its
+   precedence to R.  Of course, if set, it is equal to `prec', but we
+   need to distinguish one from the other when reducing: a symbol used
+   in a %prec is not useless.
+
+   RULES[R].assoc -- the associativity of R.
+
+   RULES[R].dprec -- the dynamic precedence level of R (for GLR
+   parsing).
+
+   RULES[R].merger -- index of merging function for R (for GLR
+   parsing).
+
+   RULES[R].line -- the line where R was defined.
+
+   RULES[R].useful -- true iff the rule is used (i.e., false if thrown
+   away by reduce).
+
+   The right hand side is stored as symbol numbers in a portion of
+   RITEM.
+
+   The length of the portion is one greater than the number of symbols
+   in the rule's right hand side.  The last element in the portion
+   contains minus R, which identifies it as the end of a portion and
+   says which rule it is for.
+
+   The portions of RITEM come in order of increasing rule number.
+   NRITEMS is the total length of RITEM.  Each element of RITEM is
+   called an "item" and its index in RITEM is an item number.
+
+   Item numbers are used in the finite state machine to represent
+   places that parsing can get to.
+
+   SYMBOLS[I]->prec records the precedence level of each symbol.
+
+   Precedence levels are assigned in increasing order starting with 1
+   so that numerically higher precedence values mean tighter binding
+   as they ought to.  Zero as a symbol or rule's precedence means none
+   is assigned.
+
+   Associativities are recorded similarly in SYMBOLS[I]->assoc.  */
+
+# include "location.h"
+# include "symtab.h"
+
+# define ISTOKEN(i)	((i) < ntokens)
+# define ISVAR(i)	((i) >= ntokens)
+
+extern int nsyms;
+extern int ntokens;
+extern int nvars;
+
+typedef int item_number;
+extern item_number *ritem;
+extern unsigned int nritems;
+
+/* There is weird relationship between OT1H item_number and OTOH
+   symbol_number and rule_number: we store the latter in
+   item_number.  symbol_number values are stored as-is, while
+   the negation of (rule_number + 1) is stored.
+
+   Therefore, a symbol_number must be a valid item_number, and we
+   sometimes have to perform the converse transformation.  */
+
+static inline item_number
+symbol_number_as_item_number (symbol_number sym)
+{
+  return sym;
+}
+
+static inline symbol_number
+item_number_as_symbol_number (item_number i)
+{
+  return i;
+}
+
+static inline bool
+item_number_is_symbol_number (item_number i)
+{
+  return i >= 0;
+}
+
+/* Rule numbers.  */
+typedef int rule_number;
+extern rule_number nrules;
+
+static inline item_number
+rule_number_as_item_number (rule_number r)
+{
+  return -1 - r;
+}
+
+static inline rule_number
+item_number_as_rule_number (item_number i)
+{
+  return -1 - i;
+}
+
+static inline bool
+item_number_is_rule_number (item_number i)
+{
+  return i < 0;
+}
+
+/*--------.
+| Rules.  |
+`--------*/
+
+typedef struct
+{
+  /* The number of the rule in the source.  It is usually the index in
+     RULES too, except if there are useless rules.  */
+  rule_number user_number;
+
+  /* The index in RULES.  Usually the rule number in the source,
+     except if some rules are useless.  */
+  rule_number number;
+
+  symbol *lhs;
+  item_number *rhs;
+
+  /* This symbol provides both the associativity, and the precedence. */
+  symbol *prec;
+
+  int dprec;
+  int merger;
+
+  /* This symbol was attached to the rule via %prec. */
+  symbol *precsym;
+
+  location location;
+  bool useful;
+
+  const char *action;
+  location action_location;
+} rule;
+
+extern rule *rules;
+
+/* A function that selects a rule.  */
+typedef bool (*rule_filter) (rule *);
+
+/* Return true IFF the rule has a `number' smaller than NRULES.  */
+bool rule_useful_p (rule *r);
+
+/* Return true IFF the rule has a `number' higher than NRULES.  */
+bool rule_useless_p (rule *r);
+
+/* Return true IFF the rule is not flagged as useful *and* is useful.
+   In other words, it was discarded because of conflicts.  */
+bool rule_never_reduced_p (rule *r);
+
+/* Print this rule's number and lhs on OUT.  If a PREVIOUS_LHS was
+   already displayed (by a previous call for another rule), avoid
+   useless repetitions.  */
+void rule_lhs_print (rule *r, symbol *previous_lhs, FILE *out);
+
+/* Return the length of the RHS.  */
+int rule_rhs_length (rule *r);
+
+/* Print this rule's RHS on OUT.  */
+void rule_rhs_print (rule *r, FILE *out);
+
+/* Print this rule on OUT.  */
+void rule_print (rule *r, FILE *out);
+
+
+
+
+/* Table of the symbols, indexed by the symbol number. */
+extern symbol **symbols;
+
+/* TOKEN_TRANSLATION -- a table indexed by a token number as returned
+   by the user's yylex routine, it yields the internal token number
+   used by the parser and throughout bison.  */
+extern symbol_number *token_translations;
+extern int max_user_token_number;
+
+
+
+/* Dump RITEM for traces. */
+void ritem_print (FILE *out);
+
+/* Return the size of the longest rule RHS.  */
+size_t ritem_longest_rhs (void);
+
+/* Print the grammar's rules numbers from BEGIN (inclusive) to END
+   (exclusive) on OUT under TITLE.  */
+void grammar_rules_partial_print (FILE *out, const char *title,
+				  rule_filter filter);
+
+/* Print the grammar's rules on OUT.  */
+void grammar_rules_print (FILE *out);
+
+/* Dump the grammar. */
+void grammar_dump (FILE *out, const char *title);
+
+/* Report on STDERR the rules that are not flagged USEFUL, using the
+   MESSAGE (which can be `useless rule' when invoked after grammar
+   reduction, or `never reduced' after conflicts were taken into
+   account).  */
+void grammar_rules_never_reduced_report (const char *message);
+
+/* Free the packed grammar. */
+void grammar_free (void);
+
+#endif /* !GRAM_H_ */
diff --git a/src/lalr.c b/src/lalr.c
new file mode 100644
index 0000000..65c55ab
--- /dev/null
+++ b/src/lalr.c
@@ -0,0 +1,463 @@
+/* Compute look-ahead criteria for Bison.
+
+   Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002, 2003, 2004, 2005,
+   2006 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+
+/* Compute how to make the finite state machine deterministic; find
+   which rules need look-ahead in each state, and which look-ahead
+   tokens they accept.  */
+
+#include <config.h>
+#include "system.h"
+
+#include <bitset.h>
+#include <bitsetv.h>
+#include <quotearg.h>
+
+#include "LR0.h"
+#include "complain.h"
+#include "derives.h"
+#include "getargs.h"
+#include "gram.h"
+#include "lalr.h"
+#include "nullable.h"
+#include "reader.h"
+#include "relation.h"
+#include "symtab.h"
+
+goto_number *goto_map;
+static goto_number ngotos;
+state_number *from_state;
+state_number *to_state;
+
+/* Linked list of goto numbers.  */
+typedef struct goto_list
+{
+  struct goto_list *next;
+  goto_number value;
+} goto_list;
+
+
+/* LA is a LR by NTOKENS matrix of bits.  LA[l, i] is 1 if the rule
+   LArule[l] is applicable in the appropriate state when the next
+   token is symbol i.  If LA[l, i] and LA[l, j] are both 1 for i != j,
+   it is a conflict.  */
+
+static bitsetv LA = NULL;
+size_t nLA;
+
+
+/* And for the famous F variable, which name is so descriptive that a
+   comment is hardly needed.  <grin>.  */
+static bitsetv F = NULL;
+
+static goto_number **includes;
+static goto_list **lookback;
+
+
+
+
+static void
+set_goto_map (void)
+{
+  state_number s;
+  goto_number *temp_map;
+
+  goto_map = xcalloc (nvars + 1, sizeof *goto_map);
+  temp_map = xnmalloc (nvars + 1, sizeof *temp_map);
+
+  ngotos = 0;
+  for (s = 0; s < nstates; ++s)
+    {
+      transitions *sp = states[s]->transitions;
+      int i;
+      for (i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i)
+	{
+	  ngotos++;
+
+	  /* Abort if (ngotos + 1) would overflow.  */
+	  assert (ngotos != GOTO_NUMBER_MAXIMUM);
+
+	  goto_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
+	}
+    }
+
+  {
+    goto_number k = 0;
+    int i;
+    for (i = ntokens; i < nsyms; i++)
+      {
+	temp_map[i - ntokens] = k;
+	k += goto_map[i - ntokens];
+      }
+
+    for (i = ntokens; i < nsyms; i++)
+      goto_map[i - ntokens] = temp_map[i - ntokens];
+
+    goto_map[nsyms - ntokens] = ngotos;
+    temp_map[nsyms - ntokens] = ngotos;
+  }
+
+  from_state = xcalloc (ngotos, sizeof *from_state);
+  to_state = xcalloc (ngotos, sizeof *to_state);
+
+  for (s = 0; s < nstates; ++s)
+    {
+      transitions *sp = states[s]->transitions;
+      int i;
+      for (i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i)
+	{
+	  goto_number k = temp_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
+	  from_state[k] = s;
+	  to_state[k] = sp->states[i]->number;
+	}
+    }
+
+  free (temp_map);
+}
+
+
+
+/*----------------------------------------------------------.
+| Map a state/symbol pair into its numeric representation.  |
+`----------------------------------------------------------*/
+
+static goto_number
+map_goto (state_number s0, symbol_number sym)
+{
+  goto_number high;
+  goto_number low;
+  goto_number middle;
+  state_number s;
+
+  low = goto_map[sym - ntokens];
+  high = goto_map[sym - ntokens + 1] - 1;
+
+  for (;;)
+    {
+      assert (low <= high);
+      middle = (low + high) / 2;
+      s = from_state[middle];
+      if (s == s0)
+	return middle;
+      else if (s < s0)
+	low = middle + 1;
+      else
+	high = middle - 1;
+    }
+}
+
+
+static void
+initialize_F (void)
+{
+  goto_number **reads = xnmalloc (ngotos, sizeof *reads);
+  goto_number *edge = xnmalloc (ngotos + 1, sizeof *edge);
+  goto_number nedges = 0;
+
+  goto_number i;
+
+  F = bitsetv_create (ngotos, ntokens, BITSET_FIXED);
+
+  for (i = 0; i < ngotos; i++)
+    {
+      state_number stateno = to_state[i];
+      transitions *sp = states[stateno]->transitions;
+
+      int j;
+      FOR_EACH_SHIFT (sp, j)
+	bitset_set (F[i], TRANSITION_SYMBOL (sp, j));
+
+      for (; j < sp->num; j++)
+	{
+	  symbol_number sym = TRANSITION_SYMBOL (sp, j);
+	  if (nullable[sym - ntokens])
+	    edge[nedges++] = map_goto (stateno, sym);
+	}
+
+      if (nedges == 0)
+	reads[i] = NULL;
+      else
+	{
+	  reads[i] = xnmalloc (nedges + 1, sizeof reads[i][0]);
+	  memcpy (reads[i], edge, nedges * sizeof edge[0]);
+	  reads[i][nedges] = END_NODE;
+	  nedges = 0;
+	}
+    }
+
+  relation_digraph (reads, ngotos, &F);
+
+  for (i = 0; i < ngotos; i++)
+    free (reads[i]);
+
+  free (reads);
+  free (edge);
+}
+
+
+static void
+add_lookback_edge (state *s, rule *r, goto_number gotono)
+{
+  int ri = state_reduction_find (s, r);
+  goto_list *sp = xmalloc (sizeof *sp);
+  sp->next = lookback[(s->reductions->look_ahead_tokens - LA) + ri];
+  sp->value = gotono;
+  lookback[(s->reductions->look_ahead_tokens - LA) + ri] = sp;
+}
+
+
+
+static void
+build_relations (void)
+{
+  goto_number *edge = xnmalloc (ngotos + 1, sizeof *edge);
+  state_number *states1 = xnmalloc (ritem_longest_rhs () + 1, sizeof *states1);
+  goto_number i;
+
+  includes = xnmalloc (ngotos, sizeof *includes);
+
+  for (i = 0; i < ngotos; i++)
+    {
+      int nedges = 0;
+      symbol_number symbol1 = states[to_state[i]]->accessing_symbol;
+      rule **rulep;
+
+      for (rulep = derives[symbol1 - ntokens]; *rulep; rulep++)
+	{
+	  bool done;
+	  int length = 1;
+	  item_number const *rp;
+	  state *s = states[from_state[i]];
+	  states1[0] = s->number;
+
+	  for (rp = (*rulep)->rhs; ! item_number_is_rule_number (*rp); rp++)
+	    {
+	      s = transitions_to (s->transitions,
+				  item_number_as_symbol_number (*rp));
+	      states1[length++] = s->number;
+	    }
+
+	  if (!s->consistent)
+	    add_lookback_edge (s, *rulep, i);
+
+	  length--;
+	  done = false;
+	  while (!done)
+	    {
+	      done = true;
+	      /* Each rhs ends in an item number, and there is a
+		 sentinel before the first rhs, so it is safe to
+		 decrement RP here.  */
+	      rp--;
+	      if (ISVAR (*rp))
+		{
+		  /* Downcasting from item_number to symbol_number.  */
+		  edge[nedges++] = map_goto (states1[--length],
+					     item_number_as_symbol_number (*rp));
+		  if (nullable[*rp - ntokens])
+		    done = false;
+		}
+	    }
+	}
+
+      if (nedges == 0)
+	includes[i] = NULL;
+      else
+	{
+	  int j;
+	  includes[i] = xnmalloc (nedges + 1, sizeof includes[i][0]);
+	  for (j = 0; j < nedges; j++)
+	    includes[i][j] = edge[j];
+	  includes[i][nedges] = END_NODE;
+	}
+    }
+
+  free (edge);
+  free (states1);
+
+  relation_transpose (&includes, ngotos);
+}
+
+
+
+static void
+compute_FOLLOWS (void)
+{
+  goto_number i;
+
+  relation_digraph (includes, ngotos, &F);
+
+  for (i = 0; i < ngotos; i++)
+    free (includes[i]);
+
+  free (includes);
+}
+
+
+static void
+compute_look_ahead_tokens (void)
+{
+  size_t i;
+  goto_list *sp;
+
+  for (i = 0; i < nLA; i++)
+    for (sp = lookback[i]; sp; sp = sp->next)
+      bitset_or (LA[i], LA[i], F[sp->value]);
+
+  /* Free LOOKBACK. */
+  for (i = 0; i < nLA; i++)
+    LIST_FREE (goto_list, lookback[i]);
+
+  free (lookback);
+  bitsetv_free (F);
+}
+
+
+/*-----------------------------------------------------.
+| Count the number of look-ahead tokens required for S |
+| (N_LOOK_AHEAD_TOKENS member).                        |
+`-----------------------------------------------------*/
+
+static int
+state_look_ahead_tokens_count (state *s)
+{
+  int k;
+  int n_look_ahead_tokens = 0;
+  reductions *rp = s->reductions;
+  transitions *sp = s->transitions;
+
+  /* We need a look-ahead either to distinguish different
+     reductions (i.e., there are two or more), or to distinguish a
+     reduction from a shift.  Otherwise, it is straightforward,
+     and the state is `consistent'.  */
+  if (rp->num > 1
+      || (rp->num == 1 && sp->num &&
+	  !TRANSITION_IS_DISABLED (sp, 0) && TRANSITION_IS_SHIFT (sp, 0)))
+    n_look_ahead_tokens += rp->num;
+  else
+    s->consistent = 1;
+
+  for (k = 0; k < sp->num; k++)
+    if (!TRANSITION_IS_DISABLED (sp, k) && TRANSITION_IS_ERROR (sp, k))
+      {
+	s->consistent = 0;
+	break;
+      }
+
+  return n_look_ahead_tokens;
+}
+
+
+/*-----------------------------------------------------.
+| Compute LA, NLA, and the look_ahead_tokens members.  |
+`-----------------------------------------------------*/
+
+static void
+initialize_LA (void)
+{
+  state_number i;
+  bitsetv pLA;
+
+  /* Compute the total number of reductions requiring a look-ahead.  */
+  nLA = 0;
+  for (i = 0; i < nstates; i++)
+    nLA += state_look_ahead_tokens_count (states[i]);
+  /* Avoid having to special case 0.  */
+  if (!nLA)
+    nLA = 1;
+
+  pLA = LA = bitsetv_create (nLA, ntokens, BITSET_FIXED);
+  lookback = xcalloc (nLA, sizeof *lookback);
+
+  /* Initialize the members LOOK_AHEAD_TOKENS for each state whose reductions
+     require look-ahead tokens.  */
+  for (i = 0; i < nstates; i++)
+    {
+      int count = state_look_ahead_tokens_count (states[i]);
+      if (count)
+	{
+	  states[i]->reductions->look_ahead_tokens = pLA;
+	  pLA += count;
+	}
+    }
+}
+
+
+/*----------------------------------------------.
+| Output the look-ahead tokens for each state.  |
+`----------------------------------------------*/
+
+static void
+look_ahead_tokens_print (FILE *out)
+{
+  state_number i;
+  int j, k;
+  fprintf (out, "Look-ahead tokens: BEGIN\n");
+  for (i = 0; i < nstates; ++i)
+    {
+      reductions *reds = states[i]->reductions;
+      bitset_iterator iter;
+      int n_look_ahead_tokens = 0;
+
+      if (reds->look_ahead_tokens)
+	for (k = 0; k < reds->num; ++k)
+	  if (reds->look_ahead_tokens[k])
+	    ++n_look_ahead_tokens;
+
+      fprintf (out, "State %d: %d look-ahead tokens\n",
+	       i, n_look_ahead_tokens);
+
+      if (reds->look_ahead_tokens)
+	for (j = 0; j < reds->num; ++j)
+	  BITSET_FOR_EACH (iter, reds->look_ahead_tokens[j], k, 0)
+	  {
+	    fprintf (out, "   on %d (%s) -> rule %d\n",
+		     k, symbols[k]->tag,
+		     reds->rules[j]->number);
+	  };
+    }
+  fprintf (out, "Look-ahead tokens: END\n");
+}
+
+void
+lalr (void)
+{
+  initialize_LA ();
+  set_goto_map ();
+  initialize_F ();
+  build_relations ();
+  compute_FOLLOWS ();
+  compute_look_ahead_tokens ();
+
+  if (trace_flag & trace_sets)
+    look_ahead_tokens_print (stderr);
+}
+
+
+void
+lalr_free (void)
+{
+  state_number s;
+  for (s = 0; s < nstates; ++s)
+    states[s]->reductions->look_ahead_tokens = NULL;
+  bitsetv_free (LA);
+}
diff --git a/src/lalr.h b/src/lalr.h
new file mode 100644
index 0000000..a2c1753
--- /dev/null
+++ b/src/lalr.h
@@ -0,0 +1,67 @@
+/* Compute look-ahead criteria for bison,
+
+   Copyright (C) 1984, 1986, 1989, 2000, 2002, 2004 Free Software
+   Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#ifndef LALR_H_
+# define LALR_H_
+
+# include <bitset.h>
+# include <bitsetv.h>
+
+/* Import the definition of RULE_T. */
+# include "gram.h"
+
+/* Import the definition of CORE, TRANSITIONS and REDUCTIONS. */
+# include "state.h"
+
+/* Compute how to make the finite state machine deterministic; find
+   which rules need look-ahead in each state, and which look-ahead
+   tokens they accept.  */
+
+void lalr (void);
+
+/* Release the information related to look-ahead tokens.  Can be performed
+   once the action tables are computed.  */
+
+void lalr_free (void);
+
+
+/* lalr() builds these data structures. */
+
+/* GOTO_MAP, FROM_STATE and TO_STATE -- record each shift transition
+   which accepts a variable (a nonterminal).
+
+   FROM_STATE[T] -- state number which a transition leads from.
+   TO_STATE[T] -- state number it leads to.
+
+   All the transitions that accept a particular variable are grouped
+   together and GOTO_MAP[I - NTOKENS] is the index in FROM_STATE and
+   TO_STATE of the first of them.  */
+
+typedef size_t goto_number;
+# define GOTO_NUMBER_MAXIMUM ((goto_number) -1)
+
+extern goto_number *goto_map;
+extern state_number *from_state;
+extern state_number *to_state;
+
+
+#endif /* !LALR_H_ */
diff --git a/src/location.c b/src/location.c
new file mode 100644
index 0000000..ecd3658
--- /dev/null
+++ b/src/location.c
@@ -0,0 +1,48 @@
+/* Locations for Bison
+
+   Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+#include "system.h"
+
+#include <quotearg.h>
+
+#include "location.h"
+
+location const empty_location;
+
+/* Output to OUT the location LOC.
+   Warning: it uses quotearg's slot 3.  */
+void
+location_print (FILE *out, location loc)
+{
+  fprintf (out, "%s:%d.%d",
+	   quotearg_n_style (3, escape_quoting_style, loc.start.file),
+	   loc.start.line, loc.start.column);
+
+  if (loc.start.file != loc.end.file)
+    fprintf (out, "-%s:%d.%d",
+	     quotearg_n_style (3, escape_quoting_style, loc.end.file),
+	     loc.end.line, loc.end.column - 1);
+  else if (loc.start.line < loc.end.line)
+    fprintf (out, "-%d.%d", loc.end.line, loc.end.column - 1);
+  else if (loc.start.column < loc.end.column - 1)
+    fprintf (out, "-%d", loc.end.column - 1);
+}
diff --git a/src/location.h b/src/location.h
new file mode 100644
index 0000000..49d2a2e
--- /dev/null
+++ b/src/location.h
@@ -0,0 +1,69 @@
+/* Locations for Bison
+   Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#ifndef LOCATION_H_
+# define LOCATION_H_
+
+# include "uniqstr.h"
+
+/* A boundary between two characters.  */
+typedef struct
+{
+  /* The name of the file that contains the boundary.  */
+  uniqstr file;
+
+  /* The (origin-1) line that contains the boundary.
+     If this is INT_MAX, the line number has overflowed.  */
+  int line;
+
+  /* The (origin-1) column just after the boundary.  This is neither a
+     byte count, nor a character count; it is a column count.
+     If this is INT_MAX, the column number has overflowed.  */
+  int column;
+
+} boundary;
+
+/* Return nonzero if A and B are equal boundaries.  */
+static inline bool
+equal_boundaries (boundary a, boundary b)
+{
+  return (a.column == b.column
+	  && a.line == b.line
+	  && UNIQSTR_EQ (a.file, b.file));
+}
+
+/* A location, that is, a region of source code.  */
+typedef struct
+{
+  /* Boundary just before the location starts.  */
+  boundary start;
+
+  /* Boundary just after the location ends.  */
+  boundary end;
+
+} location;
+
+#define YYLTYPE location
+
+extern location const empty_location;
+
+void location_print (FILE *out, location loc);
+
+#endif /* ! defined LOCATION_H_ */
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..8769fef
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,187 @@
+/* Top level entry point of Bison.
+
+   Copyright (C) 1984, 1986, 1989, 1992, 1995, 2000, 2001, 2002, 2004, 2005
+   Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+#include "system.h"
+
+#include <bitset_stats.h>
+#include <bitset.h>
+#include <timevar.h>
+
+#include "LR0.h"
+#include "complain.h"
+#include "conflicts.h"
+#include "derives.h"
+#include "files.h"
+#include "getargs.h"
+#include "gram.h"
+#include "lalr.h"
+#include "muscle_tab.h"
+#include "nullable.h"
+#include "output.h"
+#include "print.h"
+#include "print_graph.h"
+#include "reader.h"
+#include "reduce.h"
+#include "symtab.h"
+#include "tables.h"
+#include "uniqstr.h"
+
+/* The name this program was run with, for messages.  */
+char *program_name;
+
+
+
+int
+main (int argc, char *argv[])
+{
+  program_name = argv[0];
+  setlocale (LC_ALL, "");
+  (void) bindtextdomain (PACKAGE, LOCALEDIR);
+  (void) bindtextdomain ("bison-runtime", LOCALEDIR);
+  (void) textdomain (PACKAGE);
+
+  uniqstrs_new ();
+
+  getargs (argc, argv);
+
+  timevar_report = trace_flag & trace_time;
+  init_timevar ();
+  timevar_start (TV_TOTAL);
+
+  if (trace_flag & trace_bitsets)
+    bitset_stats_enable ();
+
+  muscle_init ();
+
+  /* Read the input.  Copy some parts of it to FGUARD, FACTION, FTABLE
+     and FATTRS.  In file reader.c.  The other parts are recorded in
+     the grammar; see gram.h.  */
+
+  timevar_push (TV_READER);
+  reader ();
+  timevar_pop (TV_READER);
+
+  if (complaint_issued)
+    goto finish;
+
+  /* Find useless nonterminals and productions and reduce the grammar. */
+  timevar_push (TV_REDUCE);
+  reduce_grammar ();
+  timevar_pop (TV_REDUCE);
+
+  /* Record other info about the grammar.  In files derives and
+     nullable.  */
+  timevar_push (TV_SETS);
+  derives_compute ();
+  nullable_compute ();
+  timevar_pop (TV_SETS);
+
+  /* Convert to nondeterministic finite state machine.  In file LR0.
+     See state.h for more info.  */
+  timevar_push (TV_LR0);
+  generate_states ();
+  timevar_pop (TV_LR0);
+
+  /* make it deterministic.  In file lalr.  */
+  timevar_push (TV_LALR);
+  lalr ();
+  timevar_pop (TV_LALR);
+
+  /* Find and record any conflicts: places where one token of
+     look-ahead is not enough to disambiguate the parsing.  In file
+     conflicts.  Also resolve s/r conflicts based on precedence
+     declarations.  */
+  timevar_push (TV_CONFLICTS);
+  conflicts_solve ();
+  conflicts_print ();
+  timevar_pop (TV_CONFLICTS);
+
+  /* Compute the parser tables.  */
+  timevar_push (TV_ACTIONS);
+  tables_generate ();
+  timevar_pop (TV_ACTIONS);
+
+  grammar_rules_never_reduced_report
+    (_("rule never reduced because of conflicts"));
+
+  /* Output file names. */
+  compute_output_file_names ();
+
+  /* Output the detailed report on the grammar.  */
+  if (report_flag)
+    {
+      timevar_push (TV_REPORT);
+      print_results ();
+      timevar_pop (TV_REPORT);
+    }
+
+  /* Output the VCG graph.  */
+  if (graph_flag)
+    {
+      timevar_push (TV_GRAPH);
+      print_graph ();
+      timevar_pop (TV_GRAPH);
+    }
+
+  /* Stop if there were errors, to avoid trashing previous output
+     files.  */
+  if (complaint_issued)
+    goto finish;
+
+  /* Look-ahead tokens are no longer needed. */
+  timevar_push (TV_FREE);
+  lalr_free ();
+  timevar_pop (TV_FREE);
+
+  /* Output the tables and the parser to ftable.  In file output.  */
+  timevar_push (TV_PARSER);
+  output ();
+  timevar_pop (TV_PARSER);
+
+  timevar_push (TV_FREE);
+  nullable_free ();
+  derives_free ();
+  tables_free ();
+  states_free ();
+  reduce_free ();
+  conflicts_free ();
+  grammar_free ();
+
+  /* The scanner memory cannot be released right after parsing, as it
+     contains things such as user actions, prologue, epilogue etc.  */
+  scanner_free ();
+  muscle_free ();
+  uniqstrs_free ();
+  timevar_pop (TV_FREE);
+
+  if (trace_flag & trace_bitsets)
+    bitset_stats_dump (stderr);
+
+ finish:
+
+  /* Stop timing and print the times.  */
+  timevar_stop (TV_TOTAL);
+  timevar_print (stderr);
+
+  return complaint_issued ? EXIT_FAILURE : EXIT_SUCCESS;
+}
diff --git a/src/muscle_tab.c b/src/muscle_tab.c
new file mode 100644
index 0000000..2d71085
--- /dev/null
+++ b/src/muscle_tab.c
@@ -0,0 +1,241 @@
+/* Muscle table manager for Bison.
+
+   Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software
+   Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+#include "system.h"
+
+#include <hash.h>
+#include <quotearg.h>
+
+#include "files.h"
+#include "muscle_tab.h"
+#include "getargs.h"
+
+typedef struct
+{
+  const char *key;
+  char *value;
+} muscle_entry;
+
+/* An obstack used to create some entries.  */
+struct obstack muscle_obstack;
+
+/* Initial capacity of muscles hash table.  */
+#define HT_INITIAL_CAPACITY 257
+
+static struct hash_table *muscle_table = NULL;
+
+static bool
+hash_compare_muscles (void const *x, void const *y)
+{
+  muscle_entry const *m1 = x;
+  muscle_entry const *m2 = y;
+  return strcmp (m1->key, m2->key) == 0;
+}
+
+static size_t
+hash_muscle (const void *x, size_t tablesize)
+{
+  muscle_entry const *m = x;
+  return hash_string (m->key, tablesize);
+}
+
+/*-----------------------------------------------------------------.
+| Create the MUSCLE_TABLE, and initialize it with default values.  |
+| Also set up the MUSCLE_OBSTACK.                                  |
+`-----------------------------------------------------------------*/
+
+void
+muscle_init (void)
+{
+  /* Initialize the muscle obstack.  */
+  obstack_init (&muscle_obstack);
+
+  muscle_table = hash_initialize (HT_INITIAL_CAPACITY, NULL, hash_muscle,
+				  hash_compare_muscles, free);
+
+  /* Version and input file.  */
+  MUSCLE_INSERT_STRING ("version", VERSION);
+  MUSCLE_INSERT_C_STRING ("file_name", grammar_file);
+}
+
+
+/*------------------------------------------------------------.
+| Free all the memory consumed by the muscle machinery only.  |
+`------------------------------------------------------------*/
+
+void
+muscle_free (void)
+{
+  hash_free (muscle_table);
+  obstack_free (&muscle_obstack, NULL);
+}
+
+
+
+/*------------------------------------------------------------.
+| Insert (KEY, VALUE).  If KEY already existed, overwrite the |
+| previous value.                                             |
+`------------------------------------------------------------*/
+
+void
+muscle_insert (const char *key, char *value)
+{
+  muscle_entry probe;
+  muscle_entry *entry;
+
+  probe.key = key;
+  entry = hash_lookup (muscle_table, &probe);
+
+  if (!entry)
+    {
+      /* First insertion in the hash. */
+      entry = xmalloc (sizeof *entry);
+      entry->key = key;
+      hash_insert (muscle_table, entry);
+    }
+  entry->value = value;
+}
+
+
+/*-------------------------------------------------------------------.
+| Append VALUE to the current value of KEY.  If KEY did not already  |
+| exist, create it.  Use MUSCLE_OBSTACK.  De-allocate the previously |
+| associated value.  Copy VALUE and SEPARATOR.                       |
+`-------------------------------------------------------------------*/
+
+void
+muscle_grow (const char *key, const char *val, const char *separator)
+{
+  muscle_entry probe;
+  muscle_entry *entry = NULL;
+
+  probe.key = key;
+  entry = hash_lookup (muscle_table, &probe);
+
+  if (!entry)
+    {
+      /* First insertion in the hash. */
+      entry = xmalloc (sizeof *entry);
+      entry->key = key;
+      hash_insert (muscle_table, entry);
+      entry->value = xstrdup (val);
+    }
+  else
+    {
+      /* Grow the current value. */
+      char *new_val;
+      obstack_sgrow (&muscle_obstack, entry->value);
+      free (entry->value);
+      obstack_sgrow (&muscle_obstack, separator);
+      obstack_sgrow (&muscle_obstack, val);
+      obstack_1grow (&muscle_obstack, 0);
+      new_val = obstack_finish (&muscle_obstack);
+      entry->value = xstrdup (new_val);
+      obstack_free (&muscle_obstack, new_val);
+    }
+}
+
+
+/*------------------------------------------------------------------.
+| Append VALUE to the current value of KEY, using muscle_grow.  But |
+| in addition, issue a synchronization line for the location LOC.   |
+`------------------------------------------------------------------*/
+
+void
+muscle_code_grow (const char *key, const char *val, location loc)
+{
+  char *extension = NULL;
+  obstack_fgrow1 (&muscle_obstack, "]b4_syncline(%d, [[", loc.start.line);
+  MUSCLE_OBSTACK_SGROW (&muscle_obstack,
+			quotearg_style (c_quoting_style, loc.start.file));
+  obstack_sgrow (&muscle_obstack, "]])[\n");
+  obstack_sgrow (&muscle_obstack, val);
+  obstack_1grow (&muscle_obstack, 0);
+  extension = obstack_finish (&muscle_obstack);
+  muscle_grow (key, extension, "");
+}
+
+
+/*-------------------------------------------------------------------.
+| MUSCLE is an M4 list of pairs.  Create or extend it with the pair  |
+| (A1, A2).  Note that because the muscle values are output *double* |
+| quoted, one needs to strip the first level of quotes to reach the  |
+| list itself.                                                       |
+`-------------------------------------------------------------------*/
+
+void muscle_pair_list_grow (const char *muscle,
+			    const char *a1, const char *a2)
+{
+  char *pair;
+  obstack_fgrow2 (&muscle_obstack, "[[[%s]], [[%s]]]", a1, a2);
+  obstack_1grow (&muscle_obstack, 0);
+  pair = obstack_finish (&muscle_obstack);
+  muscle_grow (muscle, pair, ",\n");
+  obstack_free (&muscle_obstack, pair);
+}
+
+/*-------------------------------.
+| Find the value of muscle KEY.  |
+`-------------------------------*/
+
+char *
+muscle_find (const char *key)
+{
+  muscle_entry probe;
+  muscle_entry *result = NULL;
+
+  probe.key = key;
+  result = hash_lookup (muscle_table, &probe);
+  return result ? result->value : NULL;
+}
+
+
+/*------------------------------------------------.
+| Output the definition of ENTRY as a m4_define.  |
+`------------------------------------------------*/
+
+static inline bool
+muscle_m4_output (muscle_entry *entry, FILE *out)
+{
+  fprintf (out, "m4_define([b4_%s],\n", entry->key);
+  fprintf (out, "[[%s]])\n\n\n", entry->value);
+  return true;
+}
+
+static bool
+muscle_m4_output_processor (void *entry, void *out)
+{
+  return muscle_m4_output (entry, out);
+}
+
+
+/*----------------------------------------------------------------.
+| Output the definition of all the current muscles into a list of |
+| m4_defines.                                                     |
+`----------------------------------------------------------------*/
+
+void
+muscles_m4_output (FILE *out)
+{
+  hash_do_for_each (muscle_table, muscle_m4_output_processor, out);
+}
diff --git a/src/muscle_tab.h b/src/muscle_tab.h
new file mode 100644
index 0000000..9e8ac24
--- /dev/null
+++ b/src/muscle_tab.h
@@ -0,0 +1,108 @@
+/* Muscle table manager for Bison,
+   Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#ifndef MUSCLE_TAB_H_
+# define MUSCLE_TAB_H_
+
+# include "location.h"
+
+void muscle_init (void);
+void muscle_insert (const char *key, char *value);
+char *muscle_find (const char *key);
+void muscle_free (void);
+
+
+/* An obstack dedicated to receive muscle keys and values.  */
+extern struct obstack muscle_obstack;
+
+#define MUSCLE_INSERT_BOOL(Key, Value)				\
+{								\
+  int v = Value;						\
+  MUSCLE_INSERT_INT (Key, v);					\
+}
+
+#define MUSCLE_INSERT_INT(Key, Value)				\
+{								\
+  obstack_fgrow1 (&muscle_obstack, "%d", Value);		\
+  obstack_1grow (&muscle_obstack, 0);				\
+  muscle_insert (Key, obstack_finish (&muscle_obstack));	\
+}
+
+#define MUSCLE_INSERT_LONG_INT(Key, Value)			\
+{								\
+  obstack_fgrow1 (&muscle_obstack, "%ld", Value);		\
+  obstack_1grow (&muscle_obstack, 0);				\
+  muscle_insert (Key, obstack_finish (&muscle_obstack));	\
+}
+
+#define MUSCLE_INSERT_STRING(Key, Value)			\
+{								\
+  obstack_sgrow (&muscle_obstack, Value);			\
+  obstack_1grow (&muscle_obstack, 0);				\
+  muscle_insert (Key, obstack_finish (&muscle_obstack));	\
+}
+
+#define MUSCLE_OBSTACK_SGROW(Obstack, Value)			\
+{								\
+  char const *p;						\
+  for (p = Value; *p; p++)					\
+    switch (*p)							\
+      {								\
+      case '$':	obstack_sgrow (Obstack, "$]["); break;		\
+      case '@':	obstack_sgrow (Obstack, "@@" ); break;		\
+      case '[':	obstack_sgrow (Obstack, "@{" ); break;		\
+      case ']':	obstack_sgrow (Obstack, "@}" ); break;		\
+      default: obstack_1grow (Obstack, *p); break;		\
+      }								\
+}
+
+#define MUSCLE_INSERT_C_STRING(Key, Value)			\
+{								\
+  MUSCLE_OBSTACK_SGROW (&muscle_obstack,			\
+			quotearg_style (c_quoting_style,	\
+					Value));		\
+  obstack_1grow (&muscle_obstack, 0);				\
+  muscle_insert (Key, obstack_finish (&muscle_obstack));	\
+}
+
+/* Insert (KEY, VALUE).  If KEY already existed, overwrite the
+   previous value.  Uses MUSCLE_OBSTACK.  De-allocates the previously
+   associated value.  VALUE and SEPARATOR are copied.  */
+
+void muscle_grow (const char *key, const char *value, const char *separator);
+
+
+/* Append VALUE to the current value of KEY, using muscle_grow.  But
+   in addition, issue a synchronization line for the location LOC.  */
+
+void muscle_code_grow (const char *key, const char *value, location loc);
+
+
+/* MUSCLE is an M4 list of pairs.  Create or extend it with the pair
+   (A1, A2).  Note that because the muscle values are output *double*
+   quoted, one needs to strip the first level of quotes to reach the
+   list itself.  */
+
+void muscle_pair_list_grow (const char *muscle,
+			    const char *a1, const char *a2);
+
+void muscles_m4_output (FILE *out);
+
+#endif /* not MUSCLE_TAB_H_ */
diff --git a/src/nullable.c b/src/nullable.c
new file mode 100644
index 0000000..83a90e9
--- /dev/null
+++ b/src/nullable.c
@@ -0,0 +1,144 @@
+/* Calculate which nonterminals can expand into the null string for Bison.
+
+   Copyright (C) 1984, 1989, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+   Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+
+/* Set up NULLABLE, a vector saying which nonterminals can expand into
+   the null string.  NULLABLE[I - NTOKENS] is nonzero if symbol I can
+   do so.  */
+
+#include <config.h>
+#include "system.h"
+
+#include "getargs.h"
+#include "gram.h"
+#include "nullable.h"
+#include "reduce.h"
+#include "symtab.h"
+
+/* Linked list of rules.  */
+typedef struct rule_list
+{
+  struct rule_list *next;
+  rule *value;
+} rule_list;
+
+bool *nullable = NULL;
+
+static void
+nullable_print (FILE *out)
+{
+  int i;
+  fputs ("NULLABLE\n", out);
+  for (i = ntokens; i < nsyms; i++)
+    fprintf (out, "\t%s: %s\n", symbols[i]->tag,
+	     nullable[i - ntokens] ? "yes" : "no");
+  fputs ("\n\n", out);
+}
+
+void
+nullable_compute (void)
+{
+  rule_number ruleno;
+  symbol_number *s1;
+  symbol_number *s2;
+  rule_list *p;
+
+  symbol_number *squeue = xnmalloc (nvars, sizeof *squeue);
+  size_t *rcount = xcalloc (nrules, sizeof *rcount);
+  /* RITEM contains all the rules, including useless productions.
+     Hence we must allocate room for useless nonterminals too.  */
+  rule_list **rsets = xcalloc (nvars, sizeof *rsets);
+  /* This is said to be more elements than we actually use.
+     Supposedly NRITEMS - NRULES is enough.  But why take the risk?  */
+  rule_list *relts = xnmalloc (nritems + nvars + 1, sizeof *relts);
+
+  nullable = xcalloc (nvars, sizeof *nullable);
+
+  s1 = s2 = squeue;
+  p = relts;
+
+  for (ruleno = 0; ruleno < nrules; ++ruleno)
+    if (rules[ruleno].useful)
+      {
+	rule *rules_ruleno = &rules[ruleno];
+	if (rules_ruleno->rhs[0] >= 0)
+	  {
+	    /* This rule has a non empty RHS. */
+	    item_number *rp = NULL;
+	    bool any_tokens = false;
+	    for (rp = rules_ruleno->rhs; *rp >= 0; ++rp)
+	      if (ISTOKEN (*rp))
+		any_tokens = true;
+
+	    /* This rule has only nonterminals: schedule it for the second
+	       pass.  */
+	    if (!any_tokens)
+	      for (rp = rules_ruleno->rhs; *rp >= 0; ++rp)
+		{
+		  rcount[ruleno]++;
+		  p->next = rsets[*rp - ntokens];
+		  p->value = rules_ruleno;
+		  rsets[*rp - ntokens] = p;
+		  p++;
+		}
+	  }
+	else
+	  {
+	    /* This rule has an empty RHS. */
+	    assert (item_number_as_rule_number (rules_ruleno->rhs[0])
+		    == ruleno);
+	    if (rules_ruleno->useful
+		&& ! nullable[rules_ruleno->lhs->number - ntokens])
+	      {
+		nullable[rules_ruleno->lhs->number - ntokens] = true;
+		*s2++ = rules_ruleno->lhs->number;
+	      }
+	  }
+      }
+
+  while (s1 < s2)
+    for (p = rsets[*s1++ - ntokens]; p; p = p->next)
+      {
+	rule *r = p->value;
+	if (--rcount[r->number] == 0)
+	  if (r->useful && ! nullable[r->lhs->number - ntokens])
+	    {
+	      nullable[r->lhs->number - ntokens] = true;
+	      *s2++ = r->lhs->number;
+	    }
+      }
+
+  free (squeue);
+  free (rcount);
+  free (rsets);
+  free (relts);
+
+  if (trace_flag & trace_sets)
+    nullable_print (stderr);
+}
+
+
+void
+nullable_free (void)
+{
+  free (nullable);
+}
diff --git a/src/nullable.h b/src/nullable.h
new file mode 100644
index 0000000..d5106c7
--- /dev/null
+++ b/src/nullable.h
@@ -0,0 +1,33 @@
+/* Part of the bison parser generator,
+   Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#ifndef NULLABLE_H_
+# define NULLABLE_H_
+
+/* A vector saying which nonterminals can expand into the null string.
+   NULLABLE[I - NTOKENS] is nonzero if symbol I can do so.  */
+extern bool *nullable;
+
+/* Set up NULLABLE. */
+extern void nullable_compute (void);
+
+/* Free NULLABLE. */
+extern void nullable_free (void);
+#endif /* !NULLABLE_H_ */
diff --git a/src/output.c b/src/output.c
new file mode 100644
index 0000000..6a02bb3
--- /dev/null
+++ b/src/output.c
@@ -0,0 +1,652 @@
+/* Output the generated parsing program for Bison.
+
+   Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003, 2004,
+   2005, 2006 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+
+#include <config.h>
+#include "system.h"
+
+#include <error.h>
+#include <get-errno.h>
+#include <quotearg.h>
+#include <subpipe.h>
+#include <timevar.h>
+
+#include "complain.h"
+#include "files.h"
+#include "getargs.h"
+#include "gram.h"
+#include "muscle_tab.h"
+#include "output.h"
+#include "reader.h"
+#include "scan-skel.h"
+#include "symtab.h"
+#include "tables.h"
+
+
+static struct obstack format_obstack;
+
+
+/*-------------------------------------------------------------------.
+| Create a function NAME which associates to the muscle NAME the     |
+| result of formatting the FIRST and then TABLE_DATA[BEGIN..END[ (of |
+| TYPE), and to the muscle NAME_max, the max value of the            |
+| TABLE_DATA.                                                        |
+`-------------------------------------------------------------------*/
+
+
+#define GENERATE_MUSCLE_INSERT_TABLE(Name, Type)			\
+									\
+static void								\
+Name (char const *name,							\
+      Type *table_data,							\
+      Type first,							\
+      int begin,							\
+      int end)								\
+{									\
+  Type min = first;							\
+  Type max = first;							\
+  long int lmin;							\
+  long int lmax;							\
+  int i;								\
+  int j = 1;								\
+									\
+  obstack_fgrow1 (&format_obstack, "%6d", first);			\
+  for (i = begin; i < end; ++i)						\
+    {									\
+      obstack_1grow (&format_obstack, ',');				\
+      if (j >= 10)							\
+	{								\
+	  obstack_sgrow (&format_obstack, "\n  ");			\
+	  j = 1;							\
+	}								\
+      else								\
+	++j;								\
+      obstack_fgrow1 (&format_obstack, "%6d", table_data[i]);		\
+      if (table_data[i] < min)						\
+	min = table_data[i];						\
+      if (max < table_data[i])						\
+	max = table_data[i];						\
+    }									\
+  obstack_1grow (&format_obstack, 0);					\
+  muscle_insert (name, obstack_finish (&format_obstack));		\
+									\
+  lmin = min;								\
+  lmax = max;								\
+  /* Build `NAME_min' and `NAME_max' in the obstack. */			\
+  obstack_fgrow1 (&format_obstack, "%s_min", name);			\
+  obstack_1grow (&format_obstack, 0);					\
+  MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmin);	\
+  obstack_fgrow1 (&format_obstack, "%s_max", name);			\
+  obstack_1grow (&format_obstack, 0);					\
+  MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmax);	\
+}
+
+GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_unsigned_int_table, unsigned int)
+GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_int_table, int)
+GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_base_table, base_number)
+GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_rule_number_table, rule_number)
+GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_symbol_number_table, symbol_number)
+GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_item_number_table, item_number)
+GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_state_number_table, state_number)
+
+
+/*--------------------------------------------------------------------.
+| Print to OUT a representation of STRING escaped both for C and M4.  |
+`--------------------------------------------------------------------*/
+
+static void
+escaped_output (FILE *out, char const *string)
+{
+  char const *p;
+  fprintf (out, "[[");
+
+  for (p = quotearg_style (c_quoting_style, string); *p; p++)
+    switch (*p)
+      {
+      case '$': fputs ("$][", out); break;
+      case '@': fputs ("@@",  out); break;
+      case '[': fputs ("@{",  out); break;
+      case ']': fputs ("@}",  out); break;
+      default: fputc (*p, out); break;
+      }
+
+  fprintf (out, "]]");
+}
+
+
+/*------------------------------------------------------------------.
+| Prepare the muscles related to the symbols: translate, tname, and |
+| toknum.                                                           |
+`------------------------------------------------------------------*/
+
+static void
+prepare_symbols (void)
+{
+  MUSCLE_INSERT_BOOL ("token_table", token_table_flag);
+  MUSCLE_INSERT_INT ("tokens_number", ntokens);
+  MUSCLE_INSERT_INT ("nterms_number", nvars);
+  MUSCLE_INSERT_INT ("undef_token_number", undeftoken->number);
+  MUSCLE_INSERT_INT ("user_token_number_max", max_user_token_number);
+
+  muscle_insert_symbol_number_table ("translate",
+				     token_translations,
+				     token_translations[0],
+				     1, max_user_token_number + 1);
+
+  /* tname -- token names.  */
+  {
+    int i;
+    /* We assume that the table will be output starting at column 2. */
+    int j = 2;
+    for (i = 0; i < nsyms; i++)
+      {
+	char const *cp = quotearg_style (c_quoting_style, symbols[i]->tag);
+	/* Width of the next token, including the two quotes, the
+	   comma and the space.  */
+	int width = strlen (cp) + 2;
+
+	if (j + width > 75)
+	  {
+	    obstack_sgrow (&format_obstack, "\n ");
+	    j = 1;
+	  }
+
+	if (i)
+	  obstack_1grow (&format_obstack, ' ');
+	MUSCLE_OBSTACK_SGROW (&format_obstack, cp);
+	obstack_1grow (&format_obstack, ',');
+	j += width;
+      }
+    /* Add a NULL entry to list of tokens (well, 0, as NULL might not be
+       defined).  */
+    obstack_sgrow (&format_obstack, " 0");
+
+    /* Finish table and store. */
+    obstack_1grow (&format_obstack, 0);
+    muscle_insert ("tname", obstack_finish (&format_obstack));
+  }
+
+  /* Output YYTOKNUM. */
+  {
+    int i;
+    int *values = xnmalloc (ntokens, sizeof *values);
+    for (i = 0; i < ntokens; ++i)
+      values[i] = symbols[i]->user_token_number;
+    muscle_insert_int_table ("toknum", values,
+			     values[0], 1, ntokens);
+    free (values);
+  }
+}
+
+
+/*-------------------------------------------------------------.
+| Prepare the muscles related to the rules: rhs, prhs, r1, r2, |
+| rline, dprec, merger.                                        |
+`-------------------------------------------------------------*/
+
+static void
+prepare_rules (void)
+{
+  rule_number r;
+  unsigned int i = 0;
+  item_number *rhs = xnmalloc (nritems, sizeof *rhs);
+  unsigned int *prhs = xnmalloc (nrules, sizeof *prhs);
+  unsigned int *rline = xnmalloc (nrules, sizeof *rline);
+  symbol_number *r1 = xnmalloc (nrules, sizeof *r1);
+  unsigned int *r2 = xnmalloc (nrules, sizeof *r2);
+  int *dprec = xnmalloc (nrules, sizeof *dprec);
+  int *merger = xnmalloc (nrules, sizeof *merger);
+
+  for (r = 0; r < nrules; ++r)
+    {
+      item_number *rhsp = NULL;
+      /* Index of rule R in RHS. */
+      prhs[r] = i;
+      /* RHS of the rule R. */
+      for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
+	rhs[i++] = *rhsp;
+      /* LHS of the rule R. */
+      r1[r] = rules[r].lhs->number;
+      /* Length of rule R's RHS. */
+      r2[r] = i - prhs[r];
+      /* Separator in RHS. */
+      rhs[i++] = -1;
+      /* Line where rule was defined. */
+      rline[r] = rules[r].location.start.line;
+      /* Dynamic precedence (GLR).  */
+      dprec[r] = rules[r].dprec;
+      /* Merger-function index (GLR).  */
+      merger[r] = rules[r].merger;
+    }
+  assert (i == nritems);
+
+  muscle_insert_item_number_table ("rhs", rhs, ritem[0], 1, nritems);
+  muscle_insert_unsigned_int_table ("prhs", prhs, 0, 0, nrules);
+  muscle_insert_unsigned_int_table ("rline", rline, 0, 0, nrules);
+  muscle_insert_symbol_number_table ("r1", r1, 0, 0, nrules);
+  muscle_insert_unsigned_int_table ("r2", r2, 0, 0, nrules);
+  muscle_insert_int_table ("dprec", dprec, 0, 0, nrules);
+  muscle_insert_int_table ("merger", merger, 0, 0, nrules);
+
+  MUSCLE_INSERT_INT ("rules_number", nrules);
+  MUSCLE_INSERT_INT ("max_left_semantic_context", max_left_semantic_context);
+
+  free (rhs);
+  free (prhs);
+  free (rline);
+  free (r1);
+  free (r2);
+  free (dprec);
+  free (merger);
+}
+
+/*--------------------------------------------.
+| Prepare the muscles related to the states.  |
+`--------------------------------------------*/
+
+static void
+prepare_states (void)
+{
+  state_number i;
+  symbol_number *values = xnmalloc (nstates, sizeof *values);
+  for (i = 0; i < nstates; ++i)
+    values[i] = states[i]->accessing_symbol;
+  muscle_insert_symbol_number_table ("stos", values,
+				     0, 1, nstates);
+  free (values);
+
+  MUSCLE_INSERT_INT ("last", high);
+  MUSCLE_INSERT_INT ("final_state_number", final_state->number);
+  MUSCLE_INSERT_INT ("states_number", nstates);
+}
+
+
+
+/*---------------------------------.
+| Output the user actions to OUT.  |
+`---------------------------------*/
+
+static void
+user_actions_output (FILE *out)
+{
+  rule_number r;
+
+  fputs ("m4_define([b4_actions], \n[[", out);
+  for (r = 0; r < nrules; ++r)
+    if (rules[r].action)
+      {
+	fprintf (out, "  case %d:\n", r + 1);
+
+	fprintf (out, "]b4_syncline(%d, ",
+		 rules[r].action_location.start.line);
+	escaped_output (out, rules[r].action_location.start.file);
+	fprintf (out, ")[\n");
+	fprintf (out, "    %s\n    break;\n\n",
+		 rules[r].action);
+      }
+  fputs ("]])\n\n", out);
+}
+
+/*--------------------------------------.
+| Output the merge functions to OUT.   |
+`--------------------------------------*/
+
+static void
+merger_output (FILE *out)
+{
+  int n;
+  merger_list* p;
+
+  fputs ("m4_define([b4_mergers], \n[[", out);
+  for (n = 1, p = merge_functions; p != NULL; n += 1, p = p->next)
+    {
+      if (p->type[0] == '\0')
+	fprintf (out, "  case %d: *yy0 = %s (*yy0, *yy1); break;\n",
+		 n, p->name);
+      else
+	fprintf (out, "  case %d: yy0->%s = %s (*yy0, *yy1); break;\n",
+		 n, p->type, p->name);
+    }
+  fputs ("]])\n\n", out);
+}
+
+/*--------------------------------------.
+| Output the tokens definition to OUT.  |
+`--------------------------------------*/
+
+static void
+token_definitions_output (FILE *out)
+{
+  int i;
+  char const *sep = "";
+
+  fputs ("m4_define([b4_tokens], \n[", out);
+  for (i = 0; i < ntokens; ++i)
+    {
+      symbol *sym = symbols[i];
+      int number = sym->user_token_number;
+
+      /* At this stage, if there are literal aliases, they are part of
+	 SYMBOLS, so we should not find symbols which are the aliases
+	 here.  */
+      assert (number != USER_NUMBER_ALIAS);
+
+      /* Skip error token.  */
+      if (sym == errtoken)
+	continue;
+
+      /* If this string has an alias, then it is necessarily the alias
+	 which is to be output.  */
+      if (sym->alias)
+	sym = sym->alias;
+
+      /* Don't output literal chars or strings (when defined only as a
+	 string).  Note that must be done after the alias resolution:
+	 think about `%token 'f' "f"'.  */
+      if (sym->tag[0] == '\'' || sym->tag[0] == '\"')
+	continue;
+
+      /* Don't #define nonliteral tokens whose names contain periods
+	 or '$' (as does the default value of the EOF token).  */
+      if (strchr (sym->tag, '.') || strchr (sym->tag, '$'))
+	continue;
+
+      fprintf (out, "%s[[[%s]], %d]",
+	       sep, sym->tag, number);
+      sep = ",\n";
+    }
+  fputs ("])\n\n", out);
+}
+
+
+/*---------------------------------------.
+| Output the symbol destructors to OUT.  |
+`---------------------------------------*/
+
+static void
+symbol_destructors_output (FILE *out)
+{
+  int i;
+  char const *sep = "";
+
+  fputs ("m4_define([b4_symbol_destructors], \n[", out);
+  for (i = 0; i < nsyms; ++i)
+    if (symbols[i]->destructor)
+      {
+	symbol *sym = symbols[i];
+
+	/* Filename, lineno,
+	   Symbol-name, Symbol-number,
+	   destructor, optional typename.  */
+	fprintf (out, "%s[", sep);
+	sep = ",\n";
+	escaped_output (out, sym->destructor_location.start.file);
+	fprintf (out, ", %d, ", sym->destructor_location.start.line);
+	escaped_output (out, sym->tag);
+	fprintf (out, ", %d, [[%s]]", sym->number, sym->destructor);
+	if (sym->type_name)
+	  fprintf (out, ", [[%s]]", sym->type_name);
+	fputc (']', out);
+      }
+  fputs ("])\n\n", out);
+}
+
+
+/*------------------------------------.
+| Output the symbol printers to OUT.  |
+`------------------------------------*/
+
+static void
+symbol_printers_output (FILE *out)
+{
+  int i;
+  char const *sep = "";
+
+  fputs ("m4_define([b4_symbol_printers], \n[", out);
+  for (i = 0; i < nsyms; ++i)
+    if (symbols[i]->printer)
+      {
+	symbol *sym = symbols[i];
+
+	/* Filename, lineno,
+	   Symbol-name, Symbol-number,
+	   printer, optional typename.  */
+	fprintf (out, "%s[", sep);
+	sep = ",\n";
+	escaped_output (out, sym->printer_location.start.file);
+	fprintf (out, ", %d, ", sym->printer_location.start.line);
+	escaped_output (out, sym->tag);
+	fprintf (out, ", %d, [[%s]]", sym->number, sym->printer);
+	if (sym->type_name)
+	  fprintf (out, ", [[%s]]", sym->type_name);
+	fputc (']', out);
+      }
+  fputs ("])\n\n", out);
+}
+
+
+static void
+prepare_actions (void)
+{
+  /* Figure out the actions for the specified state, indexed by
+     look-ahead token type.  */
+
+  muscle_insert_rule_number_table ("defact", yydefact,
+				   yydefact[0], 1, nstates);
+
+  /* Figure out what to do after reducing with each rule, depending on
+     the saved state from before the beginning of parsing the data
+     that matched this rule.  */
+  muscle_insert_state_number_table ("defgoto", yydefgoto,
+				    yydefgoto[0], 1, nsyms - ntokens);
+
+
+  /* Output PACT. */
+  muscle_insert_base_table ("pact", base,
+			     base[0], 1, nstates);
+  MUSCLE_INSERT_INT ("pact_ninf", base_ninf);
+
+  /* Output PGOTO. */
+  muscle_insert_base_table ("pgoto", base,
+			     base[nstates], nstates + 1, nvectors);
+
+  muscle_insert_base_table ("table", table,
+			    table[0], 1, high + 1);
+  MUSCLE_INSERT_INT ("table_ninf", table_ninf);
+
+  muscle_insert_base_table ("check", check,
+			    check[0], 1, high + 1);
+
+  /* GLR parsing slightly modifies YYTABLE and YYCHECK (and thus
+     YYPACT) so that in states with unresolved conflicts, the default
+     reduction is not used in the conflicted entries, so that there is
+     a place to put a conflict pointer.
+
+     This means that YYCONFLP and YYCONFL are nonsense for a non-GLR
+     parser, so we could avoid accidents by not writing them out in
+     that case.  Nevertheless, it seems even better to be able to use
+     the GLR skeletons even without the non-deterministic tables.  */
+  muscle_insert_unsigned_int_table ("conflict_list_heads", conflict_table,
+				    conflict_table[0], 1, high + 1);
+  muscle_insert_unsigned_int_table ("conflicting_rules", conflict_list,
+				    0, 1, conflict_list_cnt);
+}
+
+
+/*---------------------------.
+| Call the skeleton parser.  |
+`---------------------------*/
+
+static void
+output_skeleton (void)
+{
+  FILE *in;
+  FILE *out;
+  int filter_fd[2];
+  char const *argv[6];
+  pid_t pid;
+
+  /* Compute the names of the package data dir and skeleton file.
+     Test whether m4sugar.m4 is readable, to check for proper
+     installation.  A faulty installation can cause deadlock, so a
+     cheap sanity check is worthwhile.  */
+  char const m4sugar[] = "m4sugar/m4sugar.m4";
+  char *full_m4sugar;
+  char *full_skeleton;
+  char const *p;
+  char const *m4 = (p = getenv ("M4")) ? p : M4;
+  char const *pkgdatadir = (p = getenv ("BISON_PKGDATADIR")) ? p : PKGDATADIR;
+  size_t skeleton_size = strlen (skeleton) + 1;
+  size_t pkgdatadirlen = strlen (pkgdatadir);
+  while (pkgdatadirlen && pkgdatadir[pkgdatadirlen - 1] == '/')
+    pkgdatadirlen--;
+  full_skeleton = xmalloc (pkgdatadirlen + 1
+			   + (skeleton_size < sizeof m4sugar
+			      ? sizeof m4sugar : skeleton_size));
+  strcpy (full_skeleton, pkgdatadir);
+  full_skeleton[pkgdatadirlen] = '/';
+  strcpy (full_skeleton + pkgdatadirlen + 1, m4sugar);
+  full_m4sugar = xstrdup (full_skeleton);
+  strcpy (full_skeleton + pkgdatadirlen + 1, skeleton);
+  xfclose (xfopen (full_m4sugar, "r"));
+
+  /* Create an m4 subprocess connected to us via two pipes.  */
+
+  if (trace_flag & trace_tools)
+    fprintf (stderr, "running: %s %s - %s\n",
+	     m4, full_m4sugar, full_skeleton);
+
+  argv[0] = m4;
+  argv[1] = full_m4sugar;
+  argv[2] = "-";
+  argv[3] = full_skeleton;
+  argv[4] = trace_flag & trace_m4 ? "-dV" : NULL;
+  argv[5] = NULL;
+
+  init_subpipe ();
+  pid = create_subpipe (argv, filter_fd);
+  free (full_m4sugar);
+  free (full_skeleton);
+
+  out = fdopen (filter_fd[0], "w");
+  if (! out)
+    error (EXIT_FAILURE, get_errno (),
+	   "fdopen");
+
+  /* Output the definitions of all the muscles.  */
+  fputs ("m4_init()\n", out);
+
+  user_actions_output (out);
+  merger_output (out);
+  token_definitions_output (out);
+  symbol_destructors_output (out);
+  symbol_printers_output (out);
+
+  muscles_m4_output (out);
+
+  fputs ("m4_wrap([m4_divert_pop(0)])\n", out);
+  fputs ("m4_divert_push(0)dnl\n", out);
+  xfclose (out);
+
+  /* Read and process m4's output.  */
+  timevar_push (TV_M4);
+  end_of_output_subpipe (pid, filter_fd);
+  in = fdopen (filter_fd[1], "r");
+  if (! in)
+    error (EXIT_FAILURE, get_errno (),
+	   "fdopen");
+  scan_skel (in);
+  xfclose (in);
+  reap_subpipe (pid, m4);
+  timevar_pop (TV_M4);
+}
+
+static void
+prepare (void)
+{
+  /* Flags. */
+  MUSCLE_INSERT_BOOL ("debug_flag", debug_flag);
+  MUSCLE_INSERT_BOOL ("defines_flag", defines_flag);
+  MUSCLE_INSERT_BOOL ("error_verbose_flag", error_verbose);
+  MUSCLE_INSERT_BOOL ("locations_flag", locations_flag);
+  MUSCLE_INSERT_BOOL ("pure_flag", pure_parser);
+  MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag);
+
+  /* File names.  */
+  MUSCLE_INSERT_STRING ("prefix", spec_name_prefix ? spec_name_prefix : "yy");
+#define DEFINE(Name) MUSCLE_INSERT_STRING (#Name, Name ? Name : "")
+  DEFINE (dir_prefix);
+  DEFINE (parser_file_name);
+  DEFINE (spec_defines_file);
+  DEFINE (spec_file_prefix);
+  DEFINE (spec_graph_file);
+  DEFINE (spec_name_prefix);
+  DEFINE (spec_outfile);
+  DEFINE (spec_verbose_file);
+#undef DEFINE
+
+  /* User Code.  */
+  obstack_1grow (&pre_prologue_obstack, 0);
+  obstack_1grow (&post_prologue_obstack, 0);
+  muscle_insert ("pre_prologue", obstack_finish (&pre_prologue_obstack));
+  muscle_insert ("post_prologue", obstack_finish (&post_prologue_obstack));
+
+  /* Find the right skeleton file.  */
+  if (!skeleton)
+    {
+      if (glr_parser || nondeterministic_parser)
+	skeleton = "glr.c";
+      else
+	skeleton = "yacc.c";
+    }
+
+  /* About the skeletons. */
+  {
+    char const *pkgdatadir = getenv ("BISON_PKGDATADIR");
+    MUSCLE_INSERT_STRING ("pkgdatadir", pkgdatadir ? pkgdatadir : PKGDATADIR);
+    MUSCLE_INSERT_C_STRING ("skeleton", skeleton);
+  }
+}
+
+
+/*----------------------------------------------------------.
+| Output the parsing tables and the parser code to ftable.  |
+`----------------------------------------------------------*/
+
+void
+output (void)
+{
+  obstack_init (&format_obstack);
+
+  prepare_symbols ();
+  prepare_rules ();
+  prepare_states ();
+  prepare_actions ();
+
+  prepare ();
+
+  /* Process the selected skeleton file.  */
+  output_skeleton ();
+
+  obstack_free (&format_obstack, NULL);
+  obstack_free (&pre_prologue_obstack, NULL);
+  obstack_free (&post_prologue_obstack, NULL);
+}
diff --git a/src/output.h b/src/output.h
new file mode 100644
index 0000000..784f227
--- /dev/null
+++ b/src/output.h
@@ -0,0 +1,27 @@
+/* Output the generated parsing program for bison,
+   Copyright (C) 2000, 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+
+#ifndef OUTPUT_H_
+# define OUTPUT_H_
+
+/* Output the parsing tables and the parser code to FTABLE.  */
+void output (void);
+
+#endif /* !OUTPUT_H_ */
diff --git a/src/parse-gram.c b/src/parse-gram.c
new file mode 100644
index 0000000..2b77f3e
--- /dev/null
+++ b/src/parse-gram.c
@@ -0,0 +1,2485 @@
+/* A Bison parser, made by GNU Bison 2.2a.  */
+
+/* Skeleton implementation for Bison's Yacc-like parsers in C
+
+   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+   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 2, 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, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+/* 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 yy or YY, 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 YYBISON 1
+
+/* Bison version.  */
+#define YYBISON_VERSION "2.2a"
+
+/* Skeleton name.  */
+#define YYSKELETON_NAME "yacc.c"
+
+/* Pure parsers.  */
+#define YYPURE 1
+
+/* Using locations.  */
+#define YYLSP_NEEDED 1
+
+/* Substitute the variable and function names.  */
+#define yyparse gram_parse
+#define yylex   gram_lex
+#define yyerror gram_error
+#define yylval  gram_lval
+#define yychar  gram_char
+#define yydebug gram_debug
+#define yynerrs gram_nerrs
+#define yylloc gram_lloc
+
+/* Tokens.  */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+   /* Put the tokens into the symbol table, so that GDB and other debuggers
+      know about them.  */
+   enum yytokentype {
+     GRAM_EOF = 0,
+     STRING = 258,
+     INT = 259,
+     PERCENT_TOKEN = 260,
+     PERCENT_NTERM = 261,
+     PERCENT_TYPE = 262,
+     PERCENT_DESTRUCTOR = 263,
+     PERCENT_PRINTER = 264,
+     PERCENT_UNION = 265,
+     PERCENT_LEFT = 266,
+     PERCENT_RIGHT = 267,
+     PERCENT_NONASSOC = 268,
+     PERCENT_PREC = 269,
+     PERCENT_DPREC = 270,
+     PERCENT_MERGE = 271,
+     PERCENT_DEBUG = 272,
+     PERCENT_DEFAULT_PREC = 273,
+     PERCENT_DEFINE = 274,
+     PERCENT_DEFINES = 275,
+     PERCENT_ERROR_VERBOSE = 276,
+     PERCENT_EXPECT = 277,
+     PERCENT_EXPECT_RR = 278,
+     PERCENT_FILE_PREFIX = 279,
+     PERCENT_GLR_PARSER = 280,
+     PERCENT_INITIAL_ACTION = 281,
+     PERCENT_LEX_PARAM = 282,
+     PERCENT_LOCATIONS = 283,
+     PERCENT_NAME_PREFIX = 284,
+     PERCENT_NO_DEFAULT_PREC = 285,
+     PERCENT_NO_LINES = 286,
+     PERCENT_NONDETERMINISTIC_PARSER = 287,
+     PERCENT_OUTPUT = 288,
+     PERCENT_PARSE_PARAM = 289,
+     PERCENT_PURE_PARSER = 290,
+     PERCENT_REQUIRE = 291,
+     PERCENT_SKELETON = 292,
+     PERCENT_START = 293,
+     PERCENT_TOKEN_TABLE = 294,
+     PERCENT_VERBOSE = 295,
+     PERCENT_YACC = 296,
+     TYPE = 297,
+     EQUAL = 298,
+     SEMICOLON = 299,
+     PIPE = 300,
+     ID = 301,
+     ID_COLON = 302,
+     PERCENT_PERCENT = 303,
+     PROLOGUE = 304,
+     EPILOGUE = 305,
+     BRACED_CODE = 306
+   };
+#endif
+/* Tokens.  */
+#define GRAM_EOF 0
+#define STRING 258
+#define INT 259
+#define PERCENT_TOKEN 260
+#define PERCENT_NTERM 261
+#define PERCENT_TYPE 262
+#define PERCENT_DESTRUCTOR 263
+#define PERCENT_PRINTER 264
+#define PERCENT_UNION 265
+#define PERCENT_LEFT 266
+#define PERCENT_RIGHT 267
+#define PERCENT_NONASSOC 268
+#define PERCENT_PREC 269
+#define PERCENT_DPREC 270
+#define PERCENT_MERGE 271
+#define PERCENT_DEBUG 272
+#define PERCENT_DEFAULT_PREC 273
+#define PERCENT_DEFINE 274
+#define PERCENT_DEFINES 275
+#define PERCENT_ERROR_VERBOSE 276
+#define PERCENT_EXPECT 277
+#define PERCENT_EXPECT_RR 278
+#define PERCENT_FILE_PREFIX 279
+#define PERCENT_GLR_PARSER 280
+#define PERCENT_INITIAL_ACTION 281
+#define PERCENT_LEX_PARAM 282
+#define PERCENT_LOCATIONS 283
+#define PERCENT_NAME_PREFIX 284
+#define PERCENT_NO_DEFAULT_PREC 285
+#define PERCENT_NO_LINES 286
+#define PERCENT_NONDETERMINISTIC_PARSER 287
+#define PERCENT_OUTPUT 288
+#define PERCENT_PARSE_PARAM 289
+#define PERCENT_PURE_PARSER 290
+#define PERCENT_REQUIRE 291
+#define PERCENT_SKELETON 292
+#define PERCENT_START 293
+#define PERCENT_TOKEN_TABLE 294
+#define PERCENT_VERBOSE 295
+#define PERCENT_YACC 296
+#define TYPE 297
+#define EQUAL 298
+#define SEMICOLON 299
+#define PIPE 300
+#define ID 301
+#define ID_COLON 302
+#define PERCENT_PERCENT 303
+#define PROLOGUE 304
+#define EPILOGUE 305
+#define BRACED_CODE 306
+
+
+
+
+/* Copy the first part of user declarations.  */
+#line 1 "parse-gram.y"
+/* Bison Grammar Parser                             -*- C -*-
+
+   Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   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 2 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, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301  USA
+*/
+
+#include <config.h>
+#include "system.h"
+
+#include "complain.h"
+#include "conflicts.h"
+#include "files.h"
+#include "getargs.h"
+#include "gram.h"
+#include "muscle_tab.h"
+#include "quotearg.h"
+#include "reader.h"
+#include "symlist.h"
+#include "strverscmp.h"
+
+#define YYLLOC_DEFAULT(Current, Rhs, N)  (Current) = lloc_default (Rhs, N)
+static YYLTYPE lloc_default (YYLTYPE const *, int);
+
+#define YY_LOCATION_PRINT(File, Loc) \
+	  location_print (File, Loc)
+
+static void version_check (location const *loc, char const *version);
+
+/* Request detailed syntax error messages, and pass them to GRAM_ERROR.
+   FIXME: depends on the undocumented availability of YYLLOC.  */
+#undef  yyerror
+#define yyerror(Msg) \
+	gram_error (&yylloc, Msg)
+static void gram_error (location const *, char const *);
+
+static void add_param (char const *, char *, location);
+
+static symbol_class current_class = unknown_sym;
+static uniqstr current_type = 0;
+static symbol *current_lhs;
+static location current_lhs_location;
+static int current_prec = 0;
+
+#ifdef UINT_FAST8_MAX
+# define YYTYPE_UINT8 uint_fast8_t
+#endif
+#ifdef INT_FAST8_MAX
+# define YYTYPE_INT8 int_fast8_t
+#endif
+#ifdef UINT_FAST16_MAX
+# define YYTYPE_UINT16 uint_fast16_t
+#endif
+#ifdef INT_FAST16_MAX
+# define YYTYPE_INT16 int_fast16_t
+#endif
+
+
+/* Enabling traces.  */
+#ifndef YYDEBUG
+# define YYDEBUG 1
+#endif
+
+/* Enabling verbose error messages.  */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 1
+#endif
+
+/* Enabling the token table.  */
+#ifndef YYTOKEN_TABLE
+# define YYTOKEN_TABLE 0
+#endif
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+#line 94 "parse-gram.y"
+{
+  symbol *symbol;
+  symbol_list *list;
+  int integer;
+  char *chars;
+  assoc assoc;
+  uniqstr uniqstr;
+}
+/* Line 193 of yacc.c.  */
+#line 290 "parse-gram.c"
+	YYSTYPE;
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+# define YYSTYPE_IS_TRIVIAL 1
+#endif
+
+#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
+typedef struct YYLTYPE
+{
+  int first_line;
+  int first_column;
+  int last_line;
+  int last_column;
+} YYLTYPE;
+# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
+# define YYLTYPE_IS_DECLARED 1
+# define YYLTYPE_IS_TRIVIAL 1
+#endif
+
+
+/* Copy the second part of user declarations.  */
+
+
+/* Line 216 of yacc.c.  */
+#line 315 "parse-gram.c"
+
+#ifdef short
+# undef short
+#endif
+
+#ifdef YYTYPE_UINT8
+typedef YYTYPE_UINT8 yytype_uint8;
+#else
+typedef unsigned char yytype_uint8;
+#endif
+
+#ifdef YYTYPE_INT8
+typedef YYTYPE_INT8 yytype_int8;
+#elif (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+typedef signed char yytype_int8;
+#else
+typedef short int yytype_int8;
+#endif
+
+#ifdef YYTYPE_UINT16
+typedef YYTYPE_UINT16 yytype_uint16;
+#else
+typedef unsigned short int yytype_uint16;
+#endif
+
+#ifdef YYTYPE_INT16
+typedef YYTYPE_INT16 yytype_int16;
+#else
+typedef short int yytype_int16;
+#endif
+
+#ifndef YYSIZE_T
+# ifdef __SIZE_TYPE__
+#  define YYSIZE_T __SIZE_TYPE__
+# elif defined size_t
+#  define YYSIZE_T size_t
+# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+#  define YYSIZE_T size_t
+# else
+#  define YYSIZE_T unsigned int
+# endif
+#endif
+
+#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
+
+#ifndef YY_
+# if YYENABLE_NLS
+#  if ENABLE_NLS
+#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
+#   define YY_(msgid) dgettext ("bison-runtime", msgid)
+#  endif
+# endif
+# ifndef YY_
+#  define YY_(msgid) msgid
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E.  */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(e) ((void) (e))
+#else
+# define YYUSE(e) /* empty */
+#endif
+
+/* Identity function, used to suppress warnings about constant conditions.  */
+#ifndef lint
+# define YYID(n) (n)
+#else
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static int
+YYID (int i)
+#else
+static int
+YYID (i)
+    int i;
+#endif
+{
+  return i;
+}
+#endif
+
+#if ! defined yyoverflow || YYERROR_VERBOSE
+
+/* The parser invokes alloca or malloc; define the necessary symbols.  */
+
+# ifdef YYSTACK_USE_ALLOCA
+#  if YYSTACK_USE_ALLOCA
+#   ifdef __GNUC__
+#    define YYSTACK_ALLOC __builtin_alloca
+#   elif defined __BUILTIN_VA_ARG_INCR
+#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
+#   elif defined _AIX
+#    define YYSTACK_ALLOC __alloca
+#   elif defined _MSC_VER
+#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
+#    define alloca _alloca
+#   else
+#    define YYSTACK_ALLOC alloca
+#    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+#     ifndef _STDLIB_H
+#      define _STDLIB_H 1
+#     endif
+#    endif
+#   endif
+#  endif
+# endif
+
+# ifdef YYSTACK_ALLOC
+   /* Pacify GCC's `empty if-body' warning.  */
+#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
+#  ifndef YYSTACK_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 YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
+#  endif
+# else
+#  define YYSTACK_ALLOC YYMALLOC
+#  define YYSTACK_FREE YYFREE
+#  ifndef YYSTACK_ALLOC_MAXIMUM
+#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
+#  endif
+#  if (defined __cplusplus && ! defined _STDLIB_H \
+       && ! ((defined YYMALLOC || defined malloc) \
+	     && (defined YYFREE || defined free)))
+#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+#   ifndef _STDLIB_H
+#    define _STDLIB_H 1
+#   endif
+#  endif
+#  ifndef YYMALLOC
+#   define YYMALLOC malloc
+#   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+#   endif
+#  endif
+#  ifndef YYFREE
+#   define YYFREE free
+#   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+#   endif
+#  endif
+# endif
+#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
+
+
+#if (! defined yyoverflow \
+     && (! defined __cplusplus \
+	 || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
+	     && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member.  */
+union yyalloc
+{
+  yytype_int16 yyss;
+  YYSTYPE yyvs;
+    YYLTYPE yyls;
+};
+
+/* The size of the maximum gap between one aligned stack and the next.  */
+# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+   N elements.  */
+# define YYSTACK_BYTES(N) \
+     ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
+      + 2 * YYSTACK_GAP_MAXIMUM)
+
+/* Copy COUNT objects from FROM to TO.  The source and destination do
+   not overlap.  */
+# ifndef YYCOPY
+#  if defined __GNUC__ && 1 < __GNUC__
+#   define YYCOPY(To, From, Count) \
+      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+#  else
+#   define YYCOPY(To, From, Count)		\
+      do					\
+	{					\
+	  YYSIZE_T yyi;				\
+	  for (yyi = 0; yyi < (Count); yyi++)	\
+	    (To)[yyi] = (From)[yyi];		\
+	}					\
+      while (YYID (0))
+#  endif
+# endif
+
+/* Relocate STACK from its old location to the new one.  The
+   local variables YYSIZE and YYSTACKSIZE give the old and new number of
+   elements in the stack, and YYPTR gives the new location of the
+   stack.  Advance YYPTR to a properly aligned location for the next
+   stack.  */
+# define YYSTACK_RELOCATE(Stack)					\
+    do									\
+      {									\
+	YYSIZE_T yynewbytes;						\
+	YYCOPY (&yyptr->Stack, Stack, yysize);				\
+	Stack = &yyptr->Stack;						\
+	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+	yyptr += yynewbytes / sizeof (*yyptr);				\
+      }									\
+    while (YYID (0))
+
+#endif
+
+/* YYFINAL -- State number of the termination state.  */
+#define YYFINAL  3
+/* YYLAST -- Last index in YYTABLE.  */
+#define YYLAST   161
+
+/* YYNTOKENS -- Number of terminals.  */
+#define YYNTOKENS  52
+/* YYNNTS -- Number of nonterminals.  */
+#define YYNNTS  26
+/* YYNRULES -- Number of rules.  */
+#define YYNRULES  82
+/* YYNRULES -- Number of states.  */
+#define YYNSTATES  111
+
+/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
+#define YYUNDEFTOK  2
+#define YYMAXUTOK   306
+
+#define YYTRANSLATE(YYX)						\
+  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+
+/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
+static const yytype_uint8 yytranslate[] =
+{
+       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,
+       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,     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,    26,    27,    28,    29,    30,    31,    32,    33,    34,
+      35,    36,    37,    38,    39,    40,    41,    42,    43,    44,
+      45,    46,    47,    48,    49,    50,    51
+};
+
+#if YYDEBUG
+/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+   YYRHS.  */
+static const yytype_uint8 yyprhs[] =
+{
+       0,     0,     3,     8,     9,    12,    14,    16,    18,    21,
+      25,    27,    29,    32,    35,    39,    41,    43,    45,    47,
+      51,    53,    55,    59,    61,    63,    66,    69,    71,    73,
+      75,    77,    79,    81,    84,    86,    89,    92,    94,    96,
+      97,   101,   102,   106,   110,   114,   116,   118,   120,   121,
+     123,   125,   128,   130,   132,   135,   138,   142,   144,   147,
+     149,   152,   154,   157,   160,   161,   165,   167,   171,   174,
+     175,   178,   181,   185,   189,   193,   195,   197,   198,   201,
+     203,   205,   206
+};
+
+/* YYRHS -- A `-1'-separated list of the rules' RHS.  */
+static const yytype_int8 yyrhs[] =
+{
+      53,     0,    -1,    54,    48,    66,    77,    -1,    -1,    54,
+      55,    -1,    56,    -1,    49,    -1,    17,    -1,    19,    76,
+      -1,    19,    76,    76,    -1,    20,    -1,    21,    -1,    22,
+       4,    -1,    23,     4,    -1,    24,    43,    76,    -1,    25,
+      -1,    26,    -1,    27,    -1,    28,    -1,    29,    43,    76,
+      -1,    31,    -1,    32,    -1,    33,    43,    76,    -1,    34,
+      -1,    35,    -1,    36,    76,    -1,    37,    76,    -1,    39,
+      -1,    40,    -1,    41,    -1,    44,    -1,    60,    -1,    57,
+      -1,    38,    72,    -1,    10,    -1,     8,    63,    -1,     9,
+      63,    -1,    18,    -1,    30,    -1,    -1,     6,    58,    65,
+      -1,    -1,     5,    59,    65,    -1,     7,    42,    63,    -1,
+      61,    62,    63,    -1,    11,    -1,    12,    -1,    13,    -1,
+      -1,    42,    -1,    72,    -1,    63,    72,    -1,    42,    -1,
+      46,    -1,    46,     4,    -1,    46,    75,    -1,    46,     4,
+      75,    -1,    64,    -1,    65,    64,    -1,    67,    -1,    66,
+      67,    -1,    68,    -1,    56,    44,    -1,     1,    44,    -1,
+      -1,    47,    69,    70,    -1,    71,    -1,    70,    45,    71,
+      -1,    70,    44,    -1,    -1,    71,    72,    -1,    71,    73,
+      -1,    71,    14,    72,    -1,    71,    15,     4,    -1,    71,
+      16,    42,    -1,    46,    -1,    75,    -1,    -1,    74,    51,
+      -1,     3,    -1,     3,    -1,    -1,    48,    50,    -1
+};
+
+/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
+static const yytype_uint16 yyrline[] =
+{
+       0,   202,   202,   210,   212,   216,   217,   218,   219,   224,
+     225,   226,   227,   228,   229,   230,   235,   239,   240,   241,
+     242,   243,   244,   245,   246,   247,   248,   249,   250,   251,
+     252,   256,   257,   258,   262,   278,   285,   292,   296,   303,
+     303,   308,   308,   313,   323,   338,   339,   340,   344,   345,
+     351,   352,   357,   361,   366,   372,   378,   389,   390,   399,
+     400,   406,   407,   408,   415,   415,   419,   420,   421,   426,
+     427,   429,   430,   432,   434,   439,   440,   456,   456,   462,
+     471,   476,   478
+};
+#endif
+
+#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
+static const char *const yytname[] =
+{
+  "\"end of file\"", "error", "$undefined", "\"string\"", "\"integer\"",
+  "\"%token\"", "\"%nterm\"", "\"%type\"", "\"%destructor {...}\"",
+  "\"%printer {...}\"", "\"%union {...}\"", "\"%left\"", "\"%right\"",
+  "\"%nonassoc\"", "\"%prec\"", "\"%dprec\"", "\"%merge\"", "\"%debug\"",
+  "\"%default-prec\"", "\"%define\"", "\"%defines\"", "\"%error-verbose\"",
+  "\"%expect\"", "\"%expect-rr\"", "\"%file-prefix\"", "\"%glr-parser\"",
+  "\"%initial-action {...}\"", "\"%lex-param {...}\"", "\"%locations\"",
+  "\"%name-prefix\"", "\"%no-default-prec\"", "\"%no-lines\"",
+  "\"%nondeterministic-parser\"", "\"%output\"", "\"%parse-param {...}\"",
+  "\"%pure-parser\"", "\"%require\"", "\"%skeleton\"", "\"%start\"",
+  "\"%token-table\"", "\"%verbose\"", "\"%yacc\"", "\"type\"", "\"=\"",
+  "\";\"", "\"|\"", "\"identifier\"", "\"identifier:\"", "\"%%\"",
+  "\"%{...%}\"", "\"epilogue\"", "\"{...}\"", "$accept", "input",
+  "declarations", "declaration", "grammar_declaration",
+  "symbol_declaration", "@1", "@2", "precedence_declaration",
+  "precedence_declarator", "type.opt", "symbols.1", "symbol_def",
+  "symbol_defs.1", "grammar", "rules_or_grammar_declaration", "rules",
+  "@3", "rhses.1", "rhs", "symbol", "action", "@4", "string_as_id",
+  "string_content", "epilogue.opt", 0
+};
+#endif
+
+# ifdef YYPRINT
+/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
+   token YYLEX-NUM.  */
+static const yytype_uint16 yytoknum[] =
+{
+       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,   281,   282,   283,   284,
+     285,   286,   287,   288,   289,   290,   291,   292,   293,   294,
+     295,   296,   297,   298,   299,   300,   301,   302,   303,   304,
+     305,   306
+};
+# endif
+
+/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
+static const yytype_uint8 yyr1[] =
+{
+       0,    52,    53,    54,    54,    55,    55,    55,    55,    55,
+      55,    55,    55,    55,    55,    55,    55,    55,    55,    55,
+      55,    55,    55,    55,    55,    55,    55,    55,    55,    55,
+      55,    56,    56,    56,    56,    56,    56,    56,    56,    58,
+      57,    59,    57,    57,    60,    61,    61,    61,    62,    62,
+      63,    63,    64,    64,    64,    64,    64,    65,    65,    66,
+      66,    67,    67,    67,    69,    68,    70,    70,    70,    71,
+      71,    71,    71,    71,    71,    72,    72,    74,    73,    75,
+      76,    77,    77
+};
+
+/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
+static const yytype_uint8 yyr2[] =
+{
+       0,     2,     4,     0,     2,     1,     1,     1,     2,     3,
+       1,     1,     2,     2,     3,     1,     1,     1,     1,     3,
+       1,     1,     3,     1,     1,     2,     2,     1,     1,     1,
+       1,     1,     1,     2,     1,     2,     2,     1,     1,     0,
+       3,     0,     3,     3,     3,     1,     1,     1,     0,     1,
+       1,     2,     1,     1,     2,     2,     3,     1,     2,     1,
+       2,     1,     2,     2,     0,     3,     1,     3,     2,     0,
+       2,     2,     3,     3,     3,     1,     1,     0,     2,     1,
+       1,     0,     2
+};
+
+/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
+   STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
+   means the default is an error.  */
+static const yytype_uint8 yydefact[] =
+{
+       3,     0,     0,     1,    41,    39,     0,     0,     0,    34,
+      45,    46,    47,     7,    37,     0,    10,    11,     0,     0,
+       0,    15,    16,    17,    18,     0,    38,    20,    21,     0,
+      23,    24,     0,     0,     0,    27,    28,    29,    30,     0,
+       6,     4,     5,    32,    31,    48,     0,     0,     0,    79,
+      75,    35,    50,    76,    36,    80,     8,    12,    13,     0,
+       0,     0,    25,    26,    33,     0,    64,     0,     0,    59,
+      61,    49,     0,    52,    53,    57,    42,    40,    43,    51,
+       9,    14,    19,    22,    63,    69,    62,     0,    60,     2,
+      44,    54,    55,    58,    65,    66,    82,    56,    68,    69,
+       0,     0,     0,    70,    71,     0,    67,    72,    73,    74,
+      78
+};
+
+/* YYDEFGOTO[NTERM-NUM].  */
+static const yytype_int8 yydefgoto[] =
+{
+      -1,     1,     2,    41,    67,    43,    47,    46,    44,    45,
+      72,    51,    75,    76,    68,    69,    70,    85,    94,    95,
+      52,   104,   105,    53,    56,    89
+};
+
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+   STATE-NUM.  */
+#define YYPACT_NINF -69
+static const yytype_int8 yypact[] =
+{
+     -69,     5,   112,   -69,   -69,   -69,   -35,     0,     0,   -69,
+     -69,   -69,   -69,   -69,   -69,    13,   -69,   -69,    20,    31,
+     -18,   -69,   -69,   -69,   -69,    -6,   -69,   -69,   -69,    -5,
+     -69,   -69,    13,    13,     0,   -69,   -69,   -69,   -69,    69,
+     -69,   -69,   -69,   -69,   -69,    -2,   -38,   -38,     0,   -69,
+     -69,     0,   -69,   -69,     0,   -69,    13,   -69,   -69,    13,
+      13,    13,   -69,   -69,   -69,    -8,   -69,     3,    21,   -69,
+     -69,   -69,     0,   -69,     6,   -69,   -38,   -38,     0,   -69,
+     -69,   -69,   -69,   -69,   -69,   -69,   -69,     2,   -69,   -69,
+       0,    39,   -69,   -69,   -33,    -1,   -69,   -69,   -69,   -69,
+       0,    44,     1,   -69,   -69,     4,    -1,   -69,   -69,   -69,
+     -69
+};
+
+/* YYPGOTO[NTERM-NUM].  */
+static const yytype_int8 yypgoto[] =
+{
+     -69,   -69,   -69,   -69,    47,   -69,   -69,   -69,   -69,   -69,
+     -69,    -7,   -58,     7,   -69,   -15,   -69,   -69,   -69,   -42,
+     -34,   -69,   -69,   -68,    30,   -69
+};
+
+/* YYTABLE[YYPACT[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 zero, do what YYDEFACT says.
+   If YYTABLE_NINF, syntax error.  */
+#define YYTABLE_NINF -82
+static const yytype_int8 yytable[] =
+{
+      64,    54,    49,    49,    73,     3,    92,    48,    74,    49,
+      91,    98,    99,   100,   101,   102,    55,    79,    93,    93,
+      79,   -81,    65,    97,    57,    59,     4,     5,     6,     7,
+       8,     9,    10,    11,    12,    58,    84,    60,    61,    14,
+      71,    78,    49,   109,    79,    50,    50,    86,   108,    42,
+     -77,    26,    96,    88,    77,   110,    79,   106,     0,    34,
+       0,   103,    62,    63,     0,    90,   107,     0,    66,    87,
+      65,     0,   103,     0,     4,     5,     6,     7,     8,     9,
+      10,    11,    12,     0,     0,     0,    80,    14,     0,    81,
+      82,    83,     0,     0,     0,     0,     0,     0,     0,    26,
+       0,     0,     0,     0,     0,     0,     0,    34,     0,     0,
+       0,     0,     0,     0,     0,     0,    66,     4,     5,     6,
+       7,     8,     9,    10,    11,    12,     0,     0,     0,    13,
+      14,    15,    16,    17,    18,    19,    20,    21,    22,    23,
+      24,    25,    26,    27,    28,    29,    30,    31,    32,    33,
+      34,    35,    36,    37,     0,     0,    38,     0,     0,     0,
+      39,    40
+};
+
+static const yytype_int8 yycheck[] =
+{
+      34,     8,     3,     3,    42,     0,    74,    42,    46,     3,
+       4,    44,    45,    14,    15,    16,     3,    51,    76,    77,
+      54,     0,     1,    91,     4,    43,     5,     6,     7,     8,
+       9,    10,    11,    12,    13,     4,    44,    43,    43,    18,
+      42,    48,     3,    42,    78,    46,    46,    44,     4,     2,
+      51,    30,    50,    68,    47,    51,    90,    99,    -1,    38,
+      -1,    95,    32,    33,    -1,    72,   100,    -1,    47,    48,
+       1,    -1,   106,    -1,     5,     6,     7,     8,     9,    10,
+      11,    12,    13,    -1,    -1,    -1,    56,    18,    -1,    59,
+      60,    61,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    30,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    38,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    47,     5,     6,     7,
+       8,     9,    10,    11,    12,    13,    -1,    -1,    -1,    17,
+      18,    19,    20,    21,    22,    23,    24,    25,    26,    27,
+      28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
+      38,    39,    40,    41,    -1,    -1,    44,    -1,    -1,    -1,
+      48,    49
+};
+
+/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+   symbol of state STATE-NUM.  */
+static const yytype_uint8 yystos[] =
+{
+       0,    53,    54,     0,     5,     6,     7,     8,     9,    10,
+      11,    12,    13,    17,    18,    19,    20,    21,    22,    23,
+      24,    25,    26,    27,    28,    29,    30,    31,    32,    33,
+      34,    35,    36,    37,    38,    39,    40,    41,    44,    48,
+      49,    55,    56,    57,    60,    61,    59,    58,    42,     3,
+      46,    63,    72,    75,    63,     3,    76,     4,     4,    43,
+      43,    43,    76,    76,    72,     1,    47,    56,    66,    67,
+      68,    42,    62,    42,    46,    64,    65,    65,    63,    72,
+      76,    76,    76,    76,    44,    69,    44,    48,    67,    77,
+      63,     4,    75,    64,    70,    71,    50,    75,    44,    45,
+      14,    15,    16,    72,    73,    74,    71,    72,     4,    42,
+      51
+};
+
+#define yyerrok		(yyerrstatus = 0)
+#define yyclearin	(yychar = YYEMPTY)
+#define YYEMPTY		(-2)
+#define YYEOF		0
+
+#define YYACCEPT	goto yyacceptlab
+#define YYABORT		goto yyabortlab
+#define YYERROR		goto yyerrorlab
+
+
+/* Like YYERROR except do call yyerror.  This remains here temporarily
+   to ease the transition to the new meaning of YYERROR, for GCC.
+   Once GCC version 2 has supplanted version 1, this can go.  */
+
+#define YYFAIL		goto yyerrlab
+
+#define YYRECOVERING()  (!!yyerrstatus)
+
+#define YYBACKUP(Token, Value)					\
+do								\
+  if (yychar == YYEMPTY && yylen == 1)				\
+    {								\
+      yychar = (Token);						\
+      yylval = (Value);						\
+      yytoken = YYTRANSLATE (yychar);				\
+      YYPOPSTACK (1);						\
+      goto yybackup;						\
+    }								\
+  else								\
+    {								\
+      yyerror (YY_("syntax error: cannot back up")); \
+      YYERROR;							\
+    }								\
+while (YYID (0))
+
+
+#define YYTERROR	1
+#define YYERRCODE	256
+
+
+/* YYLLOC_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 YYRHSLOC(Rhs, K) ((Rhs)[K])
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N)				\
+    do									\
+      if (YYID (N))                                                    \
+	{								\
+	  (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;	\
+	  (Current).first_column = YYRHSLOC (Rhs, 1).first_column;	\
+	  (Current).last_line    = YYRHSLOC (Rhs, N).last_line;		\
+	  (Current).last_column  = YYRHSLOC (Rhs, N).last_column;	\
+	}								\
+      else								\
+	{								\
+	  (Current).first_line   = (Current).last_line   =		\
+	    YYRHSLOC (Rhs, 0).last_line;				\
+	  (Current).first_column = (Current).last_column =		\
+	    YYRHSLOC (Rhs, 0).last_column;				\
+	}								\
+    while (YYID (0))
+#endif
+
+
+/* YY_LOCATION_PRINT -- Print the location on the stream.
+   This macro was not mandated originally: define only if we know
+   we won't break user code: when these are the locations we know.  */
+
+#ifndef YY_LOCATION_PRINT
+# if YYLTYPE_IS_TRIVIAL
+#  define YY_LOCATION_PRINT(File, Loc)			\
+     fprintf (File, "%d.%d-%d.%d",			\
+	      (Loc).first_line, (Loc).first_column,	\
+	      (Loc).last_line,  (Loc).last_column)
+# else
+#  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+# endif
+#endif
+
+
+/* YYLEX -- calling `yylex' with the right arguments.  */
+
+#ifdef YYLEX_PARAM
+# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
+#else
+# define YYLEX yylex (&yylval, &yylloc)
+#endif
+
+/* Enable debugging if requested.  */
+#if YYDEBUG
+
+# ifndef YYFPRINTF
+#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
+#  define YYFPRINTF fprintf
+# endif
+
+# define YYDPRINTF(Args)			\
+do {						\
+  if (yydebug)					\
+    YYFPRINTF Args;				\
+} while (YYID (0))
+
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)			  \
+do {									  \
+  if (yydebug)								  \
+    {									  \
+      YYFPRINTF (stderr, "%s ", Title);					  \
+      yy_symbol_print (stderr,						  \
+		  Type, Value, Location); \
+      YYFPRINTF (stderr, "\n");						  \
+    }									  \
+} while (YYID (0))
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT.  |
+`--------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
+#else
+static void
+yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp)
+    FILE *yyoutput;
+    int yytype;
+    YYSTYPE const * const yyvaluep;
+    YYLTYPE const * const yylocationp;
+#endif
+{
+  if (!yyvaluep)
+    return;
+  YYUSE (yylocationp);
+# ifdef YYPRINT
+  if (yytype < YYNTOKENS)
+    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+# else
+  YYUSE (yyoutput);
+# endif
+  switch (yytype)
+    {
+      case 3: /* "\"string\"" */
+#line 179 "parse-gram.y"
+	{ fprintf (stderr, "\"%s\"", (yyvaluep->chars)); };
+#line 979 "parse-gram.c"
+	break;
+      case 4: /* "\"integer\"" */
+#line 192 "parse-gram.y"
+	{ fprintf (stderr, "%d", (yyvaluep->integer)); };
+#line 984 "parse-gram.c"
+	break;
+      case 8: /* "\"%destructor {...}\"" */
+#line 181 "parse-gram.y"
+	{ fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); };
+#line 989 "parse-gram.c"
+	break;
+      case 9: /* "\"%printer {...}\"" */
+#line 181 "parse-gram.y"
+	{ fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); };
+#line 994 "parse-gram.c"
+	break;
+      case 10: /* "\"%union {...}\"" */
+#line 181 "parse-gram.y"
+	{ fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); };
+#line 999 "parse-gram.c"
+	break;
+      case 26: /* "\"%initial-action {...}\"" */
+#line 181 "parse-gram.y"
+	{ fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); };
+#line 1004 "parse-gram.c"
+	break;
+      case 27: /* "\"%lex-param {...}\"" */
+#line 181 "parse-gram.y"
+	{ fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); };
+#line 1009 "parse-gram.c"
+	break;
+      case 34: /* "\"%parse-param {...}\"" */
+#line 181 "parse-gram.y"
+	{ fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); };
+#line 1014 "parse-gram.c"
+	break;
+      case 42: /* "\"type\"" */
+#line 190 "parse-gram.y"
+	{ fprintf (stderr, "<%s>", (yyvaluep->uniqstr)); };
+#line 1019 "parse-gram.c"
+	break;
+      case 46: /* "\"identifier\"" */
+#line 194 "parse-gram.y"
+	{ fprintf (stderr, "%s", (yyvaluep->symbol)->tag); };
+#line 1024 "parse-gram.c"
+	break;
+      case 47: /* "\"identifier:\"" */
+#line 196 "parse-gram.y"
+	{ fprintf (stderr, "%s:", (yyvaluep->symbol)->tag); };
+#line 1029 "parse-gram.c"
+	break;
+      case 49: /* "\"%{...%}\"" */
+#line 181 "parse-gram.y"
+	{ fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); };
+#line 1034 "parse-gram.c"
+	break;
+      case 50: /* "\"epilogue\"" */
+#line 181 "parse-gram.y"
+	{ fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); };
+#line 1039 "parse-gram.c"
+	break;
+      case 72: /* "symbol" */
+#line 194 "parse-gram.y"
+	{ fprintf (stderr, "%s", (yyvaluep->symbol)->tag); };
+#line 1044 "parse-gram.c"
+	break;
+      case 75: /* "string_as_id" */
+#line 194 "parse-gram.y"
+	{ fprintf (stderr, "%s", (yyvaluep->symbol)->tag); };
+#line 1049 "parse-gram.c"
+	break;
+      case 76: /* "string_content" */
+#line 179 "parse-gram.y"
+	{ fprintf (stderr, "\"%s\"", (yyvaluep->chars)); };
+#line 1054 "parse-gram.c"
+	break;
+      default:
+	break;
+    }
+}
+
+
+/*--------------------------------.
+| Print this symbol on YYOUTPUT.  |
+`--------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static void
+yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
+#else
+static void
+yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp)
+    FILE *yyoutput;
+    int yytype;
+    YYSTYPE const * const yyvaluep;
+    YYLTYPE const * const yylocationp;
+#endif
+{
+  if (yytype < YYNTOKENS)
+    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
+  else
+    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
+
+  YY_LOCATION_PRINT (yyoutput, *yylocationp);
+  YYFPRINTF (yyoutput, ": ");
+  yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp);
+  YYFPRINTF (yyoutput, ")");
+}
+
+/*------------------------------------------------------------------.
+| yy_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
+yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
+#else
+static void
+yy_stack_print (bottom, top)
+    yytype_int16 *bottom;
+    yytype_int16 *top;
+#endif
+{
+  YYFPRINTF (stderr, "Stack now");
+  for (; bottom <= top; ++bottom)
+    YYFPRINTF (stderr, " %d", *bottom);
+  YYFPRINTF (stderr, "\n");
+}
+
+# define YY_STACK_PRINT(Bottom, Top)				\
+do {								\
+  if (yydebug)							\
+    yy_stack_print ((Bottom), (Top));				\
+} while (YYID (0))
+
+
+/*------------------------------------------------.
+| Report that the YYRULE is going to be reduced.  |
+`------------------------------------------------*/
+
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static void
+yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule)
+#else
+static void
+yy_reduce_print (yyvsp, yylsp, yyrule)
+    YYSTYPE *yyvsp;
+    YYLTYPE *yylsp;
+    int yyrule;
+#endif
+{
+  int yynrhs = yyr2[yyrule];
+  int yyi;
+  unsigned long int yylno = yyrline[yyrule];
+  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
+	     yyrule - 1, yylno);
+  /* The symbols being reduced.  */
+  for (yyi = 0; yyi < yynrhs; yyi++)
+    {
+      fprintf (stderr, "   $%d = ", yyi + 1);
+      yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
+		       &(yyvsp[(yyi + 1) - (yynrhs)])
+		       , &(yylsp[(yyi + 1) - (yynrhs)])		       );
+      fprintf (stderr, "\n");
+    }
+}
+
+# define YY_REDUCE_PRINT(Rule)		\
+do {					\
+  if (yydebug)				\
+    yy_reduce_print (yyvsp, yylsp, Rule); \
+} while (YYID (0))
+
+/* Nonzero means print parse trace.  It is left uninitialized so that
+   multiple parsers can coexist.  */
+int yydebug;
+#else /* !YYDEBUG */
+# define YYDPRINTF(Args)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
+# define YY_STACK_PRINT(Bottom, Top)
+# define YY_REDUCE_PRINT(Rule)
+#endif /* !YYDEBUG */
+
+
+/* YYINITDEPTH -- initial size of the parser's stacks.  */
+#ifndef	YYINITDEPTH
+# define YYINITDEPTH 200
+#endif
+
+/* YYMAXDEPTH -- 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
+   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
+   evaluated with infinite-precision integer arithmetic.  */
+
+#ifndef YYMAXDEPTH
+# define YYMAXDEPTH 10000
+#endif
+
+
+
+#if YYERROR_VERBOSE
+
+# ifndef yystrlen
+#  if defined __GLIBC__ && defined _STRING_H
+#   define yystrlen strlen
+#  else
+/* Return the length of YYSTR.  */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static YYSIZE_T
+yystrlen (const char *yystr)
+#else
+static YYSIZE_T
+yystrlen (yystr)
+    const char *yystr;
+#endif
+{
+  YYSIZE_T yylen;
+  for (yylen = 0; yystr[yylen]; yylen++)
+    continue;
+  return yylen;
+}
+#  endif
+# endif
+
+# ifndef yystpcpy
+#  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
+#   define yystpcpy stpcpy
+#  else
+/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
+   YYDEST.  */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static char *
+yystpcpy (char *yydest, const char *yysrc)
+#else
+static char *
+yystpcpy (yydest, yysrc)
+    char *yydest;
+    const char *yysrc;
+#endif
+{
+  char *yyd = yydest;
+  const char *yys = yysrc;
+
+  while ((*yyd++ = *yys++) != '\0')
+    continue;
+
+  return yyd - 1;
+}
+#  endif
+# endif
+
+# ifndef yytnamerr
+/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
+   quotes and backslashes, so that it's suitable for yyerror.  The
+   heuristic is that double-quoting is unnecessary unless the string
+   contains an apostrophe, a comma, or backslash (other than
+   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
+   null, do not copy; instead, return the length of what the result
+   would have been.  */
+static YYSIZE_T
+yytnamerr (char *yyres, const char *yystr)
+{
+  if (*yystr == '"')
+    {
+      YYSIZE_T yyn = 0;
+      char const *yyp = yystr;
+
+      for (;;)
+	switch (*++yyp)
+	  {
+	  case '\'':
+	  case ',':
+	    goto do_not_strip_quotes;
+
+	  case '\\':
+	    if (*++yyp != '\\')
+	      goto do_not_strip_quotes;
+	    /* Fall through.  */
+	  default:
+	    if (yyres)
+	      yyres[yyn] = *yyp;
+	    yyn++;
+	    break;
+
+	  case '"':
+	    if (yyres)
+	      yyres[yyn] = '\0';
+	    return yyn;
+	  }
+    do_not_strip_quotes: ;
+    }
+
+  if (! yyres)
+    return yystrlen (yystr);
+
+  return yystpcpy (yyres, yystr) - yyres;
+}
+# endif
+
+/* Copy into YYRESULT an error message about the unexpected token
+   YYCHAR while in state YYSTATE.  Return the number of bytes copied,
+   including the terminating null byte.  If YYRESULT is null, do not
+   copy anything; just return the number of bytes that would be
+   copied.  As a special case, return 0 if an ordinary "syntax error"
+   message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
+   size calculation.  */
+static YYSIZE_T
+yysyntax_error (char *yyresult, int yystate, int yychar)
+{
+  int yyn = yypact[yystate];
+
+  if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
+    return 0;
+  else
+    {
+      int yytype = YYTRANSLATE (yychar);
+      YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
+      YYSIZE_T yysize = yysize0;
+      YYSIZE_T yysize1;
+      int yysize_overflow = 0;
+      enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
+      char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
+      int yyx;
+
+# if 0
+      /* This is so xgettext sees the translatable formats that are
+	 constructed on the fly.  */
+      YY_("syntax error, unexpected %s");
+      YY_("syntax error, unexpected %s, expecting %s");
+      YY_("syntax error, unexpected %s, expecting %s or %s");
+      YY_("syntax error, unexpected %s, expecting %s or %s or %s");
+      YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
+# endif
+      char *yyfmt;
+      char const *yyf;
+      static char const yyunexpected[] = "syntax error, unexpected %s";
+      static char const yyexpecting[] = ", expecting %s";
+      static char const yyor[] = " or %s";
+      char yyformat[sizeof yyunexpected
+		    + sizeof yyexpecting - 1
+		    + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
+		       * (sizeof yyor - 1))];
+      char const *yyprefix = yyexpecting;
+
+      /* Start YYX at -YYN if negative to avoid negative indexes in
+	 YYCHECK.  */
+      int yyxbegin = yyn < 0 ? -yyn : 0;
+
+      /* Stay within bounds of both yycheck and yytname.  */
+      int yychecklim = YYLAST - yyn + 1;
+      int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+      int yycount = 1;
+
+      yyarg[0] = yytname[yytype];
+      yyfmt = yystpcpy (yyformat, yyunexpected);
+
+      for (yyx = yyxbegin; yyx < yyxend; ++yyx)
+	if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
+	  {
+	    if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+	      {
+		yycount = 1;
+		yysize = yysize0;
+		yyformat[sizeof yyunexpected - 1] = '\0';
+		break;
+	      }
+	    yyarg[yycount++] = yytname[yyx];
+	    yysize1 = yysize + yytnamerr (0, yytname[yyx]);
+	    yysize_overflow |= (yysize1 < yysize);
+	    yysize = yysize1;
+	    yyfmt = yystpcpy (yyfmt, yyprefix);
+	    yyprefix = yyor;
+	  }
+
+      yyf = YY_(yyformat);
+      yysize1 = yysize + yystrlen (yyf);
+      yysize_overflow |= (yysize1 < yysize);
+      yysize = yysize1;
+
+      if (yysize_overflow)
+	return YYSIZE_MAXIMUM;
+
+      if (yyresult)
+	{
+	  /* 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 *yyp = yyresult;
+	  int yyi = 0;
+	  while ((*yyp = *yyf) != '\0')
+	    {
+	      if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
+		{
+		  yyp += yytnamerr (yyp, yyarg[yyi++]);
+		  yyf += 2;
+		}
+	      else
+		{
+		  yyp++;
+		  yyf++;
+		}
+	    }
+	}
+      return yysize;
+    }
+}
+#endif /* YYERROR_VERBOSE */
+
+
+/*-----------------------------------------------.
+| Release the memory associated to this symbol.  |
+`-----------------------------------------------*/
+
+/*ARGSUSED*/
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+static void
+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
+#else
+static void
+yydestruct (yymsg, yytype, yyvaluep, yylocationp)
+    const char *yymsg;
+    int yytype;
+    YYSTYPE *yyvaluep;
+    YYLTYPE *yylocationp;
+#endif
+{
+  YYUSE (yyvaluep);
+  YYUSE (yylocationp);
+
+  if (!yymsg)
+    yymsg = "Deleting";
+  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
+
+  switch (yytype)
+    {
+
+      default:
+	break;
+    }
+}
+
+
+/* Prevent warnings from -Wmissing-prototypes.  */
+
+#ifdef YYPARSE_PARAM
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void *YYPARSE_PARAM);
+#else
+int yyparse ();
+#endif
+#else /* ! YYPARSE_PARAM */
+#if defined __STDC__ || defined __cplusplus
+int yyparse (void);
+#else
+int yyparse ();
+#endif
+#endif /* ! YYPARSE_PARAM */
+
+
+
+
+
+
+/*----------.
+| yyparse.  |
+`----------*/
+
+#ifdef YYPARSE_PARAM
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void *YYPARSE_PARAM)
+#else
+int
+yyparse (YYPARSE_PARAM)
+    void *YYPARSE_PARAM;
+#endif
+#else /* ! YYPARSE_PARAM */
+#if (defined __STDC__ || defined __C99__FUNC__ \
+     || defined __cplusplus || defined _MSC_VER)
+int
+yyparse (void)
+#else
+int
+yyparse ()
+
+#endif
+#endif
+{
+  /* The look-ahead symbol.  */
+int yychar;
+
+/* The semantic value of the look-ahead symbol.  */
+YYSTYPE yylval;
+
+/* Number of syntax errors so far.  */
+int yynerrs;
+/* Location data for the look-ahead symbol.  */
+YYLTYPE yylloc;
+
+  int yystate;
+  int yyn;
+  int yyresult;
+  /* Number of tokens to shift before error messages enabled.  */
+  int yyerrstatus;
+  /* Look-ahead token as an internal (translated) token number.  */
+  int yytoken = 0;
+#if YYERROR_VERBOSE
+  /* Buffer for error messages, and its allocated size.  */
+  char yymsgbuf[128];
+  char *yymsg = yymsgbuf;
+  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
+#endif
+
+  /* Three stacks and their tools:
+     `yyss': related to states,
+     `yyvs': related to semantic values,
+     `yyls': related to locations.
+
+     Refer to the stacks thru separate pointers, to allow yyoverflow
+     to reallocate them elsewhere.  */
+
+  /* The state stack.  */
+  yytype_int16 yyssa[YYINITDEPTH];
+  yytype_int16 *yyss = yyssa;
+  yytype_int16 *yyssp;
+
+  /* The semantic value stack.  */
+  YYSTYPE yyvsa[YYINITDEPTH];
+  YYSTYPE *yyvs = yyvsa;
+  YYSTYPE *yyvsp;
+
+  /* The location stack.  */
+  YYLTYPE yylsa[YYINITDEPTH];
+  YYLTYPE *yyls = yylsa;
+  YYLTYPE *yylsp;
+  /* The locations where the error started and ended.  */
+  YYLTYPE yyerror_range[2];
+
+#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
+
+  YYSIZE_T yystacksize = YYINITDEPTH;
+
+  /* The variables used to return semantic value and location from the
+     action routines.  */
+  YYSTYPE yyval;
+  YYLTYPE yyloc;
+
+  /* The number of symbols on the RHS of the reduced rule.
+     Keep to zero when no symbol should be popped.  */
+  int yylen = 0;
+
+  YYDPRINTF ((stderr, "Starting parse\n"));
+
+  yystate = 0;
+  yyerrstatus = 0;
+  yynerrs = 0;
+  yychar = YYEMPTY;		/* 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.  */
+
+  yyssp = yyss;
+  yyvsp = yyvs;
+  yylsp = yyls;
+#if YYLTYPE_IS_TRIVIAL
+  /* Initialize the default location before parsing starts.  */
+  yylloc.first_line   = yylloc.last_line   = 1;
+  yylloc.first_column = yylloc.last_column = 0;
+#endif
+
+
+  /* User initialization code.  */
+#line 84 "parse-gram.y"
+{
+  /* Bison's grammar can initial empty locations, hence a default
+     location is needed. */
+  yylloc.start.file   = yylloc.end.file   = current_file;
+  yylloc.start.line   = yylloc.end.line   = 1;
+  yylloc.start.column = yylloc.end.column = 0;
+}
+/* Line 1078 of yacc.c.  */
+#line 1573 "parse-gram.c"
+  yylsp[0] = yylloc;
+  goto yysetstate;
+
+/*------------------------------------------------------------.
+| yynewstate -- Push a new state, which is found in yystate.  |
+`------------------------------------------------------------*/
+ yynewstate:
+  /* In all cases, when you get here, the value and location stacks
+     have just been pushed.  So pushing a state here evens the stacks.  */
+  yyssp++;
+
+ yysetstate:
+  *yyssp = yystate;
+
+  if (yyss + yystacksize - 1 <= yyssp)
+    {
+      /* Get the current used size of the three stacks, in elements.  */
+      YYSIZE_T yysize = yyssp - yyss + 1;
+
+#ifdef yyoverflow
+      {
+	/* Give user a chance to reallocate the stack.  Use copies of
+	   these so that the &'s don't force the real ones into
+	   memory.  */
+	YYSTYPE *yyvs1 = yyvs;
+	yytype_int16 *yyss1 = yyss;
+	YYLTYPE *yyls1 = yyls;
+
+	/* 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 yyoverflow is a macro.  */
+	yyoverflow (YY_("memory exhausted"),
+		    &yyss1, yysize * sizeof (*yyssp),
+		    &yyvs1, yysize * sizeof (*yyvsp),
+		    &yyls1, yysize * sizeof (*yylsp),
+		    &yystacksize);
+	yyls = yyls1;
+	yyss = yyss1;
+	yyvs = yyvs1;
+      }
+#else /* no yyoverflow */
+# ifndef YYSTACK_RELOCATE
+      goto yyexhaustedlab;
+# else
+      /* Extend the stack our own way.  */
+      if (YYMAXDEPTH <= yystacksize)
+	goto yyexhaustedlab;
+      yystacksize *= 2;
+      if (YYMAXDEPTH < yystacksize)
+	yystacksize = YYMAXDEPTH;
+
+      {
+	yytype_int16 *yyss1 = yyss;
+	union yyalloc *yyptr =
+	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+	if (! yyptr)
+	  goto yyexhaustedlab;
+	YYSTACK_RELOCATE (yyss);
+	YYSTACK_RELOCATE (yyvs);
+	YYSTACK_RELOCATE (yyls);
+#  undef YYSTACK_RELOCATE
+	if (yyss1 != yyssa)
+	  YYSTACK_FREE (yyss1);
+      }
+# endif
+#endif /* no yyoverflow */
+
+      yyssp = yyss + yysize - 1;
+      yyvsp = yyvs + yysize - 1;
+      yylsp = yyls + yysize - 1;
+
+      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
+		  (unsigned long int) yystacksize));
+
+      if (yyss + yystacksize - 1 <= yyssp)
+	YYABORT;
+    }
+
+  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+
+  goto yybackup;
+
+/*-----------.
+| yybackup.  |
+`-----------*/
+yybackup:
+
+  /* Do appropriate processing given the current state.  Read a
+     look-ahead token if we need one and don't already have one.  */
+
+  /* First try to decide what to do without reference to look-ahead token.  */
+  yyn = yypact[yystate];
+  if (yyn == YYPACT_NINF)
+    goto yydefault;
+
+  /* Not known => get a look-ahead token if don't already have one.  */
+
+  /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol.  */
+  if (yychar == YYEMPTY)
+    {
+      YYDPRINTF ((stderr, "Reading a token: "));
+      yychar = YYLEX;
+    }
+
+  if (yychar <= YYEOF)
+    {
+      yychar = yytoken = YYEOF;
+      YYDPRINTF ((stderr, "Now at end of input.\n"));
+    }
+  else
+    {
+      yytoken = YYTRANSLATE (yychar);
+      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
+    }
+
+  /* If the proper action on seeing token YYTOKEN is to reduce or to
+     detect an error, take that action.  */
+  yyn += yytoken;
+  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
+    goto yydefault;
+  yyn = yytable[yyn];
+  if (yyn <= 0)
+    {
+      if (yyn == 0 || yyn == YYTABLE_NINF)
+	goto yyerrlab;
+      yyn = -yyn;
+      goto yyreduce;
+    }
+
+  if (yyn == YYFINAL)
+    YYACCEPT;
+
+  /* Count tokens shifted since error; after three, turn off error
+     status.  */
+  if (yyerrstatus)
+    yyerrstatus--;
+
+  /* Shift the look-ahead token.  */
+  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
+
+  /* Discard the shifted token unless it is eof.  */
+  if (yychar != YYEOF)
+    yychar = YYEMPTY;
+
+  yystate = yyn;
+  *++yyvsp = yylval;
+  *++yylsp = yylloc;
+  goto yynewstate;
+
+
+/*-----------------------------------------------------------.
+| yydefault -- do the default action for the current state.  |
+`-----------------------------------------------------------*/
+yydefault:
+  yyn = yydefact[yystate];
+  if (yyn == 0)
+    goto yyerrlab;
+  goto yyreduce;
+
+
+/*-----------------------------.
+| yyreduce -- Do a reduction.  |
+`-----------------------------*/
+yyreduce:
+  /* yyn is the number of a rule to reduce with.  */
+  yylen = yyr2[yyn];
+
+  /* If YYLEN is nonzero, implement the default value of the action:
+     `$$ = $1'.
+
+     Otherwise, the following line sets YYVAL to garbage.
+     This behavior is undocumented and Bison
+     users should not rely upon it.  Assigning to YYVAL
+     unconditionally makes the parser a bit smaller, and it avoids a
+     GCC warning that YYVAL may be used uninitialized.  */
+  yyval = yyvsp[1-yylen];
+
+  /* Default location.  */
+  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
+  YY_REDUCE_PRINT (yyn);
+  switch (yyn)
+    {
+        case 6:
+#line 217 "parse-gram.y"
+    { prologue_augment ((yyvsp[(1) - (1)].chars), (yylsp[(1) - (1)])); }
+    break;
+
+  case 7:
+#line 218 "parse-gram.y"
+    { debug_flag = true; }
+    break;
+
+  case 8:
+#line 220 "parse-gram.y"
+    {
+      static char one[] = "1";
+      muscle_insert ((yyvsp[(2) - (2)].chars), one);
+    }
+    break;
+
+  case 9:
+#line 224 "parse-gram.y"
+    { muscle_insert ((yyvsp[(2) - (3)].chars), (yyvsp[(3) - (3)].chars)); }
+    break;
+
+  case 10:
+#line 225 "parse-gram.y"
+    { defines_flag = true; }
+    break;
+
+  case 11:
+#line 226 "parse-gram.y"
+    { error_verbose = true; }
+    break;
+
+  case 12:
+#line 227 "parse-gram.y"
+    { expected_sr_conflicts = (yyvsp[(2) - (2)].integer); }
+    break;
+
+  case 13:
+#line 228 "parse-gram.y"
+    { expected_rr_conflicts = (yyvsp[(2) - (2)].integer); }
+    break;
+
+  case 14:
+#line 229 "parse-gram.y"
+    { spec_file_prefix = (yyvsp[(3) - (3)].chars); }
+    break;
+
+  case 15:
+#line 231 "parse-gram.y"
+    {
+      nondeterministic_parser = true;
+      glr_parser = true;
+    }
+    break;
+
+  case 16:
+#line 236 "parse-gram.y"
+    {
+      muscle_code_grow ("initial_action", (yyvsp[(1) - (1)].chars), (yylsp[(1) - (1)]));
+    }
+    break;
+
+  case 17:
+#line 239 "parse-gram.y"
+    { add_param ("lex_param", (yyvsp[(1) - (1)].chars), (yylsp[(1) - (1)])); }
+    break;
+
+  case 18:
+#line 240 "parse-gram.y"
+    { locations_flag = true; }
+    break;
+
+  case 19:
+#line 241 "parse-gram.y"
+    { spec_name_prefix = (yyvsp[(3) - (3)].chars); }
+    break;
+
+  case 20:
+#line 242 "parse-gram.y"
+    { no_lines_flag = true; }
+    break;
+
+  case 21:
+#line 243 "parse-gram.y"
+    { nondeterministic_parser = true; }
+    break;
+
+  case 22:
+#line 244 "parse-gram.y"
+    { spec_outfile = (yyvsp[(3) - (3)].chars); }
+    break;
+
+  case 23:
+#line 245 "parse-gram.y"
+    { add_param ("parse_param", (yyvsp[(1) - (1)].chars), (yylsp[(1) - (1)])); }
+    break;
+
+  case 24:
+#line 246 "parse-gram.y"
+    { pure_parser = true; }
+    break;
+
+  case 25:
+#line 247 "parse-gram.y"
+    { version_check (&(yylsp[(2) - (2)]), (yyvsp[(2) - (2)].chars)); }
+    break;
+
+  case 26:
+#line 248 "parse-gram.y"
+    { skeleton = (yyvsp[(2) - (2)].chars); }
+    break;
+
+  case 27:
+#line 249 "parse-gram.y"
+    { token_table_flag = true; }
+    break;
+
+  case 28:
+#line 250 "parse-gram.y"
+    { report_flag = report_states; }
+    break;
+
+  case 29:
+#line 251 "parse-gram.y"
+    { yacc_flag = true; }
+    break;
+
+  case 33:
+#line 259 "parse-gram.y"
+    {
+      grammar_start_symbol_set ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]));
+    }
+    break;
+
+  case 34:
+#line 263 "parse-gram.y"
+    {
+      char const *body = (yyvsp[(1) - (1)].chars);
+
+      if (typed)
+	{
+	  /* Concatenate the union bodies, turning the first one's
+	     trailing '}' into '\n', and omitting the second one's '{'.  */
+	  char *code = muscle_find ("stype");
+	  code[strlen (code) - 1] = '\n';
+	  body++;
+	}
+
+      typed = true;
+      muscle_code_grow ("stype", body, (yylsp[(1) - (1)]));
+    }
+    break;
+
+  case 35:
+#line 279 "parse-gram.y"
+    {
+      symbol_list *list;
+      for (list = (yyvsp[(2) - (2)].list); list; list = list->next)
+	symbol_destructor_set (list->sym, (yyvsp[(1) - (2)].chars), (yylsp[(1) - (2)]));
+      symbol_list_free ((yyvsp[(2) - (2)].list));
+    }
+    break;
+
+  case 36:
+#line 286 "parse-gram.y"
+    {
+      symbol_list *list;
+      for (list = (yyvsp[(2) - (2)].list); list; list = list->next)
+	symbol_printer_set (list->sym, (yyvsp[(1) - (2)].chars), (yylsp[(1) - (2)]));
+      symbol_list_free ((yyvsp[(2) - (2)].list));
+    }
+    break;
+
+  case 37:
+#line 293 "parse-gram.y"
+    {
+      default_prec = true;
+    }
+    break;
+
+  case 38:
+#line 297 "parse-gram.y"
+    {
+      default_prec = false;
+    }
+    break;
+
+  case 39:
+#line 303 "parse-gram.y"
+    { current_class = nterm_sym; }
+    break;
+
+  case 40:
+#line 304 "parse-gram.y"
+    {
+      current_class = unknown_sym;
+      current_type = NULL;
+    }
+    break;
+
+  case 41:
+#line 308 "parse-gram.y"
+    { current_class = token_sym; }
+    break;
+
+  case 42:
+#line 309 "parse-gram.y"
+    {
+      current_class = unknown_sym;
+      current_type = NULL;
+    }
+    break;
+
+  case 43:
+#line 314 "parse-gram.y"
+    {
+      symbol_list *list;
+      for (list = (yyvsp[(3) - (3)].list); list; list = list->next)
+	symbol_type_set (list->sym, (yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]));
+      symbol_list_free ((yyvsp[(3) - (3)].list));
+    }
+    break;
+
+  case 44:
+#line 324 "parse-gram.y"
+    {
+      symbol_list *list;
+      ++current_prec;
+      for (list = (yyvsp[(3) - (3)].list); list; list = list->next)
+	{
+	  symbol_type_set (list->sym, current_type, (yylsp[(2) - (3)]));
+	  symbol_precedence_set (list->sym, current_prec, (yyvsp[(1) - (3)].assoc), (yylsp[(1) - (3)]));
+	}
+      symbol_list_free ((yyvsp[(3) - (3)].list));
+      current_type = NULL;
+    }
+    break;
+
+  case 45:
+#line 338 "parse-gram.y"
+    { (yyval.assoc) = left_assoc; }
+    break;
+
+  case 46:
+#line 339 "parse-gram.y"
+    { (yyval.assoc) = right_assoc; }
+    break;
+
+  case 47:
+#line 340 "parse-gram.y"
+    { (yyval.assoc) = non_assoc; }
+    break;
+
+  case 48:
+#line 344 "parse-gram.y"
+    { current_type = NULL; }
+    break;
+
+  case 49:
+#line 345 "parse-gram.y"
+    { current_type = (yyvsp[(1) - (1)].uniqstr); }
+    break;
+
+  case 50:
+#line 351 "parse-gram.y"
+    { (yyval.list) = symbol_list_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); }
+    break;
+
+  case 51:
+#line 352 "parse-gram.y"
+    { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)])); }
+    break;
+
+  case 52:
+#line 358 "parse-gram.y"
+    {
+       current_type = (yyvsp[(1) - (1)].uniqstr);
+     }
+    break;
+
+  case 53:
+#line 362 "parse-gram.y"
+    {
+       symbol_class_set ((yyvsp[(1) - (1)].symbol), current_class, (yylsp[(1) - (1)]), true);
+       symbol_type_set ((yyvsp[(1) - (1)].symbol), current_type, (yylsp[(1) - (1)]));
+     }
+    break;
+
+  case 54:
+#line 367 "parse-gram.y"
+    {
+      symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true);
+      symbol_type_set ((yyvsp[(1) - (2)].symbol), current_type, (yylsp[(1) - (2)]));
+      symbol_user_token_number_set ((yyvsp[(1) - (2)].symbol), (yyvsp[(2) - (2)].integer), (yylsp[(2) - (2)]));
+    }
+    break;
+
+  case 55:
+#line 373 "parse-gram.y"
+    {
+      symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true);
+      symbol_type_set ((yyvsp[(1) - (2)].symbol), current_type, (yylsp[(1) - (2)]));
+      symbol_make_alias ((yyvsp[(1) - (2)].symbol), (yyvsp[(2) - (2)].symbol), (yyloc));
+    }
+    break;
+
+  case 56:
+#line 379 "parse-gram.y"
+    {
+      symbol_class_set ((yyvsp[(1) - (3)].symbol), current_class, (yylsp[(1) - (3)]), true);
+      symbol_type_set ((yyvsp[(1) - (3)].symbol), current_type, (yylsp[(1) - (3)]));
+      symbol_user_token_number_set ((yyvsp[(1) - (3)].symbol), (yyvsp[(2) - (3)].integer), (yylsp[(2) - (3)]));
+      symbol_make_alias ((yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol), (yyloc));
+    }
+    break;
+
+  case 63:
+#line 409 "parse-gram.y"
+    {
+      yyerrok;
+    }
+    break;
+
+  case 64:
+#line 415 "parse-gram.y"
+    { current_lhs = (yyvsp[(1) - (1)].symbol); current_lhs_location = (yylsp[(1) - (1)]); }
+    break;
+
+  case 66:
+#line 419 "parse-gram.y"
+    { grammar_current_rule_end ((yylsp[(1) - (1)])); }
+    break;
+
+  case 67:
+#line 420 "parse-gram.y"
+    { grammar_current_rule_end ((yylsp[(3) - (3)])); }
+    break;
+
+  case 69:
+#line 426 "parse-gram.y"
+    { grammar_current_rule_begin (current_lhs, current_lhs_location); }
+    break;
+
+  case 70:
+#line 428 "parse-gram.y"
+    { grammar_current_rule_symbol_append ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)])); }
+    break;
+
+  case 72:
+#line 431 "parse-gram.y"
+    { grammar_current_rule_prec_set ((yyvsp[(3) - (3)].symbol), (yylsp[(3) - (3)])); }
+    break;
+
+  case 73:
+#line 433 "parse-gram.y"
+    { grammar_current_rule_dprec_set ((yyvsp[(3) - (3)].integer), (yylsp[(3) - (3)])); }
+    break;
+
+  case 74:
+#line 435 "parse-gram.y"
+    { grammar_current_rule_merge_set ((yyvsp[(3) - (3)].uniqstr), (yylsp[(3) - (3)])); }
+    break;
+
+  case 75:
+#line 439 "parse-gram.y"
+    { (yyval.symbol) = (yyvsp[(1) - (1)].symbol); }
+    break;
+
+  case 76:
+#line 440 "parse-gram.y"
+    { (yyval.symbol) = (yyvsp[(1) - (1)].symbol); }
+    break;
+
+  case 77:
+#line 456 "parse-gram.y"
+    { grammar_current_rule_action_append (last_string, last_braced_code_loc); }
+    break;
+
+  case 79:
+#line 463 "parse-gram.y"
+    {
+      (yyval.symbol) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[(1) - (1)].chars)), (yylsp[(1) - (1)]));
+      symbol_class_set ((yyval.symbol), token_sym, (yylsp[(1) - (1)]), false);
+    }
+    break;
+
+  case 80:
+#line 472 "parse-gram.y"
+    { (yyval.chars) = (yyvsp[(1) - (1)].chars); }
+    break;
+
+  case 82:
+#line 479 "parse-gram.y"
+    {
+      muscle_code_grow ("epilogue", (yyvsp[(2) - (2)].chars), (yylsp[(2) - (2)]));
+      scanner_last_string_free ();
+    }
+    break;
+
+
+/* Line 1267 of yacc.c.  */
+#line 2159 "parse-gram.c"
+      default: break;
+    }
+  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
+
+  YYPOPSTACK (yylen);
+  yylen = 0;
+  YY_STACK_PRINT (yyss, yyssp);
+
+  *++yyvsp = yyval;
+  *++yylsp = yyloc;
+
+  /* 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.  */
+
+  yyn = yyr1[yyn];
+
+  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
+  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+    yystate = yytable[yystate];
+  else
+    yystate = yydefgoto[yyn - YYNTOKENS];
+
+  goto yynewstate;
+
+
+/*------------------------------------.
+| yyerrlab -- here on detecting error |
+`------------------------------------*/
+yyerrlab:
+  /* If not already recovering from an error, report this error.  */
+  if (!yyerrstatus)
+    {
+      ++yynerrs;
+#if ! YYERROR_VERBOSE
+      yyerror (YY_("syntax error"));
+#else
+      {
+	YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
+	if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
+	  {
+	    YYSIZE_T yyalloc = 2 * yysize;
+	    if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
+	      yyalloc = YYSTACK_ALLOC_MAXIMUM;
+	    if (yymsg != yymsgbuf)
+	      YYSTACK_FREE (yymsg);
+	    yymsg = (char *) YYSTACK_ALLOC (yyalloc);
+	    if (yymsg)
+	      yymsg_alloc = yyalloc;
+	    else
+	      {
+		yymsg = yymsgbuf;
+		yymsg_alloc = sizeof yymsgbuf;
+	      }
+	  }
+
+	if (0 < yysize && yysize <= yymsg_alloc)
+	  {
+	    (void) yysyntax_error (yymsg, yystate, yychar);
+	    yyerror (yymsg);
+	  }
+	else
+	  {
+	    yyerror (YY_("syntax error"));
+	    if (yysize != 0)
+	      goto yyexhaustedlab;
+	  }
+      }
+#endif
+    }
+
+  yyerror_range[0] = yylloc;
+
+  if (yyerrstatus == 3)
+    {
+      /* If just tried and failed to reuse look-ahead token after an
+	 error, discard it.  */
+
+      if (yychar <= YYEOF)
+	{
+	  /* Return failure if at end of input.  */
+	  if (yychar == YYEOF)
+	    YYABORT;
+	}
+      else
+	{
+	  yydestruct ("Error: discarding",
+		      yytoken, &yylval, &yylloc);
+	  yychar = YYEMPTY;
+	}
+    }
+
+  /* Else will try to reuse look-ahead token after shifting the error
+     token.  */
+  goto yyerrlab1;
+
+
+/*---------------------------------------------------.
+| yyerrorlab -- error raised explicitly by YYERROR.  |
+`---------------------------------------------------*/
+yyerrorlab:
+
+  /* Pacify compilers like GCC when the user code never invokes
+     YYERROR and the label yyerrorlab therefore never appears in user
+     code.  */
+  if (/*CONSTCOND*/ 0)
+     goto yyerrorlab;
+
+  yyerror_range[0] = yylsp[1-yylen];
+  /* Do not reclaim the symbols of the rule which action triggered
+     this YYERROR.  */
+  YYPOPSTACK (yylen);
+  yylen = 0;
+  YY_STACK_PRINT (yyss, yyssp);
+  yystate = *yyssp;
+  goto yyerrlab1;
+
+
+/*-------------------------------------------------------------.
+| yyerrlab1 -- common code for both syntax error and YYERROR.  |
+`-------------------------------------------------------------*/
+yyerrlab1:
+  yyerrstatus = 3;	/* Each real token shifted decrements this.  */
+
+  for (;;)
+    {
+      yyn = yypact[yystate];
+      if (yyn != YYPACT_NINF)
+	{
+	  yyn += YYTERROR;
+	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
+	    {
+	      yyn = yytable[yyn];
+	      if (0 < yyn)
+		break;
+	    }
+	}
+
+      /* Pop the current state because it cannot handle the error token.  */
+      if (yyssp == yyss)
+	YYABORT;
+
+      yyerror_range[0] = *yylsp;
+      yydestruct ("Error: popping",
+		  yystos[yystate], yyvsp, yylsp);
+      YYPOPSTACK (1);
+      yystate = *yyssp;
+      YY_STACK_PRINT (yyss, yyssp);
+    }
+
+  if (yyn == YYFINAL)
+    YYACCEPT;
+
+  *++yyvsp = yylval;
+
+  yyerror_range[1] = yylloc;
+  /* Using YYLLOC is tempting, but would change the location of
+     the look-ahead.  YYLOC is available though.  */
+  YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
+  *++yylsp = yyloc;
+
+  /* Shift the error token.  */
+  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
+
+  yystate = yyn;
+  goto yynewstate;
+
+
+/*-------------------------------------.
+| yyacceptlab -- YYACCEPT comes here.  |
+`-------------------------------------*/
+yyacceptlab:
+  yyresult = 0;
+  goto yyreturn;
+
+/*-----------------------------------.
+| yyabortlab -- YYABORT comes here.  |
+`-----------------------------------*/
+yyabortlab:
+  yyresult = 1;
+  goto yyreturn;
+
+#ifndef yyoverflow
+/*-------------------------------------------------.
+| yyexhaustedlab -- memory exhaustion comes here.  |
+`-------------------------------------------------*/
+yyexhaustedlab:
+  yyerror (YY_("memory exhausted"));
+  yyresult = 2;
+  /* Fall through.  */
+#endif
+
+yyreturn:
+  if (yychar != YYEOF && yychar != YYEMPTY)
+     yydestruct ("Cleanup: discarding lookahead",
+		 yytoken, &yylval, &yylloc);
+  /* Do not reclaim the symbols of the rule which action triggered
+     this YYABORT or YYACCEPT.  */
+  YYPOPSTACK (yylen);
+  YY_STACK_PRINT (yyss, yyssp);
+  while (yyssp != yyss)
+    {
+      yydestruct ("Cleanup: popping",
+		  yystos[*yyssp], yyvsp, yylsp);
+      YYPOPSTACK (1);
+    }
+#ifndef yyoverflow
+  if (yyss != yyssa)
+    YYSTACK_FREE (yyss);
+#endif
+#if YYERROR_VERBOSE
+  if (yymsg != yymsgbuf)
+    YYSTACK_FREE (yymsg);
+#endif
+  /* Make sure YYID is used.  */
+  return YYID (yyresult);
+}
+
+
+#line 485 "parse-gram.y"
+
+
+
+/* Return the location of the left-hand side of a rule whose
+   right-hand side is RHS[1] ... RHS[N].  Ignore empty nonterminals in
+   the right-hand side, and return an empty location equal to the end
+   boundary of RHS[0] if the right-hand side is empty.  */
+
+static YYLTYPE
+lloc_default (YYLTYPE const *rhs, int n)
+{
+  int i;
+  YYLTYPE loc;
+
+  /* SGI MIPSpro 7.4.1m miscompiles "loc.start = loc.end = rhs[n].end;".
+     The bug is fixed in 7.4.2m, but play it safe for now.  */
+  loc.start = rhs[n].end;
+  loc.end = rhs[n].end;
+
+  /* Ignore empty nonterminals the start of the the right-hand side.
+     Do not bother to ignore them at the end of the right-hand side,
+     since empty nonterminals have the same end as their predecessors.  */
+  for (i = 1; i <= n; i++)
+    if (! equal_boundaries (rhs[i].start, rhs[i].end))
+      {
+	loc.start = rhs[i].start;
+	break;
+      }
+
+  return loc;
+}
+
+
+/* Add a lex-param or a parse-param (depending on TYPE) with
+   declaration DECL and location LOC.  */
+
+static void
+add_param (char const *type, char *decl, location loc)
+{
+  static char const alphanum[26 + 26 + 1 + 10] =
+    "abcdefghijklmnopqrstuvwxyz"
+    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+    "_"
+    "0123456789";
+  char const *name_start = NULL;
+  char *p;
+
+  /* Stop on last actual character.  */
+  for (p = decl; p[1]; p++)
+    if ((p == decl
+	 || ! memchr (alphanum, p[-1], sizeof alphanum))
+	&& memchr (alphanum, p[0], sizeof alphanum - 10))
+      name_start = p;
+
+  /* Strip the surrounding '{' and '}', and any blanks just inside
+     the braces.  */
+  while (*--p == ' ' || *p == '\t')
+    continue;
+  p[1] = '\0';
+  while (*++decl == ' ' || *decl == '\t')
+    continue;
+
+  if (! name_start)
+    complain_at (loc, _("missing identifier in parameter declaration"));
+  else
+    {
+      char *name;
+      size_t name_len;
+
+      for (name_len = 1;
+	   memchr (alphanum, name_start[name_len], sizeof alphanum);
+	   name_len++)
+	continue;
+
+      name = xmalloc (name_len + 1);
+      memcpy (name, name_start, name_len);
+      name[name_len] = '\0';
+      muscle_pair_list_grow (type, decl, name);
+      free (name);
+    }
+
+  scanner_last_string_free ();
+}
+
+static void
+version_check (location const *loc, char const *version)
+{
+  if (strverscmp (version, PACKAGE_VERSION) > 0)
+    {
+      complain_at (*loc, "require bison %s, but have %s",
+		   version, PACKAGE_VERSION);
+      exit (63);
+    }
+}
+
+static void
+gram_error (location const *loc, char const *msg)
+{
+  complain_at (*loc, "%s", msg);
+}
+
+char const *
+token_name (int type)
+{
+  return yytname[YYTRANSLATE (type)];
+}
+
diff --git a/src/parse-gram.h b/src/parse-gram.h
new file mode 100644
index 0000000..2d37fc1
--- /dev/null
+++ b/src/parse-gram.h
@@ -0,0 +1,183 @@
+/* A Bison parser, made by GNU Bison 2.2a.  */
+
+/* Skeleton interface for Bison's Yacc-like parsers in C
+
+   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+   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 2, 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, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+/* 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.  */
+
+/* Tokens.  */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+   /* Put the tokens into the symbol table, so that GDB and other debuggers
+      know about them.  */
+   enum yytokentype {
+     GRAM_EOF = 0,
+     STRING = 258,
+     INT = 259,
+     PERCENT_TOKEN = 260,
+     PERCENT_NTERM = 261,
+     PERCENT_TYPE = 262,
+     PERCENT_DESTRUCTOR = 263,
+     PERCENT_PRINTER = 264,
+     PERCENT_UNION = 265,
+     PERCENT_LEFT = 266,
+     PERCENT_RIGHT = 267,
+     PERCENT_NONASSOC = 268,
+     PERCENT_PREC = 269,
+     PERCENT_DPREC = 270,
+     PERCENT_MERGE = 271,
+     PERCENT_DEBUG = 272,
+     PERCENT_DEFAULT_PREC = 273,
+     PERCENT_DEFINE = 274,
+     PERCENT_DEFINES = 275,
+     PERCENT_ERROR_VERBOSE = 276,
+     PERCENT_EXPECT = 277,
+     PERCENT_EXPECT_RR = 278,
+     PERCENT_FILE_PREFIX = 279,
+     PERCENT_GLR_PARSER = 280,
+     PERCENT_INITIAL_ACTION = 281,
+     PERCENT_LEX_PARAM = 282,
+     PERCENT_LOCATIONS = 283,
+     PERCENT_NAME_PREFIX = 284,
+     PERCENT_NO_DEFAULT_PREC = 285,
+     PERCENT_NO_LINES = 286,
+     PERCENT_NONDETERMINISTIC_PARSER = 287,
+     PERCENT_OUTPUT = 288,
+     PERCENT_PARSE_PARAM = 289,
+     PERCENT_PURE_PARSER = 290,
+     PERCENT_REQUIRE = 291,
+     PERCENT_SKELETON = 292,
+     PERCENT_START = 293,
+     PERCENT_TOKEN_TABLE = 294,
+     PERCENT_VERBOSE = 295,
+     PERCENT_YACC = 296,
+     TYPE = 297,
+     EQUAL = 298,
+     SEMICOLON = 299,
+     PIPE = 300,
+     ID = 301,
+     ID_COLON = 302,
+     PERCENT_PERCENT = 303,
+     PROLOGUE = 304,
+     EPILOGUE = 305,
+     BRACED_CODE = 306
+   };
+#endif
+/* Tokens.  */
+#define GRAM_EOF 0
+#define STRING 258
+#define INT 259
+#define PERCENT_TOKEN 260
+#define PERCENT_NTERM 261
+#define PERCENT_TYPE 262
+#define PERCENT_DESTRUCTOR 263
+#define PERCENT_PRINTER 264
+#define PERCENT_UNION 265
+#define PERCENT_LEFT 266
+#define PERCENT_RIGHT 267
+#define PERCENT_NONASSOC 268
+#define PERCENT_PREC 269
+#define PERCENT_DPREC 270
+#define PERCENT_MERGE 271
+#define PERCENT_DEBUG 272
+#define PERCENT_DEFAULT_PREC 273
+#define PERCENT_DEFINE 274
+#define PERCENT_DEFINES 275
+#define PERCENT_ERROR_VERBOSE 276
+#define PERCENT_EXPECT 277
+#define PERCENT_EXPECT_RR 278
+#define PERCENT_FILE_PREFIX 279
+#define PERCENT_GLR_PARSER 280
+#define PERCENT_INITIAL_ACTION 281
+#define PERCENT_LEX_PARAM 282
+#define PERCENT_LOCATIONS 283
+#define PERCENT_NAME_PREFIX 284
+#define PERCENT_NO_DEFAULT_PREC 285
+#define PERCENT_NO_LINES 286
+#define PERCENT_NONDETERMINISTIC_PARSER 287
+#define PERCENT_OUTPUT 288
+#define PERCENT_PARSE_PARAM 289
+#define PERCENT_PURE_PARSER 290
+#define PERCENT_REQUIRE 291
+#define PERCENT_SKELETON 292
+#define PERCENT_START 293
+#define PERCENT_TOKEN_TABLE 294
+#define PERCENT_VERBOSE 295
+#define PERCENT_YACC 296
+#define TYPE 297
+#define EQUAL 298
+#define SEMICOLON 299
+#define PIPE 300
+#define ID 301
+#define ID_COLON 302
+#define PERCENT_PERCENT 303
+#define PROLOGUE 304
+#define EPILOGUE 305
+#define BRACED_CODE 306
+
+
+
+
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE
+#line 94 "parse-gram.y"
+{
+  symbol *symbol;
+  symbol_list *list;
+  int integer;
+  char *chars;
+  assoc assoc;
+  uniqstr uniqstr;
+}
+/* Line 1529 of yacc.c.  */
+#line 162 "parse-gram.h"
+	YYSTYPE;
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+# define YYSTYPE_IS_TRIVIAL 1
+#endif
+
+
+
+#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
+typedef struct YYLTYPE
+{
+  int first_line;
+  int first_column;
+  int last_line;
+  int last_column;
+} YYLTYPE;
+# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
+# define YYLTYPE_IS_DECLARED 1
+# define YYLTYPE_IS_TRIVIAL 1
+#endif
+
+
diff --git a/src/parse-gram.y b/src/parse-gram.y
new file mode 100644
index 0000000..e189e14
--- /dev/null
+++ b/src/parse-gram.y
@@ -0,0 +1,590 @@
+%{/* Bison Grammar Parser                             -*- C -*-
+
+   Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   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 2 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, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301  USA
+*/
+
+#include <config.h>
+#include "system.h"
+
+#include "complain.h"
+#include "conflicts.h"
+#include "files.h"
+#include "getargs.h"
+#include "gram.h"
+#include "muscle_tab.h"
+#include "quotearg.h"
+#include "reader.h"
+#include "symlist.h"
+#include "strverscmp.h"
+
+#define YYLLOC_DEFAULT(Current, Rhs, N)  (Current) = lloc_default (Rhs, N)
+static YYLTYPE lloc_default (YYLTYPE const *, int);
+
+#define YY_LOCATION_PRINT(File, Loc) \
+	  location_print (File, Loc)
+
+static void version_check (location const *loc, char const *version);
+
+/* Request detailed syntax error messages, and pass them to GRAM_ERROR.
+   FIXME: depends on the undocumented availability of YYLLOC.  */
+#undef  yyerror
+#define yyerror(Msg) \
+	gram_error (&yylloc, Msg)
+static void gram_error (location const *, char const *);
+
+static void add_param (char const *, char *, location);
+
+static symbol_class current_class = unknown_sym;
+static uniqstr current_type = 0;
+static symbol *current_lhs;
+static location current_lhs_location;
+static int current_prec = 0;
+
+#ifdef UINT_FAST8_MAX
+# define YYTYPE_UINT8 uint_fast8_t
+#endif
+#ifdef INT_FAST8_MAX
+# define YYTYPE_INT8 int_fast8_t
+#endif
+#ifdef UINT_FAST16_MAX
+# define YYTYPE_UINT16 uint_fast16_t
+#endif
+#ifdef INT_FAST16_MAX
+# define YYTYPE_INT16 int_fast16_t
+#endif
+%}
+
+%debug
+%verbose
+%defines
+%locations
+%pure-parser
+%error-verbose
+%defines
+%name-prefix="gram_"
+
+%initial-action
+{
+  /* Bison's grammar can initial empty locations, hence a default
+     location is needed. */
+  @$.start.file   = @$.end.file   = current_file;
+  @$.start.line   = @$.end.line   = 1;
+  @$.start.column = @$.end.column = 0;
+}
+
+/* Only NUMBERS have a value.  */
+%union
+{
+  symbol *symbol;
+  symbol_list *list;
+  int integer;
+  char *chars;
+  assoc assoc;
+  uniqstr uniqstr;
+};
+
+/* Define the tokens together with their human representation.  */
+%token GRAM_EOF 0 "end of file"
+%token STRING     "string"
+%token INT        "integer"
+
+%token PERCENT_TOKEN       "%token"
+%token PERCENT_NTERM       "%nterm"
+
+%token PERCENT_TYPE        "%type"
+%token PERCENT_DESTRUCTOR  "%destructor {...}"
+%token PERCENT_PRINTER     "%printer {...}"
+
+%token PERCENT_UNION       "%union {...}"
+
+%token PERCENT_LEFT        "%left"
+%token PERCENT_RIGHT       "%right"
+%token PERCENT_NONASSOC    "%nonassoc"
+
+%token PERCENT_PREC          "%prec"
+%token PERCENT_DPREC         "%dprec"
+%token PERCENT_MERGE         "%merge"
+
+
+/*----------------------.
+| Global Declarations.  |
+`----------------------*/
+
+%token
+  PERCENT_DEBUG           "%debug"
+  PERCENT_DEFAULT_PREC    "%default-prec"
+  PERCENT_DEFINE          "%define"
+  PERCENT_DEFINES         "%defines"
+  PERCENT_ERROR_VERBOSE   "%error-verbose"
+  PERCENT_EXPECT          "%expect"
+  PERCENT_EXPECT_RR	  "%expect-rr"
+  PERCENT_FILE_PREFIX     "%file-prefix"
+  PERCENT_GLR_PARSER      "%glr-parser"
+  PERCENT_INITIAL_ACTION  "%initial-action {...}"
+  PERCENT_LEX_PARAM       "%lex-param {...}"
+  PERCENT_LOCATIONS       "%locations"
+  PERCENT_NAME_PREFIX     "%name-prefix"
+  PERCENT_NO_DEFAULT_PREC "%no-default-prec"
+  PERCENT_NO_LINES        "%no-lines"
+  PERCENT_NONDETERMINISTIC_PARSER
+			  "%nondeterministic-parser"
+  PERCENT_OUTPUT          "%output"
+  PERCENT_PARSE_PARAM     "%parse-param {...}"
+  PERCENT_PURE_PARSER     "%pure-parser"
+  PERCENT_REQUIRE	  "%require"
+  PERCENT_SKELETON        "%skeleton"
+  PERCENT_START           "%start"
+  PERCENT_TOKEN_TABLE     "%token-table"
+  PERCENT_VERBOSE         "%verbose"
+  PERCENT_YACC            "%yacc"
+;
+
+%token TYPE            "type"
+%token EQUAL           "="
+%token SEMICOLON       ";"
+%token PIPE            "|"
+%token ID              "identifier"
+%token ID_COLON        "identifier:"
+%token PERCENT_PERCENT "%%"
+%token PROLOGUE        "%{...%}"
+%token EPILOGUE        "epilogue"
+%token BRACED_CODE     "{...}"
+
+
+%type <chars> STRING string_content
+	      "%destructor {...}"
+	      "%initial-action {...}"
+	      "%lex-param {...}"
+	      "%parse-param {...}"
+	      "%printer {...}"
+	      "%union {...}"
+	      PROLOGUE EPILOGUE
+%printer { fprintf (stderr, "\"%s\"", $$); }
+	      STRING string_content
+%printer { fprintf (stderr, "{\n%s\n}", $$); }
+	      "%destructor {...}"
+	      "%initial-action {...}"
+	      "%lex-param {...}"
+	      "%parse-param {...}"
+	      "%printer {...}"
+	      "%union {...}"
+	      PROLOGUE EPILOGUE
+%type <uniqstr> TYPE
+%printer { fprintf (stderr, "<%s>", $$); } TYPE
+%type <integer> INT
+%printer { fprintf (stderr, "%d", $$); } INT
+%type <symbol> ID symbol string_as_id
+%printer { fprintf (stderr, "%s", $$->tag); } ID symbol string_as_id
+%type <symbol> ID_COLON
+%printer { fprintf (stderr, "%s:", $$->tag); } ID_COLON
+%type <assoc> precedence_declarator
+%type <list>  symbols.1
+%%
+
+input:
+  declarations "%%" grammar epilogue.opt
+;
+
+
+	/*------------------------------------.
+	| Declarations: before the first %%.  |
+	`------------------------------------*/
+
+declarations:
+  /* Nothing */
+| declarations declaration
+;
+
+declaration:
+  grammar_declaration
+| PROLOGUE                                 { prologue_augment ($1, @1); }
+| "%debug"                                 { debug_flag = true; }
+| "%define" string_content
+    {
+      static char one[] = "1";
+      muscle_insert ($2, one);
+    }
+| "%define" string_content string_content  { muscle_insert ($2, $3); }
+| "%defines"                               { defines_flag = true; }
+| "%error-verbose"                         { error_verbose = true; }
+| "%expect" INT                            { expected_sr_conflicts = $2; }
+| "%expect-rr" INT			   { expected_rr_conflicts = $2; }
+| "%file-prefix" "=" string_content        { spec_file_prefix = $3; }
+| "%glr-parser"
+    {
+      nondeterministic_parser = true;
+      glr_parser = true;
+    }
+| "%initial-action {...}"
+    {
+      muscle_code_grow ("initial_action", $1, @1);
+    }
+| "%lex-param {...}"			   { add_param ("lex_param", $1, @1); }
+| "%locations"                             { locations_flag = true; }
+| "%name-prefix" "=" string_content        { spec_name_prefix = $3; }
+| "%no-lines"                              { no_lines_flag = true; }
+| "%nondeterministic-parser"		   { nondeterministic_parser = true; }
+| "%output" "=" string_content             { spec_outfile = $3; }
+| "%parse-param {...}"			   { add_param ("parse_param", $1, @1); }
+| "%pure-parser"                           { pure_parser = true; }
+| "%require" string_content                { version_check (&@2, $2); }
+| "%skeleton" string_content               { skeleton = $2; }
+| "%token-table"                           { token_table_flag = true; }
+| "%verbose"                               { report_flag = report_states; }
+| "%yacc"                                  { yacc_flag = true; }
+| /*FIXME: Err?  What is this horror doing here? */ ";"
+;
+
+grammar_declaration:
+  precedence_declaration
+| symbol_declaration
+| "%start" symbol
+    {
+      grammar_start_symbol_set ($2, @2);
+    }
+| "%union {...}"
+    {
+      char const *body = $1;
+
+      if (typed)
+	{
+	  /* Concatenate the union bodies, turning the first one's
+	     trailing '}' into '\n', and omitting the second one's '{'.  */
+	  char *code = muscle_find ("stype");
+	  code[strlen (code) - 1] = '\n';
+	  body++;
+	}
+
+      typed = true;
+      muscle_code_grow ("stype", body, @1);
+    }
+| "%destructor {...}" symbols.1
+    {
+      symbol_list *list;
+      for (list = $2; list; list = list->next)
+	symbol_destructor_set (list->sym, $1, @1);
+      symbol_list_free ($2);
+    }
+| "%printer {...}" symbols.1
+    {
+      symbol_list *list;
+      for (list = $2; list; list = list->next)
+	symbol_printer_set (list->sym, $1, @1);
+      symbol_list_free ($2);
+    }
+| "%default-prec"
+    {
+      default_prec = true;
+    }
+| "%no-default-prec"
+    {
+      default_prec = false;
+    }
+;
+
+symbol_declaration:
+  "%nterm" { current_class = nterm_sym; } symbol_defs.1
+    {
+      current_class = unknown_sym;
+      current_type = NULL;
+    }
+| "%token" { current_class = token_sym; } symbol_defs.1
+    {
+      current_class = unknown_sym;
+      current_type = NULL;
+    }
+| "%type" TYPE symbols.1
+    {
+      symbol_list *list;
+      for (list = $3; list; list = list->next)
+	symbol_type_set (list->sym, $2, @2);
+      symbol_list_free ($3);
+    }
+;
+
+precedence_declaration:
+  precedence_declarator type.opt symbols.1
+    {
+      symbol_list *list;
+      ++current_prec;
+      for (list = $3; list; list = list->next)
+	{
+	  symbol_type_set (list->sym, current_type, @2);
+	  symbol_precedence_set (list->sym, current_prec, $1, @1);
+	}
+      symbol_list_free ($3);
+      current_type = NULL;
+    }
+;
+
+precedence_declarator:
+  "%left"     { $$ = left_assoc; }
+| "%right"    { $$ = right_assoc; }
+| "%nonassoc" { $$ = non_assoc; }
+;
+
+type.opt:
+  /* Nothing. */ { current_type = NULL; }
+| TYPE           { current_type = $1; }
+;
+
+/* One or more nonterminals to be %typed. */
+
+symbols.1:
+  symbol            { $$ = symbol_list_new ($1, @1); }
+| symbols.1 symbol  { $$ = symbol_list_prepend ($1, $2, @2); }
+;
+
+/* One token definition.  */
+symbol_def:
+  TYPE
+     {
+       current_type = $1;
+     }
+| ID
+     {
+       symbol_class_set ($1, current_class, @1, true);
+       symbol_type_set ($1, current_type, @1);
+     }
+| ID INT
+    {
+      symbol_class_set ($1, current_class, @1, true);
+      symbol_type_set ($1, current_type, @1);
+      symbol_user_token_number_set ($1, $2, @2);
+    }
+| ID string_as_id
+    {
+      symbol_class_set ($1, current_class, @1, true);
+      symbol_type_set ($1, current_type, @1);
+      symbol_make_alias ($1, $2, @$);
+    }
+| ID INT string_as_id
+    {
+      symbol_class_set ($1, current_class, @1, true);
+      symbol_type_set ($1, current_type, @1);
+      symbol_user_token_number_set ($1, $2, @2);
+      symbol_make_alias ($1, $3, @$);
+    }
+;
+
+/* One or more symbol definitions. */
+symbol_defs.1:
+  symbol_def
+| symbol_defs.1 symbol_def
+;
+
+
+	/*------------------------------------------.
+	| The grammar section: between the two %%.  |
+	`------------------------------------------*/
+
+grammar:
+  rules_or_grammar_declaration
+| grammar rules_or_grammar_declaration
+;
+
+/* As a Bison extension, one can use the grammar declarations in the
+   body of the grammar.  */
+rules_or_grammar_declaration:
+  rules
+| grammar_declaration ";"
+| error ";"
+    {
+      yyerrok;
+    }
+;
+
+rules:
+  ID_COLON { current_lhs = $1; current_lhs_location = @1; } rhses.1
+;
+
+rhses.1:
+  rhs                { grammar_current_rule_end (@1); }
+| rhses.1 "|" rhs    { grammar_current_rule_end (@3); }
+| rhses.1 ";"
+;
+
+rhs:
+  /* Nothing.  */
+    { grammar_current_rule_begin (current_lhs, current_lhs_location); }
+| rhs symbol
+    { grammar_current_rule_symbol_append ($2, @2); }
+| rhs action
+| rhs "%prec" symbol
+    { grammar_current_rule_prec_set ($3, @3); }
+| rhs "%dprec" INT
+    { grammar_current_rule_dprec_set ($3, @3); }
+| rhs "%merge" TYPE
+    { grammar_current_rule_merge_set ($3, @3); }
+;
+
+symbol:
+  ID              { $$ = $1; }
+| string_as_id    { $$ = $1; }
+;
+
+/* Handle the semantics of an action specially, with a mid-rule
+   action, so that grammar_current_rule_action_append is invoked
+   immediately after the braced code is read by the scanner.
+
+   This implementation relies on the LALR(1) parsing algorithm.
+   If grammar_current_rule_action_append were executed in a normal
+   action for this rule, then when the input grammar contains two
+   successive actions, the scanner would have to read both actions
+   before reducing this rule.  That wouldn't work, since the scanner
+   relies on all preceding input actions being processed by
+   grammar_current_rule_action_append before it scans the next
+   action.  */
+action:
+    { grammar_current_rule_action_append (last_string, last_braced_code_loc); }
+  BRACED_CODE
+;
+
+/* A string used as an ID: quote it.  */
+string_as_id:
+  STRING
+    {
+      $$ = symbol_get (quotearg_style (c_quoting_style, $1), @1);
+      symbol_class_set ($$, token_sym, @1, false);
+    }
+;
+
+/* A string used for its contents.  Don't quote it.  */
+string_content:
+  STRING
+    { $$ = $1; }
+;
+
+
+epilogue.opt:
+  /* Nothing.  */
+| "%%" EPILOGUE
+    {
+      muscle_code_grow ("epilogue", $2, @2);
+      scanner_last_string_free ();
+    }
+;
+
+%%
+
+
+/* Return the location of the left-hand side of a rule whose
+   right-hand side is RHS[1] ... RHS[N].  Ignore empty nonterminals in
+   the right-hand side, and return an empty location equal to the end
+   boundary of RHS[0] if the right-hand side is empty.  */
+
+static YYLTYPE
+lloc_default (YYLTYPE const *rhs, int n)
+{
+  int i;
+  YYLTYPE loc;
+
+  /* SGI MIPSpro 7.4.1m miscompiles "loc.start = loc.end = rhs[n].end;".
+     The bug is fixed in 7.4.2m, but play it safe for now.  */
+  loc.start = rhs[n].end;
+  loc.end = rhs[n].end;
+
+  /* Ignore empty nonterminals the start of the the right-hand side.
+     Do not bother to ignore them at the end of the right-hand side,
+     since empty nonterminals have the same end as their predecessors.  */
+  for (i = 1; i <= n; i++)
+    if (! equal_boundaries (rhs[i].start, rhs[i].end))
+      {
+	loc.start = rhs[i].start;
+	break;
+      }
+
+  return loc;
+}
+
+
+/* Add a lex-param or a parse-param (depending on TYPE) with
+   declaration DECL and location LOC.  */
+
+static void
+add_param (char const *type, char *decl, location loc)
+{
+  static char const alphanum[26 + 26 + 1 + 10] =
+    "abcdefghijklmnopqrstuvwxyz"
+    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+    "_"
+    "0123456789";
+  char const *name_start = NULL;
+  char *p;
+
+  /* Stop on last actual character.  */
+  for (p = decl; p[1]; p++)
+    if ((p == decl
+	 || ! memchr (alphanum, p[-1], sizeof alphanum))
+	&& memchr (alphanum, p[0], sizeof alphanum - 10))
+      name_start = p;
+
+  /* Strip the surrounding '{' and '}', and any blanks just inside
+     the braces.  */
+  while (*--p == ' ' || *p == '\t')
+    continue;
+  p[1] = '\0';
+  while (*++decl == ' ' || *decl == '\t')
+    continue;
+
+  if (! name_start)
+    complain_at (loc, _("missing identifier in parameter declaration"));
+  else
+    {
+      char *name;
+      size_t name_len;
+
+      for (name_len = 1;
+	   memchr (alphanum, name_start[name_len], sizeof alphanum);
+	   name_len++)
+	continue;
+
+      name = xmalloc (name_len + 1);
+      memcpy (name, name_start, name_len);
+      name[name_len] = '\0';
+      muscle_pair_list_grow (type, decl, name);
+      free (name);
+    }
+
+  scanner_last_string_free ();
+}
+
+static void
+version_check (location const *loc, char const *version)
+{
+  if (strverscmp (version, PACKAGE_VERSION) > 0)
+    {
+      complain_at (*loc, "require bison %s, but have %s",
+		   version, PACKAGE_VERSION);
+      exit (63);
+    }
+}
+
+static void
+gram_error (location const *loc, char const *msg)
+{
+  complain_at (*loc, "%s", msg);
+}
+
+char const *
+token_name (int type)
+{
+  return yytname[YYTRANSLATE (type)];
+}
diff --git a/src/print.c b/src/print.c
new file mode 100644
index 0000000..cb1600c
--- /dev/null
+++ b/src/print.c
@@ -0,0 +1,575 @@
+/* Print information on generated parser, for bison,
+
+   Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002, 2003, 2004, 2005
+   Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+#include "system.h"
+
+#include <bitset.h>
+#include <quotearg.h>
+
+#include "LR0.h"
+#include "closure.h"
+#include "conflicts.h"
+#include "files.h"
+#include "getargs.h"
+#include "gram.h"
+#include "lalr.h"
+#include "print.h"
+#include "reader.h"
+#include "reduce.h"
+#include "state.h"
+#include "symtab.h"
+
+static bitset shift_set;
+static bitset look_ahead_set;
+
+#if 0
+static void
+print_token (int extnum, int token)
+{
+  fprintf (out, _(" type %d is %s\n"), extnum, tags[token]);
+}
+#endif
+
+
+
+/*---------------------------------------.
+| *WIDTH := max (*WIDTH, strlen (STR)).  |
+`---------------------------------------*/
+
+static void
+max_length (size_t *width, const char *str)
+{
+  size_t len = strlen (str);
+  if (len > *width)
+    *width = len;
+}
+
+/*--------------------------------.
+| Report information on a state.  |
+`--------------------------------*/
+
+static void
+print_core (FILE *out, state *s)
+{
+  size_t i;
+  item_number *sitems = s->items;
+  size_t snritems = s->nitems;
+  symbol *previous_lhs = NULL;
+
+  /* Output all the items of a state, not only its kernel.  */
+  if (report_flag & report_itemsets)
+    {
+      closure (sitems, snritems);
+      sitems = itemset;
+      snritems = nritemset;
+    }
+
+  if (!snritems)
+    return;
+
+  fputc ('\n', out);
+
+  for (i = 0; i < snritems; i++)
+    {
+      item_number *sp;
+      item_number *sp1;
+      rule_number r;
+
+      sp1 = sp = ritem + sitems[i];
+
+      while (*sp >= 0)
+	sp++;
+
+      r = item_number_as_rule_number (*sp);
+
+      rule_lhs_print (&rules[r], previous_lhs, out);
+      previous_lhs = rules[r].lhs;
+
+      for (sp = rules[r].rhs; sp < sp1; sp++)
+	fprintf (out, " %s", symbols[*sp]->tag);
+      fputs (" .", out);
+      for (/* Nothing */; *sp >= 0; ++sp)
+	fprintf (out, " %s", symbols[*sp]->tag);
+
+      /* Display the look-ahead tokens?  */
+      if (report_flag & report_look_ahead_tokens)
+	state_rule_look_ahead_tokens_print (s, &rules[r], out);
+
+      fputc ('\n', out);
+    }
+}
+
+
+/*------------------------------------------------------------.
+| Report the shifts iff DISPLAY_SHIFTS_P or the gotos of S on |
+| OUT.                                                        |
+`------------------------------------------------------------*/
+
+static void
+print_transitions (state *s, FILE *out, bool display_transitions_p)
+{
+  transitions *trans = s->transitions;
+  size_t width = 0;
+  int i;
+
+  /* Compute the width of the look-ahead token column.  */
+  for (i = 0; i < trans->num; i++)
+    if (!TRANSITION_IS_DISABLED (trans, i)
+	&& TRANSITION_IS_SHIFT (trans, i) == display_transitions_p)
+      {
+	symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
+	max_length (&width, sym->tag);
+      }
+
+  /* Nothing to report. */
+  if (!width)
+    return;
+
+  fputc ('\n', out);
+  width += 2;
+
+  /* Report look-ahead tokens and shifts.  */
+  for (i = 0; i < trans->num; i++)
+    if (!TRANSITION_IS_DISABLED (trans, i)
+	&& TRANSITION_IS_SHIFT (trans, i) == display_transitions_p)
+      {
+	symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
+	const char *tag = sym->tag;
+	state *s1 = trans->states[i];
+	int j;
+
+	fprintf (out, "    %s", tag);
+	for (j = width - strlen (tag); j > 0; --j)
+	  fputc (' ', out);
+	if (display_transitions_p)
+	  fprintf (out, _("shift, and go to state %d\n"), s1->number);
+	else
+	  fprintf (out, _("go to state %d\n"), s1->number);
+      }
+}
+
+
+/*--------------------------------------------------------.
+| Report the explicit errors of S raised from %nonassoc.  |
+`--------------------------------------------------------*/
+
+static void
+print_errs (FILE *out, state *s)
+{
+  errs *errp = s->errs;
+  size_t width = 0;
+  int i;
+
+  /* Compute the width of the look-ahead token column.  */
+  for (i = 0; i < errp->num; ++i)
+    if (errp->symbols[i])
+      max_length (&width, errp->symbols[i]->tag);
+
+  /* Nothing to report. */
+  if (!width)
+    return;
+
+  fputc ('\n', out);
+  width += 2;
+
+  /* Report look-ahead tokens and errors.  */
+  for (i = 0; i < errp->num; ++i)
+    if (errp->symbols[i])
+      {
+	const char *tag = errp->symbols[i]->tag;
+	int j;
+	fprintf (out, "    %s", tag);
+	for (j = width - strlen (tag); j > 0; --j)
+	  fputc (' ', out);
+	fputs (_("error (nonassociative)\n"), out);
+      }
+}
+
+
+/*-------------------------------------------------------------.
+| Return the default rule of S if it has one, NULL otherwise.  |
+`-------------------------------------------------------------*/
+
+static rule *
+state_default_rule (state *s)
+{
+  reductions *reds = s->reductions;
+  rule *default_rule = NULL;
+  int cmax = 0;
+  int i;
+
+  /* No need for a look-ahead.  */
+  if (s->consistent)
+    return reds->rules[0];
+
+  /* 1. Each reduction is possibly masked by the look-ahead tokens on which
+     we shift (S/R conflicts)...  */
+  bitset_zero (shift_set);
+  {
+    transitions *trans = s->transitions;
+    FOR_EACH_SHIFT (trans, i)
+      {
+	/* If this state has a shift for the error token, don't use a
+	     default rule.  */
+	if (TRANSITION_IS_ERROR (trans, i))
+	  return NULL;
+	bitset_set (shift_set, TRANSITION_SYMBOL (trans, i));
+      }
+  }
+
+  /* 2. Each reduction is possibly masked by the look-ahead tokens on which
+     we raise an error (due to %nonassoc).  */
+  {
+    errs *errp = s->errs;
+    for (i = 0; i < errp->num; i++)
+      if (errp->symbols[i])
+	bitset_set (shift_set, errp->symbols[i]->number);
+  }
+
+  for (i = 0; i < reds->num; ++i)
+    {
+      int count = 0;
+
+      /* How many non-masked look-ahead tokens are there for this
+	 reduction?  */
+      bitset_andn (look_ahead_set, reds->look_ahead_tokens[i], shift_set);
+      count = bitset_count (look_ahead_set);
+
+      if (count > cmax)
+	{
+	  cmax = count;
+	  default_rule = reds->rules[i];
+	}
+
+      /* 3. And finally, each reduction is possibly masked by previous
+	 reductions (in R/R conflicts, we keep the first reductions).
+	 */
+      bitset_or (shift_set, shift_set, reds->look_ahead_tokens[i]);
+    }
+
+  return default_rule;
+}
+
+
+/*--------------------------------------------------------------------------.
+| Report a reduction of RULE on LOOK_AHEAD_TOKEN (which can be `default').  |
+| If not ENABLED, the rule is masked by a shift or a reduce (S/R and        |
+| R/R conflicts).                                                           |
+`--------------------------------------------------------------------------*/
+
+static void
+print_reduction (FILE *out, size_t width,
+		 const char *look_ahead_token,
+		 rule *r, bool enabled)
+{
+  int j;
+  fprintf (out, "    %s", look_ahead_token);
+  for (j = width - strlen (look_ahead_token); j > 0; --j)
+    fputc (' ', out);
+  if (!enabled)
+    fputc ('[', out);
+  if (r->number)
+    fprintf (out, _("reduce using rule %d (%s)"), r->number, r->lhs->tag);
+  else
+    fprintf (out, _("accept"));
+  if (!enabled)
+    fputc (']', out);
+  fputc ('\n', out);
+}
+
+
+/*-------------------------------------------.
+| Report on OUT the reduction actions of S.  |
+`-------------------------------------------*/
+
+static void
+print_reductions (FILE *out, state *s)
+{
+  transitions *trans = s->transitions;
+  reductions *reds = s->reductions;
+  rule *default_rule = NULL;
+  size_t width = 0;
+  int i, j;
+
+  if (reds->num == 0)
+    return;
+
+  default_rule = state_default_rule (s);
+
+  bitset_zero (shift_set);
+  FOR_EACH_SHIFT (trans, i)
+    bitset_set (shift_set, TRANSITION_SYMBOL (trans, i));
+
+  /* Compute the width of the look-ahead token column.  */
+  if (default_rule)
+    width = strlen (_("$default"));
+
+  if (reds->look_ahead_tokens)
+    for (i = 0; i < ntokens; i++)
+      {
+	bool count = bitset_test (shift_set, i);
+
+	for (j = 0; j < reds->num; ++j)
+	  if (bitset_test (reds->look_ahead_tokens[j], i))
+	    {
+	      if (! count)
+		{
+		  if (reds->rules[j] != default_rule)
+		    max_length (&width, symbols[i]->tag);
+		  count = true;
+		}
+	      else
+		{
+		  max_length (&width, symbols[i]->tag);
+		}
+	    }
+      }
+
+  /* Nothing to report. */
+  if (!width)
+    return;
+
+  fputc ('\n', out);
+  width += 2;
+
+  /* Report look-ahead tokens (or $default) and reductions.  */
+  if (reds->look_ahead_tokens)
+    for (i = 0; i < ntokens; i++)
+      {
+	bool defaulted = false;
+	bool count = bitset_test (shift_set, i);
+
+	for (j = 0; j < reds->num; ++j)
+	  if (bitset_test (reds->look_ahead_tokens[j], i))
+	    {
+	      if (! count)
+		{
+		  if (reds->rules[j] != default_rule)
+		    print_reduction (out, width,
+				     symbols[i]->tag,
+				     reds->rules[j], true);
+		  else
+		    defaulted = true;
+		  count = true;
+		}
+	      else
+		{
+		  if (defaulted)
+		    print_reduction (out, width,
+				     symbols[i]->tag,
+				     default_rule, true);
+		  defaulted = false;
+		  print_reduction (out, width,
+				   symbols[i]->tag,
+				   reds->rules[j], false);
+		}
+	    }
+      }
+
+  if (default_rule)
+    print_reduction (out, width,
+		     _("$default"), default_rule, true);
+}
+
+
+/*--------------------------------------------------------------.
+| Report on OUT all the actions (shifts, gotos, reductions, and |
+| explicit erros from %nonassoc) of S.                          |
+`--------------------------------------------------------------*/
+
+static void
+print_actions (FILE *out, state *s)
+{
+  /* Print shifts.  */
+  print_transitions (s, out, true);
+  print_errs (out, s);
+  print_reductions (out, s);
+  /* Print gotos.  */
+  print_transitions (s, out, false);
+}
+
+
+/*----------------------------------.
+| Report all the data on S on OUT.  |
+`----------------------------------*/
+
+static void
+print_state (FILE *out, state *s)
+{
+  fputs ("\n\n", out);
+  fprintf (out, _("state %d"), s->number);
+  fputc ('\n', out);
+  print_core (out, s);
+  print_actions (out, s);
+  if ((report_flag & report_solved_conflicts) && s->solved_conflicts)
+    {
+      fputc ('\n', out);
+      fputs (s->solved_conflicts, out);
+    }
+}
+
+/*-----------------------------------------.
+| Print information on the whole grammar.  |
+`-----------------------------------------*/
+
+#define END_TEST(End)				\
+do {						\
+  if (column + strlen(buffer) > (End))		\
+    {						\
+      fprintf (out, "%s\n   ", buffer);		\
+      column = 3;				\
+      buffer[0] = 0;				\
+    }						\
+} while (0)
+
+
+static void
+print_grammar (FILE *out)
+{
+  symbol_number i;
+  char buffer[90];
+  int column = 0;
+
+  grammar_rules_print (out);
+
+  /* TERMINAL (type #) : rule #s terminal is on RHS */
+  fprintf (out, "%s\n\n", _("Terminals, with rules where they appear"));
+  for (i = 0; i < max_user_token_number + 1; i++)
+    if (token_translations[i] != undeftoken->number)
+      {
+	const char *tag = symbols[token_translations[i]]->tag;
+	rule_number r;
+	item_number *rhsp;
+
+	buffer[0] = 0;
+	column = strlen (tag);
+	fputs (tag, out);
+	END_TEST (50);
+	sprintf (buffer, " (%d)", i);
+
+	for (r = 0; r < nrules; r++)
+	  for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
+	    if (item_number_as_symbol_number (*rhsp) == token_translations[i])
+	      {
+		END_TEST (65);
+		sprintf (buffer + strlen (buffer), " %d", r);
+		break;
+	      }
+	fprintf (out, "%s\n", buffer);
+      }
+  fputs ("\n\n", out);
+
+
+  fprintf (out, "%s\n\n", _("Nonterminals, with rules where they appear"));
+  for (i = ntokens; i < nsyms; i++)
+    {
+      int left_count = 0, right_count = 0;
+      rule_number r;
+      const char *tag = symbols[i]->tag;
+
+      for (r = 0; r < nrules; r++)
+	{
+	  item_number *rhsp;
+	  if (rules[r].lhs->number == i)
+	    left_count++;
+	  for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
+	    if (item_number_as_symbol_number (*rhsp) == i)
+	      {
+		right_count++;
+		break;
+	      }
+	}
+
+      buffer[0] = 0;
+      fputs (tag, out);
+      column = strlen (tag);
+      sprintf (buffer, " (%d)", i);
+      END_TEST (0);
+
+      if (left_count > 0)
+	{
+	  END_TEST (50);
+	  sprintf (buffer + strlen (buffer), _(" on left:"));
+
+	  for (r = 0; r < nrules; r++)
+	    {
+	      END_TEST (65);
+	      if (rules[r].lhs->number == i)
+		sprintf (buffer + strlen (buffer), " %d", r);
+	    }
+	}
+
+      if (right_count > 0)
+	{
+	  if (left_count > 0)
+	    sprintf (buffer + strlen (buffer), ",");
+	  END_TEST (50);
+	  sprintf (buffer + strlen (buffer), _(" on right:"));
+	  for (r = 0; r < nrules; r++)
+	    {
+	      item_number *rhsp;
+	      for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
+		if (item_number_as_symbol_number (*rhsp) == i)
+		  {
+		    END_TEST (65);
+		    sprintf (buffer + strlen (buffer), " %d", r);
+		    break;
+		  }
+	    }
+	}
+      fprintf (out, "%s\n", buffer);
+    }
+}
+
+void
+print_results (void)
+{
+  state_number i;
+
+  /* We used to use just .out if SPEC_NAME_PREFIX (-p) was used, but
+     that conflicts with Posix.  */
+  FILE *out = xfopen (spec_verbose_file, "w");
+
+  reduce_output (out);
+  grammar_rules_partial_print (out,
+			       _("Rules never reduced"), rule_never_reduced_p);
+  conflicts_output (out);
+
+  print_grammar (out);
+
+  /* If the whole state item sets, not only the kernels, are wanted,
+     `closure' will be run, which needs memory allocation/deallocation.   */
+  if (report_flag & report_itemsets)
+    new_closure (nritems);
+  /* Storage for print_reductions.  */
+  shift_set =  bitset_create (ntokens, BITSET_FIXED);
+  look_ahead_set = bitset_create (ntokens, BITSET_FIXED);
+  for (i = 0; i < nstates; i++)
+    print_state (out, states[i]);
+  bitset_free (shift_set);
+  bitset_free (look_ahead_set);
+  if (report_flag & report_itemsets)
+    free_closure ();
+
+  xfclose (out);
+}
diff --git a/src/print.h b/src/print.h
new file mode 100644
index 0000000..1daa577
--- /dev/null
+++ b/src/print.h
@@ -0,0 +1,26 @@
+/* Print information on generated parser, for bison,
+   Copyright 2000 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#ifndef PRINT_H_
+# define PRINT_H_
+
+void print_results (void);
+
+#endif /* !PRINT_H_ */
diff --git a/src/print_graph.c b/src/print_graph.c
new file mode 100644
index 0000000..9580f3f
--- /dev/null
+++ b/src/print_graph.c
@@ -0,0 +1,227 @@
+/* Output a VCG description on generated parser, for Bison,
+
+   Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+#include "system.h"
+
+#include <quotearg.h>
+
+#include "LR0.h"
+#include "closure.h"
+#include "complain.h"
+#include "conflicts.h"
+#include "files.h"
+#include "getargs.h"
+#include "gram.h"
+#include "lalr.h"
+#include "print_graph.h"
+#include "reader.h"
+#include "state.h"
+#include "symtab.h"
+#include "vcg.h"
+
+static graph static_graph;
+static FILE *fgraph = NULL;
+
+
+/*----------------------------.
+| Construct the node labels.  |
+`----------------------------*/
+
+static void
+print_core (struct obstack *oout, state *s)
+{
+  size_t i;
+  item_number *sitems = s->items;
+  size_t snritems = s->nitems;
+
+  /* Output all the items of a state, not only its kernel.  */
+  if (report_flag & report_itemsets)
+    {
+      closure (sitems, snritems);
+      sitems = itemset;
+      snritems = nritemset;
+    }
+
+  obstack_fgrow1 (oout, "state %2d\n", s->number);
+  for (i = 0; i < snritems; i++)
+    {
+      item_number *sp;
+      item_number *sp1;
+      rule_number r;
+
+      sp1 = sp = ritem + sitems[i];
+
+      while (*sp >= 0)
+	sp++;
+
+      r = item_number_as_rule_number (*sp);
+
+      if (i)
+	obstack_1grow (oout, '\n');
+      obstack_fgrow1 (oout, " %s -> ",
+		      rules[r].lhs->tag);
+
+      for (sp = rules[r].rhs; sp < sp1; sp++)
+	obstack_fgrow1 (oout, "%s ", symbols[*sp]->tag);
+
+      obstack_1grow (oout, '.');
+
+      for (/* Nothing */; *sp >= 0; ++sp)
+	obstack_fgrow1 (oout, " %s", symbols[*sp]->tag);
+
+      /* Experimental feature: display the look-ahead tokens. */
+      if (report_flag & report_look_ahead_tokens)
+	{
+	  /* Find the reduction we are handling.  */
+	  reductions *reds = s->reductions;
+	  int redno = state_reduction_find (s, &rules[r]);
+
+	  /* Print them if there are.  */
+	  if (reds->look_ahead_tokens && redno != -1)
+	    {
+	      bitset_iterator biter;
+	      int k;
+	      char const *sep = "";
+	      obstack_sgrow (oout, "[");
+	      BITSET_FOR_EACH (biter, reds->look_ahead_tokens[redno], k, 0)
+		{
+		  obstack_fgrow2 (oout, "%s%s", sep, symbols[k]->tag);
+		  sep = ", ";
+		}
+	      obstack_sgrow (oout, "]");
+	    }
+	}
+    }
+}
+
+
+/*---------------------------------------------------------------.
+| Output in graph_obstack edges specifications in incidence with |
+| current node.                                                  |
+`---------------------------------------------------------------*/
+
+static void
+print_actions (state *s, const char *node_name)
+{
+  int i;
+
+  transitions *trans = s->transitions;
+  reductions *reds = s->reductions;
+
+  static char buff[10];
+  edge e;
+
+  if (!trans->num && !reds)
+    return;
+
+  for (i = 0; i < trans->num; i++)
+    if (!TRANSITION_IS_DISABLED (trans, i))
+      {
+	state *s1 = trans->states[i];
+	symbol_number sym = s1->accessing_symbol;
+
+	new_edge (&e);
+
+	if (s->number > s1->number)
+	  e.type = back_edge;
+	open_edge (&e, fgraph);
+	/* The edge source is the current node.  */
+	e.sourcename = node_name;
+	sprintf (buff, "%d", s1->number);
+	e.targetname = buff;
+	/* Shifts are blue, gotos are green, and error is red. */
+	if (TRANSITION_IS_ERROR (trans, i))
+	  e.color = red;
+	else
+	  e.color = TRANSITION_IS_SHIFT (trans, i) ? blue : green;
+	e.label = symbols[sym]->tag;
+	output_edge (&e, fgraph);
+	close_edge (fgraph);
+      }
+}
+
+
+/*-------------------------------------------------------------.
+| Output in FGRAPH the current node specifications and exiting |
+| edges.                                                       |
+`-------------------------------------------------------------*/
+
+static void
+print_state (state *s)
+{
+  static char name[10];
+  struct obstack node_obstack;
+  node n;
+
+  /* The labels of the nodes are their the items.  */
+  obstack_init (&node_obstack);
+  new_node (&n);
+  sprintf (name, "%d", s->number);
+  n.title = name;
+  print_core (&node_obstack, s);
+  obstack_1grow (&node_obstack, '\0');
+  n.label = obstack_finish (&node_obstack);
+
+  open_node (fgraph);
+  output_node (&n, fgraph);
+  close_node (fgraph);
+
+  /* Output the edges.  */
+  print_actions (s, name);
+
+  obstack_free (&node_obstack, 0);
+}
+
+
+void
+print_graph (void)
+{
+  state_number i;
+
+  /* Output file.  */
+  fgraph = xfopen (spec_graph_file, "w");
+
+  new_graph (&static_graph);
+
+  static_graph.display_edge_labels = yes;
+
+  static_graph.port_sharing = no;
+  static_graph.finetuning = yes;
+  static_graph.priority_phase = yes;
+  static_graph.splines = yes;
+
+  static_graph.crossing_weight = median;
+
+  /* Output graph options. */
+  open_graph (fgraph);
+  output_graph (&static_graph, fgraph);
+
+  /* Output nodes and edges. */
+  new_closure (nritems);
+  for (i = 0; i < nstates; i++)
+    print_state (states[i]);
+  free_closure ();
+
+  /* Close graph. */
+  close_graph (&static_graph, fgraph);
+  xfclose (fgraph);
+}
diff --git a/src/print_graph.h b/src/print_graph.h
new file mode 100644
index 0000000..befc531
--- /dev/null
+++ b/src/print_graph.h
@@ -0,0 +1,26 @@
+/* Output a VCG description on generated parser, for bison,
+   Copyright 2000 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#ifndef PRINT_GRAPH_H_
+# define PRINT_GRAPH_H_
+
+void print_graph (void);
+
+#endif /* !PRINT_GRAPH_H_ */
diff --git a/src/reader.c b/src/reader.c
new file mode 100644
index 0000000..d07ce5c
--- /dev/null
+++ b/src/reader.c
@@ -0,0 +1,576 @@
+/* Input parser for Bison
+
+   Copyright (C) 1984, 1986, 1989, 1992, 1998, 2000, 2001, 2002, 2003,
+   2005, 2006 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+#include "system.h"
+
+#include <quotearg.h>
+
+#include "complain.h"
+#include "conflicts.h"
+#include "files.h"
+#include "getargs.h"
+#include "gram.h"
+#include "muscle_tab.h"
+#include "reader.h"
+#include "symlist.h"
+#include "symtab.h"
+
+static void check_and_convert_grammar (void);
+
+static symbol_list *grammar = NULL;
+static bool start_flag = false;
+merger_list *merge_functions;
+
+/* Was %union seen?  */
+bool typed = false;
+
+/* Should rules have a default precedence?  */
+bool default_prec = true;
+
+/*-----------------------.
+| Set the start symbol.  |
+`-----------------------*/
+
+void
+grammar_start_symbol_set (symbol *sym, location loc)
+{
+  if (start_flag)
+    complain_at (loc, _("multiple %s declarations"), "%start");
+  else
+    {
+      start_flag = true;
+      startsymbol = sym;
+      startsymbol_location = loc;
+    }
+}
+
+
+/*----------------------------------------------------------------.
+| There are two prologues: one before %union, one after.  Augment |
+| the current one.                                                |
+`----------------------------------------------------------------*/
+
+void
+prologue_augment (const char *prologue, location loc)
+{
+  struct obstack *oout =
+    !typed ? &pre_prologue_obstack : &post_prologue_obstack;
+
+  obstack_fgrow1 (oout, "]b4_syncline(%d, [[", loc.start.line);
+  MUSCLE_OBSTACK_SGROW (oout,
+			quotearg_style (c_quoting_style, loc.start.file));
+  obstack_sgrow (oout, "]])[\n");
+  obstack_sgrow (oout, prologue);
+}
+
+
+
+/*-------------------------------------------------------------------.
+| Return the merger index for a merging function named NAME, whose   |
+| arguments have type TYPE.  Records the function, if new, in        |
+| MERGER_LIST.							     |
+`-------------------------------------------------------------------*/
+
+static int
+get_merge_function (uniqstr name, uniqstr type, location loc)
+{
+  merger_list *syms;
+  merger_list head;
+  int n;
+
+  if (! glr_parser)
+    return 0;
+
+  if (type == NULL)
+    type = uniqstr_new ("");
+
+  head.next = merge_functions;
+  for (syms = &head, n = 1; syms->next; syms = syms->next, n += 1)
+    if (UNIQSTR_EQ (name, syms->next->name))
+      break;
+  if (syms->next == NULL)
+    {
+      syms->next = xmalloc (sizeof syms->next[0]);
+      syms->next->name = uniqstr_new (name);
+      syms->next->type = uniqstr_new (type);
+      syms->next->next = NULL;
+      merge_functions = head.next;
+    }
+  else if (!UNIQSTR_EQ (type, syms->next->type))
+    warn_at (loc, _("result type clash on merge function %s: <%s> != <%s>"),
+	     name, type, syms->next->type);
+  return n;
+}
+
+/*--------------------------------------.
+| Free all merge-function definitions.	|
+`--------------------------------------*/
+
+void
+free_merger_functions (void)
+{
+  merger_list *L0 = merge_functions;
+  while (L0)
+    {
+      merger_list *L1 = L0->next;
+      free (L0);
+      L0 = L1;
+    }
+}
+
+
+/*-------------------------------------------------------------------.
+| Parse the input grammar into a one symbol_list structure.  Each    |
+| rule is represented by a sequence of symbols: the left hand side   |
+| followed by the contents of the right hand side, followed by a     |
+| null pointer instead of a symbol to terminate the rule.  The next  |
+| symbol is the lhs of the following rule.                           |
+|                                                                    |
+| All actions are copied out, labelled by the rule number they apply |
+| to.                                                                |
+`-------------------------------------------------------------------*/
+
+/* The (currently) last symbol of GRAMMAR. */
+static symbol_list *grammar_end = NULL;
+
+/* Append SYM to the grammar.  */
+static void
+grammar_symbol_append (symbol *sym, location loc)
+{
+  symbol_list *p = symbol_list_new (sym, loc);
+
+  if (grammar_end)
+    grammar_end->next = p;
+  else
+    grammar = p;
+
+  grammar_end = p;
+
+  /* A null SYM stands for an end of rule; it is not an actual
+     part of it.  */
+  if (sym)
+    ++nritems;
+}
+
+/* The rule currently being defined, and the previous rule.
+   CURRENT_RULE points to the first LHS of the current rule, while
+   PREVIOUS_RULE_END points to the *end* of the previous rule (NULL).  */
+symbol_list *current_rule = NULL;
+static symbol_list *previous_rule_end = NULL;
+
+
+/*----------------------------------------------.
+| Create a new rule for LHS in to the GRAMMAR.  |
+`----------------------------------------------*/
+
+void
+grammar_current_rule_begin (symbol *lhs, location loc)
+{
+  if (!start_flag)
+    {
+      startsymbol = lhs;
+      startsymbol_location = loc;
+      start_flag = true;
+    }
+
+  /* Start a new rule and record its lhs.  */
+  ++nrules;
+  previous_rule_end = grammar_end;
+  grammar_symbol_append (lhs, loc);
+  current_rule = grammar_end;
+
+  /* Mark the rule's lhs as a nonterminal if not already so.  */
+  if (lhs->class == unknown_sym)
+    {
+      lhs->class = nterm_sym;
+      lhs->number = nvars;
+      ++nvars;
+    }
+  else if (lhs->class == token_sym)
+    complain_at (loc, _("rule given for %s, which is a token"), lhs->tag);
+}
+
+
+/*----------------------------------------------------------------------.
+| A symbol should be used if it has a destructor, or if it is a         |
+| mid-rule symbol (i.e., the generated LHS replacing a mid-rule         |
+| action) that was assigned to, as in "exp: { $$ = 1; } { $$ = $1; }".  |
+`----------------------------------------------------------------------*/
+
+static bool
+symbol_should_be_used (symbol_list const *s)
+{
+  return (s->sym->destructor
+	  || (s->midrule && s->midrule->used));
+}
+
+/*----------------------------------------------------------------.
+| Check that the rule R is properly defined.  For instance, there |
+| should be no type clash on the default action.                  |
+`----------------------------------------------------------------*/
+
+static void
+grammar_rule_check (const symbol_list *r)
+{
+  /* Type check.
+
+     If there is an action, then there is nothing we can do: the user
+     is allowed to shoot herself in the foot.
+
+     Don't worry about the default action if $$ is untyped, since $$'s
+     value can't be used.  */
+  if (!r->action && r->sym->type_name)
+    {
+      symbol *first_rhs = r->next->sym;
+      /* If $$ is being set in default way, report if any type mismatch.  */
+      if (first_rhs)
+	{
+	  char const *lhs_type = r->sym->type_name;
+	  const char *rhs_type =
+	    first_rhs->type_name ? first_rhs->type_name : "";
+	  if (!UNIQSTR_EQ (lhs_type, rhs_type))
+	    warn_at (r->location,
+		     _("type clash on default action: <%s> != <%s>"),
+		     lhs_type, rhs_type);
+	}
+      /* Warn if there is no default for $$ but we need one.  */
+      else
+	warn_at (r->location,
+		 _("empty rule for typed nonterminal, and no action"));
+    }
+
+  /* Check that symbol values that should be used are in fact used.  */
+  {
+    symbol_list const *l = r;
+    int n = 0;
+    for (; l && l->sym; l = l->next, ++n)
+      if (! (l->used
+	     || !symbol_should_be_used (l)
+	     /* The default action, $$ = $1, `uses' both.  */
+	     || (!r->action && (n == 0 || n == 1))))
+	{
+	  if (n)
+	    warn_at (r->location, _("unused value: $%d"), n);
+	  else
+	    warn_at (r->location, _("unset value: $$"));
+	}
+  }
+}
+
+
+/*-------------------------------------.
+| End the currently being grown rule.  |
+`-------------------------------------*/
+
+void
+grammar_current_rule_end (location loc)
+{
+  /* Put an empty link in the list to mark the end of this rule  */
+  grammar_symbol_append (NULL, grammar_end->location);
+  current_rule->location = loc;
+  grammar_rule_check (current_rule);
+}
+
+
+/*-------------------------------------------------------------------.
+| The previous action turns out the be a mid-rule action.  Attach it |
+| to the current rule, i.e., create a dummy symbol, attach it this   |
+| mid-rule action, and append this dummy nonterminal to the current  |
+| rule.                                                              |
+`-------------------------------------------------------------------*/
+
+void
+grammar_midrule_action (void)
+{
+  /* Since the action was written out with this rule's number, we must
+     give the new rule this number by inserting the new rule before
+     it.  */
+
+  /* Make a DUMMY nonterminal, whose location is that of the midrule
+     action.  Create the MIDRULE.  */
+  location dummy_location = current_rule->action_location;
+  symbol *dummy = dummy_symbol_get (dummy_location);
+  symbol_list *midrule = symbol_list_new (dummy, dummy_location);
+
+  /* Make a new rule, whose body is empty, before the current one, so
+     that the action just read can belong to it.  */
+  ++nrules;
+  ++nritems;
+  /* Attach its location and actions to that of the DUMMY.  */
+  midrule->location = dummy_location;
+  midrule->action = current_rule->action;
+  midrule->action_location = dummy_location;
+  current_rule->action = NULL;
+  /* If $$ was used in the action, the LHS of the enclosing rule was
+     incorrectly flagged as used.  */
+  midrule->used = current_rule->used;
+  current_rule->used = false;
+
+  if (previous_rule_end)
+    previous_rule_end->next = midrule;
+  else
+    grammar = midrule;
+
+  /* End the dummy's rule.  */
+  midrule->next = symbol_list_new (NULL, dummy_location);
+  grammar_rule_check (midrule);
+  midrule->next->next = current_rule;
+
+  previous_rule_end = midrule->next;
+
+  /* Insert the dummy nonterminal replacing the midrule action into
+     the current rule.  Bind it to its dedicated rule.  */
+  grammar_current_rule_symbol_append (dummy, dummy_location);
+  grammar_end->midrule = midrule;
+}
+
+/* Set the precedence symbol of the current rule to PRECSYM. */
+
+void
+grammar_current_rule_prec_set (symbol *precsym, location loc)
+{
+  if (current_rule->ruleprec)
+    complain_at (loc, _("only one %s allowed per rule"), "%prec");
+  current_rule->ruleprec = precsym;
+}
+
+/* Attach dynamic precedence DPREC to the current rule. */
+
+void
+grammar_current_rule_dprec_set (int dprec, location loc)
+{
+  if (! glr_parser)
+    warn_at (loc, _("%s affects only GLR parsers"), "%dprec");
+  if (dprec <= 0)
+    complain_at (loc, _("%s must be followed by positive number"), "%dprec");
+  else if (current_rule->dprec != 0)
+    complain_at (loc, _("only one %s allowed per rule"), "%dprec");
+  current_rule->dprec = dprec;
+}
+
+/* Attach a merge function NAME with argument type TYPE to current
+   rule. */
+
+void
+grammar_current_rule_merge_set (uniqstr name, location loc)
+{
+  if (! glr_parser)
+    warn_at (loc, _("%s affects only GLR parsers"), "%merge");
+  if (current_rule->merger != 0)
+    complain_at (loc, _("only one %s allowed per rule"), "%merge");
+  current_rule->merger =
+    get_merge_function (name, current_rule->sym->type_name, loc);
+}
+
+/* Attach SYM to the current rule.  If needed, move the previous
+   action as a mid-rule action.  */
+
+void
+grammar_current_rule_symbol_append (symbol *sym, location loc)
+{
+  if (current_rule->action)
+    grammar_midrule_action ();
+  grammar_symbol_append (sym, loc);
+}
+
+/* Attach an ACTION to the current rule.  */
+
+void
+grammar_current_rule_action_append (const char *action, location loc)
+{
+  /* There's no need to invoke grammar_midrule_action here, since the
+     scanner already did it if necessary.  */
+  current_rule->action = action;
+  current_rule->action_location = loc;
+}
+
+
+/*---------------------------------------------------------------.
+| Convert the rules into the representation using RRHS, RLHS and |
+| RITEM.                                                         |
+`---------------------------------------------------------------*/
+
+static void
+packgram (void)
+{
+  unsigned int itemno = 0;
+  rule_number ruleno = 0;
+  symbol_list *p = grammar;
+
+  ritem = xnmalloc (nritems + 1, sizeof *ritem);
+
+  /* This sentinel is used by build_relations in gram.c.  */
+  *ritem++ = 0;
+
+  rules = xnmalloc (nrules, sizeof *rules);
+
+  while (p)
+    {
+      symbol *ruleprec = p->ruleprec;
+      rules[ruleno].user_number = ruleno;
+      rules[ruleno].number = ruleno;
+      rules[ruleno].lhs = p->sym;
+      rules[ruleno].rhs = ritem + itemno;
+      rules[ruleno].prec = NULL;
+      rules[ruleno].dprec = p->dprec;
+      rules[ruleno].merger = p->merger;
+      rules[ruleno].precsym = NULL;
+      rules[ruleno].location = p->location;
+      rules[ruleno].useful = true;
+      rules[ruleno].action = p->action;
+      rules[ruleno].action_location = p->action_location;
+
+      p = p->next;
+      while (p && p->sym)
+	{
+	  /* item_number = symbol_number.
+	     But the former needs to contain more: negative rule numbers. */
+	  ritem[itemno++] = symbol_number_as_item_number (p->sym->number);
+	  /* A rule gets by default the precedence and associativity
+	     of the last token in it.  */
+	  if (p->sym->class == token_sym && default_prec)
+	    rules[ruleno].prec = p->sym;
+	  if (p)
+	    p = p->next;
+	}
+
+      /* If this rule has a %prec,
+         the specified symbol's precedence replaces the default.  */
+      if (ruleprec)
+	{
+	  rules[ruleno].precsym = ruleprec;
+	  rules[ruleno].prec = ruleprec;
+	}
+      ritem[itemno++] = rule_number_as_item_number (ruleno);
+      ++ruleno;
+
+      if (p)
+	p = p->next;
+    }
+
+  assert (itemno == nritems);
+
+  if (trace_flag & trace_sets)
+    ritem_print (stderr);
+}
+
+/*------------------------------------------------------------------.
+| Read in the grammar specification and record it in the format     |
+| described in gram.h.  All actions are copied into ACTION_OBSTACK, |
+| in each case forming the body of a C function (YYACTION) which    |
+| contains a switch statement to decide which action to execute.    |
+`------------------------------------------------------------------*/
+
+void
+reader (void)
+{
+  /* Initialize the symbol table.  */
+  symbols_new ();
+
+  /* Construct the accept symbol. */
+  accept = symbol_get ("$accept", empty_location);
+  accept->class = nterm_sym;
+  accept->number = nvars++;
+
+  /* Construct the error token */
+  errtoken = symbol_get ("error", empty_location);
+  errtoken->class = token_sym;
+  errtoken->number = ntokens++;
+
+  /* Construct a token that represents all undefined literal tokens.
+     It is always token number 2.  */
+  undeftoken = symbol_get ("$undefined", empty_location);
+  undeftoken->class = token_sym;
+  undeftoken->number = ntokens++;
+
+  /* Initialize the obstacks. */
+  obstack_init (&pre_prologue_obstack);
+  obstack_init (&post_prologue_obstack);
+
+  gram_in = xfopen (grammar_file, "r");
+
+  gram__flex_debug = trace_flag & trace_scan;
+  gram_debug = trace_flag & trace_parse;
+  scanner_initialize ();
+  gram_parse ();
+
+  if (! complaint_issued)
+    check_and_convert_grammar ();
+
+  xfclose (gram_in);
+}
+
+
+/*-------------------------------------------------------------.
+| Check the grammar that has just been read, and convert it to |
+| internal form.					       |
+`-------------------------------------------------------------*/
+
+static void
+check_and_convert_grammar (void)
+{
+  /* Grammar has been read.  Do some checking.  */
+  if (nrules == 0)
+    fatal (_("no rules in the input grammar"));
+
+  /* Report any undefined symbols and consider them nonterminals.  */
+  symbols_check_defined ();
+
+  /* If the user did not define her ENDTOKEN, do it now. */
+  if (!endtoken)
+    {
+      endtoken = symbol_get ("$end", empty_location);
+      endtoken->class = token_sym;
+      endtoken->number = 0;
+      /* Value specified by POSIX.  */
+      endtoken->user_token_number = 0;
+    }
+
+  /* Insert the initial rule, whose line is that of the first rule
+     (not that of the start symbol):
+
+     accept: %start EOF.  */
+  {
+    symbol_list *p = symbol_list_new (accept, empty_location);
+    p->location = grammar->location;
+    p->next = symbol_list_new (startsymbol, empty_location);
+    p->next->next = symbol_list_new (endtoken, empty_location);
+    p->next->next->next = symbol_list_new (NULL, empty_location);
+    p->next->next->next->next = grammar;
+    nrules += 1;
+    nritems += 3;
+    grammar = p;
+  }
+
+  assert (nsyms <= SYMBOL_NUMBER_MAXIMUM && nsyms == ntokens + nvars);
+
+  /* Assign the symbols their symbol numbers.  Write #defines for the
+     token symbols into FDEFINES if requested.  */
+  symbols_pack ();
+
+  /* Convert the grammar into the format described in gram.h.  */
+  packgram ();
+
+  /* The grammar as a symbol_list is no longer needed. */
+  LIST_FREE (symbol_list, grammar);
+}
diff --git a/src/reader.h b/src/reader.h
new file mode 100644
index 0000000..f110f70
--- /dev/null
+++ b/src/reader.h
@@ -0,0 +1,87 @@
+/* Input parser for Bison
+
+   Copyright (C) 2000, 2001, 2002, 2003, 2005, 2006 Free Software
+   Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#ifndef READER_H_
+# define READER_H_
+
+# include "location.h"
+# include "symlist.h"
+
+# include "parse-gram.h"
+
+typedef struct merger_list
+{
+  struct merger_list* next;
+  uniqstr name;
+  uniqstr type;
+} merger_list;
+
+/* From the scanner.  */
+extern FILE *gram_in;
+extern int gram__flex_debug;
+extern boundary scanner_cursor;
+extern char *last_string;
+extern location last_braced_code_loc;
+extern int max_left_semantic_context;
+void scanner_initialize (void);
+void scanner_free (void);
+void scanner_last_string_free (void);
+
+/* These are declared by the scanner, but not used.  We put them here
+   to pacify "make syntax-check".  */
+extern FILE *gram_out;
+extern int gram_lineno;
+
+# define YY_DECL int gram_lex (YYSTYPE *val, location *loc)
+YY_DECL;
+
+
+/* From the parser.  */
+extern int gram_debug;
+int gram_parse (void);
+char const *token_name (int type);
+
+
+/* From reader.c. */
+void grammar_start_symbol_set (symbol *sym, location loc);
+void prologue_augment (const char *prologue, location loc);
+void grammar_current_rule_begin (symbol *lhs, location loc);
+void grammar_current_rule_end (location loc);
+void grammar_midrule_action (void);
+void grammar_current_rule_prec_set (symbol *precsym, location loc);
+void grammar_current_rule_dprec_set (int dprec, location loc);
+void grammar_current_rule_merge_set (uniqstr name, location loc);
+void grammar_current_rule_symbol_append (symbol *sym, location loc);
+void grammar_current_rule_action_append (const char *action, location loc);
+extern symbol_list *current_rule;
+void reader (void);
+void free_merger_functions (void);
+
+extern merger_list *merge_functions;
+
+/* Was %union seen?  */
+extern bool typed;
+
+/* Should rules have a default precedence?  */
+extern bool default_prec;
+
+#endif /* !READER_H_ */
diff --git a/src/reduce.c b/src/reduce.c
new file mode 100644
index 0000000..1bb40f0
--- /dev/null
+++ b/src/reduce.c
@@ -0,0 +1,470 @@
+/* Grammar reduction for Bison.
+
+   Copyright (C) 1988, 1989, 2000, 2001, 2002, 2003, 2005, 2006 Free
+   Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+
+/* Reduce the grammar: Find and eliminate unreachable terminals,
+   nonterminals, and productions.  David S. Bakin.  */
+
+/* Don't eliminate unreachable terminals: They may be used by the
+   user's parser.  */
+
+#include <config.h>
+#include "system.h"
+
+#include <bitset.h>
+#include <quotearg.h>
+
+#include "complain.h"
+#include "files.h"
+#include "getargs.h"
+#include "gram.h"
+#include "reader.h"
+#include "reduce.h"
+#include "symtab.h"
+
+/* Set of all nonterminals which are not useless.  */
+static bitset N;
+
+/* Set of all rules which have no useless nonterminals in their RHS.  */
+static bitset P;
+
+/* Set of all accessible symbols.  */
+static bitset V;
+
+/* Set of symbols used to define rule precedence (so they are
+   `useless', but no warning should be issued).  */
+static bitset V1;
+
+static rule_number nuseful_productions;
+rule_number nuseless_productions;
+static int nuseful_nonterminals;
+symbol_number nuseless_nonterminals;
+
+/*-------------------------------------------------------------------.
+| Another way to do this would be with a set for each production and |
+| then do subset tests against N0, but even for the C grammar the    |
+| whole reducing process takes only 2 seconds on my 8Mhz AT.         |
+`-------------------------------------------------------------------*/
+
+static bool
+useful_production (rule_number r, bitset N0)
+{
+  item_number *rhsp;
+
+  /* A production is useful if all of the nonterminals in its appear
+     in the set of useful nonterminals.  */
+
+  for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
+    if (ISVAR (*rhsp) && !bitset_test (N0, *rhsp - ntokens))
+      return false;
+  return true;
+}
+
+
+/*---------------------------------------------------------.
+| Remember that rules are 1-origin, symbols are 0-origin.  |
+`---------------------------------------------------------*/
+
+static void
+useless_nonterminals (void)
+{
+  bitset Np, Ns;
+  rule_number r;
+
+  /* N is set as built.  Np is set being built this iteration. P is
+     set of all productions which have a RHS all in N.  */
+
+  Np = bitset_create (nvars, BITSET_FIXED);
+
+
+  /* The set being computed is a set of nonterminals which can derive
+     the empty string or strings consisting of all terminals. At each
+     iteration a nonterminal is added to the set if there is a
+     production with that nonterminal as its LHS for which all the
+     nonterminals in its RHS are already in the set.  Iterate until
+     the set being computed remains unchanged.  Any nonterminals not
+     in the set at that point are useless in that they will never be
+     used in deriving a sentence of the language.
+
+     This iteration doesn't use any special traversal over the
+     productions.  A set is kept of all productions for which all the
+     nonterminals in the RHS are in useful.  Only productions not in
+     this set are scanned on each iteration.  At the end, this set is
+     saved to be used when finding useful productions: only
+     productions in this set will appear in the final grammar.  */
+
+  while (1)
+    {
+      bitset_copy (Np, N);
+      for (r = 0; r < nrules; r++)
+	if (!bitset_test (P, r)
+	    && useful_production (r, N))
+	  {
+	    bitset_set (Np, rules[r].lhs->number - ntokens);
+	    bitset_set (P, r);
+	  }
+      if (bitset_equal_p (N, Np))
+	break;
+      Ns = Np;
+      Np = N;
+      N = Ns;
+    }
+  bitset_free (N);
+  N = Np;
+}
+
+
+static void
+inaccessable_symbols (void)
+{
+  bitset Vp, Vs, Pp;
+
+  /* Find out which productions are reachable and which symbols are
+     used.  Starting with an empty set of productions and a set of
+     symbols which only has the start symbol in it, iterate over all
+     productions until the set of productions remains unchanged for an
+     iteration.  For each production which has a LHS in the set of
+     reachable symbols, add the production to the set of reachable
+     productions, and add all of the nonterminals in the RHS of the
+     production to the set of reachable symbols.
+
+     Consider only the (partially) reduced grammar which has only
+     nonterminals in N and productions in P.
+
+     The result is the set P of productions in the reduced grammar,
+     and the set V of symbols in the reduced grammar.
+
+     Although this algorithm also computes the set of terminals which
+     are reachable, no terminal will be deleted from the grammar. Some
+     terminals might not be in the grammar but might be generated by
+     semantic routines, and so the user might want them available with
+     specified numbers.  (Is this true?)  However, the nonreachable
+     terminals are printed (if running in verbose mode) so that the
+     user can know.  */
+
+  Vp = bitset_create (nsyms, BITSET_FIXED);
+  Pp = bitset_create (nrules, BITSET_FIXED);
+
+  /* If the start symbol isn't useful, then nothing will be useful. */
+  if (bitset_test (N, accept->number - ntokens))
+    {
+      bitset_set (V, accept->number);
+
+      while (1)
+	{
+	  rule_number r;
+	  bitset_copy (Vp, V);
+	  for (r = 0; r < nrules; r++)
+	    {
+	      if (!bitset_test (Pp, r)
+		  && bitset_test (P, r)
+		  && bitset_test (V, rules[r].lhs->number))
+		{
+		  item_number *rhsp;
+		  for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
+		    if (ISTOKEN (*rhsp) || bitset_test (N, *rhsp - ntokens))
+		      bitset_set (Vp, *rhsp);
+		  bitset_set (Pp, r);
+		}
+	    }
+	  if (bitset_equal_p (V, Vp))
+	    break;
+	  Vs = Vp;
+	  Vp = V;
+	  V = Vs;
+	}
+    }
+
+  bitset_free (V);
+  V = Vp;
+
+  /* Tokens 0, 1, and 2 are internal to Bison.  Consider them useful. */
+  bitset_set (V, endtoken->number);		/* end-of-input token */
+  bitset_set (V, errtoken->number);		/* error token */
+  bitset_set (V, undeftoken->number);		/* some undefined token */
+
+  bitset_free (P);
+  P = Pp;
+
+  nuseful_productions = bitset_count (P);
+  nuseless_productions = nrules - nuseful_productions;
+
+  nuseful_nonterminals = 0;
+  {
+    symbol_number i;
+    for (i = ntokens; i < nsyms; i++)
+      if (bitset_test (V, i))
+	nuseful_nonterminals++;
+  }
+  nuseless_nonterminals = nvars - nuseful_nonterminals;
+
+  /* A token that was used in %prec should not be warned about.  */
+  {
+    rule_number r;
+    for (r = 0; r < nrules; ++r)
+      if (rules[r].precsym != 0)
+	bitset_set (V1, rules[r].precsym->number);
+  }
+}
+
+
+/*-------------------------------------------------------------------.
+| Put the useless productions at the end of RULES, and adjust NRULES |
+| accordingly.                                                       |
+`-------------------------------------------------------------------*/
+
+static void
+reduce_grammar_tables (void)
+{
+  /* Report and flag useless productions.  */
+  {
+    rule_number r;
+    for (r = 0; r < nrules; r++)
+      rules[r].useful = bitset_test (P, r);
+    grammar_rules_never_reduced_report (_("useless rule"));
+  }
+
+  /* Map the nonterminals to their new index: useful first, useless
+     afterwards.  Kept for later report.  */
+  {
+    int useful = 0;
+    int useless = nrules - nuseless_productions;
+    rule *rules_sorted = xnmalloc (nrules, sizeof *rules_sorted);
+    rule_number r;
+    for (r = 0; r < nrules; ++r)
+      rules_sorted[rules[r].useful ? useful++ : useless++] = rules[r];
+    free (rules);
+    rules = rules_sorted;
+
+    /* Renumber the rules markers in RITEMS.  */
+    for (r = 0; r < nrules; ++r)
+      {
+	item_number *rhsp = rules[r].rhs;
+	for (/* Nothing. */; *rhsp >= 0; ++rhsp)
+	  /* Nothing. */;
+	*rhsp = rule_number_as_item_number (r);
+	rules[r].number = r;
+      }
+    nrules -= nuseless_productions;
+  }
+
+  /* Adjust NRITEMS.  */
+  {
+    rule_number r;
+    int length;
+    for (r = nrules; r < nrules + nuseless_productions; ++r)
+      {
+	length = rule_rhs_length (&rules[r]);
+	nritems -= length + 1;
+      }
+  }
+}
+
+
+/*------------------------------.
+| Remove useless nonterminals.  |
+`------------------------------*/
+
+static void
+nonterminals_reduce (void)
+{
+  symbol_number i, n;
+
+  /* Map the nonterminals to their new index: useful first, useless
+     afterwards.  Kept for later report.  */
+
+  symbol_number *nontermmap = xnmalloc (nvars, sizeof *nontermmap);
+  n = ntokens;
+  for (i = ntokens; i < nsyms; i++)
+    if (bitset_test (V, i))
+      nontermmap[i - ntokens] = n++;
+  for (i = ntokens; i < nsyms; i++)
+    if (!bitset_test (V, i))
+      {
+	nontermmap[i - ntokens] = n++;
+	warn_at (symbols[i]->location, _("useless nonterminal: %s"),
+		 symbols[i]->tag);
+      }
+
+
+  /* Shuffle elements of tables indexed by symbol number.  */
+  {
+    symbol **symbols_sorted = xnmalloc (nvars, sizeof *symbols_sorted);
+
+    for (i = ntokens; i < nsyms; i++)
+      symbols[i]->number = nontermmap[i - ntokens];
+    for (i = ntokens; i < nsyms; i++)
+      symbols_sorted[nontermmap[i - ntokens] - ntokens] = symbols[i];
+    for (i = ntokens; i < nsyms; i++)
+      symbols[i] = symbols_sorted[i - ntokens];
+    free (symbols_sorted);
+  }
+
+  {
+    rule_number r;
+    for (r = 0; r < nrules; ++r)
+      {
+	item_number *rhsp;
+	for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
+	  if (ISVAR (*rhsp))
+	    *rhsp =  symbol_number_as_item_number (nontermmap[*rhsp
+							      - ntokens]);
+      }
+    accept->number = nontermmap[accept->number - ntokens];
+  }
+
+  nsyms -= nuseless_nonterminals;
+  nvars -= nuseless_nonterminals;
+
+  free (nontermmap);
+}
+
+
+/*------------------------------------------------------------------.
+| Output the detailed results of the reductions.  For FILE.output.  |
+`------------------------------------------------------------------*/
+
+void
+reduce_output (FILE *out)
+{
+  if (nuseless_nonterminals > 0)
+    {
+      int i;
+      fprintf (out, "%s\n\n", _("Useless nonterminals"));
+      for (i = 0; i < nuseless_nonterminals; ++i)
+	fprintf (out, "   %s\n", symbols[nsyms + i]->tag);
+      fputs ("\n\n", out);
+    }
+
+  {
+    bool b = false;
+    int i;
+    for (i = 0; i < ntokens; i++)
+      if (!bitset_test (V, i) && !bitset_test (V1, i))
+	{
+	  if (!b)
+	    fprintf (out, "%s\n\n", _("Terminals which are not used"));
+	  b = true;
+	  fprintf (out, "   %s\n", symbols[i]->tag);
+	}
+    if (b)
+      fputs ("\n\n", out);
+  }
+
+  if (nuseless_productions > 0)
+    grammar_rules_partial_print (out, _("Useless rules"),
+				 rule_useless_p);
+}
+
+
+
+
+
+/*-------------------------------.
+| Report the results to STDERR.  |
+`-------------------------------*/
+
+static void
+reduce_print (void)
+{
+  if (yacc_flag && nuseless_productions)
+    fprintf (stderr, ngettext ("%d rule never reduced\n",
+			       "%d rules never reduced\n",
+			       nuseless_productions),
+	     nuseless_productions);
+
+  fprintf (stderr, "%s: %s: ", grammar_file, _("warning"));
+
+  if (nuseless_nonterminals > 0)
+    fprintf (stderr, ngettext ("%d useless nonterminal",
+			       "%d useless nonterminals",
+			       nuseless_nonterminals),
+	     nuseless_nonterminals);
+
+  if (nuseless_nonterminals > 0 && nuseless_productions > 0)
+    fprintf (stderr, _(" and "));
+
+  if (nuseless_productions > 0)
+    fprintf (stderr, ngettext ("%d useless rule",
+			       "%d useless rules",
+			       nuseless_productions),
+	     nuseless_productions);
+  fprintf (stderr, "\n");
+}
+
+void
+reduce_grammar (void)
+{
+  bool reduced;
+
+  /* Allocate the global sets used to compute the reduced grammar */
+
+  N = bitset_create (nvars, BITSET_FIXED);
+  P =  bitset_create (nrules, BITSET_FIXED);
+  V = bitset_create (nsyms, BITSET_FIXED);
+  V1 = bitset_create (nsyms, BITSET_FIXED);
+
+  useless_nonterminals ();
+  inaccessable_symbols ();
+
+  reduced = (nuseless_nonterminals + nuseless_productions > 0);
+  if (!reduced)
+    return;
+
+  reduce_print ();
+
+  if (!bitset_test (N, accept->number - ntokens))
+    fatal_at (startsymbol_location,
+	      _("start symbol %s does not derive any sentence"),
+	      startsymbol->tag);
+
+  /* First reduce the nonterminals, as they renumber themselves in the
+     whole grammar.  If you change the order, nonterms would be
+     renumbered only in the reduced grammar.  */
+  if (nuseless_nonterminals > 0)
+    nonterminals_reduce ();
+  if (nuseless_productions > 0)
+    reduce_grammar_tables ();
+
+  if (trace_flag & trace_grammar)
+    {
+      grammar_dump (stderr, "Reduced Grammar");
+
+      fprintf (stderr, "reduced %s defines %d terminals, %d nonterminals\
+, and %d productions.\n",
+	       grammar_file, ntokens, nvars, nrules);
+    }
+}
+
+
+/*-----------------------------------------------------------.
+| Free the global sets used to compute the reduced grammar.  |
+`-----------------------------------------------------------*/
+
+void
+reduce_free (void)
+{
+  bitset_free (N);
+  bitset_free (V);
+  bitset_free (V1);
+  bitset_free (P);
+}
diff --git a/src/reduce.h b/src/reduce.h
new file mode 100644
index 0000000..dfdab65
--- /dev/null
+++ b/src/reduce.h
@@ -0,0 +1,31 @@
+/* Grammar reduction for Bison.
+
+   Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#ifndef REDUCE_H_
+# define REDUCE_H_
+
+void reduce_grammar (void);
+void reduce_output (FILE *out);
+void reduce_free (void);
+
+extern symbol_number nuseless_nonterminals;
+extern rule_number nuseless_productions;
+#endif /* !REDUCE_H_ */
diff --git a/src/relation.c b/src/relation.c
new file mode 100644
index 0000000..1d2b42d
--- /dev/null
+++ b/src/relation.c
@@ -0,0 +1,183 @@
+/* Binary relations.
+   Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+#include "system.h"
+
+#include <bitsetv.h>
+
+#include "getargs.h"
+#include "relation.h"
+
+void
+relation_print (relation r, relation_node size, FILE *out)
+{
+  relation_node i;
+  relation_node j;
+
+  for (i = 0; i < size; ++i)
+    {
+      fprintf (out, "%3lu: ", (unsigned long int) i);
+      if (r[i])
+	for (j = 0; r[i][j] != END_NODE; ++j)
+	  fprintf (out, "%3lu ", (unsigned long int) r[i][j]);
+      fputc ('\n', out);
+    }
+  fputc ('\n', out);
+}
+
+
+/*---------------------------------------------------------------.
+| digraph & traverse.                                            |
+|                                                                |
+| The following variables are used as common storage between the |
+| two.                                                           |
+`---------------------------------------------------------------*/
+
+static relation R;
+static relation_nodes INDEX;
+static relation_nodes VERTICES;
+static relation_node top;
+static relation_node infinity;
+static bitsetv F;
+
+static void
+traverse (relation_node i)
+{
+  relation_node j;
+  relation_node height;
+
+  VERTICES[++top] = i;
+  INDEX[i] = height = top;
+
+  if (R[i])
+    for (j = 0; R[i][j] != END_NODE; ++j)
+      {
+	if (INDEX[R[i][j]] == 0)
+	  traverse (R[i][j]);
+
+	if (INDEX[i] > INDEX[R[i][j]])
+	  INDEX[i] = INDEX[R[i][j]];
+
+	bitset_or (F[i], F[i], F[R[i][j]]);
+      }
+
+  if (INDEX[i] == height)
+    for (;;)
+      {
+	j = VERTICES[top--];
+	INDEX[j] = infinity;
+
+	if (i == j)
+	  break;
+
+	bitset_copy (F[j], F[i]);
+      }
+}
+
+
+void
+relation_digraph (relation r, relation_node size, bitsetv *function)
+{
+  relation_node i;
+
+  infinity = size + 2;
+  INDEX = xcalloc (size + 1, sizeof *INDEX);
+  VERTICES = xnmalloc (size + 1, sizeof *VERTICES);
+  top = 0;
+
+  R = r;
+  F = *function;
+
+  for (i = 0; i < size; i++)
+    if (INDEX[i] == 0 && R[i])
+      traverse (i);
+
+  free (INDEX);
+  free (VERTICES);
+
+  *function = F;
+}
+
+
+/*-------------------------------------------.
+| Destructively transpose R_ARG, of size N.  |
+`-------------------------------------------*/
+
+void
+relation_transpose (relation *R_arg, relation_node n)
+{
+  relation r = *R_arg;
+  /* The result. */
+  relation new_R = xnmalloc (n, sizeof *new_R);
+  /* END_R[I] -- next entry of NEW_R[I]. */
+  relation end_R = xnmalloc (n, sizeof *end_R);
+  /* NEDGES[I] -- total size of NEW_R[I]. */
+  size_t *nedges = xcalloc (n, sizeof *nedges);
+  relation_node i;
+  relation_node j;
+
+  if (trace_flag & trace_sets)
+    {
+      fputs ("relation_transpose: input\n", stderr);
+      relation_print (r, n, stderr);
+    }
+
+  /* Count. */
+  for (i = 0; i < n; i++)
+    if (r[i])
+      for (j = 0; r[i][j] != END_NODE; ++j)
+	++nedges[r[i][j]];
+
+  /* Allocate. */
+  for (i = 0; i < n; i++)
+    {
+      relation_node *sp = NULL;
+      if (nedges[i] > 0)
+	{
+	  sp = xnmalloc (nedges[i] + 1, sizeof *sp);
+	  sp[nedges[i]] = END_NODE;
+	}
+      new_R[i] = sp;
+      end_R[i] = sp;
+    }
+
+  /* Store. */
+  for (i = 0; i < n; i++)
+    if (r[i])
+      for (j = 0; r[i][j] != END_NODE; ++j)
+	*end_R[r[i][j]]++ = i;
+
+  free (nedges);
+  free (end_R);
+
+  /* Free the input: it is replaced with the result. */
+  for (i = 0; i < n; i++)
+    free (r[i]);
+  free (r);
+
+  if (trace_flag & trace_sets)
+    {
+      fputs ("relation_transpose: output\n", stderr);
+      relation_print (new_R, n, stderr);
+    }
+
+  *R_arg = new_R;
+}
diff --git a/src/relation.h b/src/relation.h
new file mode 100644
index 0000000..479e42e
--- /dev/null
+++ b/src/relation.h
@@ -0,0 +1,50 @@
+/* Binary relations.
+   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+
+#ifndef RELATION_H_
+# define RELATION_H_
+
+/* Performing operations on graphs coded as list of adjacency.
+
+   If GRAPH is a relation, then GRAPH[Node] is a list of adjacent
+   nodes, ended with END_NODE.  */
+
+#define END_NODE ((relation_node) -1)
+
+typedef size_t relation_node;
+typedef relation_node *relation_nodes;
+typedef relation_nodes *relation;
+
+
+/* Report a relation R that has SIZE vertices.  */
+void relation_print (relation r, relation_node size, FILE *out);
+
+/* Compute the transitive closure of the FUNCTION on the relation R
+   with SIZE vertices.
+
+   If R (NODE-1, NODE-2) then on exit FUNCTION[NODE - 1] was extended
+   (unioned) with FUNCTION[NODE - 2].  */
+void relation_digraph (relation r, relation_node size, bitsetv *function);
+
+/* Destructively transpose *R_ARG, of size N.  */
+void relation_transpose (relation *R_arg, relation_node n);
+
+#endif /* ! RELATION_H_ */
diff --git a/src/scan-gram-c.c b/src/scan-gram-c.c
new file mode 100644
index 0000000..8f12e2c
--- /dev/null
+++ b/src/scan-gram-c.c
@@ -0,0 +1,2 @@
+#include <config.h>
+#include "scan-gram.c"
diff --git a/src/scan-gram.c b/src/scan-gram.c
new file mode 100644
index 0000000..04cf539
--- /dev/null
+++ b/src/scan-gram.c
@@ -0,0 +1,3822 @@
+#line 2 "scan-gram.c"
+
+#line 4 "scan-gram.c"
+
+#define  YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+#define YY_FLEX_SUBMINOR_VERSION 31
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+/* %if-c++-only */
+/* %endif */
+
+/* %if-c-only */
+    
+/* %endif */
+
+/* %if-c-only */
+
+/* %endif */
+
+/* First, we deal with  platform-specific or compiler-specific issues. */
+
+/* begin standard C headers. */
+/* %if-c-only */
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+/* %endif */
+
+/* %if-tables-serialization */
+/* %endif */
+/* end standard C headers. */
+
+/* %if-c-or-c++ */
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
+
+#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+#include <inttypes.h>
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t; 
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+#endif /* ! C99 */
+
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN               (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN              (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN              (-2147483647-1)
+#endif
+#ifndef INT8_MAX
+#define INT8_MAX               (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX              (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX              (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX              (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX             (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX             (4294967295U)
+#endif
+
+#endif /* ! FLEXINT_H */
+
+/* %endif */
+
+/* %if-c++-only */
+/* %endif */
+
+#ifdef __cplusplus
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else	/* ! __cplusplus */
+
+#if __STDC__
+
+#define YY_USE_CONST
+
+#endif	/* __STDC__ */
+#endif	/* ! __cplusplus */
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+/* %not-for-header */
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+/* %ok-for-header */
+
+/* %not-for-header */
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index.  If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+/* %ok-for-header */
+
+/* %if-reentrant */
+/* %endif */
+
+/* %if-not-reentrant */
+
+/* %endif */
+
+/* Enter a start condition.  This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN (yy_start) = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state.  The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START (((yy_start) - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE gram_restart(gram_in  )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
+#define YY_BUF_SIZE 16384
+#endif
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+/* %if-not-reentrant */
+extern int gram_leng;
+/* %endif */
+
+/* %if-c-only */
+/* %if-not-reentrant */
+extern FILE *gram_in, *gram_out;
+/* %endif */
+/* %endif */
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+    #define YY_LESS_LINENO(n)
+    
+/* Return all but the first "n" matched characters back to the input stream. */
+#define yyless(n) \
+	do \
+		{ \
+		/* Undo effects of setting up gram_text. */ \
+        int yyless_macro_arg = (n); \
+        YY_LESS_LINENO(yyless_macro_arg);\
+		*yy_cp = (yy_hold_char); \
+		YY_RESTORE_YY_MORE_OFFSET \
+		(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
+		YY_DO_BEFORE_ACTION; /* set up gram_text again */ \
+		} \
+	while ( 0 )
+
+#define unput(c) yyunput( c, (yytext_ptr)  )
+
+/* The following is because we cannot portably get our hands on size_t
+ * (without autoconf's help, which isn't available because we want
+ * flex-generated scanners to compile on their own).
+ */
+
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef unsigned int yy_size_t;
+#endif
+
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
+struct yy_buffer_state
+	{
+/* %if-c-only */
+	FILE *yy_input_file;
+/* %endif */
+
+/* %if-c++-only */
+/* %endif */
+
+	char *yy_ch_buf;		/* input buffer */
+	char *yy_buf_pos;		/* current position in input buffer */
+
+	/* Size of input buffer in bytes, not including room for EOB
+	 * characters.
+	 */
+	yy_size_t yy_buf_size;
+
+	/* Number of characters read into yy_ch_buf, not including EOB
+	 * characters.
+	 */
+	int yy_n_chars;
+
+	/* Whether we "own" the buffer - i.e., we know we created it,
+	 * and can realloc() it to grow it, and should free() it to
+	 * delete it.
+	 */
+	int yy_is_our_buffer;
+
+	/* Whether this is an "interactive" input source; if so, and
+	 * if we're using stdio for input, then we want to use getc()
+	 * instead of fread(), to make sure we stop fetching input after
+	 * each newline.
+	 */
+	int yy_is_interactive;
+
+	/* Whether we're considered to be at the beginning of a line.
+	 * If so, '^' rules will be active on the next match, otherwise
+	 * not.
+	 */
+	int yy_at_bol;
+
+    int yy_bs_lineno; /**< The line count. */
+    int yy_bs_column; /**< The column count. */
+    
+	/* Whether to try to fill the input buffer when we reach the
+	 * end of it.
+	 */
+	int yy_fill_buffer;
+
+	int yy_buffer_status;
+
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+	/* When an EOF's been seen but there's still some text to process
+	 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+	 * shouldn't try reading from the input source any more.  We might
+	 * still have a bunch of tokens to match, though, because of
+	 * possible backing-up.
+	 *
+	 * When we actually see the EOF, we change the status to "new"
+	 * (via gram_restart()), so that the user can continue scanning by
+	 * just pointing gram_in at a new input file.
+	 */
+#define YY_BUFFER_EOF_PENDING 2
+
+	};
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+/* %if-c-only Standard (non-C++) definition */
+/* %not-for-header */
+
+/* %if-not-reentrant */
+
+/* Stack of input buffers. */
+static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
+static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
+static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
+/* %endif */
+/* %ok-for-header */
+
+/* %endif */
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ *
+ * Returns the top of the stack, or NULL.
+ */
+#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
+                          ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
+                          : NULL)
+
+/* Same as previous macro, but useful when we know that the buffer stack is not
+ * NULL or when we need an lvalue. For internal use only.
+ */
+#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
+
+/* %if-c-only Standard (non-C++) definition */
+
+/* %if-not-reentrant */
+/* %not-for-header */
+
+/* yy_hold_char holds the character lost when gram_text is formed. */
+static char yy_hold_char;
+static int yy_n_chars;		/* number of characters read into yy_ch_buf */
+int gram_leng;
+
+/* Points to current character in buffer. */
+static char *yy_c_buf_p = (char *) 0;
+static int yy_init = 1;		/* whether we need to initialize */
+static int yy_start = 0;	/* start state number */
+
+/* Flag which is used to allow gram_wrap()'s to do buffer switches
+ * instead of setting up a fresh gram_in.  A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+/* %ok-for-header */
+
+/* %endif */
+
+void gram_restart (FILE *input_file  );
+void gram__switch_to_buffer (YY_BUFFER_STATE new_buffer  );
+YY_BUFFER_STATE gram__create_buffer (FILE *file,int size  );
+void gram__delete_buffer (YY_BUFFER_STATE b  );
+void gram__flush_buffer (YY_BUFFER_STATE b  );
+void gram_push_buffer_state (YY_BUFFER_STATE new_buffer  );
+void gram_pop_buffer_state (void );
+
+static void gram_ensure_buffer_stack (void );
+static void gram__load_buffer_state (void );
+static void gram__init_buffer (YY_BUFFER_STATE b,FILE *file  );
+
+#define YY_FLUSH_BUFFER gram__flush_buffer(YY_CURRENT_BUFFER )
+
+YY_BUFFER_STATE gram__scan_buffer (char *base,yy_size_t size  );
+YY_BUFFER_STATE gram__scan_string (yyconst char *yy_str  );
+YY_BUFFER_STATE gram__scan_bytes (yyconst char *bytes,int len  );
+
+/* %endif */
+
+void *gram_alloc (yy_size_t  );
+void *gram_realloc (void *,yy_size_t  );
+void gram_free (void *  );
+
+#define yy_new_buffer gram__create_buffer
+
+#define yy_set_interactive(is_interactive) \
+	{ \
+	if ( ! YY_CURRENT_BUFFER ){ \
+        gram_ensure_buffer_stack (); \
+		YY_CURRENT_BUFFER_LVALUE =    \
+            gram__create_buffer(gram_in,YY_BUF_SIZE ); \
+	} \
+	YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
+	}
+
+#define yy_set_bol(at_bol) \
+	{ \
+	if ( ! YY_CURRENT_BUFFER ){\
+        gram_ensure_buffer_stack (); \
+		YY_CURRENT_BUFFER_LVALUE =    \
+            gram__create_buffer(gram_in,YY_BUF_SIZE ); \
+	} \
+	YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
+	}
+
+#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
+
+/* %% [1.0] gram_text/gram_in/gram_out/yy_state_type/gram_lineno etc. def's & init go here */
+/* Begin user sect3 */
+
+#define gram_wrap(n) 1
+#define YY_SKIP_YYWRAP
+
+#define FLEX_DEBUG
+
+typedef unsigned char YY_CHAR;
+
+FILE *gram_in = (FILE *) 0, *gram_out = (FILE *) 0;
+
+typedef int yy_state_type;
+
+extern int gram_lineno;
+
+int gram_lineno = 1;
+
+extern char *gram_text;
+#define yytext_ptr gram_text
+
+/* %if-c-only Standard (non-C++) definition */
+
+static yy_state_type yy_get_previous_state (void );
+static yy_state_type yy_try_NUL_trans (yy_state_type current_state  );
+static int yy_get_next_buffer (void );
+static void yy_fatal_error (yyconst char msg[]  );
+
+/* %endif */
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up gram_text.
+ */
+#define YY_DO_BEFORE_ACTION \
+	(yytext_ptr) = yy_bp; \
+/* %% [2.0] code to fiddle gram_text and gram_leng for yymore() goes here \ */\
+	gram_leng = (size_t) (yy_cp - yy_bp); \
+	(yy_hold_char) = *yy_cp; \
+	*yy_cp = '\0'; \
+/* %% [3.0] code to copy yytext_ptr to gram_text[] goes here, if %array \ */\
+	(yy_c_buf_p) = yy_cp;
+
+/* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */
+#define YY_NUM_RULES 109
+#define YY_END_OF_BUFFER 110
+/* This struct is not used in this scanner,
+   but its presence is necessary. */
+struct yy_trans_info
+	{
+	flex_int32_t yy_verify;
+	flex_int32_t yy_nxt;
+	};
+static yyconst flex_int16_t yy_accept[461] =
+    {   0,
+        0,    0,    0,    0,   66,   66,    0,    0,   84,   84,
+       84,   84,    0,    0,    0,    0,    0,    0,    0,    0,
+        0,    0,    0,    0,    0,    0,  110,   59,    2,    2,
+       54,   59,   53,    1,   50,   59,   51,   51,   49,   59,
+       47,   56,   48,   59,  107,  108,  103,  107,  104,  105,
+      106,   65,  107,   63,   63,   88,   87,  107,   86,   85,
+       61,    2,    1,   61,   60,   61,   68,   67,  107,   71,
+       70,   69,   93,    2,    1,   93,   93,   90,  100,  107,
+       89,  107,  107,  101,   94,   96,  107,   58,   46,   46,
+       46,   46,   46,   46,   46,   46,   46,   46,   46,   46,
+
+       46,   46,   46,   46,   46,   46,   55,   50,    4,    3,
+       51,    0,    0,    0,   64,    0,    0,   66,   62,   84,
+       84,   84,   84,   83,   81,   72,   83,   74,   75,   76,
+       77,   78,   79,   83,   80,   83,   98,    0,   98,    0,
+       95,    0,   91,   92,    0,   94,   97,    0,   99,    0,
+       99,  102,   46,   46,   46,   46,   46,   46,   46,   46,
+       46,   46,   46,   46,   46,   46,   46,   46,   46,   46,
+       46,   46,   46,   46,   46,   46,   46,   46,   46,   46,
+       46,    3,   52,   57,    0,    0,    0,    0,    0,    0,
+        0,    0,   72,    0,    0,   73,    0,    0,    0,    0,
+
+        0,    0,    0,   46,   46,   46,   46,   46,   46,   46,
+       46,   46,   46,   46,   46,   46,   46,   46,   46,   46,
+       46,   46,   46,   46,   46,   46,   46,   46,   46,   46,
+       46,   46,   46,   46,   46,   46,   46,    0,   72,    0,
+        0,    0,   46,   46,   46,   46,   46,   46,   46,   46,
+       46,   46,   46,   46,   20,   46,   46,   46,   46,   46,
+       46,   46,   46,   46,   46,   46,   32,   46,   46,   46,
+       46,   46,   46,   39,   46,   42,   46,   46,   45,    0,
+        0,    0,   46,    7,   46,   46,   46,   12,   46,   46,
+       46,   46,   46,   46,   46,   46,   23,   46,   46,   46,
+
+       46,   46,   29,   46,   46,   46,   46,   46,   36,   46,
+       38,   40,   43,   46,    0,    0,   82,    6,   46,    9,
+       46,   46,   14,   46,   46,   46,   46,   46,   46,   46,
+       46,   46,   46,   46,   30,   46,   46,   46,   46,   46,
+       46,   46,    0,   46,   10,   46,   46,   46,   46,   46,
+       46,   46,   46,   46,   46,   46,   46,   46,   46,   46,
+       33,   46,   35,   46,   46,   44,    0,   46,   46,   46,
+       46,   46,   46,   46,   46,   46,   46,   46,   46,   26,
+       27,   46,   46,   46,   37,   46,    0,   46,   46,   46,
+       15,   46,   46,   46,   46,   21,   22,   46,   46,   46,
+
+       46,   46,   46,    0,    0,   46,   11,   46,   46,   46,
+       19,   46,   46,   46,   46,   46,   46,   46,    5,   46,
+       46,   16,   46,   46,   24,   46,   46,   31,   34,   41,
+        8,   46,   46,   46,   46,   46,   13,   46,   46,   46,
+       46,   46,   18,   46,   46,   46,   25,   46,   46,   46,
+       46,   46,   17,   46,   46,   46,   46,   46,   28,    0
+    } ;
+
+static yyconst flex_int32_t yy_ec[256] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
+        2,    2,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    4,    1,    5,    6,    7,    8,    1,    9,    1,
+        1,   10,    1,   11,   12,   13,   14,   15,   16,   16,
+       16,   16,   16,   16,   16,   17,   17,   18,   19,   20,
+       21,   22,   23,   24,   25,   25,   25,   25,   25,   25,
+       13,   13,   13,   13,   13,   13,   13,   13,   13,   13,
+       13,   13,   13,   13,   26,   13,   13,   27,   13,   13,
+       28,   29,   30,    1,   31,    1,   32,   33,   34,   35,
+
+       36,   37,   38,   39,   40,   13,   41,   42,   43,   44,
+       45,   46,   47,   48,   49,   50,   51,   52,   13,   53,
+       54,   13,   55,   56,   57,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1
+    } ;
+
+static yyconst flex_int32_t yy_meta[59] =
+    {   0,
+        1,    1,    2,    1,    1,    1,    3,    1,    1,    1,
+        1,    4,    5,    1,    6,    6,    6,    1,    1,    1,
+        1,    7,    1,    3,    6,    5,    5,    3,    1,    3,
+        5,    6,    6,    6,    6,    6,    6,    5,    5,    5,
+        5,    5,    5,    5,    5,    5,    5,    5,    5,    5,
+        5,    5,    5,    5,    1,    1,    1,    7
+    } ;
+
+static yyconst flex_int16_t yy_base[483] =
+    {   0,
+        0,  733,   56,   57,   65,   68,  728,  727,   96,   99,
+      106,  109,  138,  144,   85,  102,  142,  150,  161,  174,
+      206,    0,  162,  182,  220,  225,  736,  740,  740,  740,
+      740,  275,  740,  740,    0,   51,  176,   61,  740,    0,
+      740,  740,  740,  693,  740,  740,  740,  103,  740,  740,
+      740,  740,  164,  740,  720,  740,  740,  192,  740,  740,
+      740,  740,  740,   59,  740,  691,  740,  740,  326,  740,
+      740,  740,  740,  740,  740,   60,  690,  740,  231,  132,
+      740,  187,   71,  243,  740,  740,  674,  740,    0,  690,
+       75,  151,  689,  686,  683,   74,  690,  173,  674,  220,
+
+      147,  157,  220,  680,  687,  690,  740,    0,  740,    0,
+      269,    0,  699,  680,  740,  287,  290,  690,  740,  740,
+      293,  689,  301,  740,  740,   67,    0,  740,  740,  740,
+      740,  740,  740,    0,  740,    0,  740,  317,  321,    0,
+      740,  341,  740,  740,  344,  740,  740,  358,  740,  349,
+      352,  740,    0,  673,  220,  668,  667,  668,  131,  665,
+      672,  188,  677,  662,  666,  223,  672,  657,  658,  226,
+      657,  657,  665,  666,  669,  652,  658,  652,  657,  648,
+      661,    0,    0,  740,  650,  369,  250,  378,  381,  384,
+      387,  269,  324,    0,    0,    0,  671,  390,  152,  393,
+
+      388,  397,  202,  660,  640,  238,  640,  653,  643,  651,
+      650,  649,  672,  633,  632,  669,  648,  641,  642,  315,
+      241,  629,  630,  626,  640,  629,  636,  620,  631,  627,
+      620,  624,  630,  629,  619,  630,  628,  625,  740,    0,
+        0,  396,  612,  621,  607,  613,  608,  621,  606,  619,
+      640,  616,  604,  609,    0,  602,  597,  610,  344,  609,
+      604,  594,  606,  598,  589,  603,    0,  588,  392,  597,
+      586,  599,  584,    0,  589,    0,  588,  586,    0,  626,
+        0,    0,  575,    0,  586,  591,  575,    0,  393,  575,
+      578,  394,  591,  590,  589,  580,    0,  573,  581,  573,
+
+      567,  565,    0,  564,  601,  576,  565,  562,    0,  559,
+        0,  395,    0,  559,  399,    0,  740,    0,  557,  557,
+      571,  552,  397,  555,  557,  553,  558,  551,  553,  549,
+      564,  559,  549,  557,    0,  546,  543,  558,  553,  543,
+      537,  550,  414,  407,    0,  535,  548,  535,  546,  530,
+      531,  567,  546,  533,  540,  524,  525,  539,  524,  539,
+        0,  522,    0,  525,  536,    0,  562,  520,  520,  516,
+      515,  525,  511,  524,  527,  515,  508,  519,  513,    0,
+        0,  511,  505,  503,    0,  518,  545,  501,  500,  514,
+        0,  506,  499,  496,  509,    0,    0,  502,  491,  500,
+
+      507,  502,  495,  531,  348,  499,    0,  489,  480,  481,
+        0,  481,  477,  408,  485,  485,  479,  490,  740,  491,
+      475,    0,  473,  482,    0,  475,  480,    0,    0,    0,
+        0,  483,  409,  473,  469,  467,    0,  478,  470,  472,
+      452,  455,    0,  445,  432,  395,    0,  402,  399,  422,
+      384,  386,    0,  395,  374,  361,  318,  251,    0,  740,
+      440,  447,  454,  461,  464,  470,  476,  483,  487,  493,
+      281,  275,  236,  218,  500,  206,  151,  138,  116,  102,
+       56,  506
+    } ;
+
+static yyconst flex_int16_t yy_def[483] =
+    {   0,
+      460,    1,  461,  461,  461,  461,  462,  462,  461,  461,
+      461,  461,  463,  463,  461,  461,  461,  461,  464,  464,
+      461,   21,   21,   21,   21,   21,  460,  460,  460,  460,
+      460,  460,  460,  460,  465,  460,  460,  460,  460,  466,
+      460,  460,  460,  460,  460,  460,  460,  460,  460,  460,
+      460,  460,  460,  460,  460,  460,  460,  467,  460,  460,
+      460,  460,  460,  460,  460,  460,  460,  460,  468,  460,
+      460,  460,  460,  460,  460,  460,  460,  460,  460,  460,
+      460,  460,  460,  460,  460,  460,  460,  460,  469,  469,
+      469,  469,  469,  469,  469,  469,  469,  469,  469,  469,
+
+      469,  469,  469,  469,  469,  469,  460,  465,  460,  470,
+      460,  471,  466,  460,  460,  460,  460,  460,  460,  460,
+      460,  460,  460,  460,  460,  460,  472,  460,  460,  460,
+      460,  460,  460,  473,  460,  474,  460,  460,  460,  475,
+      460,  460,  460,  460,  460,  460,  460,  460,  460,  460,
+      460,  460,  469,  469,  469,  469,  469,  469,  469,  469,
+      469,  469,  469,  469,  469,  469,  469,  469,  469,  469,
+      469,  469,  469,  469,  469,  469,  469,  469,  469,  469,
+      469,  470,  471,  460,  460,  460,  460,  460,  460,  460,
+      460,  467,  460,  476,  477,  474,  475,  460,  460,  460,
+
+      460,  460,  460,  469,  469,  469,  469,  469,  469,  469,
+      469,  469,  469,  469,  469,  469,  469,  469,  469,  469,
+      469,  469,  469,  469,  469,  469,  469,  469,  469,  469,
+      469,  469,  469,  469,  469,  469,  469,  460,  460,  478,
+      479,  460,  469,  469,  469,  469,  469,  469,  469,  469,
+      469,  469,  469,  469,  469,  469,  469,  469,  469,  469,
+      469,  469,  469,  469,  469,  469,  469,  469,  469,  469,
+      469,  469,  469,  469,  469,  469,  469,  469,  469,  460,
+      480,  481,  469,  469,  469,  469,  469,  469,  469,  469,
+      469,  469,  469,  469,  469,  469,  469,  469,  469,  469,
+
+      469,  469,  469,  469,  469,  469,  469,  469,  469,  469,
+      469,  469,  469,  469,  460,  473,  460,  469,  469,  469,
+      469,  469,  469,  469,  469,  469,  469,  469,  469,  469,
+      469,  469,  469,  469,  469,  469,  469,  469,  469,  469,
+      469,  469,  460,  469,  469,  469,  469,  469,  469,  469,
+      469,  469,  469,  469,  469,  469,  469,  469,  469,  469,
+      469,  469,  469,  469,  469,  469,  460,  469,  469,  469,
+      469,  469,  469,  469,  469,  469,  469,  469,  469,  469,
+      469,  469,  469,  469,  469,  469,  482,  469,  469,  469,
+      469,  469,  469,  469,  469,  469,  469,  469,  469,  469,
+
+      469,  469,  469,  482,  482,  469,  469,  469,  469,  469,
+      469,  469,  469,  469,  469,  469,  469,  469,  460,  469,
+      469,  469,  469,  469,  469,  469,  469,  469,  469,  469,
+      469,  469,  469,  469,  469,  469,  469,  469,  469,  469,
+      469,  469,  469,  469,  469,  469,  469,  469,  469,  469,
+      469,  469,  469,  469,  469,  469,  469,  469,  469,    0,
+      460,  460,  460,  460,  460,  460,  460,  460,  460,  460,
+      460,  460,  460,  460,  460,  460,  460,  460,  460,  460,
+      460,  460
+    } ;
+
+static yyconst flex_int16_t yy_nxt[799] =
+    {   0,
+       28,   29,   30,   29,   31,   28,   28,   32,   33,   28,
+       34,   28,   35,   36,   37,   38,   38,   28,   39,   40,
+       41,   28,   28,   28,   35,   35,   35,   28,   28,   28,
+       35,   35,   35,   35,   35,   35,   35,   35,   35,   35,
+       35,   35,   35,   35,   35,   35,   35,   35,   35,   35,
+       35,   35,   35,   35,   42,   43,   28,   28,   46,   46,
+      109,  317,   47,   47,  110,   48,   48,   52,  109,  109,
+       52,   47,  110,  110,   47,  111,  111,  111,  146,   49,
+       49,  193,  193,   50,   50,   51,   51,   67,   49,   68,
+      147,   49,   50,   53,   51,   50,   53,   51,   56,  148,
+
+       57,   56,   47,   57,   67,   47,   68,  316,   59,  162,
+      155,   59,   47,   69,   60,   47,  115,   60,  163,   49,
+      156,  282,   49,   50,   58,   51,   50,   58,   51,   49,
+       69,  116,   49,   50,   58,   51,   50,   58,   51,   62,
+       30,   62,   70,  281,   71,   62,   30,   62,   63,   66,
+       72,   64,   71,  141,   63,   65,  241,   64,   72,   70,
+      142,   65,   74,   30,   74,  117,  118,  117,   47,   87,
+       69,   75,  211,  141,   76,   74,   30,   74,   69,   77,
+      142,   45,  172,  212,   75,   49,  173,   76,   47,   87,
+      111,  111,  111,  121,  122,  121,  143,  174,  157,   70,
+
+      144,   45,  112,  158,  165,   49,  175,   70,   46,  146,
+       78,  240,   79,   80,   81,  145,   45,  166,   45,   82,
+      123,  147,  167,  196,  215,   83,   47,   45,  112,   84,
+      148,   47,   45,   50,  220,   51,   45,  137,   45,   45,
+      216,  195,  138,   49,   45,  139,  139,  139,   49,  149,
+      140,  169,  205,  220,  150,  176,  206,  151,  151,  151,
+       85,  225,   86,  115,  177,  226,  221,  170,  207,  245,
+      171,  460,  262,  178,   45,  263,   45,  246,  116,   45,
+      194,   45,   88,  111,  111,  111,  183,   89,  186,  187,
+      186,  117,  118,  117,  189,  122,  189,  123,  459,   89,
+
+       89,   89,  191,  192,  191,   89,   89,   90,   89,   91,
+       92,   93,   94,   89,   95,   89,   96,   97,   98,   99,
+      100,   89,  101,  102,  103,  104,  105,   89,  106,  107,
+      125,  139,  139,  139,  125,  139,  139,  139,  239,  239,
+      126,  126,  198,  199,  198,  200,  201,  200,  125,  260,
+      419,  127,  405,  458,  125,  298,  261,  128,  129,  202,
+      203,  202,  130,  151,  151,  151,  151,  151,  151,  131,
+      186,  187,  186,  132,  298,  133,  134,  135,  136,  117,
+      118,  117,  189,  122,  189,  189,  122,  189,  191,  192,
+      191,  198,  199,  198,  200,  201,  200,  143,  202,  203,
+
+      202,  144,  137,  307,  322,  325,  341,  138,  348,  457,
+      139,  139,  139,  343,  343,  343,  145,  367,  368,  426,
+      438,  456,  307,  322,  325,  341,  455,  348,  343,  343,
+      343,  454,  453,  452,  451,  450,  449,  368,  426,  438,
+       45,   45,   45,   45,   45,   45,   45,   54,   54,   54,
+       54,   54,   54,   54,   61,   61,   61,   61,   61,   61,
+       61,   73,   73,   73,   73,   73,   73,   73,  108,  108,
+      113,  448,  113,  113,  113,  113,  120,  120,  447,  120,
+      120,  120,  120,  124,  124,  124,  124,  124,  124,  124,
+      153,  153,  153,  182,  446,  182,  182,  182,  182,  182,
+
+      197,  445,  197,  197,  197,  197,  404,  444,  404,  404,
+      404,  404,  404,  443,  442,  441,  440,  439,  437,  436,
+      435,  434,  433,  432,  431,  430,  429,  428,  427,  425,
+      424,  423,  422,  421,  420,  405,  418,  417,  416,  415,
+      414,  413,  412,  411,  410,  409,  408,  407,  406,  405,
+      403,  402,  401,  400,  399,  398,  397,  396,  395,  394,
+      393,  392,  391,  390,  389,  388,  387,  386,  385,  384,
+      383,  382,  381,  380,  379,  378,  377,  376,  375,  374,
+      373,  372,  371,  370,  369,  366,  365,  364,  363,  362,
+      361,  360,  359,  358,  357,  356,  355,  354,  353,  352,
+
+      351,  350,  349,  347,  346,  345,  344,  342,  340,  339,
+      338,  337,  336,  335,  334,  333,  332,  331,  330,  329,
+      328,  327,  326,  324,  323,  321,  320,  319,  318,  315,
+      314,  313,  312,  311,  310,  309,  308,  306,  305,  304,
+      303,  302,  301,  300,  299,  297,  296,  295,  294,  293,
+      292,  291,  290,  289,  288,  287,  286,  285,  284,  283,
+      280,  279,  278,  277,  276,  275,  274,  273,  272,  271,
+      270,  269,  268,  267,  266,  265,  264,  259,  258,  257,
+      256,  255,  254,  253,  252,  251,  250,  249,  248,  247,
+      244,  243,  242,  238,  237,  236,  235,  234,  233,  232,
+
+      231,  230,  229,  228,  227,  224,  223,  222,  219,  218,
+      217,  214,  213,  210,  209,  208,  204,  190,  188,  185,
+      184,  181,  180,  179,  168,  164,  161,  160,  159,  154,
+      152,  114,  114,  119,  114,  460,   55,   55,   44,   27,
+      460,  460,  460,  460,  460,  460,  460,  460,  460,  460,
+      460,  460,  460,  460,  460,  460,  460,  460,  460,  460,
+      460,  460,  460,  460,  460,  460,  460,  460,  460,  460,
+      460,  460,  460,  460,  460,  460,  460,  460,  460,  460,
+      460,  460,  460,  460,  460,  460,  460,  460,  460,  460,
+      460,  460,  460,  460,  460,  460,  460,  460
+
+    } ;
+
+static yyconst flex_int16_t yy_chk[799] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    3,    4,
+       36,  481,    3,    4,   36,    3,    4,    5,   64,   76,
+        6,    5,   64,   76,    6,   38,   38,   38,   83,    3,
+        4,  126,  126,    3,    4,    3,    4,   15,    5,   15,
+       83,    6,    5,    5,    5,    6,    6,    6,    9,   83,
+
+        9,   10,    9,   10,   16,   10,   16,  480,   11,   96,
+       91,   12,   11,   15,   11,   12,   48,   12,   96,    9,
+       91,  479,   10,    9,    9,    9,   10,   10,   10,   11,
+       16,   48,   12,   11,   11,   11,   12,   12,   12,   13,
+       13,   13,   15,  478,   17,   14,   14,   14,   13,   14,
+       17,   13,   18,   80,   14,   13,  477,   14,   18,   16,
+       80,   14,   19,   19,   19,   53,   53,   53,   23,   23,
+       17,   19,  159,  199,   19,   20,   20,   20,   18,   20,
+      199,   23,  101,  159,   20,   23,  101,   20,   24,   24,
+       37,   37,   37,   58,   58,   58,   82,  102,   92,   17,
+
+       82,   24,   37,   92,   98,   24,  102,   18,   21,  203,
+       21,  476,   21,   21,   21,   82,   23,   98,   23,   21,
+       58,  203,   98,  474,  162,   21,   25,   25,   37,   21,
+      203,   26,   26,   21,  166,   21,   24,   79,   24,   25,
+      162,  473,   79,   25,   26,   79,   79,   79,   26,   84,
+       79,  100,  155,  166,   84,  103,  155,   84,   84,   84,
+       21,  170,   21,  187,  103,  170,  166,  100,  155,  206,
+      100,  192,  221,  103,   25,  221,   25,  206,  187,   26,
+      472,   26,   32,  111,  111,  111,  471,   32,  116,  116,
+      116,  117,  117,  117,  121,  121,  121,  192,  458,   32,
+
+       32,   32,  123,  123,  123,   32,   32,   32,   32,   32,
+       32,   32,   32,   32,   32,   32,   32,   32,   32,   32,
+       32,   32,   32,   32,   32,   32,   32,   32,   32,   32,
+       69,  138,  138,  138,   69,  139,  139,  139,  193,  193,
+       69,   69,  142,  142,  142,  145,  145,  145,   69,  220,
+      405,   69,  405,  457,   69,  259,  220,   69,   69,  148,
+      148,  148,   69,  150,  150,  150,  151,  151,  151,   69,
+      186,  186,  186,   69,  259,   69,   69,   69,   69,  188,
+      188,  188,  189,  189,  189,  190,  190,  190,  191,  191,
+      191,  198,  198,  198,  200,  200,  200,  201,  202,  202,
+
+      202,  201,  242,  269,  289,  292,  312,  242,  323,  456,
+      242,  242,  242,  315,  315,  315,  201,  343,  344,  414,
+      433,  455,  269,  289,  292,  312,  454,  323,  343,  343,
+      343,  452,  451,  450,  449,  448,  446,  344,  414,  433,
+      461,  461,  461,  461,  461,  461,  461,  462,  462,  462,
+      462,  462,  462,  462,  463,  463,  463,  463,  463,  463,
+      463,  464,  464,  464,  464,  464,  464,  464,  465,  465,
+      466,  445,  466,  466,  466,  466,  467,  467,  444,  467,
+      467,  467,  467,  468,  468,  468,  468,  468,  468,  468,
+      469,  469,  469,  470,  442,  470,  470,  470,  470,  470,
+
+      475,  441,  475,  475,  475,  475,  482,  440,  482,  482,
+      482,  482,  482,  439,  438,  436,  435,  434,  432,  427,
+      426,  424,  423,  421,  420,  418,  417,  416,  415,  413,
+      412,  410,  409,  408,  406,  404,  403,  402,  401,  400,
+      399,  398,  395,  394,  393,  392,  390,  389,  388,  387,
+      386,  384,  383,  382,  379,  378,  377,  376,  375,  374,
+      373,  372,  371,  370,  369,  368,  367,  365,  364,  362,
+      360,  359,  358,  357,  356,  355,  354,  353,  352,  351,
+      350,  349,  348,  347,  346,  342,  341,  340,  339,  338,
+      337,  336,  334,  333,  332,  331,  330,  329,  328,  327,
+
+      326,  325,  324,  322,  321,  320,  319,  314,  310,  308,
+      307,  306,  305,  304,  302,  301,  300,  299,  298,  296,
+      295,  294,  293,  291,  290,  287,  286,  285,  283,  280,
+      278,  277,  275,  273,  272,  271,  270,  268,  266,  265,
+      264,  263,  262,  261,  260,  258,  257,  256,  254,  253,
+      252,  251,  250,  249,  248,  247,  246,  245,  244,  243,
+      238,  237,  236,  235,  234,  233,  232,  231,  230,  229,
+      228,  227,  226,  225,  224,  223,  222,  219,  218,  217,
+      216,  215,  214,  213,  212,  211,  210,  209,  208,  207,
+      205,  204,  197,  185,  181,  180,  179,  178,  177,  176,
+
+      175,  174,  173,  172,  171,  169,  168,  167,  165,  164,
+      163,  161,  160,  158,  157,  156,  154,  122,  118,  114,
+      113,  106,  105,  104,   99,   97,   95,   94,   93,   90,
+       87,   77,   66,   55,   44,   27,    8,    7,    2,  460,
+      460,  460,  460,  460,  460,  460,  460,  460,  460,  460,
+      460,  460,  460,  460,  460,  460,  460,  460,  460,  460,
+      460,  460,  460,  460,  460,  460,  460,  460,  460,  460,
+      460,  460,  460,  460,  460,  460,  460,  460,  460,  460,
+      460,  460,  460,  460,  460,  460,  460,  460,  460,  460,
+      460,  460,  460,  460,  460,  460,  460,  460
+
+    } ;
+
+static yy_state_type yy_last_accepting_state;
+static char *yy_last_accepting_cpos;
+
+extern int gram__flex_debug;
+int gram__flex_debug = 1;
+
+static yyconst flex_int16_t yy_rule_linenum[109] =
+    {   0,
+      197,  198,  199,  200,  208,  219,  220,  221,  222,  223,
+      224,  225,  226,  227,  228,  229,  230,  231,  232,  233,
+      234,  235,  236,  237,  238,  239,  240,  241,  242,  243,
+      244,  245,  246,  247,  248,  249,  250,  251,  252,  253,
+      254,  255,  256,  257,  258,  260,  264,  265,  266,  268,
+      275,  279,  285,  288,  291,  294,  305,  313,  320,  337,
+      343,  364,  365,  376,  387,  388,  400,  408,  419,  435,
+      441,  451,  461,  472,  473,  474,  475,  476,  477,  478,
+      481,  483,  492,  504,  509,  510,  516,  517,  528,  534,
+      540,  546,  562,  596,  597,  598,  634,  636,  637,  639,
+
+      643,  658,  693,  694,  695,  696,  704,  705
+    } ;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+char *gram_text;
+#line 1 "scan-gram.l"
+/* Bison Grammar Scanner                             -*- C -*-
+
+   Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   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 2 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, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301  USA
+*/
+#line 27 "scan-gram.l"
+/* Work around a bug in flex 2.5.31.  See Debian bug 333231
+   <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=333231>.  */
+#undef gram_wrap
+#define gram_wrap() 1
+
+#include "system.h"
+
+#include <mbswidth.h>
+#include <quote.h>
+
+#include "complain.h"
+#include "files.h"
+#include "getargs.h"
+#include "gram.h"
+#include "quotearg.h"
+#include "reader.h"
+#include "uniqstr.h"
+
+#define YY_USER_INIT					\
+  do							\
+    {							\
+      scanner_cursor.file = current_file;		\
+      scanner_cursor.line = 1;				\
+      scanner_cursor.column = 1;			\
+      code_start = scanner_cursor;			\
+    }							\
+  while (0)
+
+/* Pacify "gcc -Wmissing-prototypes" when flex 2.5.31 is used.  */
+int gram_get_lineno (void);
+FILE *gram_get_in (void);
+FILE *gram_get_out (void);
+int gram_get_leng (void);
+char *gram_get_text (void);
+void gram_set_lineno (int);
+void gram_set_in (FILE *);
+void gram_set_out (FILE *);
+int gram_get_debug (void);
+void gram_set_debug (int);
+int gram_lex_destroy (void);
+
+/* Location of scanner cursor.  */
+boundary scanner_cursor;
+
+static void adjust_location (location *, char const *, size_t);
+#define YY_USER_ACTION  adjust_location (loc, gram_text, gram_leng);
+
+static size_t no_cr_read (FILE *, char *, size_t);
+#define YY_INPUT(buf, result, size) ((result) = no_cr_read (gram_in, buf, size))
+
+
+/* OBSTACK_FOR_STRING -- Used to store all the characters that we need to
+   keep (to construct ID, STRINGS etc.).  Use the following macros to
+   use it.
+
+   Use STRING_GROW to append what has just been matched, and
+   STRING_FINISH to end the string (it puts the ending 0).
+   STRING_FINISH also stores this string in LAST_STRING, which can be
+   used, and which is used by STRING_FREE to free the last string.  */
+
+static struct obstack obstack_for_string;
+
+/* A string representing the most recently saved token.  */
+char *last_string;
+
+/* The location of the most recently saved token, if it was a
+   BRACED_CODE token; otherwise, this has an unspecified value.  */
+location last_braced_code_loc;
+
+#define STRING_GROW   \
+  obstack_grow (&obstack_for_string, gram_text, gram_leng)
+
+#define STRING_FINISH					\
+  do {							\
+    obstack_1grow (&obstack_for_string, '\0');		\
+    last_string = obstack_finish (&obstack_for_string);	\
+  } while (0)
+
+#define STRING_FREE \
+  obstack_free (&obstack_for_string, last_string)
+
+void
+scanner_last_string_free (void)
+{
+  STRING_FREE;
+}
+
+/* Within well-formed rules, RULE_LENGTH is the number of values in
+   the current rule so far, which says where to find `$0' with respect
+   to the top of the stack.  It is not the same as the rule->length in
+   the case of mid rule actions.
+
+   Outside of well-formed rules, RULE_LENGTH has an undefined value.  */
+static int rule_length;
+
+static void rule_length_overflow (location) __attribute__ ((__noreturn__));
+
+/* Increment the rule length by one, checking for overflow.  */
+static inline void
+increment_rule_length (location loc)
+{
+  rule_length++;
+
+  /* Don't allow rule_length == INT_MAX, since that might cause
+     confusion with strtol if INT_MAX == LONG_MAX.  */
+  if (rule_length == INT_MAX)
+    rule_length_overflow (loc);
+}
+
+static void handle_dollar (int token_type, char *cp, location loc);
+static void handle_at (int token_type, char *cp, location loc);
+static void handle_syncline (char *, location);
+static unsigned long int scan_integer (char const *p, int base, location loc);
+static int convert_ucn_to_byte (char const *hex_text);
+static void unexpected_eof (boundary, char const *);
+static void unexpected_newline (boundary, char const *);
+
+
+
+
+
+
+/* POSIX says that a tag must be both an id and a C union member, but
+   historically almost any character is allowed in a tag.  We disallow
+   NUL and newline, as this simplifies our implementation.  */
+/* Zero or more instances of backslash-newline.  Following GCC, allow
+   white space between the backslash and the newline.  */
+#line 1016 "scan-gram.c"
+
+#define INITIAL 0
+#define SC_COMMENT 1
+#define SC_LINE_COMMENT 2
+#define SC_YACC_COMMENT 3
+#define SC_STRING 4
+#define SC_CHARACTER 5
+#define SC_AFTER_IDENTIFIER 6
+#define SC_ESCAPED_STRING 7
+#define SC_ESCAPED_CHARACTER 8
+#define SC_PRE_CODE 9
+#define SC_BRACED_CODE 10
+#define SC_PROLOGUE 11
+#define SC_EPILOGUE 12
+
+#ifndef YY_NO_UNISTD_H
+/* Special case for "unistd.h", since it is non-ANSI. We include it way
+ * down here because we want the user's section 1 to have been scanned first.
+ * The user has a chance to override it with an option.
+ */
+/* %if-c-only */
+#include <unistd.h>
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+#endif
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+/* %if-c-only Reentrant structure and macros (non-C++). */
+/* %if-reentrant */
+/* %if-reentrant */
+/* %endif */
+/* %if-bison-bridge */
+/* %endif */
+/* %endif End reentrant structures and macros. */
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int gram_wrap (void );
+#else
+extern int gram_wrap (void );
+#endif
+#endif
+
+/* %not-for-header */
+
+/* %ok-for-header */
+
+/* %endif */
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char *,yyconst char *,int );
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * );
+#endif
+
+#ifndef YY_NO_INPUT
+/* %if-c-only Standard (non-C++) definition */
+/* %not-for-header */
+
+#ifdef __cplusplus
+static int yyinput (void );
+#else
+static int input (void );
+#endif
+/* %ok-for-header */
+
+/* %endif */
+#endif
+
+/* %if-c-only */
+
+/* %endif */
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#define YY_READ_BUF_SIZE 8192
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+#ifndef ECHO
+/* %if-c-only Standard (non-C++) definition */
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO (void) fwrite( gram_text, gram_leng, 1, gram_out )
+/* %endif */
+/* %if-c++-only C++ definition */
+/* %endif */
+#endif
+
+/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+/* %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ */\
+	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
+		{ \
+		int c = '*'; \
+		size_t n; \
+		for ( n = 0; n < max_size && \
+			     (c = getc( gram_in )) != EOF && c != '\n'; ++n ) \
+			buf[n] = (char) c; \
+		if ( c == '\n' ) \
+			buf[n++] = (char) c; \
+		if ( c == EOF && ferror( gram_in ) ) \
+			YY_FATAL_ERROR( "input in flex scanner failed" ); \
+		result = n; \
+		} \
+	else \
+		{ \
+		errno=0; \
+		while ( (result = fread(buf, 1, max_size, gram_in))==0 && ferror(gram_in)) \
+			{ \
+			if( errno != EINTR) \
+				{ \
+				YY_FATAL_ERROR( "input in flex scanner failed" ); \
+				break; \
+				} \
+			errno=0; \
+			clearerr(gram_in); \
+			} \
+		}\
+\
+/* %if-c++-only C++ definition \ */\
+/* %endif */
+
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+/* %if-c-only */
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+#endif
+
+/* %if-tables-serialization structures and prototypes */
+/* %not-for-header */
+
+/* %ok-for-header */
+
+/* %not-for-header */
+
+/* %tables-yydmap generated elements */
+/* %endif */
+/* end tables serialization structures and prototypes */
+
+/* %ok-for-header */
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+/* %if-c-only Standard (non-C++) definition */
+
+extern int gram_lex (void);
+
+#define YY_DECL int gram_lex (void)
+/* %endif */
+/* %if-c++-only C++ definition */
+/* %endif */
+#endif /* !YY_DECL */
+
+/* Code executed at the beginning of each rule, after gram_text and gram_leng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+/* %% [6.0] YY_RULE_SETUP definition goes here */
+#define YY_RULE_SETUP \
+	if ( gram_leng > 0 ) \
+		YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \
+				(gram_text[gram_leng - 1] == '\n'); \
+	YY_USER_ACTION
+
+/* %not-for-header */
+
+/** The main scanner function which does all the work.
+ */
+YY_DECL
+{
+	register yy_state_type yy_current_state;
+	register char *yy_cp, *yy_bp;
+	register int yy_act;
+    
+/* %% [7.0] user's declarations go here */
+#line 165 "scan-gram.l"
+
+
+  /* Nesting level of the current code in braces.  */
+  int braces_level IF_LINT (= 0);
+
+  /* Parent context state, when applicable.  */
+  int context_state IF_LINT (= 0);
+
+  /* Token type to return, when applicable.  */
+  int token_type IF_LINT (= 0);
+
+  /* Location of most recent identifier, when applicable.  */
+  location id_loc IF_LINT (= empty_location);
+
+  /* Where containing code started, when applicable.  Its initial
+     value is relevant only when gram_lex is invoked in the SC_EPILOGUE
+     start condition.  */
+  boundary code_start = scanner_cursor;
+
+  /* Where containing comment or string or character literal started,
+     when applicable.  */
+  boundary token_start IF_LINT (= scanner_cursor);
+
+
+
+  /*-----------------------.
+  | Scanning white space.  |
+  `-----------------------*/
+
+#line 1266 "scan-gram.c"
+
+	if ( (yy_init) )
+		{
+		(yy_init) = 0;
+
+#ifdef YY_USER_INIT
+		YY_USER_INIT;
+#endif
+
+		if ( ! (yy_start) )
+			(yy_start) = 1;	/* first start state */
+
+		if ( ! gram_in )
+/* %if-c-only */
+			gram_in = stdin;
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+
+		if ( ! gram_out )
+/* %if-c-only */
+			gram_out = stdout;
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+
+		if ( ! YY_CURRENT_BUFFER ) {
+			gram_ensure_buffer_stack ();
+			YY_CURRENT_BUFFER_LVALUE =
+				gram__create_buffer(gram_in,YY_BUF_SIZE );
+		}
+
+		gram__load_buffer_state( );
+		}
+
+	while ( 1 )		/* loops until end-of-file is reached */
+		{
+/* %% [8.0] yymore()-related code goes here */
+		yy_cp = (yy_c_buf_p);
+
+		/* Support of gram_text. */
+		*yy_cp = (yy_hold_char);
+
+		/* yy_bp points to the position in yy_ch_buf of the start of
+		 * the current run.
+		 */
+		yy_bp = yy_cp;
+
+/* %% [9.0] code to set up and find next match goes here */
+		yy_current_state = (yy_start);
+		yy_current_state += YY_AT_BOL();
+yy_match:
+		do
+			{
+			register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+			if ( yy_accept[yy_current_state] )
+				{
+				(yy_last_accepting_state) = yy_current_state;
+				(yy_last_accepting_cpos) = yy_cp;
+				}
+			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+				{
+				yy_current_state = (int) yy_def[yy_current_state];
+				if ( yy_current_state >= 461 )
+					yy_c = yy_meta[(unsigned int) yy_c];
+				}
+			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+			++yy_cp;
+			}
+		while ( yy_current_state != 460 );
+		yy_cp = (yy_last_accepting_cpos);
+		yy_current_state = (yy_last_accepting_state);
+
+yy_find_action:
+/* %% [10.0] code to find the action number goes here */
+		yy_act = yy_accept[yy_current_state];
+
+		YY_DO_BEFORE_ACTION;
+
+/* %% [11.0] code for gram_lineno update goes here */
+
+do_action:	/* This label is used only to access EOF actions. */
+
+/* %% [12.0] debug code goes here */
+		if ( gram__flex_debug )
+			{
+			if ( yy_act == 0 )
+				fprintf( stderr, "--scanner backing up\n" );
+			else if ( yy_act < 109 )
+				fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n",
+				         (long)yy_rule_linenum[yy_act], gram_text );
+			else if ( yy_act == 109 )
+				fprintf( stderr, "--accepting default rule (\"%s\")\n",
+				         gram_text );
+			else if ( yy_act == 110 )
+				fprintf( stderr, "--(end of buffer or a NUL)\n" );
+			else
+				fprintf( stderr, "--EOF (start condition %d)\n", YY_START );
+			}
+
+		switch ( yy_act )
+	{ /* beginning of action switch */
+/* %% [13.0] actions go here */
+			case 0: /* must back up */
+			/* undo the effects of YY_DO_BEFORE_ACTION */
+			*yy_cp = (yy_hold_char);
+			yy_cp = (yy_last_accepting_cpos);
+			yy_current_state = (yy_last_accepting_state);
+			goto yy_find_action;
+
+/* Comments and white space.  */
+case 1:
+YY_RULE_SETUP
+#line 197 "scan-gram.l"
+warn_at (*loc, _("stray `,' treated as white space"));
+	YY_BREAK
+case 2:
+/* rule 2 can match eol */
+#line 199 "scan-gram.l"
+case 3:
+/* rule 3 can match eol */
+YY_RULE_SETUP
+#line 199 "scan-gram.l"
+;
+	YY_BREAK
+case 4:
+YY_RULE_SETUP
+#line 200 "scan-gram.l"
+{
+    token_start = loc->start;
+    context_state = YY_START;
+    BEGIN SC_YACC_COMMENT;
+  }
+	YY_BREAK
+/* #line directives are not documented, and may be withdrawn or
+     modified in future versions of Bison.  */
+case 5:
+/* rule 5 can match eol */
+YY_RULE_SETUP
+#line 208 "scan-gram.l"
+{
+    handle_syncline (gram_text + sizeof "#line " - 1, *loc);
+  }
+	YY_BREAK
+
+/*----------------------------.
+  | Scanning Bison directives.  |
+  `----------------------------*/
+
+
+case 6:
+YY_RULE_SETUP
+#line 219 "scan-gram.l"
+return PERCENT_NONASSOC;
+	YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 220 "scan-gram.l"
+return PERCENT_DEBUG;
+	YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 221 "scan-gram.l"
+return PERCENT_DEFAULT_PREC;
+	YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 222 "scan-gram.l"
+return PERCENT_DEFINE;
+	YY_BREAK
+case 10:
+YY_RULE_SETUP
+#line 223 "scan-gram.l"
+return PERCENT_DEFINES;
+	YY_BREAK
+case 11:
+YY_RULE_SETUP
+#line 224 "scan-gram.l"
+token_type = PERCENT_DESTRUCTOR; BEGIN SC_PRE_CODE;
+	YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 225 "scan-gram.l"
+return PERCENT_DPREC;
+	YY_BREAK
+case 13:
+YY_RULE_SETUP
+#line 226 "scan-gram.l"
+return PERCENT_ERROR_VERBOSE;
+	YY_BREAK
+case 14:
+YY_RULE_SETUP
+#line 227 "scan-gram.l"
+return PERCENT_EXPECT;
+	YY_BREAK
+case 15:
+YY_RULE_SETUP
+#line 228 "scan-gram.l"
+return PERCENT_EXPECT_RR;
+	YY_BREAK
+case 16:
+YY_RULE_SETUP
+#line 229 "scan-gram.l"
+return PERCENT_FILE_PREFIX;
+	YY_BREAK
+case 17:
+YY_RULE_SETUP
+#line 230 "scan-gram.l"
+return PERCENT_YACC;
+	YY_BREAK
+case 18:
+YY_RULE_SETUP
+#line 231 "scan-gram.l"
+token_type = PERCENT_INITIAL_ACTION; BEGIN SC_PRE_CODE;
+	YY_BREAK
+case 19:
+YY_RULE_SETUP
+#line 232 "scan-gram.l"
+return PERCENT_GLR_PARSER;
+	YY_BREAK
+case 20:
+YY_RULE_SETUP
+#line 233 "scan-gram.l"
+return PERCENT_LEFT;
+	YY_BREAK
+case 21:
+YY_RULE_SETUP
+#line 234 "scan-gram.l"
+token_type = PERCENT_LEX_PARAM; BEGIN SC_PRE_CODE;
+	YY_BREAK
+case 22:
+YY_RULE_SETUP
+#line 235 "scan-gram.l"
+return PERCENT_LOCATIONS;
+	YY_BREAK
+case 23:
+YY_RULE_SETUP
+#line 236 "scan-gram.l"
+return PERCENT_MERGE;
+	YY_BREAK
+case 24:
+YY_RULE_SETUP
+#line 237 "scan-gram.l"
+return PERCENT_NAME_PREFIX;
+	YY_BREAK
+case 25:
+YY_RULE_SETUP
+#line 238 "scan-gram.l"
+return PERCENT_NO_DEFAULT_PREC;
+	YY_BREAK
+case 26:
+YY_RULE_SETUP
+#line 239 "scan-gram.l"
+return PERCENT_NO_LINES;
+	YY_BREAK
+case 27:
+YY_RULE_SETUP
+#line 240 "scan-gram.l"
+return PERCENT_NONASSOC;
+	YY_BREAK
+case 28:
+YY_RULE_SETUP
+#line 241 "scan-gram.l"
+return PERCENT_NONDETERMINISTIC_PARSER;
+	YY_BREAK
+case 29:
+YY_RULE_SETUP
+#line 242 "scan-gram.l"
+return PERCENT_NTERM;
+	YY_BREAK
+case 30:
+YY_RULE_SETUP
+#line 243 "scan-gram.l"
+return PERCENT_OUTPUT;
+	YY_BREAK
+case 31:
+YY_RULE_SETUP
+#line 244 "scan-gram.l"
+token_type = PERCENT_PARSE_PARAM; BEGIN SC_PRE_CODE;
+	YY_BREAK
+case 32:
+YY_RULE_SETUP
+#line 245 "scan-gram.l"
+rule_length--; return PERCENT_PREC;
+	YY_BREAK
+case 33:
+YY_RULE_SETUP
+#line 246 "scan-gram.l"
+token_type = PERCENT_PRINTER; BEGIN SC_PRE_CODE;
+	YY_BREAK
+case 34:
+YY_RULE_SETUP
+#line 247 "scan-gram.l"
+return PERCENT_PURE_PARSER;
+	YY_BREAK
+case 35:
+YY_RULE_SETUP
+#line 248 "scan-gram.l"
+return PERCENT_REQUIRE;
+	YY_BREAK
+case 36:
+YY_RULE_SETUP
+#line 249 "scan-gram.l"
+return PERCENT_RIGHT;
+	YY_BREAK
+case 37:
+YY_RULE_SETUP
+#line 250 "scan-gram.l"
+return PERCENT_SKELETON;
+	YY_BREAK
+case 38:
+YY_RULE_SETUP
+#line 251 "scan-gram.l"
+return PERCENT_START;
+	YY_BREAK
+case 39:
+YY_RULE_SETUP
+#line 252 "scan-gram.l"
+return PERCENT_TOKEN;
+	YY_BREAK
+case 40:
+YY_RULE_SETUP
+#line 253 "scan-gram.l"
+return PERCENT_TOKEN;
+	YY_BREAK
+case 41:
+YY_RULE_SETUP
+#line 254 "scan-gram.l"
+return PERCENT_TOKEN_TABLE;
+	YY_BREAK
+case 42:
+YY_RULE_SETUP
+#line 255 "scan-gram.l"
+return PERCENT_TYPE;
+	YY_BREAK
+case 43:
+YY_RULE_SETUP
+#line 256 "scan-gram.l"
+token_type = PERCENT_UNION; BEGIN SC_PRE_CODE;
+	YY_BREAK
+case 44:
+YY_RULE_SETUP
+#line 257 "scan-gram.l"
+return PERCENT_VERBOSE;
+	YY_BREAK
+case 45:
+YY_RULE_SETUP
+#line 258 "scan-gram.l"
+return PERCENT_YACC;
+	YY_BREAK
+case 46:
+YY_RULE_SETUP
+#line 260 "scan-gram.l"
+{
+    complain_at (*loc, _("invalid directive: %s"), quote (gram_text));
+  }
+	YY_BREAK
+case 47:
+YY_RULE_SETUP
+#line 264 "scan-gram.l"
+return EQUAL;
+	YY_BREAK
+case 48:
+YY_RULE_SETUP
+#line 265 "scan-gram.l"
+rule_length = 0; return PIPE;
+	YY_BREAK
+case 49:
+YY_RULE_SETUP
+#line 266 "scan-gram.l"
+return SEMICOLON;
+	YY_BREAK
+case 50:
+YY_RULE_SETUP
+#line 268 "scan-gram.l"
+{
+    val->symbol = symbol_get (gram_text, *loc);
+    id_loc = *loc;
+    increment_rule_length (*loc);
+    BEGIN SC_AFTER_IDENTIFIER;
+  }
+	YY_BREAK
+case 51:
+YY_RULE_SETUP
+#line 275 "scan-gram.l"
+{
+    val->integer = scan_integer (gram_text, 10, *loc);
+    return INT;
+  }
+	YY_BREAK
+case 52:
+YY_RULE_SETUP
+#line 279 "scan-gram.l"
+{
+    val->integer = scan_integer (gram_text, 16, *loc);
+    return INT;
+  }
+	YY_BREAK
+/* Characters.  We don't check there is only one.  */
+case 53:
+YY_RULE_SETUP
+#line 285 "scan-gram.l"
+STRING_GROW; token_start = loc->start; BEGIN SC_ESCAPED_CHARACTER;
+	YY_BREAK
+/* Strings. */
+case 54:
+YY_RULE_SETUP
+#line 288 "scan-gram.l"
+token_start = loc->start; BEGIN SC_ESCAPED_STRING;
+	YY_BREAK
+/* Prologue. */
+case 55:
+YY_RULE_SETUP
+#line 291 "scan-gram.l"
+code_start = loc->start; BEGIN SC_PROLOGUE;
+	YY_BREAK
+/* Code in between braces.  */
+case 56:
+YY_RULE_SETUP
+#line 294 "scan-gram.l"
+{
+    if (current_rule && current_rule->action)
+      grammar_midrule_action ();
+    STRING_GROW;
+    token_type = BRACED_CODE;
+    braces_level = 0;
+    code_start = loc->start;
+    BEGIN SC_BRACED_CODE;
+  }
+	YY_BREAK
+/* A type. */
+case 57:
+YY_RULE_SETUP
+#line 305 "scan-gram.l"
+{
+    obstack_grow (&obstack_for_string, gram_text + 1, gram_leng - 2);
+    STRING_FINISH;
+    val->uniqstr = uniqstr_new (last_string);
+    STRING_FREE;
+    return TYPE;
+  }
+	YY_BREAK
+case 58:
+YY_RULE_SETUP
+#line 313 "scan-gram.l"
+{
+    static int percent_percent_count;
+    if (++percent_percent_count == 2)
+      BEGIN SC_EPILOGUE;
+    return PERCENT_PERCENT;
+  }
+	YY_BREAK
+case 59:
+YY_RULE_SETUP
+#line 320 "scan-gram.l"
+{
+    complain_at (*loc, _("invalid character: %s"), quote (gram_text));
+  }
+	YY_BREAK
+case YY_STATE_EOF(INITIAL):
+#line 324 "scan-gram.l"
+{
+    loc->start = loc->end = scanner_cursor;
+    yyterminate ();
+  }
+	YY_BREAK
+
+/*-----------------------------------------------------------------.
+  | Scanning after an identifier, checking whether a colon is next.  |
+  `-----------------------------------------------------------------*/
+
+
+case 60:
+YY_RULE_SETUP
+#line 337 "scan-gram.l"
+{
+    rule_length = 0;
+    *loc = id_loc;
+    BEGIN INITIAL;
+    return ID_COLON;
+  }
+	YY_BREAK
+case 61:
+YY_RULE_SETUP
+#line 343 "scan-gram.l"
+{
+    scanner_cursor.column -= mbsnwidth (gram_text, gram_leng, 0);
+    yyless (0);
+    *loc = id_loc;
+    BEGIN INITIAL;
+    return ID;
+  }
+	YY_BREAK
+case YY_STATE_EOF(SC_AFTER_IDENTIFIER):
+#line 350 "scan-gram.l"
+{
+    *loc = id_loc;
+    BEGIN INITIAL;
+    return ID;
+  }
+	YY_BREAK
+
+/*---------------------------------------------------------------.
+  | Scanning a Yacc comment.  The initial `/ *' is already eaten.  |
+  `---------------------------------------------------------------*/
+
+
+case 62:
+YY_RULE_SETUP
+#line 364 "scan-gram.l"
+BEGIN context_state;
+	YY_BREAK
+case 63:
+/* rule 63 can match eol */
+YY_RULE_SETUP
+#line 365 "scan-gram.l"
+;
+	YY_BREAK
+case YY_STATE_EOF(SC_YACC_COMMENT):
+#line 366 "scan-gram.l"
+unexpected_eof (token_start, "*/"); BEGIN context_state;
+	YY_BREAK
+
+/*------------------------------------------------------------.
+  | Scanning a C comment.  The initial `/ *' is already eaten.  |
+  `------------------------------------------------------------*/
+
+
+case 64:
+/* rule 64 can match eol */
+YY_RULE_SETUP
+#line 376 "scan-gram.l"
+STRING_GROW; BEGIN context_state;
+	YY_BREAK
+case YY_STATE_EOF(SC_COMMENT):
+#line 377 "scan-gram.l"
+unexpected_eof (token_start, "*/"); BEGIN context_state;
+	YY_BREAK
+
+/*--------------------------------------------------------------.
+  | Scanning a line comment.  The initial `//' is already eaten.  |
+  `--------------------------------------------------------------*/
+
+
+case 65:
+/* rule 65 can match eol */
+YY_RULE_SETUP
+#line 387 "scan-gram.l"
+STRING_GROW; BEGIN context_state;
+	YY_BREAK
+case 66:
+/* rule 66 can match eol */
+YY_RULE_SETUP
+#line 388 "scan-gram.l"
+STRING_GROW;
+	YY_BREAK
+case YY_STATE_EOF(SC_LINE_COMMENT):
+#line 389 "scan-gram.l"
+BEGIN context_state;
+	YY_BREAK
+
+/*------------------------------------------------.
+  | Scanning a Bison string, including its escapes. |
+  | The initial quote is already eaten.             |
+  `------------------------------------------------*/
+
+
+case 67:
+YY_RULE_SETUP
+#line 400 "scan-gram.l"
+{
+    STRING_FINISH;
+    loc->start = token_start;
+    val->chars = last_string;
+    increment_rule_length (*loc);
+    BEGIN INITIAL;
+    return STRING;
+  }
+	YY_BREAK
+case 68:
+/* rule 68 can match eol */
+YY_RULE_SETUP
+#line 408 "scan-gram.l"
+unexpected_newline (token_start, "\"");	BEGIN INITIAL;
+	YY_BREAK
+case YY_STATE_EOF(SC_ESCAPED_STRING):
+#line 409 "scan-gram.l"
+unexpected_eof (token_start, "\"");	BEGIN INITIAL;
+	YY_BREAK
+
+/*----------------------------------------------------------.
+  | Scanning a Bison character literal, decoding its escapes. |
+  | The initial quote is already eaten.			      |
+  `----------------------------------------------------------*/
+
+
+case 69:
+YY_RULE_SETUP
+#line 419 "scan-gram.l"
+{
+    unsigned char last_string_1;
+    STRING_GROW;
+    STRING_FINISH;
+    loc->start = token_start;
+    val->symbol = symbol_get (quotearg_style (escape_quoting_style,
+					      last_string),
+			      *loc);
+    symbol_class_set (val->symbol, token_sym, *loc, false);
+    last_string_1 = last_string[1];
+    symbol_user_token_number_set (val->symbol, last_string_1, *loc);
+    STRING_FREE;
+    increment_rule_length (*loc);
+    BEGIN INITIAL;
+    return ID;
+  }
+	YY_BREAK
+case 70:
+/* rule 70 can match eol */
+YY_RULE_SETUP
+#line 435 "scan-gram.l"
+unexpected_newline (token_start, "'");	BEGIN INITIAL;
+	YY_BREAK
+case YY_STATE_EOF(SC_ESCAPED_CHARACTER):
+#line 436 "scan-gram.l"
+unexpected_eof (token_start, "'");	BEGIN INITIAL;
+	YY_BREAK
+
+
+
+case 71:
+YY_RULE_SETUP
+#line 441 "scan-gram.l"
+complain_at (*loc, _("invalid null character"));
+	YY_BREAK
+
+/*----------------------------.
+  | Decode escaped characters.  |
+  `----------------------------*/
+
+
+case 72:
+YY_RULE_SETUP
+#line 451 "scan-gram.l"
+{
+    unsigned long int c = strtoul (gram_text + 1, NULL, 8);
+    if (UCHAR_MAX < c)
+      complain_at (*loc, _("invalid escape sequence: %s"), quote (gram_text));
+    else if (! c)
+      complain_at (*loc, _("invalid null character: %s"), quote (gram_text));
+    else
+      obstack_1grow (&obstack_for_string, c);
+  }
+	YY_BREAK
+case 73:
+YY_RULE_SETUP
+#line 461 "scan-gram.l"
+{
+    verify (UCHAR_MAX < ULONG_MAX);
+    unsigned long int c = strtoul (gram_text + 2, NULL, 16);
+    if (UCHAR_MAX < c)
+      complain_at (*loc, _("invalid escape sequence: %s"), quote (gram_text));
+    else if (! c)
+      complain_at (*loc, _("invalid null character: %s"), quote (gram_text));
+    else
+      obstack_1grow (&obstack_for_string, c);
+  }
+	YY_BREAK
+case 74:
+YY_RULE_SETUP
+#line 472 "scan-gram.l"
+obstack_1grow (&obstack_for_string, '\a');
+	YY_BREAK
+case 75:
+YY_RULE_SETUP
+#line 473 "scan-gram.l"
+obstack_1grow (&obstack_for_string, '\b');
+	YY_BREAK
+case 76:
+YY_RULE_SETUP
+#line 474 "scan-gram.l"
+obstack_1grow (&obstack_for_string, '\f');
+	YY_BREAK
+case 77:
+YY_RULE_SETUP
+#line 475 "scan-gram.l"
+obstack_1grow (&obstack_for_string, '\n');
+	YY_BREAK
+case 78:
+YY_RULE_SETUP
+#line 476 "scan-gram.l"
+obstack_1grow (&obstack_for_string, '\r');
+	YY_BREAK
+case 79:
+YY_RULE_SETUP
+#line 477 "scan-gram.l"
+obstack_1grow (&obstack_for_string, '\t');
+	YY_BREAK
+case 80:
+YY_RULE_SETUP
+#line 478 "scan-gram.l"
+obstack_1grow (&obstack_for_string, '\v');
+	YY_BREAK
+/* \\[\"\'?\\] would be shorter, but it confuses xgettext.  */
+case 81:
+YY_RULE_SETUP
+#line 481 "scan-gram.l"
+obstack_1grow (&obstack_for_string, gram_text[1]);
+	YY_BREAK
+case 82:
+YY_RULE_SETUP
+#line 483 "scan-gram.l"
+{
+    int c = convert_ucn_to_byte (gram_text);
+    if (c < 0)
+      complain_at (*loc, _("invalid escape sequence: %s"), quote (gram_text));
+    else if (! c)
+      complain_at (*loc, _("invalid null character: %s"), quote (gram_text));
+    else
+      obstack_1grow (&obstack_for_string, c);
+  }
+	YY_BREAK
+case 83:
+/* rule 83 can match eol */
+YY_RULE_SETUP
+#line 492 "scan-gram.l"
+{
+    complain_at (*loc, _("unrecognized escape sequence: %s"), quote (gram_text));
+    STRING_GROW;
+  }
+	YY_BREAK
+
+/*--------------------------------------------.
+  | Scanning user-code characters and strings.  |
+  `--------------------------------------------*/
+
+
+case 84:
+/* rule 84 can match eol */
+YY_RULE_SETUP
+#line 504 "scan-gram.l"
+STRING_GROW;
+	YY_BREAK
+
+
+
+case 85:
+YY_RULE_SETUP
+#line 509 "scan-gram.l"
+STRING_GROW; BEGIN context_state;
+	YY_BREAK
+case 86:
+/* rule 86 can match eol */
+YY_RULE_SETUP
+#line 510 "scan-gram.l"
+unexpected_newline (token_start, "'"); BEGIN context_state;
+	YY_BREAK
+case YY_STATE_EOF(SC_CHARACTER):
+#line 511 "scan-gram.l"
+unexpected_eof (token_start, "'"); BEGIN context_state;
+	YY_BREAK
+
+
+
+case 87:
+YY_RULE_SETUP
+#line 516 "scan-gram.l"
+STRING_GROW; BEGIN context_state;
+	YY_BREAK
+case 88:
+/* rule 88 can match eol */
+YY_RULE_SETUP
+#line 517 "scan-gram.l"
+unexpected_newline (token_start, "\""); BEGIN context_state;
+	YY_BREAK
+case YY_STATE_EOF(SC_STRING):
+#line 518 "scan-gram.l"
+unexpected_eof (token_start, "\""); BEGIN context_state;
+	YY_BREAK
+
+/*---------------------------------------------------.
+  | Strings, comments etc. can be found in user code.  |
+  `---------------------------------------------------*/
+
+
+case 89:
+YY_RULE_SETUP
+#line 528 "scan-gram.l"
+{
+    STRING_GROW;
+    context_state = YY_START;
+    token_start = loc->start;
+    BEGIN SC_CHARACTER;
+  }
+	YY_BREAK
+case 90:
+YY_RULE_SETUP
+#line 534 "scan-gram.l"
+{
+    STRING_GROW;
+    context_state = YY_START;
+    token_start = loc->start;
+    BEGIN SC_STRING;
+  }
+	YY_BREAK
+case 91:
+/* rule 91 can match eol */
+YY_RULE_SETUP
+#line 540 "scan-gram.l"
+{
+    STRING_GROW;
+    context_state = YY_START;
+    token_start = loc->start;
+    BEGIN SC_COMMENT;
+  }
+	YY_BREAK
+case 92:
+/* rule 92 can match eol */
+YY_RULE_SETUP
+#line 546 "scan-gram.l"
+{
+    STRING_GROW;
+    context_state = YY_START;
+    BEGIN SC_LINE_COMMENT;
+  }
+	YY_BREAK
+
+/*---------------------------------------------------------------.
+  | Scanning after %union etc., possibly followed by white space.  |
+  | For %union only, allow arbitrary C code to appear before the   |
+  | following brace, as an extension to POSIX.			   |
+  `---------------------------------------------------------------*/
+
+
+case 93:
+YY_RULE_SETUP
+#line 562 "scan-gram.l"
+{
+    bool valid = gram_text[0] == '{' || token_type == PERCENT_UNION;
+    scanner_cursor.column -= mbsnwidth (gram_text, gram_leng, 0);
+    yyless (0);
+
+    if (valid)
+      {
+	braces_level = -1;
+	code_start = loc->start;
+	BEGIN SC_BRACED_CODE;
+      }
+    else
+      {
+	complain_at (*loc, _("missing `{' in %s"),
+		     token_name (token_type));
+	obstack_sgrow (&obstack_for_string, "{}");
+	STRING_FINISH;
+	val->chars = last_string;
+	BEGIN INITIAL;
+	return token_type;
+      }
+  }
+	YY_BREAK
+case YY_STATE_EOF(SC_PRE_CODE):
+#line 585 "scan-gram.l"
+unexpected_eof (scanner_cursor, "{}"); BEGIN INITIAL;
+	YY_BREAK
+
+/*---------------------------------------------------------------.
+  | Scanning some code in braces (%union and actions). The initial |
+  | "{" is already eaten.                                          |
+  `---------------------------------------------------------------*/
+
+
+case 94:
+/* rule 94 can match eol */
+YY_RULE_SETUP
+#line 596 "scan-gram.l"
+STRING_GROW; braces_level++;
+	YY_BREAK
+case 95:
+/* rule 95 can match eol */
+YY_RULE_SETUP
+#line 597 "scan-gram.l"
+STRING_GROW; braces_level--;
+	YY_BREAK
+case 96:
+YY_RULE_SETUP
+#line 598 "scan-gram.l"
+{
+    bool outer_brace = --braces_level < 0;
+
+    /* As an undocumented Bison extension, append `;' before the last
+       brace in braced code, so that the user code can omit trailing
+       `;'.  But do not append `;' if emulating Yacc, since Yacc does
+       not append one.
+
+       FIXME: Bison should warn if a semicolon seems to be necessary
+       here, and should omit the semicolon if it seems unnecessary
+       (e.g., after ';', '{', or '}', each followed by comments or
+       white space).  Such a warning shouldn't depend on --yacc; it
+       should depend on a new --pedantic option, which would cause
+       Bison to warn if it detects an extension to POSIX.  --pedantic
+       should also diagnose other Bison extensions like %yacc.
+       Perhaps there should also be a GCC-style --pedantic-errors
+       option, so that such warnings are diagnosed as errors.  */
+    if (outer_brace && token_type == BRACED_CODE && ! yacc_flag)
+      obstack_1grow (&obstack_for_string, ';');
+
+    obstack_1grow (&obstack_for_string, '}');
+
+    if (outer_brace)
+      {
+	STRING_FINISH;
+	loc->start = code_start;
+	val->chars = last_string;
+	increment_rule_length (*loc);
+	last_braced_code_loc = *loc;
+	BEGIN INITIAL;
+	return token_type;
+      }
+  }
+	YY_BREAK
+/* Tokenize `<<%' correctly (as `<<' `%') rather than incorrrectly
+     (as `<' `<%').  */
+case 97:
+/* rule 97 can match eol */
+YY_RULE_SETUP
+#line 634 "scan-gram.l"
+STRING_GROW;
+	YY_BREAK
+case 98:
+YY_RULE_SETUP
+#line 636 "scan-gram.l"
+handle_dollar (token_type, gram_text, *loc);
+	YY_BREAK
+case 99:
+YY_RULE_SETUP
+#line 637 "scan-gram.l"
+handle_at (token_type, gram_text, *loc);
+	YY_BREAK
+case 100:
+YY_RULE_SETUP
+#line 639 "scan-gram.l"
+{
+    warn_at (*loc, _("stray `$'"));
+    obstack_sgrow (&obstack_for_string, "$][");
+  }
+	YY_BREAK
+case 101:
+YY_RULE_SETUP
+#line 643 "scan-gram.l"
+{
+    warn_at (*loc, _("stray `@'"));
+    obstack_sgrow (&obstack_for_string, "@@");
+  }
+	YY_BREAK
+case YY_STATE_EOF(SC_BRACED_CODE):
+#line 648 "scan-gram.l"
+unexpected_eof (code_start, "}"); BEGIN INITIAL;
+	YY_BREAK
+
+/*--------------------------------------------------------------.
+  | Scanning some prologue: from "%{" (already scanned) to "%}".  |
+  `--------------------------------------------------------------*/
+
+
+case 102:
+YY_RULE_SETUP
+#line 658 "scan-gram.l"
+{
+    STRING_FINISH;
+    loc->start = code_start;
+    val->chars = last_string;
+    BEGIN INITIAL;
+    return PROLOGUE;
+  }
+	YY_BREAK
+case YY_STATE_EOF(SC_PROLOGUE):
+#line 666 "scan-gram.l"
+unexpected_eof (code_start, "%}"); BEGIN INITIAL;
+	YY_BREAK
+
+/*---------------------------------------------------------------.
+  | Scanning the epilogue (everything after the second "%%", which |
+  | has already been eaten).                                       |
+  `---------------------------------------------------------------*/
+
+
+case YY_STATE_EOF(SC_EPILOGUE):
+#line 677 "scan-gram.l"
+{
+    STRING_FINISH;
+    loc->start = code_start;
+    val->chars = last_string;
+    BEGIN INITIAL;
+    return EPILOGUE;
+  }
+	YY_BREAK
+
+/*-----------------------------------------.
+  | Escape M4 quoting characters in C code.  |
+  `-----------------------------------------*/
+
+
+case 103:
+YY_RULE_SETUP
+#line 693 "scan-gram.l"
+obstack_sgrow (&obstack_for_string, "$][");
+	YY_BREAK
+case 104:
+YY_RULE_SETUP
+#line 694 "scan-gram.l"
+obstack_sgrow (&obstack_for_string, "@@");
+	YY_BREAK
+case 105:
+YY_RULE_SETUP
+#line 695 "scan-gram.l"
+obstack_sgrow (&obstack_for_string, "@{");
+	YY_BREAK
+case 106:
+YY_RULE_SETUP
+#line 696 "scan-gram.l"
+obstack_sgrow (&obstack_for_string, "@}");
+	YY_BREAK
+
+/*-----------------------------------------------------.
+  | By default, grow the string obstack with the input.  |
+  `-----------------------------------------------------*/
+case 107:
+#line 705 "scan-gram.l"
+case 108:
+/* rule 108 can match eol */
+YY_RULE_SETUP
+#line 705 "scan-gram.l"
+STRING_GROW;
+	YY_BREAK
+case 109:
+YY_RULE_SETUP
+#line 707 "scan-gram.l"
+YY_FATAL_ERROR( "flex scanner jammed" );
+	YY_BREAK
+#line 2305 "scan-gram.c"
+
+	case YY_END_OF_BUFFER:
+		{
+		/* Amount of text matched not including the EOB char. */
+		int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
+
+		/* Undo the effects of YY_DO_BEFORE_ACTION. */
+		*yy_cp = (yy_hold_char);
+		YY_RESTORE_YY_MORE_OFFSET
+
+		if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
+			{
+			/* We're scanning a new file or input source.  It's
+			 * possible that this happened because the user
+			 * just pointed gram_in at a new source and called
+			 * gram_lex().  If so, then we have to assure
+			 * consistency between YY_CURRENT_BUFFER and our
+			 * globals.  Here is the right place to do so, because
+			 * this is the first action (other than possibly a
+			 * back-up) that will match for the new input source.
+			 */
+			(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+			YY_CURRENT_BUFFER_LVALUE->yy_input_file = gram_in;
+			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
+			}
+
+		/* Note that here we test for yy_c_buf_p "<=" to the position
+		 * of the first EOB in the buffer, since yy_c_buf_p will
+		 * already have been incremented past the NUL character
+		 * (since all states make transitions on EOB to the
+		 * end-of-buffer state).  Contrast this with the test
+		 * in input().
+		 */
+		if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+			{ /* This was really a NUL. */
+			yy_state_type yy_next_state;
+
+			(yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
+
+			yy_current_state = yy_get_previous_state(  );
+
+			/* Okay, we're now positioned to make the NUL
+			 * transition.  We couldn't have
+			 * yy_get_previous_state() go ahead and do it
+			 * for us because it doesn't know how to deal
+			 * with the possibility of jamming (and we don't
+			 * want to build jamming into it because then it
+			 * will run more slowly).
+			 */
+
+			yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+			yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+
+			if ( yy_next_state )
+				{
+				/* Consume the NUL. */
+				yy_cp = ++(yy_c_buf_p);
+				yy_current_state = yy_next_state;
+				goto yy_match;
+				}
+
+			else
+				{
+/* %% [14.0] code to do back-up for compressed tables and set up yy_cp goes here */
+				yy_cp = (yy_last_accepting_cpos);
+				yy_current_state = (yy_last_accepting_state);
+				goto yy_find_action;
+				}
+			}
+
+		else switch ( yy_get_next_buffer(  ) )
+			{
+			case EOB_ACT_END_OF_FILE:
+				{
+				(yy_did_buffer_switch_on_eof) = 0;
+
+				if ( gram_wrap( ) )
+					{
+					/* Note: because we've taken care in
+					 * yy_get_next_buffer() to have set up
+					 * gram_text, we can now set up
+					 * yy_c_buf_p so that if some total
+					 * hoser (like flex itself) wants to
+					 * call the scanner after we return the
+					 * YY_NULL, it'll still work - another
+					 * YY_NULL will get returned.
+					 */
+					(yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
+
+					yy_act = YY_STATE_EOF(YY_START);
+					goto do_action;
+					}
+
+				else
+					{
+					if ( ! (yy_did_buffer_switch_on_eof) )
+						YY_NEW_FILE;
+					}
+				break;
+				}
+
+			case EOB_ACT_CONTINUE_SCAN:
+				(yy_c_buf_p) =
+					(yytext_ptr) + yy_amount_of_matched_text;
+
+				yy_current_state = yy_get_previous_state(  );
+
+				yy_cp = (yy_c_buf_p);
+				yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+				goto yy_match;
+
+			case EOB_ACT_LAST_MATCH:
+				(yy_c_buf_p) =
+				&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
+
+				yy_current_state = yy_get_previous_state(  );
+
+				yy_cp = (yy_c_buf_p);
+				yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+				goto yy_find_action;
+			}
+		break;
+		}
+
+	default:
+		YY_FATAL_ERROR(
+			"fatal flex scanner internal error--no action found" );
+	} /* end of action switch */
+		} /* end of scanning one token */
+} /* end of gram_lex */
+/* %ok-for-header */
+
+/* %if-c++-only */
+/* %not-for-header */
+
+/* %ok-for-header */
+
+/* %endif */
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ *	EOB_ACT_LAST_MATCH -
+ *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ *	EOB_ACT_END_OF_FILE - end of file
+ */
+/* %if-c-only */
+static int yy_get_next_buffer (void)
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+    	register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+	register char *source = (yytext_ptr);
+	register int number_to_move, i;
+	int ret_val;
+
+	if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
+		YY_FATAL_ERROR(
+		"fatal flex scanner internal error--end of buffer missed" );
+
+	if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
+		{ /* Don't try to fill the buffer, so this is an EOF. */
+		if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
+			{
+			/* We matched a single character, the EOB, so
+			 * treat this as a final EOF.
+			 */
+			return EOB_ACT_END_OF_FILE;
+			}
+
+		else
+			{
+			/* We matched some text prior to the EOB, first
+			 * process it.
+			 */
+			return EOB_ACT_LAST_MATCH;
+			}
+		}
+
+	/* Try to read more data. */
+
+	/* First move last chars to start of buffer. */
+	number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
+
+	for ( i = 0; i < number_to_move; ++i )
+		*(dest++) = *(source++);
+
+	if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+		/* don't do the read, it's not guaranteed to return an EOF,
+		 * just force an EOF
+		 */
+		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
+
+	else
+		{
+			size_t num_to_read =
+			YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
+
+		while ( num_to_read <= 0 )
+			{ /* Not enough room in the buffer - grow it. */
+
+			/* just a shorter name for the current buffer */
+			YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
+
+			int yy_c_buf_p_offset =
+				(int) ((yy_c_buf_p) - b->yy_ch_buf);
+
+			if ( b->yy_is_our_buffer )
+				{
+				int new_size = b->yy_buf_size * 2;
+
+				if ( new_size <= 0 )
+					b->yy_buf_size += b->yy_buf_size / 8;
+				else
+					b->yy_buf_size *= 2;
+
+				b->yy_ch_buf = (char *)
+					/* Include room in for 2 EOB chars. */
+					gram_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2  );
+				}
+			else
+				/* Can't grow it, we don't own it. */
+				b->yy_ch_buf = 0;
+
+			if ( ! b->yy_ch_buf )
+				YY_FATAL_ERROR(
+				"fatal error - scanner input buffer overflow" );
+
+			(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+			num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
+						number_to_move - 1;
+
+			}
+
+		if ( num_to_read > YY_READ_BUF_SIZE )
+			num_to_read = YY_READ_BUF_SIZE;
+
+		/* Read in more data. */
+		YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+			(yy_n_chars), num_to_read );
+
+		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+		}
+
+	if ( (yy_n_chars) == 0 )
+		{
+		if ( number_to_move == YY_MORE_ADJ )
+			{
+			ret_val = EOB_ACT_END_OF_FILE;
+			gram_restart(gram_in  );
+			}
+
+		else
+			{
+			ret_val = EOB_ACT_LAST_MATCH;
+			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
+				YY_BUFFER_EOF_PENDING;
+			}
+		}
+
+	else
+		ret_val = EOB_ACT_CONTINUE_SCAN;
+
+	(yy_n_chars) += number_to_move;
+	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
+	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
+
+	(yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
+
+	return ret_val;
+}
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+/* %if-c-only */
+/* %not-for-header */
+
+    static yy_state_type yy_get_previous_state (void)
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+	register yy_state_type yy_current_state;
+	register char *yy_cp;
+    
+/* %% [15.0] code to get the start state into yy_current_state goes here */
+	yy_current_state = (yy_start);
+	yy_current_state += YY_AT_BOL();
+
+	for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
+		{
+/* %% [16.0] code to find the next state goes here */
+		register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 58);
+		if ( yy_accept[yy_current_state] )
+			{
+			(yy_last_accepting_state) = yy_current_state;
+			(yy_last_accepting_cpos) = yy_cp;
+			}
+		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+			{
+			yy_current_state = (int) yy_def[yy_current_state];
+			if ( yy_current_state >= 461 )
+				yy_c = yy_meta[(unsigned int) yy_c];
+			}
+		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+		}
+
+	return yy_current_state;
+}
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ *	next_state = yy_try_NUL_trans( current_state );
+ */
+/* %if-c-only */
+    static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+	register int yy_is_jam;
+    /* %% [17.0] code to find the next state, and perhaps do backing up, goes here */
+	register char *yy_cp = (yy_c_buf_p);
+
+	register YY_CHAR yy_c = 58;
+	if ( yy_accept[yy_current_state] )
+		{
+		(yy_last_accepting_state) = yy_current_state;
+		(yy_last_accepting_cpos) = yy_cp;
+		}
+	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+		{
+		yy_current_state = (int) yy_def[yy_current_state];
+		if ( yy_current_state >= 461 )
+			yy_c = yy_meta[(unsigned int) yy_c];
+		}
+	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+	yy_is_jam = (yy_current_state == 460);
+
+	return yy_is_jam ? 0 : yy_current_state;
+}
+
+/* %if-c-only */
+
+/* %endif */
+
+/* %if-c-only */
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+    static int yyinput (void)
+#else
+    static int input  (void)
+#endif
+
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+	int c;
+    
+	*(yy_c_buf_p) = (yy_hold_char);
+
+	if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
+		{
+		/* yy_c_buf_p now points to the character we want to return.
+		 * If this occurs *before* the EOB characters, then it's a
+		 * valid NUL; if not, then we've hit the end of the buffer.
+		 */
+		if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+			/* This was really a NUL. */
+			*(yy_c_buf_p) = '\0';
+
+		else
+			{ /* need more input */
+			int offset = (yy_c_buf_p) - (yytext_ptr);
+			++(yy_c_buf_p);
+
+			switch ( yy_get_next_buffer(  ) )
+				{
+				case EOB_ACT_LAST_MATCH:
+					/* This happens because yy_g_n_b()
+					 * sees that we've accumulated a
+					 * token and flags that we need to
+					 * try matching the token before
+					 * proceeding.  But for input(),
+					 * there's no matching to consider.
+					 * So convert the EOB_ACT_LAST_MATCH
+					 * to EOB_ACT_END_OF_FILE.
+					 */
+
+					/* Reset buffer status. */
+					gram_restart(gram_in );
+
+					/*FALLTHROUGH*/
+
+				case EOB_ACT_END_OF_FILE:
+					{
+					if ( gram_wrap( ) )
+						return EOF;
+
+					if ( ! (yy_did_buffer_switch_on_eof) )
+						YY_NEW_FILE;
+#ifdef __cplusplus
+					return yyinput();
+#else
+					return input();
+#endif
+					}
+
+				case EOB_ACT_CONTINUE_SCAN:
+					(yy_c_buf_p) = (yytext_ptr) + offset;
+					break;
+				}
+			}
+		}
+
+	c = *(unsigned char *) (yy_c_buf_p);	/* cast for 8-bit char's */
+	*(yy_c_buf_p) = '\0';	/* preserve gram_text */
+	(yy_hold_char) = *++(yy_c_buf_p);
+
+/* %% [19.0] update BOL and gram_lineno */
+	YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n');
+
+	return c;
+}
+/* %if-c-only */
+#endif	/* ifndef YY_NO_INPUT */
+/* %endif */
+
+/** Immediately switch to a different input stream.
+ * @param input_file A readable stream.
+ * 
+ * @note This function does not reset the start condition to @c INITIAL .
+ */
+/* %if-c-only */
+    void gram_restart  (FILE * input_file )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+    
+	if ( ! YY_CURRENT_BUFFER ){
+        gram_ensure_buffer_stack ();
+		YY_CURRENT_BUFFER_LVALUE =
+            gram__create_buffer(gram_in,YY_BUF_SIZE );
+	}
+
+	gram__init_buffer(YY_CURRENT_BUFFER,input_file );
+	gram__load_buffer_state( );
+}
+
+/** Switch to a different input buffer.
+ * @param new_buffer The new input buffer.
+ * 
+ */
+/* %if-c-only */
+    void gram__switch_to_buffer  (YY_BUFFER_STATE  new_buffer )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+    
+	/* TODO. We should be able to replace this entire function body
+	 * with
+	 *		gram_pop_buffer_state();
+	 *		gram_push_buffer_state(new_buffer);
+     */
+	gram_ensure_buffer_stack ();
+	if ( YY_CURRENT_BUFFER == new_buffer )
+		return;
+
+	if ( YY_CURRENT_BUFFER )
+		{
+		/* Flush out information for old buffer. */
+		*(yy_c_buf_p) = (yy_hold_char);
+		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+		}
+
+	YY_CURRENT_BUFFER_LVALUE = new_buffer;
+	gram__load_buffer_state( );
+
+	/* We don't actually know whether we did this switch during
+	 * EOF (gram_wrap()) processing, but the only time this flag
+	 * is looked at is after gram_wrap() is called, so it's safe
+	 * to go ahead and always set it.
+	 */
+	(yy_did_buffer_switch_on_eof) = 1;
+}
+
+/* %if-c-only */
+static void gram__load_buffer_state  (void)
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+    	(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+	(yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
+	gram_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+	(yy_hold_char) = *(yy_c_buf_p);
+}
+
+/** Allocate and initialize an input buffer state.
+ * @param file A readable stream.
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
+ * 
+ * @return the allocated buffer state.
+ */
+/* %if-c-only */
+    YY_BUFFER_STATE gram__create_buffer  (FILE * file, int  size )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+	YY_BUFFER_STATE b;
+    
+	b = (YY_BUFFER_STATE) gram_alloc(sizeof( struct yy_buffer_state )  );
+	if ( ! b )
+		YY_FATAL_ERROR( "out of dynamic memory in gram__create_buffer()" );
+
+	b->yy_buf_size = size;
+
+	/* yy_ch_buf has to be 2 characters longer than the size given because
+	 * we need to put in 2 end-of-buffer characters.
+	 */
+	b->yy_ch_buf = (char *) gram_alloc(b->yy_buf_size + 2  );
+	if ( ! b->yy_ch_buf )
+		YY_FATAL_ERROR( "out of dynamic memory in gram__create_buffer()" );
+
+	b->yy_is_our_buffer = 1;
+
+	gram__init_buffer(b,file );
+
+	return b;
+}
+
+/** Destroy the buffer.
+ * @param b a buffer created with gram__create_buffer()
+ * 
+ */
+/* %if-c-only */
+    void gram__delete_buffer (YY_BUFFER_STATE  b )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+    
+	if ( ! b )
+		return;
+
+	if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
+		YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
+
+	if ( b->yy_is_our_buffer )
+		gram_free((void *) b->yy_ch_buf  );
+
+	gram_free((void *) b  );
+}
+
+/* %if-c-only */
+
+/* %endif */
+
+/* %if-c++-only */
+/* %endif */
+
+/* Initializes or reinitializes a buffer.
+ * This function is sometimes called more than once on the same buffer,
+ * such as during a gram_restart() or at EOF.
+ */
+/* %if-c-only */
+    static void gram__init_buffer  (YY_BUFFER_STATE  b, FILE * file )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+
+{
+	int oerrno = errno;
+    
+	gram__flush_buffer(b );
+
+	b->yy_input_file = file;
+	b->yy_fill_buffer = 1;
+
+    /* If b is the current buffer, then gram__init_buffer was _probably_
+     * called from gram_restart() or through yy_get_next_buffer.
+     * In that case, we don't want to reset the lineno or column.
+     */
+    if (b != YY_CURRENT_BUFFER){
+        b->yy_bs_lineno = 1;
+        b->yy_bs_column = 0;
+    }
+
+/* %if-c-only */
+
+        b->yy_is_interactive = 0;
+    
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+	errno = oerrno;
+}
+
+/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
+ * 
+ */
+/* %if-c-only */
+    void gram__flush_buffer (YY_BUFFER_STATE  b )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+    	if ( ! b )
+		return;
+
+	b->yy_n_chars = 0;
+
+	/* We always need two end-of-buffer characters.  The first causes
+	 * a transition to the end-of-buffer state.  The second causes
+	 * a jam in that state.
+	 */
+	b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+	b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+	b->yy_buf_pos = &b->yy_ch_buf[0];
+
+	b->yy_at_bol = 1;
+	b->yy_buffer_status = YY_BUFFER_NEW;
+
+	if ( b == YY_CURRENT_BUFFER )
+		gram__load_buffer_state( );
+}
+
+/* %if-c-or-c++ */
+/** Pushes the new state onto the stack. The new state becomes
+ *  the current state. This function will allocate the stack
+ *  if necessary.
+ *  @param new_buffer The new state.
+ *  
+ */
+/* %if-c-only */
+void gram_push_buffer_state (YY_BUFFER_STATE new_buffer )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+    	if (new_buffer == NULL)
+		return;
+
+	gram_ensure_buffer_stack();
+
+	/* This block is copied from gram__switch_to_buffer. */
+	if ( YY_CURRENT_BUFFER )
+		{
+		/* Flush out information for old buffer. */
+		*(yy_c_buf_p) = (yy_hold_char);
+		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+		}
+
+	/* Only push if top exists. Otherwise, replace top. */
+	if (YY_CURRENT_BUFFER)
+		(yy_buffer_stack_top)++;
+	YY_CURRENT_BUFFER_LVALUE = new_buffer;
+
+	/* copied from gram__switch_to_buffer. */
+	gram__load_buffer_state( );
+	(yy_did_buffer_switch_on_eof) = 1;
+}
+/* %endif */
+
+/* %if-c-or-c++ */
+/** Removes and deletes the top of the stack, if present.
+ *  The next element becomes the new top.
+ *  
+ */
+/* %if-c-only */
+void gram_pop_buffer_state (void)
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+    	if (!YY_CURRENT_BUFFER)
+		return;
+
+	gram__delete_buffer(YY_CURRENT_BUFFER );
+	YY_CURRENT_BUFFER_LVALUE = NULL;
+	if ((yy_buffer_stack_top) > 0)
+		--(yy_buffer_stack_top);
+
+	if (YY_CURRENT_BUFFER) {
+		gram__load_buffer_state( );
+		(yy_did_buffer_switch_on_eof) = 1;
+	}
+}
+/* %endif */
+
+/* %if-c-or-c++ */
+/* Allocates the stack if it does not exist.
+ *  Guarantees space for at least one push.
+ */
+/* %if-c-only */
+static void gram_ensure_buffer_stack (void)
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+	int num_to_alloc;
+    
+	if (!(yy_buffer_stack)) {
+
+		/* First allocation is just for 2 elements, since we don't know if this
+		 * scanner will even need a stack. We use 2 instead of 1 to avoid an
+		 * immediate realloc on the next call.
+         */
+		num_to_alloc = 1;
+		(yy_buffer_stack) = (struct yy_buffer_state**)gram_alloc
+								(num_to_alloc * sizeof(struct yy_buffer_state*)
+								);
+		
+		memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
+				
+		(yy_buffer_stack_max) = num_to_alloc;
+		(yy_buffer_stack_top) = 0;
+		return;
+	}
+
+	if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
+
+		/* Increase the buffer to prepare for a possible push. */
+		int grow_size = 8 /* arbitrary grow size */;
+
+		num_to_alloc = (yy_buffer_stack_max) + grow_size;
+		(yy_buffer_stack) = (struct yy_buffer_state**)gram_realloc
+								((yy_buffer_stack),
+								num_to_alloc * sizeof(struct yy_buffer_state*)
+								);
+
+		/* zero only the new slots.*/
+		memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
+		(yy_buffer_stack_max) = num_to_alloc;
+	}
+}
+/* %endif */
+
+/* %if-c-only */
+/** Setup the input buffer state to scan directly from a user-specified character buffer.
+ * @param base the character buffer
+ * @param size the size in bytes of the character buffer
+ * 
+ * @return the newly allocated buffer state object. 
+ */
+YY_BUFFER_STATE gram__scan_buffer  (char * base, yy_size_t  size )
+{
+	YY_BUFFER_STATE b;
+    
+	if ( size < 2 ||
+	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
+	     base[size-1] != YY_END_OF_BUFFER_CHAR )
+		/* They forgot to leave room for the EOB's. */
+		return 0;
+
+	b = (YY_BUFFER_STATE) gram_alloc(sizeof( struct yy_buffer_state )  );
+	if ( ! b )
+		YY_FATAL_ERROR( "out of dynamic memory in gram__scan_buffer()" );
+
+	b->yy_buf_size = size - 2;	/* "- 2" to take care of EOB's */
+	b->yy_buf_pos = b->yy_ch_buf = base;
+	b->yy_is_our_buffer = 0;
+	b->yy_input_file = 0;
+	b->yy_n_chars = b->yy_buf_size;
+	b->yy_is_interactive = 0;
+	b->yy_at_bol = 1;
+	b->yy_fill_buffer = 0;
+	b->yy_buffer_status = YY_BUFFER_NEW;
+
+	gram__switch_to_buffer(b  );
+
+	return b;
+}
+/* %endif */
+
+/* %if-c-only */
+/** Setup the input buffer state to scan a string. The next call to gram_lex() will
+ * scan from a @e copy of @a str.
+ * @param str a NUL-terminated string to scan
+ * 
+ * @return the newly allocated buffer state object.
+ * @note If you want to scan bytes that may contain NUL values, then use
+ *       gram__scan_bytes() instead.
+ */
+YY_BUFFER_STATE gram__scan_string (yyconst char * yy_str )
+{
+    
+	return gram__scan_bytes(yy_str,strlen(yy_str) );
+}
+/* %endif */
+
+/* %if-c-only */
+/** Setup the input buffer state to scan the given bytes. The next call to gram_lex() will
+ * scan from a @e copy of @a bytes.
+ * @param bytes the byte buffer to scan
+ * @param len the number of bytes in the buffer pointed to by @a bytes.
+ * 
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE gram__scan_bytes  (yyconst char * bytes, int  len )
+{
+	YY_BUFFER_STATE b;
+	char *buf;
+	yy_size_t n;
+	int i;
+    
+	/* Get memory for full buffer, including space for trailing EOB's. */
+	n = len + 2;
+	buf = (char *) gram_alloc(n  );
+	if ( ! buf )
+		YY_FATAL_ERROR( "out of dynamic memory in gram__scan_bytes()" );
+
+	for ( i = 0; i < len; ++i )
+		buf[i] = bytes[i];
+
+	buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
+
+	b = gram__scan_buffer(buf,n );
+	if ( ! b )
+		YY_FATAL_ERROR( "bad buffer in gram__scan_bytes()" );
+
+	/* It's okay to grow etc. this buffer, and we should throw it
+	 * away when we're done.
+	 */
+	b->yy_is_our_buffer = 1;
+
+	return b;
+}
+/* %endif */
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+/* %if-c-only */
+static void yy_fatal_error (yyconst char* msg )
+{
+    	(void) fprintf( stderr, "%s\n", msg );
+	exit( YY_EXIT_FAILURE );
+}
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+	do \
+		{ \
+		/* Undo effects of setting up gram_text. */ \
+        int yyless_macro_arg = (n); \
+        YY_LESS_LINENO(yyless_macro_arg);\
+		gram_text[gram_leng] = (yy_hold_char); \
+		(yy_c_buf_p) = gram_text + yyless_macro_arg; \
+		(yy_hold_char) = *(yy_c_buf_p); \
+		*(yy_c_buf_p) = '\0'; \
+		gram_leng = yyless_macro_arg; \
+		} \
+	while ( 0 )
+
+/* Accessor  methods (get/set functions) to struct members. */
+
+/* %if-c-only */
+/* %if-reentrant */
+/* %endif */
+
+/** Get the current line number.
+ * 
+ */
+int gram_get_lineno  (void)
+{
+        
+    return gram_lineno;
+}
+
+/** Get the input stream.
+ * 
+ */
+FILE *gram_get_in  (void)
+{
+        return gram_in;
+}
+
+/** Get the output stream.
+ * 
+ */
+FILE *gram_get_out  (void)
+{
+        return gram_out;
+}
+
+/** Get the length of the current token.
+ * 
+ */
+int gram_get_leng  (void)
+{
+        return gram_leng;
+}
+
+/** Get the current token.
+ * 
+ */
+
+char *gram_get_text  (void)
+{
+        return gram_text;
+}
+
+/* %if-reentrant */
+/* %endif */
+
+/** Set the current line number.
+ * @param line_number
+ * 
+ */
+void gram_set_lineno (int  line_number )
+{
+    
+    gram_lineno = line_number;
+}
+
+/** Set the input stream. This does not discard the current
+ * input buffer.
+ * @param in_str A readable stream.
+ * 
+ * @see gram__switch_to_buffer
+ */
+void gram_set_in (FILE *  in_str )
+{
+        gram_in = in_str ;
+}
+
+void gram_set_out (FILE *  out_str )
+{
+        gram_out = out_str ;
+}
+
+int gram_get_debug  (void)
+{
+        return gram__flex_debug;
+}
+
+void gram_set_debug (int  bdebug )
+{
+        gram__flex_debug = bdebug ;
+}
+
+/* %endif */
+
+/* %if-reentrant */
+/* %if-bison-bridge */
+/* %endif */
+/* %endif */
+
+/* %if-c-only SNIP! this currently causes conflicts with the c++ scanner */
+/* gram_lex_destroy is for both reentrant and non-reentrant scanners. */
+int gram_lex_destroy  (void)
+{
+    
+    /* Pop the buffer stack, destroying each element. */
+	while(YY_CURRENT_BUFFER){
+		gram__delete_buffer(YY_CURRENT_BUFFER  );
+		YY_CURRENT_BUFFER_LVALUE = NULL;
+		gram_pop_buffer_state();
+	}
+
+	/* Destroy the stack itself. */
+	gram_free((yy_buffer_stack) );
+	(yy_buffer_stack) = NULL;
+
+/* %if-reentrant */
+/* %endif */
+    return 0;
+}
+/* %endif */
+
+/*
+ * Internal utility routines.
+ */
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
+{
+	register int i;
+    	for ( i = 0; i < n; ++i )
+		s1[i] = s2[i];
+}
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * s )
+{
+	register int n;
+    	for ( n = 0; s[n]; ++n )
+		;
+
+	return n;
+}
+#endif
+
+void *gram_alloc (yy_size_t  size )
+{
+	return (void *) malloc( size );
+}
+
+void *gram_realloc  (void * ptr, yy_size_t  size )
+{
+	/* The cast to (char *) in the following accommodates both
+	 * implementations that use char* generic pointers, and those
+	 * that use void* generic pointers.  It works with the latter
+	 * because both ANSI C and C++ allow castless assignment from
+	 * any pointer type to void*, and deal with argument conversions
+	 * as though doing an assignment.
+	 */
+	return (void *) realloc( (char *) ptr, size );
+}
+
+void gram_free (void * ptr )
+{
+	free( (char *) ptr );	/* see gram_realloc() for (char *) cast */
+}
+
+/* %if-tables-serialization definitions */
+/* %define-yytables   The name for this specific scanner's tables. */
+#define YYTABLES_NAME "yytables"
+/* %endif */
+
+/* %ok-for-header */
+
+#undef YY_NEW_FILE
+#undef YY_FLUSH_BUFFER
+#undef yy_set_bol
+#undef yy_new_buffer
+#undef yy_set_interactive
+#undef yytext_ptr
+#undef YY_DO_BEFORE_ACTION
+
+#ifdef YY_DECL_IS_OURS
+#undef YY_DECL_IS_OURS
+#undef YY_DECL
+#endif
+#line 707 "scan-gram.l"
+
+
+
+/* Keeps track of the maximum number of semantic values to the left of
+   a handle (those referenced by $0, $-1, etc.) are required by the
+   semantic actions of this grammar. */
+int max_left_semantic_context = 0;
+
+/* If BUF is null, add BUFSIZE (which in this case must be less than
+   INT_MAX) to COLUMN; otherwise, add mbsnwidth (BUF, BUFSIZE, 0) to
+   COLUMN.  If an overflow occurs, or might occur but is undetectable,
+   return INT_MAX.  Assume COLUMN is nonnegative.  */
+
+static inline int
+add_column_width (int column, char const *buf, size_t bufsize)
+{
+  size_t width;
+  unsigned int remaining_columns = INT_MAX - column;
+
+  if (buf)
+    {
+      if (INT_MAX / 2 <= bufsize)
+	return INT_MAX;
+      width = mbsnwidth (buf, bufsize, 0);
+    }
+  else
+    width = bufsize;
+
+  return width <= remaining_columns ? column + width : INT_MAX;
+}
+
+/* Set *LOC and adjust scanner cursor to account for token TOKEN of
+   size SIZE.  */
+
+static void
+adjust_location (location *loc, char const *token, size_t size)
+{
+  int line = scanner_cursor.line;
+  int column = scanner_cursor.column;
+  char const *p0 = token;
+  char const *p = token;
+  char const *lim = token + size;
+
+  loc->start = scanner_cursor;
+
+  for (p = token; p < lim; p++)
+    switch (*p)
+      {
+      case '\n':
+	line += line < INT_MAX;
+	column = 1;
+	p0 = p + 1;
+	break;
+
+      case '\t':
+	column = add_column_width (column, p0, p - p0);
+	column = add_column_width (column, NULL, 8 - ((column - 1) & 7));
+	p0 = p + 1;
+	break;
+
+      default:
+	break;
+      }
+
+  scanner_cursor.line = line;
+  scanner_cursor.column = column = add_column_width (column, p0, p - p0);
+
+  loc->end = scanner_cursor;
+
+  if (line == INT_MAX && loc->start.line != INT_MAX)
+    warn_at (*loc, _("line number overflow"));
+  if (column == INT_MAX && loc->start.column != INT_MAX)
+    warn_at (*loc, _("column number overflow"));
+}
+
+
+/* Read bytes from FP into buffer BUF of size SIZE.  Return the
+   number of bytes read.  Remove '\r' from input, treating \r\n
+   and isolated \r as \n.  */
+
+static size_t
+no_cr_read (FILE *fp, char *buf, size_t size)
+{
+  size_t bytes_read = fread (buf, 1, size, fp);
+  if (bytes_read)
+    {
+      char *w = memchr (buf, '\r', bytes_read);
+      if (w)
+	{
+	  char const *r = ++w;
+	  char const *lim = buf + bytes_read;
+
+	  for (;;)
+	    {
+	      /* Found an '\r'.  Treat it like '\n', but ignore any
+		 '\n' that immediately follows.  */
+	      w[-1] = '\n';
+	      if (r == lim)
+		{
+		  int ch = getc (fp);
+		  if (ch != '\n' && ungetc (ch, fp) != ch)
+		    break;
+		}
+	      else if (*r == '\n')
+		r++;
+
+	      /* Copy until the next '\r'.  */
+	      do
+		{
+		  if (r == lim)
+		    return w - buf;
+		}
+	      while ((*w++ = *r++) != '\r');
+	    }
+
+	  return w - buf;
+	}
+    }
+
+  return bytes_read;
+}
+
+
+/*------------------------------------------------------------------.
+| TEXT is pointing to a wannabee semantic value (i.e., a `$').      |
+|                                                                   |
+| Possible inputs: $[<TYPENAME>]($|integer)                         |
+|                                                                   |
+| Output to OBSTACK_FOR_STRING a reference to this semantic value.  |
+`------------------------------------------------------------------*/
+
+static inline bool
+handle_action_dollar (char *text, location loc)
+{
+  const char *type_name = NULL;
+  char *cp = text + 1;
+
+  if (! current_rule)
+    return false;
+
+  /* Get the type name if explicit. */
+  if (*cp == '<')
+    {
+      type_name = ++cp;
+      while (*cp != '>')
+	++cp;
+      *cp = '\0';
+      ++cp;
+    }
+
+  if (*cp == '$')
+    {
+      if (!type_name)
+	type_name = symbol_list_n_type_name_get (current_rule, loc, 0);
+      if (!type_name && typed)
+	complain_at (loc, _("$$ of `%s' has no declared type"),
+		     current_rule->sym->tag);
+      if (!type_name)
+	type_name = "";
+      obstack_fgrow1 (&obstack_for_string,
+		      "]b4_lhs_value([%s])[", type_name);
+      current_rule->used = true;
+    }
+  else
+    {
+      long int num = strtol (cp, NULL, 10);
+
+      if (1 - INT_MAX + rule_length <= num && num <= rule_length)
+	{
+	  int n = num;
+	  if (max_left_semantic_context < 1 - n)
+	    max_left_semantic_context = 1 - n;
+	  if (!type_name && 0 < n)
+	    type_name = symbol_list_n_type_name_get (current_rule, loc, n);
+	  if (!type_name && typed)
+	    complain_at (loc, _("$%d of `%s' has no declared type"),
+			 n, current_rule->sym->tag);
+	  if (!type_name)
+	    type_name = "";
+	  obstack_fgrow3 (&obstack_for_string,
+			  "]b4_rhs_value(%d, %d, [%s])[",
+			  rule_length, n, type_name);
+	  symbol_list_n_used_set (current_rule, n, true);
+	}
+      else
+	complain_at (loc, _("integer out of range: %s"), quote (text));
+    }
+
+  return true;
+}
+
+
+/*----------------------------------------------------------------.
+| Map `$?' onto the proper M4 symbol, depending on its TOKEN_TYPE |
+| (are we in an action?).                                         |
+`----------------------------------------------------------------*/
+
+static void
+handle_dollar (int token_type, char *text, location loc)
+{
+  switch (token_type)
+    {
+    case BRACED_CODE:
+      if (handle_action_dollar (text, loc))
+	return;
+      break;
+
+    case PERCENT_DESTRUCTOR:
+    case PERCENT_INITIAL_ACTION:
+    case PERCENT_PRINTER:
+      if (text[1] == '$')
+	{
+	  obstack_sgrow (&obstack_for_string, "]b4_dollar_dollar[");
+	  return;
+	}
+      break;
+
+    default:
+      break;
+    }
+
+  complain_at (loc, _("invalid value: %s"), quote (text));
+}
+
+
+/*------------------------------------------------------.
+| TEXT is a location token (i.e., a `@...').  Output to |
+| OBSTACK_FOR_STRING a reference to this location.      |
+`------------------------------------------------------*/
+
+static inline bool
+handle_action_at (char *text, location loc)
+{
+  char *cp = text + 1;
+  locations_flag = true;
+
+  if (! current_rule)
+    return false;
+
+  if (*cp == '$')
+    obstack_sgrow (&obstack_for_string, "]b4_lhs_location[");
+  else
+    {
+      long int num = strtol (cp, NULL, 10);
+
+      if (1 - INT_MAX + rule_length <= num && num <= rule_length)
+	{
+	  int n = num;
+	  obstack_fgrow2 (&obstack_for_string, "]b4_rhs_location(%d, %d)[",
+			  rule_length, n);
+	}
+      else
+	complain_at (loc, _("integer out of range: %s"), quote (text));
+    }
+
+  return true;
+}
+
+
+/*----------------------------------------------------------------.
+| Map `@?' onto the proper M4 symbol, depending on its TOKEN_TYPE |
+| (are we in an action?).                                         |
+`----------------------------------------------------------------*/
+
+static void
+handle_at (int token_type, char *text, location loc)
+{
+  switch (token_type)
+    {
+    case BRACED_CODE:
+      handle_action_at (text, loc);
+      return;
+
+    case PERCENT_INITIAL_ACTION:
+    case PERCENT_DESTRUCTOR:
+    case PERCENT_PRINTER:
+      if (text[1] == '$')
+	{
+	  obstack_sgrow (&obstack_for_string, "]b4_at_dollar[");
+	  return;
+	}
+      break;
+
+    default:
+      break;
+    }
+
+  complain_at (loc, _("invalid value: %s"), quote (text));
+}
+
+
+/*------------------------------------------------------.
+| Scan NUMBER for a base-BASE integer at location LOC.  |
+`------------------------------------------------------*/
+
+static unsigned long int
+scan_integer (char const *number, int base, location loc)
+{
+  verify (INT_MAX < ULONG_MAX);
+  unsigned long int num = strtoul (number, NULL, base);
+
+  if (INT_MAX < num)
+    {
+      complain_at (loc, _("integer out of range: %s"), quote (number));
+      num = INT_MAX;
+    }
+
+  return num;
+}
+
+
+/*------------------------------------------------------------------.
+| Convert universal character name UCN to a single-byte character,  |
+| and return that character.  Return -1 if UCN does not correspond  |
+| to a single-byte character.					    |
+`------------------------------------------------------------------*/
+
+static int
+convert_ucn_to_byte (char const *ucn)
+{
+  verify (UCHAR_MAX <= INT_MAX);
+  unsigned long int code = strtoul (ucn + 2, NULL, 16);
+
+  /* FIXME: Currently we assume Unicode-compatible unibyte characters
+     on ASCII hosts (i.e., Latin-1 on hosts with 8-bit bytes).  On
+     non-ASCII hosts we support only the portable C character set.
+     These limitations should be removed once we add support for
+     multibyte characters.  */
+
+  if (UCHAR_MAX < code)
+    return -1;
+
+#if ! ('$' == 0x24 && '@' == 0x40 && '`' == 0x60 && '~' == 0x7e)
+  {
+    /* A non-ASCII host.  Use CODE to index into a table of the C
+       basic execution character set, which is guaranteed to exist on
+       all Standard C platforms.  This table also includes '$', '@',
+       and '`', which are not in the basic execution character set but
+       which are unibyte characters on all the platforms that we know
+       about.  */
+    static signed char const table[] =
+      {
+	'\0',   -1,   -1,   -1,   -1,   -1,   -1, '\a',
+	'\b', '\t', '\n', '\v', '\f', '\r',   -1,   -1,
+	  -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+	  -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+	 ' ',  '!',  '"',  '#',  '$',  '%',  '&', '\'',
+	 '(',  ')',  '*',  '+',  ',',  '-',  '.',  '/',
+	 '0',  '1',  '2',  '3',  '4',  '5',  '6',  '7',
+	 '8',  '9',  ':',  ';',  '<',  '=',  '>',  '?',
+	 '@',  'A',  'B',  'C',  'D',  'E',  'F',  'G',
+	 'H',  'I',  'J',  'K',  'L',  'M',  'N',  'O',
+	 'P',  'Q',  'R',  'S',  'T',  'U',  'V',  'W',
+	 'X',  'Y',  'Z',  '[', '\\',  ']',  '^',  '_',
+	 '`',  'a',  'b',  'c',  'd',  'e',  'f',  'g',
+	 'h',  'i',  'j',  'k',  'l',  'm',  'n',  'o',
+	 'p',  'q',  'r',  's',  't',  'u',  'v',  'w',
+	 'x',  'y',  'z',  '{',  '|',  '}',  '~'
+      };
+
+    code = code < sizeof table ? table[code] : -1;
+  }
+#endif
+
+  return code;
+}
+
+
+/*----------------------------------------------------------------.
+| Handle `#line INT "FILE"'.  ARGS has already skipped `#line '.  |
+`----------------------------------------------------------------*/
+
+static void
+handle_syncline (char *args, location loc)
+{
+  char *after_num;
+  unsigned long int lineno = strtoul (args, &after_num, 10);
+  char *file = strchr (after_num, '"') + 1;
+  *strchr (file, '"') = '\0';
+  if (INT_MAX <= lineno)
+    {
+      warn_at (loc, _("line number overflow"));
+      lineno = INT_MAX;
+    }
+  scanner_cursor.file = current_file = uniqstr_new (file);
+  scanner_cursor.line = lineno;
+  scanner_cursor.column = 1;
+}
+
+
+/*---------------------------------.
+| Report a rule that is too long.  |
+`---------------------------------*/
+
+static void
+rule_length_overflow (location loc)
+{
+  fatal_at (loc, _("rule is too long"));
+}
+
+
+/*----------------------------------------------------------------.
+| For a token or comment starting at START, report message MSGID, |
+| which should say that an end marker was found before		  |
+| the expected TOKEN_END.					  |
+`----------------------------------------------------------------*/
+
+static void
+unexpected_end (boundary start, char const *msgid, char const *token_end)
+{
+  location loc;
+  loc.start = start;
+  loc.end = scanner_cursor;
+  complain_at (loc, _(msgid), token_end);
+}
+
+
+/*------------------------------------------------------------------------.
+| Report an unexpected EOF in a token or comment starting at START.       |
+| An end of file was encountered and the expected TOKEN_END was missing.  |
+`------------------------------------------------------------------------*/
+
+static void
+unexpected_eof (boundary start, char const *token_end)
+{
+  unexpected_end (start, N_("missing `%s' at end of file"), token_end);
+}
+
+
+/*----------------------------------------.
+| Likewise, but for unexpected newlines.  |
+`----------------------------------------*/
+
+static void
+unexpected_newline (boundary start, char const *token_end)
+{
+  unexpected_end (start, N_("missing `%s' at end of line"), token_end);
+}
+
+
+/*-------------------------.
+| Initialize the scanner.  |
+`-------------------------*/
+
+void
+scanner_initialize (void)
+{
+  obstack_init (&obstack_for_string);
+}
+
+
+/*-----------------------------------------------.
+| Free all the memory allocated to the scanner.  |
+`-----------------------------------------------*/
+
+void
+scanner_free (void)
+{
+  obstack_free (&obstack_for_string, 0);
+  /* Reclaim Flex's buffers.  */
+  gram__delete_buffer (YY_CURRENT_BUFFER);
+}
+
diff --git a/src/scan-gram.l b/src/scan-gram.l
new file mode 100644
index 0000000..cf704c7
--- /dev/null
+++ b/src/scan-gram.l
@@ -0,0 +1,1167 @@
+/* Bison Grammar Scanner                             -*- C -*-
+
+   Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   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 2 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, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301  USA
+*/
+
+%option debug nodefault nounput noyywrap never-interactive
+%option prefix="gram_" outfile="lex.yy.c"
+
+%{
+/* Work around a bug in flex 2.5.31.  See Debian bug 333231
+   <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=333231>.  */
+#undef gram_wrap
+#define gram_wrap() 1
+
+#include "system.h"
+
+#include <mbswidth.h>
+#include <quote.h>
+
+#include "complain.h"
+#include "files.h"
+#include "getargs.h"
+#include "gram.h"
+#include "quotearg.h"
+#include "reader.h"
+#include "uniqstr.h"
+
+#define YY_USER_INIT					\
+  do							\
+    {							\
+      scanner_cursor.file = current_file;		\
+      scanner_cursor.line = 1;				\
+      scanner_cursor.column = 1;			\
+      code_start = scanner_cursor;			\
+    }							\
+  while (0)
+
+/* Pacify "gcc -Wmissing-prototypes" when flex 2.5.31 is used.  */
+int gram_get_lineno (void);
+FILE *gram_get_in (void);
+FILE *gram_get_out (void);
+int gram_get_leng (void);
+char *gram_get_text (void);
+void gram_set_lineno (int);
+void gram_set_in (FILE *);
+void gram_set_out (FILE *);
+int gram_get_debug (void);
+void gram_set_debug (int);
+int gram_lex_destroy (void);
+
+/* Location of scanner cursor.  */
+boundary scanner_cursor;
+
+static void adjust_location (location *, char const *, size_t);
+#define YY_USER_ACTION  adjust_location (loc, yytext, yyleng);
+
+static size_t no_cr_read (FILE *, char *, size_t);
+#define YY_INPUT(buf, result, size) ((result) = no_cr_read (yyin, buf, size))
+
+
+/* OBSTACK_FOR_STRING -- Used to store all the characters that we need to
+   keep (to construct ID, STRINGS etc.).  Use the following macros to
+   use it.
+
+   Use STRING_GROW to append what has just been matched, and
+   STRING_FINISH to end the string (it puts the ending 0).
+   STRING_FINISH also stores this string in LAST_STRING, which can be
+   used, and which is used by STRING_FREE to free the last string.  */
+
+static struct obstack obstack_for_string;
+
+/* A string representing the most recently saved token.  */
+char *last_string;
+
+/* The location of the most recently saved token, if it was a
+   BRACED_CODE token; otherwise, this has an unspecified value.  */
+location last_braced_code_loc;
+
+#define STRING_GROW   \
+  obstack_grow (&obstack_for_string, yytext, yyleng)
+
+#define STRING_FINISH					\
+  do {							\
+    obstack_1grow (&obstack_for_string, '\0');		\
+    last_string = obstack_finish (&obstack_for_string);	\
+  } while (0)
+
+#define STRING_FREE \
+  obstack_free (&obstack_for_string, last_string)
+
+void
+scanner_last_string_free (void)
+{
+  STRING_FREE;
+}
+
+/* Within well-formed rules, RULE_LENGTH is the number of values in
+   the current rule so far, which says where to find `$0' with respect
+   to the top of the stack.  It is not the same as the rule->length in
+   the case of mid rule actions.
+
+   Outside of well-formed rules, RULE_LENGTH has an undefined value.  */
+static int rule_length;
+
+static void rule_length_overflow (location) __attribute__ ((__noreturn__));
+
+/* Increment the rule length by one, checking for overflow.  */
+static inline void
+increment_rule_length (location loc)
+{
+  rule_length++;
+
+  /* Don't allow rule_length == INT_MAX, since that might cause
+     confusion with strtol if INT_MAX == LONG_MAX.  */
+  if (rule_length == INT_MAX)
+    rule_length_overflow (loc);
+}
+
+static void handle_dollar (int token_type, char *cp, location loc);
+static void handle_at (int token_type, char *cp, location loc);
+static void handle_syncline (char *, location);
+static unsigned long int scan_integer (char const *p, int base, location loc);
+static int convert_ucn_to_byte (char const *hex_text);
+static void unexpected_eof (boundary, char const *);
+static void unexpected_newline (boundary, char const *);
+
+%}
+%x SC_COMMENT SC_LINE_COMMENT SC_YACC_COMMENT
+%x SC_STRING SC_CHARACTER
+%x SC_AFTER_IDENTIFIER
+%x SC_ESCAPED_STRING SC_ESCAPED_CHARACTER
+%x SC_PRE_CODE SC_BRACED_CODE SC_PROLOGUE SC_EPILOGUE
+
+letter	  [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
+id	  {letter}({letter}|[0-9])*
+directive %{letter}({letter}|[0-9]|-)*
+int	  [0-9]+
+
+/* POSIX says that a tag must be both an id and a C union member, but
+   historically almost any character is allowed in a tag.  We disallow
+   NUL and newline, as this simplifies our implementation.  */
+tag	 [^\0\n>]+
+
+/* Zero or more instances of backslash-newline.  Following GCC, allow
+   white space between the backslash and the newline.  */
+splice	 (\\[ \f\t\v]*\n)*
+
+%%
+%{
+  /* Nesting level of the current code in braces.  */
+  int braces_level IF_LINT (= 0);
+
+  /* Parent context state, when applicable.  */
+  int context_state IF_LINT (= 0);
+
+  /* Token type to return, when applicable.  */
+  int token_type IF_LINT (= 0);
+
+  /* Location of most recent identifier, when applicable.  */
+  location id_loc IF_LINT (= empty_location);
+
+  /* Where containing code started, when applicable.  Its initial
+     value is relevant only when yylex is invoked in the SC_EPILOGUE
+     start condition.  */
+  boundary code_start = scanner_cursor;
+
+  /* Where containing comment or string or character literal started,
+     when applicable.  */
+  boundary token_start IF_LINT (= scanner_cursor);
+%}
+
+
+  /*-----------------------.
+  | Scanning white space.  |
+  `-----------------------*/
+
+<INITIAL,SC_AFTER_IDENTIFIER,SC_PRE_CODE>
+{
+  /* Comments and white space.  */
+  ","	       warn_at (*loc, _("stray `,' treated as white space"));
+  [ \f\n\t\v]  |
+  "//".*       ;
+  "/*" {
+    token_start = loc->start;
+    context_state = YY_START;
+    BEGIN SC_YACC_COMMENT;
+  }
+
+  /* #line directives are not documented, and may be withdrawn or
+     modified in future versions of Bison.  */
+  ^"#line "{int}" \"".*"\"\n" {
+    handle_syncline (yytext + sizeof "#line " - 1, *loc);
+  }
+}
+
+
+  /*----------------------------.
+  | Scanning Bison directives.  |
+  `----------------------------*/
+<INITIAL>
+{
+  "%binary"               return PERCENT_NONASSOC;
+  "%debug"                return PERCENT_DEBUG;
+  "%default"[-_]"prec"    return PERCENT_DEFAULT_PREC;
+  "%define"               return PERCENT_DEFINE;
+  "%defines"              return PERCENT_DEFINES;
+  "%destructor"		  token_type = PERCENT_DESTRUCTOR; BEGIN SC_PRE_CODE;
+  "%dprec"		  return PERCENT_DPREC;
+  "%error"[-_]"verbose"   return PERCENT_ERROR_VERBOSE;
+  "%expect"               return PERCENT_EXPECT;
+  "%expect"[-_]"rr"	  return PERCENT_EXPECT_RR;
+  "%file-prefix"          return PERCENT_FILE_PREFIX;
+  "%fixed"[-_]"output"[-_]"files"   return PERCENT_YACC;
+  "%initial-action"       token_type = PERCENT_INITIAL_ACTION; BEGIN SC_PRE_CODE;
+  "%glr-parser"           return PERCENT_GLR_PARSER;
+  "%left"                 return PERCENT_LEFT;
+  "%lex-param"		  token_type = PERCENT_LEX_PARAM; BEGIN SC_PRE_CODE;
+  "%locations"            return PERCENT_LOCATIONS;
+  "%merge"		  return PERCENT_MERGE;
+  "%name"[-_]"prefix"     return PERCENT_NAME_PREFIX;
+  "%no"[-_]"default"[-_]"prec"	return PERCENT_NO_DEFAULT_PREC;
+  "%no"[-_]"lines"        return PERCENT_NO_LINES;
+  "%nonassoc"             return PERCENT_NONASSOC;
+  "%nondeterministic-parser"   return PERCENT_NONDETERMINISTIC_PARSER;
+  "%nterm"                return PERCENT_NTERM;
+  "%output"               return PERCENT_OUTPUT;
+  "%parse-param"	  token_type = PERCENT_PARSE_PARAM; BEGIN SC_PRE_CODE;
+  "%prec"                 rule_length--; return PERCENT_PREC;
+  "%printer"              token_type = PERCENT_PRINTER; BEGIN SC_PRE_CODE;
+  "%pure"[-_]"parser"     return PERCENT_PURE_PARSER;
+  "%require"              return PERCENT_REQUIRE;
+  "%right"                return PERCENT_RIGHT;
+  "%skeleton"             return PERCENT_SKELETON;
+  "%start"                return PERCENT_START;
+  "%term"                 return PERCENT_TOKEN;
+  "%token"                return PERCENT_TOKEN;
+  "%token"[-_]"table"     return PERCENT_TOKEN_TABLE;
+  "%type"                 return PERCENT_TYPE;
+  "%union"		  token_type = PERCENT_UNION; BEGIN SC_PRE_CODE;
+  "%verbose"              return PERCENT_VERBOSE;
+  "%yacc"                 return PERCENT_YACC;
+
+  {directive} {
+    complain_at (*loc, _("invalid directive: %s"), quote (yytext));
+  }
+
+  "="                     return EQUAL;
+  "|"                     rule_length = 0; return PIPE;
+  ";"                     return SEMICOLON;
+
+  {id} {
+    val->symbol = symbol_get (yytext, *loc);
+    id_loc = *loc;
+    increment_rule_length (*loc);
+    BEGIN SC_AFTER_IDENTIFIER;
+  }
+
+  {int} {
+    val->integer = scan_integer (yytext, 10, *loc);
+    return INT;
+  }
+  0[xX][0-9abcdefABCDEF]+ {
+    val->integer = scan_integer (yytext, 16, *loc);
+    return INT;
+  }
+
+  /* Characters.  We don't check there is only one.  */
+  "'"	      STRING_GROW; token_start = loc->start; BEGIN SC_ESCAPED_CHARACTER;
+
+  /* Strings. */
+  "\""	      token_start = loc->start; BEGIN SC_ESCAPED_STRING;
+
+  /* Prologue. */
+  "%{"        code_start = loc->start; BEGIN SC_PROLOGUE;
+
+  /* Code in between braces.  */
+  "{" {
+    if (current_rule && current_rule->action)
+      grammar_midrule_action ();
+    STRING_GROW;
+    token_type = BRACED_CODE;
+    braces_level = 0;
+    code_start = loc->start;
+    BEGIN SC_BRACED_CODE;
+  }
+
+  /* A type. */
+  "<"{tag}">" {
+    obstack_grow (&obstack_for_string, yytext + 1, yyleng - 2);
+    STRING_FINISH;
+    val->uniqstr = uniqstr_new (last_string);
+    STRING_FREE;
+    return TYPE;
+  }
+
+  "%%" {
+    static int percent_percent_count;
+    if (++percent_percent_count == 2)
+      BEGIN SC_EPILOGUE;
+    return PERCENT_PERCENT;
+  }
+
+  . {
+    complain_at (*loc, _("invalid character: %s"), quote (yytext));
+  }
+
+  <<EOF>> {
+    loc->start = loc->end = scanner_cursor;
+    yyterminate ();
+  }
+}
+
+
+  /*-----------------------------------------------------------------.
+  | Scanning after an identifier, checking whether a colon is next.  |
+  `-----------------------------------------------------------------*/
+
+<SC_AFTER_IDENTIFIER>
+{
+  ":" {
+    rule_length = 0;
+    *loc = id_loc;
+    BEGIN INITIAL;
+    return ID_COLON;
+  }
+  . {
+    scanner_cursor.column -= mbsnwidth (yytext, yyleng, 0);
+    yyless (0);
+    *loc = id_loc;
+    BEGIN INITIAL;
+    return ID;
+  }
+  <<EOF>> {
+    *loc = id_loc;
+    BEGIN INITIAL;
+    return ID;
+  }
+}
+
+
+  /*---------------------------------------------------------------.
+  | Scanning a Yacc comment.  The initial `/ *' is already eaten.  |
+  `---------------------------------------------------------------*/
+
+<SC_YACC_COMMENT>
+{
+  "*/"     BEGIN context_state;
+  .|\n	   ;
+  <<EOF>>  unexpected_eof (token_start, "*/"); BEGIN context_state;
+}
+
+
+  /*------------------------------------------------------------.
+  | Scanning a C comment.  The initial `/ *' is already eaten.  |
+  `------------------------------------------------------------*/
+
+<SC_COMMENT>
+{
+  "*"{splice}"/"  STRING_GROW; BEGIN context_state;
+  <<EOF>>	  unexpected_eof (token_start, "*/"); BEGIN context_state;
+}
+
+
+  /*--------------------------------------------------------------.
+  | Scanning a line comment.  The initial `//' is already eaten.  |
+  `--------------------------------------------------------------*/
+
+<SC_LINE_COMMENT>
+{
+  "\n"		 STRING_GROW; BEGIN context_state;
+  {splice}	 STRING_GROW;
+  <<EOF>>	 BEGIN context_state;
+}
+
+
+  /*------------------------------------------------.
+  | Scanning a Bison string, including its escapes. |
+  | The initial quote is already eaten.             |
+  `------------------------------------------------*/
+
+<SC_ESCAPED_STRING>
+{
+  "\"" {
+    STRING_FINISH;
+    loc->start = token_start;
+    val->chars = last_string;
+    increment_rule_length (*loc);
+    BEGIN INITIAL;
+    return STRING;
+  }
+  \n		unexpected_newline (token_start, "\"");	BEGIN INITIAL;
+  <<EOF>>	unexpected_eof (token_start, "\"");	BEGIN INITIAL;
+}
+
+  /*----------------------------------------------------------.
+  | Scanning a Bison character literal, decoding its escapes. |
+  | The initial quote is already eaten.			      |
+  `----------------------------------------------------------*/
+
+<SC_ESCAPED_CHARACTER>
+{
+  "'" {
+    unsigned char last_string_1;
+    STRING_GROW;
+    STRING_FINISH;
+    loc->start = token_start;
+    val->symbol = symbol_get (quotearg_style (escape_quoting_style,
+					      last_string),
+			      *loc);
+    symbol_class_set (val->symbol, token_sym, *loc, false);
+    last_string_1 = last_string[1];
+    symbol_user_token_number_set (val->symbol, last_string_1, *loc);
+    STRING_FREE;
+    increment_rule_length (*loc);
+    BEGIN INITIAL;
+    return ID;
+  }
+  \n		unexpected_newline (token_start, "'");	BEGIN INITIAL;
+  <<EOF>>	unexpected_eof (token_start, "'");	BEGIN INITIAL;
+}
+
+<SC_ESCAPED_CHARACTER,SC_ESCAPED_STRING>
+{
+  \0	    complain_at (*loc, _("invalid null character"));
+}
+
+
+  /*----------------------------.
+  | Decode escaped characters.  |
+  `----------------------------*/
+
+<SC_ESCAPED_STRING,SC_ESCAPED_CHARACTER>
+{
+  \\[0-7]{1,3} {
+    unsigned long int c = strtoul (yytext + 1, NULL, 8);
+    if (UCHAR_MAX < c)
+      complain_at (*loc, _("invalid escape sequence: %s"), quote (yytext));
+    else if (! c)
+      complain_at (*loc, _("invalid null character: %s"), quote (yytext));
+    else
+      obstack_1grow (&obstack_for_string, c);
+  }
+
+  \\x[0-9abcdefABCDEF]+ {
+    verify (UCHAR_MAX < ULONG_MAX);
+    unsigned long int c = strtoul (yytext + 2, NULL, 16);
+    if (UCHAR_MAX < c)
+      complain_at (*loc, _("invalid escape sequence: %s"), quote (yytext));
+    else if (! c)
+      complain_at (*loc, _("invalid null character: %s"), quote (yytext));
+    else
+      obstack_1grow (&obstack_for_string, c);
+  }
+
+  \\a	obstack_1grow (&obstack_for_string, '\a');
+  \\b	obstack_1grow (&obstack_for_string, '\b');
+  \\f	obstack_1grow (&obstack_for_string, '\f');
+  \\n	obstack_1grow (&obstack_for_string, '\n');
+  \\r	obstack_1grow (&obstack_for_string, '\r');
+  \\t	obstack_1grow (&obstack_for_string, '\t');
+  \\v	obstack_1grow (&obstack_for_string, '\v');
+
+  /* \\[\"\'?\\] would be shorter, but it confuses xgettext.  */
+  \\("\""|"'"|"?"|"\\")  obstack_1grow (&obstack_for_string, yytext[1]);
+
+  \\(u|U[0-9abcdefABCDEF]{4})[0-9abcdefABCDEF]{4} {
+    int c = convert_ucn_to_byte (yytext);
+    if (c < 0)
+      complain_at (*loc, _("invalid escape sequence: %s"), quote (yytext));
+    else if (! c)
+      complain_at (*loc, _("invalid null character: %s"), quote (yytext));
+    else
+      obstack_1grow (&obstack_for_string, c);
+  }
+  \\(.|\n)	{
+    complain_at (*loc, _("unrecognized escape sequence: %s"), quote (yytext));
+    STRING_GROW;
+  }
+}
+
+  /*--------------------------------------------.
+  | Scanning user-code characters and strings.  |
+  `--------------------------------------------*/
+
+<SC_CHARACTER,SC_STRING>
+{
+  {splice}|\\{splice}[^\n$@\[\]]	STRING_GROW;
+}
+
+<SC_CHARACTER>
+{
+  "'"		STRING_GROW; BEGIN context_state;
+  \n		unexpected_newline (token_start, "'"); BEGIN context_state;
+  <<EOF>>	unexpected_eof (token_start, "'"); BEGIN context_state;
+}
+
+<SC_STRING>
+{
+  "\""		STRING_GROW; BEGIN context_state;
+  \n		unexpected_newline (token_start, "\""); BEGIN context_state;
+  <<EOF>>	unexpected_eof (token_start, "\""); BEGIN context_state;
+}
+
+
+  /*---------------------------------------------------.
+  | Strings, comments etc. can be found in user code.  |
+  `---------------------------------------------------*/
+
+<SC_BRACED_CODE,SC_PROLOGUE,SC_EPILOGUE>
+{
+  "'" {
+    STRING_GROW;
+    context_state = YY_START;
+    token_start = loc->start;
+    BEGIN SC_CHARACTER;
+  }
+  "\"" {
+    STRING_GROW;
+    context_state = YY_START;
+    token_start = loc->start;
+    BEGIN SC_STRING;
+  }
+  "/"{splice}"*" {
+    STRING_GROW;
+    context_state = YY_START;
+    token_start = loc->start;
+    BEGIN SC_COMMENT;
+  }
+  "/"{splice}"/" {
+    STRING_GROW;
+    context_state = YY_START;
+    BEGIN SC_LINE_COMMENT;
+  }
+}
+
+
+  /*---------------------------------------------------------------.
+  | Scanning after %union etc., possibly followed by white space.  |
+  | For %union only, allow arbitrary C code to appear before the   |
+  | following brace, as an extension to POSIX.			   |
+  `---------------------------------------------------------------*/
+
+<SC_PRE_CODE>
+{
+  . {
+    bool valid = yytext[0] == '{' || token_type == PERCENT_UNION;
+    scanner_cursor.column -= mbsnwidth (yytext, yyleng, 0);
+    yyless (0);
+
+    if (valid)
+      {
+	braces_level = -1;
+	code_start = loc->start;
+	BEGIN SC_BRACED_CODE;
+      }
+    else
+      {
+	complain_at (*loc, _("missing `{' in %s"),
+		     token_name (token_type));
+	obstack_sgrow (&obstack_for_string, "{}");
+	STRING_FINISH;
+	val->chars = last_string;
+	BEGIN INITIAL;
+	return token_type;
+      }
+  }
+
+  <<EOF>>  unexpected_eof (scanner_cursor, "{}"); BEGIN INITIAL;
+}
+
+
+  /*---------------------------------------------------------------.
+  | Scanning some code in braces (%union and actions). The initial |
+  | "{" is already eaten.                                          |
+  `---------------------------------------------------------------*/
+
+<SC_BRACED_CODE>
+{
+  "{"|"<"{splice}"%"  STRING_GROW; braces_level++;
+  "%"{splice}">"      STRING_GROW; braces_level--;
+  "}" {
+    bool outer_brace = --braces_level < 0;
+
+    /* As an undocumented Bison extension, append `;' before the last
+       brace in braced code, so that the user code can omit trailing
+       `;'.  But do not append `;' if emulating Yacc, since Yacc does
+       not append one.
+
+       FIXME: Bison should warn if a semicolon seems to be necessary
+       here, and should omit the semicolon if it seems unnecessary
+       (e.g., after ';', '{', or '}', each followed by comments or
+       white space).  Such a warning shouldn't depend on --yacc; it
+       should depend on a new --pedantic option, which would cause
+       Bison to warn if it detects an extension to POSIX.  --pedantic
+       should also diagnose other Bison extensions like %yacc.
+       Perhaps there should also be a GCC-style --pedantic-errors
+       option, so that such warnings are diagnosed as errors.  */
+    if (outer_brace && token_type == BRACED_CODE && ! yacc_flag)
+      obstack_1grow (&obstack_for_string, ';');
+
+    obstack_1grow (&obstack_for_string, '}');
+
+    if (outer_brace)
+      {
+	STRING_FINISH;
+	loc->start = code_start;
+	val->chars = last_string;
+	increment_rule_length (*loc);
+	last_braced_code_loc = *loc;
+	BEGIN INITIAL;
+	return token_type;
+      }
+  }
+
+  /* Tokenize `<<%' correctly (as `<<' `%') rather than incorrrectly
+     (as `<' `<%').  */
+  "<"{splice}"<"  STRING_GROW;
+
+  "$"("<"{tag}">")?(-?[0-9]+|"$")  handle_dollar (token_type, yytext, *loc);
+  "@"(-?[0-9]+|"$")		   handle_at (token_type, yytext, *loc);
+
+  "$"  {
+    warn_at (*loc, _("stray `$'"));
+    obstack_sgrow (&obstack_for_string, "$][");
+  }
+  "@"  {
+    warn_at (*loc, _("stray `@'"));
+    obstack_sgrow (&obstack_for_string, "@@");
+  }
+
+  <<EOF>>  unexpected_eof (code_start, "}"); BEGIN INITIAL;
+}
+
+
+  /*--------------------------------------------------------------.
+  | Scanning some prologue: from "%{" (already scanned) to "%}".  |
+  `--------------------------------------------------------------*/
+
+<SC_PROLOGUE>
+{
+  "%}" {
+    STRING_FINISH;
+    loc->start = code_start;
+    val->chars = last_string;
+    BEGIN INITIAL;
+    return PROLOGUE;
+  }
+
+  <<EOF>>  unexpected_eof (code_start, "%}"); BEGIN INITIAL;
+}
+
+
+  /*---------------------------------------------------------------.
+  | Scanning the epilogue (everything after the second "%%", which |
+  | has already been eaten).                                       |
+  `---------------------------------------------------------------*/
+
+<SC_EPILOGUE>
+{
+  <<EOF>> {
+    STRING_FINISH;
+    loc->start = code_start;
+    val->chars = last_string;
+    BEGIN INITIAL;
+    return EPILOGUE;
+  }
+}
+
+
+  /*-----------------------------------------.
+  | Escape M4 quoting characters in C code.  |
+  `-----------------------------------------*/
+
+<SC_COMMENT,SC_LINE_COMMENT,SC_STRING,SC_CHARACTER,SC_BRACED_CODE,SC_PROLOGUE,SC_EPILOGUE>
+{
+  \$	obstack_sgrow (&obstack_for_string, "$][");
+  \@	obstack_sgrow (&obstack_for_string, "@@");
+  \[	obstack_sgrow (&obstack_for_string, "@{");
+  \]	obstack_sgrow (&obstack_for_string, "@}");
+}
+
+
+  /*-----------------------------------------------------.
+  | By default, grow the string obstack with the input.  |
+  `-----------------------------------------------------*/
+
+<SC_COMMENT,SC_LINE_COMMENT,SC_BRACED_CODE,SC_PROLOGUE,SC_EPILOGUE,SC_STRING,SC_CHARACTER,SC_ESCAPED_STRING,SC_ESCAPED_CHARACTER>.	|
+<SC_COMMENT,SC_LINE_COMMENT,SC_BRACED_CODE,SC_PROLOGUE,SC_EPILOGUE>\n	STRING_GROW;
+
+%%
+
+/* Keeps track of the maximum number of semantic values to the left of
+   a handle (those referenced by $0, $-1, etc.) are required by the
+   semantic actions of this grammar. */
+int max_left_semantic_context = 0;
+
+/* If BUF is null, add BUFSIZE (which in this case must be less than
+   INT_MAX) to COLUMN; otherwise, add mbsnwidth (BUF, BUFSIZE, 0) to
+   COLUMN.  If an overflow occurs, or might occur but is undetectable,
+   return INT_MAX.  Assume COLUMN is nonnegative.  */
+
+static inline int
+add_column_width (int column, char const *buf, size_t bufsize)
+{
+  size_t width;
+  unsigned int remaining_columns = INT_MAX - column;
+
+  if (buf)
+    {
+      if (INT_MAX / 2 <= bufsize)
+	return INT_MAX;
+      width = mbsnwidth (buf, bufsize, 0);
+    }
+  else
+    width = bufsize;
+
+  return width <= remaining_columns ? column + width : INT_MAX;
+}
+
+/* Set *LOC and adjust scanner cursor to account for token TOKEN of
+   size SIZE.  */
+
+static void
+adjust_location (location *loc, char const *token, size_t size)
+{
+  int line = scanner_cursor.line;
+  int column = scanner_cursor.column;
+  char const *p0 = token;
+  char const *p = token;
+  char const *lim = token + size;
+
+  loc->start = scanner_cursor;
+
+  for (p = token; p < lim; p++)
+    switch (*p)
+      {
+      case '\n':
+	line += line < INT_MAX;
+	column = 1;
+	p0 = p + 1;
+	break;
+
+      case '\t':
+	column = add_column_width (column, p0, p - p0);
+	column = add_column_width (column, NULL, 8 - ((column - 1) & 7));
+	p0 = p + 1;
+	break;
+
+      default:
+	break;
+      }
+
+  scanner_cursor.line = line;
+  scanner_cursor.column = column = add_column_width (column, p0, p - p0);
+
+  loc->end = scanner_cursor;
+
+  if (line == INT_MAX && loc->start.line != INT_MAX)
+    warn_at (*loc, _("line number overflow"));
+  if (column == INT_MAX && loc->start.column != INT_MAX)
+    warn_at (*loc, _("column number overflow"));
+}
+
+
+/* Read bytes from FP into buffer BUF of size SIZE.  Return the
+   number of bytes read.  Remove '\r' from input, treating \r\n
+   and isolated \r as \n.  */
+
+static size_t
+no_cr_read (FILE *fp, char *buf, size_t size)
+{
+  size_t bytes_read = fread (buf, 1, size, fp);
+  if (bytes_read)
+    {
+      char *w = memchr (buf, '\r', bytes_read);
+      if (w)
+	{
+	  char const *r = ++w;
+	  char const *lim = buf + bytes_read;
+
+	  for (;;)
+	    {
+	      /* Found an '\r'.  Treat it like '\n', but ignore any
+		 '\n' that immediately follows.  */
+	      w[-1] = '\n';
+	      if (r == lim)
+		{
+		  int ch = getc (fp);
+		  if (ch != '\n' && ungetc (ch, fp) != ch)
+		    break;
+		}
+	      else if (*r == '\n')
+		r++;
+
+	      /* Copy until the next '\r'.  */
+	      do
+		{
+		  if (r == lim)
+		    return w - buf;
+		}
+	      while ((*w++ = *r++) != '\r');
+	    }
+
+	  return w - buf;
+	}
+    }
+
+  return bytes_read;
+}
+
+
+/*------------------------------------------------------------------.
+| TEXT is pointing to a wannabee semantic value (i.e., a `$').      |
+|                                                                   |
+| Possible inputs: $[<TYPENAME>]($|integer)                         |
+|                                                                   |
+| Output to OBSTACK_FOR_STRING a reference to this semantic value.  |
+`------------------------------------------------------------------*/
+
+static inline bool
+handle_action_dollar (char *text, location loc)
+{
+  const char *type_name = NULL;
+  char *cp = text + 1;
+
+  if (! current_rule)
+    return false;
+
+  /* Get the type name if explicit. */
+  if (*cp == '<')
+    {
+      type_name = ++cp;
+      while (*cp != '>')
+	++cp;
+      *cp = '\0';
+      ++cp;
+    }
+
+  if (*cp == '$')
+    {
+      if (!type_name)
+	type_name = symbol_list_n_type_name_get (current_rule, loc, 0);
+      if (!type_name && typed)
+	complain_at (loc, _("$$ of `%s' has no declared type"),
+		     current_rule->sym->tag);
+      if (!type_name)
+	type_name = "";
+      obstack_fgrow1 (&obstack_for_string,
+		      "]b4_lhs_value([%s])[", type_name);
+      current_rule->used = true;
+    }
+  else
+    {
+      long int num = strtol (cp, NULL, 10);
+
+      if (1 - INT_MAX + rule_length <= num && num <= rule_length)
+	{
+	  int n = num;
+	  if (max_left_semantic_context < 1 - n)
+	    max_left_semantic_context = 1 - n;
+	  if (!type_name && 0 < n)
+	    type_name = symbol_list_n_type_name_get (current_rule, loc, n);
+	  if (!type_name && typed)
+	    complain_at (loc, _("$%d of `%s' has no declared type"),
+			 n, current_rule->sym->tag);
+	  if (!type_name)
+	    type_name = "";
+	  obstack_fgrow3 (&obstack_for_string,
+			  "]b4_rhs_value(%d, %d, [%s])[",
+			  rule_length, n, type_name);
+	  symbol_list_n_used_set (current_rule, n, true);
+	}
+      else
+	complain_at (loc, _("integer out of range: %s"), quote (text));
+    }
+
+  return true;
+}
+
+
+/*----------------------------------------------------------------.
+| Map `$?' onto the proper M4 symbol, depending on its TOKEN_TYPE |
+| (are we in an action?).                                         |
+`----------------------------------------------------------------*/
+
+static void
+handle_dollar (int token_type, char *text, location loc)
+{
+  switch (token_type)
+    {
+    case BRACED_CODE:
+      if (handle_action_dollar (text, loc))
+	return;
+      break;
+
+    case PERCENT_DESTRUCTOR:
+    case PERCENT_INITIAL_ACTION:
+    case PERCENT_PRINTER:
+      if (text[1] == '$')
+	{
+	  obstack_sgrow (&obstack_for_string, "]b4_dollar_dollar[");
+	  return;
+	}
+      break;
+
+    default:
+      break;
+    }
+
+  complain_at (loc, _("invalid value: %s"), quote (text));
+}
+
+
+/*------------------------------------------------------.
+| TEXT is a location token (i.e., a `@...').  Output to |
+| OBSTACK_FOR_STRING a reference to this location.      |
+`------------------------------------------------------*/
+
+static inline bool
+handle_action_at (char *text, location loc)
+{
+  char *cp = text + 1;
+  locations_flag = true;
+
+  if (! current_rule)
+    return false;
+
+  if (*cp == '$')
+    obstack_sgrow (&obstack_for_string, "]b4_lhs_location[");
+  else
+    {
+      long int num = strtol (cp, NULL, 10);
+
+      if (1 - INT_MAX + rule_length <= num && num <= rule_length)
+	{
+	  int n = num;
+	  obstack_fgrow2 (&obstack_for_string, "]b4_rhs_location(%d, %d)[",
+			  rule_length, n);
+	}
+      else
+	complain_at (loc, _("integer out of range: %s"), quote (text));
+    }
+
+  return true;
+}
+
+
+/*----------------------------------------------------------------.
+| Map `@?' onto the proper M4 symbol, depending on its TOKEN_TYPE |
+| (are we in an action?).                                         |
+`----------------------------------------------------------------*/
+
+static void
+handle_at (int token_type, char *text, location loc)
+{
+  switch (token_type)
+    {
+    case BRACED_CODE:
+      handle_action_at (text, loc);
+      return;
+
+    case PERCENT_INITIAL_ACTION:
+    case PERCENT_DESTRUCTOR:
+    case PERCENT_PRINTER:
+      if (text[1] == '$')
+	{
+	  obstack_sgrow (&obstack_for_string, "]b4_at_dollar[");
+	  return;
+	}
+      break;
+
+    default:
+      break;
+    }
+
+  complain_at (loc, _("invalid value: %s"), quote (text));
+}
+
+
+/*------------------------------------------------------.
+| Scan NUMBER for a base-BASE integer at location LOC.  |
+`------------------------------------------------------*/
+
+static unsigned long int
+scan_integer (char const *number, int base, location loc)
+{
+  verify (INT_MAX < ULONG_MAX);
+  unsigned long int num = strtoul (number, NULL, base);
+
+  if (INT_MAX < num)
+    {
+      complain_at (loc, _("integer out of range: %s"), quote (number));
+      num = INT_MAX;
+    }
+
+  return num;
+}
+
+
+/*------------------------------------------------------------------.
+| Convert universal character name UCN to a single-byte character,  |
+| and return that character.  Return -1 if UCN does not correspond  |
+| to a single-byte character.					    |
+`------------------------------------------------------------------*/
+
+static int
+convert_ucn_to_byte (char const *ucn)
+{
+  verify (UCHAR_MAX <= INT_MAX);
+  unsigned long int code = strtoul (ucn + 2, NULL, 16);
+
+  /* FIXME: Currently we assume Unicode-compatible unibyte characters
+     on ASCII hosts (i.e., Latin-1 on hosts with 8-bit bytes).  On
+     non-ASCII hosts we support only the portable C character set.
+     These limitations should be removed once we add support for
+     multibyte characters.  */
+
+  if (UCHAR_MAX < code)
+    return -1;
+
+#if ! ('$' == 0x24 && '@' == 0x40 && '`' == 0x60 && '~' == 0x7e)
+  {
+    /* A non-ASCII host.  Use CODE to index into a table of the C
+       basic execution character set, which is guaranteed to exist on
+       all Standard C platforms.  This table also includes '$', '@',
+       and '`', which are not in the basic execution character set but
+       which are unibyte characters on all the platforms that we know
+       about.  */
+    static signed char const table[] =
+      {
+	'\0',   -1,   -1,   -1,   -1,   -1,   -1, '\a',
+	'\b', '\t', '\n', '\v', '\f', '\r',   -1,   -1,
+	  -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+	  -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+	 ' ',  '!',  '"',  '#',  '$',  '%',  '&', '\'',
+	 '(',  ')',  '*',  '+',  ',',  '-',  '.',  '/',
+	 '0',  '1',  '2',  '3',  '4',  '5',  '6',  '7',
+	 '8',  '9',  ':',  ';',  '<',  '=',  '>',  '?',
+	 '@',  'A',  'B',  'C',  'D',  'E',  'F',  'G',
+	 'H',  'I',  'J',  'K',  'L',  'M',  'N',  'O',
+	 'P',  'Q',  'R',  'S',  'T',  'U',  'V',  'W',
+	 'X',  'Y',  'Z',  '[', '\\',  ']',  '^',  '_',
+	 '`',  'a',  'b',  'c',  'd',  'e',  'f',  'g',
+	 'h',  'i',  'j',  'k',  'l',  'm',  'n',  'o',
+	 'p',  'q',  'r',  's',  't',  'u',  'v',  'w',
+	 'x',  'y',  'z',  '{',  '|',  '}',  '~'
+      };
+
+    code = code < sizeof table ? table[code] : -1;
+  }
+#endif
+
+  return code;
+}
+
+
+/*----------------------------------------------------------------.
+| Handle `#line INT "FILE"'.  ARGS has already skipped `#line '.  |
+`----------------------------------------------------------------*/
+
+static void
+handle_syncline (char *args, location loc)
+{
+  char *after_num;
+  unsigned long int lineno = strtoul (args, &after_num, 10);
+  char *file = strchr (after_num, '"') + 1;
+  *strchr (file, '"') = '\0';
+  if (INT_MAX <= lineno)
+    {
+      warn_at (loc, _("line number overflow"));
+      lineno = INT_MAX;
+    }
+  scanner_cursor.file = current_file = uniqstr_new (file);
+  scanner_cursor.line = lineno;
+  scanner_cursor.column = 1;
+}
+
+
+/*---------------------------------.
+| Report a rule that is too long.  |
+`---------------------------------*/
+
+static void
+rule_length_overflow (location loc)
+{
+  fatal_at (loc, _("rule is too long"));
+}
+
+
+/*----------------------------------------------------------------.
+| For a token or comment starting at START, report message MSGID, |
+| which should say that an end marker was found before		  |
+| the expected TOKEN_END.					  |
+`----------------------------------------------------------------*/
+
+static void
+unexpected_end (boundary start, char const *msgid, char const *token_end)
+{
+  location loc;
+  loc.start = start;
+  loc.end = scanner_cursor;
+  complain_at (loc, _(msgid), token_end);
+}
+
+
+/*------------------------------------------------------------------------.
+| Report an unexpected EOF in a token or comment starting at START.       |
+| An end of file was encountered and the expected TOKEN_END was missing.  |
+`------------------------------------------------------------------------*/
+
+static void
+unexpected_eof (boundary start, char const *token_end)
+{
+  unexpected_end (start, N_("missing `%s' at end of file"), token_end);
+}
+
+
+/*----------------------------------------.
+| Likewise, but for unexpected newlines.  |
+`----------------------------------------*/
+
+static void
+unexpected_newline (boundary start, char const *token_end)
+{
+  unexpected_end (start, N_("missing `%s' at end of line"), token_end);
+}
+
+
+/*-------------------------.
+| Initialize the scanner.  |
+`-------------------------*/
+
+void
+scanner_initialize (void)
+{
+  obstack_init (&obstack_for_string);
+}
+
+
+/*-----------------------------------------------.
+| Free all the memory allocated to the scanner.  |
+`-----------------------------------------------*/
+
+void
+scanner_free (void)
+{
+  obstack_free (&obstack_for_string, 0);
+  /* Reclaim Flex's buffers.  */
+  yy_delete_buffer (YY_CURRENT_BUFFER);
+}
diff --git a/src/scan-skel-c.c b/src/scan-skel-c.c
new file mode 100644
index 0000000..1a047cf
--- /dev/null
+++ b/src/scan-skel-c.c
@@ -0,0 +1,2 @@
+#include <config.h>
+#include "scan-skel.c"
diff --git a/src/scan-skel.c b/src/scan-skel.c
new file mode 100644
index 0000000..f2dd18c
--- /dev/null
+++ b/src/scan-skel.c
@@ -0,0 +1,2134 @@
+#line 2 "scan-skel.c"
+
+#line 4 "scan-skel.c"
+
+#define  YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+#define YY_FLEX_SUBMINOR_VERSION 31
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+/* %if-c++-only */
+/* %endif */
+
+/* %if-c-only */
+    
+/* %endif */
+
+/* %if-c-only */
+
+/* %endif */
+
+/* First, we deal with  platform-specific or compiler-specific issues. */
+
+/* begin standard C headers. */
+/* %if-c-only */
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+/* %endif */
+
+/* %if-tables-serialization */
+/* %endif */
+/* end standard C headers. */
+
+/* %if-c-or-c++ */
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
+
+#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+#include <inttypes.h>
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t; 
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+#endif /* ! C99 */
+
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN               (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN              (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN              (-2147483647-1)
+#endif
+#ifndef INT8_MAX
+#define INT8_MAX               (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX              (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX              (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX              (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX             (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX             (4294967295U)
+#endif
+
+#endif /* ! FLEXINT_H */
+
+/* %endif */
+
+/* %if-c++-only */
+/* %endif */
+
+#ifdef __cplusplus
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else	/* ! __cplusplus */
+
+#if __STDC__
+
+#define YY_USE_CONST
+
+#endif	/* __STDC__ */
+#endif	/* ! __cplusplus */
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+/* %not-for-header */
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+/* %ok-for-header */
+
+/* %not-for-header */
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index.  If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+/* %ok-for-header */
+
+/* %if-reentrant */
+/* %endif */
+
+/* %if-not-reentrant */
+
+/* %endif */
+
+/* Enter a start condition.  This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN (yy_start) = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state.  The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START (((yy_start) - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE skel_restart(skel_in  )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
+#define YY_BUF_SIZE 16384
+#endif
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+/* %if-not-reentrant */
+extern int skel_leng;
+/* %endif */
+
+/* %if-c-only */
+/* %if-not-reentrant */
+extern FILE *skel_in, *skel_out;
+/* %endif */
+/* %endif */
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+    #define YY_LESS_LINENO(n)
+    
+/* Return all but the first "n" matched characters back to the input stream. */
+#define yyless(n) \
+	do \
+		{ \
+		/* Undo effects of setting up skel_text. */ \
+        int yyless_macro_arg = (n); \
+        YY_LESS_LINENO(yyless_macro_arg);\
+		*yy_cp = (yy_hold_char); \
+		YY_RESTORE_YY_MORE_OFFSET \
+		(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
+		YY_DO_BEFORE_ACTION; /* set up skel_text again */ \
+		} \
+	while ( 0 )
+
+#define unput(c) yyunput( c, (yytext_ptr)  )
+
+/* The following is because we cannot portably get our hands on size_t
+ * (without autoconf's help, which isn't available because we want
+ * flex-generated scanners to compile on their own).
+ */
+
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef unsigned int yy_size_t;
+#endif
+
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
+struct yy_buffer_state
+	{
+/* %if-c-only */
+	FILE *yy_input_file;
+/* %endif */
+
+/* %if-c++-only */
+/* %endif */
+
+	char *yy_ch_buf;		/* input buffer */
+	char *yy_buf_pos;		/* current position in input buffer */
+
+	/* Size of input buffer in bytes, not including room for EOB
+	 * characters.
+	 */
+	yy_size_t yy_buf_size;
+
+	/* Number of characters read into yy_ch_buf, not including EOB
+	 * characters.
+	 */
+	int yy_n_chars;
+
+	/* Whether we "own" the buffer - i.e., we know we created it,
+	 * and can realloc() it to grow it, and should free() it to
+	 * delete it.
+	 */
+	int yy_is_our_buffer;
+
+	/* Whether this is an "interactive" input source; if so, and
+	 * if we're using stdio for input, then we want to use getc()
+	 * instead of fread(), to make sure we stop fetching input after
+	 * each newline.
+	 */
+	int yy_is_interactive;
+
+	/* Whether we're considered to be at the beginning of a line.
+	 * If so, '^' rules will be active on the next match, otherwise
+	 * not.
+	 */
+	int yy_at_bol;
+
+    int yy_bs_lineno; /**< The line count. */
+    int yy_bs_column; /**< The column count. */
+    
+	/* Whether to try to fill the input buffer when we reach the
+	 * end of it.
+	 */
+	int yy_fill_buffer;
+
+	int yy_buffer_status;
+
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+	/* When an EOF's been seen but there's still some text to process
+	 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+	 * shouldn't try reading from the input source any more.  We might
+	 * still have a bunch of tokens to match, though, because of
+	 * possible backing-up.
+	 *
+	 * When we actually see the EOF, we change the status to "new"
+	 * (via skel_restart()), so that the user can continue scanning by
+	 * just pointing skel_in at a new input file.
+	 */
+#define YY_BUFFER_EOF_PENDING 2
+
+	};
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+/* %if-c-only Standard (non-C++) definition */
+/* %not-for-header */
+
+/* %if-not-reentrant */
+
+/* Stack of input buffers. */
+static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
+static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
+static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
+/* %endif */
+/* %ok-for-header */
+
+/* %endif */
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ *
+ * Returns the top of the stack, or NULL.
+ */
+#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
+                          ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
+                          : NULL)
+
+/* Same as previous macro, but useful when we know that the buffer stack is not
+ * NULL or when we need an lvalue. For internal use only.
+ */
+#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
+
+/* %if-c-only Standard (non-C++) definition */
+
+/* %if-not-reentrant */
+/* %not-for-header */
+
+/* yy_hold_char holds the character lost when skel_text is formed. */
+static char yy_hold_char;
+static int yy_n_chars;		/* number of characters read into yy_ch_buf */
+int skel_leng;
+
+/* Points to current character in buffer. */
+static char *yy_c_buf_p = (char *) 0;
+static int yy_init = 1;		/* whether we need to initialize */
+static int yy_start = 0;	/* start state number */
+
+/* Flag which is used to allow skel_wrap()'s to do buffer switches
+ * instead of setting up a fresh skel_in.  A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+/* %ok-for-header */
+
+/* %endif */
+
+void skel_restart (FILE *input_file  );
+void skel__switch_to_buffer (YY_BUFFER_STATE new_buffer  );
+YY_BUFFER_STATE skel__create_buffer (FILE *file,int size  );
+void skel__delete_buffer (YY_BUFFER_STATE b  );
+void skel__flush_buffer (YY_BUFFER_STATE b  );
+void skel_push_buffer_state (YY_BUFFER_STATE new_buffer  );
+void skel_pop_buffer_state (void );
+
+static void skel_ensure_buffer_stack (void );
+static void skel__load_buffer_state (void );
+static void skel__init_buffer (YY_BUFFER_STATE b,FILE *file  );
+
+#define YY_FLUSH_BUFFER skel__flush_buffer(YY_CURRENT_BUFFER )
+
+YY_BUFFER_STATE skel__scan_buffer (char *base,yy_size_t size  );
+YY_BUFFER_STATE skel__scan_string (yyconst char *yy_str  );
+YY_BUFFER_STATE skel__scan_bytes (yyconst char *bytes,int len  );
+
+/* %endif */
+
+void *skel_alloc (yy_size_t  );
+void *skel_realloc (void *,yy_size_t  );
+void skel_free (void *  );
+
+#define yy_new_buffer skel__create_buffer
+
+#define yy_set_interactive(is_interactive) \
+	{ \
+	if ( ! YY_CURRENT_BUFFER ){ \
+        skel_ensure_buffer_stack (); \
+		YY_CURRENT_BUFFER_LVALUE =    \
+            skel__create_buffer(skel_in,YY_BUF_SIZE ); \
+	} \
+	YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
+	}
+
+#define yy_set_bol(at_bol) \
+	{ \
+	if ( ! YY_CURRENT_BUFFER ){\
+        skel_ensure_buffer_stack (); \
+		YY_CURRENT_BUFFER_LVALUE =    \
+            skel__create_buffer(skel_in,YY_BUF_SIZE ); \
+	} \
+	YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
+	}
+
+#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
+
+/* %% [1.0] skel_text/skel_in/skel_out/yy_state_type/skel_lineno etc. def's & init go here */
+/* Begin user sect3 */
+
+#define skel_wrap(n) 1
+#define YY_SKIP_YYWRAP
+
+#define FLEX_DEBUG
+
+typedef unsigned char YY_CHAR;
+
+FILE *skel_in = (FILE *) 0, *skel_out = (FILE *) 0;
+
+typedef int yy_state_type;
+
+extern int skel_lineno;
+
+int skel_lineno = 1;
+
+extern char *skel_text;
+#define yytext_ptr skel_text
+
+/* %if-c-only Standard (non-C++) definition */
+
+static yy_state_type yy_get_previous_state (void );
+static yy_state_type yy_try_NUL_trans (yy_state_type current_state  );
+static int yy_get_next_buffer (void );
+static void yy_fatal_error (yyconst char msg[]  );
+
+/* %endif */
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up skel_text.
+ */
+#define YY_DO_BEFORE_ACTION \
+	(yytext_ptr) = yy_bp; \
+/* %% [2.0] code to fiddle skel_text and skel_leng for yymore() goes here \ */\
+	skel_leng = (size_t) (yy_cp - yy_bp); \
+	(yy_hold_char) = *yy_cp; \
+	*yy_cp = '\0'; \
+/* %% [3.0] code to copy yytext_ptr to skel_text[] goes here, if %array \ */\
+	(yy_c_buf_p) = yy_cp;
+
+/* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */
+#define YY_NUM_RULES 13
+#define YY_END_OF_BUFFER 14
+/* This struct is not used in this scanner,
+   but its presence is necessary. */
+struct yy_trans_info
+	{
+	flex_int32_t yy_verify;
+	flex_int32_t yy_nxt;
+	};
+static yyconst flex_int16_t yy_accept[69] =
+    {   0,
+        0,    0,   14,   12,   11,   10,   12,   10,    2,   10,
+       10,    3,    4,   10,   10,   10,   10,   10,   10,   10,
+       10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
+        6,    5,   10,   10,   10,   10,   10,   10,    1,    0,
+       10,   10,   10,   10,   10,   10,   10,   10,    7,   10,
+       10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
+       10,   10,   10,   10,   10,    9,    8,    0
+    } ;
+
+static yyconst flex_int32_t yy_ec[256] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    2,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    3,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    4,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    5,    1,    6,    1,    1,    7,
+
+        8,    9,    1,   10,   11,    1,    1,   12,   13,   14,
+       15,   16,    1,   17,   18,   19,   20,    1,    1,   21,
+        1,    1,   22,    1,   23,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1
+    } ;
+
+static yyconst flex_int32_t yy_meta[24] =
+    {   0,
+        1,    2,    1,    3,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1
+    } ;
+
+static yyconst flex_int16_t yy_base[74] =
+    {   0,
+        0,    1,  107,    0,  138,    2,    0,    4,  138,   24,
+       39,  138,  138,    1,   63,   45,    0,    2,    3,    9,
+        5,   18,   22,   28,   11,   21,   33,   38,   34,   32,
+      138,  138,   49,   46,   59,   54,   30,   81,  138,    8,
+       58,   56,   47,   65,   61,   69,   68,   66,  138,   78,
+       79,   77,   80,   87,   88,   91,   95,   89,   90,   97,
+      100,  104,  106,  112,  114,  138,  138,  138,  125,    0,
+      128,  131,  134
+    } ;
+
+static yyconst flex_int16_t yy_def[74] =
+    {   0,
+       69,   69,   68,   70,   68,   71,   70,   71,   68,   71,
+       10,   68,   68,   10,   10,   10,   10,   10,   10,   10,
+       10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
+       68,   68,   10,   10,   72,   10,   10,   72,   68,   73,
+       10,   10,   10,   10,   10,   10,   10,   10,   68,   10,
+       10,   10,   10,   10,   10,   10,   10,   10,   10,   10,
+       10,   10,   10,   10,   10,   68,   68,    0,   68,   68,
+       68,   68,   68
+    } ;
+
+static yyconst flex_int16_t yy_nxt[162] =
+    {   0,
+        7,    5,    5,    6,    6,    9,   22,   68,   10,   39,
+        8,    8,    8,    8,   23,    8,   11,   18,   21,    8,
+       25,    8,   24,   12,   13,   68,   68,   68,    8,   27,
+       29,    8,    8,   26,   14,   28,   31,   30,    8,   34,
+       43,   32,    8,    8,    8,   68,   68,   15,    8,    8,
+       16,   35,   33,   36,   37,   20,    8,    8,   17,    8,
+       39,   45,   40,   41,    8,   44,    8,   46,    8,   42,
+       47,    8,   49,   19,   50,    8,    8,   48,    8,    8,
+       40,   40,   39,   51,   40,   52,   53,    8,    8,    8,
+        8,   56,   57,   54,   60,   61,   55,    8,    8,    8,
+
+        8,    8,   40,   40,   58,    8,   68,    8,   59,   62,
+        8,   64,   63,   65,    8,   66,    8,   67,   68,   68,
+       68,   68,    8,   68,    8,    4,    4,    4,    8,   68,
+        8,   38,   38,   38,   40,   40,   40,    3,   68,   68,
+       68,   68,   68,   68,   68,   68,   68,   68,   68,   68,
+       68,   68,   68,   68,   68,   68,   68,   68,   68,   68,
+       68
+    } ;
+
+static yyconst flex_int16_t yy_chk[162] =
+    {   0,
+       70,    1,    2,    1,    2,    6,   18,    8,    6,   40,
+       17,   14,   18,   19,   19,   21,    6,   14,   17,   20,
+       21,   25,   20,    6,    6,    8,    8,   10,   22,   23,
+       25,   26,   23,   22,   10,   24,   27,   26,   24,   30,
+       37,   28,   30,   27,   29,   10,   10,   11,   28,   11,
+       11,   33,   29,   33,   34,   16,   34,   43,   11,   33,
+       35,   42,   35,   36,   36,   41,   42,   43,   41,   36,
+       44,   45,   46,   15,   47,   44,   48,   45,   47,   46,
+       35,   35,   38,   48,   38,   50,   51,   52,   50,   51,
+       53,   54,   55,   52,   58,   59,   53,   54,   55,   58,
+
+       59,   56,   38,   38,   56,   57,    3,   60,   57,   60,
+       61,   62,   61,   63,   62,   64,   63,   65,    0,    0,
+        0,    0,   64,    0,   65,   69,   69,   69,   71,    0,
+       71,   72,   72,   72,   73,   73,   73,   68,   68,   68,
+       68,   68,   68,   68,   68,   68,   68,   68,   68,   68,
+       68,   68,   68,   68,   68,   68,   68,   68,   68,   68,
+       68
+    } ;
+
+static yy_state_type yy_last_accepting_state;
+static char *yy_last_accepting_cpos;
+
+extern int skel__flex_debug;
+int skel__flex_debug = 1;
+
+static yyconst flex_int16_t yy_rule_linenum[13] =
+    {   0,
+       70,   97,   98,   99,  101,  102,  103,  104,  105,  108,
+      109,  110
+    } ;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+char *skel_text;
+#line 1 "scan-skel.l"
+/* Scan Bison Skeletons.                                       -*- C -*-
+
+   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software
+   Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+#line 27 "scan-skel.l"
+/* Work around a bug in flex 2.5.31.  See Debian bug 333231
+   <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=333231>.  */
+#undef skel_wrap
+#define skel_wrap() 1
+
+#include "system.h"
+
+#include <error.h>
+#include <quotearg.h>
+
+#include "complain.h"
+#include "getargs.h"
+#include "files.h"
+#include "scan-skel.h"
+
+/* Pacify "gcc -Wmissing-prototypes" when flex 2.5.31 is used.  */
+int skel_lex (void);
+int skel_get_lineno (void);
+FILE *skel_get_in (void);
+FILE *skel_get_out (void);
+int skel_get_leng (void);
+char *skel_get_text (void);
+void skel_set_lineno (int);
+void skel_set_in (FILE *);
+void skel_set_out (FILE *);
+int skel_get_debug (void);
+void skel_set_debug (int);
+int skel_lex_destroy (void);
+
+#define QPUTS(String) \
+   fputs (quotearg_style (c_quoting_style, String), skel_out)
+
+#define BASE_QPUTS(File) \
+   QPUTS (base_name (File))
+
+#line 638 "scan-skel.c"
+
+#define INITIAL 0
+
+#ifndef YY_NO_UNISTD_H
+/* Special case for "unistd.h", since it is non-ANSI. We include it way
+ * down here because we want the user's section 1 to have been scanned first.
+ * The user has a chance to override it with an option.
+ */
+/* %if-c-only */
+#include <unistd.h>
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+#endif
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+/* %if-c-only Reentrant structure and macros (non-C++). */
+/* %if-reentrant */
+/* %if-reentrant */
+/* %endif */
+/* %if-bison-bridge */
+/* %endif */
+/* %endif End reentrant structures and macros. */
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int skel_wrap (void );
+#else
+extern int skel_wrap (void );
+#endif
+#endif
+
+/* %not-for-header */
+
+/* %ok-for-header */
+
+/* %endif */
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char *,yyconst char *,int );
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * );
+#endif
+
+#ifndef YY_NO_INPUT
+/* %if-c-only Standard (non-C++) definition */
+/* %not-for-header */
+
+#ifdef __cplusplus
+static int yyinput (void );
+#else
+static int input (void );
+#endif
+/* %ok-for-header */
+
+/* %endif */
+#endif
+
+/* %if-c-only */
+
+/* %endif */
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#define YY_READ_BUF_SIZE 8192
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+#ifndef ECHO
+/* %if-c-only Standard (non-C++) definition */
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO (void) fwrite( skel_text, skel_leng, 1, skel_out )
+/* %endif */
+/* %if-c++-only C++ definition */
+/* %endif */
+#endif
+
+/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+/* %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ */\
+	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
+		{ \
+		int c = '*'; \
+		size_t n; \
+		for ( n = 0; n < max_size && \
+			     (c = getc( skel_in )) != EOF && c != '\n'; ++n ) \
+			buf[n] = (char) c; \
+		if ( c == '\n' ) \
+			buf[n++] = (char) c; \
+		if ( c == EOF && ferror( skel_in ) ) \
+			YY_FATAL_ERROR( "input in flex scanner failed" ); \
+		result = n; \
+		} \
+	else \
+		{ \
+		errno=0; \
+		while ( (result = fread(buf, 1, max_size, skel_in))==0 && ferror(skel_in)) \
+			{ \
+			if( errno != EINTR) \
+				{ \
+				YY_FATAL_ERROR( "input in flex scanner failed" ); \
+				break; \
+				} \
+			errno=0; \
+			clearerr(skel_in); \
+			} \
+		}\
+\
+/* %if-c++-only C++ definition \ */\
+/* %endif */
+
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+/* %if-c-only */
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+#endif
+
+/* %if-tables-serialization structures and prototypes */
+/* %not-for-header */
+
+/* %ok-for-header */
+
+/* %not-for-header */
+
+/* %tables-yydmap generated elements */
+/* %endif */
+/* end tables serialization structures and prototypes */
+
+/* %ok-for-header */
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+/* %if-c-only Standard (non-C++) definition */
+
+extern int skel_lex (void);
+
+#define YY_DECL int skel_lex (void)
+/* %endif */
+/* %if-c++-only C++ definition */
+/* %endif */
+#endif /* !YY_DECL */
+
+/* Code executed at the beginning of each rule, after skel_text and skel_leng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+/* %% [6.0] YY_RULE_SETUP definition goes here */
+#define YY_RULE_SETUP \
+	YY_USER_ACTION
+
+/* %not-for-header */
+
+/** The main scanner function which does all the work.
+ */
+YY_DECL
+{
+	register yy_state_type yy_current_state;
+	register char *yy_cp, *yy_bp;
+	register int yy_act;
+    
+/* %% [7.0] user's declarations go here */
+#line 63 "scan-skel.l"
+
+
+
+  int lineno IF_LINT (= 0);
+  char *outname = NULL;
+
+
+#line 851 "scan-skel.c"
+
+	if ( (yy_init) )
+		{
+		(yy_init) = 0;
+
+#ifdef YY_USER_INIT
+		YY_USER_INIT;
+#endif
+
+		if ( ! (yy_start) )
+			(yy_start) = 1;	/* first start state */
+
+		if ( ! skel_in )
+/* %if-c-only */
+			skel_in = stdin;
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+
+		if ( ! skel_out )
+/* %if-c-only */
+			skel_out = stdout;
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+
+		if ( ! YY_CURRENT_BUFFER ) {
+			skel_ensure_buffer_stack ();
+			YY_CURRENT_BUFFER_LVALUE =
+				skel__create_buffer(skel_in,YY_BUF_SIZE );
+		}
+
+		skel__load_buffer_state( );
+		}
+
+	while ( 1 )		/* loops until end-of-file is reached */
+		{
+/* %% [8.0] yymore()-related code goes here */
+		yy_cp = (yy_c_buf_p);
+
+		/* Support of skel_text. */
+		*yy_cp = (yy_hold_char);
+
+		/* yy_bp points to the position in yy_ch_buf of the start of
+		 * the current run.
+		 */
+		yy_bp = yy_cp;
+
+/* %% [9.0] code to set up and find next match goes here */
+		yy_current_state = (yy_start);
+yy_match:
+		do
+			{
+			register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+			if ( yy_accept[yy_current_state] )
+				{
+				(yy_last_accepting_state) = yy_current_state;
+				(yy_last_accepting_cpos) = yy_cp;
+				}
+			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+				{
+				yy_current_state = (int) yy_def[yy_current_state];
+				if ( yy_current_state >= 69 )
+					yy_c = yy_meta[(unsigned int) yy_c];
+				}
+			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+			++yy_cp;
+			}
+		while ( yy_current_state != 68 );
+		yy_cp = (yy_last_accepting_cpos);
+		yy_current_state = (yy_last_accepting_state);
+
+yy_find_action:
+/* %% [10.0] code to find the action number goes here */
+		yy_act = yy_accept[yy_current_state];
+
+		YY_DO_BEFORE_ACTION;
+
+/* %% [11.0] code for skel_lineno update goes here */
+
+do_action:	/* This label is used only to access EOF actions. */
+
+/* %% [12.0] debug code goes here */
+		if ( skel__flex_debug )
+			{
+			if ( yy_act == 0 )
+				fprintf( stderr, "--scanner backing up\n" );
+			else if ( yy_act < 13 )
+				fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n",
+				         (long)yy_rule_linenum[yy_act], skel_text );
+			else if ( yy_act == 13 )
+				fprintf( stderr, "--accepting default rule (\"%s\")\n",
+				         skel_text );
+			else if ( yy_act == 14 )
+				fprintf( stderr, "--(end of buffer or a NUL)\n" );
+			else
+				fprintf( stderr, "--EOF (start condition %d)\n", YY_START );
+			}
+
+		switch ( yy_act )
+	{ /* beginning of action switch */
+/* %% [13.0] actions go here */
+			case 0: /* must back up */
+			/* undo the effects of YY_DO_BEFORE_ACTION */
+			*yy_cp = (yy_hold_char);
+			yy_cp = (yy_last_accepting_cpos);
+			yy_current_state = (yy_last_accepting_state);
+			goto yy_find_action;
+
+case 1:
+/* rule 1 can match eol */
+YY_RULE_SETUP
+#line 70 "scan-skel.l"
+{
+  char const *file_name = skel_text + sizeof "@output " - 1;
+  skel_text[skel_leng - 1] = '\0';
+
+  /* Decode special file names.  They include the directory part,
+     contrary to their "free" occurrences, used for issuing #includes,
+     which must not include the directory part.  */
+
+  if (*file_name == '@')
+    {
+      if (strcmp (file_name, "@output_header_name@") == 0)
+	file_name = spec_defines_file;
+      else if (strcmp (file_name, "@output_parser_name@") == 0)
+	file_name = parser_file_name;
+      else
+	fatal ("invalid token in skeleton: %s", skel_text);
+    }
+  if (outname)
+    {
+      free (outname);
+      xfclose (skel_out);
+    }
+  outname = xstrdup (file_name);
+  skel_out = xfopen (outname, "w");
+  lineno = 1;
+}
+	YY_BREAK
+case 2:
+YY_RULE_SETUP
+#line 97 "scan-skel.l"
+fputc ('@', skel_out);
+	YY_BREAK
+case 3:
+YY_RULE_SETUP
+#line 98 "scan-skel.l"
+fputc ('[', skel_out);
+	YY_BREAK
+case 4:
+YY_RULE_SETUP
+#line 99 "scan-skel.l"
+fputc (']', skel_out);
+	YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 101 "scan-skel.l"
+fprintf (skel_out, "%d", lineno + 1);
+	YY_BREAK
+case 6:
+YY_RULE_SETUP
+#line 102 "scan-skel.l"
+QPUTS (outname);
+	YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 103 "scan-skel.l"
+QPUTS (dir_prefix);
+	YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 104 "scan-skel.l"
+BASE_QPUTS (parser_file_name);
+	YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 105 "scan-skel.l"
+BASE_QPUTS (spec_defines_file);
+	YY_BREAK
+/* This pattern must not match more than the previous @ patterns. */
+case 10:
+YY_RULE_SETUP
+#line 108 "scan-skel.l"
+fatal ("invalid @ in skeleton: %s", skel_text);
+	YY_BREAK
+case 11:
+/* rule 11 can match eol */
+YY_RULE_SETUP
+#line 109 "scan-skel.l"
+lineno++; ECHO;
+	YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 110 "scan-skel.l"
+ECHO;
+	YY_BREAK
+case YY_STATE_EOF(INITIAL):
+#line 112 "scan-skel.l"
+{
+  if (outname)
+    {
+      free (outname);
+      xfclose (skel_out);
+    }
+  return EOF;
+}
+	YY_BREAK
+case 13:
+YY_RULE_SETUP
+#line 120 "scan-skel.l"
+YY_FATAL_ERROR( "flex scanner jammed" );
+	YY_BREAK
+#line 1065 "scan-skel.c"
+
+	case YY_END_OF_BUFFER:
+		{
+		/* Amount of text matched not including the EOB char. */
+		int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
+
+		/* Undo the effects of YY_DO_BEFORE_ACTION. */
+		*yy_cp = (yy_hold_char);
+		YY_RESTORE_YY_MORE_OFFSET
+
+		if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
+			{
+			/* We're scanning a new file or input source.  It's
+			 * possible that this happened because the user
+			 * just pointed skel_in at a new source and called
+			 * skel_lex().  If so, then we have to assure
+			 * consistency between YY_CURRENT_BUFFER and our
+			 * globals.  Here is the right place to do so, because
+			 * this is the first action (other than possibly a
+			 * back-up) that will match for the new input source.
+			 */
+			(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+			YY_CURRENT_BUFFER_LVALUE->yy_input_file = skel_in;
+			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
+			}
+
+		/* Note that here we test for yy_c_buf_p "<=" to the position
+		 * of the first EOB in the buffer, since yy_c_buf_p will
+		 * already have been incremented past the NUL character
+		 * (since all states make transitions on EOB to the
+		 * end-of-buffer state).  Contrast this with the test
+		 * in input().
+		 */
+		if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+			{ /* This was really a NUL. */
+			yy_state_type yy_next_state;
+
+			(yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
+
+			yy_current_state = yy_get_previous_state(  );
+
+			/* Okay, we're now positioned to make the NUL
+			 * transition.  We couldn't have
+			 * yy_get_previous_state() go ahead and do it
+			 * for us because it doesn't know how to deal
+			 * with the possibility of jamming (and we don't
+			 * want to build jamming into it because then it
+			 * will run more slowly).
+			 */
+
+			yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+			yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+
+			if ( yy_next_state )
+				{
+				/* Consume the NUL. */
+				yy_cp = ++(yy_c_buf_p);
+				yy_current_state = yy_next_state;
+				goto yy_match;
+				}
+
+			else
+				{
+/* %% [14.0] code to do back-up for compressed tables and set up yy_cp goes here */
+				yy_cp = (yy_last_accepting_cpos);
+				yy_current_state = (yy_last_accepting_state);
+				goto yy_find_action;
+				}
+			}
+
+		else switch ( yy_get_next_buffer(  ) )
+			{
+			case EOB_ACT_END_OF_FILE:
+				{
+				(yy_did_buffer_switch_on_eof) = 0;
+
+				if ( skel_wrap( ) )
+					{
+					/* Note: because we've taken care in
+					 * yy_get_next_buffer() to have set up
+					 * skel_text, we can now set up
+					 * yy_c_buf_p so that if some total
+					 * hoser (like flex itself) wants to
+					 * call the scanner after we return the
+					 * YY_NULL, it'll still work - another
+					 * YY_NULL will get returned.
+					 */
+					(yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
+
+					yy_act = YY_STATE_EOF(YY_START);
+					goto do_action;
+					}
+
+				else
+					{
+					if ( ! (yy_did_buffer_switch_on_eof) )
+						YY_NEW_FILE;
+					}
+				break;
+				}
+
+			case EOB_ACT_CONTINUE_SCAN:
+				(yy_c_buf_p) =
+					(yytext_ptr) + yy_amount_of_matched_text;
+
+				yy_current_state = yy_get_previous_state(  );
+
+				yy_cp = (yy_c_buf_p);
+				yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+				goto yy_match;
+
+			case EOB_ACT_LAST_MATCH:
+				(yy_c_buf_p) =
+				&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
+
+				yy_current_state = yy_get_previous_state(  );
+
+				yy_cp = (yy_c_buf_p);
+				yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+				goto yy_find_action;
+			}
+		break;
+		}
+
+	default:
+		YY_FATAL_ERROR(
+			"fatal flex scanner internal error--no action found" );
+	} /* end of action switch */
+		} /* end of scanning one token */
+} /* end of skel_lex */
+/* %ok-for-header */
+
+/* %if-c++-only */
+/* %not-for-header */
+
+/* %ok-for-header */
+
+/* %endif */
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ *	EOB_ACT_LAST_MATCH -
+ *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ *	EOB_ACT_END_OF_FILE - end of file
+ */
+/* %if-c-only */
+static int yy_get_next_buffer (void)
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+    	register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+	register char *source = (yytext_ptr);
+	register int number_to_move, i;
+	int ret_val;
+
+	if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
+		YY_FATAL_ERROR(
+		"fatal flex scanner internal error--end of buffer missed" );
+
+	if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
+		{ /* Don't try to fill the buffer, so this is an EOF. */
+		if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
+			{
+			/* We matched a single character, the EOB, so
+			 * treat this as a final EOF.
+			 */
+			return EOB_ACT_END_OF_FILE;
+			}
+
+		else
+			{
+			/* We matched some text prior to the EOB, first
+			 * process it.
+			 */
+			return EOB_ACT_LAST_MATCH;
+			}
+		}
+
+	/* Try to read more data. */
+
+	/* First move last chars to start of buffer. */
+	number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
+
+	for ( i = 0; i < number_to_move; ++i )
+		*(dest++) = *(source++);
+
+	if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+		/* don't do the read, it's not guaranteed to return an EOF,
+		 * just force an EOF
+		 */
+		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
+
+	else
+		{
+			size_t num_to_read =
+			YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
+
+		while ( num_to_read <= 0 )
+			{ /* Not enough room in the buffer - grow it. */
+
+			/* just a shorter name for the current buffer */
+			YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
+
+			int yy_c_buf_p_offset =
+				(int) ((yy_c_buf_p) - b->yy_ch_buf);
+
+			if ( b->yy_is_our_buffer )
+				{
+				int new_size = b->yy_buf_size * 2;
+
+				if ( new_size <= 0 )
+					b->yy_buf_size += b->yy_buf_size / 8;
+				else
+					b->yy_buf_size *= 2;
+
+				b->yy_ch_buf = (char *)
+					/* Include room in for 2 EOB chars. */
+					skel_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2  );
+				}
+			else
+				/* Can't grow it, we don't own it. */
+				b->yy_ch_buf = 0;
+
+			if ( ! b->yy_ch_buf )
+				YY_FATAL_ERROR(
+				"fatal error - scanner input buffer overflow" );
+
+			(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+			num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
+						number_to_move - 1;
+
+			}
+
+		if ( num_to_read > YY_READ_BUF_SIZE )
+			num_to_read = YY_READ_BUF_SIZE;
+
+		/* Read in more data. */
+		YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+			(yy_n_chars), num_to_read );
+
+		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+		}
+
+	if ( (yy_n_chars) == 0 )
+		{
+		if ( number_to_move == YY_MORE_ADJ )
+			{
+			ret_val = EOB_ACT_END_OF_FILE;
+			skel_restart(skel_in  );
+			}
+
+		else
+			{
+			ret_val = EOB_ACT_LAST_MATCH;
+			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
+				YY_BUFFER_EOF_PENDING;
+			}
+		}
+
+	else
+		ret_val = EOB_ACT_CONTINUE_SCAN;
+
+	(yy_n_chars) += number_to_move;
+	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
+	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
+
+	(yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
+
+	return ret_val;
+}
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+/* %if-c-only */
+/* %not-for-header */
+
+    static yy_state_type yy_get_previous_state (void)
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+	register yy_state_type yy_current_state;
+	register char *yy_cp;
+    
+/* %% [15.0] code to get the start state into yy_current_state goes here */
+	yy_current_state = (yy_start);
+
+	for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
+		{
+/* %% [16.0] code to find the next state goes here */
+		register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+		if ( yy_accept[yy_current_state] )
+			{
+			(yy_last_accepting_state) = yy_current_state;
+			(yy_last_accepting_cpos) = yy_cp;
+			}
+		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+			{
+			yy_current_state = (int) yy_def[yy_current_state];
+			if ( yy_current_state >= 69 )
+				yy_c = yy_meta[(unsigned int) yy_c];
+			}
+		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+		}
+
+	return yy_current_state;
+}
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ *	next_state = yy_try_NUL_trans( current_state );
+ */
+/* %if-c-only */
+    static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+	register int yy_is_jam;
+    /* %% [17.0] code to find the next state, and perhaps do backing up, goes here */
+	register char *yy_cp = (yy_c_buf_p);
+
+	register YY_CHAR yy_c = 1;
+	if ( yy_accept[yy_current_state] )
+		{
+		(yy_last_accepting_state) = yy_current_state;
+		(yy_last_accepting_cpos) = yy_cp;
+		}
+	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+		{
+		yy_current_state = (int) yy_def[yy_current_state];
+		if ( yy_current_state >= 69 )
+			yy_c = yy_meta[(unsigned int) yy_c];
+		}
+	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+	yy_is_jam = (yy_current_state == 68);
+
+	return yy_is_jam ? 0 : yy_current_state;
+}
+
+/* %if-c-only */
+
+/* %endif */
+
+/* %if-c-only */
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+    static int yyinput (void)
+#else
+    static int input  (void)
+#endif
+
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+	int c;
+    
+	*(yy_c_buf_p) = (yy_hold_char);
+
+	if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
+		{
+		/* yy_c_buf_p now points to the character we want to return.
+		 * If this occurs *before* the EOB characters, then it's a
+		 * valid NUL; if not, then we've hit the end of the buffer.
+		 */
+		if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+			/* This was really a NUL. */
+			*(yy_c_buf_p) = '\0';
+
+		else
+			{ /* need more input */
+			int offset = (yy_c_buf_p) - (yytext_ptr);
+			++(yy_c_buf_p);
+
+			switch ( yy_get_next_buffer(  ) )
+				{
+				case EOB_ACT_LAST_MATCH:
+					/* This happens because yy_g_n_b()
+					 * sees that we've accumulated a
+					 * token and flags that we need to
+					 * try matching the token before
+					 * proceeding.  But for input(),
+					 * there's no matching to consider.
+					 * So convert the EOB_ACT_LAST_MATCH
+					 * to EOB_ACT_END_OF_FILE.
+					 */
+
+					/* Reset buffer status. */
+					skel_restart(skel_in );
+
+					/*FALLTHROUGH*/
+
+				case EOB_ACT_END_OF_FILE:
+					{
+					if ( skel_wrap( ) )
+						return EOF;
+
+					if ( ! (yy_did_buffer_switch_on_eof) )
+						YY_NEW_FILE;
+#ifdef __cplusplus
+					return yyinput();
+#else
+					return input();
+#endif
+					}
+
+				case EOB_ACT_CONTINUE_SCAN:
+					(yy_c_buf_p) = (yytext_ptr) + offset;
+					break;
+				}
+			}
+		}
+
+	c = *(unsigned char *) (yy_c_buf_p);	/* cast for 8-bit char's */
+	*(yy_c_buf_p) = '\0';	/* preserve skel_text */
+	(yy_hold_char) = *++(yy_c_buf_p);
+
+/* %% [19.0] update BOL and skel_lineno */
+
+	return c;
+}
+/* %if-c-only */
+#endif	/* ifndef YY_NO_INPUT */
+/* %endif */
+
+/** Immediately switch to a different input stream.
+ * @param input_file A readable stream.
+ * 
+ * @note This function does not reset the start condition to @c INITIAL .
+ */
+/* %if-c-only */
+    void skel_restart  (FILE * input_file )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+    
+	if ( ! YY_CURRENT_BUFFER ){
+        skel_ensure_buffer_stack ();
+		YY_CURRENT_BUFFER_LVALUE =
+            skel__create_buffer(skel_in,YY_BUF_SIZE );
+	}
+
+	skel__init_buffer(YY_CURRENT_BUFFER,input_file );
+	skel__load_buffer_state( );
+}
+
+/** Switch to a different input buffer.
+ * @param new_buffer The new input buffer.
+ * 
+ */
+/* %if-c-only */
+    void skel__switch_to_buffer  (YY_BUFFER_STATE  new_buffer )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+    
+	/* TODO. We should be able to replace this entire function body
+	 * with
+	 *		skel_pop_buffer_state();
+	 *		skel_push_buffer_state(new_buffer);
+     */
+	skel_ensure_buffer_stack ();
+	if ( YY_CURRENT_BUFFER == new_buffer )
+		return;
+
+	if ( YY_CURRENT_BUFFER )
+		{
+		/* Flush out information for old buffer. */
+		*(yy_c_buf_p) = (yy_hold_char);
+		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+		}
+
+	YY_CURRENT_BUFFER_LVALUE = new_buffer;
+	skel__load_buffer_state( );
+
+	/* We don't actually know whether we did this switch during
+	 * EOF (skel_wrap()) processing, but the only time this flag
+	 * is looked at is after skel_wrap() is called, so it's safe
+	 * to go ahead and always set it.
+	 */
+	(yy_did_buffer_switch_on_eof) = 1;
+}
+
+/* %if-c-only */
+static void skel__load_buffer_state  (void)
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+    	(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+	(yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
+	skel_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+	(yy_hold_char) = *(yy_c_buf_p);
+}
+
+/** Allocate and initialize an input buffer state.
+ * @param file A readable stream.
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
+ * 
+ * @return the allocated buffer state.
+ */
+/* %if-c-only */
+    YY_BUFFER_STATE skel__create_buffer  (FILE * file, int  size )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+	YY_BUFFER_STATE b;
+    
+	b = (YY_BUFFER_STATE) skel_alloc(sizeof( struct yy_buffer_state )  );
+	if ( ! b )
+		YY_FATAL_ERROR( "out of dynamic memory in skel__create_buffer()" );
+
+	b->yy_buf_size = size;
+
+	/* yy_ch_buf has to be 2 characters longer than the size given because
+	 * we need to put in 2 end-of-buffer characters.
+	 */
+	b->yy_ch_buf = (char *) skel_alloc(b->yy_buf_size + 2  );
+	if ( ! b->yy_ch_buf )
+		YY_FATAL_ERROR( "out of dynamic memory in skel__create_buffer()" );
+
+	b->yy_is_our_buffer = 1;
+
+	skel__init_buffer(b,file );
+
+	return b;
+}
+
+/** Destroy the buffer.
+ * @param b a buffer created with skel__create_buffer()
+ * 
+ */
+/* %if-c-only */
+    void skel__delete_buffer (YY_BUFFER_STATE  b )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+    
+	if ( ! b )
+		return;
+
+	if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
+		YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
+
+	if ( b->yy_is_our_buffer )
+		skel_free((void *) b->yy_ch_buf  );
+
+	skel_free((void *) b  );
+}
+
+/* %if-c-only */
+
+/* %endif */
+
+/* %if-c++-only */
+/* %endif */
+
+/* Initializes or reinitializes a buffer.
+ * This function is sometimes called more than once on the same buffer,
+ * such as during a skel_restart() or at EOF.
+ */
+/* %if-c-only */
+    static void skel__init_buffer  (YY_BUFFER_STATE  b, FILE * file )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+
+{
+	int oerrno = errno;
+    
+	skel__flush_buffer(b );
+
+	b->yy_input_file = file;
+	b->yy_fill_buffer = 1;
+
+    /* If b is the current buffer, then skel__init_buffer was _probably_
+     * called from skel_restart() or through yy_get_next_buffer.
+     * In that case, we don't want to reset the lineno or column.
+     */
+    if (b != YY_CURRENT_BUFFER){
+        b->yy_bs_lineno = 1;
+        b->yy_bs_column = 0;
+    }
+
+/* %if-c-only */
+
+        b->yy_is_interactive = 0;
+    
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+	errno = oerrno;
+}
+
+/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
+ * 
+ */
+/* %if-c-only */
+    void skel__flush_buffer (YY_BUFFER_STATE  b )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+    	if ( ! b )
+		return;
+
+	b->yy_n_chars = 0;
+
+	/* We always need two end-of-buffer characters.  The first causes
+	 * a transition to the end-of-buffer state.  The second causes
+	 * a jam in that state.
+	 */
+	b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+	b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+	b->yy_buf_pos = &b->yy_ch_buf[0];
+
+	b->yy_at_bol = 1;
+	b->yy_buffer_status = YY_BUFFER_NEW;
+
+	if ( b == YY_CURRENT_BUFFER )
+		skel__load_buffer_state( );
+}
+
+/* %if-c-or-c++ */
+/** Pushes the new state onto the stack. The new state becomes
+ *  the current state. This function will allocate the stack
+ *  if necessary.
+ *  @param new_buffer The new state.
+ *  
+ */
+/* %if-c-only */
+void skel_push_buffer_state (YY_BUFFER_STATE new_buffer )
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+    	if (new_buffer == NULL)
+		return;
+
+	skel_ensure_buffer_stack();
+
+	/* This block is copied from skel__switch_to_buffer. */
+	if ( YY_CURRENT_BUFFER )
+		{
+		/* Flush out information for old buffer. */
+		*(yy_c_buf_p) = (yy_hold_char);
+		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+		}
+
+	/* Only push if top exists. Otherwise, replace top. */
+	if (YY_CURRENT_BUFFER)
+		(yy_buffer_stack_top)++;
+	YY_CURRENT_BUFFER_LVALUE = new_buffer;
+
+	/* copied from skel__switch_to_buffer. */
+	skel__load_buffer_state( );
+	(yy_did_buffer_switch_on_eof) = 1;
+}
+/* %endif */
+
+/* %if-c-or-c++ */
+/** Removes and deletes the top of the stack, if present.
+ *  The next element becomes the new top.
+ *  
+ */
+/* %if-c-only */
+void skel_pop_buffer_state (void)
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+    	if (!YY_CURRENT_BUFFER)
+		return;
+
+	skel__delete_buffer(YY_CURRENT_BUFFER );
+	YY_CURRENT_BUFFER_LVALUE = NULL;
+	if ((yy_buffer_stack_top) > 0)
+		--(yy_buffer_stack_top);
+
+	if (YY_CURRENT_BUFFER) {
+		skel__load_buffer_state( );
+		(yy_did_buffer_switch_on_eof) = 1;
+	}
+}
+/* %endif */
+
+/* %if-c-or-c++ */
+/* Allocates the stack if it does not exist.
+ *  Guarantees space for at least one push.
+ */
+/* %if-c-only */
+static void skel_ensure_buffer_stack (void)
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+{
+	int num_to_alloc;
+    
+	if (!(yy_buffer_stack)) {
+
+		/* First allocation is just for 2 elements, since we don't know if this
+		 * scanner will even need a stack. We use 2 instead of 1 to avoid an
+		 * immediate realloc on the next call.
+         */
+		num_to_alloc = 1;
+		(yy_buffer_stack) = (struct yy_buffer_state**)skel_alloc
+								(num_to_alloc * sizeof(struct yy_buffer_state*)
+								);
+		
+		memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
+				
+		(yy_buffer_stack_max) = num_to_alloc;
+		(yy_buffer_stack_top) = 0;
+		return;
+	}
+
+	if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
+
+		/* Increase the buffer to prepare for a possible push. */
+		int grow_size = 8 /* arbitrary grow size */;
+
+		num_to_alloc = (yy_buffer_stack_max) + grow_size;
+		(yy_buffer_stack) = (struct yy_buffer_state**)skel_realloc
+								((yy_buffer_stack),
+								num_to_alloc * sizeof(struct yy_buffer_state*)
+								);
+
+		/* zero only the new slots.*/
+		memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
+		(yy_buffer_stack_max) = num_to_alloc;
+	}
+}
+/* %endif */
+
+/* %if-c-only */
+/** Setup the input buffer state to scan directly from a user-specified character buffer.
+ * @param base the character buffer
+ * @param size the size in bytes of the character buffer
+ * 
+ * @return the newly allocated buffer state object. 
+ */
+YY_BUFFER_STATE skel__scan_buffer  (char * base, yy_size_t  size )
+{
+	YY_BUFFER_STATE b;
+    
+	if ( size < 2 ||
+	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
+	     base[size-1] != YY_END_OF_BUFFER_CHAR )
+		/* They forgot to leave room for the EOB's. */
+		return 0;
+
+	b = (YY_BUFFER_STATE) skel_alloc(sizeof( struct yy_buffer_state )  );
+	if ( ! b )
+		YY_FATAL_ERROR( "out of dynamic memory in skel__scan_buffer()" );
+
+	b->yy_buf_size = size - 2;	/* "- 2" to take care of EOB's */
+	b->yy_buf_pos = b->yy_ch_buf = base;
+	b->yy_is_our_buffer = 0;
+	b->yy_input_file = 0;
+	b->yy_n_chars = b->yy_buf_size;
+	b->yy_is_interactive = 0;
+	b->yy_at_bol = 1;
+	b->yy_fill_buffer = 0;
+	b->yy_buffer_status = YY_BUFFER_NEW;
+
+	skel__switch_to_buffer(b  );
+
+	return b;
+}
+/* %endif */
+
+/* %if-c-only */
+/** Setup the input buffer state to scan a string. The next call to skel_lex() will
+ * scan from a @e copy of @a str.
+ * @param str a NUL-terminated string to scan
+ * 
+ * @return the newly allocated buffer state object.
+ * @note If you want to scan bytes that may contain NUL values, then use
+ *       skel__scan_bytes() instead.
+ */
+YY_BUFFER_STATE skel__scan_string (yyconst char * yy_str )
+{
+    
+	return skel__scan_bytes(yy_str,strlen(yy_str) );
+}
+/* %endif */
+
+/* %if-c-only */
+/** Setup the input buffer state to scan the given bytes. The next call to skel_lex() will
+ * scan from a @e copy of @a bytes.
+ * @param bytes the byte buffer to scan
+ * @param len the number of bytes in the buffer pointed to by @a bytes.
+ * 
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE skel__scan_bytes  (yyconst char * bytes, int  len )
+{
+	YY_BUFFER_STATE b;
+	char *buf;
+	yy_size_t n;
+	int i;
+    
+	/* Get memory for full buffer, including space for trailing EOB's. */
+	n = len + 2;
+	buf = (char *) skel_alloc(n  );
+	if ( ! buf )
+		YY_FATAL_ERROR( "out of dynamic memory in skel__scan_bytes()" );
+
+	for ( i = 0; i < len; ++i )
+		buf[i] = bytes[i];
+
+	buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
+
+	b = skel__scan_buffer(buf,n );
+	if ( ! b )
+		YY_FATAL_ERROR( "bad buffer in skel__scan_bytes()" );
+
+	/* It's okay to grow etc. this buffer, and we should throw it
+	 * away when we're done.
+	 */
+	b->yy_is_our_buffer = 1;
+
+	return b;
+}
+/* %endif */
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+/* %if-c-only */
+static void yy_fatal_error (yyconst char* msg )
+{
+    	(void) fprintf( stderr, "%s\n", msg );
+	exit( YY_EXIT_FAILURE );
+}
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+	do \
+		{ \
+		/* Undo effects of setting up skel_text. */ \
+        int yyless_macro_arg = (n); \
+        YY_LESS_LINENO(yyless_macro_arg);\
+		skel_text[skel_leng] = (yy_hold_char); \
+		(yy_c_buf_p) = skel_text + yyless_macro_arg; \
+		(yy_hold_char) = *(yy_c_buf_p); \
+		*(yy_c_buf_p) = '\0'; \
+		skel_leng = yyless_macro_arg; \
+		} \
+	while ( 0 )
+
+/* Accessor  methods (get/set functions) to struct members. */
+
+/* %if-c-only */
+/* %if-reentrant */
+/* %endif */
+
+/** Get the current line number.
+ * 
+ */
+int skel_get_lineno  (void)
+{
+        
+    return skel_lineno;
+}
+
+/** Get the input stream.
+ * 
+ */
+FILE *skel_get_in  (void)
+{
+        return skel_in;
+}
+
+/** Get the output stream.
+ * 
+ */
+FILE *skel_get_out  (void)
+{
+        return skel_out;
+}
+
+/** Get the length of the current token.
+ * 
+ */
+int skel_get_leng  (void)
+{
+        return skel_leng;
+}
+
+/** Get the current token.
+ * 
+ */
+
+char *skel_get_text  (void)
+{
+        return skel_text;
+}
+
+/* %if-reentrant */
+/* %endif */
+
+/** Set the current line number.
+ * @param line_number
+ * 
+ */
+void skel_set_lineno (int  line_number )
+{
+    
+    skel_lineno = line_number;
+}
+
+/** Set the input stream. This does not discard the current
+ * input buffer.
+ * @param in_str A readable stream.
+ * 
+ * @see skel__switch_to_buffer
+ */
+void skel_set_in (FILE *  in_str )
+{
+        skel_in = in_str ;
+}
+
+void skel_set_out (FILE *  out_str )
+{
+        skel_out = out_str ;
+}
+
+int skel_get_debug  (void)
+{
+        return skel__flex_debug;
+}
+
+void skel_set_debug (int  bdebug )
+{
+        skel__flex_debug = bdebug ;
+}
+
+/* %endif */
+
+/* %if-reentrant */
+/* %if-bison-bridge */
+/* %endif */
+/* %endif */
+
+/* %if-c-only SNIP! this currently causes conflicts with the c++ scanner */
+/* skel_lex_destroy is for both reentrant and non-reentrant scanners. */
+int skel_lex_destroy  (void)
+{
+    
+    /* Pop the buffer stack, destroying each element. */
+	while(YY_CURRENT_BUFFER){
+		skel__delete_buffer(YY_CURRENT_BUFFER  );
+		YY_CURRENT_BUFFER_LVALUE = NULL;
+		skel_pop_buffer_state();
+	}
+
+	/* Destroy the stack itself. */
+	skel_free((yy_buffer_stack) );
+	(yy_buffer_stack) = NULL;
+
+/* %if-reentrant */
+/* %endif */
+    return 0;
+}
+/* %endif */
+
+/*
+ * Internal utility routines.
+ */
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
+{
+	register int i;
+    	for ( i = 0; i < n; ++i )
+		s1[i] = s2[i];
+}
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * s )
+{
+	register int n;
+    	for ( n = 0; s[n]; ++n )
+		;
+
+	return n;
+}
+#endif
+
+void *skel_alloc (yy_size_t  size )
+{
+	return (void *) malloc( size );
+}
+
+void *skel_realloc  (void * ptr, yy_size_t  size )
+{
+	/* The cast to (char *) in the following accommodates both
+	 * implementations that use char* generic pointers, and those
+	 * that use void* generic pointers.  It works with the latter
+	 * because both ANSI C and C++ allow castless assignment from
+	 * any pointer type to void*, and deal with argument conversions
+	 * as though doing an assignment.
+	 */
+	return (void *) realloc( (char *) ptr, size );
+}
+
+void skel_free (void * ptr )
+{
+	free( (char *) ptr );	/* see skel_realloc() for (char *) cast */
+}
+
+/* %if-tables-serialization definitions */
+/* %define-yytables   The name for this specific scanner's tables. */
+#define YYTABLES_NAME "yytables"
+/* %endif */
+
+/* %ok-for-header */
+
+#undef YY_NEW_FILE
+#undef YY_FLUSH_BUFFER
+#undef yy_set_bol
+#undef yy_new_buffer
+#undef yy_set_interactive
+#undef yytext_ptr
+#undef YY_DO_BEFORE_ACTION
+
+#ifdef YY_DECL_IS_OURS
+#undef YY_DECL_IS_OURS
+#undef YY_DECL
+#endif
+#line 120 "scan-skel.l"
+
+
+
+/*------------------------.
+| Scan a Bison skeleton.  |
+`------------------------*/
+
+void
+scan_skel (FILE *in)
+{
+  skel_in = in;
+  skel__flex_debug = trace_flag & trace_skeleton;
+  skel_lex ();
+  /* Reclaim Flex's buffers.  */
+  skel__delete_buffer (YY_CURRENT_BUFFER);
+}
+
diff --git a/src/scan-skel.h b/src/scan-skel.h
new file mode 100644
index 0000000..a7e14c3
--- /dev/null
+++ b/src/scan-skel.h
@@ -0,0 +1,28 @@
+/* Scan Bison Skeletons.
+
+   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+void scan_skel (FILE *);
+
+/* Pacify "make syntax-check".  */
+extern FILE *skel_in;
+extern FILE *skel_out;
+extern int skel__flex_debug;
+extern int skel_lineno;
diff --git a/src/scan-skel.l b/src/scan-skel.l
new file mode 100644
index 0000000..c84eea1
--- /dev/null
+++ b/src/scan-skel.l
@@ -0,0 +1,134 @@
+/* Scan Bison Skeletons.                                       -*- C -*-
+
+   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software
+   Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+
+%option nodefault noyywrap nounput never-interactive debug
+%option prefix="skel_" outfile="lex.yy.c"
+
+%{
+/* Work around a bug in flex 2.5.31.  See Debian bug 333231
+   <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=333231>.  */
+#undef skel_wrap
+#define skel_wrap() 1
+
+#include "system.h"
+
+#include <error.h>
+#include <quotearg.h>
+
+#include "complain.h"
+#include "getargs.h"
+#include "files.h"
+#include "scan-skel.h"
+
+/* Pacify "gcc -Wmissing-prototypes" when flex 2.5.31 is used.  */
+int skel_lex (void);
+int skel_get_lineno (void);
+FILE *skel_get_in (void);
+FILE *skel_get_out (void);
+int skel_get_leng (void);
+char *skel_get_text (void);
+void skel_set_lineno (int);
+void skel_set_in (FILE *);
+void skel_set_out (FILE *);
+int skel_get_debug (void);
+void skel_set_debug (int);
+int skel_lex_destroy (void);
+
+#define QPUTS(String) \
+   fputs (quotearg_style (c_quoting_style, String), yyout)
+
+#define BASE_QPUTS(File) \
+   QPUTS (base_name (File))
+
+%}
+%%
+
+%{
+  int lineno IF_LINT (= 0);
+  char *outname = NULL;
+%}
+
+"@output ".*\n {
+  char const *file_name = yytext + sizeof "@output " - 1;
+  yytext[yyleng - 1] = '\0';
+
+  /* Decode special file names.  They include the directory part,
+     contrary to their "free" occurrences, used for issuing #includes,
+     which must not include the directory part.  */
+
+  if (*file_name == '@')
+    {
+      if (strcmp (file_name, "@output_header_name@") == 0)
+	file_name = spec_defines_file;
+      else if (strcmp (file_name, "@output_parser_name@") == 0)
+	file_name = parser_file_name;
+      else
+	fatal ("invalid token in skeleton: %s", yytext);
+    }
+  if (outname)
+    {
+      free (outname);
+      xfclose (yyout);
+    }
+  outname = xstrdup (file_name);
+  yyout = xfopen (outname, "w");
+  lineno = 1;
+}
+
+"@@"	   fputc ('@', yyout);
+"@{"	   fputc ('[', yyout);
+"@}"	   fputc (']', yyout);
+
+"@oline@"  fprintf (yyout, "%d", lineno + 1);
+"@ofile@"  QPUTS (outname);
+"@dir_prefix@" QPUTS (dir_prefix);
+"@output_parser_name@"	BASE_QPUTS (parser_file_name);
+"@output_header_name@"	BASE_QPUTS (spec_defines_file);
+
+  /* This pattern must not match more than the previous @ patterns. */
+@[^{}@\n]* fatal ("invalid @ in skeleton: %s", yytext);
+\n	   lineno++; ECHO;
+[^@\n]+	   ECHO;
+
+<<EOF>> {
+  if (outname)
+    {
+      free (outname);
+      xfclose (yyout);
+    }
+  return EOF;
+}
+%%
+
+/*------------------------.
+| Scan a Bison skeleton.  |
+`------------------------*/
+
+void
+scan_skel (FILE *in)
+{
+  skel_in = in;
+  skel__flex_debug = trace_flag & trace_skeleton;
+  skel_lex ();
+  /* Reclaim Flex's buffers.  */
+  yy_delete_buffer (YY_CURRENT_BUFFER);
+}
diff --git a/src/state.c b/src/state.c
new file mode 100644
index 0000000..4eb39f9
--- /dev/null
+++ b/src/state.c
@@ -0,0 +1,370 @@
+/* Type definitions for nondeterministic finite state machine for Bison.
+
+   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software
+   Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+#include "system.h"
+
+#include <hash.h>
+
+#include "complain.h"
+#include "gram.h"
+#include "state.h"
+
+
+			/*-------------------.
+			| Shifts and Gotos.  |
+			`-------------------*/
+
+
+/*-----------------------------------------.
+| Create a new array of NUM shifts/gotos.  |
+`-----------------------------------------*/
+
+static transitions *
+transitions_new (int num, state **the_states)
+{
+  size_t states_size = num * sizeof *the_states;
+  transitions *res = xmalloc (offsetof (transitions, states) + states_size);
+  res->num = num;
+  memcpy (res->states, the_states, states_size);
+  return res;
+}
+
+
+/*-------------------------------------------------------.
+| Return the state such that SHIFTS contain a shift/goto |
+| to it on SYM.  Abort if none found.                    |
+`-------------------------------------------------------*/
+
+state *
+transitions_to (transitions *shifts, symbol_number sym)
+{
+  int j;
+  for (j = 0; ; j++)
+    {
+      assert (j < shifts->num);
+      if (TRANSITION_SYMBOL (shifts, j) == sym)
+	return shifts->states[j];
+    }
+}
+
+
+			/*--------------------.
+			| Error transitions.  |
+			`--------------------*/
+
+
+/*---------------------------------.
+| Create a new array of NUM errs.  |
+`---------------------------------*/
+
+errs *
+errs_new (int num, symbol **tokens)
+{
+  size_t symbols_size = num * sizeof *tokens;
+  errs *res = xmalloc (offsetof (errs, symbols) + symbols_size);
+  res->num = num;
+  memcpy (res->symbols, tokens, symbols_size);
+  return res;
+}
+
+
+
+
+			/*-------------.
+			| Reductions.  |
+			`-------------*/
+
+
+/*---------------------------------------.
+| Create a new array of NUM reductions.  |
+`---------------------------------------*/
+
+static reductions *
+reductions_new (int num, rule **reds)
+{
+  size_t rules_size = num * sizeof *reds;
+  reductions *res = xmalloc (offsetof (reductions, rules) + rules_size);
+  res->num = num;
+  res->look_ahead_tokens = NULL;
+  memcpy (res->rules, reds, rules_size);
+  return res;
+}
+
+
+
+			/*---------.
+			| States.  |
+			`---------*/
+
+
+state_number nstates = 0;
+/* FINAL_STATE is properly set by new_state when it recognizes its
+   accessing symbol: $end.  */
+state *final_state = NULL;
+
+
+/*------------------------------------------------------------------.
+| Create a new state with ACCESSING_SYMBOL, for those items.  Store |
+| it in the state hash table.                                       |
+`------------------------------------------------------------------*/
+
+state *
+state_new (symbol_number accessing_symbol,
+	   size_t nitems, item_number *core)
+{
+  state *res;
+  size_t items_size = nitems * sizeof *core;
+
+  assert (nstates < STATE_NUMBER_MAXIMUM);
+
+  res = xmalloc (offsetof (state, items) + items_size);
+  res->number = nstates++;
+  res->accessing_symbol = accessing_symbol;
+  res->transitions = NULL;
+  res->reductions = NULL;
+  res->errs = NULL;
+  res->consistent = 0;
+  res->solved_conflicts = NULL;
+
+  res->nitems = nitems;
+  memcpy (res->items, core, items_size);
+
+  state_hash_insert (res);
+
+  return res;
+}
+
+
+/*---------.
+| Free S.  |
+`---------*/
+
+static void
+state_free (state *s)
+{
+  free (s->transitions);
+  free (s->reductions);
+  free (s->errs);
+  free (s);
+}
+
+
+/*---------------------------.
+| Set the transitions of S.  |
+`---------------------------*/
+
+void
+state_transitions_set (state *s, int num, state **trans)
+{
+  assert (!s->transitions);
+  s->transitions = transitions_new (num, trans);
+}
+
+
+/*--------------------------.
+| Set the reductions of S.  |
+`--------------------------*/
+
+void
+state_reductions_set (state *s, int num, rule **reds)
+{
+  assert (!s->reductions);
+  s->reductions = reductions_new (num, reds);
+}
+
+
+int
+state_reduction_find (state *s, rule *r)
+{
+  int i;
+  reductions *reds = s->reductions;
+  for (i = 0; i < reds->num; ++i)
+    if (reds->rules[i] == r)
+      return i;
+  return -1;
+}
+
+
+/*--------------------.
+| Set the errs of S.  |
+`--------------------*/
+
+void
+state_errs_set (state *s, int num, symbol **tokens)
+{
+  assert (!s->errs);
+  s->errs = errs_new (num, tokens);
+}
+
+
+
+/*---------------------------------------------------.
+| Print on OUT all the look-ahead tokens such that S |
+| wants to reduce R.                                 |
+`---------------------------------------------------*/
+
+void
+state_rule_look_ahead_tokens_print (state *s, rule *r, FILE *out)
+{
+  /* Find the reduction we are handling.  */
+  reductions *reds = s->reductions;
+  int red = state_reduction_find (s, r);
+
+  /* Print them if there are.  */
+  if (reds->look_ahead_tokens && red != -1)
+    {
+      bitset_iterator biter;
+      int k;
+      char const *sep = "";
+      fprintf (out, "  [");
+      BITSET_FOR_EACH (biter, reds->look_ahead_tokens[red], k, 0)
+	{
+	  fprintf (out, "%s%s", sep, symbols[k]->tag);
+	  sep = ", ";
+	}
+      fprintf (out, "]");
+    }
+}
+
+
+/*---------------------.
+| A state hash table.  |
+`---------------------*/
+
+/* Initial capacity of states hash table.  */
+#define HT_INITIAL_CAPACITY 257
+
+static struct hash_table *state_table = NULL;
+
+/* Two states are equal if they have the same core items.  */
+static inline bool
+state_compare (state const *s1, state const *s2)
+{
+  size_t i;
+
+  if (s1->nitems != s2->nitems)
+    return false;
+
+  for (i = 0; i < s1->nitems; ++i)
+    if (s1->items[i] != s2->items[i])
+      return false;
+
+  return true;
+}
+
+static bool
+state_comparator (void const *s1, void const *s2)
+{
+  return state_compare (s1, s2);
+}
+
+static inline size_t
+state_hash (state const *s, size_t tablesize)
+{
+  /* Add up the state's item numbers to get a hash key.  */
+  size_t key = 0;
+  size_t i;
+  for (i = 0; i < s->nitems; ++i)
+    key += s->items[i];
+  return key % tablesize;
+}
+
+static size_t
+state_hasher (void const *s, size_t tablesize)
+{
+  return state_hash (s, tablesize);
+}
+
+
+/*-------------------------------.
+| Create the states hash table.  |
+`-------------------------------*/
+
+void
+state_hash_new (void)
+{
+  state_table = hash_initialize (HT_INITIAL_CAPACITY,
+				 NULL,
+				 state_hasher,
+				 state_comparator,
+				 NULL);
+}
+
+
+/*---------------------------------------------.
+| Free the states hash table, not the states.  |
+`---------------------------------------------*/
+
+void
+state_hash_free (void)
+{
+  hash_free (state_table);
+}
+
+
+/*-----------------------------------.
+| Insert S in the state hash table.  |
+`-----------------------------------*/
+
+void
+state_hash_insert (state *s)
+{
+  hash_insert (state_table, s);
+}
+
+
+/*------------------------------------------------------------------.
+| Find the state associated to the CORE, and return it.  If it does |
+| not exist yet, return NULL.                                       |
+`------------------------------------------------------------------*/
+
+state *
+state_hash_lookup (size_t nitems, item_number *core)
+{
+  size_t items_size = nitems * sizeof *core;
+  state *probe = xmalloc (offsetof (state, items) + items_size);
+  state *entry;
+
+  probe->nitems = nitems;
+  memcpy (probe->items, core, items_size);
+  entry = hash_lookup (state_table, probe);
+  free (probe);
+  return entry;
+}
+
+/* All the decorated states, indexed by the state number.  */
+state **states = NULL;
+
+
+/*----------------------.
+| Free all the states.  |
+`----------------------*/
+
+void
+states_free (void)
+{
+  state_number i;
+  for (i = 0; i < nstates; ++i)
+    state_free (states[i]);
+  free (states);
+}
diff --git a/src/state.h b/src/state.h
new file mode 100644
index 0000000..440cd46
--- /dev/null
+++ b/src/state.h
@@ -0,0 +1,257 @@
+/* Type definitions for nondeterministic finite state machine for Bison.
+
+   Copyright (C) 1984, 1989, 2000, 2001, 2002, 2003, 2004 Free
+   Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+
+/* These type definitions are used to represent a nondeterministic
+   finite state machine that parses the specified grammar.  This
+   information is generated by the function generate_states in the
+   file LR0.
+
+   Each state of the machine is described by a set of items --
+   particular positions in particular rules -- that are the possible
+   places where parsing could continue when the machine is in this
+   state.  These symbols at these items are the allowable inputs that
+   can follow now.
+
+   A core represents one state.  States are numbered in the NUMBER
+   field.  When generate_states is finished, the starting state is
+   state 0 and NSTATES is the number of states.  (FIXME: This sentence
+   is no longer true: A transition to a state whose state number is
+   NSTATES indicates termination.)  All the cores are chained together
+   and FIRST_STATE points to the first one (state 0).
+
+   For each state there is a particular symbol which must have been
+   the last thing accepted to reach that state.  It is the
+   ACCESSING_SYMBOL of the core.
+
+   Each core contains a vector of NITEMS items which are the indices
+   in the RITEMS vector of the items that are selected in this state.
+
+   The two types of actions are shifts/gotos (push the look-ahead token
+   and read another/goto to the state designated by a nterm) and
+   reductions (combine the last n things on the stack via a rule,
+   replace them with the symbol that the rule derives, and leave the
+   look-ahead token alone).  When the states are generated, these
+   actions are represented in two other lists.
+
+   Each transition structure describes the possible transitions out
+   of one state, the state whose number is in the number field.  Each
+   contains a vector of numbers of the states that transitions can go
+   to.  The accessing_symbol fields of those states' cores say what
+   kind of input leads to them.
+
+   A transition to state zero should be ignored: conflict resolution
+   deletes transitions by having them point to zero.
+
+   Each reductions structure describes the possible reductions at the
+   state whose number is in the number field.  The data is a list of
+   nreds rules, represented by their rule numbers.  first_reduction
+   points to the list of these structures.
+
+   Conflict resolution can decide that certain tokens in certain
+   states should explicitly be errors (for implementing %nonassoc).
+   For each state, the tokens that are errors for this reason are
+   recorded in an errs structure, which holds the token numbers.
+
+   There is at least one goto transition present in state zero.  It
+   leads to a next-to-final state whose accessing_symbol is the
+   grammar's start symbol.  The next-to-final state has one shift to
+   the final state, whose accessing_symbol is zero (end of input).
+   The final state has one shift, which goes to the termination state.
+   The reason for the extra state at the end is to placate the
+   parser's strategy of making all decisions one token ahead of its
+   actions.  */
+
+#ifndef STATE_H_
+# define STATE_H_
+
+# include <bitset.h>
+
+# include "gram.h"
+# include "symtab.h"
+
+
+/*-------------------.
+| Numbering states.  |
+`-------------------*/
+
+typedef int state_number;
+# define STATE_NUMBER_MAXIMUM INT_MAX
+
+/* Be ready to map a state_number to an int.  */
+static inline int
+state_number_as_int (state_number s)
+{
+  return s;
+}
+
+
+typedef struct state state;
+
+/*--------------.
+| Transitions.  |
+`--------------*/
+
+typedef struct
+{
+  int num;
+  state *states[1];
+} transitions;
+
+
+/* What is the symbol labelling the transition to
+   TRANSITIONS->states[Num]?  Can be a token (amongst which the error
+   token), or non terminals in case of gotos.  */
+
+#define TRANSITION_SYMBOL(Transitions, Num) \
+  (Transitions->states[Num]->accessing_symbol)
+
+/* Is the TRANSITIONS->states[Num] a shift? (as opposed to gotos).  */
+
+#define TRANSITION_IS_SHIFT(Transitions, Num) \
+  (ISTOKEN (TRANSITION_SYMBOL (Transitions, Num)))
+
+/* Is the TRANSITIONS->states[Num] a goto?. */
+
+#define TRANSITION_IS_GOTO(Transitions, Num) \
+  (!TRANSITION_IS_SHIFT (Transitions, Num))
+
+/* Is the TRANSITIONS->states[Num] labelled by the error token?  */
+
+#define TRANSITION_IS_ERROR(Transitions, Num) \
+  (TRANSITION_SYMBOL (Transitions, Num) == errtoken->number)
+
+/* When resolving a SR conflicts, if the reduction wins, the shift is
+   disabled.  */
+
+#define TRANSITION_DISABLE(Transitions, Num) \
+  (Transitions->states[Num] = NULL)
+
+#define TRANSITION_IS_DISABLED(Transitions, Num) \
+  (Transitions->states[Num] == NULL)
+
+
+/* Iterate over each transition over a token (shifts).  */
+#define FOR_EACH_SHIFT(Transitions, Iter)			\
+  for (Iter = 0;						\
+       Iter < Transitions->num					\
+	 && (TRANSITION_IS_DISABLED (Transitions, Iter)		\
+	     || TRANSITION_IS_SHIFT (Transitions, Iter));	\
+       ++Iter)							\
+    if (!TRANSITION_IS_DISABLED (Transitions, Iter))
+
+
+/* Return the state such SHIFTS contain a shift/goto to it on SYM.
+   Abort if none found.  */
+struct state *transitions_to (transitions *shifts, symbol_number sym);
+
+
+/*-------.
+| Errs.  |
+`-------*/
+
+typedef struct
+{
+  int num;
+  symbol *symbols[1];
+} errs;
+
+errs *errs_new (int num, symbol **tokens);
+
+
+/*-------------.
+| Reductions.  |
+`-------------*/
+
+typedef struct
+{
+  int num;
+  bitset *look_ahead_tokens;
+  rule *rules[1];
+} reductions;
+
+
+
+/*---------.
+| states.  |
+`---------*/
+
+struct state
+{
+  state_number number;
+  symbol_number accessing_symbol;
+  transitions *transitions;
+  reductions *reductions;
+  errs *errs;
+
+  /* Nonzero if no look-ahead is needed to decide what to do in state S.  */
+  char consistent;
+
+  /* If some conflicts were solved thanks to precedence/associativity,
+     a human readable description of the resolution.  */
+  const char *solved_conflicts;
+
+  /* Its items.  Must be last, since ITEMS can be arbitrarily large.
+     */
+  size_t nitems;
+  item_number items[1];
+};
+
+extern state_number nstates;
+extern state *final_state;
+
+/* Create a new state with ACCESSING_SYMBOL for those items.  */
+state *state_new (symbol_number accessing_symbol,
+		  size_t core_size, item_number *core);
+
+/* Set the transitions of STATE.  */
+void state_transitions_set (state *s, int num, state **trans);
+
+/* Set the reductions of STATE.  */
+void state_reductions_set (state *s, int num, rule **reds);
+
+int state_reduction_find (state *s, rule *r);
+
+/* Set the errs of STATE.  */
+void state_errs_set (state *s, int num, symbol **errors);
+
+/* Print on OUT all the look-ahead tokens such that this STATE wants to
+   reduce R.  */
+void state_rule_look_ahead_tokens_print (state *s, rule *r, FILE *out);
+
+/* Create/destroy the states hash table.  */
+void state_hash_new (void);
+void state_hash_free (void);
+
+/* Find the state associated to the CORE, and return it.  If it does
+   not exist yet, return NULL.  */
+state *state_hash_lookup (size_t core_size, item_number *core);
+
+/* Insert STATE in the state hash table.  */
+void state_hash_insert (state *s);
+
+/* All the states, indexed by the state number.  */
+extern state **states;
+
+/* Free all the states.  */
+void states_free (void);
+#endif /* !STATE_H_ */
diff --git a/src/symlist.c b/src/symlist.c
new file mode 100644
index 0000000..70db82f
--- /dev/null
+++ b/src/symlist.c
@@ -0,0 +1,162 @@
+/* Lists of symbols for Bison
+
+   Copyright (C) 2002, 2005, 2006 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+#include "system.h"
+
+#include "complain.h"
+#include "symlist.h"
+
+
+/*--------------------------------------.
+| Create a list containing SYM at LOC.  |
+`--------------------------------------*/
+
+symbol_list *
+symbol_list_new (symbol *sym, location loc)
+{
+  symbol_list *res = xmalloc (sizeof *res);
+
+  res->sym = sym;
+  res->location = loc;
+
+  res->midrule = NULL;
+
+  res->action = NULL;
+  res->used = false;
+
+  res->ruleprec = NULL;
+  res->dprec = 0;
+  res->merger = 0;
+
+  res->next = NULL;
+
+  return res;
+}
+
+
+/*------------------.
+| Print this list.  |
+`------------------*/
+
+void
+symbol_list_print (const symbol_list *l, FILE *f)
+{
+  for (/* Nothing. */; l && l->sym; l = l->next)
+    {
+      symbol_print (l->sym, f);
+      fprintf (stderr, l->used ? " used" : " unused");
+      if (l && l->sym)
+	fprintf (f, ", ");
+    }
+}
+
+
+/*---------------------------------.
+| Prepend SYM at LOC to the LIST.  |
+`---------------------------------*/
+
+symbol_list *
+symbol_list_prepend (symbol_list *list, symbol *sym, location loc)
+{
+  symbol_list *res = symbol_list_new (sym, loc);
+  res->next = list;
+  return res;
+}
+
+
+/*-------------------------------------------------.
+| Free the LIST, but not the symbols it contains.  |
+`-------------------------------------------------*/
+
+void
+symbol_list_free (symbol_list *list)
+{
+  LIST_FREE (symbol_list, list);
+}
+
+
+/*--------------------.
+| Return its length.  |
+`--------------------*/
+
+unsigned int
+symbol_list_length (const symbol_list *l)
+{
+  int res = 0;
+  for (/* Nothing. */; l; l = l->next)
+    ++res;
+  return res;
+}
+
+
+/*--------------------------------.
+| Get symbol N in symbol list L.  |
+`--------------------------------*/
+
+symbol_list *
+symbol_list_n_get (symbol_list *l, int n)
+{
+  int i;
+
+  if (n < 0)
+    return NULL;
+
+  for (i = 0; i < n; ++i)
+    {
+      l = l->next;
+      if (l == NULL || l->sym == NULL)
+	return NULL;
+    }
+
+  return l;
+}
+
+
+/*--------------------------------------------------------------.
+| Get the data type (alternative in the union) of the value for |
+| symbol N in symbol list L.                                    |
+`--------------------------------------------------------------*/
+
+uniqstr
+symbol_list_n_type_name_get (symbol_list *l, location loc, int n)
+{
+  l = symbol_list_n_get (l, n);
+  if (!l)
+    {
+      complain_at (loc, _("invalid $ value: $%d"), n);
+      return NULL;
+    }
+  return l->sym->type_name;
+}
+
+
+/*----------------------------------------.
+| The symbol N in symbol list L is USED.  |
+`----------------------------------------*/
+
+void
+symbol_list_n_used_set (symbol_list *l, int n, bool used)
+{
+  l = symbol_list_n_get (l, n);
+  if (l)
+    l->used = used;
+}
diff --git a/src/symlist.h b/src/symlist.h
new file mode 100644
index 0000000..0423d01
--- /dev/null
+++ b/src/symlist.h
@@ -0,0 +1,83 @@
+/* Lists of symbols for Bison
+
+   Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#ifndef SYMLIST_H_
+# define SYMLIST_H_
+
+# include "location.h"
+# include "symtab.h"
+
+/* A list of symbols, used during the parsing to store the rules.  */
+typedef struct symbol_list
+{
+  /* The symbol.  */
+  symbol *sym;
+  location location;
+
+  /* If this symbol is the generated lhs for a mid-rule, a pointer to
+     that mid-rule.  */
+  struct symbol_list *midrule;
+
+  /* The action is attached to the LHS of a rule. */
+  const char *action;
+  location action_location;
+
+  /* Whether this symbol's value is used in the current action. */
+  bool used;
+
+  /* Precedence/associativity.  */
+  symbol *ruleprec;
+  int dprec;
+  int merger;
+
+  /* The list.  */
+  struct symbol_list *next;
+} symbol_list;
+
+
+/* Create a list containing SYM at LOC.  */
+symbol_list *symbol_list_new (symbol *sym, location loc);
+
+/* Print it.  */
+void symbol_list_print (const symbol_list *l, FILE *f);
+
+/* Prepend SYM at LOC to the LIST.  */
+symbol_list *symbol_list_prepend (symbol_list *l,
+				  symbol *sym,
+				  location loc);
+
+/* Free the LIST, but not the symbols it contains.  */
+void symbol_list_free (symbol_list *l);
+
+/* Return its length. */
+unsigned int symbol_list_length (const symbol_list *l);
+
+/* Get symbol N in symbol list L.  */
+symbol_list *symbol_list_n_get (symbol_list *l, int n);
+
+/* Get the data type (alternative in the union) of the value for
+   symbol N in rule RULE.  */
+uniqstr symbol_list_n_type_name_get (symbol_list *l, location loc, int n);
+
+/* The symbol N in symbol list L is USED.  */
+void symbol_list_n_used_set (symbol_list *l, int n, bool used);
+
+#endif /* !SYMLIST_H_ */
diff --git a/src/symtab.c b/src/symtab.c
new file mode 100644
index 0000000..ef59c6e
--- /dev/null
+++ b/src/symtab.c
@@ -0,0 +1,657 @@
+/* Symbol table manager for Bison.
+
+   Copyright (C) 1984, 1989, 2000, 2001, 2002, 2004, 2005, 2006 Free
+   Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+#include "system.h"
+
+#include <hash.h>
+#include <quotearg.h>
+
+#include "complain.h"
+#include "gram.h"
+#include "symtab.h"
+
+/*------------------------.
+| Distinguished symbols.  |
+`------------------------*/
+
+symbol *errtoken = NULL;
+symbol *undeftoken = NULL;
+symbol *endtoken = NULL;
+symbol *accept = NULL;
+symbol *startsymbol = NULL;
+location startsymbol_location;
+
+/*---------------------------------.
+| Create a new symbol, named TAG.  |
+`---------------------------------*/
+
+static symbol *
+symbol_new (uniqstr tag, location loc)
+{
+  symbol *res = xmalloc (sizeof *res);
+
+  uniqstr_assert (tag);
+  res->tag = tag;
+  res->location = loc;
+
+  res->type_name = NULL;
+  res->destructor = NULL;
+  res->printer = NULL;
+
+  res->number = NUMBER_UNDEFINED;
+  res->prec = 0;
+  res->assoc = undef_assoc;
+  res->user_token_number = USER_NUMBER_UNDEFINED;
+
+  res->alias = NULL;
+  res->class = unknown_sym;
+  res->declared = false;
+
+  if (nsyms == SYMBOL_NUMBER_MAXIMUM)
+    fatal (_("too many symbols in input grammar (limit is %d)"),
+	   SYMBOL_NUMBER_MAXIMUM);
+  nsyms++;
+  return res;
+}
+
+
+/*-----------------.
+| Print a symbol.  |
+`-----------------*/
+
+#define SYMBOL_ATTR_PRINT(Attr)				\
+  if (s->Attr)						\
+    fprintf (f, " %s { %s }", #Attr, s->Attr)
+
+void
+symbol_print (symbol *s, FILE *f)
+{
+  if (s)
+    {
+      fprintf (f, "\"%s\"", s->tag);
+      SYMBOL_ATTR_PRINT (type_name);
+      SYMBOL_ATTR_PRINT (destructor);
+      SYMBOL_ATTR_PRINT (printer);
+    }
+  else
+    fprintf (f, "<NULL>");
+}
+
+#undef SYMBOL_ATTR_PRINT
+
+/*------------------------------------------------------------------.
+| Complain that S's WHAT is redeclared at SECOND, and was first set |
+| at FIRST.                                                         |
+`------------------------------------------------------------------*/
+
+static void
+redeclaration (symbol* s, const char *what, location first, location second)
+{
+  complain_at (second, _("%s redeclaration for %s"), what, s->tag);
+  complain_at (first, _("first declaration"));
+}
+
+
+/*-----------------------------------------------------------------.
+| Set the TYPE_NAME associated with SYM.  Does nothing if passed 0 |
+| as TYPE_NAME.                                                    |
+`-----------------------------------------------------------------*/
+
+void
+symbol_type_set (symbol *sym, uniqstr type_name, location loc)
+{
+  if (type_name)
+    {
+      if (sym->type_name)
+	redeclaration (sym, "%type", sym->type_location, loc);
+      uniqstr_assert (type_name);
+      sym->type_name = type_name;
+      sym->type_location = loc;
+    }
+}
+
+
+/*------------------------------------------------------------------.
+| Set the DESTRUCTOR associated with SYM.  Do nothing if passed 0.  |
+`------------------------------------------------------------------*/
+
+void
+symbol_destructor_set (symbol *sym, const char *destructor, location loc)
+{
+  if (destructor)
+    {
+      if (sym->destructor)
+	redeclaration (sym, "%destructor", sym->destructor_location, loc);
+      sym->destructor = destructor;
+      sym->destructor_location = loc;
+    }
+}
+
+
+/*---------------------------------------------------------------.
+| Set the PRINTER associated with SYM.  Do nothing if passed 0.  |
+`---------------------------------------------------------------*/
+
+void
+symbol_printer_set (symbol *sym, const char *printer, location loc)
+{
+  if (printer)
+    {
+      if (sym->printer)
+	redeclaration (sym, "%printer", sym->destructor_location, loc);
+      sym->printer = printer;
+      sym->printer_location = loc;
+    }
+}
+
+
+/*-----------------------------------------------------------------.
+| Set the PRECEDENCE associated with SYM.  Does nothing if invoked |
+| with UNDEF_ASSOC as ASSOC.                                       |
+`-----------------------------------------------------------------*/
+
+void
+symbol_precedence_set (symbol *sym, int prec, assoc a, location loc)
+{
+  if (a != undef_assoc)
+    {
+      if (sym->prec != 0)
+	redeclaration (sym, assoc_to_string (a), sym->prec_location, loc);
+      sym->prec = prec;
+      sym->assoc = a;
+      sym->prec_location = loc;
+    }
+
+  /* Only terminals have a precedence. */
+  symbol_class_set (sym, token_sym, loc, false);
+}
+
+
+/*------------------------------------.
+| Set the CLASS associated with SYM.  |
+`------------------------------------*/
+
+void
+symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring)
+{
+  if (sym->class != unknown_sym && sym->class != class)
+    {
+      complain_at (loc, _("symbol %s redefined"), sym->tag);
+      sym->declared = false;
+    }
+
+  if (class == nterm_sym && sym->class != nterm_sym)
+    sym->number = nvars++;
+  else if (class == token_sym && sym->number == NUMBER_UNDEFINED)
+    sym->number = ntokens++;
+
+  sym->class = class;
+
+  if (declaring)
+    {
+      if (sym->declared)
+	warn_at (loc, _("symbol %s redeclared"), sym->tag);
+      sym->declared = true;
+    }
+}
+
+
+/*------------------------------------------------.
+| Set the USER_TOKEN_NUMBER associated with SYM.  |
+`------------------------------------------------*/
+
+void
+symbol_user_token_number_set (symbol *sym, int user_token_number, location loc)
+{
+  assert (sym->class == token_sym);
+
+  if (sym->user_token_number != USER_NUMBER_UNDEFINED
+      && sym->user_token_number != user_token_number)
+    complain_at (loc, _("redefining user token number of %s"), sym->tag);
+
+  sym->user_token_number = user_token_number;
+  /* User defined $end token? */
+  if (user_token_number == 0)
+    {
+      endtoken = sym;
+      endtoken->number = 0;
+      /* It is always mapped to 0, so it was already counted in
+	 NTOKENS.  */
+      --ntokens;
+    }
+}
+
+
+/*----------------------------------------------------------.
+| If SYM is not defined, report an error, and consider it a |
+| nonterminal.                                              |
+`----------------------------------------------------------*/
+
+static inline bool
+symbol_check_defined (symbol *sym)
+{
+  if (sym->class == unknown_sym)
+    {
+      complain_at
+	(sym->location,
+	 _("symbol %s is used, but is not defined as a token and has no rules"),
+	 sym->tag);
+      sym->class = nterm_sym;
+      sym->number = nvars++;
+    }
+
+  return true;
+}
+
+static bool
+symbol_check_defined_processor (void *sym, void *null ATTRIBUTE_UNUSED)
+{
+  return symbol_check_defined (sym);
+}
+
+
+/*------------------------------------------------------------------.
+| Declare the new symbol SYM.  Make it an alias of SYMVAL, and type |
+| SYMVAL with SYM's type.                                           |
+`------------------------------------------------------------------*/
+
+void
+symbol_make_alias (symbol *sym, symbol *symval, location loc)
+{
+  if (symval->alias)
+    warn_at (loc, _("symbol `%s' used more than once as a literal string"),
+	     symval->tag);
+  else if (sym->alias)
+    warn_at (loc, _("symbol `%s' given more than one literal string"),
+	     sym->tag);
+  else
+    {
+      symval->class = token_sym;
+      symval->user_token_number = sym->user_token_number;
+      sym->user_token_number = USER_NUMBER_ALIAS;
+      symval->alias = sym;
+      sym->alias = symval;
+      /* sym and symval combined are only one symbol.  */
+      nsyms--;
+      ntokens--;
+      assert (ntokens == sym->number || ntokens == symval->number);
+      sym->number = symval->number =
+	(symval->number < sym->number) ? symval->number : sym->number;
+      symbol_type_set (symval, sym->type_name, loc);
+    }
+}
+
+
+/*---------------------------------------------------------.
+| Check that THIS, and its alias, have same precedence and |
+| associativity.                                           |
+`---------------------------------------------------------*/
+
+static inline void
+symbol_check_alias_consistency (symbol *this)
+{
+  symbol *alias = this;
+  symbol *orig  = this->alias;
+
+  /* Check only those that _are_ the aliases.  */
+  if (!(this->alias && this->user_token_number == USER_NUMBER_ALIAS))
+    return;
+
+  if (orig->type_name != alias->type_name)
+    {
+      if (orig->type_name)
+	symbol_type_set (alias, orig->type_name, orig->type_location);
+      else
+	symbol_type_set (orig, alias->type_name, alias->type_location);
+    }
+
+
+  if (orig->destructor || alias->destructor)
+    {
+      if (orig->destructor)
+	symbol_destructor_set (alias, orig->destructor,
+			       orig->destructor_location);
+      else
+	symbol_destructor_set (orig, alias->destructor,
+			       alias->destructor_location);
+    }
+
+  if (orig->printer || alias->printer)
+    {
+      if (orig->printer)
+	symbol_printer_set (alias, orig->printer, orig->printer_location);
+      else
+	symbol_printer_set (orig, alias->printer, alias->printer_location);
+    }
+
+  if (alias->prec || orig->prec)
+    {
+      if (orig->prec)
+	symbol_precedence_set (alias, orig->prec, orig->assoc,
+			       orig->prec_location);
+      else
+	symbol_precedence_set (orig, alias->prec, alias->assoc,
+			       alias->prec_location);
+    }
+}
+
+static bool
+symbol_check_alias_consistency_processor (void *this,
+					  void *null ATTRIBUTE_UNUSED)
+{
+  symbol_check_alias_consistency (this);
+  return true;
+}
+
+
+/*-------------------------------------------------------------------.
+| Assign a symbol number, and write the definition of the token name |
+| into FDEFINES.  Put in SYMBOLS.                                    |
+`-------------------------------------------------------------------*/
+
+static inline bool
+symbol_pack (symbol *this)
+{
+  if (this->class == nterm_sym)
+    {
+      this->number += ntokens;
+    }
+  else if (this->alias)
+    {
+      /* This symbol and its alias are a single token defn.
+	 Allocate a tokno, and assign to both check agreement of
+	 prec and assoc fields and make both the same */
+      if (this->number == NUMBER_UNDEFINED)
+	{
+	  if (this == endtoken || this->alias == endtoken)
+	    this->number = this->alias->number = 0;
+	  else
+	    {
+	      assert (this->alias->number != NUMBER_UNDEFINED);
+	      this->number = this->alias->number;
+	    }
+	}
+      /* Do not do processing below for USER_NUMBER_ALIASes.  */
+      if (this->user_token_number == USER_NUMBER_ALIAS)
+	return true;
+    }
+  else /* this->class == token_sym */
+    assert (this->number != NUMBER_UNDEFINED);
+
+  symbols[this->number] = this;
+  return true;
+}
+
+static bool
+symbol_pack_processor (void *this, void *null ATTRIBUTE_UNUSED)
+{
+  return symbol_pack (this);
+}
+
+
+
+
+/*--------------------------------------------------.
+| Put THIS in TOKEN_TRANSLATIONS if it is a token.  |
+`--------------------------------------------------*/
+
+static inline bool
+symbol_translation (symbol *this)
+{
+  /* Non-terminal? */
+  if (this->class == token_sym
+      && this->user_token_number != USER_NUMBER_ALIAS)
+    {
+      /* A token which translation has already been set? */
+      if (token_translations[this->user_token_number] != undeftoken->number)
+	complain_at (this->location,
+		     _("tokens %s and %s both assigned number %d"),
+		     symbols[token_translations[this->user_token_number]]->tag,
+		     this->tag, this->user_token_number);
+
+      token_translations[this->user_token_number] = this->number;
+    }
+
+  return true;
+}
+
+static bool
+symbol_translation_processor (void *this, void *null ATTRIBUTE_UNUSED)
+{
+  return symbol_translation (this);
+}
+
+
+/*----------------------.
+| A symbol hash table.  |
+`----------------------*/
+
+/* Initial capacity of symbols hash table.  */
+#define HT_INITIAL_CAPACITY 257
+
+static struct hash_table *symbol_table = NULL;
+
+static inline bool
+hash_compare_symbol (const symbol *m1, const symbol *m2)
+{
+  /* Since tags are unique, we can compare the pointers themselves.  */
+  return UNIQSTR_EQ (m1->tag, m2->tag);
+}
+
+static bool
+hash_symbol_comparator (void const *m1, void const *m2)
+{
+  return hash_compare_symbol (m1, m2);
+}
+
+static inline size_t
+hash_symbol (const symbol *m, size_t tablesize)
+{
+  /* Since tags are unique, we can hash the pointer itself.  */
+  return ((uintptr_t) m->tag) % tablesize;
+}
+
+static size_t
+hash_symbol_hasher (void const *m, size_t tablesize)
+{
+  return hash_symbol (m, tablesize);
+}
+
+
+/*-------------------------------.
+| Create the symbol hash table.  |
+`-------------------------------*/
+
+void
+symbols_new (void)
+{
+  symbol_table = hash_initialize (HT_INITIAL_CAPACITY,
+				  NULL,
+				  hash_symbol_hasher,
+				  hash_symbol_comparator,
+				  free);
+}
+
+
+/*----------------------------------------------------------------.
+| Find the symbol named KEY, and return it.  If it does not exist |
+| yet, create it.                                                 |
+`----------------------------------------------------------------*/
+
+symbol *
+symbol_get (const char *key, location loc)
+{
+  symbol probe;
+  symbol *entry;
+
+  key = uniqstr_new (key);
+  probe.tag = key;
+  entry = hash_lookup (symbol_table, &probe);
+
+  if (!entry)
+    {
+      /* First insertion in the hash. */
+      entry = symbol_new (key, loc);
+      hash_insert (symbol_table, entry);
+    }
+  return entry;
+}
+
+
+/*------------------------------------------------------------------.
+| Generate a dummy nonterminal, whose name cannot conflict with the |
+| user's names.                                                     |
+`------------------------------------------------------------------*/
+
+symbol *
+dummy_symbol_get (location loc)
+{
+  /* Incremented for each generated symbol.  */
+  static int dummy_count = 0;
+  static char buf[256];
+
+  symbol *sym;
+
+  sprintf (buf, "@%d", ++dummy_count);
+  sym = symbol_get (buf, loc);
+  sym->class = nterm_sym;
+  sym->number = nvars++;
+  return sym;
+}
+
+
+/*-------------------.
+| Free the symbols.  |
+`-------------------*/
+
+void
+symbols_free (void)
+{
+  hash_free (symbol_table);
+  free (symbols);
+}
+
+
+/*---------------------------------------------------------------.
+| Look for undefined symbols, report an error, and consider them |
+| terminals.                                                     |
+`---------------------------------------------------------------*/
+
+static void
+symbols_do (Hash_processor processor, void *processor_data)
+{
+  hash_do_for_each (symbol_table, processor, processor_data);
+}
+
+
+/*--------------------------------------------------------------.
+| Check that all the symbols are defined.  Report any undefined |
+| symbols and consider them nonterminals.                       |
+`--------------------------------------------------------------*/
+
+void
+symbols_check_defined (void)
+{
+  symbols_do (symbol_check_defined_processor, NULL);
+}
+
+/*------------------------------------------------------------------.
+| Set TOKEN_TRANSLATIONS.  Check that no two symbols share the same |
+| number.                                                           |
+`------------------------------------------------------------------*/
+
+static void
+symbols_token_translations_init (void)
+{
+  bool num_256_available_p = true;
+  int i;
+
+  /* Find the highest user token number, and whether 256, the POSIX
+     preferred user token number for the error token, is used.  */
+  max_user_token_number = 0;
+  for (i = 0; i < ntokens; ++i)
+    {
+      symbol *this = symbols[i];
+      if (this->user_token_number != USER_NUMBER_UNDEFINED)
+	{
+	  if (this->user_token_number > max_user_token_number)
+	    max_user_token_number = this->user_token_number;
+	  if (this->user_token_number == 256)
+	    num_256_available_p = false;
+	}
+    }
+
+  /* If 256 is not used, assign it to error, to follow POSIX.  */
+  if (num_256_available_p
+      && errtoken->user_token_number == USER_NUMBER_UNDEFINED)
+    errtoken->user_token_number = 256;
+
+  /* Set the missing user numbers. */
+  if (max_user_token_number < 256)
+    max_user_token_number = 256;
+
+  for (i = 0; i < ntokens; ++i)
+    {
+      symbol *this = symbols[i];
+      if (this->user_token_number == USER_NUMBER_UNDEFINED)
+	this->user_token_number = ++max_user_token_number;
+      if (this->user_token_number > max_user_token_number)
+	max_user_token_number = this->user_token_number;
+    }
+
+  token_translations = xnmalloc (max_user_token_number + 1,
+				 sizeof *token_translations);
+
+  /* Initialize all entries for literal tokens to 2, the internal
+     token number for $undefined, which represents all invalid inputs.
+     */
+  for (i = 0; i < max_user_token_number + 1; i++)
+    token_translations[i] = undeftoken->number;
+  symbols_do (symbol_translation_processor, NULL);
+}
+
+
+/*----------------------------------------------------------------.
+| Assign symbol numbers, and write definition of token names into |
+| FDEFINES.  Set up vectors SYMBOL_TABLE, TAGS of symbols.        |
+`----------------------------------------------------------------*/
+
+void
+symbols_pack (void)
+{
+  symbols = xcalloc (nsyms, sizeof *symbols);
+
+  symbols_do (symbol_check_alias_consistency_processor, NULL);
+  symbols_do (symbol_pack_processor, NULL);
+
+  symbols_token_translations_init ();
+
+  if (startsymbol->class == unknown_sym)
+    fatal_at (startsymbol_location,
+	      _("the start symbol %s is undefined"),
+	      startsymbol->tag);
+  else if (startsymbol->class == token_sym)
+    fatal_at (startsymbol_location,
+	      _("the start symbol %s is a token"),
+	      startsymbol->tag);
+}
diff --git a/src/symtab.h b/src/symtab.h
new file mode 100644
index 0000000..0f852b7
--- /dev/null
+++ b/src/symtab.h
@@ -0,0 +1,162 @@
+/* Definitions for symtab.c and callers, part of Bison.
+
+   Copyright (C) 1984, 1989, 1992, 2000, 2001, 2002, 2004, 2005, 2006
+   Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#ifndef SYMTAB_H_
+# define SYMTAB_H_
+
+# include "assoc.h"
+# include "location.h"
+# include "uniqstr.h"
+
+/*----------.
+| Symbols.  |
+`----------*/
+
+/* Symbol classes.  */
+typedef enum
+{
+  unknown_sym,
+  token_sym,		/* terminal symbol */
+  nterm_sym		/* non-terminal */
+} symbol_class;
+
+
+/* Internal token numbers. */
+typedef int symbol_number;
+#define SYMBOL_NUMBER_MAXIMUM INT_MAX
+
+
+typedef struct symbol symbol;
+
+/* When extending this structure, be sure to complete
+   symbol_check_alias_consistency.  */
+struct symbol
+{
+  /* The key, name of the symbol.  */
+  uniqstr tag;
+  /* The location of its first occurrence.  */
+  location location;
+
+  /* Its %type and associated printer and destructor.  */
+  uniqstr type_name;
+  location type_location;
+
+  /* Does not own the memory. */
+  const char *destructor;
+  location destructor_location;
+
+  /* Does not own the memory. */
+  const char *printer;
+  location printer_location;
+
+  symbol_number number;
+  location prec_location;
+  int prec;
+  assoc assoc;
+  int user_token_number;
+
+  /* Points to the other in the identifier-symbol pair for an alias.
+     Special value USER_NUMBER_ALIAS in the identifier half of the
+     identifier-symbol pair for an alias.  */
+  symbol *alias;
+  symbol_class class;
+  bool declared;
+};
+
+/* Undefined user number.  */
+#define USER_NUMBER_UNDEFINED -1
+
+/* `symbol->user_token_number == USER_NUMBER_ALIAS' means this symbol
+   *has* (not is) a string literal alias.  For instance, `%token foo
+   "foo"' has `"foo"' numbered regularly, and `foo' numbered as
+   USER_NUMBER_ALIAS.  */
+#define USER_NUMBER_ALIAS -9991
+
+/* Undefined internal token number.  */
+#define NUMBER_UNDEFINED (-1)
+
+/* Print a symbol (for debugging). */
+void symbol_print (symbol *s, FILE *f);
+
+/* Fetch (or create) the symbol associated to KEY.  */
+symbol *symbol_get (const char *key, location loc);
+
+/* Generate a dummy nonterminal, whose name cannot conflict with the
+   user's names.  */
+symbol *dummy_symbol_get (location loc);
+
+/* Declare the new symbol SYM.  Make it an alias of SYMVAL.  */
+void symbol_make_alias (symbol *sym, symbol *symval, location loc);
+
+/* Set the TYPE_NAME associated with SYM.  Do nothing if passed 0 as
+   TYPE_NAME.  */
+void symbol_type_set (symbol *sym, uniqstr type_name, location loc);
+
+/* Set the DESTRUCTOR associated with SYM.  */
+void symbol_destructor_set (symbol *sym, const char *destructor, location loc);
+
+/* Set the PRINTER associated with SYM.  */
+void symbol_printer_set (symbol *sym, const char *printer, location loc);
+
+/* Set the PRECEDENCE associated with SYM.  Ensure that SYMBOL is a
+   terminal.  Do nothing if invoked with UNDEF_ASSOC as ASSOC.  */
+void symbol_precedence_set (symbol *sym, int prec, assoc a, location loc);
+
+/* Set the CLASS associated with SYM.  */
+void symbol_class_set (symbol *sym, symbol_class class, location loc,
+		       bool declaring);
+
+/* Set the USER_TOKEN_NUMBER associated with SYM.  */
+void symbol_user_token_number_set (symbol *sym, int user_number, location loc);
+
+
+/* Distinguished symbols.  AXIOM is the real start symbol, that used
+   by the automaton.  STARTSYMBOL is the one specified by the user.
+   */
+extern symbol *errtoken;
+extern symbol *undeftoken;
+extern symbol *endtoken;
+extern symbol *accept;
+extern symbol *startsymbol;
+extern location startsymbol_location;
+
+
+/*---------------.
+| Symbol table.  |
+`---------------*/
+
+
+/* Create the symbol table.  */
+void symbols_new (void);
+
+/* Free all the memory allocated for symbols.  */
+void symbols_free (void);
+
+/* Check that all the symbols are defined.  Report any undefined
+   symbols and consider them nonterminals.  */
+void symbols_check_defined (void);
+
+/* Perform various sanity checks, assign symbol numbers, and set up
+   TOKEN_TRANSLATIONS.  */
+void symbols_pack (void);
+
+#endif /* !SYMTAB_H_ */
diff --git a/src/system.h b/src/system.h
new file mode 100644
index 0000000..6315790
--- /dev/null
+++ b/src/system.h
@@ -0,0 +1,231 @@
+/* System-dependent definitions for Bison.
+
+   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 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 2, 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, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef BISON_SYSTEM_H
+#define BISON_SYSTEM_H
+
+/* flex 2.5.31 gratutiously defines macros like INT8_MIN.  But this
+   runs afoul of pre-C99 compilers that have <inttypes.h> or
+   <stdint.h>, which are included below if available.  It also runs
+   afoul of pre-C99 compilers that define these macros in <limits.h>.  */
+#if ! defined __STDC_VERSION__ || __STDC_VERSION__ < 199901
+# undef INT8_MIN
+# undef INT16_MIN
+# undef INT32_MIN
+# undef INT8_MAX
+# undef INT16_MAX
+# undef UINT8_MAX
+# undef INT32_MAX
+# undef UINT16_MAX
+# undef UINT32_MAX
+#endif
+
+#include <limits.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "unlocked-io.h"
+
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+
+#if ! HAVE_UINTPTR_T
+/* This isn't perfect, but it's good enough for Bison, which needs
+   only to hash pointers.  */
+typedef size_t uintptr_t;
+#endif
+
+#include <verify.h>
+#include <xalloc.h>
+
+
+/*---------------------.
+| Missing prototypes.  |
+`---------------------*/
+
+#include <stpcpy.h>
+
+/* From lib/basename.c. */
+char *base_name (char const *name);
+
+
+/*-----------------.
+| GCC extensions.  |
+`-----------------*/
+
+/* Use this to suppress gcc's `...may be used before initialized'
+   warnings.  */
+#ifdef lint
+# define IF_LINT(Code) Code
+#else
+# define IF_LINT(Code) /* empty */
+#endif
+
+#ifndef __attribute__
+/* This feature is available in gcc versions 2.5 and later.  */
+# if (! defined __GNUC__ || __GNUC__ < 2 \
+      || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__)
+#  define __attribute__(Spec) /* empty */
+# endif
+#endif
+
+/* The __-protected variants of `format' and `printf' attributes
+   are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
+#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+# define __format__ format
+# define __printf__ printf
+#endif
+
+#ifndef ATTRIBUTE_NORETURN
+# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
+#endif
+
+#ifndef ATTRIBUTE_UNUSED
+# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
+#endif
+
+/*------.
+| NLS.  |
+`------*/
+
+#include <locale.h>
+
+#include <gettext.h>
+#define _(Msgid)  gettext (Msgid)
+#define N_(Msgid) (Msgid)
+
+
+/*-------------------------------.
+| Fix broken compilation flags.  |
+`-------------------------------*/
+
+#ifndef LOCALEDIR
+# define LOCALEDIR "/usr/local/share/locale"
+#endif
+
+
+/*-----------.
+| Booleans.  |
+`-----------*/
+
+#include <stdbool.h>
+
+
+/*-----------.
+| Obstacks.  |
+`-----------*/
+
+#define obstack_chunk_alloc xmalloc
+#define obstack_chunk_free  free
+#include <obstack.h>
+
+#define obstack_sgrow(Obs, Str) \
+  obstack_grow (Obs, Str, strlen (Str))
+
+#define obstack_fgrow1(Obs, Format, Arg1)	\
+do {						\
+  char buf[4096];				\
+  sprintf (buf, Format, Arg1);			\
+  obstack_grow (Obs, buf, strlen (buf));	\
+} while (0)
+
+#define obstack_fgrow2(Obs, Format, Arg1, Arg2)	\
+do {						\
+  char buf[4096];				\
+  sprintf (buf, Format, Arg1, Arg2);		\
+  obstack_grow (Obs, buf, strlen (buf));	\
+} while (0)
+
+#define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3)	\
+do {							\
+  char buf[4096];					\
+  sprintf (buf, Format, Arg1, Arg2, Arg3);		\
+  obstack_grow (Obs, buf, strlen (buf));		\
+} while (0)
+
+#define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4)	\
+do {								\
+  char buf[4096];						\
+  sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4);		\
+  obstack_grow (Obs, buf, strlen (buf));			\
+} while (0)
+
+
+
+/*-----------------------------------------.
+| Extensions to use for the output files.  |
+`-----------------------------------------*/
+
+#ifndef OUTPUT_EXT
+# define OUTPUT_EXT ".output"
+#endif
+
+#ifndef TAB_EXT
+# define TAB_EXT ".tab"
+#endif
+
+#ifndef DEFAULT_TMPDIR
+# define DEFAULT_TMPDIR "/tmp"
+#endif
+
+
+
+/*---------------------.
+| Free a linked list.  |
+`---------------------*/
+
+#define LIST_FREE(Type, List)			\
+do {						\
+  Type *_node, *_next;				\
+  for (_node = List; _node; _node = _next)	\
+    {						\
+      _next = _node->next;			\
+      free (_node);				\
+    }						\
+} while (0)
+
+
+/* Assertions.  <assert.h>'s assertions are too heavyweight, and can
+   be disabled too easily, so implement it separately here.  */
+#define assert(x) ((void) ((x) || (abort (), 0)))
+
+
+/*---------------------------------------------.
+| Debugging memory allocation (must be last).  |
+`---------------------------------------------*/
+
+# if WITH_DMALLOC
+#  define DMALLOC_FUNC_CHECK
+#  include <dmalloc.h>
+# endif /* WITH_DMALLOC */
+
+#endif  /* ! BISON_SYSTEM_H */
diff --git a/src/tables.c b/src/tables.c
new file mode 100644
index 0000000..c938139
--- /dev/null
+++ b/src/tables.c
@@ -0,0 +1,861 @@
+/* Output the generated parsing program for Bison.
+
+   Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003, 2004,
+   2005 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+
+#include <config.h>
+#include "system.h"
+
+#include <bitsetv.h>
+#include <quotearg.h>
+
+#include "complain.h"
+#include "conflicts.h"
+#include "files.h"
+#include "getargs.h"
+#include "gram.h"
+#include "lalr.h"
+#include "reader.h"
+#include "symtab.h"
+#include "tables.h"
+
+/* Several tables are indexed both by state and nonterminal numbers.
+   We call such an index a `vector'; i.e., a vector is either a state
+   or a nonterminal number.
+
+   Of course vector_number_t ought to be wide enough to contain
+   state_number and symbol_number.  */
+typedef int vector_number;
+
+#if 0 /* Not currently used.  */
+static inline vector_number
+state_number_to_vector_number (state_number s)
+{
+  return s;
+}
+#endif
+
+static inline vector_number
+symbol_number_to_vector_number (symbol_number sym)
+{
+  return state_number_as_int (nstates) + sym - ntokens;
+}
+
+int nvectors;
+
+
+/* FROMS and TOS are indexed by vector_number.
+
+   If VECTOR is a nonterminal, (FROMS[VECTOR], TOS[VECTOR]) form an
+   array of state numbers of the non defaulted GOTO on VECTOR.
+
+   If VECTOR is a state, TOS[VECTOR] is the array of actions to do on
+   the (array of) symbols FROMS[VECTOR].
+
+   In both cases, TALLY[VECTOR] is the size of the arrays
+   FROMS[VECTOR], TOS[VECTOR]; and WIDTH[VECTOR] =
+   (FROMS[VECTOR][SIZE] - FROMS[VECTOR][0] + 1) where SIZE =
+   TALLY[VECTOR].
+
+   FROMS therefore contains symbol_number and action_number,
+   TOS state_number and action_number,
+   TALLY sizes,
+   WIDTH differences of FROMS.
+
+   Let base_number be the type of FROMS, TOS, and WIDTH.  */
+#define BASE_MAXIMUM INT_MAX
+#define BASE_MINIMUM INT_MIN
+
+static base_number **froms;
+static base_number **tos;
+static unsigned int **conflict_tos;
+static int *tally;
+static base_number *width;
+
+
+/* For a given state, N = ACTROW[SYMBOL]:
+
+   If N = 0, stands for `run the default action'.
+   If N = MIN, stands for `raise a syntax error'.
+   If N > 0, stands for `shift SYMBOL and go to n'.
+   If N < 0, stands for `reduce -N'.  */
+typedef int action_number;
+#define ACTION_NUMBER_MINIMUM INT_MIN
+
+static action_number *actrow;
+
+/* FROMS and TOS are reordered to be compressed.  ORDER[VECTOR] is the
+   new vector number of VECTOR.  We skip `empty' vectors (i.e.,
+   TALLY[VECTOR] = 0), and call these `entries'.  */
+static vector_number *order;
+static int nentries;
+
+base_number *base = NULL;
+/* A distinguished value of BASE, negative infinite.  During the
+   computation equals to BASE_MINIMUM, later mapped to BASE_NINF to
+   keep parser tables small.  */
+base_number base_ninf = 0;
+static base_number *pos = NULL;
+
+static unsigned int *conflrow;
+unsigned int *conflict_table;
+unsigned int *conflict_list;
+int conflict_list_cnt;
+static int conflict_list_free;
+
+/* TABLE_SIZE is the allocated size of both TABLE and CHECK.  We start
+   with more or less the original hard-coded value (which was
+   SHRT_MAX).  */
+static int table_size = 32768;
+base_number *table;
+base_number *check;
+/* The value used in TABLE to denote explicit syntax errors
+   (%nonassoc), a negative infinite.  First defaults to ACTION_NUMBER_MININUM,
+   but in order to keep small tables, renumbered as TABLE_ERROR, which
+   is the smallest (non error) value minus 1.  */
+base_number table_ninf = 0;
+static int lowzero;
+int high;
+
+state_number *yydefgoto;
+rule_number *yydefact;
+
+/*----------------------------------------------------------------.
+| If TABLE (and CHECK) appear to be small to be addressed at      |
+| DESIRED, grow them.  Note that TABLE[DESIRED] is to be used, so |
+| the desired size is at least DESIRED + 1.                       |
+`----------------------------------------------------------------*/
+
+static void
+table_grow (int desired)
+{
+  int old_size = table_size;
+
+  while (table_size <= desired)
+    table_size *= 2;
+
+  if (trace_flag & trace_resource)
+    fprintf (stderr, "growing table and check from: %d to %d\n",
+	     old_size, table_size);
+
+  table = xnrealloc (table, table_size, sizeof *table);
+  conflict_table = xnrealloc (conflict_table, table_size,
+			      sizeof *conflict_table);
+  check = xnrealloc (check, table_size, sizeof *check);
+
+  for (/* Nothing. */; old_size < table_size; ++old_size)
+    {
+      table[old_size] = 0;
+      conflict_table[old_size] = 0;
+      check[old_size] = -1;
+    }
+}
+
+
+
+
+/*-------------------------------------------------------------------.
+| For GLR parsers, for each conflicted token in S, as indicated      |
+| by non-zero entries in CONFLROW, create a list of possible	     |
+| reductions that are alternatives to the shift or reduction	     |
+| currently recorded for that token in S.  Store the alternative     |
+| reductions followed by a 0 in CONFLICT_LIST, updating		     |
+| CONFLICT_LIST_CNT, and storing an index to the start of the list   |
+| back into CONFLROW.						     |
+`-------------------------------------------------------------------*/
+
+static void
+conflict_row (state *s)
+{
+  int i, j;
+  reductions *reds = s->reductions;
+
+  if (!nondeterministic_parser)
+    return;
+
+  for (j = 0; j < ntokens; j += 1)
+    if (conflrow[j])
+      {
+	conflrow[j] = conflict_list_cnt;
+
+	/* Find all reductions for token J, and record all that do not
+	   match ACTROW[J].  */
+	for (i = 0; i < reds->num; i += 1)
+	  if (bitset_test (reds->look_ahead_tokens[i], j)
+	      && (actrow[j]
+		  != rule_number_as_item_number (reds->rules[i]->number)))
+	    {
+	      assert (0 < conflict_list_free);
+	      conflict_list[conflict_list_cnt] = reds->rules[i]->number + 1;
+	      conflict_list_cnt += 1;
+	      conflict_list_free -= 1;
+	    }
+
+	/* Leave a 0 at the end.  */
+	assert (0 < conflict_list_free);
+	conflict_list[conflict_list_cnt] = 0;
+	conflict_list_cnt += 1;
+	conflict_list_free -= 1;
+      }
+}
+
+
+/*------------------------------------------------------------------.
+| Decide what to do for each type of token if seen as the           |
+| look-ahead in specified state.  The value returned is used as the |
+| default action (yydefact) for the state.  In addition, ACTROW is  |
+| filled with what to do for each kind of token, index by symbol    |
+| number, with zero meaning do the default action.  The value       |
+| ACTION_NUMBER_MINIMUM, a very negative number, means this	    |
+| situation is an error.  The parser recognizes this value	    |
+| specially.							    |
+|                                                                   |
+| This is where conflicts are resolved.  The loop over look-ahead   |
+| rules considered lower-numbered rules last, and the last rule     |
+| considered that likes a token gets to handle it.                  |
+|                                                                   |
+| For GLR parsers, also sets CONFLROW[SYM] to an index into         |
+| CONFLICT_LIST iff there is an unresolved conflict (s/r or r/r)    |
+| with symbol SYM. The default reduction is not used for a symbol   |
+| that has any such conflicts.                                      |
+`------------------------------------------------------------------*/
+
+static rule *
+action_row (state *s)
+{
+  int i;
+  rule *default_rule = NULL;
+  reductions *reds = s->reductions;
+  transitions *trans = s->transitions;
+  errs *errp = s->errs;
+  /* Set to nonzero to inhibit having any default reduction.  */
+  bool nodefault = false;
+  bool conflicted = false;
+
+  for (i = 0; i < ntokens; i++)
+    actrow[i] = conflrow[i] = 0;
+
+  if (reds->look_ahead_tokens)
+    {
+      int j;
+      bitset_iterator biter;
+      /* loop over all the rules available here which require
+	 look-ahead (in reverse order to give precedence to the first
+	 rule) */
+      for (i = reds->num - 1; i >= 0; --i)
+	/* and find each token which the rule finds acceptable
+	   to come next */
+	BITSET_FOR_EACH (biter, reds->look_ahead_tokens[i], j, 0)
+	{
+	  /* and record this rule as the rule to use if that
+	     token follows.  */
+	  if (actrow[j] != 0)
+	    {
+	      conflicted = true;
+	      conflrow[j] = 1;
+	    }
+	  actrow[j] = rule_number_as_item_number (reds->rules[i]->number);
+	}
+    }
+
+  /* Now see which tokens are allowed for shifts in this state.  For
+     them, record the shift as the thing to do.  So shift is preferred
+     to reduce.  */
+  FOR_EACH_SHIFT (trans, i)
+    {
+      symbol_number sym = TRANSITION_SYMBOL (trans, i);
+      state *shift_state = trans->states[i];
+
+      if (actrow[sym] != 0)
+	{
+	  conflicted = true;
+	  conflrow[sym] = 1;
+	}
+      actrow[sym] = state_number_as_int (shift_state->number);
+
+      /* Do not use any default reduction if there is a shift for
+	 error */
+      if (sym == errtoken->number)
+	nodefault = true;
+    }
+
+  /* See which tokens are an explicit error in this state (due to
+     %nonassoc).  For them, record ACTION_NUMBER_MINIMUM as the
+     action.  */
+  for (i = 0; i < errp->num; i++)
+    {
+      symbol *sym = errp->symbols[i];
+      actrow[sym->number] = ACTION_NUMBER_MINIMUM;
+    }
+
+  /* Now find the most common reduction and make it the default action
+     for this state.  */
+
+  if (reds->num >= 1 && !nodefault)
+    {
+      if (s->consistent)
+	default_rule = reds->rules[0];
+      else
+	{
+	  int max = 0;
+	  for (i = 0; i < reds->num; i++)
+	    {
+	      int count = 0;
+	      rule *r = reds->rules[i];
+	      symbol_number j;
+
+	      for (j = 0; j < ntokens; j++)
+		if (actrow[j] == rule_number_as_item_number (r->number))
+		  count++;
+
+	      if (count > max)
+		{
+		  max = count;
+		  default_rule = r;
+		}
+	    }
+
+	  /* GLR parsers need space for conflict lists, so we can't
+	     default conflicted entries.  For non-conflicted entries
+	     or as long as we are not building a GLR parser,
+	     actions that match the default are replaced with zero,
+	     which means "use the default". */
+
+	  if (max > 0)
+	    {
+	      int j;
+	      for (j = 0; j < ntokens; j++)
+		if (actrow[j] == rule_number_as_item_number (default_rule->number)
+		    && ! (nondeterministic_parser && conflrow[j]))
+		  actrow[j] = 0;
+	    }
+	}
+    }
+
+  /* If have no default rule, the default is an error.
+     So replace any action which says "error" with "use default".  */
+
+  if (!default_rule)
+    for (i = 0; i < ntokens; i++)
+      if (actrow[i] == ACTION_NUMBER_MINIMUM)
+	actrow[i] = 0;
+
+  if (conflicted)
+    conflict_row (s);
+
+  return default_rule;
+}
+
+
+/*----------------------------------------.
+| Set FROMS, TOS, TALLY and WIDTH for S.  |
+`----------------------------------------*/
+
+static void
+save_row (state_number s)
+{
+  symbol_number i;
+  int count;
+  base_number *sp;
+  base_number *sp1;
+  base_number *sp2;
+  unsigned int *sp3;
+
+  /* Number of non default actions in S.  */
+  count = 0;
+  for (i = 0; i < ntokens; i++)
+    if (actrow[i] != 0)
+      count++;
+
+  if (count == 0)
+    return;
+
+  /* Allocate non defaulted actions.  */
+  froms[s] = sp = sp1 = xnmalloc (count, sizeof *sp1);
+  tos[s] = sp2 = xnmalloc (count, sizeof *sp2);
+  conflict_tos[s] = sp3 =
+    nondeterministic_parser ? xnmalloc (count, sizeof *sp3) : NULL;
+
+  /* Store non defaulted actions.  */
+  for (i = 0; i < ntokens; i++)
+    if (actrow[i] != 0)
+      {
+	*sp1++ = i;
+	*sp2++ = actrow[i];
+	if (nondeterministic_parser)
+	  *sp3++ = conflrow[i];
+      }
+
+  tally[s] = count;
+  width[s] = sp1[-1] - sp[0] + 1;
+}
+
+
+/*------------------------------------------------------------------.
+| Figure out the actions for the specified state, indexed by        |
+| look-ahead token type.                                            |
+|                                                                   |
+| The YYDEFACT table is output now.  The detailed info is saved for |
+| putting into YYTABLE later.                                       |
+`------------------------------------------------------------------*/
+
+static void
+token_actions (void)
+{
+  state_number i;
+  symbol_number j;
+  rule_number r;
+
+  int nconflict = nondeterministic_parser ? conflicts_total_count () : 0;
+
+  yydefact = xnmalloc (nstates, sizeof *yydefact);
+
+  actrow = xnmalloc (ntokens, sizeof *actrow);
+  conflrow = xnmalloc (ntokens, sizeof *conflrow);
+
+  conflict_list = xnmalloc (1 + 2 * nconflict, sizeof *conflict_list);
+  conflict_list_free = 2 * nconflict;
+  conflict_list_cnt = 1;
+
+  /* Find the rules which are reduced.  */
+  if (!nondeterministic_parser)
+    for (r = 0; r < nrules; ++r)
+      rules[r].useful = false;
+
+  for (i = 0; i < nstates; ++i)
+    {
+      rule *default_rule = action_row (states[i]);
+      yydefact[i] = default_rule ? default_rule->number + 1 : 0;
+      save_row (i);
+
+      /* Now that the parser was computed, we can find which rules are
+	 really reduced, and which are not because of SR or RR
+	 conflicts.  */
+      if (!nondeterministic_parser)
+	{
+	  for (j = 0; j < ntokens; ++j)
+	    if (actrow[j] < 0 && actrow[j] != ACTION_NUMBER_MINIMUM)
+	      rules[item_number_as_rule_number (actrow[j])].useful = true;
+	  if (yydefact[i])
+	    rules[yydefact[i] - 1].useful = true;
+	}
+    }
+
+  free (actrow);
+  free (conflrow);
+}
+
+
+/*------------------------------------------------------------------.
+| Compute FROMS[VECTOR], TOS[VECTOR], TALLY[VECTOR], WIDTH[VECTOR], |
+| i.e., the information related to non defaulted GOTO on the nterm  |
+| SYM.                                                              |
+|                                                                   |
+| DEFAULT_STATE is the principal destination on SYM, i.e., the      |
+| default GOTO destination on SYM.                                  |
+`------------------------------------------------------------------*/
+
+static void
+save_column (symbol_number sym, state_number default_state)
+{
+  goto_number i;
+  base_number *sp;
+  base_number *sp1;
+  base_number *sp2;
+  int count;
+  vector_number symno = symbol_number_to_vector_number (sym);
+
+  goto_number begin = goto_map[sym - ntokens];
+  goto_number end = goto_map[sym - ntokens + 1];
+
+  /* Number of non default GOTO.  */
+  count = 0;
+  for (i = begin; i < end; i++)
+    if (to_state[i] != default_state)
+      count++;
+
+  if (count == 0)
+    return;
+
+  /* Allocate room for non defaulted gotos.  */
+  froms[symno] = sp = sp1 = xnmalloc (count, sizeof *sp1);
+  tos[symno] = sp2 = xnmalloc (count, sizeof *sp2);
+
+  /* Store the state numbers of the non defaulted gotos.  */
+  for (i = begin; i < end; i++)
+    if (to_state[i] != default_state)
+      {
+	*sp1++ = from_state[i];
+	*sp2++ = to_state[i];
+      }
+
+  tally[symno] = count;
+  width[symno] = sp1[-1] - sp[0] + 1;
+}
+
+
+/*-------------------------------------------------------------.
+| Return `the' most common destination GOTO on SYM (a nterm).  |
+`-------------------------------------------------------------*/
+
+static state_number
+default_goto (symbol_number sym, size_t state_count[])
+{
+  state_number s;
+  goto_number i;
+  goto_number m = goto_map[sym - ntokens];
+  goto_number n = goto_map[sym - ntokens + 1];
+  state_number default_state = -1;
+  size_t max = 0;
+
+  if (m == n)
+    return -1;
+
+  for (s = 0; s < nstates; s++)
+    state_count[s] = 0;
+
+  for (i = m; i < n; i++)
+    state_count[to_state[i]]++;
+
+  for (s = 0; s < nstates; s++)
+    if (state_count[s] > max)
+      {
+	max = state_count[s];
+	default_state = s;
+      }
+
+  return default_state;
+}
+
+
+/*-------------------------------------------------------------------.
+| Figure out what to do after reducing with each rule, depending on  |
+| the saved state from before the beginning of parsing the data that |
+| matched this rule.                                                 |
+|                                                                    |
+| The YYDEFGOTO table is output now.  The detailed info is saved for |
+| putting into YYTABLE later.                                        |
+`-------------------------------------------------------------------*/
+
+static void
+goto_actions (void)
+{
+  symbol_number i;
+  size_t *state_count = xnmalloc (nstates, sizeof *state_count);
+  yydefgoto = xnmalloc (nvars, sizeof *yydefgoto);
+
+  /* For a given nterm I, STATE_COUNT[S] is the number of times there
+     is a GOTO to S on I.  */
+  for (i = ntokens; i < nsyms; ++i)
+    {
+      state_number default_state = default_goto (i, state_count);
+      save_column (i, default_state);
+      yydefgoto[i - ntokens] = default_state;
+    }
+  free (state_count);
+}
+
+
+/*------------------------------------------------------------------.
+| Compute ORDER, a reordering of vectors, in order to decide how to |
+| pack the actions and gotos information into yytable.              |
+`------------------------------------------------------------------*/
+
+static void
+sort_actions (void)
+{
+  int i;
+
+  nentries = 0;
+
+  for (i = 0; i < nvectors; i++)
+    if (tally[i] > 0)
+      {
+	int k;
+	int t = tally[i];
+	int w = width[i];
+	int j = nentries - 1;
+
+	while (j >= 0 && (width[order[j]] < w))
+	  j--;
+
+	while (j >= 0 && (width[order[j]] == w) && (tally[order[j]] < t))
+	  j--;
+
+	for (k = nentries - 1; k > j; k--)
+	  order[k + 1] = order[k];
+
+	order[j + 1] = i;
+	nentries++;
+      }
+}
+
+
+/* If VECTOR is a state which actions (reflected by FROMS, TOS, TALLY
+   and WIDTH of VECTOR) are common to a previous state, return this
+   state number.
+
+   In any other case, return -1.  */
+
+static state_number
+matching_state (vector_number vector)
+{
+  vector_number i = order[vector];
+  int t;
+  int w;
+  int prev;
+
+  /* If VECTOR is a nterm, return -1.  */
+  if (nstates <= i)
+    return -1;
+
+  t = tally[i];
+  w = width[i];
+
+  /* If VECTOR has GLR conflicts, return -1 */
+  if (conflict_tos[i] != NULL)
+    {
+      int j;
+      for (j = 0; j < t; j += 1)
+	if (conflict_tos[i][j] != 0)
+	  return -1;
+    }
+
+  for (prev = vector - 1; prev >= 0; prev--)
+    {
+      vector_number j = order[prev];
+      int k;
+      int match = 1;
+
+      /* Given how ORDER was computed, if the WIDTH or TALLY is
+	 different, there cannot be a matching state.  */
+      if (width[j] != w || tally[j] != t)
+	return -1;
+
+      for (k = 0; match && k < t; k++)
+	if (tos[j][k] != tos[i][k] || froms[j][k] != froms[i][k]
+	    || (conflict_tos[j] != NULL && conflict_tos[j][k] != 0))
+	  match = 0;
+
+      if (match)
+	return j;
+    }
+
+  return -1;
+}
+
+
+static base_number
+pack_vector (vector_number vector)
+{
+  vector_number i = order[vector];
+  int j;
+  int t = tally[i];
+  int loc = 0;
+  base_number *from = froms[i];
+  base_number *to = tos[i];
+  unsigned int *conflict_to = conflict_tos[i];
+
+  assert (t);
+
+  for (j = lowzero - from[0]; ; j++)
+    {
+      int k;
+      bool ok = true;
+
+      assert (j < table_size);
+
+      for (k = 0; ok && k < t; k++)
+	{
+	  loc = j + state_number_as_int (from[k]);
+	  if (table_size <= loc)
+	    table_grow (loc);
+
+	  if (table[loc] != 0)
+	    ok = false;
+	}
+
+      for (k = 0; ok && k < vector; k++)
+	if (pos[k] == j)
+	  ok = false;
+
+      if (ok)
+	{
+	  for (k = 0; k < t; k++)
+	    {
+	      loc = j + from[k];
+	      table[loc] = to[k];
+	      if (nondeterministic_parser && conflict_to != NULL)
+		conflict_table[loc] = conflict_to[k];
+	      check[loc] = from[k];
+	    }
+
+	  while (table[lowzero] != 0)
+	    lowzero++;
+
+	  if (loc > high)
+	    high = loc;
+
+	  assert (BASE_MINIMUM <= j && j <= BASE_MAXIMUM);
+	  return j;
+	}
+    }
+}
+
+
+/*-------------------------------------------------------------.
+| Remap the negative infinite in TAB from NINF to the greatest |
+| possible smallest value.  Return it.                         |
+|                                                              |
+| In most case this allows us to use shorts instead of ints in |
+| parsers.                                                     |
+`-------------------------------------------------------------*/
+
+static base_number
+table_ninf_remap (base_number tab[], int size, base_number ninf)
+{
+  base_number res = 0;
+  int i;
+
+  for (i = 0; i < size; i++)
+    if (tab[i] < res && tab[i] != ninf)
+      res = tab[i];
+
+  --res;
+
+  for (i = 0; i < size; i++)
+    if (tab[i] == ninf)
+      tab[i] = res;
+
+  return res;
+}
+
+static void
+pack_table (void)
+{
+  int i;
+
+  base = xnmalloc (nvectors, sizeof *base);
+  pos = xnmalloc (nentries, sizeof *pos);
+  table = xcalloc (table_size, sizeof *table);
+  conflict_table = xcalloc (table_size, sizeof *conflict_table);
+  check = xnmalloc (table_size, sizeof *check);
+
+  lowzero = 0;
+  high = 0;
+
+  for (i = 0; i < nvectors; i++)
+    base[i] = BASE_MINIMUM;
+
+  for (i = 0; i < table_size; i++)
+    check[i] = -1;
+
+  for (i = 0; i < nentries; i++)
+    {
+      state_number s = matching_state (i);
+      base_number place;
+
+      if (s < 0)
+	/* A new set of state actions, or a nonterminal.  */
+	place = pack_vector (i);
+      else
+	/* Action of I were already coded for S.  */
+	place = base[s];
+
+      pos[i] = place;
+      base[order[i]] = place;
+    }
+
+  /* Use the greatest possible negative infinites.  */
+  base_ninf = table_ninf_remap (base, nvectors, BASE_MINIMUM);
+  table_ninf = table_ninf_remap (table, high + 1, ACTION_NUMBER_MINIMUM);
+
+  free (pos);
+}
+
+
+
+/*-----------------------------------------------------------------.
+| Compute and output yydefact, yydefgoto, yypact, yypgoto, yytable |
+| and yycheck.                                                     |
+`-----------------------------------------------------------------*/
+
+void
+tables_generate (void)
+{
+  int i;
+
+  /* This is a poor way to make sure the sizes are properly
+     correlated.  In particular the signedness is not taken into
+     account.  But it's not useless.  */
+  verify (sizeof nstates <= sizeof nvectors
+	  && sizeof nvars <= sizeof nvectors);
+
+  nvectors = state_number_as_int (nstates) + nvars;
+
+  froms = xcalloc (nvectors, sizeof *froms);
+  tos = xcalloc (nvectors, sizeof *tos);
+  conflict_tos = xcalloc (nvectors, sizeof *conflict_tos);
+  tally = xcalloc (nvectors, sizeof *tally);
+  width = xnmalloc (nvectors, sizeof *width);
+
+  token_actions ();
+
+  goto_actions ();
+  free (goto_map);
+  free (from_state);
+  free (to_state);
+
+  order = xcalloc (nvectors, sizeof *order);
+  sort_actions ();
+  pack_table ();
+  free (order);
+
+  free (tally);
+  free (width);
+
+  for (i = 0; i < nvectors; i++)
+    {
+      free (froms[i]);
+      free (tos[i]);
+      free (conflict_tos[i]);
+    }
+
+  free (froms);
+  free (tos);
+  free (conflict_tos);
+}
+
+
+/*-------------------------.
+| Free the parser tables.  |
+`-------------------------*/
+
+void
+tables_free (void)
+{
+  free (base);
+  free (conflict_table);
+  free (conflict_list);
+  free (table);
+  free (check);
+  free (yydefgoto);
+  free (yydefact);
+}
diff --git a/src/tables.h b/src/tables.h
new file mode 100644
index 0000000..911917f
--- /dev/null
+++ b/src/tables.h
@@ -0,0 +1,119 @@
+/* Prepare the LALR and GLR parser tables.
+   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to the Free
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+
+#ifndef TABLES_H_
+# define TABLES_H_
+
+# include "state.h"
+
+/* The parser tables consist of these tables.
+
+   YYTRANSLATE = vector mapping yylex's token numbers into bison's
+   token numbers.
+
+   YYTNAME = vector of string-names indexed by bison token number.
+
+   YYTOKNUM = vector of yylex token numbers corresponding to entries
+   in YYTNAME.
+
+   YYRLINE = vector of line-numbers of all rules.  For yydebug
+   printouts.
+
+   YYRHS = vector of items of all rules.  This is exactly what RITEMS
+   contains.  For yydebug and for semantic parser.
+
+   YYPRHS[R] = index in YYRHS of first item for rule R.
+
+   YYR1[R] = symbol number of symbol that rule R derives.
+
+   YYR2[R] = number of symbols composing right hand side of rule R.
+
+   YYSTOS[S] = the symbol number of the symbol that leads to state S.
+
+   YYDEFACT[S] = default rule to reduce with in state s, when YYTABLE
+   doesn't specify something else to do.  Zero means the default is an
+   error.
+
+   YYDEFGOTO[I] = default state to go to after a reduction of a rule
+   that generates variable NTOKENS + I, except when YYTABLE specifies
+   something else to do.
+
+   YYPACT[S] = index in YYTABLE of the portion describing state S.
+   The look-ahead token's type is used to index that portion to find
+   out what to do.
+
+   If the value in YYTABLE is positive, we shift the token and go to
+   that state.
+
+   If the value is negative, it is minus a rule number to reduce by.
+
+   If the value is zero, the default action from YYDEFACT[S] is used.
+
+   YYPGOTO[I] = the index in YYTABLE of the portion describing what to
+   do after reducing a rule that derives variable I + NTOKENS.  This
+   portion is indexed by the parser state number, S, as of before the
+   text for this nonterminal was read.  The value from YYTABLE is the
+   state to go to if the corresponding value in YYCHECK is S.
+
+   YYTABLE = a vector filled with portions for different uses, found
+   via YYPACT and YYPGOTO.
+
+   YYCHECK = a vector indexed in parallel with YYTABLE.  It indicates,
+   in a roundabout way, the bounds of the portion you are trying to
+   examine.
+
+   Suppose that the portion of YYTABLE starts at index P and the index
+   to be examined within the portion is I.  Then if YYCHECK[P+I] != I,
+   I is outside the bounds of what is actually allocated, and the
+   default (from YYDEFACT or YYDEFGOTO) should be used.  Otherwise,
+   YYTABLE[P+I] should be used.
+
+   YYFINAL = the state number of the termination state.
+
+   YYLAST ( = high) the number of the last element of YYTABLE, i.e.,
+   sizeof (YYTABLE) - 1.  */
+
+extern int nvectors;
+
+typedef int base_number;
+extern base_number *base;
+/* A distinguished value of BASE, negative infinite.  During the
+   computation equals to BASE_MINIMUM, later mapped to BASE_NINF to
+   keep parser tables small.  */
+extern base_number base_ninf;
+
+extern unsigned int *conflict_table;
+extern unsigned int *conflict_list;
+extern int conflict_list_cnt;
+
+extern base_number *table;
+extern base_number *check;
+/* The value used in TABLE to denote explicit syntax errors
+   (%nonassoc), a negative infinite.  */
+extern base_number table_ninf;
+
+extern state_number *yydefgoto;
+extern rule_number *yydefact;
+extern int high;
+
+void tables_generate (void);
+void tables_free (void);
+
+#endif /* !TABLES_H_ */
diff --git a/src/uniqstr.c b/src/uniqstr.c
new file mode 100644
index 0000000..8804a80
--- /dev/null
+++ b/src/uniqstr.c
@@ -0,0 +1,153 @@
+/* Keep a unique copy of strings.
+
+   Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+#include "system.h"
+
+#include <error.h>
+#include <hash.h>
+#include <quotearg.h>
+
+#include "uniqstr.h"
+
+/*-----------------------.
+| A uniqstr hash table.  |
+`-----------------------*/
+
+/* Initial capacity of uniqstr hash table.  */
+#define HT_INITIAL_CAPACITY 257
+
+static struct hash_table *uniqstrs_table = NULL;
+
+/*-------------------------------------.
+| Create the uniqstr for S if needed.  |
+`-------------------------------------*/
+
+uniqstr
+uniqstr_new (char const *str)
+{
+  uniqstr res = hash_lookup (uniqstrs_table, str);
+  if (!res)
+    {
+      /* First insertion in the hash. */
+      res = xstrdup (str);
+      hash_insert (uniqstrs_table, res);
+    }
+  return res;
+}
+
+
+/*------------------------------.
+| Abort if S is not a uniqstr.  |
+`------------------------------*/
+
+void
+uniqstr_assert (char const *str)
+{
+  if (!hash_lookup (uniqstrs_table, str))
+    {
+      error (0, 0,
+	     "not a uniqstr: %s", quotearg (str));
+      abort ();
+    }
+}
+
+
+/*--------------------.
+| Print the uniqstr.  |
+`--------------------*/
+
+static inline bool
+uniqstr_print (uniqstr ustr)
+{
+  fprintf (stderr, "%s\n", ustr);
+  return true;
+}
+
+static bool
+uniqstr_print_processor (void *ustr, void *null ATTRIBUTE_UNUSED)
+{
+  return uniqstr_print (ustr);
+}
+
+
+/*-----------------------.
+| A uniqstr hash table.  |
+`-----------------------*/
+
+static bool
+hash_compare_uniqstr (void const *m1, void const *m2)
+{
+  return strcmp (m1, m2) == 0;
+}
+
+static size_t
+hash_uniqstr (void const *m, size_t tablesize)
+{
+  return hash_string (m, tablesize);
+}
+
+/*----------------------------.
+| Create the uniqstrs table.  |
+`----------------------------*/
+
+void
+uniqstrs_new (void)
+{
+  uniqstrs_table = hash_initialize (HT_INITIAL_CAPACITY,
+				    NULL,
+				    hash_uniqstr,
+				    hash_compare_uniqstr,
+				    free);
+}
+
+
+/*-------------------------------------.
+| Perform a task on all the uniqstrs.  |
+`-------------------------------------*/
+
+static void
+uniqstrs_do (Hash_processor processor, void *processor_data)
+{
+  hash_do_for_each (uniqstrs_table, processor, processor_data);
+}
+
+
+/*-----------------.
+| Print them all.  |
+`-----------------*/
+
+void
+uniqstrs_print (void)
+{
+  uniqstrs_do (uniqstr_print_processor, NULL);
+}
+
+
+/*--------------------.
+| Free the uniqstrs.  |
+`--------------------*/
+
+void
+uniqstrs_free (void)
+{
+  hash_free (uniqstrs_table);
+}
diff --git a/src/uniqstr.h b/src/uniqstr.h
new file mode 100644
index 0000000..ab482be
--- /dev/null
+++ b/src/uniqstr.h
@@ -0,0 +1,53 @@
+/* Keeping a unique copy of strings.
+
+   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#ifndef UNIQSTR_H_
+# define UNIQSTR_H_
+
+/*-----------------------------------------.
+| Pointers to unique copies of C strings.  |
+`-----------------------------------------*/
+
+typedef char const *uniqstr;
+
+/* Return the uniqstr for STR.  */
+uniqstr uniqstr_new (char const *str);
+
+/* Two uniqstr values have the same value iff they are the same.  */
+#define UNIQSTR_EQ(USTR1, USTR2) ((USTR1) == (USTR2))
+
+/*--------------------------------------.
+| Initializing, destroying, debugging.  |
+`--------------------------------------*/
+
+/* Create the string table.  */
+void uniqstrs_new (void);
+
+/* Die if STR is not a uniqstr.  */
+void uniqstr_assert (char const *str);
+
+/* Free all the memory allocated for symbols.  */
+void uniqstrs_free (void);
+
+/* Report them all.  */
+void uniqstrs_print (void);
+
+#endif /* ! defined UNIQSTR_H_ */
diff --git a/src/vcg.c b/src/vcg.c
new file mode 100644
index 0000000..25fbb64
--- /dev/null
+++ b/src/vcg.c
@@ -0,0 +1,841 @@
+/* VCG description handler for Bison.
+
+   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software
+   Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+#include "system.h"
+
+#include <quotearg.h>
+
+#include "vcg.h"
+#include "vcg_defaults.h"
+
+/* Return an unambiguous printable representated, for NAME, suitable
+   for C strings.  Use slot 2 since the user may use slots 0 and 1.
+   */
+
+static char const *
+quote (char const *name)
+{
+  return quotearg_n_style (2, c_quoting_style, name);
+}
+
+
+/* Initialize a graph with the default values. */
+void
+new_graph (graph *g)
+{
+  g->title = G_TITLE;
+  g->label = G_LABEL;
+
+  g->infos[0] = G_INFOS1;
+  g->infos[1] = G_INFOS2;
+  g->infos[2] = G_INFOS3;
+
+  g->color = G_COLOR;
+  g->textcolor = G_TEXTCOLOR;
+  g->bordercolor = G_BORDERCOLOR;
+
+  g->width = G_WIDTH;
+  g->height = G_HEIGHT;
+  g->borderwidth = G_BORDERWIDTH;
+  g->x = G_X;
+  g->y = G_Y;
+  g->folding = G_FOLDING;
+  g->shrink = G_SHRINK;
+  g->stretch = G_STRETCH;
+
+  g->textmode = G_TEXTMODE;
+  g->shape = G_SHAPE;
+
+  g->vertical_order = G_VERTICAL_ORDER;
+  g->horizontal_order = G_HORIZONTAL_ORDER;
+
+  g->xmax = G_XMAX; /* Not output. */
+  g->ymax = G_YMAX; /* Not output. */
+
+  g->xbase = G_XBASE;
+  g->ybase = G_YBASE;
+
+  g->xspace = G_XSPACE;
+  g->yspace = G_YSPACE;
+  g->xlspace = G_XLSPACE; /* Not output. */
+
+  g->xraster = G_XRASTER;
+  g->yraster = G_YRASTER;
+  g->xlraster = G_XLRASTER;
+
+  g->hidden = G_HIDDEN; /* No default value. */
+
+  g->classname = G_CLASSNAME; /* No class name association. */
+
+  g->layout_downfactor = G_LAYOUT_DOWNFACTOR;
+  g->layout_upfactor = G_LAYOUT_UPFACTOR;
+  g->layout_nearfactor = G_LAYOUT_NEARFACTOR;
+  g->layout_splinefactor = G_LAYOUT_SPLINEFACTOR;
+
+  g->late_edge_labels = G_LATE_EDGE_LABELS;
+  g->display_edge_labels = G_DISPLAY_EDGE_LABELS;
+  g->dirty_edge_labels = G_DIRTY_EDGE_LABELS;
+  g->finetuning = G_FINETUNING;
+  g->ignore_singles = G_IGNORE_SINGLES;
+  g->priority_phase = G_PRIORITY_PHASE;
+  g->manhattan_edges = G_MANHATTAN_EDGES;
+  g->smanhattan_edges = G_SMANHATTAN_EDGES;
+  g->near_edges = G_NEAR_EDGES;
+
+  g->orientation = G_ORIENTATION;
+  g->node_alignment = G_NODE_ALIGNMENT;
+  g->port_sharing = G_PORT_SHARING;
+  g->arrow_mode = G_ARROW_MODE;
+  g->treefactor = G_TREEFACTOR;
+  g->spreadlevel = G_SPREADLEVEL;
+  g->crossing_weight = G_CROSSING_WEIGHT;
+  g->crossing_phase2 = G_CROSSING_PHASE2;
+  g->crossing_optimization = G_CROSSING_OPTIMIZATION;
+  g->view = G_VIEW;
+
+  g->edges = G_EDGES;
+  g->nodes = G_NODES;
+  g->splines = G_SPLINES;
+
+  g->bmax = G_BMAX;
+  g->cmin = G_CMIN;
+  g->cmax = G_CMAX;
+  g->pmin = G_PMIN;
+  g->pmax = G_PMAX;
+  g->rmin = G_RMIN;
+  g->rmax = G_RMAX;
+  g->smax = G_SMAX;
+
+  g->node_list = G_NODE_LIST;
+  g->edge_list = G_EDGE_LIST;
+
+  new_edge (&g->edge);
+  new_node (&g->node);
+}
+
+/* Initialize a node with the default values. */
+void
+new_node (node *n)
+{
+  n->title = N_TITLE;
+  n->label = N_LABEL;
+
+  n->locx = N_LOCX; /* Default unspcified. */
+  n->locy = N_LOCY; /* Default unspcified. */
+
+  n->vertical_order = N_VERTICAL_ORDER;	/* Default unspcified. */
+  n->horizontal_order = N_HORIZONTAL_ORDER;	/* Default unspcified. */
+
+  n->width = N_WIDTH; /* We assume that we can't define it now. */
+  n->height = N_HEIGHT; /* Also. */
+
+  n->shrink = N_SHRINK;
+  n->stretch = N_STRETCH;
+
+  n->folding = N_FOLDING; /* No explicit default value. */
+
+  n->shape = N_SHAPE;
+  n->textmode = N_TEXTMODE;
+  n->borderwidth = N_BORDERWIDTH;
+
+  n->color = N_COLOR;
+  n->textcolor = N_TEXTCOLOR;
+  n->bordercolor = N_BORDERCOLOR;
+
+  n->infos[0] = N_INFOS1;
+  n->infos[1] = N_INFOS2;
+  n->infos[2] = N_INFOS3;
+
+  n->next = N_NEXT;
+}
+
+/* Initialize an edge with the default values. */
+void
+new_edge (edge *e)
+{
+  e->type = E_EDGE_TYPE;
+
+  e->sourcename = E_SOURCENAME;
+  e->targetname = E_TARGETNAME;
+  e->label = E_LABEL;
+
+  e->linestyle = E_LINESTYLE;
+  e->thickness = E_THICKNESS;
+
+  e->class = E_CLASS;
+
+  e->color = E_COLOR;
+  e->textcolor = E_TEXTCOLOR;
+  e->arrowcolor = E_ARROWCOLOR;
+  e->backarrowcolor = E_BACKARROWCOLOR;
+
+  e->arrowsize = E_ARROWSIZE;
+  e->backarrowsize = E_BACKARROWSIZE;
+  e->arrowstyle = E_ARROWSTYLE;
+
+  e->backarrowstyle = E_BACKARROWSTYLE;
+
+  e->priority = E_PRIORITY;
+
+  e->anchor = E_ANCHOR;
+
+  e->horizontal_order = E_HORIZONTAL_ORDER;
+
+  e->next = E_NEXT;
+}
+
+/*----------------------------------------------.
+| Get functions.	                        |
+| Return string corresponding to an enum value. |
+`----------------------------------------------*/
+
+static const char *
+get_color_str (enum color color)
+{
+  switch (color)
+    {
+    default:		abort ();
+    case white:		return "white";
+    case blue:		return "blue";
+    case red:		return "red";
+    case green:		return "green";
+    case yellow:	return "yellow";
+    case magenta:	return "magenta";
+    case cyan:		return "cyan";
+    case darkgrey:	return "darkgrey";
+    case darkblue:	return "darkblue";
+    case darkred:	return "darkred";
+    case darkgreen:	return "darkgreen";
+    case darkyellow:	return "darkyellow";
+    case darkmagenta:	return "darkmagenta";
+    case darkcyan:	return "darkcyan";
+    case gold:		return "gold";
+    case lightgrey:	return "lightgrey";
+    case lightblue:	return "lightblue";
+    case lightred:	return "lightred";
+    case lightgreen:	return "lightgreen";
+    case lightyellow:	return "lightyellow";
+    case lightmagenta:	return "lightmagenta";
+    case lightcyan:	return "lightcyan";
+    case lilac:		return "lilac";
+    case turquoise:	return "turquoise";
+    case aquamarine:	return "aquamarine";
+    case khaki:		return "khaki";
+    case purple:	return "purple";
+    case yellowgreen:	return "yellowgreen";
+    case pink:		return "pink";
+    case orange:	return "orange";
+    case orchid:	return "orchid";
+    case black:		return "black";
+    }
+}
+
+static const char *
+get_textmode_str (enum textmode textmode)
+{
+  switch (textmode)
+    {
+    default:		abort ();
+    case centered:	return "center";
+    case left_justify:	return "left_justify";
+    case right_justify:	return "right_justify";
+    }
+}
+
+static const char *
+get_shape_str (enum shape shape)
+{
+  switch (shape)
+    {
+    default:		abort ();
+    case box:		return "box";
+    case rhomb:		return "rhomb";
+    case ellipse:	return "ellipse";
+    case triangle:	return "triangle";
+    }
+}
+
+static const char *
+get_decision_str (enum decision decision)
+{
+  switch (decision)
+    {
+    default:	abort ();
+    case no:	return "no";
+    case yes:	return "yes";
+    }
+}
+
+static const char *
+get_orientation_str (enum orientation orientation)
+{
+  switch (orientation)
+    {
+    default:		abort ();
+    case top_to_bottom:	return "top_to_bottom";
+    case bottom_to_top: return "bottom_to_top";
+    case left_to_right: return "left_to_right";
+    case right_to_left: return "right_to_left";
+    }
+}
+
+static const char *
+get_node_alignment_str (enum alignment alignment)
+{
+  switch (alignment)
+    {
+    default:		abort ();
+    case center:	return "center";
+    case top:		return "top";
+    case bottom:	return "bottom";
+    }
+}
+
+static const char *
+get_arrow_mode_str (enum arrow_mode arrow_mode)
+{
+  switch (arrow_mode)
+    {
+    default:		abort ();
+    case fixed:		return "fixed";
+    case free_a:	return "free";
+    }
+}
+
+static const char *
+get_crossing_type_str (enum crossing_type crossing_type)
+{
+  switch (crossing_type)
+    {
+    default:		abort ();
+    case bary:		return "bary";
+    case median:	return "median";
+    case barymedian:	return "barymedian";
+    case medianbary:	return "medianbary";
+    }
+}
+
+static const char *
+get_view_str (enum view view)
+{
+  /* There is no way with vcg 1.30 to specify a normal view explicitly,
+     so it is an error here if view == normal_view.  */
+  switch (view)
+    {
+    default:		abort ();
+    case cfish:		return "cfish";
+    case pfish:		return "pfish";
+    case fcfish:	return "fcfish";
+    case fpfish:	return "fpfish";
+    }
+}
+
+static const char *
+get_linestyle_str (enum linestyle linestyle)
+{
+  switch (linestyle)
+    {
+    default:		abort ();
+    case continuous:	return "continuous";
+    case dashed:	return "dashed";
+    case dotted:	return "dotted";
+    case invisible:	return "invisible";
+    }
+}
+
+static const char *
+get_arrowstyle_str (enum arrowstyle arrowstyle)
+{
+  switch (arrowstyle)
+    {
+    default:	abort ();
+    case solid:	return "solid";
+    case line:	return "line";
+    case none:	return "none";
+    }
+}
+
+/*------------------------------.
+| Add functions.	        |
+| Edge and nodes into a graph.  |
+`------------------------------*/
+
+void
+add_node (graph *g, node *n)
+{
+  n->next = g->node_list;
+  g->node_list = n;
+}
+
+void
+add_edge (graph *g, edge *e)
+{
+  e->next = g->edge_list;
+  g->edge_list = e;
+}
+
+void
+add_classname (graph *g, int val, const char *name)
+{
+  struct classname *classname = xmalloc (sizeof *classname);
+  classname->no = val;
+  classname->name = name;
+  classname->next = g->classname;
+  g->classname = classname;
+}
+
+void
+add_infoname (graph *g, int integer, const char *str)
+{
+  struct infoname *infoname = xmalloc (sizeof *infoname);
+  infoname->integer = integer;
+  infoname->chars = str;
+  infoname->next = g->infoname;
+  g->infoname = infoname;
+}
+
+/* Build a colorentry struct and add it to the list.  */
+void
+add_colorentry (graph *g, int color_idx, int red_cp,
+		int green_cp, int blue_cp)
+{
+  struct colorentry *ce = xmalloc (sizeof *ce);
+  ce->color_index = color_idx;
+  ce->red_cp = red_cp;
+  ce->green_cp = green_cp;
+  ce->blue_cp = blue_cp;
+  ce->next = g->colorentry;
+  g->colorentry = ce;
+}
+
+/*-------------------------------------.
+| Open and close functions (formatted) |
+`-------------------------------------*/
+
+void
+open_edge (edge *e, FILE *fout)
+{
+  switch (e->type)
+    {
+    case normal_edge:
+      fputs ("\tedge: {\n", fout);
+      break;
+    case back_edge:
+      fputs ("\tbackedge: {\n", fout);
+      break;
+    case near_edge:
+      fputs ("\tnearedge: {\n", fout);
+      break;
+    case bent_near_edge:
+      fputs ("\tbentnearedge: {\n", fout);
+      break;
+    default:
+      fputs ("\tedge: {\n", fout);
+    }
+}
+
+void
+close_edge (FILE *fout)
+{
+  fputs ("\t}\n", fout);
+}
+
+void
+open_node (FILE *fout)
+{
+  fputs ("\tnode: {\n", fout);
+}
+
+void
+close_node (FILE *fout)
+{
+  fputs ("\t}\n", fout);
+}
+
+void
+open_graph (FILE *fout)
+{
+  fputs ("graph: {\n", fout);
+}
+
+void
+close_graph (graph *g, FILE *fout)
+{
+  fputc ('\n', fout);
+
+  /* FIXME: Unallocate nodes and edges if required.  */
+  {
+    node *n;
+
+    for (n = g->node_list; n; n = n->next)
+      {
+	open_node (fout);
+	output_node (n, fout);
+	close_node (fout);
+      }
+  }
+
+  fputc ('\n', fout);
+
+  {
+    edge *e;
+
+    for (e = g->edge_list; e; e = e->next)
+      {
+	open_edge (e, fout);
+	output_edge (e, fout);
+	close_edge (fout);
+      }
+  }
+
+  fputs ("}\n", fout);
+}
+
+/*-------------------------------------------.
+| Output functions (formatted) in file FOUT  |
+`-------------------------------------------*/
+
+void
+output_node (node *n, FILE *fout)
+{
+  if (n->title != N_TITLE)
+    fprintf (fout, "\t\ttitle:\t%s\n", quote (n->title));
+  if (n->label != N_LABEL)
+    fprintf (fout, "\t\tlabel:\t%s\n", quote (n->label));
+
+  if ((n->locx != N_LOCX) && (n->locy != N_LOCY))
+    fprintf (fout, "\t\tloc { x: %d  y: %d }\t\n", n->locx, n->locy);
+
+  if (n->vertical_order != N_VERTICAL_ORDER)
+    fprintf (fout, "\t\tvertical_order:\t%d\n", n->vertical_order);
+  if (n->horizontal_order != N_HORIZONTAL_ORDER)
+    fprintf (fout, "\t\thorizontal_order:\t%d\n", n->horizontal_order);
+
+  if (n->width != N_WIDTH)
+    fprintf (fout, "\t\twidth:\t%d\n", n->width);
+  if (n->height != N_HEIGHT)
+    fprintf (fout, "\t\theight:\t%d\n", n->height);
+
+  if (n->shrink != N_SHRINK)
+    fprintf (fout, "\t\tshrink:\t%d\n", n->shrink);
+  if (n->stretch != N_STRETCH)
+    fprintf (fout, "\t\tstretch:\t%d\n", n->stretch);
+
+  if (n->folding != N_FOLDING)
+    fprintf (fout, "\t\tfolding:\t%d\n", n->folding);
+
+  if (n->textmode != N_TEXTMODE)
+    fprintf (fout, "\t\ttextmode:\t%s\n",
+	     get_textmode_str (n->textmode));
+
+  if (n->shape != N_SHAPE)
+    fprintf (fout, "\t\tshape:\t%s\n", get_shape_str (n->shape));
+
+  if (n->borderwidth != N_BORDERWIDTH)
+    fprintf (fout, "\t\tborderwidth:\t%d\n", n->borderwidth);
+
+  if (n->color != N_COLOR)
+    fprintf (fout, "\t\tcolor:\t%s\n", get_color_str (n->color));
+  if (n->textcolor != N_TEXTCOLOR)
+    fprintf (fout, "\t\ttextcolor:\t%s\n",
+	     get_color_str (n->textcolor));
+  if (n->bordercolor != N_BORDERCOLOR)
+    fprintf (fout, "\t\tbordercolor:\t%s\n",
+	     get_color_str (n->bordercolor));
+
+  {
+    int i;
+    for (i = 0; i < 3; ++i)
+      if (n->infos[i])
+	fprintf (fout, "\t\tinfo%d:\t%s\n",
+		 i, quote (n->infos[i]));
+  }
+}
+
+void
+output_edge (edge *e, FILE *fout)
+{
+  /* FIXME: SOURCENAME and TARGETNAME are mandatory
+     so it has to be fatal not to give these informations.  */
+  if (e->sourcename != E_SOURCENAME)
+    fprintf (fout, "\t\tsourcename:\t%s\n", quote (e->sourcename));
+  if (e->targetname != E_TARGETNAME)
+    fprintf (fout, "\t\ttargetname:\t%s\n", quote (e->targetname));
+
+  if (e->label != E_LABEL)
+    fprintf (fout, "\t\tlabel:\t%s\n", quote (e->label));
+
+  if (e->linestyle != E_LINESTYLE)
+    fprintf (fout, "\t\tlinestyle:\t%s\n", get_linestyle_str (e->linestyle));
+
+  if (e->thickness != E_THICKNESS)
+    fprintf (fout, "\t\tthickness:\t%d\n", e->thickness);
+  if (e->class != E_CLASS)
+    fprintf (fout, "\t\tclass:\t%d\n", e->class);
+
+  if (e->color != E_COLOR)
+    fprintf (fout, "\t\tcolor:\t%s\n", get_color_str (e->color));
+  if (e->color != E_TEXTCOLOR)
+    fprintf (fout, "\t\ttextcolor:\t%s\n",
+	     get_color_str (e->textcolor));
+  if (e->arrowcolor != E_ARROWCOLOR)
+    fprintf (fout, "\t\tarrowcolor:\t%s\n",
+	     get_color_str (e->arrowcolor));
+  if (e->backarrowcolor != E_BACKARROWCOLOR)
+    fprintf (fout, "\t\tbackarrowcolor:\t%s\n",
+	     get_color_str (e->backarrowcolor));
+
+  if (e->arrowsize != E_ARROWSIZE)
+    fprintf (fout, "\t\tarrowsize:\t%d\n", e->arrowsize);
+  if (e->backarrowsize != E_BACKARROWSIZE)
+    fprintf (fout, "\t\tbackarrowsize:\t%d\n", e->backarrowsize);
+
+  if (e->arrowstyle != E_ARROWSTYLE)
+    fprintf (fout, "\t\tarrowstyle:\t%s\n",
+	     get_arrowstyle_str (e->arrowstyle));
+  if (e->backarrowstyle != E_BACKARROWSTYLE)
+    fprintf (fout, "\t\tbackarrowstyle:\t%s\n",
+	     get_arrowstyle_str (e->backarrowstyle));
+
+  if (e->priority != E_PRIORITY)
+    fprintf (fout, "\t\tpriority:\t%d\n", e->priority);
+  if (e->anchor != E_ANCHOR)
+    fprintf (fout, "\t\tanchor:\t%d\n", e->anchor);
+  if (e->horizontal_order != E_HORIZONTAL_ORDER)
+    fprintf (fout, "\t\thorizontal_order:\t%d\n", e->horizontal_order);
+}
+
+void
+output_graph (graph *g, FILE *fout)
+{
+  if (g->title)
+    fprintf (fout, "\ttitle:\t%s\n", quote (g->title));
+  if (g->label)
+    fprintf (fout, "\tlabel:\t%s\n", quote (g->label));
+
+  {
+    int i;
+    for (i = 0; i < 3; ++i)
+      if (g->infos[i])
+	fprintf (fout, "\tinfo%d:\t%s\n", i, quote (g->infos[i]));
+  }
+
+  if (g->color != G_COLOR)
+    fprintf (fout, "\tcolor:\t%s\n", get_color_str (g->color));
+  if (g->textcolor != G_TEXTCOLOR)
+    fprintf (fout, "\ttextcolor:\t%s\n", get_color_str (g->textcolor));
+  if (g->bordercolor != G_BORDERCOLOR)
+    fprintf (fout, "\tbordercolor:\t%s\n",
+	     get_color_str (g->bordercolor));
+
+  if (g->width != G_WIDTH)
+    fprintf (fout, "\twidth:\t%d\n", g->width);
+  if (g->height != G_HEIGHT)
+    fprintf (fout, "\theight:\t%d\n", g->height);
+  if (g->borderwidth != G_BORDERWIDTH)
+    fprintf (fout, "\tborderwidth:\t%d\n", g->borderwidth);
+
+  if (g->x != G_X)
+    fprintf (fout, "\tx:\t%d\n", g->x);
+  if (g->y != G_Y)
+    fprintf (fout, "\ty:\t%d\n", g->y);
+
+  if (g->folding != G_FOLDING)
+    fprintf (fout, "\tfolding:\t%d\n", g->folding);
+
+  if (g->shrink != G_SHRINK)
+    fprintf (fout, "\tshrink:\t%d\n", g->shrink);
+  if (g->stretch != G_STRETCH)
+    fprintf (fout, "\tstretch:\t%d\n", g->stretch);
+
+  if (g->textmode != G_TEXTMODE)
+    fprintf (fout, "\ttextmode:\t%s\n",
+	     get_textmode_str (g->textmode));
+
+  if (g->shape != G_SHAPE)
+    fprintf (fout, "\tshape:\t%s\n", get_shape_str (g->shape));
+
+  if (g->vertical_order != G_VERTICAL_ORDER)
+    fprintf (fout, "\tvertical_order:\t%d\n", g->vertical_order);
+  if (g->horizontal_order != G_HORIZONTAL_ORDER)
+    fprintf (fout, "\thorizontal_order:\t%d\n", g->horizontal_order);
+
+  if (g->xmax != G_XMAX)
+    fprintf (fout, "\txmax:\t%d\n", g->xmax);
+  if (g->ymax != G_YMAX)
+    fprintf (fout, "\tymax:\t%d\n", g->ymax);
+
+  if (g->xbase != G_XBASE)
+    fprintf (fout, "\txbase:\t%d\n", g->xbase);
+  if (g->ybase != G_YBASE)
+    fprintf (fout, "\tybase:\t%d\n", g->ybase);
+
+  if (g->xspace != G_XSPACE)
+    fprintf (fout, "\txspace:\t%d\n", g->xspace);
+  if (g->yspace != G_YSPACE)
+    fprintf (fout, "\tyspace:\t%d\n", g->yspace);
+  if (g->xlspace != G_XLSPACE)
+    fprintf (fout, "\txlspace:\t%d\n", g->xlspace);
+
+  if (g->xraster != G_XRASTER)
+    fprintf (fout, "\txraster:\t%d\n", g->xraster);
+  if (g->yraster != G_YRASTER)
+    fprintf (fout, "\tyraster:\t%d\n", g->yraster);
+  if (g->xlraster != G_XLRASTER)
+    fprintf (fout, "\txlraster:\t%d\n", g->xlraster);
+
+  if (g->hidden != G_HIDDEN)
+    fprintf (fout, "\thidden:\t%d\n", g->hidden);
+
+  /* FIXME: Unallocate struct list if required.
+     Maybe with a little function.  */
+  if (g->classname != G_CLASSNAME)
+    {
+      struct classname *ite;
+
+      for (ite = g->classname; ite; ite = ite->next)
+	fprintf (fout, "\tclassname %d :\t%s\n", ite->no, ite->name);
+    }
+
+  if (g->infoname != G_INFONAME)
+    {
+      struct infoname *ite;
+
+      for (ite = g->infoname; ite; ite = ite->next)
+	fprintf (fout, "\tinfoname %d :\t%s\n", ite->integer, ite->chars);
+    }
+
+  if (g->colorentry != G_COLORENTRY)
+    {
+      struct colorentry *ite;
+
+      for (ite = g->colorentry; ite; ite = ite->next)
+	{
+	  fprintf (fout, "\tcolorentry %d :\t%d %d %d\n",
+		   ite->color_index,
+		   ite->red_cp,
+		   ite->green_cp,
+		   ite->blue_cp);
+	}
+    }
+
+  if (g->layout_downfactor != G_LAYOUT_DOWNFACTOR)
+    fprintf (fout, "\tlayout_downfactor:\t%d\n", g->layout_downfactor);
+  if (g->layout_upfactor != G_LAYOUT_UPFACTOR)
+    fprintf (fout, "\tlayout_upfactor:\t%d\n", g->layout_upfactor);
+  if (g->layout_nearfactor != G_LAYOUT_NEARFACTOR)
+    fprintf (fout, "\tlayout_nearfactor:\t%d\n", g->layout_nearfactor);
+  if (g->layout_splinefactor != G_LAYOUT_SPLINEFACTOR)
+    fprintf (fout, "\tlayout_splinefactor:\t%d\n",
+	     g->layout_splinefactor);
+
+  if (g->late_edge_labels != G_LATE_EDGE_LABELS)
+    fprintf (fout, "\tlate_edge_labels:\t%s\n",
+	     get_decision_str (g->late_edge_labels));
+  if (g->display_edge_labels != G_DISPLAY_EDGE_LABELS)
+    fprintf (fout, "\tdisplay_edge_labels:\t%s\n",
+	     get_decision_str (g->display_edge_labels));
+  if (g->dirty_edge_labels != G_DIRTY_EDGE_LABELS)
+    fprintf (fout, "\tdirty_edge_labels:\t%s\n",
+	     get_decision_str (g->dirty_edge_labels));
+  if (g->finetuning != G_FINETUNING)
+    fprintf (fout, "\tfinetuning:\t%s\n",
+	     get_decision_str (g->finetuning));
+  if (g->ignore_singles != G_IGNORE_SINGLES)
+    fprintf (fout, "\tignore_singles:\t%s\n",
+	     get_decision_str (g->ignore_singles));
+  if (g->priority_phase != G_PRIORITY_PHASE)
+    fprintf (fout, "\tpriority_phase:\t%s\n",
+	     get_decision_str (g->priority_phase));
+  if (g->manhattan_edges != G_MANHATTAN_EDGES)
+    fprintf (fout,
+	     "\tmanhattan_edges:\t%s\n",
+	     get_decision_str (g->manhattan_edges));
+  if (g->smanhattan_edges != G_SMANHATTAN_EDGES)
+    fprintf (fout,
+	     "\tsmanhattan_edges:\t%s\n",
+	     get_decision_str (g->smanhattan_edges));
+  if (g->near_edges != G_NEAR_EDGES)
+    fprintf (fout, "\tnear_edges:\t%s\n",
+	     get_decision_str (g->near_edges));
+
+  if (g->orientation != G_ORIENTATION)
+    fprintf (fout, "\torientation:\t%s\n",
+	     get_orientation_str (g->orientation));
+
+  if (g->node_alignment != G_NODE_ALIGNMENT)
+    fprintf (fout, "\tnode_alignment:\t%s\n",
+	     get_node_alignment_str (g->node_alignment));
+
+  if (g->port_sharing != G_PORT_SHARING)
+    fprintf (fout, "\tport_sharing:\t%s\n",
+	     get_decision_str (g->port_sharing));
+
+  if (g->arrow_mode != G_ARROW_MODE)
+    fprintf (fout, "\tarrow_mode:\t%s\n",
+	     get_arrow_mode_str (g->arrow_mode));
+
+  if (g->treefactor != G_TREEFACTOR)
+    fprintf (fout, "\ttreefactor:\t%f\n", g->treefactor);
+  if (g->spreadlevel != G_SPREADLEVEL)
+    fprintf (fout, "\tspreadlevel:\t%d\n", g->spreadlevel);
+
+  if (g->crossing_weight != G_CROSSING_WEIGHT)
+    fprintf (fout, "\tcrossing_weight:\t%s\n",
+	     get_crossing_type_str (g->crossing_weight));
+  if (g->crossing_phase2 != G_CROSSING_PHASE2)
+    fprintf (fout, "\tcrossing_phase2:\t%s\n",
+	     get_decision_str (g->crossing_phase2));
+  if (g->crossing_optimization != G_CROSSING_OPTIMIZATION)
+    fprintf (fout, "\tcrossing_optimization:\t%s\n",
+	     get_decision_str (g->crossing_optimization));
+
+  if (g->view != normal_view)
+    fprintf (fout, "\tview:\t%s\n", get_view_str (g->view));
+
+  if (g->edges != G_EDGES)
+    fprintf (fout, "\tedges:\t%s\n", get_decision_str (g->edges));
+
+  if (g->nodes != G_NODES)
+    fprintf (fout,"\tnodes:\t%s\n", get_decision_str (g->nodes));
+
+  if (g->splines != G_SPLINES)
+    fprintf (fout, "\tsplines:\t%s\n", get_decision_str (g->splines));
+
+  if (g->bmax != G_BMAX)
+    fprintf (fout, "\tbmax:\t%d\n", g->bmax);
+  if (g->cmin != G_CMIN)
+    fprintf (fout, "\tcmin:\t%d\n", g->cmin);
+  if (g->cmax != G_CMAX)
+    fprintf (fout, "\tcmax:\t%d\n", g->cmax);
+  if (g->pmin != G_PMIN)
+    fprintf (fout, "\tpmin:\t%d\n", g->pmin);
+  if (g->pmax != G_PMAX)
+    fprintf (fout, "\tpmax:\t%d\n", g->pmax);
+  if (g->rmin != G_RMIN)
+    fprintf (fout, "\trmin:\t%d\n", g->rmin);
+  if (g->rmax != G_RMAX)
+    fprintf (fout, "\trmax:\t%d\n", g->rmax);
+  if (g->smax != G_SMAX)
+    fprintf (fout, "\tsmax:\t%d\n", g->smax);
+}
diff --git a/src/vcg.h b/src/vcg.h
new file mode 100644
index 0000000..ed35603
--- /dev/null
+++ b/src/vcg.h
@@ -0,0 +1,963 @@
+/* VCG description handler for Bison.
+
+   Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#ifndef VCG_H_
+# define VCG_H_
+
+/* VCG color map. The 32 prime predefined colors. */
+enum color
+{
+  white		= 0,
+  blue,
+  red,
+  green		= 3,
+  yellow,
+  magenta,
+  cyan		= 6,
+  darkgrey,
+  darkblue,
+  darkred	= 9,
+  darkgreen,
+  darkyellow,
+  darkmagenta	= 12,
+  darkcyan,
+  gold,
+  lightgrey	= 15,
+  lightblue,
+  lightred,
+  lightgreen	= 18,
+  lightyellow,
+  lightmagenta,
+  lightcyan	= 21,
+  lilac,
+  turquoise,
+  aquamarine	= 24,
+  khaki,
+  purple,
+  yellowgreen	= 27,
+  pink,
+  orange,
+  orchid,
+  black		= 31
+};
+
+/* VCG textmode. Specify the adjustement of the text within the border of a summary node. */
+enum textmode
+{
+  centered,
+  left_justify,
+  right_justify
+};
+
+/* VCG shapes. Used for nodes shapes. */
+enum shape
+{
+  box,
+  rhomb,
+  ellipse,
+  triangle
+};
+
+/* Structure for colorentries.  */
+struct colorentry
+{
+  int color_index;
+  int red_cp;
+  int green_cp;
+  int blue_cp;
+  struct colorentry *next;
+};
+
+/* Structure to construct lists of classnames. */
+struct classname
+{
+  int no; /* Class number */
+  const char *name; /* Name associated to the class no. */
+  struct classname *next; /* next name class association. */
+};
+
+/* Structure is in infoname.  */
+struct infoname
+{
+  int integer;
+  char const *chars;
+  struct infoname *next;
+};
+
+/* VCG decision yes/no. */
+enum decision
+{
+  yes,
+  no
+};
+
+/* VCG graph orientation. */
+enum orientation
+{
+  top_to_bottom,
+  bottom_to_top,
+  left_to_right,
+  right_to_left
+};
+
+/* VCG alignment for node alignement. */
+enum alignment
+{
+  center,
+  top,
+  bottom
+};
+
+/* VCG arrow mode. */
+enum arrow_mode
+{
+  fixed,
+  free_a
+};
+
+/* VCG crossing weight type. */
+enum crossing_type
+{
+  bary,
+  median,
+  barymedian,
+  medianbary
+};
+
+/* VCG views. */
+enum view
+{
+  normal_view,
+  cfish,
+  pfish,
+  fcfish,
+  fpfish
+};
+
+/*------------------------------------------------------.
+| Node attributs list. structure that describes a node. |
+`------------------------------------------------------*/
+
+struct node
+{
+  /* Title the unique string identifying the node. This attribute is
+     mandatory. */
+  const char *title;
+
+  /* Label the text displayed inside the node. If no label is specified
+     then the title of the node will be used. Note that this text may
+     contain control characters like NEWLINE that influences the size of
+     the node. */
+  const char *label;
+
+  /* loc is the location as x, y position relatively to the system of
+     coordinates of the graph. Locations are specified in the form
+     loc: - x: xpos y: ypos "". The locations of nodes are only valid,
+     if the whole graph is fully specified with locations and no part is
+     folded. The layout algorithm of the tool calculates appropriate x, y
+     positions, if at least one node that must be drawn (i.e., is not
+     hidden by folding or edge classes) does not have fixed specified
+     locations.
+     Default is none. */
+  int locx;
+  int locy;
+
+  /* vertical order is the level position (rank) of the node. We can also
+     specify level: int. Level specifications are only valid, if the
+     layout is calculated, i.e. if at least one node does not have a
+     fixed location specification. The layout algorithm partitioned all
+     nodes into levels 0...maxlevel. Nodes at the level 0 are on the
+     upper corner. The algorithm is able to calculate appropriate levels
+     for the nodes automatically, if no fixed levels are given.
+     Specifications of levels are additional constraints, that may be
+     ignored, if they are in conflict with near edge specifications.
+     Default values are unspecified. */
+  int vertical_order;
+
+  /* horizontal order is the horizontal position of the node within a
+     level. The nodes which are specified with horizontal positions are
+     ordered according to these positions within the levels. The nodes
+     which do not have this attribute are inserted into this ordering by
+     the crossing reduction mechanism. Note that connected components are
+     handled separately, thus it is not possible to intermix such
+     components by specifying a horizontal order. If the algorithm for
+     downward laid out trees is used, the horizontal order influences
+     only the order of the child nodes at a node, but not the order of
+     the whole level.
+     Default is unspecified. */
+  int horizontal_order;
+
+  /* width, height is the width and height of a node including the border.
+     If no value (in pixels) is given then width and height are
+     calculated from the size of the label.
+     Default are width and height of the label. */
+  int width;
+  int height;
+
+  /* shrink, stretch gives the shrinking and stretching factor of the
+     node. The values of the attributes width, height, borderwidth and
+     the size of the label text is scaled by ((stretch=shrink) \Lambda
+     100) percent. Note that the actual scale value is determined by the
+     scale value of a node relatively to a scale value of the graph,
+     i.e. if (stretch,shrink) = (2,1) for the graph and (stretch,shrink)
+     = (2,1) for the node of the graph, then the node is scaled by the
+     factor 4 compared to the normal size. The scale value can also be
+     specified by scaling: float.
+     Default are 1,1. */
+  int shrink;
+  int stretch;
+
+  /* folding specifies the default folding of the nodes. The folding k
+     (with k ? 0) means that the graph part that is reachable via edges
+     of a class less or equal to k is folded and displayed as one node.
+     There are commands to unfold such summary nodes, see section 5. If
+     no folding is specified for a node, then the node may be folded if
+     it is in the region of another node that starts the folding. If
+     folding 0 is specified, then the node is never folded. In this case
+     the folding stops at the predecessors of this node, if it is
+     reachable from another folding node. The summary node inherits some
+     attributes from the original node which starts the folding (all
+     color attributes, textmode and label, but not the location). A
+     folded region may contain folded regions with smaller folding class
+     values (nested foldings). If there is more than one node that start
+     the folding of the same region (this implies that the folding class
+     values are equal) then the attributes are inherited by one of these
+     nodes nondeterministically. If foldnode attributes are specified,
+     then the summary node attributes are inherited from these attributes.
+     Default is none. */
+  int folding;
+
+  /* shape specifies the visual appearance of a node: box, rhomb, ellipse,
+     and triangle. The drawing of ellipses is much slower than the drawing
+     of the other shapes.
+     Default is box. */
+  enum shape shape;
+
+  /* textmode specifies the adjustment of the text within the border of a
+     node. The possibilities are center, left.justify and right.justify.
+     Default is center. */
+  enum textmode textmode;
+
+  /* borderwidth specifies the thickness of the node's border in pixels.
+     color is the background color of the node. If none is given, the
+     node is white. For the possibilities, see the attribute color for
+     graphs.
+     Default is 2. */
+  int borderwidth;
+
+  /* node color.
+     Default is white or transparent, */
+  enum color color;
+
+  /* textcolor is the color for the label text. bordercolor is the color
+     of the border. Default color is the textcolor. info1, info2, info3
+     combines additional text labels with a node or a folded graph. info1,
+     Default is black. */
+  enum color textcolor;
+
+  /* info2, info3 can be selected from the menu. The corresponding text
+     labels can be shown by mouse clicks on nodes.
+     Default are null strings. */
+  const char *infos[3];
+
+  /* Node border color.
+     Default is textcolor. */
+  enum color bordercolor;
+
+  /* Next node node... */
+  struct node *next;
+};
+
+/* typedef alias. */
+typedef struct node node;
+
+/*-------------------------------------------------------.
+| Edge attributs list. Structure that describes an edge. |
+`-------------------------------------------------------*/
+
+/* VCG Edge type. */
+enum edge_type
+{
+  normal_edge,
+  back_edge,
+  near_edge,
+  bent_near_edge
+};
+
+/* Structs enum definitions for edges. */
+enum linestyle
+{
+  continuous,
+  dashed,
+  dotted,
+  invisible
+};
+
+enum arrowstyle
+{
+  solid,
+  line,
+  none
+};
+
+/* The struct edge itself. */
+struct edge
+{
+
+  /* Edge type.
+     Default is normal edge. */
+  enum edge_type type;
+
+  /* Sourcename is the title of the source node of the edge.
+     Default: none. */
+  const char *sourcename; /* Mandatory. */
+
+  /* Targetname is the title of the target node of the edge.
+     Default: none. */
+  const char *targetname; /* Mandatory. */
+
+  /* Label specifies the label of the edge. It is drawn if
+     display.edge.labels is set to yes.
+     Default: no label. */
+  const char *label;
+
+  /* Linestyle specifies the style the edge is drawn. Possibilities are:
+     ffl continuous a solid line is drawn ( -- ) ffl dashed the edge
+     consists of single dashes ( - - - ) ffl dotted the edge is made of
+     single dots ( \Delta  \Delta  \Delta  ) ffl invisible the edge is not
+     drawn. The attributes of its shape (color, thickness) are ignored.
+     To draw a dashed or dotted line needs more time than solid lines.
+     Default is continuous. */
+  enum linestyle linestyle;
+
+  /* Thickness is the thickness of an edge.
+     Default is 2. */
+  int thickness;
+
+  /* Class specifies the folding class of the edge. Nodes reachable by
+     edges of a class less or equal to a constant k specify folding
+     regions of k. See the node attribute folding and the folding commands.
+     Default is 1. */
+  int class;
+
+  /* color is the color of the edge.
+     Default is black. */
+  enum color color;
+
+  /* textcolor is the color of the label of the edge. arrowcolor,
+     backarrowcolor is the color of the arrow head and of the backarrow
+     head. priority The positions of the nodes are mainly determined by
+     the incoming and outgoing edges. One can think of rubberbands instead
+     of edges that pull a node into its position. The priority of an edges
+     corresponds to the strength of the rubberband.
+     Default is color. */
+  enum color textcolor;
+
+  /* Arrow color.
+     Default is color. */
+  enum color arrowcolor;
+
+  /* BackArrow color.
+     Default is color. */
+  enum color backarrowcolor;
+
+  /* arrowsize, backarrowsize The arrow head is a right-angled, isosceles
+     triangle and the cathetuses have length arrowsize.
+     Default is 10. */
+  int arrowsize;
+
+  /* Backarrow size
+     Default is 0. */
+  int backarrowsize;
+
+  /* arrowstyle, backarrowstyle Each edge has two arrow heads: the one
+     appears at the target node (the normal arrow head), the other appears
+     at the source node (the backarrow head). Normal edges only have the
+     normal solid arrow head, while the backarrow head is not drawn, i.e.
+     it is none. Arrowstyle is the style of the normal arrow head, and
+     backarrowstyle is the style of the backarrow head. Styles are none,
+     i.e. no arrow head, solid, and line.
+     Default is solid. */
+  enum arrowstyle arrowstyle;
+
+  /* Default is none. */
+  enum arrowstyle backarrowstyle;
+
+  /* Default is 1. */
+  int priority;
+
+  /* Anchor. An anchor point describes the vertical position in a node
+     where an edge goes out. This is useful, if node labels are several
+     lines long, and outgoing edges are related to label lines. (E.g.,
+     this allows a nice visualization of structs containing pointers as
+     fields.).
+     Default is none. */
+  int anchor;
+
+  /* Horizontal order is the horizontal position the edge. This is of
+     interest only if the edge crosses several levels because it specifies
+     the point where the edge crosses the level. within a level. The nodes
+     which are specified with horizontal positions are ordered according
+     to these positions within a level. The horizontal position of a long
+     edge that crosses the level specifies between which two node of that
+     level the edge has to be drawn. Other edges which do not have this
+     attribute are inserted into this ordering by the crossing reduction
+     mechanism. Note that connected components are handled separately,
+     thus it is not possible to intermix such components by specifying a
+     horizontal order.
+     Default is unspcified. */
+  int horizontal_order;
+
+  /*
+  ** Next edge node...
+  */
+  struct edge *next;
+
+};
+
+/*
+** typedef alias.
+*/
+typedef struct edge edge;
+
+/*--------------------------------------------------------.
+| Graph attributs list. Structure that describes a graph. |
+`--------------------------------------------------------*/
+
+struct graph
+{
+  /* Graph title or name.
+     Title specifies the name (a string) associated with the graph. The
+     default name of a subgraph is the name of the outer graph, and the
+     name of the outmost graph is the name of the specification input
+     file. The name of a graph is used to identify this graph, e.g., if
+     we want to express that an edge points to a subgraph. Such edges
+     point to the root of the graph, i.e. the first node of the graph or
+     the root of the first subgraph in the graph, if the subgraph is
+     visualized explicitly.
+     By default, it's the name of the vcg graph file description. */
+  const char *title;
+
+  /* Graph label.
+     Label the text displayed inside the node, when the graph is folded
+     to a node. If no label is specified then the title of the graph will
+     be used. Note that this text may contain control characters like
+     NEWLINE that influences the size of the node.
+     By default, it takes the title value */
+  const char *label;
+
+  /* Any informations.
+     Info1, info2, info3 combines additional text labels with a node or a
+     folded graph. info1, info2, info3 can be selected from the menu
+     interactively. The corresponding text labels can be shown by mouse
+     clicks on nodes.
+     Default values are empty strings (here NULL pointers) */
+  const char *infos[3];
+
+  /* Background color and summary node colors
+     Color specifies the background color for the outermost graph, or the
+     color of the summary node for subgraphs. Colors are given in the enum
+     declared above. If more than these default colors are needed, a
+     color map with maximal 256 entries can be used. The first 32 entries
+     correspond to the colors just listed. A color of the color map can
+     selected by the color map index, an integer, for instance red has
+     index 2, green has index 3, etc.
+     Default is white for background and white or transparent for summary
+     nodes. */
+  enum color color;
+
+  /* Textcolor.
+     need explanations ???
+     default is black for summary nodes. */
+  enum color textcolor;
+
+  /* Bordercolor is the color of the summary node's border. Default color
+     is the textcolor. width, height are width and height of the
+     displayed part of the window of the outermost graph in pixels, or
+     width and height of the summary node of inner subgraphs.
+     Default is the default of the textcolor. */
+  enum color bordercolor;
+
+  /* Width, height are width and height of the displayed part of the
+     window of the outermost graph in pixels, or width and height of the
+     summary node of inner subgraphs.
+     Default value is 100. */
+  int width;
+  int height;
+
+  /* Specify the thickness if summary node's border in pixels.
+     default value is 2. */
+  int borderwidth;
+
+  /* x, y are the x-position and y-position of the graph's window in
+     pixels, relatively to the root screen, if it is the outermost graph.
+     The origin of the window is upper, left hand. For inner subgraphs,
+     it is the position of the folded summary node. The position can also
+     be specified in the form loc: fx:int y:intg.
+     The default value is 0. */
+  int x;
+  int y;
+
+  /* folding of a subgraph is 1, if the subgraph is fused, and 0, if the
+     subgraph is visualized explicitly. There are commands to unfold such
+     summary nodes.
+     Default value is 0 */
+  int folding;
+
+  /* Shrink, stretch gives the shrinking and stretching factor for the
+     graph's representation (default is 1, 1). ((stretch=shrink) \Lambda
+     100) is the scaling of the graph in percentage, e.g.,
+     (stretch,shrink) = (1,1) or (2,2) or (3,3) : : : is normal size,
+     (stretch,shrink) = (1,2) is half size, (stretch,shrink) = (2,1) is
+     double size. For subgraphs, it is also the scaling factor of the
+     summary node. The scaling factor can also be specified by scaling:
+     float (here, scaling 1.0 means normal size). */
+  int shrink;
+  int stretch;
+
+  /* textmode specifies the adjustment of the text within the border of a
+     summary node. The possibilities are center, left.justify and
+     right.justify.
+     Default value is center.*/
+  enum textmode textmode;
+
+  /* Shape can be specified for subgraphs only. It is the shape of the
+     subgraph summary node that appears if the subgraph is folded: box,
+     rhomb, ellipse, and triangle. vertical order is the level position
+     (rank) of the summary node of an inner subgraph, if this subgraph is
+     folded. We can also specify level: int. The level is only
+     recognized, if an automatical layout is calculated. horizontal order
+     is the horizontal position of the summary node within a level. The
+     nodes which are specified with horizontal positions are ordered
+     according to these positions within the levels. The nodes which do
+     not have this attribute are inserted into this ordering by the
+     crossing reduction mechanism. Note that connected
+     components are handled separately, thus it is not possible to
+     intermix such components by specifying a horizontal order. If the
+     algorithm for downward laid out trees is used, the horizontal order
+     influences only the order of the child nodes at a node, but not the
+     order of the whole level.
+     Default is box, other: rhomb, ellipse, triangle. */
+  enum shape shape;
+
+  /* Vertical order is the level position (rank) of the summary node of an
+     inner subgraph, if this subgraph is folded. We can also specify
+     level: int. The level is only recognized, if an automatical layout is
+     calculated.  */
+  int vertical_order;
+
+  /* Horizontal order is the horizontal position of the summary node within
+     a level. The nodes which are specified with horizontal positions are
+     ordered according to these positions within the levels. The nodes which
+     do not have this attribute are inserted into this ordering by the
+     crossing reduction mechanism. Note that connected components are
+     handled separately, thus it is not possible to intermix such components
+     by specifying a horizontal order. If the algorithm for downward laid
+     out trees is used, the horizontal order influences only the order of
+     the child nodes at a node, but not the order of the whole level.  */
+  int horizontal_order;
+
+  /* xmax, ymax specify the maximal size of the virtual window that is
+     used to display the graph. This is usually larger than the displayed
+     part, thus the width and height of the displayed part cannot be
+     greater than xmax and ymax. Only those parts of the graph are drawn
+     that are inside the virtual window. The virtual window can be moved
+     over the potential infinite system of coordinates by special
+     positioning commands.
+     Defaults are 90 and 90. */
+  int xmax;
+  int ymax;
+
+  /* xy-base: specify the upper left corner coordinates of the graph
+     relatively to the root window.
+     Defaults are 5, 5. */
+  int xbase;
+  int ybase;
+
+  /* xspace, yspace the minimum horizontal and vertical distance between
+     nodes. xlspace is the horizontal distance between lines at the
+     points where they cross the levels. (At these points, dummy nodes
+     are used. In fact, this is the horizontal distance between dummy
+     nodes.) It is recommended to set xlspace to a larger value, if
+     splines are used to draw edges, to prevent sharp bendings.
+     Default are 20 and 70. */
+  int xspace;
+  int yspace;
+
+  /* The horizontal space between lines at the point where they cross
+     the levels.
+     defaults value is 1/2 xspace (polygone) and 4/5 xspace (splines)*/
+  int xlspace;
+
+  /* xraster, yraster specifies the raster distance for the position of
+     the nodes. The center of a node is aligned to this raster. xlraster
+     is the horizontal raster for the positions of the line control
+     points (the dummy nodes). It should be a divisor of xraster.
+     defaults are 1,1. */
+  int xraster;
+  int yraster;
+
+  /* xlraster is the horizontal raster for the positions of the line
+     control points (the dummy nodes). It should be a divisor of xraster.
+     defaults is 1. */
+  int xlraster;
+
+  /* hidden specifies the classes of edges that are hidden.
+     Edges that are within such a class are not laid out nor drawn.
+     Nodes that are only reachable (forward or backward) by edges of an
+     hidden class are not drawn. However, nodes that are not reachable
+     at all are drawn. (But see attribute ignore.singles.) Specification
+     of classes of hidden edges allows to hide parts of a graph, e.g.,
+     annotations of a syntax tree. This attribute is only allowed at the
+     outermost level. More than one settings are possible to specify
+     exactly the set of classes that are hidden. Note the important
+     difference between hiding of edges and the edge line style invisible.
+     Hidden edges are not existent in the layout. Edges with line style
+     invisible are existent in the layout; they need space and may
+     produce crossings and influence the layout, but you cannot see
+     them.
+     No default value. */
+  int hidden;
+
+  /* Classname allows to introduce names for the edge classes. The names
+     are used in the menus. infoname allows to introduce names for the
+     additional text labels. The names are used in the menus.
+     defaults are 1,2,3...
+     By default, no class names. */
+  struct classname *classname;
+
+  /* Infoname allows to introduce names for the additional text labels.
+     The names are used in the menus.
+     Infoname is given by an integer and a string.
+     The default value is NULL.  */
+  struct infoname *infoname;
+
+  /* Colorentry allows to fill the color map. A color is a triplet of integer
+     values for the red/green/blue-part. Each integer is between 0 (off) and
+     255 (on), e.g., 0 0 0 is black and 255 255 255 is white. For instance
+     colorentry 75 : 70 130 180 sets the map entry 75 to steel blue. This
+     color can be used by specifying just the number 75.
+     Default id NULL.  */
+  struct colorentry *colorentry;
+
+  /* Layout downfactor, layout upfactor, layout nearfactor The layout
+     algorithm partitions the set of edges into edges pointing upward,
+     edges pointing downward, and edges pointing sidewards. The last type
+     of edges is also called near edges. If the layout.downfactor is
+     large compared to the layout.upfactor and the layout.nearfactor,
+     then the positions of the nodes is mainly determined by the edges
+     pointing downwards. If the layout.upfactor is large compared to the
+     layout.downfactor and the layout.nearfactor, then the positions of
+     the nodes is mainly determined by the edges pointing upwards. If the
+     layout.nearfactor is large, then the positions of the nodes is
+     mainly determined by the edges pointing sidewards. These attributes
+     have no effect, if the method for downward laid out trees is used.
+     Default is normal. */
+  int layout_downfactor;
+  int layout_upfactor;
+  int layout_nearfactor;
+  /* Layout splinefactor determines the bending at splines. The factor
+     100 indicates a very sharp bending, a factor 1 indicates a very flat
+     bending. Useful values are 30 : : : 80. */
+  int layout_splinefactor;
+
+  /* Late edge labels yes means that the graph is first partitioned and
+     then, labels are introduced. The default algorithm first creates
+     labels and then partitions the graph, which yield a more compact
+     layout, but may have more crossings.
+     Default is no. */
+  enum decision late_edge_labels;
+
+  /* Display edge labels yes means display labels and no means don't
+     display edge labels.
+     Default vaule is no. */
+  enum decision display_edge_labels;
+
+  /* Dirty edge labels yes enforces a fast layout of edge labels, which
+     may very ugly because several labels may be drawn at the same place.
+     Dirty edge labels cannot be used if splines are used.
+     Default is no.
+  */
+  enum decision dirty_edge_labels;
+
+  /* Finetuning no switches the fine tuning phase of the graph layout
+     algorithm off, while it is on as default. The fine tuning phase
+     tries to give all edges the same length.
+     Default is yes. */
+  enum decision finetuning;
+
+  /* Ignore singles yes hides all nodes which would appear single and
+     unconnected from the remaining graph. Such nodes have no edge at all
+     and are sometimes very ugly. Default is to show all nodes.
+     Default is no. */
+  enum decision ignore_singles;
+
+  /* priority phase yes replaces the normal pendulum method by a
+     specialized method: It forces straight long edges with 90 degree,
+     just as the straight phase. In fact, the straight phase is a fine
+     tune phase of the priority method. This phase is also recommended,
+     if an orthogonal layout is selected (see manhattan.edges).
+     Default is no. */
+  enum decision priority_phase;
+
+  /* manhattan edges yes switches the orthogonal layout on. Orthogonal
+     layout (or manhattan layout) means that all edges consist of line
+     segments with gradient 0 or 90 degree. Vertical edge segments might
+     by shared by several edges, while horizontal edge segments are never
+     shared. This results in very aesthetical layouts just for flowcharts.
+     If the orthogonal layout is used, then the priority phase and
+     straight phase should be used. Thus, these both phases are switched
+     on, too, unless priority layout and straight line tuning are
+     switched off explicitly.
+     Default is no. */
+  enum decision manhattan_edges;
+
+  /* Smanhattan edges yes switches a specialized orthogonal layout on:
+     Here, all horizontal edge segments between two levels share the same
+     horizontal line, i.e. not only vertical edge segments are shared,
+     but horizontal edge segments are shared by several edges, too. This
+     looks nice for trees but might be too confusing in general, because
+     the location of an edge might be ambiguously.
+     Default is no. */
+  enum decision smanhattan_edges;
+
+  /* Near edges no suppresses near edges and bent near edges in the
+     graph layout.
+     Default is yes. */
+  enum decision near_edges;
+
+  /* Orientation specifies the orientation of the graph: top.to.bottom,
+     bottom.to.top, left.to.right or right.to.left. Note: the normal
+     orientation is top.to.bottom. All explanations here are given
+     relatively to the normal orientation, i.e., e.g., if the orientation
+     is left to right, the attribute xlspace is not the horizontal but
+     the vertical distance between lines, etc.
+     Default is to_to_bottom. */
+  enum orientation orientation;
+
+  /* Node alignment specified the vertical alignment of nodes at the
+     horizontal reference line of the levels. If top is specified, the
+     tops of all nodes of a level have the same y-coordinate; on bottom,
+     the bottoms have the same y-coordinate, on center the nodes are
+     centered at the levels.
+     Default is center. */
+  enum alignment node_alignment;
+
+  /* Port sharing no suppresses the sharing of ports of edges at the
+     nodes. Normally, if multiple edges are adjacent to the same node,
+     and the arrow head of all these edges has the same visual appearance
+     (color, size, etc.), then these edges may share a port at a node,
+     i.e. only one arrow head is draw, and all edges are incoming into
+     this arrow head. This allows to have many edges adjacent to one node
+     without getting confused by too many arrow heads. If no port sharing
+     is used, each edge has its own port, i.e. its own place where it is
+     adjacent to the node.
+     Default is yes. */
+  enum decision port_sharing;
+
+  /* Arrow mode fixed (default) should be used, if port sharing is used,
+     because then, only a fixed set of rotations for the arrow heads are
+     used. If the arrow mode is free, then each arrow head is rotated
+     individually to each edge. But this can yield to a black spot, where
+     nothing is recognizable, if port sharing is used, since all these
+     qdifferently rotated arrow heads are drawn at the same place. If the
+     arrow mode is fixed, then the arrow head is rotated only in steps of
+     45 degree, and only one arrow head occurs at each port.
+     Default is fixed. */
+  enum arrow_mode arrow_mode;
+
+  /* Treefactor The algorithm tree for downward laid out trees tries to
+     produce a medium dense, balanced tree-like layout. If the tree
+     factor is greater than 0.5, the tree edges are spread, i.e. they
+     get a larger gradient. This may improve the readability of the tree.
+     Note: it is not obvious whether spreading results in a more dense or
+     wide layout. For a tree, there is a tree factor such that the whole
+     tree is minimal wide.
+     Default is 0.5. */
+  float treefactor;
+
+  /* Spreadlevel This parameter only influences the algorithm tree, too.
+     For large, balanced trees, spreading of the uppermost nodes would
+     enlarge the width of the tree too much, such that the tree does not
+     fit anymore in a window. Thus, the spreadlevel specifies the minimal
+     level (rank) where nodes are spread. Nodes of levels upper than
+     spreadlevel are not spread.
+     Default is 1. */
+  int spreadlevel;
+
+  /* Crossing weight specifies the weight that is used for the crossing
+     reduction: bary (default), median, barymedian or medianbary. We
+     cannot give a general recommendation, which is the best method. For
+     graphs with very large average degree of edges (number of incoming
+     and outgoing edges at a node), the weight bary is the fastest
+     method. With the weights barymedian and medianbary, equal weights of
+     different nodes are not very probable, thus the crossing reduction
+     phase 2 might be very fast.
+     Default is bary. */
+  enum crossing_type crossing_weight;
+
+  /* Crossing phase2 is the most time consuming phase of the crossing
+     reduction. In this phase, the nodes that happen to have equal
+     crossing weights are permuted. By specifying no, this phase is
+     suppressed.
+     Default is yes. */
+  enum decision crossing_phase2;
+
+  /* Crossing optimization is a postprocessing phase after the normal
+     crossing reduction: we try to optimize locally, by exchanging pairs
+     of nodes to reduce the crossings. Although this phase is not very
+     time consuming, it can be suppressed by specifying no.
+     Default is yes. */
+  enum decision crossing_optimization;
+
+  /* View allows to select the fisheye views. Because
+     of the fixed size of the window that shows the graph, we normally
+     can only see a small amount of a large graph. If we shrink the graph
+     such that it fits into the window, we cannot recognize any detail
+     anymore. Fisheye views are coordinate transformations: the view onto
+     the graph is distort, to overcome this usage deficiency. The polar
+     fisheye is easy to explain: assume a projection of the plane that
+     contains the graph picture onto a spheric ball. If we now look onto
+     this ball in 3 D, we have a polar fisheye view. There is a focus
+     point which is magnified such that we see all details. Parts of the
+     plane that are far away from the focus point are demagnified very
+     much. Cartesian fisheye have a similar effect; only the formula for
+     the coordinate transformation is different. Selecting cfish means
+     the cartesian fisheye is used which demagnifies such that the whole
+     graph is visible (self adaptable cartesian fisheye). With fcfish,
+     the cartesian fisheye shows the region of a fixed radius around the
+     focus point (fixed radius cartesian fisheye). This region might be
+     smaller than the whole graph, but the demagnification needed to show
+     this region in the window is also not so large, thus more details
+     are recognizable. With pfish the self adaptable polar fisheye is
+     selected that shows the whole graph, and with fpfish the fixed
+     radius polar fisheye is selected.
+     Default is normal view.  */
+  enum view view;
+
+  /* Edges no suppresses the drawing of edges.
+     Default is yes. */
+  enum decision edges;
+
+  /* Nodes no suppresses the drawing of nodes.
+     Default is yes. */
+  enum decision nodes;
+
+  /* Splines specifies whether splines are used to draw edges (yes or no).
+     As default, polygon segments are used to draw edges, because this is
+     much faster. Note that the spline drawing routine is not fully
+     validated, and is very slow. Its use is mainly to prepare high
+     quality PostScript output for very small graphs.
+     Default is no. */
+  enum decision splines;
+
+  /* Bmax set the maximal number of iterations that are done for the
+     reduction of edge bendings.
+   Default is 100. */
+  int bmax;
+
+  /* Cmin set the minimal number of iterations that are done for the
+     crossing reduction with the crossing weights. The normal method
+     stops if two consecutive checks does not reduce the number of
+     crossings anymore. However, this increasing of the number of
+     crossings might be locally, such that after some more iterations,
+     the crossing number might decrease much more.
+     Default is 0. */
+  int cmin;
+
+  /* Cmax set the maximal number of interactions for crossing reduction.
+     This is helpful for speeding up the layout process.
+     Default is -1, which represents infinity.  */
+  int cmax;
+
+  /* Pmin set the minimal number of iterations that is done with the
+     pendulum method. Similar to the crossing reduction, this method
+     stops if the `imbalancement weight' does not decreases anymore.
+     However, the increasing of the imbalancement weight might be locally,
+     such that after some more iterations, the imbalancement weight might
+     decrease much more.
+     Default is 0. */
+  int pmin;
+
+  /* Pmax set the maximal number of iterations of the pendulum method.
+     This is helpful for speedup the layout process.
+     Default is 100. */
+  int pmax;
+
+  /* Rmin set the minimal number of iterations that is done with the
+     rubberband method. This is similar as for the pendulum method.
+     Default is 0. */
+  int rmin;
+
+  /* Rmax set the maximal number of iterations of the rubberband method.
+     This is helpful for speedup the layout process.
+     Default is 100. */
+  int rmax;
+
+  /* Smax set the maximal number of iterations of the straight line
+     recognition phase (useful only, if the straight line recognition
+     phase is switched on, see attribute straight.phase).
+     Default is 100. */
+  int smax;
+
+  /* Generic values.
+   */
+  node node;
+  edge edge;
+
+  /* List of nodes declared.
+     Pointer. */
+  node *node_list;
+
+  /* List of edges declared.
+     Pointer. */
+  edge *edge_list;
+
+};
+
+/* Graph typedefs. */
+typedef struct graph graph;
+
+void new_graph (graph *g);
+void new_node (node *n);
+void new_edge (edge *e);
+
+void add_node (graph *g, node *n);
+void add_edge (graph *g, edge *e);
+
+void add_colorentry (graph *g, int color_idx, int red_cp,
+		     int green_cp, int blue_cp);
+void add_classname (graph *g, int val, const char *name);
+void add_infoname (graph *g, int val, const char *name);
+
+void open_node (FILE *fout);
+void output_node (node *n, FILE *fout);
+void close_node (FILE *fout);
+
+void open_edge (edge *e, FILE *fout);
+void output_edge (edge *e, FILE *fout);
+void close_edge (FILE *fout);
+
+void open_graph (FILE *fout);
+void output_graph (graph *g, FILE *fout);
+void close_graph (graph *g, FILE *fout);
+
+#endif /* VCG_H_ */
diff --git a/src/vcg_defaults.h b/src/vcg_defaults.h
new file mode 100644
index 0000000..78e24b5
--- /dev/null
+++ b/src/vcg_defaults.h
@@ -0,0 +1,181 @@
+/* VCG description handler for Bison.
+
+   Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc.
+
+   This file is part of Bison, the GNU Compiler Compiler.
+
+   Bison 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 2, or (at your option)
+   any later version.
+
+   Bison 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 Bison; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
+
+#ifndef VCG_DEFAULTS_H_
+# define VCG_DEFAULTS_H_
+
+/* Graph defaults. */
+# define G_TITLE		NULL
+# define G_LABEL		NULL
+# define G_INFOS1		NULL
+# define G_INFOS2		NULL
+# define G_INFOS3		NULL
+
+# define G_COLOR		white
+# define G_TEXTCOLOR		black
+# define G_BORDERCOLOR		G_TEXTCOLOR
+
+# define G_WIDTH		100
+# define G_HEIGHT		100
+# define G_BORDERWIDTH		2
+
+# define G_X			0
+# define G_Y			0
+
+# define G_FOLDING		0
+
+# define G_SHRINK		1
+# define G_STRETCH		1
+
+# define G_TEXTMODE		centered
+# define G_SHAPE		box
+
+# define G_VERTICAL_ORDER	0	/* Unspecified for subgraphs.  */
+# define G_HORIZONTAL_ORDER	0	/* Unspecified for subgraphs.  */
+
+# define G_XMAX			90	/* Not output.  */
+# define G_YMAX			90	/* Not output.  */
+
+# define G_XBASE		5
+# define G_YBASE		5
+
+# define G_XSPACE		20
+# define G_YSPACE		70
+# define G_XLSPACE		(G_XSPACE / 2)	/* Not output */
+
+# define G_XRASTER		1
+# define G_YRASTER		1
+# define G_XLRASTER		1
+
+# define G_HIDDEN		(-1)	/* No default value.  */
+
+# define G_CLASSNAME		NULL	/* No class name association.  */
+# define G_INFONAME		NULL
+# define G_COLORENTRY		NULL
+
+# define G_LAYOUTALGORITHM	normal
+# define G_LAYOUT_DOWNFACTOR	1
+# define G_LAYOUT_UPFACTOR	1
+# define G_LAYOUT_NEARFACTOR	1
+# define G_LAYOUT_SPLINEFACTOR	70
+
+# define G_LATE_EDGE_LABELS	no
+# define G_DISPLAY_EDGE_LABELS	no
+# define G_DIRTY_EDGE_LABELS	no
+# define G_FINETUNING		yes
+# define G_IGNORE_SINGLES	no
+# define G_LONG_STRAIGHT_PHASE	no
+# define G_PRIORITY_PHASE	no
+# define G_MANHATTAN_EDGES	no
+# define G_SMANHATTAN_EDGES	no
+# define G_NEAR_EDGES		yes
+
+# define G_ORIENTATION		top_to_bottom
+# define G_NODE_ALIGNMENT	center
+# define G_PORT_SHARING		yes
+# define G_ARROW_MODE		fixed
+# define G_TREEFACTOR		0.5
+# define G_SPREADLEVEL		1
+# define G_CROSSING_WEIGHT	bary
+# define G_CROSSING_PHASE2	yes
+# define G_CROSSING_OPTIMIZATION	yes
+# define G_VIEW			normal_view
+
+# define G_EDGES		yes
+# define G_NODES		yes
+# define G_SPLINES		no
+
+# define G_BMAX			100
+# define G_CMIN			0
+# define G_CMAX			(-1)	/* Infinity */
+# define G_PMIN			0
+# define G_PMAX			100
+# define G_RMIN			0
+# define G_RMAX			100
+# define G_SMAX			100
+
+# define G_NODE_LIST		NULL
+# define G_EDGE_LIST		NULL
+
+/* Nodes defaults. */
+# define N_TITLE		NULL
+# define N_LABEL		NULL
+
+# define N_LOCX			(-1)	/* Default unspcified */
+# define N_LOCY			(-1)	/* Default unspcified */
+
+# define N_VERTICAL_ORDER	(-1)	/* Default unspcified */
+# define N_HORIZONTAL_ORDER	(-1)	/* Default unspcified */
+
+# define N_WIDTH		(-1)	/* We assume that we can't define it now. */
+# define N_HEIGHT		(-1)	/* also. */
+
+# define N_SHRINK		1
+# define N_STRETCH		1
+
+# define N_FOLDING		(-1)	/* no explicit default value. */
+
+# define N_SHAPE		box
+# define N_TEXTMODE		centered
+# define N_BORDERWIDTH		2
+
+# define N_COLOR		white
+# define N_TEXTCOLOR		black
+# define N_BORDERCOLOR		N_TEXTCOLOR
+
+# define N_INFOS1		NULL
+# define N_INFOS2		NULL
+# define N_INFOS3		NULL
+
+# define N_NEXT			NULL
+
+/* Edge defaults. */
+# define E_EDGE_TYPE		normal_edge
+
+# define E_SOURCENAME		NULL	/* Mandatory. */
+# define E_TARGETNAME		NULL	/* Mandatory. */
+# define E_LABEL		NULL
+
+# define E_LINESTYLE		continuous
+# define E_THICKNESS		2
+
+# define E_CLASS		1
+
+# define E_COLOR		black
+# define E_TEXTCOLOR		E_COLOR
+# define E_ARROWCOLOR		E_COLOR
+# define E_BACKARROWCOLOR	E_COLOR
+
+# define E_ARROWSIZE		10
+# define E_BACKARROWSIZE	0
+
+# define E_ARROWSTYLE		solid
+# define E_BACKARROWSTYLE	none
+
+# define E_PRIORITY		1
+
+# define E_ANCHOR		(-1)
+
+# define E_HORIZONTAL_ORDER	(-1)
+
+# define E_NEXT			NULL
+
+#endif /* not VCG_DEFAULTS_H_ */
diff --git a/src/yacc b/src/yacc
new file mode 100755
index 0000000..eda226d
--- /dev/null
+++ b/src/yacc
@@ -0,0 +1,2 @@
+#! /bin/sh
+exec /home/phanna/src/bison/bin/bison -y "$@"