Header lexy/dsl/parse_as.hpp

Branch rule lexy::dsl::parse_as

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.


All errors raised by rule. The rule then fails if rule has failed.


Value production is done as if the parse action lexy::parse  was used, regardless of the actual parse action used in the top-level. If rule parses a child production P, it invokes the P::value callback as necessary to produce a value. When the rule succeeds, all arguments produced by rule are passed to lexy::construct<T> and produces that as its single value.

Use this rule as a branch condition for a lexy::scan_production .

See also