diff --git a/Cargo.lock b/Cargo.lock index e025782..7cd1c95 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -163,7 +163,6 @@ dependencies = [ name = "chumsky-app" version = "0.0.0" dependencies = [ - "ariadne", "chumsky", ] diff --git a/examples/chumsky-app/Cargo.toml b/examples/chumsky-app/Cargo.toml index 6301b94..c6d2060 100644 --- a/examples/chumsky-app/Cargo.toml +++ b/examples/chumsky-app/Cargo.toml @@ -7,5 +7,4 @@ name = "chumsky-app" path = "app.rs" [dependencies] -ariadne = "0.4.1" chumsky = "0.9.3" diff --git a/examples/chumsky-app/app.rs b/examples/chumsky-app/app.rs index 28a490b..bf813c9 100644 --- a/examples/chumsky-app/app.rs +++ b/examples/chumsky-app/app.rs @@ -6,7 +6,6 @@ mod parser; use std::{env, fs}; -use ariadne::{Color, Fmt, Label, Report, ReportKind, Source}; use chumsky::Parser; fn main() { @@ -22,66 +21,7 @@ fn main() { { std::hint::black_box(json); } - errs.into_iter().for_each(|e| { - let msg = if let chumsky::error::SimpleReason::Custom(msg) = e.reason() { - msg.clone() - } else { - format!( - "{}{}, expected {}", - if e.found().is_some() { - "Unexpected token" - } else { - "Unexpected end of input" - }, - if let Some(label) = e.label() { - format!(" while parsing {}", label) - } else { - String::new() - }, - if e.expected().len() == 0 { - "something else".to_string() - } else { - e.expected() - .map(|expected| match expected { - Some(expected) => expected.to_string(), - None => "end of input".to_string(), - }) - .collect::>() - .join(", ") - }, - ) - }; - - let report = Report::build(ReportKind::Error, (), e.span().start) - .with_code(3) - .with_message(msg) - .with_label( - Label::new(e.span()) - .with_message(match e.reason() { - chumsky::error::SimpleReason::Custom(msg) => msg.clone(), - _ => format!( - "Unexpected {}", - e.found() - .map(|c| format!("token {}", c.fg(Color::Red))) - .unwrap_or_else(|| "end of input".to_string()) - ), - }) - .with_color(Color::Red), - ); - - let report = match e.reason() { - chumsky::error::SimpleReason::Unclosed { span, delimiter } => report.with_label( - Label::new(span.clone()) - .with_message(format!( - "Unclosed delimiter {}", - delimiter.fg(Color::Yellow) - )) - .with_color(Color::Yellow), - ), - chumsky::error::SimpleReason::Unexpected => report, - chumsky::error::SimpleReason::Custom(_) => report, - }; - - report.finish().print(Source::from(&src)).unwrap(); - }); + for err in errs { + eprintln!("{err}"); + } }