Skip to main content

Module protocol_parser

Module protocol_parser 

Source
Expand description

Causal protocol parser (REQ-201, SPEC-015 REQ-704).

Parses (protocol (then ...)+) S-expressions into CausalProtocol. Desugars variadic (then a b c) to pairwise edges: a→b, b→c.

§Bounded repetition (SPEC-015 REQ-704, CON-701)

A (repeat <k> <step>…) form may appear in step position inside a (then …) chain (and nowhere else); <k> is a nat (post-parse predicate: positive integer atom) and each <step> is a node-ref or a nested repeat. The form macro-expands once, at parse into k sequential copies of its body spliced into the enclosing chain, so the ordinary pairwise-edge desugaring chains the copies by :caused-by type references and R1–R3, R5, R6 run over the expanded protocol.

Synthesised copy names live in a non-user namespace: copy i of step x is x#i, and '#' (cbcl_core::protocol::REPEAT_SEPARATOR) is outside the legal symbol alphabet (parser::is_symbol_char; it introduces #t/#f), so collision with any user-declared performative is impossible by construction. Iteration seams are structural: a body ending in (any a b) seams as (any a#i b#i) → first-of-copy-i+1 (the choice over the alternatives’ copy-instances), one ending in (all …) seams on the fan-in’s copy-instance; nested repeat multiplies bounds and suffixes again (x#1#2).

Enums§

ProtocolParseError
Errors from parsing a (protocol ...) declaration.

Functions§

parse_protocol
Parse a (protocol (then ...)+) S-expression into a CausalProtocol (REQ-201).