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
//! Lowering: the stage that rewrites each frozen tree into the presentation
//! tree one backend emits, the driver that runs it, and the rules and helpers
//! every backend shares.
//!
//! **Lowering** rewrites each frozen tree into a presentation tree for one
//! backend, by applying the lowering rule selected for each element, in
//! rounds, until only elements the backend writes natively remain; the result
//! is computed data in the table `flm.lowered.<backend>` (see [backends,
//! lowering, and
//! outputs](crate::guide::concepts_overview#backends-lowering-and-outputs)).
//! The frozen trees themselves never change (see [frozen trees and computed
//! data](crate::guide::concepts_overview#frozen-trees-and-computed-data)).
//! After lowering, the backend's emitter writes the output from the lowered
//! trees (for the text backend, [`mod@super::text::emit`]).
//!
//! The terms this module relies on:
//!
//! - A **backend** is the registration bundle for one output format
//! ([`BackendDef`](crate::core::registry::BackendDef)). Every backend
//! registers exactly one lowering stage, [`LoweringStage`], a `Compute`
//! stage of `PerTree` scope named `flm.<backend>.lower`.
//! - A **lowering rule** is a named registry entity written for one element:
//! it declares what it requires, reads and produces, and implements `Lower`,
//! which stages (builds into the lowered tree) the element's presentation
//! for one backend ([`LoweringRule`](crate::core::lowering::LoweringRule)).
//! The plan selects one rule per element and backend.
//! - A **presentation node** is a node of a presentation element, an element
//! that never occurs in a source document ([`super::pres`]). A lowered tree
//! is built from presentation nodes and from nodes of the elements the
//! backend writes natively: where the frozen tree holds a paragraph, the
//! lowered tree holds `flm.pres.par`; where it holds a heading,
//! `flm.pres.block-heading`; where it holds a reference, a `flm.pres.link`
//! around the reference's displayed content.
//! - A **decoration** is a node whose element carries the
//! [`Decoration`](super::pres::Decoration) aspect. When a rule stages a
//! presentation node, the driver moves every decoration out of the node's
//! content slots into an attached slot of that node (see [decorations,
//! roles and kinds](crate::guide::concepts_overview#decorations-roles-and-kinds)).
//! - A **piece** is a document-level synthesized value that a backend places
//! before or after the document's content
//! ([`Piece`](crate::core::piece::Piece)); [`lower_value`] lowers one, for
//! the pieces stage ([`super::pieces`]).
//! - A **node region** is one of a node's arguments or one of its slots
//! ([`NodeRegion`](crate::core::lowering::NodeRegion)). A rule may lower a
//! node region of another node where its own node is placed, which is how a
//! [content pointer](ContentPointer) shows content written elsewhere.
//!
//! Every rule works through the [`Lowerer`], the only interface a lowering
//! rule has to the run, which the driver implements: through it the rule
//! lowers parts of its node, stages presentation nodes, splices a synthesized
//! value and lowers a node region of another node.
//!
//! # Module map
//!
//! - [`stage`] — [`LoweringStage`], the per-backend stage. The needs it
//! declares when the plan is built are the union of the selected rules'
//! declarations ([`rules_needs`], shared with every stage that lowers for a
//! backend), and the number of rounds it allows is [`rank`].
//! - [`driver`] — [`lower_tree`], which runs the rounds over one tree;
//! [`lower_value`], which runs them over a synthesized value, such as a
//! piece, after bringing it up to date; the implementation of the
//! [`Lowerer`] (lowering of a node's parts, staging of presentation nodes
//! with their provenance, decorations moved into attached slots, splicing a
//! synthesized value, and the checks that a rule reads only what it
//! declared). Also the helpers a rule calls: [`copy_subtree_verbatim`] and
//! [`copy_run_verbatim`] for opaque content; [`read_verbatim_content`] and
//! [`stage_verbatim_content`], through which every rule that stages
//! verbatim content reads it as characters, reporting content that is not
//! characters ([`ContentNotCharacters`]); [`lower_run`], which hands a run
//! of sibling nodes back to the ordinary rules; and [`lower_region_content`],
//! the plain shape of a node region lowered through
//! [`Lowerer::lower_region`](crate::core::lowering::Lowerer::lower_region).
//! - [`table`] — [`LoweredTrees`], the `flm.lowered.<backend>` table, and
//! [`LoweredAddr`], the address of a node inside a lowered tree.
//! - [`rules`] — the default lowering rules of the structural elements, and
//! the helpers that stage paragraphs and trimmed inline content for other
//! rules.
//! - [`mod@pointer`] — [`ContentPointer`], the payload of a synthesized node
//! that shows content written elsewhere without copying it, and
//! [`lower_content_pointer`], the lowering every such node's rule calls,
//! with a check supplied by the rule's own feature.
//! - [`error`] — the `flm.lowering.*` conditions and
//! `flm.verbatim.content-not-characters`, and the recovery after each.
//! - [`mod@feature`] — the `lowering` feature, which registers the
//! presentation vocabulary, the default rules, the two native-set
//! implications the driver relies on ([`native_implications`]) and two
//! service slots.
//!
//! [`Lowerer`]: crate::core::lowering::Lowerer
pub use ;
pub use lower_written_pieces;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;