/**
 * The ONE shell lexer: one walk over a bash command mints a structure of words made of PIECES, and every other
 * spelling a reader consumes — `raw`, `folded`, the quoted spans, the expansion list, the assignment fact, the
 * reason a value cannot be read off the text — is a view of that structure. Dialect: bash (the execution
 * environment's last-resort `sh` reads `$'…'`, `+=`, a subscript, `<<<`, `<(…)` and `&>` differently; see
 * {@link bashOnlyConstructsOf}).
 *
 * ONE walk, ONE reading: every construct bash reads is RECORDED — a redirection, a substitution, an escape, a
 * comment, a line break, a backgrounding `&` — never refused here. Which of them a face refuses is that face's
 * predicate over the result (the classify faces' residual predicate in the read-only classifier); the lexer has
 * no modes. Bash's own word rules hold throughout: an unquoted word-start `#` begins a comment, and only a blank
 * (space or tab) bounds a word — a non-breaking space or a vertical tab is a word character.
 *
 * A command bash cannot parse is a {@link LexParseFailure}, never a guessed reading: an unterminated quote,
 * substitution, subscript or here-document yields NO segments. A word bash reads but whose VALUE the text does not
 * contain carries {@link LexedWord.unresolved}; the word is still delimited and its neighbours still read.
 *
 * Line continuations. Bash removes a `\<newline>` pair before it recognises anything — except inside single quotes,
 * a comment and a QUOTED here-document body. Every lookahead below reads the next LOGICAL character past any
 * continuation, so a pair can stand inside a construct's spelling and never inside the three places bash keeps it.
 */
import type { ExecutionEnvModelShell } from "../internal/harness-types.js";
import type { AssertAllKeysHandled } from "@sema-agent/primitives";
/** The dialect this lexer reads: bash. The engine's own commands (`ExecutionEnv.exec`) are not read by it. */
export declare const SHELL_LEX_DIALECT = "bash";
/** The shell a reading of model text is made for ({@link lexShell}): the one the start of the leg that runs the text reports
 *  (`ExecutionEnvModelShell.ready`), or `"unknown"` where the reader holds no start fact (`judgeShellRead` on an environment whose
 *  start is not mounted) — read like any shell but bash: the stop, never bash by default. One row per kind: how it is read. */
declare const STARTED_SHELL_READING: {
    readonly bash: "read";
    readonly zsh: "stop";
    readonly unknown: "stop";
};
export type StartedShell = keyof typeof STARTED_SHELL_READING;
/** Compile-time fence: `never` while every shell `ready` reports is a {@link StartedShell}. */
export type StartedShellCoversReady = AssertAllKeysHandled<Exclude<Extract<Awaited<ReturnType<NonNullable<ExecutionEnvModelShell["ready"]>>>, {
    readonly ok: true;
}>["value"]["shell"], StartedShell>>;
/** What holds a character quoted: the four quote forms and the backslash escape, one reason each. */
export declare const QUOTE_KINDS: readonly ["'", "\"", "$'", "$\"", "\\"];
export type QuoteKind = (typeof QUOTE_KINDS)[number];
/** The expansions this lexer names. Extended globs are not among them: `extglob` is off when `bash -c` starts, where
 *  `?(…)` is a syntax error and `(` is a group token here — but a text may turn it on (`shopt -s extglob` on an earlier
 *  line), after which bash reads `pack@(age.json)` as one pattern. A reader that plans reads treats an unquoted opener
 *  as a pattern it does not expand (`extglobOpenerIn`, the read station's `unreadable` floor). */
export declare const EXPANSION_KINDS: readonly ["parameter", "command", "process", "arithmetic", "tilde", "brace", "glob"];
export type ExpansionKind = (typeof EXPANSION_KINDS)[number];
/** Why a word's value cannot be read off the text. Each member is a spelling whose value the text does not
 *  contain — never "the lexer did not look". */
export declare const UNRESOLVED_REASONS: readonly ["ansi_c_escape", "locale_string", "parameter_text", "subscript_text", "compound_array_value", "trailing_backslash"];
export type UnresolvedReason = (typeof UNRESOLVED_REASONS)[number];
/** The sentence a consumer hands on for an unresolved word: every reason is one a face ASKS about (the locale
 *  string included — its translation is not in the text), and a deny row is still judged on the written spelling
 *  by the readers that keep the word beside the reason. */
export declare const UNRESOLVED_SENTENCE: {
    readonly ansi_c_escape: "an ANSI-C quoted word carries an escape this lexer does not fold";
    readonly locale_string: "a locale-translated string carries text this lexer does not read";
    readonly parameter_text: "a parameter expansion carries text this lexer does not read";
    readonly subscript_text: "a subscript carries text this lexer does not read";
    readonly compound_array_value: "a compound assignment value is a list this lexer does not read";
    readonly trailing_backslash: "a backslash ends the command, which the shell versions read differently (3.2 drops it, 5 keeps it)";
};
/** Why a command yields no segments: bash's own syntax errors and the two constructs this lexer cannot delimit. */
export declare const PARSE_FAILURE_REASONS: readonly ["unterminated_single_quote", "unterminated_double_quote", "unterminated_ansi_c", "unterminated_subscript", "unterminated_compound_value", "unterminated_command_substitution", "unterminated_process_substitution", "unterminated_parameter_expansion", "unterminated_arithmetic_expansion", "unterminated_heredoc", "undelimited_substitution", "undelimited_substitution_heredoc", "redirect_without_target", "heredoc_without_delimiter", "heredoc_delimiter_expands", "started_shell_not_bash"];
export type ParseFailureReason = (typeof PARSE_FAILURE_REASONS)[number];
export declare const PARSE_FAILURE_SENTENCE: {
    readonly unterminated_single_quote: "a single-quoted word never closes";
    readonly unterminated_double_quote: "a double-quoted word never closes";
    readonly unterminated_ansi_c: "an ANSI-C quoted word never closes";
    readonly unterminated_subscript: "a subscript never closes";
    readonly unterminated_compound_value: "a compound assignment value never closes";
    readonly unterminated_command_substitution: "a command substitution never terminates";
    readonly unterminated_process_substitution: "a process substitution never terminates";
    readonly unterminated_parameter_expansion: "a parameter expansion never terminates";
    readonly unterminated_arithmetic_expansion: "an arithmetic expansion never terminates";
    readonly unterminated_heredoc: "a here-document body never terminates";
    readonly undelimited_substitution: "a command substitution carries a construct this lexer cannot delimit";
    readonly undelimited_substitution_heredoc: "a here-document in a command substitution that shell versions end at different places — feed the text as stdin (`git commit -F -`) or reword it";
    readonly redirect_without_target: "a redirection names no target";
    readonly heredoc_without_delimiter: "a here-document operator names no delimiter";
    readonly heredoc_delimiter_expands: "a here-document delimiter is not a plain word";
    readonly started_shell_not_bash: "the shell that runs this command is not known to be bash, the one dialect this lexer reads";
};
/**
 * The segments a shell MAY run around a stop, in order: those read in full before it ({@link LexParseFailure.readBefore}), the
 * statement it stopped in as far as the stop where the shell still runs that statement ({@link STATEMENT_RUNS_PAST}: the words
 * read in full before the stop are the command's first words, judged as written; the word the stop falls in, a here-document
 * whose body was not reached and all past the stop stay unread), and the statements past the stop ({@link segmentsPastStop}).
 * That head is {@link LexedSegment.spliced}: its program may receive more words, so what it binds or where it moves is a candidate;
 * its substitutions are those its words carry (a substitution in the word the stop falls in is that word's, unread too).
 */
export declare function segmentsAroundStop(source: string, failure: LexParseFailure): readonly LexedSegment[];
/** The constructs of this dialect a POSIX `sh` reads as something else. */
export declare const BASH_ONLY_CONSTRUCTS: readonly ["ansi_c_quoting", "locale_string", "append_assignment", "subscript_assignment", "compound_assignment", "here_string", "process_substitution", "redirect_both", "pipe_both", "brace_expansion"];
export type BashOnlyConstruct = (typeof BASH_ONLY_CONSTRUCTS)[number];
/**
 * The single-letter ANSI-C escapes this lexer folds: the thirteen whose byte is the same in every bash. The numeric and
 * control escapes are folded beside them where they yield such a byte ({@link numericEscapeAt}); every other escape is
 * `unresolved` rather than decoded. Admission is a differential test against the real shells.
 */
