diff --git a/NEWS.md b/NEWS.md index b7b9822d..fab8ff7f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,7 @@ Red Panda C++ Version 2.22 - fix: Crash at startup when current problem in the problem set is connected with source file. - fix: Double-clicking on touchpad can't select current word. + - fix: foreach-loops are not correctly parsed. Red Panda C++ Version 2.21 diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 25c36318..50b710e4 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -2428,8 +2428,15 @@ void CppParser::handleForBlock() mIndex++; // skip for/catch; if (mIndex >= tokenCount) return; + if (mTokenizer[mIndex]->text!="(") + return; int i=indexOfNextSemicolon(mIndex); int i2 = i+1; //skip over ';' (tokenizer have change for(;;) to for(;) + + // for(int x:vec) + if (i2 > mTokenizer[mIndex]->matchIndex) + i2 = mTokenizer[mIndex]->matchIndex+1; + if (i2>=tokenCount) return; if (mTokenizer[i2]->text.startsWith('{')) { @@ -3955,7 +3962,7 @@ void CppParser::internalParse(const QString &fileName) QStringList preprocessResult = mPreprocessor.result(); #ifdef QT_DEBUG -// stringsToFile(mPreprocessor.result(),QString("r:\\preprocess-%1.txt").arg(extractFileName(fileName))); + stringsToFile(mPreprocessor.result(),QString("r:\\preprocess-%1.txt").arg(extractFileName(fileName))); // mPreprocessor.dumpDefinesTo("r:\\defines.txt"); // mPreprocessor.dumpIncludesListTo("r:\\includes.txt"); #endif @@ -3974,7 +3981,7 @@ void CppParser::internalParse(const QString &fileName) if (mTokenizer.tokenCount() == 0) return; #ifdef QT_DEBUG -// mTokenizer.dumpTokens(QString("r:\\tokens-%1.txt").arg(extractFileName(fileName))); + mTokenizer.dumpTokens(QString("r:\\tokens-%1.txt").arg(extractFileName(fileName))); #endif #ifdef QT_DEBUG mLastIndex = -1; @@ -3987,8 +3994,8 @@ void CppParser::internalParse(const QString &fileName) } // qDebug()<<"parse"<args=="" ) { if (define->value != word ) @@ -601,7 +601,7 @@ void CppPreprocessor::expandMacro(const QString &line, QString &newLine, QString } else { newLine += word; } - } +// } } QString CppPreprocessor::removeGCCAttributes(const QString &line)