summaryrefslogtreecommitdiff
path: root/dhall/src/syntax/binary
diff options
context:
space:
mode:
Diffstat (limited to 'dhall/src/syntax/binary')
-rw-r--r--dhall/src/syntax/binary/decode.rs19
-rw-r--r--dhall/src/syntax/binary/encode.rs16
2 files changed, 19 insertions, 16 deletions
diff --git a/dhall/src/syntax/binary/decode.rs b/dhall/src/syntax/binary/decode.rs
index 46c9921..254ab07 100644
--- a/dhall/src/syntax/binary/decode.rs
+++ b/dhall/src/syntax/binary/decode.rs
@@ -2,12 +2,13 @@ use itertools::Itertools;
use serde_cbor::value::value as cbor;
use std::iter::FromIterator;
-use crate::semantics::error::DecodeError;
+use crate::error::DecodeError;
use crate::semantics::phase::DecodedExpr;
use crate::syntax;
use crate::syntax::{
- Expr, ExprF, FilePath, FilePrefix, Hash, ImportLocation, ImportMode,
- Integer, InterpolatedText, Label, Natural, RawExpr, Scheme, Span, URL, V,
+ Expr, ExprKind, FilePath, FilePrefix, Hash, ImportLocation, ImportMode,
+ Integer, InterpolatedText, Label, Natural, Scheme, Span, UnspannedExpr,
+ URL, V,
};
pub(crate) fn decode(data: &[u8]) -> Result<DecodedExpr, DecodeError> {
@@ -18,17 +19,17 @@ pub(crate) fn decode(data: &[u8]) -> Result<DecodedExpr, DecodeError> {
}
// Should probably rename this
-fn rc<E>(x: RawExpr<E>) -> Expr<E> {
+fn rc<E>(x: UnspannedExpr<E>) -> Expr<E> {
Expr::new(x, Span::Decoded)
}
fn cbor_value_to_dhall(data: &cbor::Value) -> Result<DecodedExpr, DecodeError> {
use cbor::Value::*;
use syntax::{BinOp, Builtin, Const};
- use ExprF::*;
+ use ExprKind::*;
Ok(rc(match data {
String(s) => match Builtin::parse(s) {
- Some(b) => ExprF::Builtin(b),
+ Some(b) => ExprKind::Builtin(b),
None => match s.as_str() {
"True" => BoolLit(true),
"False" => BoolLit(false),
@@ -123,7 +124,7 @@ fn cbor_value_to_dhall(data: &cbor::Value) -> Result<DecodedExpr, DecodeError> {
}
[U64(4), t] => {
let t = cbor_value_to_dhall(&t)?;
- EmptyListLit(rc(App(rc(ExprF::Builtin(Builtin::List)), t)))
+ EmptyListLit(rc(App(rc(ExprKind::Builtin(Builtin::List)), t)))
}
[U64(4), Null, rest @ ..] => {
let rest = rest
@@ -139,14 +140,14 @@ fn cbor_value_to_dhall(data: &cbor::Value) -> Result<DecodedExpr, DecodeError> {
// Old-style optional literals
[U64(5), t] => {
let t = cbor_value_to_dhall(&t)?;
- App(rc(ExprF::Builtin(Builtin::OptionalNone)), t)
+ App(rc(ExprKind::Builtin(Builtin::OptionalNone)), t)
}
[U64(5), t, x] => {
let x = cbor_value_to_dhall(&x)?;
let t = cbor_value_to_dhall(&t)?;
Annot(
rc(SomeLit(x)),
- rc(App(rc(ExprF::Builtin(Builtin::Optional)), t)),
+ rc(App(rc(ExprKind::Builtin(Builtin::Optional)), t)),
)
}
[U64(6), x, y] => {
diff --git a/dhall/src/syntax/binary/encode.rs b/dhall/src/syntax/binary/encode.rs
index 8e13efd..25a545c 100644
--- a/dhall/src/syntax/binary/encode.rs
+++ b/dhall/src/syntax/binary/encode.rs
@@ -1,12 +1,12 @@
use serde_cbor::value::value as cbor;
use std::vec;
-use crate::semantics::error::EncodeError;
+use crate::error::EncodeError;
use crate::syntax;
use crate::syntax::map::DupTreeMap;
use crate::syntax::{
- Expr, ExprF, FilePrefix, Hash, Import, ImportLocation, ImportMode, Label,
- Scheme, V,
+ Expr, ExprKind, FilePrefix, Hash, Import, ImportLocation, ImportMode,
+ Label, Scheme, V,
};
/// Warning: will fail if `expr` contains an `Embed` node.
@@ -46,7 +46,7 @@ where
use cbor::Value::{String, I64, U64};
use std::iter::once;
use syntax::Builtin;
- use syntax::ExprF::*;
+ use syntax::ExprKind::*;
use self::Serialize::{RecordMap, UnionMap};
fn expr<E>(x: &Expr<E>) -> self::Serialize<'_, E> {
@@ -110,7 +110,9 @@ where
SomeLit(x) => ser_seq!(ser; tag(5), null(), expr(x)),
EmptyListLit(x) => match x.as_ref() {
App(f, a) => match f.as_ref() {
- ExprF::Builtin(Builtin::List) => ser_seq!(ser; tag(4), expr(a)),
+ ExprKind::Builtin(Builtin::List) => {
+ ser_seq!(ser; tag(4), expr(a))
+ }
_ => ser_seq!(ser; tag(28), expr(x)),
},
_ => ser_seq!(ser; tag(28), expr(x)),
@@ -284,7 +286,7 @@ fn collect_nested_applications<'a, E>(
) -> (&'a Expr<E>, Vec<&'a Expr<E>>) {
fn go<'a, E>(e: &'a Expr<E>, vec: &mut Vec<&'a Expr<E>>) -> &'a Expr<E> {
match e.as_ref() {
- ExprF::App(f, a) => {
+ ExprKind::App(f, a) => {
vec.push(a);
go(f, vec)
}
@@ -306,7 +308,7 @@ fn collect_nested_lets<'a, E>(
vec: &mut Vec<LetBinding<'a, E>>,
) -> &'a Expr<E> {
match e.as_ref() {
- ExprF::Let(l, t, v, e) => {
+ ExprKind::Let(l, t, v, e) => {
vec.push((l, t, v));
go(e, vec)
}