-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Difficulty: Medium — Parser must handle expr & prefix on ALT cases; codegen must conditionally enable/disable select cases (e.g., by setting channels to nil when the guard is false).
Summary
Occam ALT cases can have boolean guard pre-conditions using the & operator. A guard that evaluates to FALSE disables that ALT branch. Currently the parser does not support this syntax.
Occam syntax
ALT
running & in ? x
... only considered if running is TRUE
(NOT paused) & tim ? AFTER timeout
... only considered if paused is FALSE
TRUE & stop ? any
... always considered
Proposed Go mapping
select {
case x = <-in: // wrap in: if running { ... }
case <-time.After(...): // wrap in: if !paused { ... }
case any = <-stop: // always active
}For reflect.Select-based ALT replicators, disabled guards can be handled by setting the channel to nil (which makes a select case block forever, effectively disabling it).
Affected files
bar.occ(lines 327, 338, 352, 399, 402)
Work required
- Parser: Before parsing a channel input in ALT, check for
expr &guard prefix - AST: Add a
Guardexpression field to ALT case nodes - Codegen: Conditionally enable/disable select cases based on guard value
Part of #43.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels