Skip to content

implicitMultiplyRule

function implicitMultiplyRule(priority?, canStart?): NormalizerRule;

Defined in: packages/engine/src/normalizer/BuiltinNormalizerRules.ts:72

Creates a normalization rule that inserts an implicit multiplication operator between adjacent tokens where multiplication is implied.

Inserts a STAR token between:

  • NUMBER IDENT (e.g., “2 x” → “2 * x”)
  • RPAREN IDENT (e.g., “(x+1)y” → “(x+1) * y”)
  • NUMBER LPAREN (e.g., “2(x+1)” → “2 * (x+1)”)
  • NUMBER PI / NUMBER E (e.g., “2π” → “2 * π”)
  • When the following identifier starts a multi-word phrase (checked against PHRASE_START_WORDS)
  • When the following token is not an identifier or parenthesized expression

Default priority is 50, below phrase fusion so phrases match first.

ParameterTypeDefault valueDescription
prioritynumber50Rule priority (default 50)
canStart?(word) => booleanundefined-

NormalizerRule

A NormalizerRule that inserts implicit multiply operators