summaryrefslogtreecommitdiff
path: root/dhall_generated_parser
diff options
context:
space:
mode:
authorNadrieril2019-09-10 15:43:24 +0200
committerNadrieril2019-09-10 16:38:28 +0200
commit83ca228b1b0d3c40d2a1998dde45ecfef6fa0bb7 (patch)
tree83f41047f7505282c0fb11994df8d3391662fe41 /dhall_generated_parser
parent20e75122354dc44468fa58c40e94a43a128aa764 (diff)
Tentatively derive pest::Parser normally
If it still creates spurious recompilations, I'll revert that
Diffstat (limited to 'dhall_generated_parser')
-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
3 files changed, 7 insertions, 20 deletions
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;