@@ -1276,18 +1276,6 @@ Parser::parseMatchingTokenSyntax(tok K, Diag<> ErrorDiag, SourceLoc OtherLoc,
1276
1276
return makeParserError ();
1277
1277
}
1278
1278
1279
- Optional<ParsedTokenSyntax>
1280
- Parser::parseMatchingTokenSyntax (tok K, SourceLoc &TokLoc, Diag<> ErrorDiag,
1281
- SourceLoc OtherLoc) {
1282
- TokLoc = Tok.getLoc ();
1283
- auto result = parseMatchingTokenSyntax (K, ErrorDiag, OtherLoc);
1284
- if (result.isNull ()) {
1285
- TokLoc = getLocForMissingMatchingToken ();
1286
- return None;
1287
- }
1288
- return result.get ();
1289
- }
1290
-
1291
1279
SourceLoc Parser::getLocForMissingMatchingToken () const {
1292
1280
// At present, use the same location whether it's an error or whether
1293
1281
// the matching token is missing.
@@ -1333,7 +1321,6 @@ static SyntaxKind getListElementKind(SyntaxKind ListKind) {
1333
1321
ParserStatus
1334
1322
Parser::parseListSyntax (tok RightK, SourceLoc LeftLoc,
1335
1323
Optional<ParsedTokenSyntax> &LastComma,
1336
- SourceLoc &RightLoc,
1337
1324
Optional<ParsedTokenSyntax> &Right,
1338
1325
SmallVectorImpl<ParsedSyntax>& Junk,
1339
1326
bool AllowSepAfterLast, Diag<> ErrorDiag,
@@ -1343,13 +1330,11 @@ Parser::parseListSyntax(tok RightK, SourceLoc LeftLoc,
1343
1330
};
1344
1331
1345
1332
if (Tok.is (RightK)) {
1346
- RightLoc = Tok.getLoc ();
1347
1333
Right = consumeTokenSyntax (RightK);
1348
1334
return makeParserSuccess ();
1349
1335
}
1350
1336
if (TokIsStringInterpolationEOF ()) {
1351
1337
Tok.setKind (RightK);
1352
- RightLoc = Tok.getLoc ();
1353
1338
Right = consumeTokenSyntax ();
1354
1339
return makeParserSuccess ();
1355
1340
}
@@ -1372,7 +1357,6 @@ Parser::parseListSyntax(tok RightK, SourceLoc LeftLoc,
1372
1357
// Just accept the ")" and build the tuple as we usually do.
1373
1358
if (TokIsStringInterpolationEOF ()) {
1374
1359
Tok.setKind (RightK);
1375
- RightLoc = Tok.getLoc ();
1376
1360
Right = consumeTokenSyntax ();
1377
1361
return Status;
1378
1362
}
@@ -1409,20 +1393,10 @@ Parser::parseListSyntax(tok RightK, SourceLoc LeftLoc,
1409
1393
Status.setIsParseError ();
1410
1394
}
1411
1395
1412
- if (Status.isError ()) {
1413
- // If we've already got errors, don't emit missing RightK diagnostics.
1414
- if (Tok.is (RightK)) {
1415
- RightLoc = Tok.getLoc ();
1416
- Right = consumeTokenSyntax (RightK);
1417
- } else {
1418
- RightLoc = getLocForMissingMatchingToken ();
1419
- }
1420
- } else {
1421
- Right = parseMatchingTokenSyntax (RightK, RightLoc, ErrorDiag, LeftLoc);
1422
- if (!Right)
1423
- Status.setIsParseError ();
1424
- }
1425
-
1396
+ auto RightResult = parseMatchingTokenSyntax (RightK, ErrorDiag, LeftLoc,
1397
+ Status.isError ());
1398
+ Status |= RightResult.getStatus ();
1399
+ Right = RightResult.getOrNull ();
1426
1400
return Status;
1427
1401
}
1428
1402
0 commit comments