mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-02-21 18:49:04 +01:00
This commit is contained in:
parent
8a5bc7b6ea
commit
f3fcf663a8
1 changed files with 8 additions and 6 deletions
|
|
@ -9,12 +9,14 @@ pub trait View<O, U> {
|
|||
Err(format!("View::view_word: no words defined: {word:?}").into())
|
||||
}
|
||||
fn view <'a> (&'a self, output: &mut O, dsl: &'a impl Language) -> Usually<U> {
|
||||
if let Ok(Some(expr)) = dsl.expr() {
|
||||
self.view_expr(output, &expr)
|
||||
} else if let Ok(Some(word)) = dsl.word() {
|
||||
self.view_word(output, &word)
|
||||
} else {
|
||||
Err(format!("{dsl:?}: invalid").into())
|
||||
let is_expr = dsl.expr();
|
||||
let is_word = dsl.word();
|
||||
match (dsl.expr(), dsl.word()) {
|
||||
(Ok(Some(e)), _ ) => self.view_expr(output, &e),
|
||||
(_, Ok(Some(w))) => self.view_word(output, &w),
|
||||
(Err(e), _ ) => Err(format!("invalid view expr:\n{dsl:?}\n{e}").into()),
|
||||
(_, Err(w) ) => Err(format!("invalid view word:\n{dsl:?}\n{w}").into()),
|
||||
(Ok(None), Ok(None) ) => Err(format!("empty view:\n{dsl:?}").into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue