From ec884ec1d85f6e1d7868db3e82d572579cc5d345 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 5 Oct 2022 12:49:39 +0200 Subject: Refactor syntax module --- src/eval/mod.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/eval') diff --git a/src/eval/mod.rs b/src/eval/mod.rs index 5bbac77e..cc9d3422 100644 --- a/src/eval/mod.rs +++ b/src/eval/mod.rs @@ -133,25 +133,25 @@ pub trait Eval { fn eval(&self, vm: &mut Vm) -> SourceResult; } -impl Eval for Markup { +impl Eval for MarkupNode { type Output = Content; fn eval(&self, vm: &mut Vm) -> SourceResult { - eval_markup(vm, &mut self.nodes()) + eval_markup(vm, &mut self.items()) } } /// Evaluate a stream of markup nodes. fn eval_markup( vm: &mut Vm, - nodes: &mut impl Iterator, + nodes: &mut impl Iterator, ) -> SourceResult { let flow = vm.flow.take(); let mut seq = Vec::with_capacity(nodes.size_hint().1.unwrap_or_default()); while let Some(node) = nodes.next() { seq.push(match node { - MarkupNode::Expr(Expr::Set(set)) => { + MarkupItem::Expr(Expr::Set(set)) => { let styles = set.eval(vm)?; if vm.flow.is_some() { break; @@ -159,7 +159,7 @@ fn eval_markup( eval_markup(vm, nodes)?.styled_with_map(styles) } - MarkupNode::Expr(Expr::Show(show)) => { + MarkupItem::Expr(Expr::Show(show)) => { let recipe = show.eval(vm)?; if vm.flow.is_some() { break; @@ -168,7 +168,7 @@ fn eval_markup( eval_markup(vm, nodes)? .styled_with_entry(StyleEntry::Recipe(recipe).into()) } - MarkupNode::Expr(Expr::Wrap(wrap)) => { + MarkupItem::Expr(Expr::Wrap(wrap)) => { let tail = eval_markup(vm, nodes)?; vm.scopes.top.define(wrap.binding().take(), tail); wrap.body().eval(vm)?.display() @@ -189,7 +189,7 @@ fn eval_markup( Ok(Content::sequence(seq)) } -impl Eval for MarkupNode { +impl Eval for MarkupItem { type Output = Content; fn eval(&self, vm: &mut Vm) -> SourceResult { @@ -252,12 +252,12 @@ impl Eval for RawNode { } } -impl Eval for Math { +impl Eval for MathNode { type Output = Content; fn eval(&self, vm: &mut Vm) -> SourceResult { let nodes = - self.nodes().map(|node| node.eval(vm)).collect::>()?; + self.items().map(|node| node.eval(vm)).collect::>()?; Ok(Content::show(library::math::MathNode::Row( Arc::new(nodes), self.span(), @@ -265,7 +265,7 @@ impl Eval for Math { } } -impl Eval for MathNode { +impl Eval for MathItem { type Output = library::math::MathNode; fn eval(&self, vm: &mut Vm) -> SourceResult { @@ -278,7 +278,7 @@ impl Eval for MathNode { Self::Align(node) => node.eval(vm)?, Self::Group(node) => library::math::MathNode::Row( Arc::new( - node.nodes() + node.items() .map(|node| node.eval(vm)) .collect::>()?, ), @@ -346,7 +346,7 @@ impl Eval for HeadingNode { } } -impl Eval for ListNode { +impl Eval for ListItem { type Output = Content; fn eval(&self, vm: &mut Vm) -> SourceResult { @@ -355,7 +355,7 @@ impl Eval for ListNode { } } -impl Eval for EnumNode { +impl Eval for EnumItem { type Output = Content; fn eval(&self, vm: &mut Vm) -> SourceResult { @@ -367,7 +367,7 @@ impl Eval for EnumNode { } } -impl Eval for DescNode { +impl Eval for DescItem { type Output = Content; fn eval(&self, vm: &mut Vm) -> SourceResult { -- cgit v1.2.3