quivers.dsl.emit¶
AST → canonical .qvr source. Walks a Module and produces text
that, when re-parsed by quivers.dsl.loads, compiles to the same
program.
emit
¶
AST -> .qvr source emit.
Walks a quivers.dsl.ast_nodes.Module
and produces canonical .qvr source text.
The emit is a one-way printer, not a panproto ParseEmitLens:
quivers' AST is already the resolved form. The printer's contract is
semantic: the emitted source, re-parsed by quivers.dsl.loads,
produces a Module that compiles to the same program as the
original AST. The printer is additionally a canonical fixed point:
emit(parse(emit(ast))) == emit(ast) byte for byte.
Canonical formatting conventions:
- 4-space indentation per nesting level.
- One blank line between top-level statements; a single trailing newline at end of file.
- Option blocks, constructor brace options, lists, and tuples are always emitted inline.
- Doc comments are emitted as
#! textlines directly above the declaration they document. - Numeric option values and draw-arg scalars render integral floats
as
X.0; constructor keyword arguments renderintvalues without a decimal point andfloatvalues inreprform. - Convenience fields that mirror option-block entries (
axes,via,over,reductionon program steps;leveloncompositionrides its own option block) are not re-emitted from the mirror: the option block is the single surface source.
EmitError
¶
Bases: Exception
Raised when an AST value has no valid .qvr surface form.
module_to_source
¶
module_to_source(module: Module) -> str
Serialize a Module AST to canonical .qvr source.
Source code in src/quivers/dsl/emit.py
171 172 173 174 | |