From 711164a7a24ab832006b72cac162e78cf434861a Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 4 Aug 2019 11:11:37 +0200 Subject: Remove old-style optional literals --- dhall_syntax/src/core/expr.rs | 4 ---- dhall_syntax/src/core/visitor.rs | 4 ---- dhall_syntax/src/parser.rs | 18 +++--------------- dhall_syntax/src/printer.rs | 8 -------- 4 files changed, 3 insertions(+), 31 deletions(-) (limited to 'dhall_syntax/src') diff --git a/dhall_syntax/src/core/expr.rs b/dhall_syntax/src/core/expr.rs index da9465d..df2dc97 100644 --- a/dhall_syntax/src/core/expr.rs +++ b/dhall_syntax/src/core/expr.rs @@ -194,10 +194,6 @@ pub enum ExprF { EmptyListLit(SubExpr), /// `[x, y, z]` NEListLit(Vec), - /// Deprecated Optional literal form - /// `[] : Optional a` - /// `[x] : Optional a` - OldOptionalLit(Option, SubExpr), /// `Some e` SomeLit(SubExpr), /// `{ k1 : t1, k2 : t1 }` diff --git a/dhall_syntax/src/core/visitor.rs b/dhall_syntax/src/core/visitor.rs index 99a9c11..1745fdb 100644 --- a/dhall_syntax/src/core/visitor.rs +++ b/dhall_syntax/src/core/visitor.rs @@ -137,10 +137,6 @@ where ), EmptyListLit(t) => EmptyListLit(v.visit_subexpr(t)?), NEListLit(es) => NEListLit(vec(es, |e| v.visit_subexpr(e))?), - OldOptionalLit(x, t) => OldOptionalLit( - opt(x, |e| v.visit_subexpr(e))?, - v.visit_subexpr(t)?, - ), SomeLit(e) => SomeLit(v.visit_subexpr(e)?), RecordType(kts) => RecordType(dupmap(kts, v)?), RecordLit(kvs) => RecordLit(dupmap(kvs, v)?), diff --git a/dhall_syntax/src/parser.rs b/dhall_syntax/src/parser.rs index 9d9a374..db1699b 100644 --- a/dhall_syntax/src/parser.rs +++ b/dhall_syntax/src/parser.rs @@ -724,6 +724,9 @@ make_parser! { [merge(()), expression(x), expression(y), expression(z)] => { spanned(span, Merge(x, y, Some(z))) }, + [List(()), expression(x)] => { + spanned(span, EmptyListLit(x)) + }, [expression(e)] => e, )); @@ -738,21 +741,6 @@ make_parser! { token_rule!(List<()>); token_rule!(Optional<()>); - rule!(empty_collection as expression; span; children!( - [List(_), expression(t)] => { - spanned(span, EmptyListLit(t)) - }, - [Optional(_), expression(t)] => { - spanned(span, OldOptionalLit(None, t)) - }, - )); - - rule!(non_empty_optional as expression; span; children!( - [expression(x), Optional(_), expression(t)] => { - spanned(span, OldOptionalLit(Some(x), t)) - } - )); - rule!(import_alt_expression as expression; children!( [expression(e)] => e, [expression(first), expression(rest)..] => { diff --git a/dhall_syntax/src/printer.rs b/dhall_syntax/src/printer.rs index dbed55d..b585a5b 100644 --- a/dhall_syntax/src/printer.rs +++ b/dhall_syntax/src/printer.rs @@ -32,12 +32,6 @@ impl Display for ExprF { NEListLit(es) => { fmt_list("[", ", ", "]", es, f, Display::fmt)?; } - OldOptionalLit(None, t) => { - write!(f, "[] : Optional {}", t)?; - } - OldOptionalLit(Some(x), t) => { - write!(f, "[{}] : Optional {}", x, t)?; - } SomeLit(e) => { write!(f, "Some {}", e)?; } @@ -154,7 +148,6 @@ impl Expr { | Let(_, _, _, _) | EmptyListLit(_) | NEListLit(_) - | OldOptionalLit(_, _) | SomeLit(_) | Merge(_, _, _) | Annot(_, _) @@ -190,7 +183,6 @@ impl Expr { b.phase(PrintPhase::BinOp(op)), ), EmptyListLit(t) => EmptyListLit(t.phase(Import)), - OldOptionalLit(x, t) => OldOptionalLit(x, t.phase(Import)), SomeLit(e) => SomeLit(e.phase(Import)), ExprF::App(f, a) => ExprF::App(f.phase(Import), a.phase(Import)), Field(a, b) => Field(a.phase(Primitive), b), -- cgit v1.2.3