Skip to main content

prefix

Create a prefix operator, given a binding power and a function that evaluates the node.

def prefix(
bp: int,
func: callable
) - > class

Create a prefix operator, given a binding power and a function that evaluates the node.

Parameters

NameTypeDescription
bpintThe binding power (precedence level) assigned to the prefix operator, determining how tightly it binds to the following expression.
funccallableA function used to evaluate the operator node; it should accept a context and the operand node, returning the result or False on failure.

Returns

TypeDescription
classA new Operator class inheriting from TokenBase that handles null denotation (nud) and evaluation logic for prefix operations.