[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 03/14] glr2.cc: prefer unnamed namespace to 'static'
From: |
Akim Demaille |
Subject: |
[PATCH 03/14] glr2.cc: prefer unnamed namespace to 'static' |
Date: |
Sun, 12 Sep 2021 14:07:36 +0200 |
* data/skeletons/glr2.cc: here.
---
data/skeletons/glr2.cc | 48 +++++++++++++++++++++++++++++++-----------
1 file changed, 36 insertions(+), 12 deletions(-)
diff --git a/data/skeletons/glr2.cc b/data/skeletons/glr2.cc
index 06956d01..b5d5452d 100644
--- a/data/skeletons/glr2.cc
+++ b/data/skeletons/glr2.cc
@@ -42,6 +42,20 @@ m4_define([b4_parser_class],
b4_namespace_ref[::]b4_parser_class[::symbol_kind::]b4_symbol($1,
kind_base))
])
+
+# b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT)
+# -------------------------------------------------------------
+# Define "yy<TABLE-NAME>" whose contents is CONTENT. Does not use "static",
+# should be in unnamed namespace.
+m4_define([b4_integral_parser_table_define],
+[m4_ifvaln([$3], [ b4_comment([$3])])dnl
+ const b4_int_type_for([$2]) yy$1[[]] =
+ {
+ $2
+ };dnl
+])
+
+
## ---------------- ##
## Default values. ##
## ---------------- ##
@@ -523,9 +537,11 @@ static ]b4_namespace_ref[::]b4_parser_class[::value_type
yyval_default;
accessed by $0, $-1, etc., in any rule. */
#define YYMAXLEFT ]b4_max_left_semantic_context[
+namespace
+{
#if ]b4_api_PREFIX[DEBUG
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
-static const ]b4_int_type_for([b4_rline])[ yyrline[] =
+ const ]b4_int_type_for([b4_rline])[ yyrline[] =
{
]b4_rline[
};
@@ -537,20 +553,20 @@ static const ]b4_int_type_for([b4_rline])[ yyrline[] =
]b4_parser_tables_define[
/* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */
-static const ]b4_int_type_for([b4_dprec])[ yydprec[] =
+ const ]b4_int_type_for([b4_dprec])[ yydprec[] =
{
]b4_dprec[
};
/* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */
-static const ]b4_int_type_for([b4_merger])[ yymerger[] =
+ const ]b4_int_type_for([b4_merger])[ yymerger[] =
{
]b4_merger[
};
/* YYIMMEDIATE[RULE-NUM] -- True iff rule #RULE-NUM is not to be deferred, as
in the case of predicates. */
-static const bool yyimmediate[] =
+ const bool yyimmediate[] =
{
]b4_immediate[
};
@@ -559,7 +575,7 @@ static const bool yyimmediate[] =
list of conflicting reductions corresponding to action entry for
state STATE-NUM in yytable. 0 means no conflicts. The list in
yyconfl is terminated by a rule number of 0. */
-static const ]b4_int_type_for([b4_conflict_list_heads])[ yyconflp[] =
+ const ]b4_int_type_for([b4_conflict_list_heads])[ yyconflp[] =
{
]b4_conflict_list_heads[
};
@@ -569,10 +585,12 @@ static const ]b4_int_type_for([b4_conflict_list_heads])[
yyconflp[] =
]dnl Do not use b4_int_type_for here, since there are places where
dnl pointers onto yyconfl are taken, whose type is "short*".
dnl We probably ought to introduce a type for confl.
-[static const short yyconfl[] =
+ [const short yyconfl[] =
{
]b4_conflicting_rules[
};
+}
+
/* Error token number */
#define YYTERROR 1
@@ -615,11 +633,13 @@ enum YYRESULTTAG { yyok, yyaccept, yyabort, yyerr };
multiple parsers can coexist. */
int yydebug;
-class glr_stack;
-static void yypstack (const glr_stack& yystack, size_t yyk)
+namespace
+{
+ void yypstack (const glr_stack& yystack, size_t yyk)
YY_ATTRIBUTE_UNUSED;
-static void yypdumpstack (const glr_stack& yystack)
+ void yypdumpstack (const glr_stack& yystack)
YY_ATTRIBUTE_UNUSED;
+}
#else /* !]b4_api_PREFIX[DEBUG */
@@ -3199,16 +3219,20 @@ private:
/* DEBUGGING ONLY */
#if ]b4_api_PREFIX[DEBUG
-static void
+namespace
+{
+ void
yypstack (const glr_stack& yystack, size_t yyk)
{
yystack.yypstack (create_state_set_index (static_cast<std::ptrdiff_t>
(yyk)));
}
-static void yypdumpstack (const glr_stack& yystack)
+
+ void
+ yypdumpstack (const glr_stack& yystack)
{
yystack.yypdumpstack ();
}
-
+}
#endif
]b4_namespace_open[
--
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 <=
- [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, 2021/09/12
- [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