2013-12-18 20:58:05 -08:00
|
|
|
#include "rules.h"
|
2013-11-15 08:46:45 -08:00
|
|
|
|
2013-12-19 23:05:54 -08:00
|
|
|
using std::string;
|
|
|
|
|
|
2013-11-15 08:46:45 -08:00
|
|
|
namespace tree_sitter {
|
|
|
|
|
namespace rules {
|
|
|
|
|
Repeat::Repeat(const rule_ptr content) : content(content) {}
|
|
|
|
|
|
|
|
|
|
bool Repeat::operator==(const Rule &rule) const {
|
|
|
|
|
const Repeat *other = dynamic_cast<const Repeat *>(&rule);
|
|
|
|
|
return other && (*other->content == *content);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-30 23:52:38 -08:00
|
|
|
size_t Repeat::hash_code() const {
|
|
|
|
|
return typeid(this).hash_code() ^ content->hash_code();
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-02 13:04:41 -08:00
|
|
|
rule_ptr Repeat::copy() const {
|
|
|
|
|
return std::make_shared<Repeat>(*this);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-19 23:05:54 -08:00
|
|
|
string Repeat::to_string() const {
|
2013-12-30 23:12:19 -08:00
|
|
|
return string("#<repeat ") + content->to_string() + ">";
|
2013-11-15 08:46:45 -08:00
|
|
|
}
|
2013-12-18 20:58:05 -08:00
|
|
|
|
2013-12-19 23:16:13 -08:00
|
|
|
void Repeat::accept(Visitor &visitor) const {
|
2013-12-18 20:58:05 -08:00
|
|
|
visitor.visit(this);
|
|
|
|
|
}
|
2013-11-15 08:46:45 -08:00
|
|
|
}
|
|
|
|
|
}
|