Users can define customization points with the logic to parse and store the results of grammar rules as part of the same library architecture. This allows arbitrary grammar logic in expressions that interact with the existing rules. Some use cases could include alternative or extended syntax for URLs and its components.
These new function overloads may be defined in other namespaces with the
tag_invoke
customization
point.
/* VFALCO This needs rewriting
struct lowercase_rule
{
urls::string_view str;
friend
void
tag_invoke(
urls::grammar::parse_tag const&,
char const*& it,
char const* const end,
urls::error_code& ec,
lowercase_rule& t) noexcept
{
ec = {};
char const* begin = it;
while (it != end && std::islower(*it))
{
++it;
}
t.str = urls::string_view(begin, it);
}
};
*/
Code |
Output |
---|---|
// VFALCO THIS NEEDS TO BE PORTED /* urls::string_view s = "http:somelowercase"; urls::scheme_rule r1; lowercase_rule r2; urls::error_code ec; if (urls::grammar::parse_string(s, ec, r1, ':', r2)) { std::cout << "scheme: " << r1.scheme << '\n'; std::cout << "lower: " << r2.str << '\n'; } */ |
scheme: http lower: somelowercase |