summaryrefslogtreecommitdiff
path: root/src/library/val.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-08-16 22:14:27 +0200
committerLaurenz <laurmaedje@gmail.com>2020-08-16 22:39:21 +0200
commit30f16bbf6431ca0c174ca0a1abaa6a13ef50ab06 (patch)
treef5a5c0adad15840ebe24b39e77ff467862067c91 /src/library/val.rs
parent9f6137d8a829fe8f34554623495fa620252a0184 (diff)
Add Value type and replace dyn-nodes with call-exprs 🏗
- In addition to syntax trees there are now `Value`s, which syntax trees can be evaluated into (e.g. the tree is `5+5` and the value is `10`) - Parsing is completely pure, function calls are not parsed into nodes, but into simple call expressions, which are resolved later - Functions aren't dynamic nodes anymore, but simply functions which receive their arguments as a table and the layouting context - Functions may return any `Value` - Layouting is powered by functions which return the new `Commands` value, which informs the layouting engine what to do - When a function returns a non-`Commands` value, the layouter simply dumps the value into the document in monospace
Diffstat (limited to 'src/library/val.rs')
-rw-r--r--src/library/val.rs28
1 files changed, 0 insertions, 28 deletions
diff --git a/src/library/val.rs b/src/library/val.rs
deleted file mode 100644
index 9df55401..00000000
--- a/src/library/val.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-use super::*;
-
-/// `val`: Ignores all arguments and layouts its body flatly.
-///
-/// This is also the fallback function, which is used when a function name
-/// cannot be resolved.
-pub fn val(call: FuncCall, _: &ParseState) -> Pass<SyntaxNode> {
- let mut args = call.args;
- let node = ValNode {
- content: args.take::<SyntaxTree>(),
- };
- Pass::node(node, Feedback::new())
-}
-
-#[derive(Debug, Clone, PartialEq)]
-struct ValNode {
- content: Option<SyntaxTree>,
-}
-
-#[async_trait(?Send)]
-impl Layout for ValNode {
- async fn layout<'a>(&'a self, _: LayoutContext<'_>) -> Pass<Commands<'a>> {
- Pass::okay(match &self.content {
- Some(tree) => vec![LayoutSyntaxTree(tree)],
- None => vec![],
- })
- }
-}