glr2.cc: put semantic_option into an unnamed namespace

If we link several glr2.cc parsers together, we get linking failures
because of duplicate symbols.

* data/skeletons/glr2.cc (semantic_option::indexIn)
(semantic_option::next): Remove the useless overloads.
This commit is contained in:
Akim Demaille
2021-09-08 21:58:32 +02:00
parent ca96df89b2
commit 4ec4309cce

View File

@@ -753,7 +753,10 @@ typedef int rule_num;
// Forward declarations.
class glr_state;
class semantic_option;
namespace
{
class semantic_option;
}
class glr_stack_item;
class glr_stack;
@@ -1126,9 +1129,11 @@ private:
glr_state* yylastDeleted;
};
class semantic_option
namespace
{
public:
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([[
@@ -1189,11 +1194,11 @@ public:
const glr_state* state() const;
void setState(const glr_state* s);
const semantic_option* next () const;
const semantic_option* next () const YY_ATTRIBUTE_UNUSED;
semantic_option* next ();
void setNext (const semantic_option* s);
std::ptrdiff_t indexIn (const glr_stack_item* array) const;
std::ptrdiff_t indexIn (const glr_stack_item* array) const YY_ATTRIBUTE_UNUSED;
/** True iff YYY0 and YYY1 represent identical options at the top level.
* That is, they represent the same rule applied to RHS symbols
@@ -1343,7 +1348,7 @@ public:
/** Rule number for this reduction */
rule_num yyrule;
private:
private:
template <typename T>
static const glr_stack_item* asItem(const T* state)
{
@@ -1360,14 +1365,14 @@ private:
* options are chained in decreasing order by address. */
std::ptrdiff_t yynext;
public:
public:
/** The lookahead for this reduction. */
symbol_kind_type yytoken;
value_type yyval;]b4_locations_if([[
location_type yyloc;]])[
]b4_parse_assert_if([[
public:
public:
// Check invariants.
void check_ () const
{
@@ -1379,7 +1384,8 @@ public:
// A magic number to check our pointer arithmetic is sane.
enum { MAGIC = 0xeff1cace };
unsigned int magic_;]])[
};
};
}
/** Type of the items in the GLR stack.
* It can be either a glr_state or a semantic_option. The is_state_ field