The lexer currently reports user errors through panics (In particular, there is currently only one user error, "token limit reached", i.e. TokenLimitReachedError).
As the lexer is used in the parser, which already previously got refactored from reporting user errors as panics in #1764, it might be surprising to users of the parser that user errors are still reported as panics in some cases.
Suggested Solution
Refactor the lexer to report user errors, such as the "token limit reached" error (TokenLimitReachedError), to be reported as an error return value, instead of a panic.
Issue to be solved
The lexer currently reports user errors through panics (In particular, there is currently only one user error, "token limit reached", i.e.
TokenLimitReachedError
).As the lexer is used in the parser, which already previously got refactored from reporting user errors as panics in #1764, it might be surprising to users of the parser that user errors are still reported as panics in some cases.
Suggested Solution
Refactor the lexer to report user errors, such as the "token limit reached" error (
TokenLimitReachedError
), to be reported as an error return value, instead of a panic.