LR0: Added ::Item::operator==

This commit is contained in:
Paul Beckingham 2016-01-05 01:48:38 -05:00
parent 0d7c356bed
commit c33e12f099
2 changed files with 16 additions and 0 deletions

View file

@ -225,6 +225,21 @@ LR0::Item::Item (const std::vector <std::string>& rule)
_rule.pop_back ();
}
////////////////////////////////////////////////////////////////////////////////
bool LR0::Item::operator== (const Item& other)
{
if (_cursor != other._cursor ||
_grammarRule != other._grammarRule ||
_rule.size () != other._rule.size ())
return false;
for (unsigned int i = 0; i < _rule.size () - 1; ++i)
if (_rule[i] != other._rule[i])
return false;
return true;
}
////////////////////////////////////////////////////////////////////////////////
void LR0::Item::setGrammarRuleIndex (const int rule)
{

View file

@ -45,6 +45,7 @@ public:
{
public:
Item (const std::vector <std::string>&);
bool operator== (const LR0::Item&);
void setGrammarRuleIndex (const int);
bool advance ();
bool done () const;