Skip to content

Commit

Permalink
Fix offset in REPL
Browse files Browse the repository at this point in the history
  • Loading branch information
ajeetdsouza committed May 10, 2024
1 parent 5bbd8ea commit 431f59d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/syntax/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ pub fn parse(source: &str, offset: usize) -> Result<Program, Vec<ErrorS>> {

errors.extend(parser_errors.into_iter().map(|err| match err {
ParseError::ExtraToken { token: (start, _, end) } => (
Error::SyntaxError(SyntaxError::ExtraToken { token: source[start..end].to_string() }),
Error::SyntaxError(SyntaxError::ExtraToken {
token: source[start - offset..end - offset].to_string(),
}),
start..end,
),
ParseError::InvalidToken { location } => {
Expand All @@ -49,7 +51,7 @@ pub fn parse(source: &str, offset: usize) -> Result<Program, Vec<ErrorS>> {
}
ParseError::UnrecognizedToken { token: (start, _, end), expected } => (
Error::SyntaxError(SyntaxError::UnrecognizedToken {
token: source[start..end].to_string(),
token: source[start - offset..end - offset].to_string(),
expected,
}),
start..end,
Expand Down

0 comments on commit 431f59d

Please sign in to comment.