remove Atom. almost there

This commit is contained in:
🪞👃🪞 2025-01-18 15:37:53 +01:00
parent dc7b713108
commit cf1fd5b45a
20 changed files with 539 additions and 739 deletions

View file

@ -31,35 +31,35 @@ impl<E: Output, A: Content<E>, B: Content<E>> Content<E> for Bsp<A, B> {
}
}
}
try_from_atoms!(<'a, E>: Bsp<RenderBox<'a, E>, RenderBox<'a, E>>: |state, atoms| {
let head = atoms.next()?;
if head.kind() != TokenKind::Key { return None }
match head.text() {
"bsp/n" => return Some(Self::n(
state.get_content(&atoms.next()?).expect("no south"),
state.get_content(&atoms.next()?).expect("no north")
)),
"bsp/s" => return Some(Self::s(
state.get_content(&atoms.next()?).expect("no north"),
state.get_content(&atoms.next()?).expect("no south")
)),
"bsp/e" => return Some(Self::e(
state.get_content(&atoms.next()?).expect("no west"),
state.get_content(&atoms.next()?).expect("no east")
)),
"bsp/w" => return Some(Self::w(
state.get_content(&atoms.next()?).expect("no east"),
state.get_content(&atoms.next()?).expect("no west")
)),
"bsp/a" => return Some(Self::a(
state.get_content(&atoms.next()?).expect("no above"),
state.get_content(&atoms.next()?).expect("no below")
)),
"bsp/b" => return Some(Self::b(
state.get_content(&atoms.next()?).expect("no above"),
state.get_content(&atoms.next()?).expect("no below")
)),
_ => {}
try_from_expr!(<'a, E>: Bsp<RenderBox<'a, E>, RenderBox<'a, E>>: |state, iter| {
if let Some((Token { value: Value::Key(key), .. }, _)) = iter.next() {
match key {
"bsp/n" => return Some(Self::n(
state.get_content(&iter.next()?.0.value).expect("no south"),
state.get_content(&iter.next()?.0.value).expect("no north")
)),
"bsp/s" => return Some(Self::s(
state.get_content(&iter.next()?.0.value).expect("no north"),
state.get_content(&iter.next()?.0.value).expect("no south")
)),
"bsp/e" => return Some(Self::e(
state.get_content(&iter.next()?.0.value).expect("no west"),
state.get_content(&iter.next()?.0.value).expect("no east")
)),
"bsp/w" => return Some(Self::w(
state.get_content(&iter.next()?.0.value).expect("no east"),
state.get_content(&iter.next()?.0.value).expect("no west")
)),
"bsp/a" => return Some(Self::a(
state.get_content(&iter.next()?.0.value).expect("no above"),
state.get_content(&iter.next()?.0.value).expect("no below")
)),
"bsp/b" => return Some(Self::b(
state.get_content(&iter.next()?.0.value).expect("no above"),
state.get_content(&iter.next()?.0.value).expect("no below")
)),
_ => {}
}
}
});
impl<A, B> Bsp<A, B> {