Rename static 'Build' methods to 'build'
This commit is contained in:
parent
34d96909d1
commit
a0d9da9d5c
12 changed files with 22 additions and 22 deletions
|
|
@ -8,7 +8,7 @@ START_TEST
|
|||
describe("Choice", []() {
|
||||
describe("constructing choices", [&]() {
|
||||
it("eliminates duplicate members", [&]() {
|
||||
auto rule = Choice::Build({
|
||||
auto rule = Choice::build({
|
||||
seq({ sym("one"), sym("two") }),
|
||||
sym("three"),
|
||||
seq({ sym("one"), sym("two") })
|
||||
|
|
@ -21,9 +21,9 @@ describe("Choice", []() {
|
|||
});
|
||||
|
||||
it("eliminates duplicates within nested choices", [&]() {
|
||||
auto rule = Choice::Build({
|
||||
auto rule = Choice::build({
|
||||
seq({ sym("one"), sym("two") }),
|
||||
Choice::Build({
|
||||
Choice::build({
|
||||
sym("three"),
|
||||
seq({ sym("one"), sym("two") })
|
||||
})
|
||||
|
|
@ -36,9 +36,9 @@ describe("Choice", []() {
|
|||
});
|
||||
|
||||
it("doesn't construct a choice if there's only one unique member", [&]() {
|
||||
auto rule = Choice::Build({
|
||||
auto rule = Choice::build({
|
||||
sym("one"),
|
||||
Choice::Build({
|
||||
Choice::build({
|
||||
sym("one"),
|
||||
})
|
||||
});
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ class LexTableBuilder {
|
|||
}
|
||||
|
||||
rules::rule_ptr after_separators(rules::rule_ptr rule) {
|
||||
return rules::Seq::Build(
|
||||
return rules::Seq::build(
|
||||
{ make_shared<rules::Metadata>(
|
||||
separator_rule(),
|
||||
map<rules::MetadataKey, int>(
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ void merge_transitions(map<T, rule_ptr> *, const map<T, rule_ptr> &);
|
|||
|
||||
struct MergeAsChoice {
|
||||
void operator()(rule_ptr *left, const rule_ptr *right) {
|
||||
*left = Choice::Build({ *left, *right });
|
||||
*left = Choice::build({ *left, *right });
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ class RuleTransitions : public rules::RuleFn<map<T, rule_ptr>> {
|
|||
map<T, rule_ptr> apply_to(const rules::Seq *rule) {
|
||||
auto result = this->apply(rule->left);
|
||||
for (auto &pair : result)
|
||||
pair.second = rules::Seq::Build({ pair.second, rule->right });
|
||||
pair.second = rules::Seq::build({ pair.second, rule->right });
|
||||
if (rule_can_be_blank(rule->left))
|
||||
merge_transitions<T>(&result, this->apply(rule->right));
|
||||
return result;
|
||||
|
|
@ -81,7 +81,7 @@ class RuleTransitions : public rules::RuleFn<map<T, rule_ptr>> {
|
|||
map<T, rule_ptr> apply_to(const rules::Repeat *rule) {
|
||||
auto result = this->apply(rule->content);
|
||||
for (auto &pair : result)
|
||||
pair.second = rules::Seq::Build({ pair.second, rule->copy() });
|
||||
pair.second = rules::Seq::build({ pair.second, rule->copy() });
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@ class ExpandRepeats : public rules::IdentityRuleFn {
|
|||
make_shared<Symbol>(offset + index, rules::SymbolOptionAuxiliary);
|
||||
aux_rules.push_back(
|
||||
{ helper_rule_name,
|
||||
Seq::Build({ inner_rule, Choice::Build({ repeat_symbol,
|
||||
Seq::build({ inner_rule, Choice::build({ repeat_symbol,
|
||||
make_shared<Blank>() }) }) });
|
||||
return Choice::Build({ repeat_symbol, make_shared<Blank>() });
|
||||
return Choice::build({ repeat_symbol, make_shared<Blank>() });
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class ExpandTokens : public rules::IdentityRuleFn {
|
|||
elements.push_back(rules::CharacterSet().include(el).copy());
|
||||
}
|
||||
|
||||
return rules::Seq::Build(elements);
|
||||
return rules::Seq::build(elements);
|
||||
}
|
||||
|
||||
rule_ptr apply_to(const Pattern *rule) {
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class PatternParser {
|
|||
auto pair = factor();
|
||||
if (pair.second)
|
||||
return { blank(), pair.second };
|
||||
result = Seq::Build({ result, pair.first });
|
||||
result = Seq::build({ result, pair.first });
|
||||
} while (has_more_input());
|
||||
return { result, nullptr };
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ class PatternParser {
|
|||
break;
|
||||
case '?':
|
||||
next();
|
||||
result = Choice::Build({ result, make_shared<Blank>() });
|
||||
result = Choice::build({ result, make_shared<Blank>() });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ void add_choice_element(vector<rule_ptr> *vec, const rule_ptr new_rule) {
|
|||
}
|
||||
}
|
||||
|
||||
rule_ptr Choice::Build(const vector<rule_ptr> &inputs) {
|
||||
rule_ptr Choice::build(const vector<rule_ptr> &inputs) {
|
||||
vector<rule_ptr> elements;
|
||||
for (auto &el : inputs)
|
||||
add_choice_element(&elements, el);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace rules {
|
|||
class Choice : public Rule {
|
||||
public:
|
||||
explicit Choice(const std::vector<rule_ptr> &elements);
|
||||
static rule_ptr Build(const std::vector<rule_ptr> &rules);
|
||||
static rule_ptr build(const std::vector<rule_ptr> &rules);
|
||||
|
||||
bool operator==(const Rule &other) const;
|
||||
size_t hash_code() const;
|
||||
|
|
|
|||
|
|
@ -32,13 +32,13 @@ static rule_ptr metadata(rule_ptr rule, map<MetadataKey, int> values) {
|
|||
|
||||
rule_ptr blank() { return make_shared<Blank>(); }
|
||||
|
||||
rule_ptr choice(const vector<rule_ptr> &rules) { return Choice::Build(rules); }
|
||||
rule_ptr choice(const vector<rule_ptr> &rules) { return Choice::build(rules); }
|
||||
|
||||
rule_ptr repeat(const rule_ptr &content) {
|
||||
return std::make_shared<Repeat>(content);
|
||||
}
|
||||
|
||||
rule_ptr seq(const vector<rule_ptr> &rules) { return Seq::Build(rules); }
|
||||
rule_ptr seq(const vector<rule_ptr> &rules) { return Seq::build(rules); }
|
||||
|
||||
rule_ptr sym(const string &name) { return make_shared<NamedSymbol>(name); }
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ using std::vector;
|
|||
|
||||
Seq::Seq(rule_ptr left, rule_ptr right) : left(left), right(right) {}
|
||||
|
||||
rule_ptr Seq::Build(const std::vector<rule_ptr> &rules) {
|
||||
rule_ptr Seq::build(const std::vector<rule_ptr> &rules) {
|
||||
rule_ptr result = make_shared<Blank>();
|
||||
for (auto &rule : rules)
|
||||
result = (typeid(*result) != typeid(Blank)) ? make_shared<Seq>(result, rule)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace rules {
|
|||
class Seq : public Rule {
|
||||
public:
|
||||
Seq(rule_ptr left, rule_ptr right);
|
||||
static rule_ptr Build(const std::vector<rule_ptr> &rules);
|
||||
static rule_ptr build(const std::vector<rule_ptr> &rules);
|
||||
|
||||
bool operator==(const Rule &other) const;
|
||||
size_t hash_code() const;
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@ rule_ptr IdentityRuleFn::apply_to(const Choice *rule) {
|
|||
vector<rule_ptr> rules;
|
||||
for (const auto &el : rule->elements)
|
||||
rules.push_back(apply(el));
|
||||
return Choice::Build(rules);
|
||||
return Choice::build(rules);
|
||||
}
|
||||
|
||||
rule_ptr IdentityRuleFn::apply_to(const Seq *rule) {
|
||||
return Seq::Build({ apply(rule->left), apply(rule->right) });
|
||||
return Seq::build({ apply(rule->left), apply(rule->right) });
|
||||
}
|
||||
|
||||
rule_ptr IdentityRuleFn::apply_to(const Repeat *rule) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue