1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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
//! The `lowering` feature: the registrations every backend relies on.
//!
//! The `lowering` feature ([`LoweringFeature`], an [`FlmFeature`]) registers
//! what lowering needs on any backend:
//!
//! - the presentation vocabulary ([`super::super::pres`]), through
//! [`pres::register()`];
//! - the default lowering rules of the structural elements ([`super::rules`]),
//! among them the rule of the field element
//! ([`FIELD`](crate::lang::structural::FIELD)), which every field carries (a
//! macro that a construct absorbs as data, such as a `\label` written after
//! a heading; see [fields: data a construct
//! reads](crate::guide::concepts_overview#fields-data-a-construct-reads));
//! - the two native-set implications the lowering driver relies on
//! ([`native_implications`]);
//! - the service slot [`NAMER_SLOT`], through which the embedding program
//! gives the path of each artifact of an output, and the service slot
//! [`REGIONS_SLOT`], through which each backend states which of its outputs
//! are made of output regions.
//!
//! The rules are registered here so that they exist in every registry that
//! renders anything: the language layer creates a field node wherever a
//! declaration carries a field, and a construct that fails to read its field
//! must be reported regardless of which features are registered. A backend's own feature
//! ([`TextBackend`](crate::stdlib::backends::text::TextBackend), for
//! instance) is registered beside this one and adds the backend, its stages
//! and its output. Registering this feature twice into one registry is a
//! registry build error, so a package lists it once.
use Arc;
use crateArtifactNamer;
use crateRegionsOutput;
use crate;
use crateArity;
use crate;
use default_rules;
/// The name under which this feature is registered, `lowering`; also the
/// middle segment of its conditions' identifiers, `flm.lowering.*`
/// ([`super::error`]).
pub const FEATURE_NAME: &str = "lowering";
/// The service slot `flm.artifacts.namer`
/// ([`service_slot`](crate::core::registry::FeatureBuilder::service_slot)),
/// holding at most one [`ArtifactNamer`]: the embedding program's naming
/// scheme, which gives the path of each artifact of an output, relative to
/// the output location.
///
/// A service slot is the declaration, by the feature that owns an interaction,
/// of a dotted name, the type of the values the slot takes and its arity; any
/// feature, and the embedding program through the registry builder, may
/// contribute a value to it (see [`crate::core::services`]). The library reads and writes no files and
/// chooses no file path itself. A host that writes files contributes its
/// naming scheme here, so that a stage of any feature can ask for an
/// artifact's path before the artifact is made, for example to write a link
/// from a page to a file placed beside it. When the host contributes nothing,
/// the slot is empty and a stage then writes no file path. The slot is
/// declared by this feature, beside the vocabulary every backend shares,
/// because the artifacts of every backend get their paths through it.
pub const NAMER_SLOT: &str = "flm.artifacts.namer";
/// The service slot `flm.output.regions`, holding one [`RegionsOutput`] per
/// output whose entry artifact is made of output regions
/// ([`Regions`](crate::core::region::Regions)), in contribution order.
///
/// An output region is one named part of an output's entry artifact (the
/// document's content, each piece placed beside it, and on HTML the
/// stylesheets, the scripts, the title and the language). A stage that
/// assembles the regions in a layout other than the backend's final stage
/// (see [output regions and the final
/// stage](crate::guide::concepts_overview#output-regions-and-the-final-stage))
/// reads this slot to learn which outputs it can assemble. Each backend that
/// writes regions contributes its own value; the slot is declared by this
/// feature, beside the vocabulary every backend shares, since any backend's
/// output may be made of regions.
pub const REGIONS_SLOT: &str = "flm.output.regions";
/// The `lowering` feature: it registers the presentation vocabulary
/// ([`pres::register()`]), the default lowering rules of the structural
/// elements, the field element's among them ([`default_rules`]), the
/// native-set implications the driver relies on ([`native_implications`]),
/// and the service slots [`NAMER_SLOT`] and [`REGIONS_SLOT`] (see the module
/// documentation).
///
/// Every registry that renders anything needs this feature. Use
/// [`feature()`] to obtain it as a value a package entry can list.
;
/// The two [native-set implications](NativeImplication) the lowering driver
/// relies on, which this feature declares so that the registry build checks
/// every backend against them.
///
/// A backend's native set is the list of elements its emit stage writes
/// directly ([`BackendDef::native`](crate::core::registry::BackendDef::native)).
/// The driver ([`super::driver`]) stages two presentation elements on its
/// own, with no lowering rule declaring that it produces them, so plan
/// construction cannot see that a backend needs them:
///
/// 1. A backend whose native set holds any element carrying the
/// [`Decoration`] aspect must hold `flm.pres.deco-mark` too: the driver
/// moves such a decoration out of a content slot into an attached slot and
/// leaves that mark at its former position.
/// 2. Every backend must hold `flm.pres.unsupported`: the driver stages it
/// for a node of an accepted unrenderable element, for a node whose rule
/// failed, and for a node no rule lowers.
///
/// A backend missing one fails the registry build with
/// [`BuildError::NativeSetIncomplete`] instead of failing at lowering.
///
/// # Examples
///
/// ```
/// use flm_core::core::registry::NativeImplicationKind;
/// use flm_core::stdlib::backends::{lowering, pres};
///
/// let implications = lowering::native_implications();
/// assert_eq!(implications[0].must_claim, pres::DECO_MARK);
/// assert_eq!(implications[1].must_claim, pres::UNSUPPORTED);
/// assert_eq!(implications[1].kind, NativeImplicationKind::Always);
/// ```
/// The `lowering` feature as a shared value, ready to be listed in a package
/// entry.
///
/// # Examples
///
/// ```
/// use flm_core::stdlib::backends::lowering;
///
/// assert_eq!(lowering::feature().info().name.as_str(), lowering::FEATURE_NAME);
/// ```