import type { ImapAttributeList, ParserOptions } from './types.js';
import type { ParserInstance } from './parser-instance.js';
/**
 * A node of the parse tree built by TokenParser. `type` is false for a node that has not
 * been classified yet, 'TREE' for the root, and otherwise the token or structure type
 * (ATOM, string, LITERAL, SEQUENCE, LIST, SECTION, PARTIAL).
 */
export interface TokenNode {
    childNodes: TokenNode[];
    type: string | false;
    value: string | Buffer;
    isClosed: boolean;
    parentNode?: TokenNode | undefined;
    depth: number;
    startPos?: number | undefined;
    endPos?: number | undefined;
    literalType?: string | undefined;
    /** Digits accumulated as a string while the literal marker is read, converted to a number once the marker closes */
    literalLength?: string | number | undefined;
    literalPlus?: boolean | undefined;
    started?: boolean | undefined;
    chBuffer?: Buffer | undefined;
    chPos?: number | undefined;
}
/**
 * The parent object a TokenParser reads the parsed command from
 */
export interface TokenParserParent {
    command?: string | undefined;
}
/**
 * Tokenizes an IMAP attribute string into a tree of typed nodes.
 * Handles all IMAP data types: atoms, quoted strings, literals (including literal8),
 * sequences, lists (parenthesized groups), sections (bracketed groups), and partial ranges.
 * Enforces a maximum nesting depth of {@link MAX_NODE_DEPTH} to prevent stack overflow
 * from malicious input.
 */
export declare class TokenParser {
    str: string;
    options: ParserOptions;
    parent: TokenParserParent | ParserInstance;
    maxLiteralSize: number;
    tree: TokenNode;
    currentNode: TokenNode;
    pos: number;
    state: number;
    expectedLiteralType?: string | false | undefined;
    /**
     * Creates a new TokenParser.
     *
     * @param parent - The parent ParserInstance that owns this token parser. Used to access the parsed command for context-sensitive parsing.
     * @param startPos - The starting position offset in the original input, used for error reporting.
     * @param str - The attribute string to tokenize.
     * @param options - Parser options.
     * @param options.literalPlus - Whether the LITERAL+ extension is in use.
     * @param options.literals - Pre-parsed literal values from the input stream.
     * @param options.maxLiteralSize - Maximum size (in bytes) of a literal parsed inline
     *   from the input, i.e. when no pre-parsed literal buffers were supplied. Defaults to 1GB.
     */
    constructor(parent: TokenParserParent | ParserInstance, startPos?: number | undefined, str?: string | null | undefined, options?: ParserOptions | undefined);
    /**
     * Processes the input string and returns the parsed attributes as a flat array of typed objects.
     * Each attribute is an object with a `type` (e.g., "ATOM", "STRING", "LITERAL", "SEQUENCE")
     * and a `value` property. Lists are represented as nested arrays. Sections and partials are
     * attached as properties on the preceding attribute object.
     *
     * @returns A promise that resolves to an array of parsed attribute objects and nested arrays.
     * @throws {Error} If the input contains syntax errors or unclosed nodes.
     */
    getAttributes(): Promise<ImapAttributeList>;
    /**
     * Creates a new node in the parse tree. Each node represents a token or structural
     * element (e.g., atom, string, literal, list, section, partial). The node is automatically
     * appended to the parent's childNodes array if a parent is provided.
     *
     * @param parentNode - The parent node to attach this node to. If omitted, creates a root node.
     * @param startPos - The starting position of this node in the original input string.
     * @returns The newly created node with childNodes, type, value, and isClosed properties.
     * @throws {Error} If the nesting depth exceeds MAX_NODE_DEPTH.
     */
    createNode(parentNode?: TokenNode | undefined, startPos?: number | undefined): TokenNode;
    /**
     * Processes the entire input string character by character using a state machine.
     * Transitions between states (NORMAL, ATOM, STRING, LITERAL, SEQUENCE, PARTIAL, TEXT)
     * based on the current character and builds the parse tree. This is the main parsing
     * loop that drives the tokenization.
     *
     * @throws {Error} If the input contains unexpected characters, unclosed structures, or other syntax errors.
     */
    processString(): Promise<void>;
}
