tree-sitter/src/compiler/rules/rules.cc

53 lines
1.3 KiB
C++
Raw Normal View History

#include "tree_sitter/compiler.h"
2014-03-09 21:37:21 -07:00
#include "compiler/rules/rule.h"
#include "compiler/rules/blank.h"
#include "compiler/rules/symbol.h"
#include "compiler/rules/choice.h"
#include "compiler/rules/seq.h"
#include "compiler/rules/string.h"
#include "compiler/rules/pattern.h"
#include "compiler/rules/character_set.h"
#include "compiler/rules/repeat.h"
#include "compiler/rules/built_in_symbols.h"
namespace tree_sitter {
using std::make_shared;
using std::string;
using std::set;
using std::vector;
2014-03-09 19:49:35 -07:00
namespace rules {
rule_ptr blank() {
return make_shared<Blank>();
}
2014-03-09 19:49:35 -07:00
rule_ptr choice(const vector<rule_ptr> &rules) {
return Choice::Build(rules);
}
2014-03-09 19:49:35 -07:00
2014-02-21 08:23:20 -08:00
rule_ptr repeat(const rule_ptr &content) {
return std::make_shared<Repeat>(content);
}
2014-03-09 19:49:35 -07:00
rule_ptr seq(const vector<rule_ptr> &rules) {
return Seq::Build(rules);
}
2014-02-11 13:15:44 -08:00
rule_ptr sym(const string &name) {
return make_shared<Symbol>(name);
}
2014-02-21 08:23:20 -08:00
rule_ptr pattern(const string &value) {
return make_shared<Pattern>(value);
}
2014-03-09 19:49:35 -07:00
2014-02-21 08:23:20 -08:00
rule_ptr str(const string &value) {
return make_shared<String>(value);
}
2014-03-09 19:49:35 -07:00
2014-02-26 19:03:43 -08:00
rule_ptr err(const rule_ptr &rule) {
2014-03-28 13:51:32 -07:00
return choice({ rule, ERROR().copy() });
2014-02-26 19:03:43 -08:00
}
}
}