mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-07 12:16:44 +01:00
AstToken -> Ast <- AstValue
This commit is contained in:
parent
f77139c8fd
commit
e9d4c7e0bc
5 changed files with 30 additions and 40 deletions
|
|
@ -2,15 +2,21 @@ use crate::*;
|
|||
use std::sync::Arc;
|
||||
use std::borrow::Cow;
|
||||
|
||||
/// Owns its values, and has no metadata.
|
||||
#[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>, Vec<AstToken>>;
|
||||
impl<'source> From<CstValue<'source>> for AstValue {
|
||||
pub struct AstIter;
|
||||
impl<'source> From<SourceIter<'source>> for AstIter {
|
||||
fn from (source: SourceIter<'source>) -> Self {
|
||||
Self // TODO
|
||||
}
|
||||
}
|
||||
/// Owns its values, and has no metadata.
|
||||
pub type Ast = Value<Arc<str>, AstIter>;
|
||||
impl<'source> From<CstToken<'source>> for Ast {
|
||||
fn from (token: CstToken<'source>) -> Self {
|
||||
token.value().into()
|
||||
}
|
||||
}
|
||||
impl<'source> From<CstValue<'source>> for Ast {
|
||||
fn from (value: CstValue<'source>) -> Self {
|
||||
use Value::*;
|
||||
match value {
|
||||
|
|
@ -24,11 +30,3 @@ impl<'source> From<CstValue<'source>> for AstValue {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
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