Universal Arrow Grammar
The 7-stage Universal Arrow Pipeline, attribute cradles, temporal gates, multi-level scoping, and diagram-type permissibility.
Every directed connection in Dhi—whether a sequence message, state transition, activity control flow, class relationship, or generic channel—follows a single unified arrow pipeline inside flow { ... }.
The 7-Stage Universal Arrow Pipeline
[Source] [on <Trigger>] [if "<guard>" | else] (-> | -[]-> | -[attrs]->) [Modifier] [Target] [: Payload] ({ do "<action>"; } | ;)- 1. Source ([Source]): Originating entity (Lifeline, State, Action, Class, Node). Explicit at Level 0; implicitly bound at Level 1 & Level 2.
- 2. Trigger ([on <Trigger>]): Stimulus event (signal, call, timeout). Optional for completion flows.
- 3. Pre-Check Gate ([if "<guard>" | else]): Pure boolean condition evaluated before traversing the path.
- 4. Arrow Shaft (-> / -[attrs]->): Directed connection with optional inline attribute cradle for id, timeout, min/max, bus_width, and edge pin notes.
- 5. Modifier ([Modifier]): Traversal semantics and line styling (reply, async, timed, destroy, extends, implements, associates, composes, internal, interrupt).
- 6. Target ([Target]) & Payload ([: Payload]): Destination entity and optional message/label payload.
- 7. Action Effect ({ do "<action>"; }): Procedural mutation or event emission executed during or immediately after traversal (State Machine & Activity).
Arrow Shafts, Cradles & Returns
Dhi uses -> as the single universal forward arrow operator—there is no separate --> token. Dashed sequence returns use -> reply, metadata sits inside the shaft cradle -[...]->, and synchronous calls support inline return legs via => or =[id: @res]=>.
// Explicit arrow IDs for layout & theme targeting
Client -[id: @loginReq, timeout: 50ms]-> AuthSvc.login: "POST /login" =[id: @loginRes]=> "200 OK";
// Edge pin note inside the arrow cradle (zero layout footprint)
Gateway -[note: "Requires mTLS"]-> PaymentSvc.charge: "Charge()";
// Bidirectional association (Class associates & Generic full-duplex)
Order[1] <-> OrderItem[1..*]: associates;Temporal Separation: Pre-Check vs. Action
Dhi strictly separates conditions checked before traversal from side effects executed during traversal: if / else guards appear before the arrow shaft, while action effects appear inside the trailing { do ...; } block.
AwaitingPayment on PayClicked {
if order.balance > 0 -> Paid { do "emitReceipt()"; }
else -> Rejected { do "logDecline()"; }
}Multi-Level Scope Splitability
To eliminate repetition, Dhi connectors support three hierarchical scoping levels where Source and Trigger are inferred from the enclosing block.
flow {
// Level 0: Flat diagram scope (explicit Source & Trigger)
Idle on Start -> Active;
// Level 1: Entity scope (Source implicitly bound to CheckStock)
CheckStock {
if "qty > 0" -> Ship;
else -> Backorder;
}
// Level 2: Trigger scope (Source & Trigger both inferred)
Active {
on Timeout {
if "retries >= 3" -> Terminated { do "notifyOps()"; }
else -> Retrying;
}
}
}Diagram-Type Permissibility Matrix
| Slot | Sequence | Class | State Machine | Activity | Generic |
|---|---|---|---|---|---|
| Forward (-> / -[attrs]->) | Calls, returns, signals | Relationships | Transitions | Control & object flows | Node/port channels |
| Bidirectional (<->) | Forbidden (E001) | associates only | Forbidden (E001) | Forbidden (E001) | Full-duplex / bus |
| Inline Return (=>) | Sync call responses | Forbidden (E001) | Forbidden (E001) | Forbidden (E001) | Forbidden (E001) |
| Modifiers | reply, async, timed, destroy | extends, implements, associates, composes, aggregates, depends | internal | interrupt | dashed, dotted, solid, open, none, bold |
| Arrow Block ({ ... }) | Terminates with ; | Terminates with ; | { do; note; } | { do; note; } | Terminates with ; |
| Level 1 / Level 2 Scope | Level 1 (Lifeline.spec { }) | Forbidden (E001) | Level 1 & Level 2 | Level 1 (Control/Action) | Level 1 (Node/port) |