mirror of
https://github.com/TxtDot/dalet-rs.git
synced 2025-02-28 05:11:24 +03:00
fix: errors
This commit is contained in:
parent
50f5c7fe19
commit
ebc47a2c27
2 changed files with 58 additions and 20 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue