Move rule transitions to visitor class
This commit is contained in:
parent
84a7afbca5
commit
b1bbeae2a1
29 changed files with 205 additions and 125 deletions
|
|
@ -1,5 +1,4 @@
|
|||
#include "symbol.h"
|
||||
#include "blank.h"
|
||||
#include "rules.h"
|
||||
#include "transition_map.h"
|
||||
|
||||
namespace tree_sitter {
|
||||
|
|
@ -10,10 +9,6 @@ namespace tree_sitter {
|
|||
return std::make_shared<Symbol>(name);
|
||||
}
|
||||
|
||||
TransitionMap<Rule> Symbol::transitions() const {
|
||||
return TransitionMap<Rule>({{ sym(name) , blank() }});
|
||||
}
|
||||
|
||||
bool Symbol::operator==(const Rule &rule) const {
|
||||
const Symbol *other = dynamic_cast<const Symbol *>(&rule);
|
||||
return other && (other->name == name);
|
||||
|
|
@ -22,5 +17,9 @@ namespace tree_sitter {
|
|||
std::string Symbol::to_string() const {
|
||||
return std::string("(sym '") + name + "')";
|
||||
}
|
||||
|
||||
void Symbol::accept(RuleVisitor &visitor) const {
|
||||
visitor.visit(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue