ExVEx.Formula.Shift (ExVEx v0.2.0)

Copy Markdown View Source

Applies a %ExVEx.Mutation.Shift{} to a token stream produced by ExVEx.Formula.Tokenizer, rewriting cell and range references so they continue to point at the same logical cells after the shift.

Rules (matching Excel's structural insert/delete semantics):

  • A reference is only shifted when the shift applies to its sheet. If the shift's :sheet is nil, it applies everywhere; if set, only tokens whose :sheet matches (or is nil, meaning the current sheet) are shifted.

  • Absolute-axis markers ($) are preserved through the shift but do NOT prevent it — Excel shifts every reference at or below an insert point, including $A$5. The $ affects copy-paste semantics, not structural row/column inserts.

  • References above the insertion point (or before the deletion span) are unchanged.

  • References at or below the insertion point are incremented by the delta.

  • References inside a deletion span are collapsed to #REF! (the token's text is replaced with the error string).

Summary

Functions

apply(tokens, shift, current_sheet \\ nil)