Function chumsky::pratt::postfix

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

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

Operators like factorial, field access, function composition, etc. are postfix 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 operand and the operator itself
impl Fn(O, Op) -> O
// Combine the operand, the operator itself, and the span that covers the whole operation
impl Fn(Op, O, I::Span) -> O