Move rule transitions to visitor class

This commit is contained in:
Max Brunsfeld 2013-12-18 20:58:05 -08:00
parent 84a7afbca5
commit b1bbeae2a1
29 changed files with 205 additions and 125 deletions

View file

@ -1,7 +1,4 @@
#include "blank.h"
#include "seq.h"
#include "choice.h"
#include "repeat.h"
#include "rules.h"
#include "transition_map.h"
namespace tree_sitter {
@ -12,12 +9,6 @@ namespace tree_sitter {
return std::make_shared<Repeat>(content);
}
TransitionMap<Rule> Repeat::transitions() const {
return content->transitions().map<Rule>([&](const rule_ptr &value) -> rule_ptr {
return seq({ value, choice({ repeat(content), blank() }) });
});
}
bool Repeat::operator==(const Rule &rule) const {
const Repeat *other = dynamic_cast<const Repeat *>(&rule);
return other && (*other->content == *content);
@ -26,5 +17,9 @@ namespace tree_sitter {
std::string Repeat::to_string() const {
return std::string("(repeat ") + content->to_string() + ")";
}
void Repeat::accept(RuleVisitor &visitor) const {
visitor.visit(this);
}
}
}