import type { DeferredCommandExpansion, ParseError, Word, WordPart } from "./types.ts";
export declare const Token: {
readonly Word: 0;
readonly Assignment: 1;
readonly Semi: 2;
readonly Newline: 3;
readonly Pipe: 4;
readonly And: 5;
readonly Or: 6;
readonly Amp: 7;
readonly LParen: 8;
readonly RParen: 9;
readonly LBrace: 10;
readonly RBrace: 11;
readonly Bang: 12;
readonly If: 13;
readonly Then: 14;
readonly Else: 15;
readonly Elif: 16;
readonly Fi: 17;
readonly Do: 18;
readonly Done: 19;
readonly For: 20;
readonly While: 21;
readonly Until: 22;
readonly In: 23;
readonly Case: 24;
readonly Esac: 25;
readonly Function: 26;
readonly DoubleSemi: 27;
readonly SemiAmp: 28;
readonly DoubleSemiAmp: 29;
readonly Select: 30;
readonly DblLBracket: 31;
readonly DblRBracket: 32;
readonly EOF: 33;
readonly ArithCmd: 34;
readonly Coproc: 35;
readonly Redirect: 36;
};
export type Token = (typeof Token)[keyof typeof Token];
export declare class TokenValue {
token: Token;
value: string;
pos: number;
end: number;
fileDescriptor?: number;
variableName?: string;
content?: string;
targetPos: number;
targetEnd: number;
reset(): void;
copyFrom(other: TokenValue): void;
}
export declare const LexContext: {
readonly Normal: 0;
readonly CommandStart: 1;
readonly TestMode: 2;
};
export type LexContext = (typeof LexContext)[keyof typeof LexContext];
export declare class Lexer {
private src;
private srcEnd;
private pos;
private current;
private nextState;
private hasPeek;
private pendingHereDocs;
private collectedExpansions;
_errors: ParseError[] | null;
_buildParts: boolean;
constructor(src: string, start?: number, end?: number);
getSource(): string;
get errors(): ParseError[];
getCollectedExpansions(): DeferredCommandExpansion[];
getPos(): number;
/** Set position and scan a word, building parts. Used by computeWordParts. */
buildWordParts(startPos: number): WordPart[] | null;
/** Scan a heredoc body for expansions, building parts. Spaces/newlines are literal. */
buildHereDocParts(bodyPos: number, bodyEnd: number): WordPart[] | null;
registerHereDocTarget(target: {
content?: string;
heredocQuoted?: boolean;
body?: Word;
}): void;
readTestRegexWord(): TokenValue;
readCStyleForExprs(): [string, string, string, number, number, number];
peek(ctx?: LexContext): TokenValue;
next(ctx?: LexContext): TokenValue;
unshift(tok: TokenValue): void;
private readNext;
private tryReadOperator;
private readRedirection;
private redirectToken;
private readProcessSubstitution;
private readHereDocDelimiter;
private consumePendingHereDocs;
private readHereDocBody;
private parseHereDocBody;
private _wordText;
private _wordQuoted;
private _wordHasExpansions;
_wordParts: WordPart[] | null;
private _redirectTargetPos;
private _resultText;
private _resultHasExpansion;
private _resultPart;
private _dqText;
private _dqHasExpansions;
private _dqParts;
private _hereDelim;
private _hereQuoted;
private readWord;
private readWordText;
private readInnerWordText;
private parseSubFieldWord;
private skipSQ;
private skipDQ;
private skipSpacesAndTabs;
private readDoubleQuoted;
private readDollar;
private scanArithmeticBody;
private readArithmeticExpansion;
private readArithmeticCommand;
private readCommandSubstitution;
private readBraceCommandSubstitution;
private readValueSubstitution;
private readBraceSubstitution;
private readBacktickExpansion;
private readParameterExpansion;
private parseParamInner;
private scanParamName;
private findCloseBracket;
private readAnsiCQuoted;
private extractBalanced;
}