ExVEx.Formula.Tokenizer (ExVEx v0.2.0)

Copy Markdown View Source

Tokenises an Excel formula string into a flat list of ExVEx.Formula.Token records.

The goal isn't to build an AST — Excel formulas are too complex for that in a pure-Elixir budget — but to flatten the input into a stream where cell and range references are structured and everything else passes through as literal text. That's enough to rewrite references on row/column insert without understanding operator precedence or function semantics.

Supported reference forms:

  • Plain cells: A1, $A$1, A$1, $A1
  • Ranges: A1:B5, $A$1:$B$5
  • Row ranges: 1:5, $1:5
  • Column ranges: A:C
  • Sheet prefix: Sheet1!A1, 'Data Sheet'!A1
  • 3D sheet spans: Sheet1:Sheet3!A1

String literals ("text") and quoted sheet names ('Sheet Name') are preserved verbatim.

Summary

Functions

tokenize(formula)

@spec tokenize(String.t()) :: [ExVEx.Formula.Token.t()]