diff options
author | Nadrieril | 2019-08-13 22:11:45 +0200 |
---|---|---|
committer | Nadrieril | 2019-08-13 22:11:45 +0200 |
commit | 8d45d633dfa60e8d64c9e6e742de4e33496bf0fa (patch) | |
tree | 526c351bbdd6121cdde3cd56f721156d3b34e6de /dhall_syntax/src/printer.rs | |
parent | 07956ccb1daf4a6819f64776f70b6f5f26869184 (diff) |
Store Imports in their own node instead of in Embed
Diffstat (limited to 'dhall_syntax/src/printer.rs')
-rw-r--r-- | dhall_syntax/src/printer.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/dhall_syntax/src/printer.rs b/dhall_syntax/src/printer.rs index 48e56be..5f5f99b 100644 --- a/dhall_syntax/src/printer.rs +++ b/dhall_syntax/src/printer.rs @@ -88,6 +88,7 @@ impl<SE: Display + Clone, E: Display> Display for ExprF<SE, E> { } Ok(()) })?, + Import(a) => a.fmt(f)?, Embed(a) => a.fmt(f)?, } Ok(()) @@ -151,7 +152,9 @@ impl<A: Display + Clone> Expr<A> { // 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 > Import => true, + Field(_, _) | Projection(_, _) if phase > PrintPhase::Import => { + true + } _ => false, }; @@ -165,8 +168,8 @@ impl<A: Display + Clone> Expr<A> { } } Merge(a, b, c) => Merge( - a.phase(Import), - b.phase(Import), + a.phase(PrintPhase::Import), + b.phase(PrintPhase::Import), c.map(|x| x.phase(PrintPhase::App)), ), Annot(a, b) => Annot(a.phase(Operator), b), @@ -175,8 +178,11 @@ impl<A: Display + Clone> Expr<A> { a.phase(PrintPhase::BinOp(op)), b.phase(PrintPhase::BinOp(op)), ), - SomeLit(e) => SomeLit(e.phase(Import)), - ExprF::App(f, a) => ExprF::App(f.phase(Import), a.phase(Import)), + SomeLit(e) => SomeLit(e.phase(PrintPhase::Import)), + ExprF::App(f, a) => ExprF::App( + f.phase(PrintPhase::Import), + a.phase(PrintPhase::Import), + ), Field(a, b) => Field(a.phase(Primitive), b), Projection(e, ls) => Projection(e.phase(Primitive), ls), e => e, |