Header lexy/dsl/sequence.hpp
Rule lexy::dsl::operator+
lexy/dsl/sequence.hppnamespace lexy::dsl
{
constexpr rule auto operator+(rule auto lhs, rule auto rhs);
}operator+ (sequence) is a rule that parses multiple rules one after the other.
- Parsing
Parses
lhs, then parsesrhs.- Errors
All errors raised by
lhsand/orrhs. The rule fails if either of them has failed.- Values
All values produced from
rhsfollowed by all values produced byrhs.
Example 1. Sequence rule is used practically all the time
struct name
{
static constexpr auto rule
// One or more alpha numeric characters, underscores or hyphens.
= dsl::identifier(dsl::unicode::alnum / dsl::lit_c<'_'> / dsl::lit_c<'-'>);
};
struct production
{
// Allow arbitrary spaces between individual tokens.
static constexpr auto whitespace = dsl::ascii::space;
static constexpr auto rule = [] {
auto greeting = LEXY_LIT("Hello");
return greeting + dsl::p<name> + dsl::exclamation_mark + dsl::eof;
}();
};