diff --git a/flake.nix b/flake.nix index e3d9831..cf1a7c3 100644 --- a/flake.nix +++ b/flake.nix @@ -4,9 +4,9 @@ flake-utils.url = "github:numtide/flake-utils"; }; outputs = { - self, nixpkgs, flake-utils, + ... }: flake-utils.lib.eachDefaultSystem (system: let @@ -28,6 +28,8 @@ pkgs.bacon pkgs.cargo-semver-checks pkgs.cargo-insta + # debugger + pkgs.lldb ]; }; packages.default = pkgs.rustPlatform.buildRustPackage { diff --git a/notes.org b/notes.org index a00857a..3759fa5 100644 --- a/notes.org +++ b/notes.org @@ -220,7 +220,9 @@ i will use rustyline, since it seems like the most feature-complete * DONE parse strings -* TODO better error message display for unclosed " in string +* DONE better error message display for unclosed " in string + +* TODO print errors to stderr * TODO parse insert statements in the form insert diff --git a/src/error_display.rs b/src/error_display.rs index cd303b6..0f8bd14 100644 --- a/src/error_display.rs +++ b/src/error_display.rs @@ -32,15 +32,34 @@ impl OSDBError for CommandParseError { impl OSDBError for ScanError { fn display(&self, file: &str, input: &str) { let location = (file, Into::>::into(&self.location)); - Report::build(ReportKind::Error, location.clone()) - .with_message(format!("{self}")) - .with_label( + + let report = + Report::build(ReportKind::Error, location.clone()).with_message(format!("{self}")); + let report = match &self.kind { + crate::tokens::ScanErrorKind::UnexpectedEndOfInputWhileLookingForMatching( + c, + start_location, + ) => { + let start_location = (file, Into::>::into(start_location)); + report + .with_label( + Label::new(location) + .with_order(-1) + .with_color(Color::Red) + .with_message(format!("expected {c:?} but found end of input")), + ) + .with_label( + Label::new(start_location) + .with_color(Color::Blue) + .with_message(format!("looking for a {c:?} to match this")), + ) + } + _ => report.with_label( Label::new(location) .with_color(Color::Red) .with_message(format!("{self}")), - ) - .finish() - .print((file, Source::from(input))) - .unwrap(); + ), + }; + report.finish().print((file, Source::from(input))).unwrap(); } }