-#output "b4_output_prefix[]b4_output_infix[]-class.hh"
-/* -*- C++ -*- */
+m4_divert(-1)
+# m4_define_default(MACRO, VALUE)
+# -------------------------------
+# Define MACRO to VALUE, unless already defined.
+m4_define([m4_define_default],
+[m4_ifdef([$1], [], [m4_define($@)])])
+
+m4_define_default([b4_input_suffix], [.y])
+
+m4_define_default([b4_output_parser_suffix],
+[m4_translit(b4_input_suffix, [yY], [cC])])
+
+m4_define_default([b4_output_parser_name],
+[b4_output_prefix[]b4_output_infix[]b4_output_parser_suffix[]])
+
+
+m4_define_default([b4_output_header_suffix],
+[m4_translit(b4_input_suffix, [yY], [hH])])
+
+m4_define_default([b4_output_header_name],
+[b4_output_prefix[]b4_output_infix[]b4_output_header_suffix[]])
+
+m4_define_default([b4_header_guard],
+ [m4_bpatsubst(m4_toupper([BISON_]b4_output_header_name),
+ [[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]], [_])])
+
+m4_define([b4_copyright],
+ [/* -*- C++ -*- */
/* A Bison parser, made from b4_filename,
by GNU bison b4_version. */
/* Skeleton output parser for bison,
- Copyright 1984, 1989, 1990, 2000, 2001 Free Software Foundation, Inc.
+ Copyright 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
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
- in version 1.24 of Bison. */
+ in version 1.24 of Bison. */])
+
+m4_divert(0)dnl
+#output "b4_output_header_name"
+b4_copyright
+#ifndef b4_header_guard
+# define b4_header_guard
#include "stack.hh"
#include "location.hh"
+#include <string>
+
+/* Using locations. */
+#define YYLSP_NEEDED b4_locations_flag
+
b4_prologue
+/* Tokens. */
+b4_tokendef
+
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG b4_debug
# define YYERROR_VERBOSE b4_error_verbose
#endif
-/* Using locations. */
-#define YYLSP_NEEDED b4_locations_flag
+#ifndef YYSTYPE
+typedef b4_stype
+yystype;
+# define YYSTYPE yystype
+#endif
-// FIXME: This should be defined in traits, not here.
-typedef b4_stype yystype;
+m4_if(b4_locations_flag, [0], [],
+[#ifndef YYLTYPE
+typedef struct yyltype
+{
+ int first_line;
+ int first_column;
+ int last_line;
+ int last_column;
+} yyltype;
+# define YYLTYPE yyltype
+#endif])
namespace yy
{
typedef Stack< SemanticType > SemanticStack;
typedef Stack< LocationType > LocationStack;
+#if YYLSP_NEEDED
+ b4_name (bool debug,
+ LocationType initlocation) : debug_ (debug),
+ initlocation_ (initlocation)
+#else
b4_name (bool debug) : debug_ (debug)
+#endif
{
}
/* @$ and $$. */
SemanticType value;
LocationType location;
+
+ /* Initial location. */
+ LocationType initlocation_;
};
}
+#endif /* not b4_header_guard */
+
#output "b4_output_prefix[]b4_output_infix[].cc"
-#include "b4_output_prefix[]b4_output_infix-class.hh"
+b4_copyright
+
+#include "b4_output_header_name"
/* Enable debugging if requested. */
#if YYDEBUG
# define YYDPRINTF(Args)
#endif /* !YYDEBUG */
-/* Tokens. */
-b4_tokendef
-
int
yy::b4_name::parse ()
{
/* Start. */
state_ = 0;
looka_ = empty_;
+#if YYLSP_NEEDED
+ location = initlocation_;
+#endif
YYDPRINTF ((stderr, "Starting parse\n"));
/* New state. */
}
else if (n_ == 0)
goto yyerrlab;
-
+
/* Accept? */
if (n_ == final_)
goto yyacceptlab;
semantic_stack_.push (value);
location_stack_.push (location);
+
+ /* Count tokens shifted since error; after three, turn off error
+ status. */
+ if (errstatus)
+ --errstatus;
+
state_ = n_;
goto yynewstate;
YYFPRINTF (stderr, "-> %s\n", name_[[r1_[n_]]]);
}
#endif
-
+
{
SemanticType& yyval (value);
LocationType& yyloc (location);
b4_actions
}
}
-
+
state_stack_.pop (len_);
semantic_stack_.pop (len_);
location_stack_.pop (len_);
if (debug_)
{
YYFPRINTF (stderr, "state stack now");
- for (StateStack::ConstIterator i = state_stack_.begin ();
+ for (StateStack::ConstIterator i = state_stack_.begin ();
i != state_stack_.end (); ++i)
YYFPRINTF (stderr, " %d", *i);
YYFPRINTF (stderr, "\n");
}
#endif
-
+
semantic_stack_.push (value);
location_stack_.push (location);
if (!errstatus)
{
++nerrs;
-
+
#if YYERROR_VERBOSE
n_ = pact_[[state_]];
if (n_ > flag_ && n_ < last_)
for (int x = (n_ < 0 ? -n_ : 0); x < ntokens_ + nnts_; ++x)
if (check_[[x + n_]] == x)
{
- message += (!count++) ? ", expecting " : " or ";
+ message += (!count++) ? ", expecting " : " or ";
message += name_[[x]];
}
}
else
#endif
message = "parse error";
+ error_ ();
}
- error_ ();
goto yyerrlab1;
-
+
/* Error raised explicitly by an action. */
yyerrlab1:
if (errstatus == 3)
if (debug_)
{
YYFPRINTF (stderr, "Error: state stack now");
- for (StateStack::ConstIterator i = state_stack_.begin ();
+ for (StateStack::ConstIterator i = state_stack_.begin ();
i != state_stack_.end (); ++i)
YYFPRINTF (stderr, " %d", *i);
- YYFPRINTF (stderr, "\n");
+ YYFPRINTF (stderr, "\n");
}
#endif
};
/* YYR1[[YYN]] -- Symbol number of symbol that rule YYN derives. */
-const short
+const short
yy::b4_name::r1_[[]] =
{
b4_r1
};
/* YYR2[[YYN]] -- Number of symbols composing right hand side of rule YYN. */
-const short
+const short
yy::b4_name::r2_[[]] =
{
b4_r2
#if YYDEBUG
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
-const short
+const short
yy::b4_name::rhs_[[]] =
{
b4_rhs
char
yy::b4_name::translate_ (int token)
{
- static
- const char
+ static
+ const char
translate_[[]] =
{
b4_translate
b4_epilogue
#output "stack.hh"
+b4_copyright
+
#ifndef BISON_STACK_HH
# define BISON_STACK_HH
for (; n; --n)
seq_.pop_back ();
}
-
+
inline
void
reserve (unsigned n)
#endif // not BISON_STACK_HH
#output "location.hh"
+b4_copyright
+
#ifndef BISON_LOCATION_HH
# define BISON_LOCATION_HH
}
#endif // not BISON_LOCATION_HH
-
-m4_if(b4_defines_flag, 0, [],
-[#output "b4_output_header_name"
-#ifndef b4_header_guard
-# define b4_header_guard
-
-b4_tokendef
-
-#ifndef YYSTYPE
-typedef b4_stype
-yystype;
-# define YYSTYPE yystype
-#endif
-
-m4_if(b4_pure, [0],
-[extern YYSTYPE b4_prefix[]lval;])
-
-m4_if(b4_locations_flag, [0], [],
-[#ifndef YYLTYPE
-typedef struct yyltype
-{
- int first_line;
- int first_column;
- int last_line;
- int last_column;
-} yyltype;
-# define YYLTYPE yyltype
-#endif
-
-m4_if(b4_pure, [0],
-[extern YYLTYPE b4_prefix[]lloc;])
-])
-#endif /* not b4_header_guard */
-])