diff options
Diffstat (limited to 'src/library/val.rs')
| -rw-r--r-- | src/library/val.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/library/val.rs b/src/library/val.rs new file mode 100644 index 00000000..8e431049 --- /dev/null +++ b/src/library/val.rs @@ -0,0 +1,28 @@ +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, state: &ParseState) -> Pass<SyntaxNode> { + let mut f = Feedback::new(); + let node = ValNode { + body: parse_body_maybe(call.body, state, &mut f), + }; + Pass::node(node, f) +} + +#[derive(Debug, Clone, PartialEq)] +struct ValNode { + body: Option<SyntaxTree>, +} + +#[async_trait(?Send)] +impl Layout for ValNode { + async fn layout<'a>(&'a self, _: LayoutContext<'_>) -> Pass<Commands<'a>> { + Pass::okay(match &self.body { + Some(tree) => vec![LayoutSyntaxTree(tree)], + None => vec![], + }) + } +} |
