From c9f8500cd7463652e7ccc1be59afa29c484037a3 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 21 Dec 2019 21:32:19 +0000 Subject: Remove leftover file --- test.dhall | 68 -------------------------------------------------------------- 1 file changed, 68 deletions(-) delete mode 100644 test.dhall diff --git a/test.dhall b/test.dhall deleted file mode 100644 index 5bc4c88..0000000 --- a/test.dhall +++ /dev/null @@ -1,68 +0,0 @@ -let PList = - http://prelude.dhall-lang.org/List/package.dhall sha256:ca82b0e91b63a044b425b47a0ac02c3c0e726acf1c8b567cdc24ebac0073209a - -let tail - : forall(a: Type) - -> List a - -> List a - = \(a: Type) - -> \(l: List a) - -> List/Build - a - ( λ(list : Type) - → λ(cons : a → list → list) - → λ(nil : list) - → List/fold a l list ( - \(x: a) -> - \(p: list) -> - nil - ) nil - ) - List/fold - - a - l - (List a) - ( \(x: a) - -> \(q: List a) - -> q - ) - ([] : List a) - -in tail Text [ "ABC", "DEF", "GHI" ] --- let nth --- : forall(a : Type) --- -> Natural --- -> List a --- -> Optional a --- = \(a: Type) --- -> \(n: Natural) --- -> \(l: List a) --- -> Natural/fold n --- --- in nth Text 2 [ "ABC", "DEF", "GHI" ] --- let zip --- : ∀(a : Type) --- → ∀(b : Type) --- → { _1 : List a, _2 : List b } --- → List { _1 : a, _2 : b } --- = λ(a : Type) --- → λ(b : Type) --- → λ(xs : { _1 : List a, _2 : List b }) --- -- → List/build --- -- { _1 : a, _2 : b } --- -- ( λ(list : Type) --- -- → λ(cons : { _1 : a, _2 : b } → list → list) --- -- → λ(nil : list) --- -- → List/fold { index : Natural, value : a } (List/indexed a xs._1) list ( --- -- \(x: { index : Natural, value : a }) -> --- -- \(p: list) -> --- -- List/fold b xs._2 list (\(y: b) -> \(q: list) -> cons { _1 = x.value, _2 = y } q) nil : list --- -- ) nil --- -- ) --- → PList.map { index : Natural, value : a } { index : Natural, value : a } (List/indexed a xs._1) ( --- \(x: { index : Natural, value : a }) -> --- List/fold b xs._2 list (\(y: b) -> \(q: list) -> cons { _1 = x.value, _2 = y } q) nil : list --- ) nil --- --- in zip Text Bool { _1 = [ "ABC", "DEF", "GHI" ], _2 = [ True, False, True ] } -- cgit v1.2.3 From 8c14a3321f516d9e789671ce64584dafb656473f Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 21 Dec 2019 22:16:59 +0000 Subject: Prepare for publishing on crates.io --- dhall/Cargo.toml | 8 +++++--- dhall/README.md | 10 ++++++++++ dhall/src/lib.rs | 1 + dhall_proc_macros/Cargo.toml | 5 ++++- dhall_proc_macros/README.md | 7 +++++++ dhall_proc_macros/src/lib.rs | 1 + serde_dhall/Cargo.toml | 6 +++++- serde_dhall/src/lib.rs | 1 + 8 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 dhall/README.md create mode 100644 dhall_proc_macros/README.md diff --git a/dhall/Cargo.toml b/dhall/Cargo.toml index a93153d..60232be 100644 --- a/dhall/Cargo.toml +++ b/dhall/Cargo.toml @@ -1,8 +1,11 @@ [package] name = "dhall" -version = "0.1.0" +version = "0.1.0" # remember to update html_root_url authors = ["NanoTech ", "Nadrieril "] license = "BSD-2-Clause" +description = "Implementation of the Dhall configuration language" +readme = "README.md" +repository = "https://github.com/Nadrieril/dhall-rust" edition = "2018" build = "build.rs" @@ -12,9 +15,8 @@ hex = "0.3.2" lazy_static = "1.4.0" percent-encoding = "2.1.0" pest = "2.1" -# pest_consume = { path = "../../pest_consume/pest_consume" } pest_consume = "1.0" -serde = { version = "1.0" } +serde = "1.0" serde_cbor = "0.9.0" smallvec = "1.0.0" take_mut = "0.2.2" diff --git a/dhall/README.md b/dhall/README.md new file mode 100644 index 0000000..e40458a --- /dev/null +++ b/dhall/README.md @@ -0,0 +1,10 @@ +# `dhall` + +Implementation of the Dhall configuration language. +This is an internal crate used for [`serde_dhall`], you probably want to use +that instead. + +The API is very unstable and does not respect semver; +use at your own risk. + +[`serde_dhall`](https://docs.rs/serde_dhall) diff --git a/dhall/src/lib.rs b/dhall/src/lib.rs index 12660b4..54111dd 100644 --- a/dhall/src/lib.rs +++ b/dhall/src/lib.rs @@ -1,3 +1,4 @@ +#![doc(html_root_url = "https://docs.rs/dhall/0.1.0")] #![feature(trace_macros)] #![feature(slice_patterns)] #![feature(never_type)] diff --git a/dhall_proc_macros/Cargo.toml b/dhall_proc_macros/Cargo.toml index b641a39..f9d6e1a 100644 --- a/dhall_proc_macros/Cargo.toml +++ b/dhall_proc_macros/Cargo.toml @@ -1,8 +1,11 @@ [package] name = "dhall_proc_macros" -version = "0.1.0" +version = "0.1.0" # remember to update html_root_url authors = ["Nadrieril "] license = "BSD-2-Clause" +description = "Macros for dhall" +readme = "README.md" +repository = "https://github.com/Nadrieril/dhall-rust" edition = "2018" [lib] diff --git a/dhall_proc_macros/README.md b/dhall_proc_macros/README.md new file mode 100644 index 0000000..2900f0e --- /dev/null +++ b/dhall_proc_macros/README.md @@ -0,0 +1,7 @@ +# `dhall_proc_macros` + +This is an internal crate used for [`serde_dhall`], you probably want to use +that instead. + +[`serde_dhall`](https://docs.rs/serde_dhall) + diff --git a/dhall_proc_macros/src/lib.rs b/dhall_proc_macros/src/lib.rs index 5304429..ce2dcdb 100644 --- a/dhall_proc_macros/src/lib.rs +++ b/dhall_proc_macros/src/lib.rs @@ -1,3 +1,4 @@ +#![doc(html_root_url = "https://docs.rs/dhall_proc_macros/0.1.0")] //! This crate contains the code-generation primitives for the [dhall-rust][dhall-rust] crate. //! This is highly unstable and breaks regularly; use at your own risk. //! diff --git a/serde_dhall/Cargo.toml b/serde_dhall/Cargo.toml index 9d46822..cc5db01 100644 --- a/serde_dhall/Cargo.toml +++ b/serde_dhall/Cargo.toml @@ -1,8 +1,12 @@ [package] name = "serde_dhall" -version = "0.1.0" +version = "0.1.0" # remember to update html_root_url and README authors = ["Nadrieril "] license = "BSD-2-Clause" +description = "Dhall support for serde" +readme = "../README.md" +repository = "https://github.com/Nadrieril/dhall-rust" +keywords = ["serde", "serialization", "dhall"] edition = "2018" [dependencies] diff --git a/serde_dhall/src/lib.rs b/serde_dhall/src/lib.rs index d8a94d1..62c624a 100644 --- a/serde_dhall/src/lib.rs +++ b/serde_dhall/src/lib.rs @@ -1,3 +1,4 @@ +#![doc(html_root_url = "https://docs.rs/serde_dhall/0.1.0")] //! [Dhall][dhall] is a programmable configuration language that provides a non-repetitive //! alternative to JSON and YAML. //! -- cgit v1.2.3 From 6fd4156325e17a313135cb966bb137db9f684768 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 21 Dec 2019 22:25:49 +0000 Subject: Bump abnf_to_pest version --- Cargo.lock | 4 ++-- abnf_to_pest/Cargo.toml | 3 +-- dhall/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index de01002..ffdf17b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,7 +10,7 @@ dependencies = [ [[package]] name = "abnf_to_pest" -version = "0.1.1" +version = "0.1.2" dependencies = [ "abnf 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -73,7 +73,7 @@ dependencies = [ name = "dhall" version = "0.1.0" dependencies = [ - "abnf_to_pest 0.1.1", + "abnf_to_pest 0.1.2", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/abnf_to_pest/Cargo.toml b/abnf_to_pest/Cargo.toml index 9573c67..93ec829 100644 --- a/abnf_to_pest/Cargo.toml +++ b/abnf_to_pest/Cargo.toml @@ -1,13 +1,12 @@ [package] name = "abnf_to_pest" -version = "0.1.1" # remember to update html_root_url +version = "0.1.2" # remember to update html_root_url authors = ["Nadrieril "] license = "MIT OR Apache-2.0" edition = "2018" description = "A tiny crate that helps convert ABNF grammars to pest" readme = "README.md" repository = "https://github.com/Nadrieril/dhall-rust" -documentation = "https://docs.rs/abnf_to_pest" [lib] doctest = false diff --git a/dhall/Cargo.toml b/dhall/Cargo.toml index 60232be..44c8932 100644 --- a/dhall/Cargo.toml +++ b/dhall/Cargo.toml @@ -26,6 +26,6 @@ pretty_assertions = "0.6.1" [build-dependencies] walkdir = "2" -abnf_to_pest = { version = "0.1.1", path = "../abnf_to_pest" } +abnf_to_pest = { version = "0.1.2", path = "../abnf_to_pest" } -- cgit v1.2.3 From bd2ab17dd0d61d70105a9946d3998bcdb17d04a4 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 21 Dec 2019 22:30:52 +0000 Subject: Typo --- dhall/README.md | 2 +- dhall_proc_macros/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dhall/README.md b/dhall/README.md index e40458a..82b3e6a 100644 --- a/dhall/README.md +++ b/dhall/README.md @@ -7,4 +7,4 @@ that instead. The API is very unstable and does not respect semver; use at your own risk. -[`serde_dhall`](https://docs.rs/serde_dhall) +[`serde_dhall`]: https://docs.rs/serde_dhall diff --git a/dhall_proc_macros/README.md b/dhall_proc_macros/README.md index 2900f0e..9f512c6 100644 --- a/dhall_proc_macros/README.md +++ b/dhall_proc_macros/README.md @@ -3,5 +3,5 @@ This is an internal crate used for [`serde_dhall`], you probably want to use that instead. -[`serde_dhall`](https://docs.rs/serde_dhall) +[`serde_dhall`]: https://docs.rs/serde_dhall -- cgit v1.2.3 From 7680d4f036bbcfd97f687f4d0cfc9be9a195d423 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 21 Dec 2019 22:32:06 +0000 Subject: No need for syn features --- dhall_proc_macros/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dhall_proc_macros/Cargo.toml b/dhall_proc_macros/Cargo.toml index f9d6e1a..ef8ae6c 100644 --- a/dhall_proc_macros/Cargo.toml +++ b/dhall_proc_macros/Cargo.toml @@ -16,4 +16,4 @@ doctest = false itertools = "0.8.0" quote = "1.0.2" proc-macro2 = "1.0.2" -syn = { version = "1.0.5", features = ["full", "extra-traits"] } +syn = "1.0.5" -- cgit v1.2.3 From a588b946ecc9881090ae52e1a1cf81f4607f3426 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 21 Dec 2019 22:33:45 +0000 Subject: Pin version of local crate dependencies --- serde_dhall/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/serde_dhall/Cargo.toml b/serde_dhall/Cargo.toml index cc5db01..8c75f68 100644 --- a/serde_dhall/Cargo.toml +++ b/serde_dhall/Cargo.toml @@ -11,5 +11,5 @@ edition = "2018" [dependencies] serde = { version = "1.0", features = ["derive"] } -dhall = { path = "../dhall" } -dhall_proc_macros = { path = "../dhall_proc_macros" } +dhall = { version = "0.1.0", path = "../dhall" } +dhall_proc_macros = { version = "0.1.0", path = "../dhall_proc_macros" } -- cgit v1.2.3 From be9510bc21724077fd27dcdb3825557475a6bb44 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 21 Dec 2019 23:00:52 +0000 Subject: Generate parser manually to make the crate publishable --- Cargo.lock | 2 ++ dhall/.gitignore | 1 - dhall/Cargo.toml | 2 ++ dhall/build.rs | 28 ++++++++++++++++++++++++++-- dhall/src/syntax/text/parser.rs | 12 +++++++++--- 5 files changed, 39 insertions(+), 6 deletions(-) delete mode 100644 dhall/.gitignore diff --git a/Cargo.lock b/Cargo.lock index ffdf17b..29aba92 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,7 +80,9 @@ dependencies = [ "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "pest 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "pest_consume 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "pest_generator 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_cbor 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/dhall/.gitignore b/dhall/.gitignore deleted file mode 100644 index 8a0bac6..0000000 --- a/dhall/.gitignore +++ /dev/null @@ -1 +0,0 @@ -src/dhall.pest diff --git a/dhall/Cargo.toml b/dhall/Cargo.toml index 44c8932..a9c237c 100644 --- a/dhall/Cargo.toml +++ b/dhall/Cargo.toml @@ -27,5 +27,7 @@ pretty_assertions = "0.6.1" [build-dependencies] walkdir = "2" abnf_to_pest = { version = "0.1.2", path = "../abnf_to_pest" } +pest_generator = "2.1" +quote = "1.0" diff --git a/dhall/build.rs b/dhall/build.rs index 50f423e..3021f03 100644 --- a/dhall/build.rs +++ b/dhall/build.rs @@ -408,9 +408,10 @@ fn generate_tests() -> std::io::Result<()> { } fn convert_abnf_to_pest() -> std::io::Result<()> { + let out_dir = env::var("OUT_DIR").unwrap(); let abnf_path = "src/dhall.abnf"; let visibility_path = "src/dhall.pest.visibility"; - let pest_path = "src/dhall.pest"; + let grammar_path = Path::new(&out_dir).join("dhall.pest"); println!("cargo:rerun-if-changed={}", abnf_path); println!("cargo:rerun-if-changed={}", visibility_path); @@ -427,7 +428,7 @@ fn convert_abnf_to_pest() -> std::io::Result<()> { } } - let mut file = File::create(pest_path)?; + let mut file = File::create(grammar_path)?; writeln!(&mut file, "// AUTO-GENERATED FILE. See build.rs.")?; // TODO: this is a cheat; properly support RFC3986 URLs instead @@ -493,8 +494,31 @@ fn convert_abnf_to_pest() -> std::io::Result<()> { Ok(()) } +// Generate pest parser manually becaue otherwise we'd need to modify something outside of +// OUT_DIR and that's forbidden by docs.rs. +fn generate_pest_parser() -> std::io::Result<()> { + let out_dir = env::var("OUT_DIR").unwrap(); + let grammar_path = Path::new(&out_dir).join("dhall.pest"); + let grammar_path = grammar_path.to_str(); + let output_path = Path::new(&out_dir).join("dhall_parser.rs"); + + let pest = quote::quote!( + #[grammar = #grammar_path] + struct DhallParser; + ); + let derived = pest_generator::derive_parser(pest, false); + let file_contents = quote::quote!( + struct DhallParser; + #derived + ); + + let mut file = File::create(output_path)?; + writeln!(file, "{}", file_contents) +} + fn main() -> std::io::Result<()> { convert_abnf_to_pest()?; + generate_pest_parser()?; generate_tests()?; Ok(()) } diff --git a/dhall/src/syntax/text/parser.rs b/dhall/src/syntax/text/parser.rs index 90cb4b1..832472b 100644 --- a/dhall/src/syntax/text/parser.rs +++ b/dhall/src/syntax/text/parser.rs @@ -156,9 +156,15 @@ lazy_static::lazy_static! { }; } -#[derive(Parser)] -#[grammar = "dhall.pest"] -struct DhallParser; +// Generate pest parser manually becaue otherwise we'd need to modify something outside of OUT_DIR +// and that's forbidden by docs.rs. +// This is equivalent to: +// ``` +// #[derive(Parser) +// #[grammar = "..."] +// struct DhallParser; +// ``` +include!(concat!(env!("OUT_DIR"), "/dhall_parser.rs")); #[pest_consume::parser(parser = DhallParser, rule = Rule)] impl DhallParser { -- cgit v1.2.3 From 6e6094731a3b6a8ff2adc23f8ecae43b25d02731 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 21 Dec 2019 23:01:41 +0000 Subject: Bump dhall version --- dhall/Cargo.toml | 2 +- dhall/src/lib.rs | 2 +- serde_dhall/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dhall/Cargo.toml b/dhall/Cargo.toml index a9c237c..34cf444 100644 --- a/dhall/Cargo.toml +++ b/dhall/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dhall" -version = "0.1.0" # remember to update html_root_url +version = "0.1.1" # remember to update html_root_url authors = ["NanoTech ", "Nadrieril "] license = "BSD-2-Clause" description = "Implementation of the Dhall configuration language" diff --git a/dhall/src/lib.rs b/dhall/src/lib.rs index 54111dd..dfa06e7 100644 --- a/dhall/src/lib.rs +++ b/dhall/src/lib.rs @@ -1,4 +1,4 @@ -#![doc(html_root_url = "https://docs.rs/dhall/0.1.0")] +#![doc(html_root_url = "https://docs.rs/dhall/0.1.1")] #![feature(trace_macros)] #![feature(slice_patterns)] #![feature(never_type)] diff --git a/serde_dhall/Cargo.toml b/serde_dhall/Cargo.toml index 8c75f68..0dd0cd5 100644 --- a/serde_dhall/Cargo.toml +++ b/serde_dhall/Cargo.toml @@ -11,5 +11,5 @@ edition = "2018" [dependencies] serde = { version = "1.0", features = ["derive"] } -dhall = { version = "0.1.0", path = "../dhall" } +dhall = { version = "0.1.1", path = "../dhall" } dhall_proc_macros = { version = "0.1.0", path = "../dhall_proc_macros" } -- cgit v1.2.3 From 139daf4da23c87366d920cea2775afe11cce7be7 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 21 Dec 2019 23:09:54 +0000 Subject: Fix --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 29aba92..b27c167 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "dhall" -version = "0.1.0" +version = "0.1.1" dependencies = [ "abnf_to_pest 0.1.2", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -349,7 +349,7 @@ dependencies = [ name = "serde_dhall" version = "0.1.0" dependencies = [ - "dhall 0.1.0", + "dhall 0.1.1", "dhall_proc_macros 0.1.0", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] -- cgit v1.2.3