[#boost-urls-grammar-Rule] = xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/grammar.adoc[grammar]::Rule :relfileprefix: ../../../ :mrdocs: Concept for a grammar Rule == Synopsis Declared in `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/grammar/type_traits.hpp#Lundefined[boost/url/grammar/type_traits.hpp]>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class T> concept Rule = requires (T t, char const*& it, char const* end) { typename T::value_type; { t.parse(it, end) } ‐> std::same_as<system::result<typename T::value_type>>; }; ---- == Description This concept is satisfied if `T` is a valid grammar Rule A `Rule` defines an algorithm used to match an input buffer of ASCII characters against a set of syntactical specifications. Each rule represents either a terminal symbol or a composition in the represented grammar. The library comes with a set of rules for productions typically found in RFC documents. Rules are not invoked directly; instead, rule variables are used with overloads of xref:boost/urls/grammar/parse-09.adoc[`parse`] which provide a convenient, uniform front end. == Exemplar For best results, it is suggested that all constructors for rules be marked `constexpr`. [,cpp] ---- struct Rule { struct value_type; constexpr Rule( Rule const& ) noexcept = default; auto parse( char const*& it, char const* end ) const -> result< value_type >; }; // Declare a variable of type Rule for notational convenience constexpr Rule rule{}; ---- == Model * xref:boost/urls/grammar/dec_octet_rule.adoc[`dec_octet_rule`] * xref:boost/urls/grammar/delim_rule-0a.adoc[`delim_rule`] * xref:boost/urls/grammar/not_empty_rule.adoc[`not_empty_rule`] * xref:boost/urls/grammar/optional_rule.adoc[`optional_rule`] * xref:boost/urls/grammar/range_rule-02.adoc[`range_rule`] * xref:boost/urls/grammar/token_rule-00.adoc[`token_rule`] * xref:boost/urls/grammar/tuple_rule.adoc[`tuple_rule`] * xref:boost/urls/grammar/unsigned_rule.adoc[`unsigned_rule`] * xref:boost/urls/grammar/variant_rule.adoc[`variant_rule`] == See Also xref:boost/urls/grammar/parse-09.adoc[`parse`], xref:boost/urls/grammar/is_rule.adoc[`is_rule`]. [.small]#Created with https://www.mrdocs.com[MrDocs]#