summaryrefslogtreecommitdiff
path: root/dhall/src/syntax/binary
diff options
context:
space:
mode:
authorNadrieril2020-09-15 00:10:48 +0100
committerGitHub2020-09-15 00:10:48 +0100
commit12752fb0ff108fcbc37f209384eb3d2720809fb7 (patch)
treeb7aa0f75932426461234e4b7568a6681247482ff /dhall/src/syntax/binary
parent97a3719a3b4fa88873cd128fb193444c5d4bb387 (diff)
parentd1ac40eea5d1e62762c4a20ba9d2dc5ed0d5e06e (diff)
Merge pull request #176 from Nadrieril/catchup-spec
Diffstat (limited to 'dhall/src/syntax/binary')
-rw-r--r--dhall/src/syntax/binary/decode.rs21
-rw-r--r--dhall/src/syntax/binary/encode.rs4
2 files changed, 25 insertions, 0 deletions
diff --git a/dhall/src/syntax/binary/decode.rs b/dhall/src/syntax/binary/decode.rs
index 195bd0a..d360949 100644
--- a/dhall/src/syntax/binary/decode.rs
+++ b/dhall/src/syntax/binary/decode.rs
@@ -434,6 +434,27 @@ fn cbor_value_to_dhall(data: &cbor::Value) -> Result<DecodedExpr, DecodeError> {
let x = cbor_value_to_dhall(&x)?;
EmptyListLit(x)
}
+ [U64(29), x, labels, y] => {
+ let x = cbor_value_to_dhall(&x)?;
+ let y = cbor_value_to_dhall(&y)?;
+ let labels = match labels {
+ Array(labels) => labels
+ .iter()
+ .map(|s| match s {
+ String(s) => Ok(Label::from(s.as_str())),
+ _ => Err(DecodeError::WrongFormatError(
+ "with".to_owned(),
+ )),
+ })
+ .collect::<Result<_, _>>()?,
+ _ => {
+ return Err(DecodeError::WrongFormatError(
+ "with".to_owned(),
+ ))
+ }
+ };
+ Op(With(x, labels, y))
+ }
_ => {
return Err(DecodeError::WrongFormatError(format!(
"{:?}",
diff --git a/dhall/src/syntax/binary/encode.rs b/dhall/src/syntax/binary/encode.rs
index b6bbabe..33c7fa5 100644
--- a/dhall/src/syntax/binary/encode.rs
+++ b/dhall/src/syntax/binary/encode.rs
@@ -171,6 +171,10 @@ where
Op(Completion(x, y)) => {
ser_seq!(ser; tag(3), tag(13), expr(x), expr(y))
}
+ Op(With(x, ls, y)) => {
+ let ls: Vec<_> = ls.iter().map(label).collect();
+ ser_seq!(ser; tag(29), expr(x), ls, expr(y))
+ }
Import(import) => serialize_import(ser, import),
}
}