diff --git a/src/compiler/build_tables/rule_transitions.cpp b/src/compiler/build_tables/rule_transitions.cpp index aa61bdad..3f6ec3e2 100644 --- a/src/compiler/build_tables/rule_transitions.cpp +++ b/src/compiler/build_tables/rule_transitions.cpp @@ -26,6 +26,14 @@ namespace tree_sitter { return choice({ left, right }); }); } + + template + transition_map map_transitions(const transition_map &initial, std::function map_fn) { + transition_map result; + for (auto &pair : initial) + result.add(pair.first, map_fn(pair.second)); + return result; + } template class TransitionsVisitor : public rules::Visitor { @@ -59,7 +67,7 @@ namespace tree_sitter { } void visit(const Seq *rule) { - value = transitions(rule->left).template map([&](const rule_ptr left_rule) -> rule_ptr { + value = map_transitions(transitions(rule->left), [&](const rule_ptr left_rule) -> rule_ptr { if (is_blank(left_rule)) return rule->right; else @@ -71,7 +79,7 @@ namespace tree_sitter { } void visit(const Repeat *rule) { - value = transitions(rule->content).template map([&](const rule_ptr &value) -> rule_ptr { + value = map_transitions(transitions(rule->content), [&](const rule_ptr &value) -> rule_ptr { return seq({ value, choice({ rule->copy(), blank() }) }); }); } diff --git a/src/compiler/build_tables/transition_map.h b/src/compiler/build_tables/transition_map.h index a9311eb4..3de5daa5 100644 --- a/src/compiler/build_tables/transition_map.h +++ b/src/compiler/build_tables/transition_map.h @@ -43,16 +43,6 @@ namespace tree_sitter { return TValuePtr(); } - template - transition_map map(std::function(TValuePtr)> map_fn) { - transition_map result; - for (pair_type pair : *this) { - auto new_value = map_fn(pair.second); - result.add(pair.first, new_value); - } - return result; - } - #pragma mark - Container typedef typename contents_type::const_iterator const_iterator;