enhancement: Support lambda expression without a parameter list.

This commit is contained in:
Roy Qu 2024-04-23 13:05:54 +08:00
parent f59462025f
commit 3887b9387d
1 changed files with 13 additions and 8 deletions

View File

@ -2905,14 +2905,18 @@ void CppParser::handleLambda(int index, int maxIndex)
QSet<QString> captures = parseLambdaCaptures(index);
int startLine=mTokenizer[index]->line;
int argStart=index+1;
if (mTokenizer[argStart]->text!='(')
return;
int argEnd= mTokenizer[argStart]->matchIndex;
//TODO: parse captures
int bodyStart=indexOfNextLeftBrace(argEnd+1, maxIndex);
int argEnd, bodyStart;
if (mTokenizer[argStart]->text == '(' ) {
argEnd = mTokenizer[argStart]->matchIndex;
bodyStart=indexOfNextLeftBrace(argEnd+1, maxIndex);
if (bodyStart>=maxIndex) {
return;
}
} else if (mTokenizer[argStart]->text == '{') {
argEnd = argStart;
bodyStart = argStart;
} else
return;
int bodyEnd = mTokenizer[bodyStart]->matchIndex;
if (bodyEnd>maxIndex) {
return;
@ -2931,6 +2935,7 @@ void CppParser::handleLambda(int index, int maxIndex)
StatementAccessibility::None,
StatementProperty::HasDefinition);
lambdaBlock->lambdaCaptures = captures;
if (argEnd > argStart)
scanMethodArgs(lambdaBlock,argStart);
addSoloScopeLevel(lambdaBlock,mTokenizer[bodyStart]->line);
int oldIndex = mIndex;