Consolidate logic for making shared pointers to rules

This commit is contained in:
Max Brunsfeld 2013-12-19 23:05:54 -08:00
parent 9f78d72a7c
commit 6f444fcc79
22 changed files with 113 additions and 94 deletions

View file

@ -1,21 +1,19 @@
#include "rules.h"
#include "transition_map.h"
using std::string;
namespace tree_sitter {
namespace rules {
Repeat::Repeat(const rule_ptr content) : content(content) {}
rule_ptr repeat(const rule_ptr content) {
return std::make_shared<Repeat>(content);
}
bool Repeat::operator==(const Rule &rule) const {
const Repeat *other = dynamic_cast<const Repeat *>(&rule);
return other && (*other->content == *content);
}
std::string Repeat::to_string() const {
return std::string("(repeat ") + content->to_string() + ")";
string Repeat::to_string() const {
return string("(repeat ") + content->to_string() + ")";
}
void Repeat::accept(RuleVisitor &visitor) const {