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 = "..." (override the BNF rule name) and hidden/inline (as for #[derive(Grammar)]); validated is not supported — reject the value from the conversion’s own Err instead.