add nom error handling

main
NotAFile 2022-02-01 23:11:59 +01:00
parent c32da018ad
commit cec4f5fb8d
1 changed files with 2 additions and 5 deletions

View File

@ -1,9 +1,5 @@
use std::fmt::Debug;
use std::ops::Deref;
use super::{IErr, Span};
use ariadne::{Label, Report, ReportKind};
use nom::error::ErrorKind;
use nom_greedyerror::{GreedyErrorKind, Position};
fn span_to_range(input: Span) -> std::ops::Range<usize> {
@ -19,7 +15,8 @@ pub fn convert_error(input: Span, e: IErr<Span>) -> Report {
}
GreedyErrorKind::Char(c) => Label::new(err.0.position()..err.0.position())
.with_message(format!("expected {c:?}")),
GreedyErrorKind::Nom(_) => todo!(),
GreedyErrorKind::Nom(kind) => Label::new(err.0.position()..err.0.position())
.with_message(format!("nom error {kind:?}")),
};
labels.push(label);
}