mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 03:36:42 +01:00
32 lines
879 B
Rust
32 lines
879 B
Rust
use crate::*;
|
|
use std::sync::Arc;
|
|
use std::borrow::Cow;
|
|
|
|
#[derive(Debug, Copy, Clone, Default, PartialEq)]
|
|
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 {
|
|
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()),
|
|
}
|
|
}
|
|
}
|