This document defines the stable AST schema returned by parseMPD.
interface ParseResult {
ast: ProgramNode | null;
diagnostics: Diagnostic[];
}
ast is null when parsing fails fatally.diagnostics includes syntax and semantic diagnostics with spans.All nodes include a type discriminator and a span with start/end offsets and line/column positions.
interface SourcePosition {
offset: number;
line: number;
column: number;
}
interface SourceSpan {
start: SourcePosition;
end: SourcePosition;
}
interface ProgramNode {
type: "Program";
version: string;
body: TopLevelItem[];
span: SourceSpan;
}
TopLevelItem includes:
DeckDiagramDeclRuntimeDeclSelectorsDeclStylesDeclConstDeclSceneDeclBindingDeclPluginDeclMetaDeclUnknownBlockinterface SceneDeclNode {
type: "SceneDecl";
name: NameValue;
diagram?: NameValue;
items: SceneItem[];
span: SourceSpan;
}
interface StepDeclNode {
type: "StepDecl";
name: NameValue;
alias?: string;
statements: StepStmt[];
span: SourceSpan;
}
The expression tree includes literals, variables, objects, arrays, unary/binary expressions, function calls, and target expressions.
interface Diagnostic {
message: string;
severity: "error" | "warning";
span?: SourceSpan;
code?: string;
}
type strings are stable.