From e294450e1e76491e96019b8a3695463e09d1739b Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 22 Dec 2019 19:02:18 +0000 Subject: Implement parsing for record completion --- dhall/build.rs | 16 ++++++++++++++++ dhall/src/dhall.pest.visibility | 2 ++ dhall/src/semantics/phase/normalize.rs | 1 + dhall/src/semantics/phase/typecheck.rs | 1 + dhall/src/syntax/ast/expr.rs | 2 ++ dhall/src/syntax/ast/visitor.rs | 7 +++++++ dhall/src/syntax/binary/decode.rs | 5 +++++ dhall/src/syntax/binary/encode.rs | 3 +++ dhall/src/syntax/text/parser.rs | 19 +++++++++++++++++++ dhall/src/syntax/text/printer.rs | 20 ++++++++++++-------- 10 files changed, 68 insertions(+), 8 deletions(-) (limited to 'dhall') diff --git a/dhall/build.rs b/dhall/build.rs index e06f9b3..ec06ece 100644 --- a/dhall/build.rs +++ b/dhall/build.rs @@ -267,6 +267,9 @@ fn generate_tests() -> std::io::Result<()> { || path == "unit/RightBiasedMergeEquivalentArguments" || path == "unit/NestedRecordProjection" || path == "unit/NestedRecordProjectionByType" + // TODO: record completion + || path == "simple/completion" + || path == "unit/Completion" }), input_type: FileType::Text, output_type: Some(FileType::Text), @@ -299,6 +302,9 @@ fn generate_tests() -> std::io::Result<()> { || path == "unit/ToMapAnnotated" || path == "unit/ToMapInferTypeFromRecord" || path == "simple/toMapEmptyNormalizeAnnotation" + // TODO: record completion + || path == "simple/completion" + || path == "unit/Completion" }), input_type: FileType::Text, output_type: Some(FileType::Text), @@ -322,6 +328,11 @@ fn generate_tests() -> std::io::Result<()> { || path == "unit/NonRecordToMap" || path == "unit/ToMapEmptyInvalidAnnotation" || path == "unit/ToMapWrongKind" + // TODO: record completion + || path == "unit/CompletionMissingRequiredField" + || path == "unit/CompletionWithWrongDefaultType" + || path == "unit/CompletionWithWrongFieldName" + || path == "unit/CompletionWithWrongOverridenType" }), input_type: FileType::Text, output_type: None, @@ -345,6 +356,11 @@ fn generate_tests() -> std::io::Result<()> { || path == "unit/NonRecordToMap" || path == "unit/ToMapEmptyInvalidAnnotation" || path == "unit/ToMapWrongKind" + // TODO: record completion + || path == "unit/CompletionMissingRequiredField" + || path == "unit/CompletionWithWrongDefaultType" + || path == "unit/CompletionWithWrongFieldName" + || path == "unit/CompletionWithWrongOverridenType" }), input_type: FileType::Text, output_type: None, diff --git a/dhall/src/dhall.pest.visibility b/dhall/src/dhall.pest.visibility index 17c1edc..41aa833 100644 --- a/dhall/src/dhall.pest.visibility +++ b/dhall/src/dhall.pest.visibility @@ -91,6 +91,7 @@ prefer lambda forall arrow +# complete # exponent numeric_double_literal minus_infinity_literal @@ -161,6 +162,7 @@ equivalent_expression application_expression first_application_expression # import_expression +completion_expression selector_expression selector labels diff --git a/dhall/src/semantics/phase/normalize.rs b/dhall/src/semantics/phase/normalize.rs index d81a910..65384c2 100644 --- a/dhall/src/semantics/phase/normalize.rs +++ b/dhall/src/semantics/phase/normalize.rs @@ -741,6 +741,7 @@ pub(crate) fn normalize_one_layer( ExprKind::ProjectionByExpr(_, _) => { unimplemented!("selection by expression") } + ExprKind::Completion(_, _) => unimplemented!("record completion"), ExprKind::Merge(ref handlers, ref variant, _) => { let handlers_borrow = handlers.as_whnf(); diff --git a/dhall/src/semantics/phase/typecheck.rs b/dhall/src/semantics/phase/typecheck.rs index 856f5c3..c9834e1 100644 --- a/dhall/src/semantics/phase/typecheck.rs +++ b/dhall/src/semantics/phase/typecheck.rs @@ -792,6 +792,7 @@ fn type_last_layer( )) } ProjectionByExpr(_, _) => unimplemented!("selection by expression"), + Completion(_, _) => unimplemented!("record completion"), }; Ok(match ret { diff --git a/dhall/src/syntax/ast/expr.rs b/dhall/src/syntax/ast/expr.rs index 48c48d8..fe49448 100644 --- a/dhall/src/syntax/ast/expr.rs +++ b/dhall/src/syntax/ast/expr.rs @@ -163,6 +163,8 @@ pub enum ExprKind { Projection(SubExpr, DupTreeSet