use crate::*; #[derive(Debug, Clone, Default, PartialEq)] pub struct Ast(pub AstValue); /// The abstract syntax tree (AST) can be produced from the CST /// by cloning source slices into owned [Arc] values. pub type AstValue = DslValue, VecDeque>; //#[derive(Debug, Clone, Default, PartialEq)] //pub struct AstIter(); impl<'src> From> for Ast { fn from (token: Cst<'src>) -> Self { token.value().into() } } impl<'src> From> for Ast { fn from (value: CstValue<'src>) -> Self { Self(match value { DslValue::Nil => DslValue::Nil, DslValue::Err(e) => DslValue::Err(e), DslValue::Num(u) => DslValue::Num(u), DslValue::Sym(s) => DslValue::Sym(s.into()), DslValue::Key(s) => DslValue::Key(s.into()), DslValue::Str(s) => DslValue::Str(s.into()), DslValue::Exp(d, x) => DslValue::Exp(d, x.map(|x|x.into()).collect()), }) } }