Fold RawToken into Token and remove the old Token.#16
Merged
c42f merged 1 commit intoJuliaLang:mainfrom Feb 24, 2022
Merged
Conversation
646c5dd to
0006393
Compare
RawToken into Token and remove the old Token.
0006393 to
978656a
Compare
c42f
approved these changes
Feb 24, 2022
Member
c42f
left a comment
There was a problem hiding this comment.
What an unexpected-but-welcome gift of code. Thanks @KristofferC !
| print(io, rpad(kind(t), 15, " ")) | ||
| print(io, "\"", str, "\"") | ||
| function untokenize(t::Token, str::String) | ||
| String(codeunits(str)[1 .+ (t.startbyte:t.endbyte)]) |
Member
There was a problem hiding this comment.
This is a nice way to express this operation with codeunits. I'm usually messing with previndex for this.
| end | ||
|
|
||
| ~(tok::T.AbstractToken, t::Tuple) = tok.kind == t[1] && untokenize(tok) == t[2] | ||
| ~(tok::T.Token, t::Tuple) = tok.kind == t[1] && untokenize(tok, t[3]) == t[2] |
Member
There was a problem hiding this comment.
Oho. I see what you did there. Very tricky.
Maybe neater to just define a utility function to take the place of collect(tokenize(ts)) instead which yields the tuples I'm testing against below. Then use == rather than having to pass str everywhere.
(Nevertheless, let's merge this as-is; that could be cleaned up separately.)
c42f
pushed a commit
to JuliaLang/julia
that referenced
this pull request
Oct 17, 2025
topolarity
pushed a commit
to JuliaLang/julia
that referenced
this pull request
Nov 14, 2025
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.
I think it is best to go "all in" on that Token only stores the byte ranges. No one will use the Token that stores the string explicitly because it is too slow. This allows quite a lot of code removal.