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
30
31
32
use glicol_parser::Rule;
use pest::error::Error;
pub use pest::error::ErrorVariant;

#[derive(Debug)]
pub enum EngineError {
    ParsingError(pest::error::Error<glicol_parser::Rule>),
    NonExistReference(String),
    NonExsitSample(String),
}

impl std::convert::From<Error<Rule>> for EngineError {
    fn from(err: Error<Rule>) -> EngineError {
        EngineError::ParsingError(err)
    }
}

// pub fn encode_error_info(e) -> [u8; 256] {

// }

pub fn get_error_info(e: Error<Rule>) -> (Vec<Rule>, Vec<Rule>) {
    match e.variant {
        ErrorVariant::ParsingError {
            positives,
            negatives,
        } => (positives, negatives),
        _ => {
            unimplemented!();
        }
    }
}