/** * @license * Copyright (c) 2025 Handsoncode. All rights reserved. */ import { ArraySize } from '../../ArraySize'; import { ProcedureAst } from '../../parser'; import { InterpreterState } from '../InterpreterState'; import { InterpreterValue } from '../InterpreterValue'; import { FunctionPlugin, FunctionPluginTypecheck, ImplementedFunctions } from './FunctionPlugin'; /** * Plugin implementing the SEQUENCE spreadsheet function. * * SEQUENCE(rows, [cols], [start], [step]) returns a rows×cols array of * sequential numbers starting at `start` and incrementing by `step`. */ export declare class SequencePlugin extends FunctionPlugin implements FunctionPluginTypecheck { /** * Minimum valid value for the `rows` and `cols` arguments. * Extracted to avoid duplicating the check between `sequence()` (runtime) and * `sequenceArraySize()` (parse time). */ private static readonly MIN_DIMENSION; /** Returns true when `n` is a finite number at least {@link MIN_DIMENSION}. */ private static isValidDimension; /** * Parses a literal dimension from an AST node at parse time. * Handles NUMBER nodes directly, STRING nodes via numeric coercion, * PLUS/MINUS_UNARY_OP wrapping a NUMBER (e.g. `+3`, `-2`), * and TRUE()/FALSE() function calls (returning 1/0). * Returns undefined for non-literal nodes (cell refs, formulas, binary ops). */ private static parseLiteralDimension; static implementedFunctions: ImplementedFunctions; /** * Corresponds to SEQUENCE(rows, [cols], [start], [step]) * * Returns a rows×cols array of sequential numbers starting at `start` * and incrementing by `step`, filled row-major. * * Note: dynamic arguments (cell references, formulas) for `rows` or `cols` * cause a size mismatch between parse-time prediction and runtime result, * which results in a #VALUE! error. Use literal numbers for rows and cols. * * @param {ProcedureAst} ast - The parsed function call AST node. * @param {InterpreterState} state - Current interpreter evaluation state. */ sequence(ast: ProcedureAst, state: InterpreterState): InterpreterValue; /** * Predicts the output array size for SEQUENCE at parse time. * * Handles NUMBER and STRING literals for rows/cols via `parseLiteralDimension`. * Non-literal args (cell refs, formulas, unary/binary ops) fall back to 1, * which will cause a size mismatch at eval time when the actual result is larger. * * @param {ProcedureAst} ast - The parsed function call AST node. * @param {InterpreterState} _state - Current interpreter evaluation state (unused). */ sequenceArraySize(ast: ProcedureAst, _state: InterpreterState): ArraySize; }