bool UnwrappedLineParser::tryToParseLambda() { // FIXME: This is a dirty way to access the previous token. Find a better // solution. if (!Line->Tokens.empty() && Line->Tokens.back().Tok->isOneOf(tok::identifier, tok::kw_operator)) { nextToken(); return false; } assert(FormatTok->is(tok::l_square)); FormatToken &LSquare = *FormatTok; if (!tryToParseLambdaIntroducer()) return false; while (FormatTok->isNot(tok::l_brace)) { switch (FormatTok->Tok.getKind()) { case tok::l_brace: break; case tok::l_paren: parseParens(); break; case tok::identifier: case tok::kw_mutable: nextToken(); break; default: return true; } } LSquare.Type = TT_LambdaLSquare; parseChildBlock(); return true; }
bool UnwrappedLineParser::tryToParseLambda() { // FIXME: This is a dirty way to access the previous token. Find a better // solution. if (!Line->Tokens.empty() && (Line->Tokens.back().Tok->isOneOf(tok::identifier, tok::kw_operator) || Line->Tokens.back().Tok->closesScope() || Line->Tokens.back().Tok->isSimpleTypeSpecifier())) { nextToken(); return false; } assert(FormatTok->is(tok::l_square)); FormatToken &LSquare = *FormatTok; if (!tryToParseLambdaIntroducer()) return false; while (FormatTok->isNot(tok::l_brace)) { if (FormatTok->isSimpleTypeSpecifier()) { nextToken(); continue; } switch (FormatTok->Tok.getKind()) { case tok::l_brace: break; case tok::l_paren: parseParens(); break; case tok::less: case tok::greater: case tok::identifier: case tok::coloncolon: case tok::kw_mutable: nextToken(); break; case tok::arrow: FormatTok->Type = TT_TrailingReturnArrow; nextToken(); break; default: return true; } } LSquare.Type = TT_LambdaLSquare; parseChildBlock(); return true; }