mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 11:46:42 +01:00
wip: mrr
This commit is contained in:
parent
6c3a0964ec
commit
7271081fc9
10 changed files with 119 additions and 296 deletions
|
|
@ -42,7 +42,20 @@ pub enum DslVal<Str, Exp> {
|
|||
Exp(usize, Exp),
|
||||
}
|
||||
|
||||
pub trait Dsl {
|
||||
pub fn dsl_val <A: Into<X>, B: Into<Y>, X, Y> (val: DslVal<A, B>) -> DslVal<X, Y> {
|
||||
use DslVal::*;
|
||||
match val {
|
||||
Nil => Nil,
|
||||
Err(e) => Err(e),
|
||||
Num(u) => Num(u),
|
||||
Sym(s) => Sym(s.into()),
|
||||
Key(s) => Key(s.into()),
|
||||
Str(s) => Str(s.into()),
|
||||
Exp(d, x) => Exp(d, x.into()),
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Dsl: Debug {
|
||||
type Str: PartialEq + Clone + Default + Debug + AsRef<str>;
|
||||
type Exp: PartialEq + Clone + Default + Debug + Dsl;
|
||||
fn nth (&self, index: usize) -> Option<DslVal<Self::Str, Self::Exp>>;
|
||||
|
|
@ -61,7 +74,7 @@ impl<
|
|||
fn val (&self) -> DslVal<Str, Exp> {
|
||||
self.clone()
|
||||
}
|
||||
fn nth (&self, index: usize) -> Option<DslVal<Str, Exp>> {
|
||||
fn nth (&self, _index: usize) -> Option<DslVal<Str, Exp>> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
@ -163,16 +176,3 @@ from_str!(Ast|source|Self::from(CstIter::from(source)));
|
|||
from_str!(Cst<'s>|source|Self(CstIter(CstConstIter(source))));
|
||||
from_str!(CstIter<'s>|source|Self(CstConstIter(source)));
|
||||
from_str!(CstConstIter<'s>|source|Self::new(source));
|
||||
|
||||
pub fn dsl_val <A: Into<X>, B: Into<Y>, X, Y> (val: DslVal<A, B>) -> DslVal<X, Y> {
|
||||
use DslVal::*;
|
||||
match val {
|
||||
Nil => Nil,
|
||||
Err(e) => Err(e),
|
||||
Num(u) => Num(u),
|
||||
Sym(s) => Sym(s.into()),
|
||||
Key(s) => Key(s.into()),
|
||||
Str(s) => Str(s.into()),
|
||||
Exp(d, x) => Exp(d, x.into()),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue