jss-core 0.2.0

Json Simplified Schema Core Interface
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use jss_pest::{pest::error::LineColLocation, Error, Rule};

use crate::{JssError, JssErrorKind};

impl From<Error<Rule>> for JssError {
    fn from(e: Error<Rule>) -> Self {
        let kind = JssErrorKind::SyntaxError(e.to_string());
        match e.line_col {
            LineColLocation::Pos(_) => Self { kind: Box::new(kind), line: 0, column: 0 },
            LineColLocation::Span(start, _) => Self { kind: Box::new(kind), line: start.0 as u32, column: start.0 as u32 },
        }
    }
}