1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use crate::runtime::RuntimeError;
use parsit::error::ParseError;
use parsit::step::Step;

pub mod parser;
pub mod project;

pub fn cerr(v: String) -> TreeError {
    TreeError::CompileError(v)
}

#[derive(Debug, PartialEq)]
pub enum TreeError {
    ParseError(String),
    CompileError(String),
    VisualizationError(String),
    IOError(String),
}

impl From<ParseError<'_>> for TreeError {
    fn from(value: ParseError) -> Self {
        TreeError::ParseError(value.to_string())
    }
}
impl From<RuntimeError> for TreeError {
    fn from(value: RuntimeError) -> Self {
        TreeError::IOError(format!("{:?}", value))
    }
}