-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Clarify the positions of the lexer and parser #36969
Conversation
This is a [breaking-change] for libsyntax.
Likewise, rename LastTokenKind as PrevTokenKind. This is a [breaking-change] for libsyntax.
This is a [breaking-change] for libsyntax.
This is a [breaking-change] for libsyntax.
Likewise, rename StringReader::curr_is as ch_is. This is a [breaking-change] for libsyntax.
This commit renames the variables to make it clearer which char each one refers to. It also slightly reorders and rearranges some statements.
(rust_highfive has picked a reviewer for you, use r? to override) |
r? @eddyb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Manishearth r=me
To clarify, we're blocked here on @Manishearth doing some kind of "rollup of plugin-breaking changes"? /me can't wait for macros 1.1 |
📌 Commit 94b3659 has been approved by |
Yeah libsyntax won't affect Serde anymore. I still appreciate the heads-up because aster and quasi still exist. |
Yay. This is a useful patch and it'd be nice to have it merged sooner rather than later. |
Clarify the positions of the lexer and parser The lexer and parser use unclear names to indicate their positions in the source code. I propose the following renamings. Lexer: ``` pos -> next_pos # it's actually the next pos! last_pos -> pos # it's actually the current pos! curr -> ch # the current char curr_is -> ch_is # tests the current char col (unchanged) # the current column ``` parser ``` - last_span -> prev_span # the previous token's span - last_token_kind -> prev_token_kind # the previous token's kind - LastTokenKind -> PrevTokenKind # ditto (but the type) - token (unchanged) # the current token - span (unchanged) # the current span ``` Things to note: - This proposal removes all uses of "last", which is an unclear word because it could mean (a) previous, (b) final, or (c) most recent, i.e. current. - The "current" things (ch, col, token, span) consistently lack a prefix. The "previous" and "next" things consistently have a prefix.
The lexer and parser use unclear names to indicate their positions in the
source code. I propose the following renamings.
Lexer:
parser
Things to note:
could mean (a) previous, (b) final, or (c) most recent, i.e. current.
"previous" and "next" things consistently have a prefix.