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,7 +1,5 @@
|
|||
#include "string.h"
|
||||
#include "rules.h"
|
||||
#include "transition_map.h"
|
||||
#include "char.h"
|
||||
#include "seq.h"
|
||||
|
||||
namespace tree_sitter {
|
||||
namespace rules {
|
||||
|
|
@ -11,13 +9,6 @@ namespace tree_sitter {
|
|||
return std::make_shared<String>(value);
|
||||
}
|
||||
|
||||
TransitionMap<Rule> String::transitions() const {
|
||||
rule_ptr result = character(value[0]);
|
||||
for (int i = 1; i < value.length(); i++)
|
||||
result = seq({ result, character(value[i]) });
|
||||
return result->transitions();
|
||||
}
|
||||
|
||||
bool String::operator==(const Rule &rule) const {
|
||||
const String *other = dynamic_cast<const String *>(&rule);
|
||||
return (other != NULL) && (other->value == value);
|
||||
|
|
@ -26,6 +17,9 @@ namespace tree_sitter {
|
|||
std::string String::to_string() const {
|
||||
return std::string("(string '") + value + "')";
|
||||
}
|
||||
|
||||
|
||||
void String::accept(RuleVisitor &visitor) const {
|
||||
visitor.visit(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue