Merged
Conversation
This was referenced Jun 7, 2023
Member
Author
|
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
Contributor
PR Check ResultsEcosystem✅ ecosystem check detected no changes. BenchmarkLinuxWindows |
MichaReiser
commented
Jun 7, 2023
| Other, | ||
|
|
||
| /// Returned for each character after [`TokenKind::Other`] has been returned once. | ||
| Bogus, |
Member
Author
There was a problem hiding this comment.
Should we name this Unknown instead?
bb0517f to
2448287
Compare
2448287 to
5a9709d
Compare
Merged
MichaReiser
commented
Jun 8, 2023
| let tokens = SimpleTokenizer::up_to(offset, code); | ||
| let mut newlines = 0u32; | ||
|
|
||
| for token in tokens.rev() { |
Member
Author
There was a problem hiding this comment.
One of the main benefits is that we no longer repeat the same logic over and over again (and e.g. correctly handle continuation tokens)
5a9709d to
894b045
Compare
894b045 to
f5240f7
Compare
f5240f7 to
1b58a53
Compare
1b58a53 to
6a13e21
Compare
Member
Author
|
@charliermarsh let me know if you have time to look at this PR. I'll otherwise go ahead and merge it, as there's already a lot of code depending on it |
Member
|
@MichaReiser - Go for it, I won't have time for a few hours. |
Merged
This was referenced Jun 9, 2023
konstin
pushed a commit
that referenced
this pull request
Jun 13, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
This PR introduces a simple zero-allocation lexer specific for the needs of the formatter.
It supports a very limited set of tokens for optimized performance.
The main reason for introducing a lexer is that Charlie correctly pointed out that the current implementation for testing if an expression is parenthesized is not sufficient.
Having a more proper lexer will simplify testing for the right tokens.
Test Plan
cargo test, new unit tests