diff --git a/spec/compiler/rules/choice_spec.cc b/spec/compiler/rules/choice_spec.cc index 36d1ddb0..b5c5e273 100644 --- a/spec/compiler/rules/choice_spec.cc +++ b/spec/compiler/rules/choice_spec.cc @@ -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"), }) }); diff --git a/src/compiler/build_tables/build_lex_table.cc b/src/compiler/build_tables/build_lex_table.cc index e41952a4..ac2155e1 100644 --- a/src/compiler/build_tables/build_lex_table.cc +++ b/src/compiler/build_tables/build_lex_table.cc @@ -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( separator_rule(), map( diff --git a/src/compiler/build_tables/rule_transitions.cc b/src/compiler/build_tables/rule_transitions.cc index cbc6c4c8..597aecd8 100644 --- a/src/compiler/build_tables/rule_transitions.cc +++ b/src/compiler/build_tables/rule_transitions.cc @@ -25,7 +25,7 @@ void merge_transitions(map *, const map &); 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 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(&result, this->apply(rule->right)); return result; @@ -81,7 +81,7 @@ class RuleTransitions : public rules::RuleFn> { map 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; } diff --git a/src/compiler/prepare_grammar/expand_repeats.cc b/src/compiler/prepare_grammar/expand_repeats.cc index 9e8f4349..4273d153 100644 --- a/src/compiler/prepare_grammar/expand_repeats.cc +++ b/src/compiler/prepare_grammar/expand_repeats.cc @@ -37,9 +37,9 @@ class ExpandRepeats : public rules::IdentityRuleFn { make_shared(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() }) }) }); - return Choice::Build({ repeat_symbol, make_shared() }); + return Choice::build({ repeat_symbol, make_shared() }); } public: diff --git a/src/compiler/prepare_grammar/expand_tokens.cc b/src/compiler/prepare_grammar/expand_tokens.cc index f52de48b..71fef522 100644 --- a/src/compiler/prepare_grammar/expand_tokens.cc +++ b/src/compiler/prepare_grammar/expand_tokens.cc @@ -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) { diff --git a/src/compiler/prepare_grammar/parse_regex.cc b/src/compiler/prepare_grammar/parse_regex.cc index 2d3e2414..d71e900c 100644 --- a/src/compiler/prepare_grammar/parse_regex.cc +++ b/src/compiler/prepare_grammar/parse_regex.cc @@ -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() }); + result = Choice::build({ result, make_shared() }); break; } } diff --git a/src/compiler/rules/choice.cc b/src/compiler/rules/choice.cc index 1e1580be..15b3e76c 100644 --- a/src/compiler/rules/choice.cc +++ b/src/compiler/rules/choice.cc @@ -27,7 +27,7 @@ void add_choice_element(vector *vec, const rule_ptr new_rule) { } } -rule_ptr Choice::Build(const vector &inputs) { +rule_ptr Choice::build(const vector &inputs) { vector elements; for (auto &el : inputs) add_choice_element(&elements, el); diff --git a/src/compiler/rules/choice.h b/src/compiler/rules/choice.h index 5f971db1..761ce8a7 100644 --- a/src/compiler/rules/choice.h +++ b/src/compiler/rules/choice.h @@ -11,7 +11,7 @@ namespace rules { class Choice : public Rule { public: explicit Choice(const std::vector &elements); - static rule_ptr Build(const std::vector &rules); + static rule_ptr build(const std::vector &rules); bool operator==(const Rule &other) const; size_t hash_code() const; diff --git a/src/compiler/rules/rules.cc b/src/compiler/rules/rules.cc index 41a3e966..d0970846 100644 --- a/src/compiler/rules/rules.cc +++ b/src/compiler/rules/rules.cc @@ -32,13 +32,13 @@ static rule_ptr metadata(rule_ptr rule, map values) { rule_ptr blank() { return make_shared(); } -rule_ptr choice(const vector &rules) { return Choice::Build(rules); } +rule_ptr choice(const vector &rules) { return Choice::build(rules); } rule_ptr repeat(const rule_ptr &content) { return std::make_shared(content); } -rule_ptr seq(const vector &rules) { return Seq::Build(rules); } +rule_ptr seq(const vector &rules) { return Seq::build(rules); } rule_ptr sym(const string &name) { return make_shared(name); } diff --git a/src/compiler/rules/seq.cc b/src/compiler/rules/seq.cc index d83ee0a1..bd5aa06b 100644 --- a/src/compiler/rules/seq.cc +++ b/src/compiler/rules/seq.cc @@ -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 &rules) { +rule_ptr Seq::build(const std::vector &rules) { rule_ptr result = make_shared(); for (auto &rule : rules) result = (typeid(*result) != typeid(Blank)) ? make_shared(result, rule) diff --git a/src/compiler/rules/seq.h b/src/compiler/rules/seq.h index fa625d06..29238848 100644 --- a/src/compiler/rules/seq.h +++ b/src/compiler/rules/seq.h @@ -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 &rules); + static rule_ptr build(const std::vector &rules); bool operator==(const Rule &other) const; size_t hash_code() const; diff --git a/src/compiler/rules/visitor.cc b/src/compiler/rules/visitor.cc index f0bdc3c3..da2e4c82 100644 --- a/src/compiler/rules/visitor.cc +++ b/src/compiler/rules/visitor.cc @@ -25,11 +25,11 @@ rule_ptr IdentityRuleFn::apply_to(const Choice *rule) { vector 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) {