Header lexy/dsl/parse_as.hpp
Branch rule lexy::dsl::parse_as
lexy/dsl/parse_as.hpp
namespace 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
rule
unchanged.- Errors
All errors raised by
rule
. The rule then fails ifrule
has failed.- Values
Value production is done as if the parse action
lexy::parse
was used, regardless of the actual parse action used in the top-level. Ifrule
parses a child productionP
, it invokes theP::value
callback as necessary to produce a value. When the rule succeeds, all arguments produced byrule
are passed tolexy::construct<T>
and produces that as its single value.
Tip | Use this rule as a branch condition for a lexy::scan_production . |