export declare const ANSI_C_ESCAPES: {
    readonly a: "\u0007";
    readonly b: "\b";
    readonly e: "\u001B";
    readonly E: "\u001B";
    readonly f: "\f";
    readonly n: "\n";
    readonly r: "\r";
    readonly t: "\t";
    readonly v: "\v";
    readonly "\\": "\\";
    readonly "'": "'";
    readonly '"': "\"";
    readonly "?": "?";
};
export interface WordPiece {
    /** Source offsets of the written text, `[start, end)`; a continuation between two pieces is nobody's. */
    readonly span: readonly [number, number];
    readonly quotedBy: QuoteKind | undefined;
    /** The text the program receives from this piece — absent for an expansion and for an unresolved piece. */
    readonly literal?: string;
    readonly expansion?: WordExpansion;
}
export interface WordExpansion {
    readonly kind: ExpansionKind;
    /** `"many"` where the result may be zero or several words: word-split (an unquoted parameter, command or arithmetic
     *  substitution), a brace list, a glob, or a parameter expanded once per element even in double quotes (`"$@"`,
     *  `"${a[@]}"`, `"${!prefix@}"`). */
    readonly yields: "one" | "many";
    /** The text between the delimiters, where there is one (a substitution body, a brace list, a tilde-prefix). */
    readonly body?: string;
    /** The parameter name, where the expansion names one. */
    readonly name?: string;
    /** A glob's pattern — absent where an expansion stands inside it (its text is not the pattern): `folded`, what the
     *  program receives where it matches nothing — quotes removed, the spelling {@link LexedWord.folded} carries at its place
     *  (`[^.]`); `written`, as written, quoting kept (`[^\.]`, `["!"a]`) — the text a shell re-reading it matches by;
     *  `judged`, the spelling a reader judges the names it matches by — `folded`, save a class the judge reads as any one
     *  character: one holding a quoted or escaped character (its quote-removed text reads another class: `["!"a]` is not
     *  the negation `[!a]`) or a `[:…:]` / `[=…=]` / `[.….]` unit — spelled `?`, a superset of its members. */
    readonly pattern?: {
        readonly folded: string;
        readonly written: string;
        readonly judged: string;
    };
    /** The expansions a brace list or a bracket class encloses (`{${a[n]},x}`, `[$x]`): they run before the pattern is
     *  formed. Absent when it encloses none. */
    readonly inner?: readonly WordExpansion[];
}
export interface QuotedSpan {
    /** Offsets into {@link LexedWord.raw}, `[start, end)`; the quote characters belong to their span. */
    readonly start: number;
    readonly end: number;
    readonly by: QuoteKind;
}
/** Bash's assignment fact for a word whose folded spelling is `NAME[subscript]?(+)?=value`, minted wherever the
 *  word stands. Whether bash STRIPS it before choosing the program is `bare && atCommandPosition`; whether the
 *  program that receives it reads it as an assignment is the program's own grammar. */
export interface AssignmentFact {
    readonly name: string;
    readonly op: "=" | "+=";
    readonly subscript?: {
        readonly raw: string;
        readonly folded: string;
        readonly expansions: readonly WordPiece[];
    };
    readonly value: {
        readonly raw: string;
        readonly folded: string;
        readonly pieces: readonly WordPiece[];
        readonly expansions: readonly WordPiece[];
        readonly unresolved?: UnresolvedReason;
    };
    /** The name, the brackets and the operator are written unquoted and unescaped — the subscript's CONTENT and the
     *  value may be quoted and still leave the word an assignment. */
    readonly bare: boolean;
    readonly form: "scalar" | "compound";
    /** `op === "="` with no subscript and a scalar value: the whole name is settled by this word's text. */
    readonly settlesWholeName: boolean;
    /** Only on a compound value whose every element this lexer read as a word: each element, in order
     *  ({@link CompoundElement}). Absent on a compound value it did not read element by element (its `compound_array_value`
     *  stands for the whole value). */
    readonly elements?: readonly CompoundElement[];
}
/** One element of a compound value `NAME=(…)`: the element as the list's own word (what bash word-expands, its patterns
 *  included), and the scalar assignment bash performs for it — `NAME[k]=v` for a keyed element (`[k]=v`, `[k]+=v`), the
 *  subscript the shell evaluates; `NAME=v` for any other element. */
export interface CompoundElement {
    readonly word: LexedWord;
    readonly stored: LexedWord;
}
/** An argv word. `raw` is what the SHELL sees (quotes, escapes and substitution text retained); `folded` is what
 *  the PROGRAM receives after quote removal, with every substitution replaced by {@link SUBSTITUTION_PLACEHOLDER},
 *  every other expansion left in its written spelling, and a literal leading tilde spelled `./~…`
 *  ({@link literalTildeSpelling}). Both are views of {@link LexedWord.pieces}. */
export interface LexedWord {
    readonly kind: "word";
    readonly raw: string;
    readonly folded: string;
    /** The spelling a reader judges the word's names by, where it is not `folded`: each bracket class holding a quoted or
     *  escaped character or a `[:…:]` / `[=…=]` / `[.….]` unit spelled `?` (`["!"a]*`, `[[:alpha:]]*` ⇒ `?*`,
     *  {@link WordExpansion.pattern}). */
    readonly judged?: string;
    readonly pieces: readonly WordPiece[];
    readonly quotedSpans: readonly QuotedSpan[];
    /** The pieces that carry an expansion, in order. */
    readonly expansions: readonly WordPiece[];
    readonly assignment?: AssignmentFact;
    /** The first reason, in reading order, that a value in this word cannot be read off the text. */
    readonly unresolved?: UnresolvedReason;
    /** The word was read where bash accepts an assignment or a command name: at a segment's start, after a bare
     *  assignment word, after a bare control-prefix word, or after a leading redirection list. */
    readonly atCommandPosition: boolean;
}
/** A redirection and the word it takes. A descriptor duplication (`>&2`, `<&0`, `>&-`, `>&1-`) takes none: its
 *  operand is `dup`, the descriptor (or `-`, or a descriptor followed by `-`) as written. `fd` is the descriptor
 *  number written in front of the operator (`2>f`, `3>&0`); absent when none was (bash's default, `1` for an
 *  output form and `0` for an input form, is the reader's to apply). */
export interface LexedRedirect {
    readonly kind: "redirect";
    /** `<>` opens its target for reading AND writing (creating it), on descriptor 0 unless one is written. */
    readonly op: "<" | ">" | ">>" | "<<<" | "<>" | "&>" | "&>>" | ">&" | "<&";
    readonly fd?: number;
    /** The word right before the operator is a bare `{NAME}` (`{fd}>file`, `{fd}<<EOF`): bash ≥ 4.1 opens a descriptor it picks
     *  (never 0) and stores its number in NAME — no argument; bash 3.2 reads `{NAME}` as an argument and the redirection on its
     *  default descriptor. The word stays a word token; every reader takes both readings ({@link namesRedirectDescriptor}). */
    readonly allocated?: true;
    readonly target?: LexedWord;
    readonly dup?: string;
}
/** A here-document: the body is DATA the program reads on stdin, never command text. `quoted` records whether
 *  the delimiter word carried a quote or an escape, which is bash's rule for "the body does not expand". */
export interface LexedHeredoc {
    readonly kind: "heredoc";
    readonly delimiter: string;
    readonly quoted: boolean;
    readonly body: string;
    /** The descriptor the body is opened on when the operator carried one (`3<<EOF`); absent = standard input. */
    readonly fd?: number;
    /** `{NAME}<<EOF`: a descriptor bash ≥ 4.1 allocates, standard input to bash 3.2 ({@link LexedRedirect.allocated}). */
    readonly allocated?: true;
}
/** A subshell parenthesis, standing alone: structure, not a word. */
export interface LexedGroup {
    readonly kind: "group";
    readonly op: "(" | ")";
}
export type LexedToken = LexedWord | LexedRedirect | LexedHeredoc | LexedGroup;
/** The connector bash ran a segment through — `"start"` for the first one. A closed set, because the read
 *  boundary distinguishes all four: `&&` is the only one under which the previous segment is known to have
 *  exited ZERO, `||` is the only one under which the previous segment may have been SKIPPED ENTIRELY, `|`
 *  puts the segment in a subshell whose directory changes never reach the parent, and `;` is plain sequence. */
export type ShellSegmentConnector = "start" | ";" | "&&" | "||" | "|";
/** The two boundaries the read boundary does not distinguish from a plain sequence: a backgrounding `&` and a
 *  line break. */
export type LenientConnector = ShellSegmentConnector | "&" | "\n";
export interface LexedSegment {
    /** The segment's text exactly as written (surrounding whitespace included). Here-document bodies are not part
     *  of any segment's text. */
    readonly text: string;
    readonly connector: LenientConnector;
    /** The `|` was spelled `|&`: the previous segment's standard error is piped too (bash 4+; a syntax error on
     *  bash 3.2, so a reader on the fail-closed side treats the pipe as real). */
    readonly pipesStderr?: true;
    readonly tokens: readonly LexedToken[];
    /** The bodies of the substitutions found in THIS segment (its words and its redirection targets), in order. */
    readonly substitutions: readonly string[];
    /** The bodies among {@link substitutions} of a function or value substitution (`${ list; }`, `${| list; }`): their list
     *  runs in the CURRENT shell, so what it assigns or where it moves outlives the word. Absent when there is none. */
    readonly currentShell?: readonly string[];
    /** Whether the segment runs where it stands is not proven, so what it binds or where it moves is one more candidate, never
     *  a certainty (#3557): it stands where a `source` of a file this text wrote stood (#3400) — the written literal's text, not
     *  the text as the shell will read it (the write may have failed or gone to a device, the printer may be shadowed) — or it
     *  is a statement read past the place the lexer stopped ({@link segmentsPastStop}: a reading that may have started inside
     *  a construct, or past text no shell gets beyond). */
    readonly spliced?: true;
    /** The `source` segment itself, kept after the segments its written literal was spliced into (#3557): never spliced
     *  again. The inserted segments are only {@link spliced} — a `source` among them of a file the inserted text itself
     *  wrote splices on the next pass (a guard on `spliced` would hide `. ./inner.sh` inside the spliced text). */
    readonly sourced?: true;
    /** The words a statement holds before the place the lexer stopped in it ({@link segmentsAroundStop}): judged as that
     *  command, and no statement the splice of a written `source` reads — the statements around it are adjacent to it as they
     *  were before the head was read. */
    readonly stopHead?: true;
}
export interface LexedCommand {
    readonly segments: readonly LexedSegment[];
    /** Every substitution body of the command, in order (the per-segment lists concatenated). */
    readonly substitutions: readonly string[];
}
export interface LexParseFailure {
    readonly parseFailure: {
        readonly reason: ParseFailureReason;
        readonly at: number;
    };
    /** The segments the walk read before it stopped, the last one holding the tokens it had read when it stopped. Bash runs
     *  each complete line before it parses the next one (`rm -r x` on line 1 runs although line 2 never closes its quote),
     *  so a reader asking what the text MAY run reads these as runs; a reader asking what the text DOES reads the failure.
     *  Every segment before the last is such a run — the read station's planner and the deny lanes read the same ones. A
     *  here-document the text never terminates is read as the shells read it, to the end of the text: the segment owning it
     *  holds that body, and the last segment is an empty one at the text's end. Which of these runs a shell reaches is not
     *  decided here (a quote left open on the SAME line stops bash before any of that line runs; zsh parses the whole text
     *  first): the reading is of what MAY run. */
    readonly readBefore: readonly LexedSegment[];
}
/** A command: its segments, or the one reason it has none. */
export type ShellLex = LexedCommand | LexParseFailure;
/** One segment's argv words in both spellings, index-aligned by construction (folding is strictly per word — it
 *  never splits or joins). The one shape every downstream arm of the classifier reads. */
export interface SegmentTokens {
    readonly folded: readonly string[];
    readonly raw: readonly string[];
}
/** What a substitution leaves in a word's FOLDED spelling: a marker no argv word can spell, so a consumer that
 *  judges words sees "this word carries text the shell computes" rather than the computing text itself. */
export declare const SUBSTITUTION_PLACEHOLDER = " subst";
/** Shell control words that stand BEFORE a command: transparent for the boundary walk (the command behind them is
 *  judged), and a position after which bash still accepts an assignment word. */
export declare const SHELL_CONTROL_PREFIXES: ReadonlySet<string>;
/**
 * Does the `$` at `at` OPEN a quote form (`$'…'` / `$"…"`)? ONE question, asked by every walker that has to
 * answer it. Escaped means an ODD run of backslashes in front of it: `\$'y'` is a literal `$`, while `x\\$'y'`
 * is a literal backslash followed by a real ANSI-C quote. Counting the run is what a one-character peek behind
 * cannot do. The quote may follow line continuations bash removes first (`$\<newline>"…"` is `$"…"`).
 */
export declare function dollarOpensQuote(text: string, at: number): boolean;
/** The `'` that CLOSES the ANSI-C quote opened at `open`, or `undefined` when none does. `\'` does not close
 *  one — the single place a quote region honours a backslash. */
export declare function ansiCQuoteClose(source: string, open: number): number | undefined;
/** The ONE spelling of a LITERAL leading tilde — `./~…`, the relative path it is — for every position bash does not
 *  expand it in; a word without a leading tilde is returned as is. */
export declare function literalTildeSpelling(word: string): string;
/** The argv words of a segment: redirections, here-documents and groups are not words the program receives (bash
 *  removes them before exec). */
export declare function argvOf(segment: LexedSegment): readonly LexedWord[];
/** The two-spelling view of {@link argvOf}, for the readers that compare spellings. */
export declare function wordsOf(segment: LexedSegment): SegmentTokens;
/** One expansion of an unquoted here-document body; `unresolved` where the parameter text is one this lexer does not
 *  read (`${x:-$(…)}`, a nested `${…}`) — what it may assign or run is then not in the facts. */
export interface HeredocExpansion {
    readonly expansion: WordExpansion;
    readonly unresolved?: "parameter_text";
    /** A function or value substitution ({@link opensCurrentShellSubstitution}): its list runs in the current shell. */
    readonly currentShell?: true;
    /** Where it stands in the body, `[start, end)`. */
    readonly span: readonly [number, number];
}
/** The expansions of an UNQUOTED here-document body, in order: `$(…)`, `$((…))`, `$[…]` and backticks, `${ …; }` /
 *  `${| …; }`, `${…}` and `$NAME`. The body expands as double-quoted text does: quotes are ordinary characters, a backslash
 *  protects the next character, nothing is word-split. `undefined` when an expansion never closes. What its expansions
 *  ask of the rest of `body` is read once for the whole body ({@link whileReading}). */
export declare function expansionsInHeredocBody(body: string): readonly HeredocExpansion[] | undefined;
/** The substitution bodies of an UNQUOTED here-document body (the command and arithmetic members of
 *  {@link expansionsInHeredocBody}, a function / value substitution marked `currentShell`). `undefined` when an
 *  expansion never closes. */
export declare function substitutionsInHeredocBody(body: string): {
    readonly body: string;
    readonly kind: "command" | "arithmetic";
    readonly currentShell?: true;
}[] | undefined;
/** What expanding an unquoted here-document body runs ({@link expansionRunsOf} over its expansions): the command lines its
 *  substitutions run, and `hidden` where it may run a program none of them shows — a body whose expansions cannot be
 *  delimited, a parameter text this lexer does not read, a process-substitution opener (text to bash in a body; read
 *  here as one — the side that judges more). */
export declare function heredocRunsOf(body: string): ExpansionRuns;
/** Can expanding an unquoted here-document body run a program ({@link heredocRunsOf}: a line its substitutions run, or a
 *  run none of them shows)? */
export declare function heredocBodyHidesRun(body: string): boolean;
/** A `${…}` body read once, past its head ({@link PARAMETER_HEAD}): the texts bash evaluates as arithmetic — the subscript
 *  (`a[i]`, `#a[i]`, `!a[i]`: up to the first `]`, or to the end where none closes) and a substring expansion's offset and
 *  length (`x:off:len`, `*:N+=1`, after a closed subscript or none; not the `:-` `:=` `:+` `:?` operators). A line
 *  continuation is removed first. The one reading of the body grammar: the deny lanes and auto-background ask whether
 *  either text names a variable ({@link expansionHidesRun}), the read station re-enters what either runs. */
export declare function parameterArithmeticTexts(body: string): {
    readonly subscript?: string;
    readonly offset?: string;
};
/**
 * The command lines a parameter expansion's OPERAND runs (`${X:-$(cmd)}` when X is unset or empty, `${X:+$(cmd)}` when it is
 * set, `${X#$(cmd)}` always; measured on bash 3.2 and 5.2, dash, zsh): the command and process substitutions written in it,
 * and those of the arithmetic and parameter expansions written in it — read as the shell expands the operand, left to right.
 * In double quotes (`quoted`) a single quote is an ordinary character there (`"${X:-'$(cmd)'}"` runs cmd); outside them a
 * single-quoted run — `$'…'` read to its unescaped close — is text, and a double-quoted run inside the operand reads as in
 * double quotes (`${X:-'$(cmd)'}` runs nothing, `${X:-"'$(cmd)'"}` runs cmd). `<(…)` / `>(…)` are process substitutions
 * outside both, and in double quotes in a pattern operand too ({@link PATTERN_OPERAND}: `"${X#<(cmd)}"`, `"${X//<(cmd)/}"`,
 * `"${X^^<(cmd)}"` run cmd; `"${X:-<(cmd)}"` does not — measured on 3.2 and 5.3). A substitution's
 * own text is never rewritten (`${X:-$(cat '.env')}` reads `cat '.env'`). A subscript and a substring offset are not operand
 * text ({@link parameterArithmeticTexts}: the evaluator's). The walk stops at an expansion it cannot delimit and keeps what it
 * read before it: the word itself stays unread either way (its braces carry `$`, {@link UNREADABLE_EXPANSION_TEXT}). The
 * one reading of what an operand runs: the deny lanes' lines ({@link expansionRunsOf}) and the read station's nested plans.
 */
export declare function parameterOperandLines(body: string, quoted: boolean): readonly string[];
/** What evaluating an expansion (a word's, a here-document body's) runs, as far as its text shows it. `lines`: the command
 *  lines its substitutions run, each a command line of its own — a command or process substitution's body, the list of
 *  `${ …; }`, and the substitutions an arithmetic text holds (bash expands that text as double-quoted text first:
 *  `$(( '$(cmd)' ))` runs cmd); a brace list's or bracket class's enclosed expansions count as their own. `hidden`: it may
 *  ALSO run a program no line shows — the arithmetic evaluator evaluates a NAME recursively (`a='x[$(…)]'; $((a))`), so
 *  arithmetic text that names a variable or carries a `$` may, and so may a parameter expansion's subscript or substring
 *  offset (its own or one nested in its text, `${x:-${a[i]}}`), a value it re-reads (`${!R}`, `${P@P}`), and a parameter,
 *  brace or glob text that carries a substitution opener. A parameter's operand is word grammar this lexer does not read as
 *  words, but the substitutions written in it run (`${X:-$(cmd)}` runs cmd when X is unset, `${X#$(cmd)}` always; measured on
 *  bash 3.2 and 5.2, dash, zsh): they are its lines ({@link parameterOperandLines}, the reading the read station's planner
 *  takes of the same operand), and the expansion stays hidden — whether the operand is expanded, and what it yields, the
 *  text does not say. The one reading of what an expansion runs: {@link expansionHidesRun} is its boolean face. */
export interface ExpansionRuns {
    readonly lines: readonly string[];
    readonly hidden: boolean;
}
/** `quoted`: the expansion stands in double quotes (a here-document body and an arithmetic text expand as such) — how its
 *  operand's quotes read ({@link parameterOperandLines}). */
export declare function expansionRunsOf(e: WordExpansion, quoted?: boolean): ExpansionRuns;
/** An arithmetic text's runs: none when it is plain ({@link arithmeticTextIsPlain}); else hidden (the evaluator may run
 *  what a value names), with the lines of the substitutions it holds, read as double-quoted text
 *  ({@link expansionsInHeredocBody}: quotes are ordinary characters there). */
export declare function arithmeticTextRunsOf(text: string): ExpansionRuns;
/** Can evaluating this expansion run a program ({@link expansionRunsOf}: a line its substitutions run, or a run none of
 *  them shows)? */
export declare function expansionHidesRun(e: WordExpansion): boolean;
/**
 * The words an assignment word stores, each the ONE assignment bash performs: the word itself, or — a compound value
 * `NAME=(…)` the lexer read element by element — each element's scalar assignment ({@link CompoundElement.stored}:
 * `NAME[k]=v` / `NAME=v`); a compound value it did not read that way is the word itself, its `compound_array_value`
 * standing. Every reader of what a word's value runs or cannot be read reads these, so an element is judged exactly as
 * the scalar assignment of the same text (`A=(${P@P})` as `A=${P@P}`, `A=([x]=1)` as `A[x]=1`, `A=("$@")` as `A="$@"`).
 */
export declare function assignedWords(w: LexedWord): readonly LexedWord[];
/** Does the parameter body (`P@P`, `a[i]@P`) carry a transformation that EVALUATES the value — `${P@P}` expands P's value
 *  as a prompt string, its parameter, command and arithmetic expansions run (measured on 5.3) — rather than respelling it? */
export declare function transformEvaluates(body: string): boolean;
/** Does evaluating a parameter expansion with this body RE-READ the parameter's own VALUE — an indirect `${!R}` (R's
 *  value names what is then expanded, so `R='a[$(…)]'` evaluates that subscript; a name list `${!prefix*}` / a key list
 *  `${!a[@]}` expand names only) or an evaluating transform `${P@P}` (the value is expanded as a prompt string, its own
 *  expansions run)? The one reading every consumer uses for "the value runs what the text does not show": the read
 *  station asks (it does not follow the value), the deny lanes and auto-background read it a hidden run through
 *  {@link expansionHidesRun}. A subscript or substring offset re-reads the BODY's own text, not the value — that is
 *  {@link parameterArithmeticTexts}. A line continuation in the body is removed first (`${P@\⏎P}` is `${P@P}`). */
export declare function parameterRereadsValue(body: string): boolean;
/** Is the arithmetic text (an arithmetic command's interior) provably free of a variable — the same reading
 *  {@link expansionHidesRun} gives an arithmetic expansion? */
export declare function arithmeticTextIsPlain(text: string): boolean;
/** Does an assignment word's subscript (`A[x]=v`, an element `[x]=v` read as {@link assignedWords} does) hide a run? An
 *  indexed array's subscript is arithmetic bash evaluates as the assignment runs: anything but digits and operators may
 *  evaluate a value the text does not show (`x='b[$(…)0]'; A[x]=1`). The deny lanes and auto-background ask it alike. */
export declare function subscriptHidesRun(w: LexedWord): boolean;
/** What expanding a word runs ({@link ExpansionRuns}), read on the words an assignment stores ({@link assignedWords}): the
 *  lines its expansions' substitutions run, and `hidden` where an expansion may run what no line shows, an assignment
 *  subscript may ({@link subscriptHidesRun}), or a compound value the lexer did not read element by element stands (it may
 *  run anything). The deny lanes' one reading of a word. */
export declare function wordRunsOf(w: LexedWord): ExpansionRuns;
/** Does a word run a program — a line its substitutions run, or a run none of them shows ({@link wordRunsOf})? */
export declare function wordHidesRun(w: LexedWord): boolean;
/** Does the word standing right before the token `next` name the descriptor `next` opens (`{fd}>file`, `{fd}<<EOF`) — to bash
 *  ≥ 4.1, which allocates it; to bash 3.2 the word is an argument ({@link LexedRedirect.allocated}, the lexer's one reading). */
export declare function namesRedirectDescriptor(next: LexedToken | undefined): boolean;
/** The words of a segment that name the descriptor of the redirection after them ({@link namesRedirectDescriptor}): what bash
 *  ≥ 4.1's reading of the argv drops (bash 3.2 keeps them as arguments). */
export declare function descriptorNameWords(segment: LexedSegment): ReadonlySet<LexedWord>;
/** The text a word's pieces hand the program when every piece is literal; `undefined` when one is an expansion or
 *  unresolved. */
export declare function literalTextOf(pieces: readonly WordPiece[]): string | undefined;
/** The text an UNQUOTED here-document body delivers when the shell expands nothing in it: a backslash before `$`, a
 *  backquote or a backslash is removed (a line continuation was joined when the body was read), every other character
 *  stands. `undefined` when an unescaped `$` or backquote stands in it: the program reads what the expansion makes. */
export declare function literalHeredocBody(body: string): string | undefined;
/** An UNQUOTED here-document body as the pieces of the one text it delivers: each expansion where it stands ({@link
 *  expansionsInHeredocBody}) and the literal runs between them as the program receives them (a `$` that opens no
 *  expansion stands). `undefined` when an expansion never closes. */
export declare function heredocBodyPieces(body: string): readonly WordPiece[] | undefined;
/** The connector bash reaches segment `si` through: its own, except a line break that only continues a pipe — bash reads on
 *  past line breaks (and a comment) after a `|`, so a segment with only empty segments between it and a `|` is that pipe's (the
 *  segments list keeps the empty one the `|` opened, and each line break after it as one more). */
export declare function connectorReaching(segments: readonly LexedSegment[], si: number): LenientConnector;
/** Lex a command `shell` runs: its segments, or the one reason bash (or this lexer) cannot delimit them — with the segments read
 *  before it ({@link LexParseFailure.readBefore}). A text a shell other than bash runs is never read as a whole: it is read as bash
 *  and stops with `started_shell_not_bash` — where bash's reading stopped, else at its end — so every statement read before the stop
 *  is a run and the one it stops in is judged as far as the stop ({@link segmentsAroundStop}). */
export declare function lexShell(shell: StartedShell, source: string): ShellLex;
/** How many characters, in all, the readings past one stop are charged before no new one starts ({@link segmentsPastStop}):
 *  each reading is charged the text its walks read — from where it starts to the furthest place any of them reached
 *  ({@link readTo}), at least one character; the last one started may run past the budget. Past it no boundary is read from:
 *  what stands after it is read by no reading, and stays inside the text the lexer did not read — the unreadable segment it
 *  stopped in reaches to the text's end ({@link LexParseFailure.readBefore}), so every reader still takes the whole text as one
 *  it cannot read. A script of a megabyte with a stop the shell reads past on every line is charged well under it (a reading
 *  ends where it meets a statement an earlier one opened); one where a construct that never closes, or that a walk reads far
 *  into before giving up, opens on line after line is not. */
export declare const READ_PAST_STOP_BUDGET: number;
/**
 * The statements written past the place the lexer stopped ({@link LexParseFailure}), as segments a shell MAY run. Where the
 * lexer stops, a shell need not: bash 5 reads past a `case` in a substitution and a here-document delimiter spelled with a
 * `$`, and runs every statement after them. The lexer cannot say where such a construct ends, so it does not guess: it
 * starts reading again at EVERY statement boundary past the stop (a line break, `;`, `&`, `|` — never between the two
 * characters of `&&`, `||`, `|&`, `;;`, `;&` or `&>`) and keeps every complete
 * segment any such reading reads, each once (by where it starts), in the order they stand. The lexer carries nothing from
 * one statement to the next but a here-document body owed and an arithmetic command left open: a reading does not start
 * where an earlier reading opened a statement with neither, and ends where it opens one so itself at such a place — from
 * there on the two read alike. A reading that starts inside the construct, or inside text another reading took as quoted
 * or as a here-document's body, may read a piece of it as a statement: such a piece is judged as one (a question or a
 * refusal about text that would not run), and what it may bind is a binding for the statements after it. Each segment is
 * {@link LexedSegment.spliced} — whether it runs is not proven, so what it binds is a candidate — and a reading's first
 * one stands after a line break; offsets are the whole text's. The construct itself — the segment the lexer stopped in —
 * is in none of them: what it runs stays unread. The readings start past both the stop and the start of that segment: an
 * unterminated here-document's body, read to the text's end, is no text past it. They are bounded by
 * {@link READ_PAST_STOP_BUDGET}.
 */
export declare function segmentsPastStop(source: string, failure: LexParseFailure): readonly LexedSegment[];
/**
 * The refused-reading view of {@link lexShell}: a parse failure, and any word whose value cannot be read off the
 * text, become the one `{ reject }` sentence a consumer's unreadable arm already takes. A reader that keeps the
 * other words (the read station) reads {@link lexShell} and the word's {@link LexedWord.unresolved} instead.
 */
export declare function lexShellText(shell: StartedShell, source: string): LexedCommand | {
    reject: string;
};
/** The constructs of this dialect the command leans on — what a POSIX `sh` would read as something else. Empty
 *  when the command reads the same under either shell's word grammar. */
export declare function bashOnlyConstructsOf(command: LexedCommand): readonly BashOnlyConstruct[];
export {};
