Compare commits

...

2 commits

3 changed files with 32 additions and 9 deletions

View file

@ -4,9 +4,9 @@
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
}; };
outputs = { outputs = {
self,
nixpkgs, nixpkgs,
flake-utils, flake-utils,
...
}: }:
flake-utils.lib.eachDefaultSystem flake-utils.lib.eachDefaultSystem
(system: let (system: let
@ -28,6 +28,8 @@
pkgs.bacon pkgs.bacon
pkgs.cargo-semver-checks pkgs.cargo-semver-checks
pkgs.cargo-insta pkgs.cargo-insta
# debugger
pkgs.lldb
]; ];
}; };
packages.default = pkgs.rustPlatform.buildRustPackage { packages.default = pkgs.rustPlatform.buildRustPackage {

View file

@ -220,7 +220,9 @@ i will use rustyline, since it seems like the most feature-complete
* DONE parse strings * 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 * TODO parse insert statements in the form
insert <id:int> <username:string> <email:string> insert <id:int> <username:string> <email:string>

View file

@ -32,15 +32,34 @@ impl OSDBError for CommandParseError {
impl OSDBError for ScanError { impl OSDBError for ScanError {
fn display(&self, file: &str, input: &str) { fn display(&self, file: &str, input: &str) {
let location = (file, Into::<std::ops::Range<usize>>::into(&self.location)); let location = (file, Into::<std::ops::Range<usize>>::into(&self.location));
Report::build(ReportKind::Error, location.clone())
.with_message(format!("{self}")) let report =
.with_label( 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::<std::ops::Range<usize>>::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) Label::new(location)
.with_color(Color::Red) .with_color(Color::Red)
.with_message(format!("{self}")), .with_message(format!("{self}")),
) ),
.finish() };
.print((file, Source::from(input))) report.finish().print((file, Source::from(input))).unwrap();
.unwrap();
} }
} }