mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
LR0: Added ::Item::operator==
This commit is contained in:
parent
0d7c356bed
commit
c33e12f099
2 changed files with 16 additions and 0 deletions
15
src/LR0.cpp
15
src/LR0.cpp
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue