SpecDraft 0.1
Sections

Lena control 0.1

This document is draft 0.1. This module depends on Lena core 0.1 and storage 0.1.

1 Frames and transfers

control 0.1 builds a program from a core signature, storage declarations, an entry pc, and a set of blocks with unique IDs. Block, cell, and binding IDs belong to separate namespaces. pc is the ID of the next block to choose. A frame holds a fixed input environment, a store that starts empty, and the current pc. If a parameter has to go into a cell, the entry path contains an explicit write. The adapter must preserve the source entry conditions that lead to this boundary.

Dispatch looks up the block for the current pc. If there is none, InvalidPc of lena-control-0.1 is observed. The block ID is an auxiliary diagnostic. If the block exists, its storage actions run in order. Then one of the following transfers runs.

  • control-jump p sets pc to p.
  • control-branch e p q evaluates the boolean expression e, then sets pc to p if it is true and to q if it is false.
  • control-return e evaluates e, an expression of the signature's result type, and returns the result.

Every transfer uses the same frame. An early return from an expression, or a fault or defect in an action or expression, ends the program at once. A storage defect keeps the lena-storage-0.1 module and its canonical code. The frame closes when the program ends. Resuming a caller and effects across frames are outside this boundary.

The graph built from the existing blocks that are syntactically reachable from the entry must be acyclic. Both edges of a branch count. An edge to a missing block is an edge that ends in a defect. The cycle check is static. A reachable cycle is unsupported for every input.

Conformance tests observe · the transfer chosen at a branch, cell state preserved at a join, InvalidPc for a missing entry or transfer target, transfers that never run, and rejection of reachable cycles.

2 Text form

Canonical output and token rules follow core §10. Cell, Actions, and E use the grammar of storage §2. Block IDs have the same range as U in the core.

Control  = (lena-control-0.1 W (params Param*) T (cells Cell*) (entry U) (blocks CBlock*))
CBlock   = (control-block U Actions Transfer)
Transfer = (control-jump U) | (control-branch E U U) | (control-return E)

Conformance tests observe · separation from core tags, the order of the block list, and the structural round trip of transfers and their targets.

Source revision 4259231 ·