Expand description
Parser and AST for the embassy-supervisor
task-graph DSL.
This crate exists because a proc-macro crate type cannot export anything
other than macros, so the grammar shared between embassy-supervisor-macros
and tooling lives here instead. The AST is an internal contract: it is not
a stable API and changes whenever the graph syntax does.
The parser checks grammatical shape (empty clauses, repeated paths, numeric ranges, and so on). Semantic checks such as duplicate names, missing fragments, or feature-gated constructs are left to callers.
Modules§
- kw
- Custom keywords used by the supervisor graph DSL.
Structs§
- Access
- One dataflow access discovered by scanning a
#[dataflow]fn body. - Adopted
Fn - A function adopted via a
dataflow: [ ... ]clause. - Common
Clauses - Clauses shared between
nodeandpooldeclarations. - Dep
- A single entry in a
deps: [ ... ]list. - Executor
Item - A parsed
executor NAME;declaration. - Gated
- A clause value together with the
#[cfg(...)]attributes gating it. - Graph
Spec - The parsed contents of a
supervisor_graph!orsupervisor_fragment!body. - Node
Item - A parsed
node NAME = Mode, ...;declaration. - Pool
Item - A parsed
pool NAME = [Mode, ...], ...;declaration. - Provide
Decl - A single
provides:entry: a resource-slot name, optionally#[cfg]-gated. - Resource
Decl - A single entry in a
resources: [ ... ]list. - Signal
Decl - A single entry in a
reads:orwrites:signal list. - Verb
Call - A single dataflow verb call discovered in a
#[dataflow]fn body. - Verb
Table - Registry of read/write verbs used when scanning a
#[dataflow]fn.
Enums§
- Item
- A top-level item inside a graph declaration.
- Resource
Kind - How a
resources:entry hands its value to the task, as one value the consumers branch on instead of probing the marker fields. - State
Init - How a node’s
state:initial value is specified. - Task
Source - How a node or pool member obtains its task future.
Constants§
- BUILTIN_
READS - Built-in read verb names recognised by the dataflow scanner.
- BUILTIN_
WRITES - Built-in write verb names recognised by the dataflow scanner.
Functions§
- apply_
default_ executor - Apply the graph’s default executor to nodes and pools that do not write
their own
executor:clause. Only items whose task source is atask:fn or aspawn:path/partial call are eligible; parked nodes and verbatimspawn:closures keep the supervisor’s executor. - cfg_
text - The
#[cfg]attributes’ token text, normalized for predicate comparison. - check_
signal_ list - Check that a
reads:orwrites:list is non-empty and has no duplicates. - dataflow_
attr - Unwrap a
#[dataflow]attribute, including any#[cfg_attr(...)]wrapper. - is_
dataflow_ attr - Return
trueifattris a#[dataflow]attribute, written directly or wrapped in#[cfg_attr(.., dataflow)]. Seedataflow_attr. - item_
executor - Return the
executor:an item routes through, if it names one. - item_
ident_ cfg - Return the identifying name and
#[cfg]attributes of an item, if it has one. - item_
resources - Return the resource declarations for an item, if any.
- item_
signal_ entries - Iterate over every signal entry declared by an item.
- name_
string - Convert an identifier to a lower-case, hyphenated string.
- node_
param - Find the name of the function argument whose type contains
TaskNode. - normalize_
fragment_ crate - Rewrite bare
cratepaths in a fragment body into$crate. - parse_
dep_ list - Parse a bracketed dependency list of the form
[A, B ready, C ready bound]. - parse_
mode_ list - Parse a bracketed list of pool member mode identifiers.
- parse_
node - Parse a
node NAME = Mode, ...;declaration after the leadingnodekeyword. - parse_
pool - Parse a
pool NAME = [Mode, ...], ...;declaration after the leadingpoolkeyword. - parse_
resource_ list - Parse a bracketed resource list such as
[SLOT: Type local shared]. - parse_
signal_ list - Parse a bracketed signal list such as
[S, T observed, U beat]. - path_
to_ string - Render a
syn::Pathas its::-separated string form. - peek_
kind_ marker - Look ahead for a resource kind marker (
local,consume,shared,divisible, orserialized). - rewrite_
verb_ calls - Walk a
#[dataflow]fn body and rewrite recognised verb calls. - scan_
dataflow - Scan Rust source for
#[dataflow]functions and append their accesses toout. - substitute_
dollar_ crate - Replace every
$crateoccurrence instreamwithreplacement. - task_
source - Resolve the optional
spawn:/task:clauses into aTaskSource. - verb_
table_ of - Build a
VerbTablefrom a#[dataflow(...)]attribute.