Skip to content

Support power(^) operator #193

Description

@ggyuchive

Description:

  • The ^ exponentiation operator is missing from the formula grammar.
  • =5^2 returns #ERROR! because the parser does not recognise the token.
  • The POWER(x, n) function works correctly, so the underlying math is fine — only the operator path is missing.
  • Bind ^ tighter than *// and right-associatively (2^3^2 = 2^(3^2) = 512).

Minimal reproduction

Cell Formula Expected Actual Status
A1 =5^2 "25" "#ERROR!"
A2 =POWER(5, 2) "25" "25"
A3 =2^10 "1024" "#ERROR!"
A4 =2^0.5 "1.4142…" "#ERROR!"

POWER() works → underlying Math.pow is fine. Only the ^ operator is missing from the grammar.

Why:

packages/sheets/src/formula/antlr/Formula.g4 does not include a power-operator rule.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgood first issueGood for newcomerssheetsRelated to wafflebase sheets component

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions