@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
62 lines • 1.75 kB
TypeScript
import { type TSNodeLike } from '../../shell/types.ts';
export declare const PATTERN_OPS: ReadonlySet<string>;
/** One token of a `[[ ]]` expression: an operator's text, or an operand node. */
export type ExprToken = {
readonly op: string;
readonly operand: null;
} | {
readonly op: null;
readonly operand: TSNodeLike;
};
/** A parsed `[[ ]]` expression, its leaves holding their operand nodes. */
export type CondTree = {
kind: 'and' | 'or';
left: CondTree;
right: CondTree;
} | {
kind: 'not' | 'group';
inner: CondTree;
} | {
kind: 'unary';
op: string;
operand: TSNodeLike;
} | {
kind: 'binary';
op: string;
left: TSNodeLike;
right: TSNodeLike;
} | {
kind: 'word';
operand: TSNodeLike;
};
/** The tokens are no expression the `[[ ]]` grammar reads. */
export declare class CondSyntax extends Error {
}
/**
* The tokens of a `[[ ]]` node in source order, which its grammar
* (`CondParser`) reads: every reader of the test reads these. The parser
* splits the test into bash's words and operators, a `-x` an operator only
* where bash reads one.
*/
export declare function condTokens(node: TSNodeLike): ExprToken[];
export declare class CondParser {
private readonly tokens;
private at;
constructor(tokens: ExprToken[]);
private op;
private operand;
private take;
parse(): CondTree;
private either;
private both;
private term;
private test;
}
/**
* The tests of a parsed `[[ ]]` expression in source order: its unary,
* binary and word leaves, each a test of its own.
*/
export declare function condLeaves(tree: CondTree): Extract<CondTree, {
kind: 'unary' | 'binary' | 'word';
}>[];
//# sourceMappingURL=test_tokens.d.ts.map