Skip to content

Commit aa1059c

Browse files
[Syntax] Parse WhileStmtSyntax nodes (#15186)
1 parent 94dbbd7 commit aa1059c

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

lib/Parse/ParseStmt.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,7 @@ ParserResult<Stmt> Parser::parseStmtGuard() {
15991599
/// stmt-while:
16001600
/// (identifier ':')? 'while' expr-basic stmt-brace
16011601
ParserResult<Stmt> Parser::parseStmtWhile(LabeledStmtInfo LabelInfo) {
1602+
SyntaxContext->setCreateSyntax(SyntaxKind::WhileStmt);
16021603
SourceLoc WhileLoc = consumeToken(tok::kw_while);
16031604

16041605
Scope S(this, ScopeKind::WhileVars);

test/Syntax/Outputs/round_trip_parse_gen.swift.withkinds

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,9 @@ func statementTests<FunctionSignature><ParameterClause>() </ParameterClause></Fu
319319
} </CodeBlock></CatchClause><CatchClause>catch <CodeBlock>{
320320
}</CodeBlock></CatchClause></DoStmt><RepeatWhileStmt>
321321
repeat <CodeBlock>{ } </CodeBlock>while <BooleanLiteralExpr>true</BooleanLiteralExpr></RepeatWhileStmt><RepeatWhileStmt>
322-
LABEL: repeat <CodeBlock>{ } </CodeBlock>while <BooleanLiteralExpr>false</BooleanLiteralExpr></RepeatWhileStmt><DoStmt>
322+
LABEL: repeat <CodeBlock>{ } </CodeBlock>while <BooleanLiteralExpr>false</BooleanLiteralExpr></RepeatWhileStmt><WhileStmt>
323+
while <ConditionElement><BooleanLiteralExpr>true </BooleanLiteralExpr></ConditionElement><CodeBlock>{ }</CodeBlock></WhileStmt><WhileStmt>
324+
LABEL: while <ConditionElement><BooleanLiteralExpr>true </BooleanLiteralExpr></ConditionElement><CodeBlock>{ }</CodeBlock></WhileStmt><DoStmt>
323325
LABEL: do <CodeBlock>{}</CodeBlock></DoStmt>
324326
LABEL: switch <IdentifierExpr>foo </IdentifierExpr>{
325327
case <ExpressionPattern><IntegerLiteralExpr>1</IntegerLiteralExpr></ExpressionPattern>:<FallthroughStmt>

test/Syntax/round_trip_parse_gen.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@ func statementTests() {
320320
}
321321
repeat { } while true
322322
LABEL: repeat { } while false
323+
while true { }
324+
LABEL: while true { }
323325
LABEL: do {}
324326
LABEL: switch foo {
325327
case 1:

0 commit comments

Comments
 (0)