Function chumsky::pratt::prefix

source ·
pub const fn prefix<A, F, Op, Args>(
    binding_power: u16,
    op_parser: A,
    fold: F
) -> Prefix<A, F, Op, Args>
Available on crate feature pratt only.
Expand description

Specify a unary prefix operator for a pratt parser with the given binding power and fold function.

Operators like negation, not, dereferencing, etc. are prefix unary operators in most languages.

The fold function (the last argument) must have one of the following signatures:

// Transform the operand
impl Fn(O) -> O
// Combine the operator itself and the operand
impl Fn(Op, O) -> O
// Combine the operator itself, the operand, and the span that covers the whole operation
impl Fn(Op, O, I::Span) -> O