- fix: '^' is not correctly handled as operator.

This commit is contained in:
Roy Qu 2023-05-24 13:42:46 +08:00
parent a251173a6a
commit 19a85db1f9
5 changed files with 25 additions and 23 deletions

View File

@ -3,6 +3,7 @@ Red Panda C++ Version 2.22
- fix: Crash at startup when current problem in the problem set is connected with source file. - 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: Double-clicking on touchpad can't select current word.
- fix: foreach-loops are not correctly parsed. - fix: foreach-loops are not correctly parsed.
- fix: '^' is not correctly handled as operator.
Red Panda C++ Version 2.21 Red Panda C++ Version 2.21

View File

@ -3981,7 +3981,7 @@ void CppParser::internalParse(const QString &fileName)
if (mTokenizer.tokenCount() == 0) if (mTokenizer.tokenCount() == 0)
return; return;
#ifdef QT_DEBUG #ifdef QT_DEBUG
// mTokenizer.dumpTokens(QString("r:\\tokens-%1.txt").arg(extractFileName(fileName))); mTokenizer.dumpTokens(QString("r:\\tokens-%1.txt").arg(extractFileName(fileName)));
#endif #endif
#ifdef QT_DEBUG #ifdef QT_DEBUG
mLastIndex = -1; mLastIndex = -1;
@ -3994,8 +3994,8 @@ void CppParser::internalParse(const QString &fileName)
} }
// qDebug()<<"parse"<<timer.elapsed(); // qDebug()<<"parse"<<timer.elapsed();
#ifdef QT_DEBUG #ifdef QT_DEBUG
// mStatementList.dumpAll(QString("r:\\all-stats-%1.txt").arg(extractFileName(fileName))); mStatementList.dumpAll(QString("r:\\all-stats-%1.txt").arg(extractFileName(fileName)));
// mStatementList.dump(QString("r:\\stats-%1.txt").arg(extractFileName(fileName))); mStatementList.dump(QString("r:\\stats-%1.txt").arg(extractFileName(fileName)));
#endif #endif
//reduce memory usage //reduce memory usage
internalClear(); internalClear();

View File

@ -1122,26 +1122,26 @@ bool CppPreprocessor::isSpaceChar(const QChar &ch)
return ch == ' ' || ch == '\t'; return ch == ' ' || ch == '\t';
} }
bool CppPreprocessor::isOperatorChar(const QChar &ch) //bool CppPreprocessor::isOperatorChar(const QChar &ch)
{ //{
switch(ch.unicode()) { // switch(ch.unicode()) {
case '+': // case '+':
case '-': // case '-':
case '*': // case '*':
case '/': // case '/':
case '!': // case '!':
case '=': // case '=':
case '<': // case '<':
case '>': // case '>':
case '&': // case '&':
case '|': // case '|':
case '^': // case '^':
return true; // return true;
default: // default:
return false; // return false;
} // }
} //}
bool CppPreprocessor::isMacroIdentChar(const QChar &ch) bool CppPreprocessor::isMacroIdentChar(const QChar &ch)
{ {

View File

@ -176,7 +176,7 @@ static bool isSpaceChar(const QChar& ch);
/* /*
* '+', '-', '*', '/', '!', '=', '<', '>', '&', '|', '^' * '+', '-', '*', '/', '!', '=', '<', '>', '&', '|', '^'
*/ */
static bool isOperatorChar(const QChar& ch); //static bool isOperatorChar(const QChar& ch);
/* /*
* 'A'..'Z', 'a'..'z', '_' * 'A'..'Z', 'a'..'z', '_'

View File

@ -373,6 +373,7 @@ QString CppTokenizer::getNextToken(TokenType *pTokenType)
case '|': case '|':
case '+': case '+':
case '~': case '~':
case '^':
if (*(mCurrent + 1) == '=') { if (*(mCurrent + 1) == '=') {
countLines(); countLines();
result = *mCurrent; result = *mCurrent;