diff options
Diffstat (limited to '')
-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 |
6 files changed, 48 insertions, 2 deletions
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 |