mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 19:56:44 +01:00
output: remove view; group tests
This commit is contained in:
parent
daef8dfa9e
commit
a4a1066f18
4 changed files with 237 additions and 135 deletions
|
|
@ -21,35 +21,29 @@ impl<E: Output, A: Content<E>, B: Content<E>> Content<E> for Bsp<A, B> {
|
|||
}
|
||||
}
|
||||
#[cfg(feature = "dsl")]
|
||||
from_dsl!(@ab: Bsp<A, B>: |state, iter|Ok(if let Some(Token {
|
||||
value: Value::Key("bsp/n"|"bsp/s"|"bsp/e"|"bsp/w"|"bsp/a"|"bsp/b"),
|
||||
..
|
||||
}) = iter.peek() {
|
||||
let base = iter.clone();
|
||||
return Ok(Some(match iter.next() {
|
||||
Some(Token { value: Value::Key("bsp/n"), .. }) =>
|
||||
Self::n(state.take_or_fail(iter, "expected content 1")?,
|
||||
state.take_or_fail(iter, "expected content 2")?),
|
||||
Some(Token { value: Value::Key("bsp/s"), .. }) =>
|
||||
Self::s(state.take_or_fail(iter, "expected content 1")?,
|
||||
state.take_or_fail(iter, "expected content 2")?),
|
||||
Some(Token { value: Value::Key("bsp/e"), .. }) =>
|
||||
Self::e(state.take_or_fail(iter, "expected content 1")?,
|
||||
state.take_or_fail(iter, "expected content 2")?),
|
||||
Some(Token { value: Value::Key("bsp/w"), .. }) =>
|
||||
Self::w(state.take_or_fail(iter, "expected content 1")?,
|
||||
state.take_or_fail(iter, "expected content 2")?),
|
||||
Some(Token { value: Value::Key("bsp/a"), .. }) =>
|
||||
Self::a(state.take_or_fail(iter, "expected content 1")?,
|
||||
state.take_or_fail(iter, "expected content 2")?),
|
||||
Some(Token { value: Value::Key("bsp/b"), .. }) =>
|
||||
Self::b(state.take_or_fail(iter, "expected content 1")?,
|
||||
state.take_or_fail(iter, "expected content 2")?),
|
||||
_ => unreachable!(),
|
||||
}))
|
||||
} else {
|
||||
None
|
||||
}));
|
||||
impl<State: Dsl<A> + Dsl<B> + std::fmt::Debug, A, B> Namespace<State> for Bsp<A, B> {
|
||||
fn take_from <'source> (state: &State, words: &mut TokenIter<'source>) -> Perhaps<Self> {
|
||||
Ok(if let Some(Token {
|
||||
value: Value::Key("bsp/n"|"bsp/s"|"bsp/e"|"bsp/w"|"bsp/a"|"bsp/b"),
|
||||
..
|
||||
}) = words.peek() {
|
||||
let base = words.clone();
|
||||
let a: A = state.take_or_fail(words, "expected content 1")?;
|
||||
let b: B = state.take_or_fail(words, "expected content 2")?;
|
||||
return Ok(Some(match words.next() {
|
||||
Some(Token { value: Value::Key("bsp/n"), .. }) => Self::n(a, b),
|
||||
Some(Token { value: Value::Key("bsp/s"), .. }) => Self::s(a, b),
|
||||
Some(Token { value: Value::Key("bsp/e"), .. }) => Self::e(a, b),
|
||||
Some(Token { value: Value::Key("bsp/w"), .. }) => Self::w(a, b),
|
||||
Some(Token { value: Value::Key("bsp/a"), .. }) => Self::a(a, b),
|
||||
Some(Token { value: Value::Key("bsp/b"), .. }) => Self::b(a, b),
|
||||
_ => unreachable!(),
|
||||
}))
|
||||
} else {
|
||||
None
|
||||
})
|
||||
}
|
||||
}
|
||||
impl<A, B> Bsp<A, B> {
|
||||
#[inline] pub const fn n (a: A, b: B) -> Self { Self(North, a, b) }
|
||||
#[inline] pub const fn s (a: A, b: B) -> Self { Self(South, a, b) }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue