summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNadrieril2019-09-10 15:43:24 +0200
committerNadrieril2019-09-10 16:38:28 +0200
commit83ca228b1b0d3c40d2a1998dde45ecfef6fa0bb7 (patch)
tree83f41047f7505282c0fb11994df8d3391662fe41
parent20e75122354dc44468fa58c40e94a43a128aa764 (diff)
Tentatively derive pest::Parser normally
If it still creates spurious recompilations, I'll revert that
-rw-r--r--Cargo.lock14
-rw-r--r--dhall_generated_parser/Cargo.toml3
-rw-r--r--dhall_generated_parser/build.rs17
-rw-r--r--dhall_generated_parser/src/lib.rs7
-rw-r--r--dhall_syntax/Cargo.toml1
5 files changed, 20 insertions, 22 deletions
diff --git a/Cargo.lock b/Cargo.lock
index bf9f18a..017e1b2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -91,8 +91,7 @@ version = "0.1.0"
dependencies = [
"abnf_to_pest 0.1.1",
"pest 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "pest_generator 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -118,6 +117,7 @@ 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 0.1.0",
+ "pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -258,6 +258,15 @@ dependencies = [
]
[[package]]
+name = "pest_derive"
+version = "2.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "pest 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "pest_generator 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "pest_generator"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -512,6 +521,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum output_vt100 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9"
"checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
"checksum pest 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e4fb201c5c22a55d8b24fef95f78be52738e5e1361129be1b5e862ecdb6894a"
+"checksum pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0"
"checksum pest_generator 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7b9fcf299b5712d06ee128a556c94709aaa04512c4dffb8ead07c5c998447fc0"
"checksum pest_meta 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "df43fd99896fd72c485fe47542c7b500e4ac1e8700bf995544d1317a60ded547"
"checksum pretty 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f60c0d9f6fc88ecdd245d90c1920ff76a430ab34303fc778d33b1d0a4c3bf6d3"
diff --git a/dhall_generated_parser/Cargo.toml b/dhall_generated_parser/Cargo.toml
index 0730f60..b1f0d02 100644
--- a/dhall_generated_parser/Cargo.toml
+++ b/dhall_generated_parser/Cargo.toml
@@ -12,8 +12,7 @@ doctest = false
[build-dependencies]
abnf_to_pest = { version = "0.1.1", path = "../abnf_to_pest" }
-pest_generator = "2.1"
-quote = "1.0.2"
[dependencies]
pest = "2.1"
+pest_derive = "2.1"
diff --git a/dhall_generated_parser/build.rs b/dhall_generated_parser/build.rs
index c562fad..68895dd 100644
--- a/dhall_generated_parser/build.rs
+++ b/dhall_generated_parser/build.rs
@@ -1,7 +1,5 @@
-use std::env;
use std::fs::File;
use std::io::{BufRead, BufReader, Read, Write};
-use std::path::Path;
use abnf_to_pest::render_rules_to_pest;
@@ -90,20 +88,5 @@ fn main() -> std::io::Result<()> {
writeln!(&mut file)?;
writeln!(&mut file, "{}", render_rules_to_pest(rules).pretty(80))?;
- // Generate pest parser manually to avoid spurious recompilations
- let derived = {
- let pest_path = "dhall.pest";
- let pest = quote::quote! {
- #[grammar = #pest_path]
- pub struct DhallParser;
- };
- pest_generator::derive_parser(pest, false)
- };
-
- let out_dir = env::var("OUT_DIR").unwrap();
- let grammar_path = Path::new(&out_dir).join("grammar.rs");
- let mut file = File::create(grammar_path)?;
- writeln!(file, "pub struct DhallParser;\n{}", derived,)?;
-
Ok(())
}
diff --git a/dhall_generated_parser/src/lib.rs b/dhall_generated_parser/src/lib.rs
index 280b75e..fbb9ccd 100644
--- a/dhall_generated_parser/src/lib.rs
+++ b/dhall_generated_parser/src/lib.rs
@@ -14,4 +14,9 @@
// additional overrides are done in ../build.rs.
// The lines that are commented out in ./dhall.pest.visibility are marked as
// silent (see pest docs for what that means) in the generated pest file.
-include!(concat!(env!("OUT_DIR"), "/grammar.rs"));
+
+use pest_derive::Parser;
+
+#[derive(Parser)]
+#[grammar = "dhall.pest"]
+pub struct DhallParser;
diff --git a/dhall_syntax/Cargo.toml b/dhall_syntax/Cargo.toml
index 450175c..8d9cca6 100644
--- a/dhall_syntax/Cargo.toml
+++ b/dhall_syntax/Cargo.toml
@@ -12,6 +12,7 @@ doctest = false
itertools = "0.8.0"
percent-encoding = "2.1.0"
pest = "2.1"
+pest_derive = "2.1"
either = "1.5.2"
take_mut = "0.2.2"
hex = "0.3.2"