summaryrefslogtreecommitdiff
path: root/chomp-macro/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'chomp-macro/src/lib.rs')
-rw-r--r--chomp-macro/src/lib.rs21
1 files changed, 11 insertions, 10 deletions
diff --git a/chomp-macro/src/lib.rs b/chomp-macro/src/lib.rs
index 67964ec..a8e4782 100644
--- a/chomp-macro/src/lib.rs
+++ b/chomp-macro/src/lib.rs
@@ -1,6 +1,6 @@
use chomp::{
chomp::{
- ast::substitute::InlineCalls,
+ ast::substitute::Reduce,
typed::{
context::Context,
lower::{Backend, GenerateCode},
@@ -9,20 +9,21 @@ use chomp::{
visit::Visitable,
},
lower::RustBackend,
- nibble::File,
+ nibble::{convert::{self, Convert}, Statement},
};
-use proc_macro::TokenStream;
+use proc_macro::{Span, TokenStream};
use syn::Error;
#[proc_macro]
pub fn nibble(item: TokenStream) -> TokenStream {
syn::parse(item)
- .and_then(|nibble: File| nibble.convert().map_err(Error::from))
- .and_then(|(funs, goal)| {
- funs.into_iter()
- .try_rfold(goal, |goal, function| {
- goal.fold(&mut InlineCalls { function })
- })
+ .and_then(|nibble: Statement| {
+ nibble
+ .convert(&mut convert::Context::default())
+ .map_err(Error::from)
+ })
+ .and_then(|expr| {
+ expr.fold(&mut Reduce)
.map_err(Error::from)
})
.and_then(|expr| {
@@ -35,7 +36,7 @@ pub fn nibble(item: TokenStream) -> TokenStream {
.map(|typed| {
let mut backend = RustBackend::default();
let id = typed.gen(&mut backend);
- backend.emit_code(None, None, id)
+ backend.emit_code(None, Span::call_site().into(), id)
})
.unwrap_or_else(Error::into_compile_error)
.into()