Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add file info to span during tokenizing and handle error properly #5

Merged
merged 1 commit into from
Jan 8, 2025

Conversation

cakevm
Copy link
Owner

@cakevm cakevm commented Jan 8, 2025

This is a first step towards better error handling. The Lexer::new get additionally to the source the file to allow to add this info to the span. This can be refactored and simplified in a later step.

For invalid character now a proper error message is printed. Cases for imported files need to be fixed.

Before:

⠋ Compiling...thread 'main' panicked at crates/core/src/lib.rs:352:50:
called `Result::unwrap()` on an `Err` value: LexicalError { kind: InvalidCharacter('#'), span: Span { start: 2810, end: 2810, file: None } }
stack backtrace:...

After:

Error: Invalid Character: "#" 
-> src/Flux.huff:2810-2810
       |
  > 49 | #
       |

@cakevm cakevm merged commit a672516 into main Jan 8, 2025
6 checks passed
@cakevm cakevm deleted the tokenize-error branch January 8, 2025 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant