/** * Expression Lowering * * Transforms MEL Canonical IR (8 kinds) to Core Runtime IR (30+ kinds). * * @see SPEC v0.4.0 §17 */ import type { ExprNode as CoreExprNode } from "@manifesto-ai/core"; import type { ExprLoweringContext } from "./context.js"; /** * MEL primitive value. */ export type MelPrimitive = null | boolean | number | string; /** * MEL path segment. */ export type MelPathSegment = { kind: "prop"; name: string; }; /** * MEL path node array. */ export type MelPathNode = MelPathSegment[]; /** * MEL system path as segment array. */ export type MelSystemPath = string[]; /** * MEL object field. */ export type MelObjField = { key: string; value: MelExprNode; }; /** * MEL Canonical IR (8 kinds). * * @see SPEC v0.4.0 §17.1.1 */ export type MelExprNode = { kind: "lit"; value: MelPrimitive; } | { kind: "var"; name: "item"; } | { kind: "sys"; path: MelSystemPath; } | { kind: "get"; base?: MelExprNode; path: MelPathNode; } | { kind: "field"; object: MelExprNode; property: string; } | { kind: "call"; fn: string; args: MelExprNode[]; } | { kind: "obj"; fields: MelObjField[]; } | { kind: "arr"; elements: MelExprNode[]; }; /** * Lower MEL expression to Core expression. * * @param input - MEL canonical IR expression * @param ctx - Lowering context * @returns Core runtime IR expression * @throws LoweringError if expression cannot be lowered * * @see SPEC v0.4.0 §17.3 */ export declare function lowerExprNode(input: MelExprNode, ctx: ExprLoweringContext): CoreExprNode;