Skip to content

This site describes solve-engine as it is on main: 2.43.0, which npm does not have yet. npm installs 2.40.0, so a page may show an answer that version does not give yet.

BindingPower

const BindingPower: {
Assignment: 10;
BitwiseAnd: 22;
BitwiseOr: 18;
BitwiseXor: 20;
Call: 80;
Comparison: 23;
Conditional: 24;
Conjunction: 16;
Exponent: 50;
LogicalAnd: 14;
LogicalOr: 12;
Lowest: 0;
Postfix: 70;
Prefix: 60;
Product: 40;
Shift: 27;
Sum: 30;
Uncertainty: 45;
};

Defined in: packages/engine/src/parser/BindingPower.ts:12

Named precedence levels for the Pratt parser, from loosest (Lowest) to tightest (Call) binding. A custom infix parselet compares its own binding power against the current expression’s to decide whether to consume the next operator (higher power binds tighter, e.g. * over +).

Package authors reference these when declaring an infix parselet in a package’s infixParselets. See the built-in packages for examples of picking an appropriate level (e.g. arithmetic +/- use Sum, *// use Product).

readonly Assignment: 10 = 10;
readonly BitwiseAnd: 22 = 22;
readonly BitwiseOr: 18 = 18;
readonly BitwiseXor: 20 = 20;
readonly Call: 80 = 80;
readonly Comparison: 23 = 23;
readonly Conditional: 24 = 24;
readonly Conjunction: 16 = 16;
readonly Exponent: 50 = 50;
readonly LogicalAnd: 14 = 14;
readonly LogicalOr: 12 = 12;
readonly Lowest: 0 = 0;
readonly Postfix: 70 = 70;
readonly Prefix: 60 = 60;
readonly Product: 40 = 40;
readonly Shift: 27 = 27;
readonly Sum: 30 = 30;
readonly Uncertainty: 45 = 45;