kestrel.markets
Version:
A typed, token-efficient language + runtime for agentic trading: agents author bounded plans, the runtime fires them at the tick. CLI + typed library + MCP server.
34 lines • 1.99 kB
TypeScript
/**
* # parse — recursive-descent parser (canonical text -> the typed object model)
*
* The inverse projection of {@link ./print.ts} (ADR-0004): `parse(print(x))` deep-equals
* `x`, and `print(parse(text))` is byte-stable. The parser reads the {@link LineNode} tree
* the {@link ./lex.ts} lexer produces — a statement's header is one line, its clauses are
* the lines nested beneath, and a continued clause folds in via {@link flatten}.
*
* Design commitments:
* - **Fail closed** (ARCHITECTURE §6): every escape is a {@link KestrelParseError} with
* `line`/`col` and an instructive message (the text is read by LLM agents — it names
* what was expected and lists the legal alternatives). No silent clause-dropping.
* - **Registry-open names** (CONTEXT: Registry): any well-formed identifier parses as a
* series reference; resolution happens at arm time, never at parse time.
* - **`atomic` is refused, not faked** (ADR-0005): the keyword parses to a loud rejection.
* - **USING defaults thread through** (ARCHITECTURE §2): a statement inside a module with
* an ambient `USING` is fully qualified by merging the ambient with any explicit clause,
* so the elided form round-trips.
*/
import type { KestrelNode } from "./ast.ts";
export { KestrelParseError } from "./lex.ts";
/**
* Parse a Kestrel document into the typed object model. Returns a bare {@link Statement}
* when the text is a single statement with no module-level directives (so `parse(print(x))`
* round-trips a bare statement); otherwise a {@link Module}. Fails closed: any escape is a
* {@link KestrelParseError} carrying `line`/`col`.
*/
export declare function parse(src: string): KestrelNode;
/**
* Extract every ```` ```kestrel ```` fenced block from Markdown and parse each identically
* to a `.kestrel` file (ADR-0001). Returns one {@link KestrelNode} per block, in order.
*/
export declare function parseMarkdown(src: string): KestrelNode[];
//# sourceMappingURL=parse.d.ts.map