Put rule transitions in LR namespace
This commit is contained in:
parent
656f6b0819
commit
30315a78d2
10 changed files with 177 additions and 144 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue