Skip to main content

Module process

Module process 

Source
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)

  1. ; — sequential composition (separates body items)
  2. [] / default — external choice; each branch must carry a discriminator. The parser checks structurally and recurses into Seq’s first item and nested Choice. The only deferred case is ProcessRef, where the validator must resolve the name. See [is_valid_choice_branch].
  3. [b] — guard
  4. -> — event prefix (right-associative; Hoare page 4)
  5. atoms — Skip, Div, parens, process reference Name(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 '}'.