mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-07 12:16:44 +01:00
wip: wee
This commit is contained in:
parent
d6e8be6ce5
commit
f77139c8fd
5 changed files with 68 additions and 59 deletions
|
|
@ -3,12 +3,13 @@ use std::sync::Arc;
|
|||
use std::borrow::Cow;
|
||||
|
||||
/// Owns its values, and has no metadata.
|
||||
pub type AstToken = Token<AstValue, AstMeta>;
|
||||
#[derive(PartialEq, Clone, Default, Debug)]
|
||||
pub struct AstToken(pub AstValue, pub AstMeta);
|
||||
|
||||
#[derive(Debug, Copy, Clone, Default, PartialEq)]
|
||||
pub struct AstMeta;
|
||||
|
||||
pub type AstValue = Value<Arc<str>, AstExp>;
|
||||
pub type AstValue = Value<Arc<str>, Vec<AstToken>>;
|
||||
impl<'source> From<CstValue<'source>> for AstValue {
|
||||
fn from (value: CstValue<'source>) -> Self {
|
||||
use Value::*;
|
||||
|
|
@ -19,18 +20,15 @@ impl<'source> From<CstValue<'source>> for AstValue {
|
|||
Sym(s) => Sym(s.into()),
|
||||
Key(s) => Key(s.into()),
|
||||
Str(s) => Str(s.into()),
|
||||
Exp(x) => Exp(x.into()),
|
||||
Exp(d, x) => Exp(d, x.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, PartialEq)]
|
||||
pub struct AstExp(pub Vec<AstToken>);
|
||||
impl<'source> From<CstExp<'source>> for AstExp {
|
||||
fn from (exp: CstExp<'source>) -> AstExp {
|
||||
AstExp(exp.words.map(|token|Token(
|
||||
AstValue::from(token.value()),
|
||||
AstMeta,
|
||||
)).collect())
|
||||
}
|
||||
}
|
||||
pub trait AstIter: DslIter<Token = AstToken> {}
|
||||
|
||||
//impl<'source> From<CstExp<'source>> for AstExp {
|
||||
//fn from (exp: CstExp<'source>) -> AstExp {
|
||||
//AstExp(exp.words.map(|token|Token(AstValue::from(token.value()), AstMeta,)).collect())
|
||||
//}
|
||||
//}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue