summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2021-09-12 13:13:13 +0200
committerAkim Demaille <akim.demaille@gmail.com>2021-09-12 14:00:55 +0200
commitd432079f8adb3e1b158bacf8b2283410ec0fd24c (patch)
treee422301f4dde0a94b07ae4dc97a0db10e9364277
parentb6ac175a1c310f944e3ba96a46edfa15caf9f37a (diff)
downloadbison-d432079f8adb3e1b158bacf8b2283410ec0fd24c.tar.gz
glr2.cc: move strong_index_alias into the unnamed namespace
* data/skeletons/glr2.cc: here.
-rw-r--r--data/skeletons/glr2.cc164
1 files changed, 82 insertions, 82 deletions
diff --git a/data/skeletons/glr2.cc b/data/skeletons/glr2.cc
index 49382474..70755e99 100644
--- a/data/skeletons/glr2.cc
+++ b/data/skeletons/glr2.cc
@@ -435,16 +435,19 @@ m4_define([b4_shared_declarations],
]b4_header_if([[#include "@basename(]b4_spec_header_file[@)"]],
[b4_shared_declarations([cc])])[
-/* Default (constant) value used for initialization for null
- right-hand sides. Unlike the standard yacc.c template, here we set
- the default value of $$ to a zeroed-out value. Since the default
- value is undefined, this behavior is technically correct. */
-static ]b4_namespace_ref[::]b4_parser_class[::value_type yyval_default;
+namespace
+{
+ /* Default (constant) value used for initialization for null
+ right-hand sides. Unlike the standard yacc.c template, here we set
+ the default value of $$ to a zeroed-out value. Since the default
+ value is undefined, this behavior is technically correct. */
+ ]b4_namespace_ref[::]b4_parser_class[::value_type yyval_default;
+}
]b4_user_post_prologue[
-]b4_percent_code_get[]dnl
+]b4_percent_code_get[
-[#include <cstdio>
+#include <cstdio>
#include <cstdlib>
#ifndef YY_
@@ -586,7 +589,7 @@ namespace
{
]b4_conflicting_rules[
};
-}
+} // namespace
/* Error token number */
@@ -676,106 +679,103 @@ namespace
# define YYSTACKEXPANDABLE 1
#endif
-template <typename Parameter>
-class strong_index_alias
+namespace
{
-public:
- static strong_index_alias create (std::ptrdiff_t value)
+ template <typename Parameter>
+ class strong_index_alias
{
- strong_index_alias result;
- result.value_ = value;
- return result;
- }
+ public:
+ static strong_index_alias create (std::ptrdiff_t value)
+ {
+ strong_index_alias result;
+ result.value_ = value;
+ return result;
+ }
- std::ptrdiff_t const& get () const { return value_; }
+ std::ptrdiff_t const& get () const { return value_; }
- size_t uget () const { return static_cast<size_t> (value_); }
+ size_t uget () const { return static_cast<size_t> (value_); }
- strong_index_alias operator+ (std::ptrdiff_t other) const
- {
- return strong_index_alias (get () + other);
- }
+ strong_index_alias operator+ (std::ptrdiff_t other) const
+ {
+ return strong_index_alias (get () + other);
+ }
- void operator+= (std::ptrdiff_t other)
- {
- value_ += other;
- }
+ void operator+= (std::ptrdiff_t other)
+ {
+ value_ += other;
+ }
- strong_index_alias operator- (std::ptrdiff_t other)
- {
- return strong_index_alias (get () - other);
- }
+ strong_index_alias operator- (std::ptrdiff_t other)
+ {
+ return strong_index_alias (get () - other);
+ }
- void operator-= (std::ptrdiff_t other)
- {
- value_ -= other;
- }
+ void operator-= (std::ptrdiff_t other)
+ {
+ value_ -= other;
+ }
- size_t operator- (strong_index_alias other)
- {
- return strong_index_alias (get () - other.get ());
- }
+ size_t operator- (strong_index_alias other)
+ {
+ return strong_index_alias (get () - other.get ());
+ }
- strong_index_alias& operator++ ()
- {
- ++value_;
- return *this;
- }
+ strong_index_alias& operator++ ()
+ {
+ ++value_;
+ return *this;
+ }
- bool isValid () const
- {
- return value_ != INVALID_INDEX;
- }
+ bool isValid () const
+ {
+ return value_ != INVALID_INDEX;
+ }
- void setInvalid()
- {
- value_ = INVALID_INDEX;
- }
+ void setInvalid()
+ {
+ value_ = INVALID_INDEX;
+ }
- bool operator== (strong_index_alias other)
- {
- return get () == other.get ();
- }
+ bool operator== (strong_index_alias other)
+ {
+ return get () == other.get ();
+ }
- bool operator!= (strong_index_alias other)
- {
- return get () != other.get ();
- }
+ bool operator!= (strong_index_alias other)
+ {
+ return get () != other.get ();
+ }
- bool operator< (strong_index_alias other)
- {
- return get () < other.get ();
- }
+ bool operator< (strong_index_alias other)
+ {
+ return get () < other.get ();
+ }
-private:
- static const std::ptrdiff_t INVALID_INDEX;
+ private:
+ static const std::ptrdiff_t INVALID_INDEX;
- // WARNING: 0-initialized.
- std::ptrdiff_t value_;
-};
+ // WARNING: 0-initialized.
+ std::ptrdiff_t value_;
+ }; // class strong_index_alias
-template<typename T>
-const std::ptrdiff_t strong_index_alias<T>::INVALID_INDEX =
- std::numeric_limits<std::ptrdiff_t>::max ();
+ template<typename T>
+ const std::ptrdiff_t strong_index_alias<T>::INVALID_INDEX =
+ std::numeric_limits<std::ptrdiff_t>::max ();
-using state_set_index = strong_index_alias<struct glr_state_set_tag>;
+ using state_set_index = strong_index_alias<struct glr_state_set_tag>;
-namespace
-{
state_set_index create_state_set_index (std::ptrdiff_t value)
{
return state_set_index::create (value);
}
-}
-/** State numbers, as in LALR(1) machine */
-using state_num = int;
+ /** State numbers, as in LALR(1) machine */
+ using state_num = int;
-/** Rule numbers, as in LALR(1) machine */
-using rule_num = int;
+ /** Rule numbers, as in LALR(1) machine */
+ 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;
@@ -786,7 +786,7 @@ namespace
// Forward declarations.
class glr_stack_item;
class semantic_option;
-}
+} // namespace
namespace
{