diff --git a/dsl/src/dsl_provide.rs b/dsl/src/dsl_provide.rs index cbd99ff..639fddf 100644 --- a/dsl/src/dsl_provide.rs +++ b/dsl/src/dsl_provide.rs @@ -1,34 +1,34 @@ use crate::*; pub trait Dsl { - fn take <'source> (&self, token: &mut TokenIter<'source>) -> Perhaps; + fn take <'source> (&self, words: &mut TokenIter<'source>) -> Perhaps; fn take_or_fail <'source> ( - &self, token: &mut TokenIter<'source>, error: impl Into> + &self, words: &mut TokenIter<'source>, error: impl Into> ) -> Usually { - if let Some(value) = Dsl::::take(self, token)? { + if let Some(value) = Dsl::::take(self, words)? { Ok(value) } else { - Result::Err(error.into()) + Result::Err(format!("{}: {:?}", error.into(), words.peek().map(|x|x.value)).into()) } } } impl, State> Dsl for State { - fn take <'source> (&self, token: &mut TokenIter<'source>) -> Perhaps { - Namespace::take_from(self, token) + fn take <'source> (&self, words: &mut TokenIter<'source>) -> Perhaps { + Namespace::take_from(self, words) } } pub trait Namespace: Sized { - fn take_from <'source> (state: &State, token: &mut TokenIter<'source>) + fn take_from <'source> (state: &State, words: &mut TokenIter<'source>) -> Perhaps; fn take_from_or_fail <'source> ( - state: &State, token: &mut TokenIter<'source>, error: impl Into> + state: &State, words: &mut TokenIter<'source>, error: impl Into> ) -> Usually { - if let Some(value) = Namespace::::take_from(state, token)? { + if let Some(value) = Namespace::::take_from(state, words)? { Ok(value) } else { - Result::Err(error.into()) + Result::Err(format!("{}: {:?}", error.into(), words.peek().map(|x|x.value)).into()) } } }