glr2.cc: simplify

* data/skeletons/glr2.cc (glr_state_set::yyremoveDeletes): Use
vector::resize rather than vector::erase.
(glr_state::copyFrom): Merge into...
(glr_state::operator=): here.
Valentin wanted each assignment to be explicit, hence copyFrom rather
that operator=.  But in 0a82316e54
(glr2.cc: example: use objects (not pointers) to represent the AST),
in order to get real objects to be processed correctly, we had to
introduce the assignment operator.  Afterward, we also introduced a
full implementation of the copy-ctor, independent of copyFrom.  As a
result, today the only invocation of copyFrom is from the assignment
operator.  Simplify this.
This commit is contained in:
Akim Demaille
2020-12-26 07:30:45 +01:00
parent 734ce73bf2
commit 2a07cb0f2d

View File

@@ -822,12 +822,6 @@ public:
} }
glr_state& operator= (const glr_state& other) glr_state& operator= (const glr_state& other)
{
copyFrom (other);
return *this;
}
void copyFrom (const glr_state& other)
{]b4_parse_assert_if([[ {]b4_parse_assert_if([[
check_ (); check_ ();
other.check_ ();]])[ other.check_ ();]])[
@@ -842,6 +836,7 @@ public:
else else
setFirstVal (other.firstVal ());]b4_locations_if([[ setFirstVal (other.firstVal ());]b4_locations_if([[
yyloc = other.yyloc;]])[ yyloc = other.yyloc;]])[
return *this;
} }
/** Type tag for the semantic value. If true, yysval applies, otherwise /** Type tag for the semantic value. If true, yysval applies, otherwise
@@ -1060,9 +1055,8 @@ class glr_state_set
j += 1; j += 1;
} }
} }
yystates.erase (yystates.begin () + static_cast<std::ptrdiff_t> (newsize), yystates.end ()); yystates.resize (newsize);
yylookaheadNeeds.erase (yylookaheadNeeds.begin () + static_cast<std::ptrdiff_t> (newsize), yylookaheadNeeds.resize (newsize);
yylookaheadNeeds.end ());
} }