tengri/dsl/src/dsl_ast.rs

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()),
}
}
}