UNPKG

@odoo/o-spreadsheet

Version:
27 lines (26 loc) 1.12 kB
import { type Locale } from "../types/locale"; /** * Tokenizer * * A tokenizer is a piece of code whose job is to transform a string into a list * of "tokens". For example, "(12+" is converted into: * [{type: "LEFT_PAREN", value: "("}, * {type: "NUMBER", value: "12"}, * {type: "OPERATOR", value: "+"}] * * As the example shows, a tokenizer does not care about the meaning behind those * tokens. It only cares about the structure. * * The tokenizer is usually the first step in a compilation pipeline. Also, it * is useful for the composer, which needs to be able to work with incomplete * formulas. */ export declare const POSTFIX_UNARY_OPERATORS: string[]; export declare const DEBUGGER_CHAR = "?"; type TokenType = "OPERATOR" | "NUMBER" | "STRING" | "SYMBOL" | "SPACE" | "DEBUGGER" | "ARG_SEPARATOR" | "ARRAY_ROW_SEPARATOR" | "LEFT_PAREN" | "RIGHT_PAREN" | "LEFT_BRACE" | "RIGHT_BRACE" | "REFERENCE" | "INVALID_REFERENCE" | "UNKNOWN"; export interface Token { readonly type: TokenType; value: string; } export declare function tokenize(str: string, locale?: Locale): Token[]; export {};