pub enum ArgShape {
Positional(usize),
StringThenParser,
OneString,
ParserWithSkip,
ParserWithOptionalCount,
GridMaybeRagged,
OnePositionalOrNamed,
Items,
NamedOnly {
at_least: usize,
},
}Expand description
The shape of a constructor call’s argument list (§7.5).
A count is not enough: sep takes a string and then a parser, choice
takes named arguments and no positional ones, chars takes a parser and an
optional keyword. Checking a positional arity alone would accept
optional(int, word) and choice(int).
Variants§
Positional(usize)
Exactly n positional parsers and nothing else.
StringThenParser
sep("s", P) — one string literal, then one parser.
OneString
one_of("LR") — one string literal.
ParserWithSkip
chars(P, skip: policy) — one parser and an optional skip: keyword.
ParserWithOptionalCount
repeated(P) or repeated(P, N) — one parser and an optional count
literal. The count must be a literal because the parser plan is built
when the program is compiled, so there is no runtime value in scope to
read one from.
GridMaybeRagged
grid(P) or grid(P, ragged, fill: value) — the ragged flag and the
fill value come as a pair or not at all.
OnePositionalOrNamed
sections(P) or sections(name: P, …) — the homogeneous and
heterogeneous forms are one name with two shapes.
Items
block(item, …) — one or more positional parsers and/or named items.
NamedOnly
choice(Name: P, …) — named arguments only, at least at_least of them.