Consolidate logic for making shared pointers to rules
This commit is contained in:
parent
9f78d72a7c
commit
6f444fcc79
22 changed files with 113 additions and 94 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue