From 19a85db1f92df05f6840b6b7098be92c31712621 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 24 May 2023 13:42:46 +0800 Subject: [PATCH] - fix: '^' is not correctly handled as operator. --- NEWS.md | 1 + RedPandaIDE/parser/cppparser.cpp | 6 ++-- RedPandaIDE/parser/cpppreprocessor.cpp | 38 +++++++++++++------------- RedPandaIDE/parser/cpppreprocessor.h | 2 +- RedPandaIDE/parser/cpptokenizer.cpp | 1 + 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/NEWS.md b/NEWS.md index fab8ff7f..56caea43 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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: Double-clicking on touchpad can't select current word. - fix: foreach-loops are not correctly parsed. + - fix: '^' is not correctly handled as operator. Red Panda C++ Version 2.21 diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 306b787d..4eebb2d4 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -3981,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; @@ -3994,8 +3994,8 @@ void CppParser::internalParse(const QString &fileName) } // qDebug()<<"parse"<': - case '&': - case '|': - case '^': - return true; - default: - return false; - } -} +// switch(ch.unicode()) { +// case '+': +// case '-': +// case '*': +// case '/': +// case '!': +// case '=': +// case '<': +// case '>': +// case '&': +// case '|': +// case '^': +// return true; +// default: +// return false; +// } +//} bool CppPreprocessor::isMacroIdentChar(const QChar &ch) { diff --git a/RedPandaIDE/parser/cpppreprocessor.h b/RedPandaIDE/parser/cpppreprocessor.h index 16a3ac47..5f91c619 100644 --- a/RedPandaIDE/parser/cpppreprocessor.h +++ b/RedPandaIDE/parser/cpppreprocessor.h @@ -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', '_' diff --git a/RedPandaIDE/parser/cpptokenizer.cpp b/RedPandaIDE/parser/cpptokenizer.cpp index ac66f97e..34768460 100644 --- a/RedPandaIDE/parser/cpptokenizer.cpp +++ b/RedPandaIDE/parser/cpptokenizer.cpp @@ -373,6 +373,7 @@ QString CppTokenizer::getNextToken(TokenType *pTokenType) case '|': case '+': case '~': + case '^': if (*(mCurrent + 1) == '=') { countLines(); result = *mCurrent;