Skip to content

Commit cd5fdff

Browse files
committed
[Syntax] Parse "repeat-while statement" syntax node
1 parent 8830fdd commit cd5fdff

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
@@ -1625,6 +1625,7 @@ ParserResult<Stmt> Parser::parseStmtWhile(LabeledStmtInfo LabelInfo) {
16251625
/// stmt-repeat:
16261626
/// (identifier ':')? 'repeat' stmt-brace 'while' expr
16271627
ParserResult<Stmt> Parser::parseStmtRepeat(LabeledStmtInfo labelInfo) {
1628+
SyntaxContext->setCreateSyntax(SyntaxKind::RepeatWhileStmt);
16281629
SourceLoc repeatLoc = consumeToken(tok::kw_repeat);
16291630

16301631
ParserStatus status;

test/Syntax/Outputs/round_trip_parse_gen.swift.withkinds

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ func statementTests<FunctionSignature><ParameterClause>() </ParameterClause></Fu
243243
} </CodeBlock></CatchClause><CatchClause>catch <WhereClause>where <BooleanLiteralExpr>false </BooleanLiteralExpr></WhereClause><CodeBlock>{
244244
} </CodeBlock></CatchClause><CatchClause>catch <ValueBindingPattern>let <IdentifierPattern>e </IdentifierPattern></ValueBindingPattern><WhereClause>where <SequenceExpr><MemberAccessExpr><IdentifierExpr>e</IdentifierExpr>.foo </MemberAccessExpr><BinaryOperatorExpr>== </BinaryOperatorExpr><IdentifierExpr>bar </IdentifierExpr></SequenceExpr></WhereClause><CodeBlock>{
245245
} </CodeBlock></CatchClause><CatchClause>catch <CodeBlock>{
246-
}</CodeBlock></CatchClause></DoStmt><DoStmt>
246+
}</CodeBlock></CatchClause></DoStmt><RepeatWhileStmt>
247+
repeat <CodeBlock>{ } </CodeBlock>while <BooleanLiteralExpr>true</BooleanLiteralExpr></RepeatWhileStmt><RepeatWhileStmt>
248+
LABEL: repeat <CodeBlock>{ } </CodeBlock>while <BooleanLiteralExpr>false</BooleanLiteralExpr></RepeatWhileStmt><DoStmt>
247249
LABEL: do <CodeBlock>{}</CodeBlock></DoStmt>
248250
LABEL: switch <IdentifierExpr>foo </IdentifierExpr>{
249251
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
@@ -244,6 +244,8 @@ func statementTests() {
244244
} catch let e where e.foo == bar {
245245
} catch {
246246
}
247+
repeat { } while true
248+
LABEL: repeat { } while false
247249
LABEL: do {}
248250
LABEL: switch foo {
249251
case 1:

0 commit comments

Comments
 (0)