jss_core/errors/from_pest/mod.rs
1use jss_pest::{pest::error::LineColLocation, Error, Rule};
2
3use crate::{JssError, JssErrorKind};
4
5impl From<Error<Rule>> for JssError {
6 fn from(e: Error<Rule>) -> Self {
7 let kind = JssErrorKind::SyntaxError(e.to_string());
8 match e.line_col {
9 LineColLocation::Pos(_) => Self { kind: Box::new(kind), line: 0, column: 0 },
10 LineColLocation::Span(start, _) => Self { kind: Box::new(kind), line: start.0 as u32, column: start.0 as u32 },
11 }
12 }
13}