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,4 +1,4 @@
|
|||
#include "choice.h"
|
||||
#include "rules.h"
|
||||
#include "transition_map.h"
|
||||
|
||||
namespace tree_sitter {
|
||||
|
|
@ -12,14 +12,6 @@ namespace tree_sitter {
|
|||
return result;
|
||||
}
|
||||
|
||||
TransitionMap<Rule> Choice::transitions() const {
|
||||
auto result = left->transitions();
|
||||
result.merge(right->transitions(), [&](rule_ptr left, rule_ptr right) -> rule_ptr {
|
||||
return choice({ left, right });
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Choice::operator==(const Rule &rule) const {
|
||||
const Choice *other = dynamic_cast<const Choice *>(&rule);
|
||||
return other && (*other->left == *left) && (*other->right == *right);
|
||||
|
|
@ -28,5 +20,9 @@ namespace tree_sitter {
|
|||
std::string Choice::to_string() const {
|
||||
return std::string("(choice ") + left->to_string() + " " + right->to_string() + ")";
|
||||
}
|
||||
|
||||
void Choice::accept(RuleVisitor &visitor) const {
|
||||
visitor.visit(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue