Move shared rule pointer factories into individual rule files
This commit is contained in:
parent
8a0a442a24
commit
040ec86000
19 changed files with 102 additions and 76 deletions
|
|
@ -5,10 +5,14 @@ namespace tree_sitter {
|
|||
namespace rules {
|
||||
Choice::Choice(rule_ptr left, rule_ptr right) : left(left), right(right) {};
|
||||
|
||||
rule_ptr choice(const std::initializer_list<rule_ptr> &rules) {
|
||||
return build_binary_rule_tree<Choice>(rules);
|
||||
}
|
||||
|
||||
TransitionMap<Rule> Choice::transitions() const {
|
||||
auto result = left->transitions();
|
||||
result.merge(right->transitions(), [&](rule_ptr left, rule_ptr right) -> rule_ptr {
|
||||
return rule_ptr(new Choice(left, right));
|
||||
return choice({ left, right });
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue