Skip to main content

GrammarFromStr

Derive Macro GrammarFromStr 

Source
#[derive(GrammarFromStr)]
{
    // Attributes available to this derive:
    #[grammar]
}
Expand description

Grammar via GrammarFrom + FromStr on the matched text.

Parses GrammarFrom::Source, then calls Self::from_str on the exact substring it matched. Err backtracks the parse as if nothing had matched, and is traced under the trace/trace_pos features.

#[grammar(...)] here supports name = "...", hidden/inline, and validated (as for #[derive(Grammar)]) — Validate::validate runs after a successful conversion, independent of the conversion’s own Err. Since the conversion can also reject an otherwise-matching Source, the rule’s own BNF definition shows a side-condition marker.