summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-10-07 17:07:44 +0200
committerLaurenz <laurmaedje@gmail.com>2020-10-07 17:07:44 +0200
commit537545e7f8351d7677c396456e46568f5a5e2a7a (patch)
treef4c7614293246db06c7fa7496458da01b15c3b84 /src/lib.rs
parentca1256c924f3672feb76dbc2bc2e309eb4fc4cf5 (diff)
Evaluation and node-based layouting 🚀
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/lib.rs b/src/lib.rs
index ef81a8ae..6380b929 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -3,25 +3,33 @@
//! # Steps
//! - **Parsing:** The parsing step first transforms a plain string into an
//! [iterator of tokens][tokens]. This token stream is [parsed] into a [syntax
-//! tree]. The structures describing the tree can be found in the [ast]
+//! tree]. The structures describing the tree can be found in the [AST]
//! module.
-//! - **Layouting:** The next step is to transform the syntax tree into a
-//! portable representation of the typesetted document. The final output
-//! consists of a vector of [`BoxLayouts`] (corresponding to pages), ready for
-//! exporting.
-//! - **Exporting:** The finished layout can then be exported into a supported
+//! - **Evaluation:** The next step is to [evaluate] the parsed "script" to a
+//! [document], a high-level, fully styled representation. The [nodes] of the
+//! document tree are fully self-contained and order-independent and thus much
+//! better suited for layouting than the syntax tree.
+//! - **Layouting:** The next step is to [layout] the document into a portable
+//! version of the typesetted document. The output of this is a vector of
+//! [`BoxLayouts`] (corresponding to pages), ready for exporting.
+//! - **Exporting:** The finished layout can be exported into a supported
//! format. Submodules for these formats are located in the [export] module.
//! Currently, the only supported output format is [_PDF_].
//!
-//! [tokens]: parsing/struct.Tokens.html
-//! [parsed]: parsing/fn.parse.html
+//! [tokens]: parse/struct.Tokens.html
+//! [parsed]: parse/fn.parse.html
//! [syntax tree]: syntax/ast/type.SynTree.html
-//! [ast]: syntax/ast/index.html
-//! [layout]: layout/index.html
+//! [AST]: syntax/ast/index.html
+//! [evaluate]: eval/fn.eval.html
+//! [document]: layout/nodes/struct.Document.html
+//! [nodes]: layout/nodes/index.html
+//! [layout]: layout/fn.layout.html
//! [`BoxLayouts`]: layout/struct.BoxLayout.html
//! [export]: export/index.html
//! [_PDF_]: export/pdf/index.html
+#![allow(unused)]
+
#[macro_use]
pub mod diag;
@@ -55,10 +63,10 @@ pub async fn typeset(
state: State,
loader: SharedFontLoader,
) -> Pass<Vec<BoxLayout>> {
- let parsed = parse::parse(src);
- let layouted = layout::layout(&parsed.output, state, loader).await;
- let feedback = Feedback::join(parsed.feedback, layouted.feedback);
- Pass::new(layouted.output, feedback)
+ let Pass { output: tree, feedback: f1 } = parse::parse(src);
+ let Pass { output: document, feedback: f2 } = eval::eval(&tree, state);
+ let layouts = layout::layout(&document, loader).await;
+ Pass::new(layouts, Feedback::join(f1, f2))
}
/// A dynamic future type which allows recursive invocation of async functions