@borgar/fx
Version:
Utilities for working with Excel formulas
16 lines (13 loc) • 503 B
text/typescript
import { ERROR } from '../constants.ts';
import type { Token } from '../types.ts';
const re_ERROR = /#(?:NAME\?|FIELD!|CALC!|VALUE!|REF!|DIV\/0!|NULL!|NUM!|N\/A|GETTING_DATA\b|SPILL!|UNKNOWN!|SYNTAX\?|ERROR!|CONNECT!|BLOCKED!|EXTERNAL!)/iy;
const HASH = 35;
export function lexError (str: string, pos: number): Token | undefined {
if (str.charCodeAt(pos) === HASH) {
re_ERROR.lastIndex = pos;
const m = re_ERROR.exec(str);
if (m) {
return { type: ERROR, value: m[0] };
}
}
}