pub struct ConstructGrammar {
pub shape: String,
pub keyword: String,
pub slots: Vec<ConstructGrammarSlot>,
pub payload: Option<Vec<ConstructGrammarPayloadField>>,
pub binding: String,
pub target_capability: String,
pub clauses: Option<Vec<ConstructGrammarClause>>,
}Expand description
A DR-0011 grammar object: the single source of the construct’s parse shape.
Kept as plain validated strings, matching the rest of the registration data.
Two shapes are manifest-expressible: effect_operation
(CONSTRUCT_GRAMMAR_SHAPE_EFFECT_OPERATION, <keyword> [<connective> <slot>]* [{ payload }]? as <binding>) and declaration_block
(CONSTRUCT_GRAMMAR_SHAPE_DECLARATION_BLOCK, an order-free block of named
clauses). The shape string discriminates: clauses is Some exactly for
declaration_block, and slots/payload/binding/target_capability
carry the effect_operation shape (empty/None/"none"/empty otherwise).
Fields§
§shape: String§keyword: String§slots: Vec<ConstructGrammarSlot>§payload: Option<Vec<ConstructGrammarPayloadField>>None = no payload block; Some(fields) = a { ... } block of named
expression fields.
binding: Stringrequired | optional | none — the trailing as <binding> policy.
target_capability: String§clauses: Option<Vec<ConstructGrammarClause>>Some(clauses) for a declaration_block shape; None for
effect_operation (the shape string discriminates — the design note
picked Option over a shape enum because shape already carries the
discriminant, for the smaller diff).
Implementations§
Source§impl ConstructGrammar
impl ConstructGrammar
Sourcepub fn derive_fields(&self) -> Vec<ConstructField>
pub fn derive_fields(&self) -> Vec<ConstructField>
Derive the flat fields[] view downstream consumers read.
For a declaration_block shape, each clause becomes one field: a flag
clause maps to an optional boolean field (a flag carries no value, so
it is never required); a list clause flattens into the list field
kind (carrying the clause’s own required flag); any other clause maps its
value kind through field_kind_for_clause_kind with the clause’s
required flag. A declaration_block has no trailing as <binding>, so no
binding field is appended.
For an effect_operation shape: the ordered slots (always required),
then the payload fields with their own required flags, then — unless the
binding mode is none — the trailing binding as an identifier field
named binding (required when the mode is required).
Trait Implementations§
Source§impl Clone for ConstructGrammar
impl Clone for ConstructGrammar
Source§fn clone(&self) -> ConstructGrammar
fn clone(&self) -> ConstructGrammar
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConstructGrammar
impl Debug for ConstructGrammar
impl Eq for ConstructGrammar
Source§impl PartialEq for ConstructGrammar
impl PartialEq for ConstructGrammar
Source§fn eq(&self, other: &ConstructGrammar) -> bool
fn eq(&self, other: &ConstructGrammar) -> bool
self and other values to be equal, and is used by ==.