mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-07 04:06:48 +01:00
dsl: extract dsl_error; ParseError -> DslError
This commit is contained in:
parent
f18e01c220
commit
ed772b9872
4 changed files with 34 additions and 21 deletions
|
|
@ -1,10 +1,21 @@
|
|||
use crate::*;
|
||||
|
||||
/// Map EDN tokens to parameters of a given type for a given context
|
||||
/// TODO: Replace both [Context] and [TryFromDsl] with this trait
|
||||
/// which returns a [Result].
|
||||
pub trait Dsl<U>: Sized {
|
||||
fn take <'state, 'source> (_: &'state Self, _: &mut TokenIter<'source>) -> Perhaps<U> {
|
||||
Ok(None)
|
||||
}
|
||||
fn take_or_fail <'state, 'source> (
|
||||
state: &'state Self, iter: &mut TokenIter<'source>
|
||||
) -> Usually<U> {
|
||||
if let Some(value) = Self::take(state, iter)? {
|
||||
Ok(value)
|
||||
} else {
|
||||
Result::Err("not found".into()) // TODO add info and error type
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Map EDN tokens to parameters of a given type for a given context
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue