use std::error::Error;
use std::fmt::{Display, Formatter};
use crate::evaluator::{SyntaxError, Context};
use crate::template::EvaluableMixedContent;
use crate::units::Position;
pub trait Compiler<T> {
type Item;
type ItemIterator: Iterator<Item = Self::Item>;
fn compile<C>(&self, content: C, context: Context) -> Result<String, CompilationError>
where C: EvaluableMixedContent<Item=Self::Item, IntoIter=Self::ItemIterator>;
}
#[derive(Debug, PartialEq)]
pub enum CompilationError {
EvaluationFailed {
error: SyntaxError,
position: Position,
source: String,
},
}
impl Error for CompilationError {}
impl Display for CompilationError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}