flowrep.compiler.statements module
- flowrep.compiler.statements.emit_body(recipe: Annotated[AtomicRecipe | ConstantRecipe | ForEachRecipe | IfRecipe | TryRecipe | WhileRecipe | WorkflowRecipe, FieldInfo(annotation=NoneType, required=True, discriminator='type')], label: str, in_syms: dict[str, str], required: dict[str, str], emitter: Emitter, alloc: NameAllocator) tuple[list[str], dict[str, str]][source]
Emit a branch/loop body that may be a workflow subgraph or a single node.
A reference-free
WorkflowRecipeis inlined as a subgraph (as before); any other node (atomic, or a referenced workflow) is emitted as one assignment.
- flowrep.compiler.statements.emit_workflow_body(recipe: WorkflowRecipe, in_syms: dict[str, str], required_out_syms: dict[str, str], emitter: Emitter, alloc: NameAllocator) tuple[list[str], dict[str, str]][source]
- flowrep.compiler.statements.flow_control_input_requirements(recipe: WorkflowRecipe) dict[tuple[str, str], str][source]
Required source-symbol names imposed by flow-control node inputs.
A flow-control node’s input port name is derived by the forward parser from the enclosing symbol feeding it. To round-trip those port names, every flow-control input fed by a sibling node must force that sibling’s output to be named after the port. Inputs fed directly from a workflow input (an
InputSource) need no requirement – the parameter already carries the matching name. Referenced and nested-workflow nodes impose no requirement, since their calls pass arguments by keyword regardless of the symbol names.
- flowrep.compiler.statements.label_base(label: str) str[source]
Strip the trailing ‘_N’ numeric suffix that label_helpers.unique_suffix appended.
When re-parsing, the workflow_parser calls
unique_suffix(function.__name__, existing_labels)to re-derive the node label. If the nested def’s__name__is the base (pre-suffix) of the original label, unique_suffix regenerates the same label on round-trip.Examples
‘my_add_0’ → ‘my_add’ ‘for_each_2’ → ‘for_each’ ‘plain’ → ‘plain’ (no numeric suffix; returned as-is)
- flowrep.compiler.statements.node_call_path(node: Annotated[AtomicRecipe | ConstantRecipe | ForEachRecipe | IfRecipe | TryRecipe | WhileRecipe | WorkflowRecipe, FieldInfo(annotation=NoneType, required=True, discriminator='type')], label: str, emitter: Emitter, alloc: NameAllocator) str | None[source]
Resolve the call path for a node that emits as a single call expression.
Returns the dotted call path for a referenced node (adding its import) or the local function name for a reference-free
WorkflowRecipe(emitting a nested def). ReturnsNonefor flow controls, which cannot be expressed as a single call.
- flowrep.compiler.statements.render_call(call_path: str, node: Annotated[AtomicRecipe | ConstantRecipe | ForEachRecipe | IfRecipe | TryRecipe | WhileRecipe | WorkflowRecipe, FieldInfo(annotation=NoneType, required=True, discriminator='type')], in_resolver: Callable[[str], str]) str[source]
Render a call expression. in_resolver(port) returns a symbol or raises.