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 {
|
||||
Symbol::Symbol(const std::string &name) : name(name) {};
|
||||
|
||||
rule_ptr sym(const std::string &name) {
|
||||
return std::make_shared<Symbol>(name);
|
||||
}
|
||||
|
||||
bool Symbol::operator==(const Rule &rule) const {
|
||||
const Symbol *other = dynamic_cast<const Symbol *>(&rule);
|
||||
return other && (other->name == name);
|
||||
}
|
||||
|
||||
std::string Symbol::to_string() const {
|
||||
return std::string("(sym '") + name + "')";
|
||||
string Symbol::to_string() const {
|
||||
return string("(sym '") + name + "')";
|
||||
}
|
||||
|
||||
void Symbol::accept(RuleVisitor &visitor) const {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue