From facd2c587d96510c5a808f19d37b40c1fc2d2618 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 11 Nov 2019 17:20:48 +0000 Subject: Parse projection by expression --- dhall_syntax/src/printer.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'dhall_syntax/src/printer.rs') diff --git a/dhall_syntax/src/printer.rs b/dhall_syntax/src/printer.rs index 19ec781..ce6ff97 100644 --- a/dhall_syntax/src/printer.rs +++ b/dhall_syntax/src/printer.rs @@ -66,6 +66,9 @@ impl Display for ExprF { write!(f, "{}.", e)?; fmt_list("{ ", ", ", " }", ls, f, Display::fmt)?; } + ProjectionByExpr(a, b) => { + write!(f, "{}.({})", a, b)?; + } Var(a) => a.fmt(f)?, Const(k) => k.fmt(f)?, Builtin(v) => v.fmt(f)?, @@ -159,7 +162,9 @@ impl RawExpr { // Precedence is magically handled by the ordering of BinOps. ExprF::BinOp(op, _, _) if phase > PrintPhase::BinOp(*op) => true, ExprF::App(_, _) if phase > PrintPhase::App => true, - Field(_, _) | Projection(_, _) if phase > PrintPhase::Import => { + Field(_, _) | Projection(_, _) | ProjectionByExpr(_, _) + if phase > PrintPhase::Import => + { true } _ => false, @@ -196,6 +201,7 @@ impl RawExpr { ), Field(a, b) => Field(a.phase(Primitive), b), Projection(e, ls) => Projection(e.phase(Primitive), ls), + ProjectionByExpr(a, b) => ProjectionByExpr(a.phase(Primitive), b), e => e, }; -- cgit v1.2.3