fix(errors): unexpected char errors were pointing one char too far

This commit is contained in:
Khaïs COLIN 2025-05-04 18:10:50 +02:00
parent a0869b1b66
commit 106c2547b5
2 changed files with 8 additions and 3 deletions

View file

@ -185,6 +185,10 @@ CLOCK: [2025-05-04 dim. 14:01]--[2025-05-04 dim. 14:14] => 0:13
:EFFORT: 10 :EFFORT: 10
:END: :END:
* TODO error offsets are incorrect * DONE error offsets are incorrect
* TODO remove old FromStr parser implementation * TODO remove old FromStr parser implementation
* TODO use a better readline impl
* TODO handle non-interactive input better

View file

@ -216,11 +216,12 @@ impl Tokenizer {
} else if c.is_whitespace() { } else if c.is_whitespace() {
self.advance(); self.advance();
} else { } else {
self.advance(); let result = Err(ScanError {
return Err(ScanError {
location: self.current_location(1), location: self.current_location(1),
kind: ScanErrorKind::UnexpectedChar(c), kind: ScanErrorKind::UnexpectedChar(c),
}); });
self.advance();
return result;
} }
} else { } else {
return Ok(None); return Ok(None);