Fix bug in character rule equality

This commit is contained in:
Max Brunsfeld 2014-01-30 13:04:10 -08:00
parent 7f62e752be
commit 28e10dc722
2 changed files with 24 additions and 0 deletions

View file

@ -54,6 +54,7 @@ namespace tree_sitter {
bool Character::operator==(const Rule &rule) const {
const Character *other = dynamic_cast<const Character *>(&rule);
if (!other) return false;
if (other->sign != sign) return false;
auto size = matches.size();
if (other->matches.size() != size) return false;
for (int i = 0; i < size; i++)
@ -71,6 +72,7 @@ namespace tree_sitter {
string Character::to_string() const {
string prefix("#<char");
if (!sign) prefix += " (not)";
for (auto &match : matches)
prefix += " " + match.to_string();
return prefix + ">";