output: fix expressions

This commit is contained in:
🪞👃🪞 2025-06-08 04:45:14 +03:00
parent cb47c4d0ff
commit 08593571fa

View file

@ -3,7 +3,7 @@ use Value::*;
impl<S, A> Dsl<S> for When<A> where S: Eval<Ast, bool> + Eval<Ast, A> {
fn try_provide (state: &S, source: Ast) -> Perhaps<Self> {
if let Exp(_, exp) = source.0 && let Some(Ast(Key(id))) = exp.peek() && *id == *"when" {
if let Exp(_, mut exp) = source.0 && let Some(Ast(Key(id))) = exp.peek() && *id == *"when" {
let _ = exp.next();
return Ok(Some(Self(
state.eval(exp.next().unwrap(), ||"when: expected condition")?,
@ -16,7 +16,7 @@ impl<S, A> Dsl<S> for When<A> where S: Eval<Ast, bool> + Eval<Ast, A> {
impl<S, A, B> Dsl<S> for Either<A, B> where S: Eval<Ast, bool> + Eval<Ast, A> + Eval<Ast, B> {
fn try_provide (state: &S, source: Ast) -> Perhaps<Self> {
if let Exp(_, exp) = source.0 && let Some(Ast(Key(id))) = exp.peek() && *id == *"either" {
if let Exp(_, mut exp) = source.0 && let Some(Ast(Key(id))) = exp.peek() && *id == *"either" {
let _ = exp.next();
return Ok(Some(Self(
state.eval(exp.next().unwrap(), ||"either: expected condition")?,
@ -32,7 +32,7 @@ impl<S, A> Dsl<S> for Align<A> where S: Eval<Option<Ast>, A> {
fn try_provide (state: &S, source: Ast) -> Perhaps<Self> {
if let Exp(_, source) = source.0 {
let mut rest = source.clone();
return Ok(Some(match rest.next().and_then(|x|x.key()) {
return Ok(Some(match rest.next().as_ref().and_then(|x|x.key()) {
Some("align/c") => Self::c(state.eval(rest.next(), ||"align/c: expected content")?),
Some("align/x") => Self::x(state.eval(rest.next(), ||"align/x: expected content")?),
Some("align/y") => Self::y(state.eval(rest.next(), ||"align/y: expected content")?),
@ -55,7 +55,7 @@ impl<S, A, B> Dsl<S> for Bsp<A, B> where S: Eval<Option<Ast>, A> + Eval<Option<A
fn try_provide (state: &S, source: Ast) -> Perhaps<Self> {
if let Exp(_, exp) = source.0 {
let mut rest = exp.clone();
return Ok(Some(match rest.next().and_then(|x|x.key()) {
return Ok(Some(match rest.next().as_ref().and_then(|x|x.key()) {
Some("bsp/n") => Self::n(
state.eval(rest.next(), ||"bsp/n: expected content 1")?,
state.eval(rest.next(), ||"bsp/n: expected content 2")?,