Reference checks¶
references
¶
Prose references to declarations in a literate module.
The prose of a literate document names declarations with the role
{qvr:ref}`Name`. A reference is resolved like a name written in the
module's code, in the scope of the module the document tangles to: a bare
name is one of the module's declarations (or a member of one, such as a
deduction's generated Grammar.Item), and M.name is a declaration of
an imported module M. A reference that resolves to nothing is refused
with its document line and column, so renaming a declaration breaks the
prose that names it rather than leaving it silently stale.
prose_references finds
the references of a document; check_references resolves them.
ReferenceProblem
didactic-model
¶
ReferenceProblem(*, reference: ProseReference, message: str)
Bases: Model
A prose reference that names no declaration.
| PARAMETER | DESCRIPTION |
|---|---|
reference
|
The reference.
TYPE:
|
message
|
Why it does not resolve.
TYPE:
|
declared_names
¶
declared_names(flat: FlatProgram, module: QiecModule | None) -> frozenset[str]
Every flat-program name a reference may denote.
| PARAMETER | DESCRIPTION |
|---|---|
flat
|
The interpreted module graph.
TYPE:
|
module
|
Its checked core, whose generated declarations (deduction items, constructors, derived instances) are named there.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
frozenset[str]
|
The names of the flat program's statements and of the core's families, constructors, index sorts, computations, entries, effects, instances, handlers, and structure declarations. |
Source code in src/quivers/literate/references.py
check_references
¶
check_references(references: Iterable[ProseReference], graph: ModuleGraph, known: frozenset[str]) -> tuple[ReferenceProblem, ...]
Resolve prose references in the scope of a document's module.
| PARAMETER | DESCRIPTION |
|---|---|
references
|
The references.
TYPE:
|
graph
|
The loaded graph rooted at the document's module.
TYPE:
|
known
|
The names the program declares (
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[ReferenceProblem, ...]
|
One problem per reference that names no declaration, empty when all resolve. |
Source code in src/quivers/literate/references.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |