/** * Represents a token. */ export interface Token { /** * The value of the token. */ readonly value: string; /** * The raw value of the token e.g. with quotes. */ readonly raw: string; /** * Trailing whitespace. */ readonly trailing: string; } /** * Joins tokens together. * By default, this keeps as much of the original input as possible. * * ```ts * // Note three trailing spaces. * const tokens = new Lexer('hello "world"') * .setQuotes([['"', '"']]) * .lex(); * * console.log(joinTokens(tokens)); * >>> 'hello "world"' * * console.log(joinTokens(tokens, ' ', false)); * >>> 'hello world' * ``` * * @param tokens - Tokens to join. * @param separator - The separator, if null, will use original trailing whitespace; defaults to null. * @param raw - Whether to use raw values e.g. with quotes; defaults to true. * @returns The joined string. */ export declare function joinTokens(tokens: Token[], separator?: string | null, raw?: boolean): string; /** * A function to match a prefix. * @param s - A string that may start with the prefix. * @returns The length of the prefix if there is one. */ export declare type MatchPrefix = (s: string) => number | null; /** * Extracts a command from the first one or two tokens from a list of tokens. * The command format is ' ', and the space is optional. * @param matchPrefix - A function that gives the length of the prefix if there is one. * @param tokens - Tokens to check. * @param mutate - Whether to mutate the list of tokens. * @returns The token containing the name of the command. * This may be a token from the list or a new token. */ export declare function extractCommand(matchPrefix: MatchPrefix, tokens: Token[], mutate?: boolean): Token | null;