From 2ad5973a32099ad8f79f247adc9d03340e2df4ab Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 3 Aug 2019 21:36:53 +0200 Subject: Update dhall-lang submodule --- dhall_syntax/Cargo.toml | 1 + dhall_syntax/src/core/import.rs | 5 ++--- dhall_syntax/src/parser.rs | 18 +++++++++++++----- dhall_syntax/src/printer.rs | 4 +++- 4 files changed, 19 insertions(+), 9 deletions(-) (limited to 'dhall_syntax') diff --git a/dhall_syntax/Cargo.toml b/dhall_syntax/Cargo.toml index b25a0fe..6a61b09 100644 --- a/dhall_syntax/Cargo.toml +++ b/dhall_syntax/Cargo.toml @@ -14,5 +14,6 @@ percent-encoding = "1.0.1" pest = "2.1" either = "1.5.2" take_mut = "0.2.2" +hex = "0.3.2" dhall_generated_parser = { path = "../dhall_generated_parser" } improved_slice_patterns = { version = "2.0.0", path = "../improved_slice_patterns" } diff --git a/dhall_syntax/src/core/import.rs b/dhall_syntax/src/core/import.rs index fbf2f7b..c328e34 100644 --- a/dhall_syntax/src/core/import.rs +++ b/dhall_syntax/src/core/import.rs @@ -43,9 +43,8 @@ pub enum ImportMode { } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct Hash { - pub protocol: String, - pub hash: String, +pub enum Hash { + SHA256(Vec), } #[derive(Debug, Clone, PartialEq, Eq, Hash)] diff --git a/dhall_syntax/src/parser.rs b/dhall_syntax/src/parser.rs index 316ef2f..d8bd957 100644 --- a/dhall_syntax/src/parser.rs +++ b/dhall_syntax/src/parser.rs @@ -461,6 +461,11 @@ make_parser! { lines.push(vec![]); lines }, + [single_quote_char("\r\n"), single_quote_continue(lines)] => { + let mut lines = lines; + lines.push(vec![]); + lines + }, [single_quote_char(c), single_quote_continue(lines)] => { // TODO: don't allocate for every char let c = InterpolatedTextContents::Text(c.to_owned()); @@ -654,12 +659,15 @@ make_parser! { }, )); - rule!(hash; captured_str!(s) => - Hash { - protocol: s.trim()[..6].to_owned(), - hash: s.trim()[7..].to_owned(), + rule!(hash; captured_str!(s) => { + let s = s.trim(); + let protocol = &s[..6]; + let hash = &s[7..]; + if protocol != "sha256" { + Err(format!("Unknown hashing protocol '{}'", protocol))? } - ); + Hash::SHA256(hex::decode(hash).unwrap()) + }); rule!(import_hashed; children!( [import_type(location)] => diff --git a/dhall_syntax/src/printer.rs b/dhall_syntax/src/printer.rs index f1ce230..dbed55d 100644 --- a/dhall_syntax/src/printer.rs +++ b/dhall_syntax/src/printer.rs @@ -348,7 +348,9 @@ impl Display for Label { impl Display for Hash { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - write!(f, "{}:{}", self.protocol, self.hash) + match self { + Hash::SHA256(hash) => write!(f, "sha256:{}", hex::encode(hash)), + } } } impl Display for ImportHashed { -- cgit v1.3.1 From b85967fbe27505ae932be3b640dff5260fd32662 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 3 Aug 2019 22:15:49 +0200 Subject: Update dhall-lang submodule --- dhall-lang | 2 +- dhall/build.rs | 15 ++++++++++----- dhall_generated_parser/src/dhall.pest.visibility | 1 + dhall_syntax/src/parser.rs | 1 + tests_buffer | 1 + 5 files changed, 14 insertions(+), 6 deletions(-) (limited to 'dhall_syntax') diff --git a/dhall-lang b/dhall-lang index 70c0498..034d48a 160000 --- a/dhall-lang +++ b/dhall-lang @@ -1 +1 @@ -Subproject commit 70c049883d2a6c9662511f166f5a359b7664d0d1 +Subproject commit 034d48aa2d9433c4af574165483b3e7963824835 diff --git a/dhall/build.rs b/dhall/build.rs index 46bb3a4..3f09d47 100644 --- a/dhall/build.rs +++ b/dhall/build.rs @@ -35,11 +35,11 @@ fn dhall_files_in_dir<'a>( } fn make_test_module( - w: &mut impl Write, - mod_name: &str, - dir: &Path, - feature: &str, - mut exclude: impl FnMut(&str) -> bool, + w: &mut impl Write, // Where to output the generated code + mod_name: &str, // Name of the module, used in the output of `cargo test` + dir: &Path, // Directory containing the tests files + feature: &str, // Relevant variant of `dhall::tests::Feature` + mut exclude: impl FnMut(&str) -> bool, // Given a file name, whether to exclude it ) -> std::io::Result<()> { writeln!(w, "mod {} {{", mod_name)?; for (name, path) in dhall_files_in_dir(&dir.join("success/"), true) { @@ -67,6 +67,8 @@ fn make_test_module( } fn main() -> std::io::Result<()> { + // Tries to detect when the submodule gets updated; doesn't really work. + // To force regeneration of the test list, just `touch dhall-lang/.git` println!("cargo:rerun-if-changed=../dhall-lang/.git"); println!( "cargo:rerun-if-changed=../.git/modules/dhall-lang/refs/heads/master" @@ -129,6 +131,9 @@ fn main() -> std::io::Result<()> { path == "success/simple/integerToDouble" // Too slow || path == "success/remoteSystems" + // TODO: selection by expression + || path == "success/unit/RecordProjectionTypeEmpty" + || path == "success/unit/RecordProjectionTypeNonEmpty" }, )?; diff --git a/dhall_generated_parser/src/dhall.pest.visibility b/dhall_generated_parser/src/dhall.pest.visibility index 6e83052..60de54d 100644 --- a/dhall_generated_parser/src/dhall.pest.visibility +++ b/dhall_generated_parser/src/dhall.pest.visibility @@ -155,6 +155,7 @@ first_application_expression selector_expression selector labels +# type_selector primitive_expression # record_type_or_literal empty_record_literal diff --git a/dhall_syntax/src/parser.rs b/dhall_syntax/src/parser.rs index d8bd957..9d9a374 100644 --- a/dhall_syntax/src/parser.rs +++ b/dhall_syntax/src/parser.rs @@ -878,6 +878,7 @@ make_parser! { rule!(selector>>; children!( [label(l)] => Either::Left(l), [labels(ls)] => Either::Right(ls), + [expression(e)] => unimplemented!("selection by expression"), // TODO )); rule!(labels>; children!( diff --git a/tests_buffer b/tests_buffer index 75a233b..1ea9a1c 100644 --- a/tests_buffer +++ b/tests_buffer @@ -5,6 +5,7 @@ text interpolation and escapes remove `double` remove imports/parenthesizeUsing remove multilet +selection by expression unit tests success/ imports/ Missing missing -- cgit v1.3.1