From aba7e62e49ac9dead0a2868f739091d2d15ff0d1 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 31 Aug 2019 21:59:39 +0200 Subject: Implement parsing of `toMap` keyword --- dhall/build.rs | 9 --------- dhall/src/phase/binary.rs | 11 +++++++++++ dhall/src/phase/normalize.rs | 1 + dhall/src/phase/typecheck.rs | 1 + 4 files changed, 13 insertions(+), 9 deletions(-) (limited to 'dhall') diff --git a/dhall/build.rs b/dhall/build.rs index 4c654c9..e31e39d 100644 --- a/dhall/build.rs +++ b/dhall/build.rs @@ -133,8 +133,6 @@ fn main() -> std::io::Result<()> { || path == "unit/import/urls/emptyPath0" || path == "unit/import/urls/emptyPath1" || path == "unit/import/urls/emptyPathSegment" - // TODO: toMap - || path == "toMap" }, input_type: FileType::Text, output_type: Some(FileType::Binary), @@ -172,8 +170,6 @@ fn main() -> std::io::Result<()> { || path == "unit/import/urls/emptyPath0" || path == "unit/import/urls/emptyPath1" || path == "unit/import/urls/emptyPathSegment" - // TODO: toMap - || path == "toMap" }, input_type: FileType::Text, output_type: Some(FileType::Binary), @@ -203,8 +199,6 @@ fn main() -> std::io::Result<()> { || path == "unit/import/urls/emptyPath0" || path == "unit/import/urls/emptyPath1" || path == "unit/import/urls/emptyPathSegment" - // TODO: toMap - || path == "toMap" }, input_type: FileType::Text, output_type: Some(FileType::Binary), @@ -222,9 +216,6 @@ fn main() -> std::io::Result<()> { // TODO: projection by expression || path == "unit/RecordProjectFields" || path == "unit/recordProjectionByExpression" - // TODO: toMap - || path == "unit/ToMap" - || path == "unit/ToMapAnnotated" }, input_type: FileType::Binary, output_type: Some(FileType::Text), diff --git a/dhall/src/phase/binary.rs b/dhall/src/phase/binary.rs index 7dc9be2..40219d9 100644 --- a/dhall/src/phase/binary.rs +++ b/dhall/src/phase/binary.rs @@ -366,6 +366,15 @@ fn cbor_value_to_dhall(data: &cbor::Value) -> Result { let y = cbor_value_to_dhall(&y)?; Annot(x, y) } + [U64(27), x] => { + let x = cbor_value_to_dhall(&x)?; + ToMap(x, None) + } + [U64(27), x, y] => { + let x = cbor_value_to_dhall(&x)?; + let y = cbor_value_to_dhall(&y)?; + ToMap(x, Some(y)) + } [U64(28), x] => { let x = cbor_value_to_dhall(&x)?; EmptyListLit(x) @@ -550,6 +559,8 @@ where Merge(x, y, Some(z)) => { ser_seq!(ser; tag(6), expr(x), expr(y), expr(z)) } + ToMap(x, None) => ser_seq!(ser; tag(27), expr(x)), + ToMap(x, Some(y)) => ser_seq!(ser; tag(27), expr(x), expr(y)), Projection(x, ls) => ser.collect_seq( once(tag(10)) .chain(once(expr(x))) diff --git a/dhall/src/phase/normalize.rs b/dhall/src/phase/normalize.rs index 82a378c..3f6e99c 100644 --- a/dhall/src/phase/normalize.rs +++ b/dhall/src/phase/normalize.rs @@ -765,6 +765,7 @@ pub(crate) fn normalize_one_layer( } } } + ExprF::ToMap(_, _) => unimplemented!("toMap"), }; match ret { diff --git a/dhall/src/phase/typecheck.rs b/dhall/src/phase/typecheck.rs index 52a4e47..9013c1f 100644 --- a/dhall/src/phase/typecheck.rs +++ b/dhall/src/phase/typecheck.rs @@ -757,6 +757,7 @@ fn type_last_layer( (None, None) => return mkerr(MergeEmptyNeedsAnnotation), } } + ToMap(_, _) => unimplemented!("toMap"), Projection(record, labels) => { let record_type = record.get_type()?; let record_borrow = record_type.as_whnf(); -- cgit v1.2.3