use std::collections::HashMap;
use crate::err::TmplResult;
use crate::value::TmplValue;
pub struct ExpressionManager {
pub symbols: Vec<ExprSymbolCovert>,
pub primitive_renders: HashMap<String, PrimitiveRenderType>,
}
pub struct ExprSymbolCovert {
pub symbol: String,
pub covert: fn(ExpressionIR, ExpressionIR) -> ExpressionIR,
}
pub enum PrimitiveRenderType {
Native(fn(Vec<TmplValue>) -> TmplResult<TmplValue>),
Translate(fn(Vec<ExpressionIR>) -> TmplResult<ExpressionIR>),
}
#[derive(Debug, Clone, PartialEq)]
pub enum ExpressionIR {
ItemSymbol(SymbolType),
ItemValue(TmplValue),
ItemVariable(Vec<String>),
ItemPrimitive(String, Vec<ExpressionIR>),
ItemGroup(Vec<ExpressionIR>),
}
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum SymbolType {
BlockStart,
BlockEnd,
BlockCut,
Custom(String),
}
#[derive(Debug)]
pub struct Expression {
pub variables: Vec<String>,
pub ast: ExpressionAST,
}
#[derive(Debug)]
pub enum ExpressionAST {
ItemValue(TmplValue),
ItemVariable(String),
ItemPrimitive(String, Vec<ExpressionAST>),
}