This document specifies the core WXML AST node types
interface Position {
start: number;
end: number;
start: {
line: number;
column: number;
},
end: {
line: number;
column: number;
},
range: [number, number]
}
type WXNode = WXScript | WXElement | WXComment | WXText;
interface Program extends Position {
type: "Program";
body: WXNode[];
comments: WXComment[];
errors: Array<WXLexerError | WXParseError>;
tokens: []; // placeholder for future feature
}
interface WXLexerError extends Position {
type: "WXLexerError";
value: string; // error.message
}
interface WXParseError extends Position {
type: "WXParseError";
value: string; // error.message
rawType: string; // error.name
}
interface WXScript extends Position {
type: "WXScript",
name: "wxs",
startTag: WXStartTag
endTag: WXEndTag | null
value: string | null;
error: WXScriptError | undefined;
body: [WXScriptProgram] | undefined;
}
interface WXElement extends Position {
type: "WXElement";
name: string;
children: WXNode[];
startTag: WXStartTag;
endTag: WXEndTag | null;
}
interface WXStartTag extends Position {
type: "WXStartTag";
name: string;
attributes: WXAttribute[];
selfClosing: boolean;
}
interface WXEndTag extends Position {
type: "WXEndTag";
name: string;
}
interface WXAttribute extends Position {
type: "WXAttribute";
key: string;
quote: '\'' | '\"';
value: string | null;
rawValue: string | null;
children: Array<WXAttributeInterpolation | WXText>;
interpolations: WXInterpolation[];
}
same with
WXAttributeInterpolation
interface WXInterpolation extends Position {
type: "WXInterpolation";
rawValue: string;
value: string;
}
interface WXText extends Position {
type: "WXText";
value: string;
}
<!-- I am a WXComment Node -->
interface WXComment extends Position {
type: "WXComment";
value: string;
}