fix: errors

This commit is contained in:
Artemy Egorov 2024-08-12 17:46:57 +03:00
parent 50f5c7fe19
commit ebc47a2c27
2 changed files with 58 additions and 20 deletions

View file

@ -1,5 +1,5 @@
use ariadne::{Color, Label, Report, ReportKind, Source};
use chumsky::{input::Input, Parser};
use chumsky::{error::RichReason, input::Input, Parser};
use dalet::daleth::{lexer::lexer, parser::parser};
fn main() {
@ -12,16 +12,19 @@ fn main() {
match parsed.into_result() {
Ok(t) => {
println!("{:#?}", t);
// println!("{}", format(&t));
}
Err(e) => e.into_iter().for_each(|e| {
// println!("{:#}", )
let msg = match e.reason() {
RichReason::Many(errs) => errs[0].to_string(),
_ => e.to_string(),
};
Report::build(ReportKind::Error, src_file, e.span().start)
.with_code("Parser")
.with_message(e.to_string())
.with_label(
Label::new((src_file, e.span().into_range()))
.with_message(e.to_string())
.with_message(&msg)
.with_color(Color::Red),
)
.finish()