Move rule transitions to visitor class

This commit is contained in:
Max Brunsfeld 2013-12-18 20:58:05 -08:00
parent 84a7afbca5
commit b1bbeae2a1
29 changed files with 205 additions and 125 deletions

View file

@ -1,5 +1,6 @@
#include "item.h"
#include "grammar.h"
#include "transitions.h"
#include <iostream>
@ -17,14 +18,14 @@ namespace tree_sitter {
}
TransitionMap<Item> Item::transitions() const {
return rule->transitions().map<Item>([&](rules::rule_ptr to_rule) {
return rules::transitions(rule).map<Item>([&](rules::rule_ptr to_rule) {
return std::make_shared<Item>(rule_name, to_rule, consumed_sym_count + 1);
});
};
vector<rules::sym_ptr> Item::next_symbols() const {
vector<rules::sym_ptr> result;
for (auto pair : rule->transitions()) {
for (auto pair : rules::transitions(rule)) {
shared_ptr<const rules::Symbol> sym = dynamic_pointer_cast<const rules::Symbol>(pair.first);
if (sym) result.push_back(sym);
}