diff options
-rw-r--r-- | Cargo.lock | 11 | ||||
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | dhall_proc_macros/src/lib.rs | 19 | ||||
-rw-r--r-- | pest_consume/Cargo.toml | 2 | ||||
-rw-r--r-- | pest_consume/src/lib.rs | 2 | ||||
-rw-r--r-- | pest_consume_macros/Cargo.toml | 18 | ||||
-rw-r--r-- | pest_consume_macros/src/lib.rs | 28 | ||||
-rw-r--r-- | pest_consume_macros/src/make_parser.rs (renamed from dhall_proc_macros/src/make_parser.rs) | 0 | ||||
-rw-r--r-- | pest_consume_macros/src/parse_children.rs (renamed from dhall_proc_macros/src/parse_children.rs) | 0 |
9 files changed, 59 insertions, 22 deletions
@@ -242,8 +242,17 @@ dependencies = [ name = "pest_consume" version = "0.1.0" dependencies = [ - "dhall_proc_macros 0.1.0", "pest 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "pest_consume_macros 0.1.0", +] + +[[package]] +name = "pest_consume_macros" +version = "0.1.0" +dependencies = [ + "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -9,6 +9,7 @@ members = [ "dhall_proc_macros", "improved_slice_patterns", "pest_consume", + "pest_consume_macros", "serde_dhall" ] diff --git a/dhall_proc_macros/src/lib.rs b/dhall_proc_macros/src/lib.rs index 37e8f9f..5304429 100644 --- a/dhall_proc_macros/src/lib.rs +++ b/dhall_proc_macros/src/lib.rs @@ -1,4 +1,3 @@ -#![feature(drain_filter)] //! 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. //! @@ -7,8 +6,6 @@ extern crate proc_macro; mod derive; -mod make_parser; -mod parse_children; use proc_macro::TokenStream; @@ -16,19 +13,3 @@ use proc_macro::TokenStream; pub fn derive_static_type(input: TokenStream) -> TokenStream { derive::derive_static_type(input) } - -#[proc_macro_attribute] -pub fn make_parser(attrs: TokenStream, input: TokenStream) -> TokenStream { - TokenStream::from(match make_parser::make_parser(attrs, input) { - Ok(tokens) => tokens, - Err(err) => err.to_compile_error(), - }) -} - -#[proc_macro] -pub fn parse_children(input: TokenStream) -> TokenStream { - TokenStream::from(match parse_children::parse_children(input) { - Ok(tokens) => tokens, - Err(err) => err.to_compile_error(), - }) -} diff --git a/pest_consume/Cargo.toml b/pest_consume/Cargo.toml index b3f1db7..7b26d56 100644 --- a/pest_consume/Cargo.toml +++ b/pest_consume/Cargo.toml @@ -10,4 +10,4 @@ repository = "https://github.com/Nadrieril/dhall-rust" [dependencies] pest = "2.1" -dhall_proc_macros = { path = "../dhall_proc_macros" } +pest_consume_macros = { path = "../pest_consume_macros" } diff --git a/pest_consume/src/lib.rs b/pest_consume/src/lib.rs index 1cedc74..6e4b2e3 100644 --- a/pest_consume/src/lib.rs +++ b/pest_consume/src/lib.rs @@ -2,7 +2,7 @@ use pest::error::{Error, ErrorVariant}; use pest::iterators::Pair; use pest::Span; -pub use dhall_proc_macros::{make_parser, parse_children}; +pub use pest_consume_macros::{make_parser, parse_children}; /// Carries a pest Pair alongside custom user data. #[derive(Debug, Clone)] diff --git a/pest_consume_macros/Cargo.toml b/pest_consume_macros/Cargo.toml new file mode 100644 index 0000000..dd65d95 --- /dev/null +++ b/pest_consume_macros/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "pest_consume_macros" +version = "0.1.0" # remember to update html_root_url +authors = ["Nadrieril <nadrieril@users.noreply.github.com>"] +license = "MIT OR Apache-2.0" +edition = "2018" +description = "Macros for pest_consume" +readme = "README.md" +repository = "https://github.com/Nadrieril/dhall-rust" + +[lib] +proc-macro = true +doctest = false + +[dependencies] +quote = "1.0.2" +proc-macro2 = "1.0.2" +syn = { version = "1.0.5", features = ["full", "extra-traits"] } diff --git a/pest_consume_macros/src/lib.rs b/pest_consume_macros/src/lib.rs new file mode 100644 index 0000000..dd437f6 --- /dev/null +++ b/pest_consume_macros/src/lib.rs @@ -0,0 +1,28 @@ +#![feature(drain_filter)] +//! 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. +//! +//! [dhall-rust]: https://github.com/Nadrieril/dhall-rust + +extern crate proc_macro; + +mod make_parser; +mod parse_children; + +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn make_parser(attrs: TokenStream, input: TokenStream) -> TokenStream { + TokenStream::from(match make_parser::make_parser(attrs, input) { + Ok(tokens) => tokens, + Err(err) => err.to_compile_error(), + }) +} + +#[proc_macro] +pub fn parse_children(input: TokenStream) -> TokenStream { + TokenStream::from(match parse_children::parse_children(input) { + Ok(tokens) => tokens, + Err(err) => err.to_compile_error(), + }) +} diff --git a/dhall_proc_macros/src/make_parser.rs b/pest_consume_macros/src/make_parser.rs index c0594a5..c0594a5 100644 --- a/dhall_proc_macros/src/make_parser.rs +++ b/pest_consume_macros/src/make_parser.rs diff --git a/dhall_proc_macros/src/parse_children.rs b/pest_consume_macros/src/parse_children.rs index d6474a7..d6474a7 100644 --- a/dhall_proc_macros/src/parse_children.rs +++ b/pest_consume_macros/src/parse_children.rs |