Expand description
Parser for Fiducia processes.
Processes appear in .fi files as flat declarations with the proc
keyword. See crate::ast::process for the AST node documentation.
proc Notified() { irq?159 -> Handle_eth(); Notified(); }
proc Handle_eth() { handle_irq -> Dispatch(); }
proc Dispatch() { [rx] receive -> Skip [] [!rx] cleanup -> Skip; }
proc Reply(pkt: int) { [pass] o2d!pkt -> Skip [] [!pass] handle_ping -> Skip; }Every process referenced (Handle_eth, Dispatch) is declared in
the same file; receive, cleanup, handle_irq, handle_ping
are computation events declared as evt declarations, and irq,
o2d are channel names from the surrounding .fis.
Process names use UpperCamelCase. The header is
proc Name(args)? { body }, where args use the name: Type form.
Bodies are enclosed in {} and contain variable declarations (x: Type;)
interleaved with process expressions, separated by ;. Variable declarations
self-terminate with ;; process expressions use ; as the body-item
separator. Assignment statements and external calls belong in evt declarations.
§Operator precedence (loosest → tightest)
;— sequential composition (separates body items)[]/default— external choice; each branch must carry a discriminator. The parser checks structurally and recurses intoSeq’s first item and nestedChoice. The only deferred case isProcessRef, where the validator must resolve the name. See [is_valid_choice_branch].[b]— guard->— event prefix (right-associative; Hoare page 4)- atoms —
Skip,Div, parens, process referenceName(args)?
Concrete consequences:
e -> P [] e2 -> Q≡Choice([Prefix(e, P), Prefix(e2, Q)])— the prefix binds tighter than the choice, so each branch is its own prefix.e -> P ; Q≡(e -> P) ; Q— prefix tighter than;.[b] e -> P [] e2 -> Q≡Choice([Guard(b, Prefix(e, P)), Prefix(e2, Q)])— guard binds the first branch only. Outer-guarding the whole choice requires explicit parens:[b] (e -> P [] e2 -> Q).p1 ; p2 [] p3≡p1 ; (p2 [] p3)—;is loosest.
Parenthesisation cuts through: ( ... ) re-enters at the top of
the precedence chain (process).
§Limitations
Argument lists for process invocations and computation event references are currently restricted to identifiers (and integer literals for IRQ-style channel events).
Functions§
- parse
- Parse a process declaration:
@bind(...)? 'proc' Name(params) '{' body '}'.