Function chumsky::pratt::infix

source ·
pub const fn infix<A, F, Op, Args>(
    associativity: Associativity,
    op_parser: A,
    fold: F
) -> Infix<A, F, Op, Args>
Available on crate feature pratt only.
Expand description

Specify a binary infix operator for a pratt parser with the given associativity, binding power, and fold function.

Operators like addition, subtraction, multiplication, division, remainder, exponentiation, etc. are infix binary operators in most languages.

See left and right for information about associativity.

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

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