[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 09/14] glr2.cc: prefer using, and remove useless type aliases
From: |
Akim Demaille |
Subject: |
[PATCH 09/14] glr2.cc: prefer using, and remove useless type aliases |
Date: |
Sun, 12 Sep 2021 14:07:42 +0200 |
* data/skeletons/glr2.cc: here.
---
data/skeletons/glr2.cc | 35 ++++++++++-------------------------
1 file changed, 10 insertions(+), 25 deletions(-)
diff --git a/data/skeletons/glr2.cc b/data/skeletons/glr2.cc
index 17dde98e..cd8c9beb 100644
--- a/data/skeletons/glr2.cc
+++ b/data/skeletons/glr2.cc
@@ -259,7 +259,7 @@ m4_define([b4_shared_declarations],
void set_debug_stream (std::ostream &);
/// Type for debugging levels.
- typedef int debug_level_type;
+ using debug_level_type = int;
/// The current debugging level.
debug_level_type debug_level () const;
/// Set the current debugging level.
@@ -435,7 +435,7 @@ m4_define([b4_shared_declarations],
]b4_header_if([[#include "@basename(]b4_spec_header_file[@)"]],
[b4_shared_declarations([cc])])[
-typedef ]b4_namespace_ref[::]b4_parser_class[::symbol_kind_type
yysymbol_kind_t;
+using yysymbol_kind_t =
]b4_namespace_ref[::]b4_parser_class[::symbol_kind_type;
/* Default (constant) value used for initialization for null
right-hand sides. Unlike the standard yacc.c template, here we set
@@ -760,7 +760,7 @@ template<typename T>
const std::ptrdiff_t strong_index_alias<T>::INVALID_INDEX =
std::numeric_limits<std::ptrdiff_t>::max ();
-typedef strong_index_alias<struct glr_state_set_tag> state_set_index;
+using state_set_index = strong_index_alias<struct glr_state_set_tag>;
namespace
{
@@ -771,15 +771,19 @@ namespace
}
/** State numbers, as in LALR(1) machine */
-typedef int state_num;
+using state_num = int;
/** Rule numbers, as in LALR(1) machine */
-typedef int rule_num;
+using rule_num = int;
namespace
{
using parser_type = ]b4_namespace_ref[::]b4_parser_class[;
using glr_state = parser_type::glr_state;
+ using symbol_kind = parser_type::symbol_kind;
+ using symbol_kind_type = parser_type::symbol_kind_type;
+ using value_type = parser_type::value_type;]b4_locations_if([[
+ using location_type = parser_type::location_type;]])[
// Forward declarations.
class glr_stack_item;
@@ -812,11 +816,6 @@ namespace ]b4_namespace_ref[
class ]b4_parser_class[::glr_state
{
public:
- typedef ]b4_namespace_ref[::]b4_parser_class[::symbol_kind symbol_kind;
- typedef ]b4_namespace_ref[::]b4_parser_class[::symbol_kind_type
symbol_kind_type;
- 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;]])[
-
glr_state ()
: yyresolved (false)
, yylrState (0)
@@ -1167,11 +1166,6 @@ namespace
class semantic_option
{
public:
- typedef ]b4_namespace_ref[::]b4_parser_class[::symbol_kind symbol_kind;
- typedef ]b4_namespace_ref[::]b4_parser_class[::symbol_kind_type
symbol_kind_type;
- 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;]])[
-
semantic_option ()
: yyrule (0)
, yystate (0)
@@ -1748,7 +1742,7 @@ namespace
bool
reduceToOneStack ()
{
- typedef std::vector<glr_state*>::iterator iterator;
+ using iterator = std::vector<glr_state*>::iterator;
const iterator yybegin = yytops.begin();
const iterator yyend = yytops.end();
const iterator yyit = std::find_if(yybegin, yyend, glr_state_not_null);
@@ -2093,15 +2087,7 @@ namespace ]b4_namespace_ref[
class ]b4_parser_class[::glr_stack
{
public:
- typedef ]b4_namespace_ref[::]b4_parser_class[ parser_type;
- typedef parser_type::symbol_kind symbol_kind;
- typedef parser_type::symbol_kind_type symbol_kind_type;
- typedef parser_type::symbol_type symbol_type;
- typedef parser_type::value_type value_type;]b4_locations_if([[
- typedef parser_type::location_type location_type;]])[
-
]b4_parse_error_bmatch([custom\|detailed\|verbose], [[
- typedef parser_type::context context;
// Needs access to yypact_value_is_default, etc.
friend context;
]])[
@@ -2618,7 +2604,6 @@ 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 parser_type::syntax_error syntax_error;
try
{
#endif // YY_EXCEPTIONS
--
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, 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 <=
- [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