Put rule transitions in LR namespace

This commit is contained in:
Max Brunsfeld 2013-12-28 23:26:20 -08:00
parent 656f6b0819
commit 30315a78d2
10 changed files with 177 additions and 144 deletions

View file

@ -1,25 +0,0 @@
#include "grammar.h"
using namespace std;
namespace tree_sitter {
Grammar::Grammar(const rule_map_init_list &rules) :
rules(rules),
start_rule_name(rules.begin()->first) {}
const rules::rule_ptr Grammar::rule(const std::string &name) const {
auto iter = rules.find(name);
return (iter == rules.end()) ?
rules::rule_ptr(nullptr) :
iter->second;
}
vector<string> Grammar::rule_names() const {
vector<string> result;
for (auto pair : rules) {
result.push_back(pair.first);
}
return result;
}
}