private void ParseStatements(List<StatementSyntax> statements, bool stopOnSwitchSections)
{
var saveTerm = _termState;
_termState |= TerminatorState.IsPossibleStatementStartOrStop; // partial statements can abort if a new statement starts
if (stopOnSwitchSections)
_termState |= TerminatorState.IsSwitchSectionStart;
while (Current.Kind != SyntaxKind.CloseBraceToken
&& Current.Kind != SyntaxKind.EndOfFileToken
&& !(stopOnSwitchSections && IsPossibleSwitchSection()))
{
if (IsPossibleStatement())
{
statements.Add(ParseStatement());
}
else
{
var action = SkipBadStatementListTokens(SyntaxKind.CloseBraceToken);
if (action == PostSkipAction.Abort)
break;
}
}
_termState = saveTerm;
}