提交 31f1fb6b 编写于 作者: N Neal Gafter

Use `IsMakingProgress` in pattern parsing.

Simplify expressions in `IsPossibleSubpatternElement`
上级 83561e68
......@@ -532,7 +532,8 @@ private PropertySubpatternSyntax ParsePropertySubpattern()
list.Add(this.ParseSubpatternElement());
// additional patterns
while (true)
int lastTokenPosition = -1;
while (IsMakingProgress(ref lastTokenPosition))
{
if (this.CurrentToken.Kind == SyntaxKind.CloseParenToken ||
this.CurrentToken.Kind == SyntaxKind.CloseBraceToken ||
......@@ -588,8 +589,11 @@ private SubpatternElementSyntax ParseSubpatternElement()
private bool IsPossibleSubpatternElement()
{
var tk = this.CurrentToken.Kind;
return this.IsPossibleExpression() && !(SyntaxFacts.IsBinaryExpression(tk) || SyntaxFacts.IsAssignmentExpressionOperatorToken(tk)) ||
this.CurrentToken.Kind == SyntaxKind.OpenBraceToken;
bool isExpression = this.IsPossibleExpression() &&
// IsPossibleExpression returns true when the next token is a binary operator.
// That is useful for error recovery elsewhere, but not here.
!(SyntaxFacts.IsBinaryExpression(tk) || SyntaxFacts.IsAssignmentExpressionOperatorToken(tk));
return isExpression || this.CurrentToken.Kind == SyntaxKind.OpenBraceToken;
}
private PostSkipAction SkipBadPatternListTokens(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册