mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-27 13:13:04 +00:00
glr2.cc: move state_stack into the unnamed namespace
* data/skeletons/glr2.cc: here. Prefer `using` to `typedef`, this is C++11. Use the type alias we introduced.
This commit is contained in:
@@ -1660,12 +1660,15 @@ void glr_state::destroy (char const* yymsg, ]b4_namespace_ref[::]b4_parser_class
|
||||
#undef YYFILL
|
||||
#define YYFILL(N) yyfill (yyvsp, yylow, (N), yynormal)
|
||||
|
||||
class state_stack
|
||||
namespace
|
||||
{
|
||||
public:
|
||||
typedef ]b4_namespace_ref[::]b4_parser_class[::symbol_kind symbol_kind;
|
||||
typedef ]b4_namespace_ref[::]b4_parser_class[::value_type value_type;]b4_locations_if([[
|
||||
typedef ]b4_namespace_ref[::]b4_parser_class[::location_type location_type;]])[
|
||||
class state_stack
|
||||
{
|
||||
public:
|
||||
using parser_type = ]b4_namespace_ref[::]b4_parser_class[;
|
||||
using symbol_kind = parser_type::symbol_kind;
|
||||
using value_type = parser_type::value_type;]b4_locations_if([[
|
||||
using location_type = parser_type::location_type;]])[
|
||||
|
||||
/** Initialize to a single empty stack, with total maximum
|
||||
* capacity for all stacks of YYSIZE. */
|
||||
@@ -1683,7 +1686,7 @@ public:
|
||||
return YYHEADROOM <= spaceLeft () || yyexpandGLRStack ();
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
/** If *this is expandable, extend it. WARNING: Pointers into the
|
||||
stack from outside should be considered invalid after this call.
|
||||
We always expand when there are 1 or fewer items left AFTER an
|
||||
@@ -1719,7 +1722,7 @@ private:
|
||||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
#else
|
||||
bool yyexpandGLRStackIfNeeded ()
|
||||
{
|
||||
@@ -1951,7 +1954,7 @@ public:
|
||||
|
||||
void
|
||||
yy_reduce_print (bool yynormal, glr_stack_item* yyvsp, state_set_index yyk,
|
||||
rule_num yyrule, ]b4_namespace_ref[::]b4_parser_class[& yyparser)
|
||||
rule_num yyrule, parser_type& yyparser)
|
||||
{
|
||||
int yynrhs = yyrhsLength (yyrule);]b4_locations_if([
|
||||
int yylow = 1;])[
|
||||
@@ -2015,7 +2018,7 @@ public:
|
||||
|
||||
YYRESULTTAG
|
||||
yyreportAmbiguity (const semantic_option& yyx0,
|
||||
const semantic_option& yyx1, ]b4_namespace_ref[::]b4_parser_class[& yyparser]b4_locations_if([, const location_type& yyloc])[)
|
||||
const semantic_option& yyx1, parser_type& yyparser]b4_locations_if([, const location_type& yyloc])[)
|
||||
{
|
||||
YY_USE (yyx0);
|
||||
YY_USE (yyx1);
|
||||
@@ -2033,7 +2036,6 @@ public:
|
||||
return yyabort;
|
||||
}
|
||||
|
||||
/* DEBUGGING ONLY */
|
||||
#if ]b4_api_PREFIX[DEBUG
|
||||
/* Print YYS (possibly NULL) and its predecessors. */
|
||||
void
|
||||
@@ -2047,7 +2049,7 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
private:
|
||||
size_t spaceLeft() const
|
||||
{
|
||||
return yyitems.capacity() - yyitems.size();
|
||||
@@ -2066,13 +2068,13 @@ private:
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
public:
|
||||
std::vector<glr_stack_item> yyitems;
|
||||
// Where the stack splits. Anything below this address is deterministic.
|
||||
const glr_state* yysplitPoint;
|
||||
glr_state_set yytops;
|
||||
};
|
||||
}; // class state_stack
|
||||
} // namespace
|
||||
|
||||
#undef YYFILL
|
||||
#define YYFILL(N) yystateStack.yyfill (yyvsp, yylow, (N), yynormal)
|
||||
@@ -2095,7 +2097,7 @@ namespace ]b4_namespace_ref[
|
||||
friend context;
|
||||
]])[
|
||||
|
||||
glr_stack (size_t yysize, ]b4_namespace_ref[::]b4_parser_class[& yyparser_yyarg]m4_ifset([b4_parse_param], [, b4_parse_param_decl])[)
|
||||
glr_stack (size_t yysize, parser_type& yyparser_yyarg]m4_ifset([b4_parse_param], [, b4_parse_param_decl])[)
|
||||
: yyerrState (0)
|
||||
, yystateStack (yysize)
|
||||
, yyerrcnt (0)
|
||||
@@ -2118,7 +2120,7 @@ namespace ]b4_namespace_ref[
|
||||
int yyerrcnt;
|
||||
symbol_type yyla;
|
||||
YYJMP_BUF yyexception_buffer;
|
||||
]b4_namespace_ref[::]b4_parser_class[& yyparser;
|
||||
parser_type& yyparser;
|
||||
|
||||
#define YYCHK1(YYE) \
|
||||
do { \
|
||||
@@ -2607,7 +2609,7 @@ namespace ]b4_namespace_ref[
|
||||
so pretend the stack is "normal". */
|
||||
YY_REDUCE_PRINT ((yynormal || yyk == create_state_set_index (-1), yyvsp, yyk, yyrule, yyparser));
|
||||
#if YY_EXCEPTIONS
|
||||
typedef ]b4_namespace_ref[::]b4_parser_class[::syntax_error syntax_error;
|
||||
typedef parser_type::syntax_error syntax_error;
|
||||
try
|
||||
{
|
||||
#endif // YY_EXCEPTIONS
|
||||
@@ -3085,7 +3087,7 @@ namespace ]b4_namespace_ref[
|
||||
yyla.kind_ = yyparser.yytranslate_ (]b4_yylex[);]])[
|
||||
}
|
||||
#if YY_EXCEPTIONS
|
||||
catch (const ]b4_namespace_ref[::]b4_parser_class[::syntax_error& yyexc)
|
||||
catch (const parser_type::syntax_error& yyexc)
|
||||
{
|
||||
YYCDEBUG << "Caught exception: " << yyexc.what () << '\n';]b4_locations_if([
|
||||
this->yyla.location = yyexc.location;])[
|
||||
|
||||
Reference in New Issue
Block a user