mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
glr2.cc: semantic_option: use a symbol
* data/skeletons/c++.m4 (basic_symbol): Add assignment operators. * data/skeletons/glr2.cc (semantic_option): Replace yytoken, yyvalue and yylocation by yyla.
This commit is contained in:
@@ -347,6 +347,17 @@ m4_define([b4_symbol_type_define],
|
|||||||
}
|
}
|
||||||
|
|
||||||
]b4_glr2_cc_if([[
|
]b4_glr2_cc_if([[
|
||||||
|
/// Copy assignment.
|
||||||
|
basic_symbol& operator= (const basic_symbol& that)
|
||||||
|
{
|
||||||
|
Base::operator= (that);]b4_variant_if([[
|
||||||
|
]b4_symbol_variant([this->kind ()], [value], [copy],
|
||||||
|
[that.value])], [[
|
||||||
|
value = that.value]])[;]b4_locations_if([[
|
||||||
|
location = that.location;]])[
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/// Move assignment.
|
/// Move assignment.
|
||||||
basic_symbol& operator= (basic_symbol&& that)
|
basic_symbol& operator= (basic_symbol&& that)
|
||||||
{
|
{
|
||||||
@@ -438,6 +449,9 @@ m4_define([b4_symbol_type_define],
|
|||||||
by_kind (const by_kind& that);
|
by_kind (const by_kind& that);
|
||||||
|
|
||||||
]b4_glr2_cc_if([[
|
]b4_glr2_cc_if([[
|
||||||
|
/// Copy assignment.
|
||||||
|
by_kind& operator= (const by_kind& that);
|
||||||
|
|
||||||
/// Move assignment.
|
/// Move assignment.
|
||||||
by_kind& operator= (by_kind&& that);
|
by_kind& operator= (by_kind&& that);
|
||||||
]])[
|
]])[
|
||||||
@@ -571,6 +585,13 @@ m4_define([b4_public_types_define],
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
]b4_glr2_cc_if([[
|
]b4_glr2_cc_if([[
|
||||||
|
]b4_inline([$1])]b4_parser_class[::by_kind&
|
||||||
|
b4_parser_class[::by_kind::by_kind::operator= (const by_kind& that)
|
||||||
|
{
|
||||||
|
kind_ = that.kind_;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
]b4_inline([$1])]b4_parser_class[::by_kind&
|
]b4_inline([$1])]b4_parser_class[::by_kind&
|
||||||
b4_parser_class[::by_kind::by_kind::operator= (by_kind&& that)
|
b4_parser_class[::by_kind::by_kind::operator= (by_kind&& that)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -780,6 +780,7 @@ namespace
|
|||||||
using glr_state = parser_type::glr_state;
|
using glr_state = parser_type::glr_state;
|
||||||
using symbol_kind = parser_type::symbol_kind;
|
using symbol_kind = parser_type::symbol_kind;
|
||||||
using symbol_kind_type = parser_type::symbol_kind_type;
|
using symbol_kind_type = parser_type::symbol_kind_type;
|
||||||
|
using symbol_type = parser_type::symbol_type;
|
||||||
using value_type = parser_type::value_type;]b4_locations_if([[
|
using value_type = parser_type::value_type;]b4_locations_if([[
|
||||||
using location_type = parser_type::location_type;]])[
|
using location_type = parser_type::location_type;]])[
|
||||||
|
|
||||||
@@ -1171,9 +1172,7 @@ namespace
|
|||||||
: yyrule (0)
|
: yyrule (0)
|
||||||
, yystate (0)
|
, yystate (0)
|
||||||
, yynext (0)
|
, yynext (0)
|
||||||
, yytoken (]b4_symbol(empty, kind)[)
|
, yyla ()]b4_parse_assert_if([[
|
||||||
, yyval ()]b4_locations_if([[
|
|
||||||
, yyloc ()]])[]b4_parse_assert_if([[
|
|
||||||
, magic_ (MAGIC)]])[
|
, magic_ (MAGIC)]])[
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@@ -1181,9 +1180,7 @@ namespace
|
|||||||
: yyrule (rule)
|
: yyrule (rule)
|
||||||
, yystate (0)
|
, yystate (0)
|
||||||
, yynext (0)
|
, yynext (0)
|
||||||
, yytoken (]b4_symbol(empty, kind)[)
|
, yyla ()]b4_parse_assert_if([[
|
||||||
, yyval ()]b4_locations_if([[
|
|
||||||
, yyloc ()]])[]b4_parse_assert_if([[
|
|
||||||
, magic_ (MAGIC)]])[
|
, magic_ (MAGIC)]])[
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@@ -1191,14 +1188,10 @@ namespace
|
|||||||
: yyrule (that.yyrule)
|
: yyrule (that.yyrule)
|
||||||
, yystate (that.yystate)
|
, yystate (that.yystate)
|
||||||
, yynext (that.yynext)
|
, yynext (that.yynext)
|
||||||
, yytoken (that.yytoken)
|
, yyla (that.yyla)]b4_parse_assert_if([[
|
||||||
, yyval (]b4_variant_if([], [[that.yyval]])[)]b4_locations_if([[
|
|
||||||
, yyloc (that.yyloc)]])[]b4_parse_assert_if([[
|
|
||||||
, magic_ (MAGIC)]])[
|
, magic_ (MAGIC)]])[
|
||||||
{]b4_parse_assert_if([[
|
{]b4_parse_assert_if([[
|
||||||
that.check_ ();]])[]b4_variant_if([[
|
that.check_ ();]])[
|
||||||
]b4_symbol_variant([yytoken],
|
|
||||||
[yyval], [copy], [that.yyval])])[
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed for the assignment in yynewSemanticOption.
|
// Needed for the assignment in yynewSemanticOption.
|
||||||
@@ -1209,11 +1202,7 @@ namespace
|
|||||||
yyrule = that.yyrule;
|
yyrule = that.yyrule;
|
||||||
yystate = that.yystate;
|
yystate = that.yystate;
|
||||||
yynext = that.yynext;
|
yynext = that.yynext;
|
||||||
yytoken = that.yytoken;]b4_variant_if([[
|
yyla = that.yyla;
|
||||||
]b4_symbol_variant([yytoken],
|
|
||||||
[yyval], [copy], [that.yyval])], [[
|
|
||||||
yyval = that.yyval;]])[]b4_locations_if([[
|
|
||||||
yyloc = that.yyloc;]])[
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1395,9 +1384,7 @@ namespace
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/** The lookahead for this reduction. */
|
/** The lookahead for this reduction. */
|
||||||
symbol_kind_type yytoken;
|
symbol_type yyla;
|
||||||
value_type yyval;]b4_locations_if([[
|
|
||||||
location_type yyloc;]])[
|
|
||||||
|
|
||||||
]b4_parse_assert_if([[
|
]b4_parse_assert_if([[
|
||||||
public:
|
public:
|
||||||
@@ -2339,19 +2326,12 @@ b4_dollar_popdef])[]dnl
|
|||||||
yyaddDeferredAction (state_set_index yyk, glr_state* yystate,
|
yyaddDeferredAction (state_set_index yyk, glr_state* yystate,
|
||||||
glr_state* yyrhs, rule_num yyrule)
|
glr_state* yyrhs, rule_num yyrule)
|
||||||
{
|
{
|
||||||
semantic_option& yynewOption =
|
semantic_option& yyopt = yystateStack.yynewSemanticOption (semantic_option (yyrule));
|
||||||
yystateStack.yynewSemanticOption (semantic_option (yyrule));
|
yyopt.setState (yyrhs);
|
||||||
yynewOption.setState(yyrhs);
|
yyopt.setNext (yystate->firstVal ());
|
||||||
yynewOption.setNext(yystate->firstVal());
|
if (yystateStack.yytops.lookaheadNeeds (yyk))
|
||||||
if (yystateStack.yytops.lookaheadNeeds(yyk))
|
yyopt.yyla = this->yyla;
|
||||||
{
|
yystate->setFirstVal (&yyopt);
|
||||||
yynewOption.yytoken = this->yyla.kind ();]b4_variant_if([[
|
|
||||||
]b4_symbol_variant([this->yyla.kind ()],
|
|
||||||
[yynewOption.yyval], [copy], [this->yyla.value])], [[
|
|
||||||
yynewOption.yyval = this->yyla.value;]])[]b4_locations_if([
|
|
||||||
yynewOption.yyloc = this->yyla.location;])[
|
|
||||||
}
|
|
||||||
yystate->setFirstVal (&yynewOption);
|
|
||||||
|
|
||||||
yyreserveGlrStack ();
|
yyreserveGlrStack ();
|
||||||
}
|
}
|
||||||
@@ -3003,16 +2983,11 @@ b4_dollar_popdef])[]dnl
|
|||||||
yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].getState().yyloc = yyoptState->yyloc;]])[
|
yyrhsVals[YYMAXRHS + YYMAXLEFT - 1].getState().yyloc = yyoptState->yyloc;]])[
|
||||||
{
|
{
|
||||||
symbol_type yyla_current = std::move (this->yyla);
|
symbol_type yyla_current = std::move (this->yyla);
|
||||||
this->yyla.kind_ = yyopt.yytoken;]b4_variant_if([[
|
this->yyla = std::move (yyopt.yyla);
|
||||||
]b4_symbol_variant([this->yyla.kind ()],
|
|
||||||
[this->yyla.value], [move], [yyopt.yyval])], [[
|
|
||||||
this->yyla.value = yyopt.yyval;]])[]b4_locations_if([
|
|
||||||
this->yyla.location = yyopt.yyloc;])[
|
|
||||||
yyflag = yyuserAction (yyopt.yyrule, yynrhs,
|
yyflag = yyuserAction (yyopt.yyrule, yynrhs,
|
||||||
yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
|
yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
|
||||||
create_state_set_index (-1),
|
create_state_set_index (-1),
|
||||||
yyvalp]b4_locations_if([, yylocp])[);
|
yyvalp]b4_locations_if([, yylocp])[);
|
||||||
|
|
||||||
this->yyla = std::move (yyla_current);
|
this->yyla = std::move (yyla_current);
|
||||||
}
|
}
|
||||||
return yyflag;
|
return yyflag;
|
||||||
|
|||||||
Reference in New Issue
Block a user