The PXAML pipeline transforms declarative UI markup into executable user interfaces.
PXAML (Markup) → Parser → IR (JSON) → Renderer → GUI/TUI/Web
The PXAML parser reads XML markup and produces an Abstract Syntax Tree (AST).
<!-- Input: PXAML --> <Window Title="Demo" Width="400"> <Button Content="Click me" Click="OnClick"/> </Window>
Parser tasks:
The AST is transformed into an Intermediate Representation (IR) - a JSON-based intermediate format.
{
"type": "Window",
"properties": {
"Title": { "value": "Demo", "type": "string" },
"Width": { "value": 400, "type": "number" }
},
"children": [
{
"type": "Button",
"properties": {
"Content": { "value": "Click me", "type": "string" }
},
"events": {
"Click": { "handler": "OnClick" }
}
}
]
}
IR properties:
Data bindings are analyzed and converted into executable structures.
<!-- PXAML with Binding --> <TextBox Text="{Binding Path=UserName, Mode=TwoWay}"/>
{
"type": "TextBox",
"properties": {
"Text": {
"type": "binding",
"path": "UserName",
"mode": "TwoWay"
}
}
}
The IR is translated by the target-specific renderer into native UI elements.
| Renderer | Output | Technology |
|---|---|---|
| GUI | Native Controls | LCL/WinAPI |
| TUI | Terminal characters | ANSI/VT100 |
| Web | DOM Elements | HTML/CSS |
type TWvdSPxamlParser = class public function Parse(const ASource: string): TWvdSIRNode; function ParseFile(const APath: string): TWvdSIRNode; end;
type TWvdSIRNode = class NodeType: string; Properties: TWvdSPropertyMap; Children: TWvdSIRNodeList; Events: TWvdSEventMap; Bindings: TWvdSBindingList; end;
type TWvdSRenderer = class abstract public procedure Render(ARoot: TWvdSIRNode); virtual; abstract; procedure Update(AOldRoot, ANewRoot: TWvdSIRNode); virtual; abstract; end;
The pipeline supports hot reload through IR differentiation:
1. New PXAML → Parser → New IR 2. Diff(Old IR, New IR) → Patch List 3. Renderer.ApplyPatches(Patch List)
Benefits:
| Error Type | Phase | Handling |
|---|---|---|
| XML syntax error | Parsing | Position + message |
| Unknown element | Parsing | Warning + fallback |
| Invalid property type | IR | Type coercion + warning |
| Binding error | Binding | Fallback value |