|
|
@@ -5,7 +5,7 @@
|
|
|
|
|
|
#include <abnf/literals.h>
|
|
|
|
|
|
-struct abnf::grammar::satisfies_result {
|
|
|
+struct abnf::grammar_base::satisfies_result {
|
|
|
satisfies_result(size_t read) : read(read), valid(true) {}
|
|
|
satisfies_result(bool valid) : valid(valid) {}
|
|
|
|
|
|
@@ -24,7 +24,7 @@ struct abnf::grammar::satisfies_result {
|
|
|
namespace abnf {
|
|
|
using namespace abnf::literals;
|
|
|
|
|
|
-grammar::rule_store const grammar::s_default_rules_{
|
|
|
+grammar_base::rule_store const grammar_base::s_default_rules_{
|
|
|
{"ALPHA", "%x41-5A"_range / "%x61-7A"_range},
|
|
|
{"DIGIT", "%x30-39"_range},
|
|
|
{"HEXDIG", "DIGIT"_ref / "%x41-46"_range / "%x61-66"_range},
|
|
|
@@ -63,15 +63,15 @@ reference::reference(std::string_view ref) {
|
|
|
}
|
|
|
|
|
|
template <>
|
|
|
-auto grammar::satisfies(std::string_view text, literal const & lit) const
|
|
|
+auto grammar_base::satisfies(std::string_view text, literal const & lit) const
|
|
|
-> satisfies_result {
|
|
|
if (text.starts_with(lit.value)) { return lit.value.size(); }
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
template <>
|
|
|
-auto grammar::satisfies(std::string_view text, char_range const & rng) const
|
|
|
- -> satisfies_result {
|
|
|
+auto grammar_base::satisfies(std::string_view text,
|
|
|
+ char_range const & rng) const -> satisfies_result {
|
|
|
if (code_point cp(text); cp >= rng.first && cp <= rng.last) {
|
|
|
return cp.width();
|
|
|
}
|
|
|
@@ -79,7 +79,7 @@ auto grammar::satisfies(std::string_view text, char_range const & rng) const
|
|
|
}
|
|
|
|
|
|
template <>
|
|
|
-auto grammar::satisfies(std::string_view text, reference const & ref) const
|
|
|
+auto grammar_base::satisfies(std::string_view text, reference const & ref) const
|
|
|
-> satisfies_result {
|
|
|
if (auto it = s_default_rules_.find(ref.value);
|
|
|
it != s_default_rules_.end()) {
|
|
|
@@ -89,7 +89,7 @@ auto grammar::satisfies(std::string_view text, reference const & ref) const
|
|
|
}
|
|
|
|
|
|
template <>
|
|
|
-auto grammar::satisfies(std::string_view text, repeated const & rep) const
|
|
|
+auto grammar_base::satisfies(std::string_view text, repeated const & rep) const
|
|
|
-> satisfies_result {
|
|
|
size_t count = 0;
|
|
|
satisfies_result result{true};
|
|
|
@@ -101,7 +101,7 @@ auto grammar::satisfies(std::string_view text, repeated const & rep) const
|
|
|
}
|
|
|
|
|
|
template <>
|
|
|
-auto grammar::satisfies(std::string_view text, one_of const & one_of) const
|
|
|
+auto grammar_base::satisfies(std::string_view text, one_of const & one_of) const
|
|
|
-> satisfies_result {
|
|
|
for (rule const & r : one_of.rules) {
|
|
|
std::string_view tmp = text;
|
|
|
@@ -110,7 +110,7 @@ auto grammar::satisfies(std::string_view text, one_of const & one_of) const
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
-auto grammar::satisfies(std::string_view & text, rule const & rule) const
|
|
|
+auto grammar_base::satisfies(std::string_view & text, rule const & rule) const
|
|
|
-> satisfies_result {
|
|
|
auto visitor = [this, &text](auto const & part) {
|
|
|
return satisfies(text, part);
|
|
|
@@ -130,6 +130,6 @@ auto grammar::satisfies(std::string_view & text, rule const & rule) const
|
|
|
}
|
|
|
|
|
|
bool grammar::satisfies(std::string_view text) const {
|
|
|
- return satisfies(text, base_rule_).valid;
|
|
|
+ return grammar_base::satisfies(text, base_rule_).valid;
|
|
|
}
|
|
|
}
|