2013-11-10 14:24:25 -08:00
|
|
|
#include "grammar.h"
|
|
|
|
|
|
|
|
|
|
namespace tree_sitter {
|
2013-11-13 20:22:06 -08:00
|
|
|
Grammar::Grammar(const rule_map_init_list &rules) :
|
2013-11-10 14:24:25 -08:00
|
|
|
rules(rules),
|
2013-11-13 20:22:06 -08:00
|
|
|
start_rule_name(rules.begin()->first) {}
|
2013-11-12 18:37:02 -08:00
|
|
|
|
2013-11-13 20:22:06 -08:00
|
|
|
const rules::rule_ptr Grammar::rule(const std::string &name) {
|
|
|
|
|
auto iter = rules.find(name);
|
|
|
|
|
return (iter == rules.end()) ?
|
|
|
|
|
rules::rule_ptr(nullptr) :
|
|
|
|
|
iter->second;
|
2013-11-10 14:24:25 -08:00
|
|
|
}
|
|
|
|
|
}
|