Skip to content

Support parsing for Unsigned Right Shift operator#60501

Merged
AlekseyTs merged 3 commits intodotnet:features/UnsignedRightShiftfrom
AlekseyTs:UnsignedRightShift_01
Apr 4, 2022
Merged

Support parsing for Unsigned Right Shift operator#60501
AlekseyTs merged 3 commits intodotnet:features/UnsignedRightShiftfrom
AlekseyTs:UnsignedRightShift_01

Conversation

@AlekseyTs
Copy link
Copy Markdown
Contributor

@AlekseyTs AlekseyTs commented Mar 31, 2022

NoTriviaBetween(opToken2, tk)) // no trailing trivia and no leading trivia
{
opToken2 = this.EatToken();
opToken = SyntaxFactory.Token(opToken.GetLeadingTrivia(), SyntaxKind.GreaterThanGreaterThanGreaterThanToken, opToken2.GetTrailingTrivia());
Copy link
Copy Markdown
Member

@Youssef1313 Youssef1313 Mar 31, 2022

Choose a reason for hiding this comment

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

Should MergeAdjacent be used? #Resolved

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should MergeAdjacent be used?

I am not inventing new ways of doing things, simply following what we do for SyntaxKind.GreaterThanGreaterThanToken.

operatorToken.ValueText + operatorToken2.ValueText + operatorToken3.ValueText,
operatorToken3.GetTrailingTrivia());

operatorToken = SyntaxFactory.MissingToken(SyntaxKind.PlusToken);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not entirely clear waht's going on here. Is x >>>= 1 not allowed?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

oh. this is doc comment parsing. n/m/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

fwiw, there feels like there's a lot of overlap between this and the same logic below for >>=. consider extracting a local function to help out here.

Copy link
Copy Markdown
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

Couple of questions.

operatorToken.Text + operatorToken2.Text + operatorToken3.Text,
operatorToken.ValueText + operatorToken2.ValueText + operatorToken3.ValueText,
operatorToken3.GetTrailingTrivia());

Copy link
Copy Markdown
Member

@333fred 333fred Mar 31, 2022

Choose a reason for hiding this comment

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

Why use a PlusToken, and not a GreaterThanToken? #Resolved

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Why use a PlusToken, and not a GreaterThanToken?

Simply following the existing behavior on line 1092

@@ -10639,25 +10650,42 @@ private ExpressionSyntax ParseExpressionContinued(ExpressionSyntax leftOperand,
var newPrecedence = GetPrecedence(opKind);

// check for >> or >>=
Copy link
Copy Markdown
Member

@333fred 333fred Mar 31, 2022

Choose a reason for hiding this comment

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

Consider updating this comment. #Resolved

@@ -3720,12 +3722,106 @@ void M()
var j = e is a < i >>> 2;
Copy link
Copy Markdown
Member

@333fred 333fred Mar 31, 2022

Choose a reason for hiding this comment

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

Consider removing the comment above this line. #Closed

{
void M()
{
var added = ImmutableDictionary<T<S>>>
Copy link
Copy Markdown
Member

@333fred 333fred Mar 31, 2022

Choose a reason for hiding this comment

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

Would it be useful to have a test with a tuple type next to the >>> as well? #Resolved

Copy link
Copy Markdown
Contributor Author

@AlekseyTs AlekseyTs Mar 31, 2022

Choose a reason for hiding this comment

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

Would it be useful to have a test with a tuple type next to the >>> as well?

I am not aware of any specific reason why this could be useful, other than the fact that any test potentially has some value. Also, I think there is no test like that for >>, so I assume there isn't anything special there.

@AlekseyTs
Copy link
Copy Markdown
Contributor Author

@jcouv, @dotnet/roslyn-compiler For the second review.

1 similar comment
@AlekseyTs
Copy link
Copy Markdown
Contributor Author

@jcouv, @dotnet/roslyn-compiler For the second review.

}
}
EOF();
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: I was trying to brainstorm cases to tests. Scenarios like is A<B<C<T>>>, as A<B<C<T>>>, (A<B<C<T>>>, Type) a = ... are probably already covered (plus those relate to parsing types, not parsing expressions).
So maybe a legit expression scenario: a < b < c < t >>> n, or an incremental scenario transitioning from type to expression or vice-versa?

Copy link
Copy Markdown
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 2)

@jcouv jcouv self-assigned this Apr 1, 2022
{
foreach (var options in new[] { TestOptions.RegularPreview, TestOptions.Regular10, TestOptions.RegularNext })
{
UsingExpression("x >> >= y", options,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Consider a test similar to:

_ = x switch
{
    A<B<C<D>>>=> 0,
}

@AlekseyTs AlekseyTs enabled auto-merge (squash) April 4, 2022 17:26
@AlekseyTs
Copy link
Copy Markdown
Contributor Author

I'll follow up on test suggestions separately.

@AlekseyTs AlekseyTs merged commit 6ab2107 into dotnet:features/UnsignedRightShift Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants