Compare contents in ATNConfig::operator==

This commit is contained in:
Nathan Burles 2016-08-01 16:25:37 +01:00
parent d089c8d864
commit a025c9eefc
2 changed files with 8 additions and 4 deletions

View File

@ -101,14 +101,17 @@ void ATNConfig::setPrecedenceFilterSuppressed(bool value) {
}
}
bool ATNConfig::operator == (const ATNConfig &other) const
{
bool ATNConfig::operator == (const ATNConfig &other) const {
return state->stateNumber == other.state->stateNumber && alt == other.alt &&
(context == other.context || (context != nullptr && context == other.context)) &&
semanticContext == other.semanticContext &&
(context == other.context || (context != nullptr && *context == *(other.context))) &&
(semanticContext == other.semanticContext || (semanticContext != nullptr && *semanticContext == *(other.semanticContext))) &&
isPrecedenceFilterSuppressed() == other.isPrecedenceFilterSuppressed();
}
bool ATNConfig::operator != (const ATNConfig &other) const {
return !operator==(other);
}
std::string ATNConfig::toString() {
return toString(true);
}

View File

@ -129,6 +129,7 @@ namespace atn {
/// the same state, they predict the same alternative, and
/// syntactic/semantic contexts are the same.
bool operator == (const ATNConfig &other) const;
bool operator != (const ATNConfig &other) const;
virtual std::string toString();
std::string toString(bool showAlt);