diff options
author | Nadrieril | 2019-03-24 23:36:15 +0100 |
---|---|---|
committer | Nadrieril | 2019-03-24 23:36:15 +0100 |
commit | 0424d165836fcbf15aa2e05527d0e790941c9518 (patch) | |
tree | 8aaf71ac08cf912f4d4c2c47f51d58dcaa874891 /dhall_generator/src | |
parent | 5663b4499b46a914ad59792220b0a6cfc24b608c (diff) |
Lay groundwork for DhallType deriving
Diffstat (limited to 'dhall_generator/src')
-rw-r--r-- | dhall_generator/src/dhall_expr.rs | 3 | ||||
-rw-r--r-- | dhall_generator/src/dhall_type.rs | 15 | ||||
-rw-r--r-- | dhall_generator/src/lib.rs | 9 |
3 files changed, 26 insertions, 1 deletions
diff --git a/dhall_generator/src/dhall_expr.rs b/dhall_generator/src/dhall_expr.rs index 1eb4580..1ee4d1a 100644 --- a/dhall_generator/src/dhall_expr.rs +++ b/dhall_generator/src/dhall_expr.rs @@ -62,6 +62,9 @@ fn dhall_to_tokenstream( NaturalLit(n) => { quote! { dhall_core::Expr::NaturalLit(#n) } } + BoolLit(b) => { + quote! { dhall_core::Expr::BoolLit(#b) } + } EmptyOptionalLit(x) => { let x = dhall_to_tokenstream_bx(x, ctx); quote! { dhall_core::Expr::EmptyOptionalLit(#x) } diff --git a/dhall_generator/src/dhall_type.rs b/dhall_generator/src/dhall_type.rs new file mode 100644 index 0000000..7cfd945 --- /dev/null +++ b/dhall_generator/src/dhall_type.rs @@ -0,0 +1,15 @@ +extern crate proc_macro; +// use dhall_core::*; +// use proc_macro2::TokenStream; +use quote::quote; + +pub fn derive_dhall_type(_input: proc_macro::TokenStream) -> proc_macro::TokenStream { + (quote!{ + impl DhallType for A { + fn dhall_type() -> dhall_core::DhallExpr { + dhall_core::rc(dhall_core::Expr::BoolLit(false)) + } + } + }).into() +} + diff --git a/dhall_generator/src/lib.rs b/dhall_generator/src/lib.rs index 7d3304b..b52c454 100644 --- a/dhall_generator/src/lib.rs +++ b/dhall_generator/src/lib.rs @@ -1,9 +1,16 @@ extern crate proc_macro; mod dhall_expr; +mod dhall_type; + +use proc_macro::TokenStream; #[proc_macro] -pub fn dhall_expr(input: proc_macro::TokenStream) -> proc_macro::TokenStream { +pub fn dhall_expr(input: TokenStream) -> TokenStream { dhall_expr::dhall_expr(input) } +#[proc_macro_derive(DhallType)] +pub fn derive_dhall_type(input: TokenStream) -> TokenStream { + dhall_type::derive_dhall_type(input) +} |