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

Do not lex .. as a single DotDotToken #75549

Merged
merged 51 commits into from
Oct 25, 2024

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Oct 17, 2024

Fixes #74456

Alternate approach to #75532.

The general idea here is to take the same approach parsing .. as we do with >>. Namely, instead of having the lexer lex out a combined token, which the parser would have to 'break up', we instead only have the lexer lex out two tokens, and we have the parser combine those tokens as needed when in a context where .. is legal (like a range-operator, slice-pattern, or collection-spread element).

This is fairly simple to accomplish, and simplifies a bunch of parsing code that used to have to look for . or .. and break up the latter. It also fixes incremental parsing as we can treat .. exactly like >> in the incremental parsing, marking it as a parser-fabricated token that should not then be returned when incrementally lexing.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 17, 2024
@@ -3235,7 +3235,6 @@ private bool IsFieldDeclaration(bool isEvent, bool isGlobalScriptLevel)
{
case SyntaxKind.DotToken: // Goo. explicit
case SyntaxKind.ColonColonToken: // Goo:: explicit
case SyntaxKind.DotDotToken: // Goo.. explicit
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most parser code got simpler. Instead of dealing with DotDot as if it was an errant Dot that they need to split, tehy just handle 'dot' like normal. only the code that explicitly cares about a .. token needs to handle and synthesize it.

@CyrusNajmabadi CyrusNajmabadi changed the title WIP Do not lex .. as a single DotDotToken Oct 17, 2024
@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review October 17, 2024 19:29
@CyrusNajmabadi
Copy link
Member Author

@jcouv this is ready for another pass.

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done with review pass (iteration 48)

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks! (iteration 51)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nonsense identifier expected error depending on how you edit unrelated code
6 participants