Header lexy/dsl/parse_as.hpp
Branch rule lexy::dsl::parse_as
lexy/dsl/parse_as.hppnamespace lexy::dsl
{
template <typename T>
constexpr rule auto parse_as(rule auto rule);
template <typename T>
constexpr branch-rule auto parse_as(branch-rule auto rule);
}parse_as is a branch rule that parses the rule and ensures that it always produces a value.
- (Branch) Parsing
Parses
ruleunchanged.- Errors
All errors raised by
rule. The rule then fails ifrulehas failed.- Values
Value production is done as if the parse action
lexy::parsewas used, regardless of the actual parse action used in the top-level. Ifruleparses a child productionP, it invokes theP::valuecallback as necessary to produce a value. When the rule succeeds, all arguments produced byruleare passed tolexy::construct<T>and produces that as its single value.
Tip | Use this rule as a branch condition for a lexy::scan_production. |