[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 07/14] glr2.cc: move state_stack into the unnamed namespace
From: |
Akim Demaille |
Subject: |
[PATCH 07/14] glr2.cc: move state_stack into the unnamed namespace |
Date: |
Sun, 12 Sep 2021 14:07:40 +0200 |
* data/skeletons/glr2.cc: here.
Prefer `using` to `typedef`, this is C++11.
Use the type alias we introduced.
---
data/skeletons/glr2.cc | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/data/skeletons/glr2.cc b/data/skeletons/glr2.cc
index 93549639..dcb00943 100644
--- a/data/skeletons/glr2.cc
+++ b/data/skeletons/glr2.cc
@@ -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)
+namespace
+{
class state_stack
{
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;]])[
+ 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. */
@@ -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
@@ -2067,12 +2069,12 @@ private:
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;])[
--
2.32.0
- [PATCH 00/14] glr2.cc: fix linking conflicts, Akim Demaille, 2021/09/12
- [PATCH 01/14] glr2.cc: don't publish YY_EXCEPTIONS, Akim Demaille, 2021/09/12
- [PATCH 02/14] glr2.cc: put semantic_option into an unnamed namespace, Akim Demaille, 2021/09/12
- [PATCH 03/14] glr2.cc: prefer unnamed namespace to 'static', Akim Demaille, 2021/09/12
- [PATCH 04/14] glr2.cc: put create_state_set_index in unnamed namespace, Akim Demaille, 2021/09/12
- [PATCH 05/14] glr2.cc: move glr_stack and glr_state into the parser class, Akim Demaille, 2021/09/12
- [PATCH 06/14] glr2.cc: style: clarify control flow, Akim Demaille, 2021/09/12
- [PATCH 07/14] glr2.cc: move state_stack into the unnamed namespace,
Akim Demaille <=
- [PATCH 08/14] glr2.cc: put glr_state_set and glr_stack_item in unnamed namespace, Akim Demaille, 2021/09/12
- [PATCH 09/14] glr2.cc: prefer using, and remove useless type aliases, Akim Demaille, 2021/09/12
- [PATCH 10/14] glr2.cc: use only symbol_kind_type, not yysymbol_kind_t, Akim Demaille, 2021/09/12
- [PATCH 11/14] glr2.cc: move strong_index_alias into the unnamed namespace, Akim Demaille, 2021/09/12
- [PATCH 12/14] glr2.cc: check linking conflicts, Akim Demaille, 2021/09/12
- [PATCH 13/14] glr2.cc: kill trailing white spaces, Akim Demaille, 2021/09/12
- [PATCH 14/14] glr2.cc: don't pass %parse-param to destroy, Akim Demaille, 2021/09/12
- Re: [PATCH 00/14] glr2.cc: fix linking conflicts, Tom Shields, 2021/09/12