Skip to content

Conversation

@CyrusNajmabadi
Copy link
Member

This gives us the ability to parse about 30 more frames during heavily recursive scenarios.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner February 13, 2020 17:18
@CyrusNajmabadi
Copy link
Member Author

Tagging @RikkiGibson @jcouv @cston

this.EatToken(SyntaxKind.CloseParenToken),
this.ParseEmbeddedStatement(),
this.ParseElseClauseOpt());
}
Copy link
Member Author

Choose a reason for hiding this comment

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

optimie the fast path of a normal if-statement, with no need for flow control or storage for flow control temps.

this.ParseElseClauseOpt());
}

private IfStatementSyntax ParseMisplacedElse()
Copy link
Member Author

Choose a reason for hiding this comment

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

MisplacedElse is a very rare case (usually just in the IDE as people are typing). it's fine for it to have it's own dedicated parsing method.

return this.ParseIfStatement();
case SyntaxKind.ElseKeyword:
// Including 'else' keyword to handle 'else without if' error cases
return this.ParseMisplacedElse();
Copy link
Member

Choose a reason for hiding this comment

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

good idea!

return _syntaxFactory.IfStatement(@if, openParen, condition, closeParen, statement, elseClause);
return _syntaxFactory.IfStatement(
this.EatToken(SyntaxKind.IfKeyword, ErrorCode.ERR_ElseCannotStartStatement),
this.EatToken(SyntaxKind.OpenParenToken),
Copy link
Member

Choose a reason for hiding this comment

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

Should we call EatToken, ParseExpressionCore, etc in this way even though we know they will always fail? Basically everything before 'ParseElseClauseOpt'?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. That's the idea (and what the code did before). It effectively synthesizes the missing nodes/tokens we want here

@RikkiGibson RikkiGibson requested a review from a team February 13, 2020 18:16
@RikkiGibson RikkiGibson added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Feb 13, 2020
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Auto-approval

@RikkiGibson RikkiGibson added this to the 16.6 milestone Feb 13, 2020
@ghost ghost merged commit 04f5679 into dotnet:master Feb 13, 2020
@CyrusNajmabadi
Copy link
Member Author

Thanks!

@CyrusNajmabadi CyrusNajmabadi deleted the ifParsing2 branch February 13, 2020 19:29
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers auto-merge Community The pull request was submitted by a contributor who is not a Microsoft employee.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants