ExVEx.Formula.Token (ExVEx v0.2.0)

Copy Markdown View Source

A single token produced by ExVEx.Formula.Tokenizer. Every formula is a flat list of these tokens, preserving enough structure for shift-on-insert/delete to walk the stream and rewrite cell references.

Token variants (the :kind field):

  • :literal — opaque text that should be emitted verbatim (operators, function names, punctuation, string literals).
  • :cell_ref — a concrete cell reference, optionally scoped to a sheet. Carries a %Reference{} plus the original sheet prefix.
  • :range_ref — a start / end pair for A1:B5 references.
  • :row_range — full-row reference like 1:5.
  • :col_range — full-column reference like A:C.
  • :sheet_range — 3D sheet-span prefix (Sheet1:Sheet3!).

Summary

Types

kind()

@type kind() ::
  :literal | :cell_ref | :range_ref | :row_range | :col_range | :sheet_range

t()

@type t() ::
  %ExVEx.Formula.Token{
    end_abs?: term(),
    end_col: term(),
    end_ref: term(),
    end_row: term(),
    kind: :literal,
    ref: term(),
    sheet: term(),
    start_abs?: term(),
    start_col: term(),
    start_ref: term(),
    start_row: term(),
    text: String.t()
  }
  | %ExVEx.Formula.Token{
      end_abs?: term(),
      end_col: term(),
      end_ref: term(),
      end_row: term(),
      kind: :cell_ref,
      ref: ExVEx.Formula.Reference.t(),
      sheet: String.t() | nil,
      start_abs?: term(),
      start_col: term(),
      start_ref: term(),
      start_row: term(),
      text: String.t()
    }
  | %ExVEx.Formula.Token{
      end_abs?: term(),
      end_col: term(),
      end_ref: ExVEx.Formula.Reference.t(),
      end_row: term(),
      kind: :range_ref,
      ref: term(),
      sheet: String.t() | nil,
      start_abs?: term(),
      start_col: term(),
      start_ref: ExVEx.Formula.Reference.t(),
      start_row: term(),
      text: String.t()
    }
  | %ExVEx.Formula.Token{
      end_abs?: boolean(),
      end_col: term(),
      end_ref: term(),
      end_row: pos_integer(),
      kind: :row_range,
      ref: term(),
      sheet: String.t() | nil,
      start_abs?: boolean(),
      start_col: term(),
      start_ref: term(),
      start_row: pos_integer(),
      text: String.t()
    }
  | %ExVEx.Formula.Token{
      end_abs?: boolean(),
      end_col: pos_integer(),
      end_ref: term(),
      end_row: term(),
      kind: :col_range,
      ref: term(),
      sheet: String.t() | nil,
      start_abs?: boolean(),
      start_col: pos_integer(),
      start_ref: term(),
      start_row: term(),
      text: String.t()
    }