From 7e523ae1903ae2d8bca8b3a8352167d7bac5b2b5 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 14 Sep 2020 23:09:22 +0100 Subject: spec: Enable `with` optimizations --- dhall/src/syntax/text/parser.rs | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) (limited to 'dhall/src/syntax/text/parser.rs') diff --git a/dhall/src/syntax/text/parser.rs b/dhall/src/syntax/text/parser.rs index 06c1ac3..377f5e4 100644 --- a/dhall/src/syntax/text/parser.rs +++ b/dhall/src/syntax/text/parser.rs @@ -105,26 +105,6 @@ fn insert_recordlit_entry(map: &mut BTreeMap, l: Label, e: Expr) { } } -fn desugar_with_expr(x: Expr, labels: &[Label], y: Expr) -> Expr { - use crate::operations::BinOp::RightBiasedRecordMerge; - let expr = |k| Expr::new(k, Span::WithSugar); - match labels { - [] => y, - [l, rest @ ..] => { - let res = desugar_with_expr( - expr(Op(Field(x.clone(), l.clone()))), - rest, - y, - ); - expr(Op(BinOp( - RightBiasedRecordMerge, - x, - expr(RecordLit(once((l.clone(), res)).collect())), - ))) - } - } -} - lazy_static::lazy_static! { static ref PRECCLIMBER: PrecClimber = { use Rule::*; @@ -778,7 +758,11 @@ impl DhallParser { clauses.fold( first, |acc, (labels, e)| { - desugar_with_expr(acc, &labels, e) + spanned_union( + acc.span(), + e.span(), + Op(With(acc, labels, e)) + ) } ) }, -- cgit v1.2.3