diff options
author | Nadrieril | 2019-04-19 14:42:36 +0200 |
---|---|---|
committer | Nadrieril | 2019-04-19 14:42:36 +0200 |
commit | 4bed7b11e227a3151a2ff9e74f9662c126aad5a4 (patch) | |
tree | 789479787c3652d9adce1511a37fbee69d9a73a7 /dhall_core | |
parent | 759705047eea74f538883c15b6abd3292bbebb13 (diff) |
Make App() only store one argument
Diffstat (limited to 'dhall_core')
-rw-r--r-- | dhall_core/src/core.rs | 2 | ||||
-rw-r--r-- | dhall_core/src/parser.rs | 4 | ||||
-rw-r--r-- | dhall_core/src/printer.rs | 13 | ||||
-rw-r--r-- | dhall_core/src/visitor.rs | 4 |
4 files changed, 7 insertions, 16 deletions
diff --git a/dhall_core/src/core.rs b/dhall_core/src/core.rs index 56ab66c..ab29148 100644 --- a/dhall_core/src/core.rs +++ b/dhall_core/src/core.rs @@ -150,7 +150,7 @@ pub enum ExprF<SubExpr, Label, Note, Embed> { /// `∀(x : A) -> B` Pi(Label, SubExpr, SubExpr), /// `f a` - App(SubExpr, Vec<SubExpr>), + App(SubExpr, SubExpr), /// `let x = r in e` /// `let x : t = r in e` Let(Label, Option<SubExpr>, SubExpr, SubExpr), diff --git a/dhall_core/src/parser.rs b/dhall_core/src/parser.rs index 2a30b2b..051a4e6 100644 --- a/dhall_core/src/parser.rs +++ b/dhall_core/src/parser.rs @@ -743,10 +743,10 @@ make_parser! { token_rule!(Some_<()>); - rule!(application_expression<ParsedExpr<'a>> as expression; span; children!( + rule!(application_expression<ParsedExpr<'a>> as expression; children!( [expression(e)] => e, [expression(first), expression(rest)..] => { - spanned(span, App(rc(first), rest.map(rc).collect())) + rest.fold(first, |acc, e| App(rc(acc), rc(e))) }, )); diff --git a/dhall_core/src/printer.rs b/dhall_core/src/printer.rs index 4d1ae2d..85105d9 100644 --- a/dhall_core/src/printer.rs +++ b/dhall_core/src/printer.rs @@ -56,12 +56,8 @@ impl<SE: Display + Clone, N, E: Display> Display for ExprF<SE, Label, N, E> { ExprF::BinOp(op, a, b) => { write!(f, "{} {} {}", a, op, b)?; } - ExprF::App(a, args) => { - a.fmt(f)?; - for x in args { - f.write_str(" ")?; - x.fmt(f)?; - } + ExprF::App(a, b) => { + write!(f, "{} {}", a, b)?; } Field(a, b) => { write!(f, "{}.{}", a, b)?; @@ -216,10 +212,7 @@ impl<S: Clone, A: Display + Clone> Expr<S, A> { OldOptionalLit(x, t) => OldOptionalLit(x, t.phase(Import)), EmptyOptionalLit(t) => EmptyOptionalLit(t.phase(Import)), NEOptionalLit(e) => NEOptionalLit(e.phase(Import)), - ExprF::App(a, args) => ExprF::App( - a.phase(Import), - args.into_iter().map(|x| x.phase(Import)).collect(), - ), + ExprF::App(f, a) => ExprF::App(f.phase(Import), a.phase(Import)), Field(a, b) => Field(a.phase(Primitive), b), Projection(e, ls) => Projection(e.phase(Primitive), ls), Note(n, b) => Note(n, b.phase(phase)), diff --git a/dhall_core/src/visitor.rs b/dhall_core/src/visitor.rs index 16ad418..9111414 100644 --- a/dhall_core/src/visitor.rs +++ b/dhall_core/src/visitor.rs @@ -130,9 +130,7 @@ where let (l, e) = v.visit_binder(l, e)?; Let(l, t, a, e) } - App(f, args) => { - App(v.visit_subexpr(f)?, vec(args, |e| v.visit_subexpr(e))?) - } + App(f, a) => App(v.visit_subexpr(f)?, v.visit_subexpr(a)?), Annot(x, t) => Annot(v.visit_subexpr(x)?, v.visit_subexpr(t)?), Const(k) => Const(*k), Builtin(v) => Builtin(*v), |