mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-16 15:53:03 +00:00
glr2.cc: put glr_state_set and glr_stack_item in unnamed namespace
* data/skeletons/glr2.cc: here.
This commit is contained in:
@@ -776,12 +776,15 @@ typedef int state_num;
|
|||||||
/** Rule numbers, as in LALR(1) machine */
|
/** Rule numbers, as in LALR(1) machine */
|
||||||
typedef int rule_num;
|
typedef int rule_num;
|
||||||
|
|
||||||
// Forward declarations.
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
using parser_type = ]b4_namespace_ref[::]b4_parser_class[;
|
||||||
|
using glr_state = parser_type::glr_state;
|
||||||
|
|
||||||
|
// Forward declarations.
|
||||||
|
class glr_stack_item;
|
||||||
class semantic_option;
|
class semantic_option;
|
||||||
}
|
}
|
||||||
class glr_stack_item;
|
|
||||||
|
|
||||||
/** Accessing symbol of state YYSTATE. */
|
/** Accessing symbol of state YYSTATE. */
|
||||||
static inline yysymbol_kind_t
|
static inline yysymbol_kind_t
|
||||||
@@ -954,7 +957,7 @@ namespace ]b4_namespace_ref[
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::ptrdiff_t indexIn (const glr_stack_item* array) const;
|
std::ptrdiff_t indexIn (const glr_stack_item* array) const YY_ATTRIBUTE_UNUSED;
|
||||||
|
|
||||||
glr_stack_item* asItem ()
|
glr_stack_item* asItem ()
|
||||||
{]b4_parse_assert_if([[
|
{]b4_parse_assert_if([[
|
||||||
@@ -1015,15 +1018,17 @@ namespace ]b4_namespace_ref[
|
|||||||
// A magic number to check our pointer arithmetic is sane.
|
// A magic number to check our pointer arithmetic is sane.
|
||||||
enum { MAGIC = 713705 };
|
enum { MAGIC = 713705 };
|
||||||
unsigned int magic_;]])[
|
unsigned int magic_;]])[
|
||||||
};
|
}; // class ]b4_parser_class[::glr_state
|
||||||
} // namespace ]b4_namespace_ref[
|
} // namespace ]b4_namespace_ref[
|
||||||
|
|
||||||
|
|
||||||
/** A stack of GLRState representing the different heads during
|
namespace
|
||||||
* nondeterministic evaluation. */
|
|
||||||
class glr_state_set
|
|
||||||
{
|
{
|
||||||
public:
|
/** A stack of GLRState representing the different heads during
|
||||||
|
* nondeterministic evaluation. */
|
||||||
|
class glr_state_set
|
||||||
|
{
|
||||||
|
public:
|
||||||
/** Initialize YYSET to a singleton set containing an empty stack. */
|
/** Initialize YYSET to a singleton set containing an empty stack. */
|
||||||
glr_state_set ()
|
glr_state_set ()
|
||||||
: yylastDeleted (YY_NULLPTR)
|
: yylastDeleted (YY_NULLPTR)
|
||||||
@@ -1143,7 +1148,7 @@ public:
|
|||||||
yylastDeleted = YY_NULLPTR;
|
yylastDeleted = YY_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::vector<glr_state*> yystates;
|
std::vector<glr_state*> yystates;
|
||||||
/** During nondeterministic operation, yylookaheadNeeds tracks which
|
/** During nondeterministic operation, yylookaheadNeeds tracks which
|
||||||
@@ -1154,7 +1159,8 @@ private:
|
|||||||
|
|
||||||
/** The last stack we invalidated. */
|
/** The last stack we invalidated. */
|
||||||
glr_state* yylastDeleted;
|
glr_state* yylastDeleted;
|
||||||
};
|
}; // class glr_state_set
|
||||||
|
} // namespace
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -1411,15 +1417,17 @@ namespace
|
|||||||
// A magic number to check our pointer arithmetic is sane.
|
// A magic number to check our pointer arithmetic is sane.
|
||||||
enum { MAGIC = 0xeff1cace };
|
enum { MAGIC = 0xeff1cace };
|
||||||
unsigned int magic_;]])[
|
unsigned int magic_;]])[
|
||||||
};
|
}; // class semantic_option
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
/** Type of the items in the GLR stack.
|
namespace
|
||||||
|
{
|
||||||
|
/** Type of the items in the GLR stack.
|
||||||
* It can be either a glr_state or a semantic_option. The is_state_ field
|
* It can be either a glr_state or a semantic_option. The is_state_ field
|
||||||
* indicates which item of the union is valid. */
|
* indicates which item of the union is valid. */
|
||||||
class glr_stack_item
|
class glr_stack_item
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
glr_stack_item (bool state = true)
|
glr_stack_item (bool state = true)
|
||||||
: is_state_ (state)]b4_parse_assert_if([[
|
: is_state_ (state)]b4_parse_assert_if([[
|
||||||
, magic_ (MAGIC)]])[
|
, magic_ (MAGIC)]])[
|
||||||
@@ -1511,7 +1519,7 @@ public:
|
|||||||
return is_state_;
|
return is_state_;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// The possible contents of raw_. Since they have constructors, they cannot
|
/// The possible contents of raw_. Since they have constructors, they cannot
|
||||||
/// be directly included in the union.
|
/// be directly included in the union.
|
||||||
union contents
|
union contents
|
||||||
@@ -1529,7 +1537,7 @@ private:
|
|||||||
/** Type tag for the union. */
|
/** Type tag for the union. */
|
||||||
bool is_state_;
|
bool is_state_;
|
||||||
]b4_parse_assert_if([[
|
]b4_parse_assert_if([[
|
||||||
public:
|
public:
|
||||||
// Check invariants.
|
// Check invariants.
|
||||||
void check_ () const
|
void check_ () const
|
||||||
{
|
{
|
||||||
@@ -1539,7 +1547,8 @@ public:
|
|||||||
// A magic number to check our pointer arithmetic is sane.
|
// A magic number to check our pointer arithmetic is sane.
|
||||||
enum { MAGIC = 0xDEAD1ACC }; // 3735886540.
|
enum { MAGIC = 0xDEAD1ACC }; // 3735886540.
|
||||||
const unsigned int magic_;]])[
|
const unsigned int magic_;]])[
|
||||||
};
|
}; // class glr_stack_item
|
||||||
|
} // namespace
|
||||||
|
|
||||||
glr_state* glr_state::pred ()
|
glr_state* glr_state::pred ()
|
||||||
{]b4_parse_assert_if([[
|
{]b4_parse_assert_if([[
|
||||||
|
|||||||
Reference in New Issue
Block a user