Skip to content

Commit

Permalink
- enhancement: improve parse result for STL <random>
Browse files Browse the repository at this point in the history
  • Loading branch information
royqh1979 committed Nov 12, 2022
1 parent edfd091 commit 6a6dc12
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
5 changes: 3 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ Red Panda C++ Version 2.4
- fix: &operator= functions are not correctly parsed;
- fix: Code Formatter's "add indent to continueous lines" option is not correctly saved.
- fix: _Pragma is not correctly handled;
- enhancement: improve parse result for STL <random>
- change: the default value for UI font size : 11
- change: the default value for add leading zeros to line numbers : false


- upgrade integrated libturtle. fix: nothing is drawed when set background color to BLACK
- upgrade integrate fmtlib. fix: imcompatible with GBK encoding

Red Panda C++ Version 2.3

Expand Down
6 changes: 3 additions & 3 deletions RedPandaIDE/parser/cppparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ void CppParser::addSoloScopeLevel(PStatement& statement, int line, bool shouldRe
mClassScope = StatementClassScope::Public; // structs are public by default
mCurrentClassScope.append(mClassScope);
#ifdef QT_DEBUG
//if (mCurrentClassScope.count()==1)
// if (mCurrentClassScope.count()==1)
// qDebug()<<"++add scope"<<mCurrentFile<<line<<mCurrentClassScope.count();
#endif
}
Expand All @@ -1468,7 +1468,7 @@ void CppParser::removeScopeLevel(int line)
if (mCurrentScope.isEmpty())
return; // TODO: should be an exception
#ifdef QT_DEBUG
//if (mCurrentClassScope.count()==1)
// if (mCurrentClassScope.count()==1)
// qDebug()<<"--remove scope"<<mCurrentFile<<line<<mCurrentClassScope.count();
#endif
PStatement currentScope = getCurrentScope();
Expand Down Expand Up @@ -3618,7 +3618,7 @@ void CppParser::handleVar(const QString& typePrefix,bool isExtern,bool isStatic)
break;
} else if (isWordChar(mTokenizer[mIndex]->text[0])) {
QString cmd=mTokenizer[mIndex]->text;
if (mTokenizer[mIndex+1]->text=='('
if (mIndex+1< mTokenizer.tokenCount() && mTokenizer[mIndex+1]->text=='('
&& mTokenizer[mIndex+1]->matchIndex+1<mTokenizer.tokenCount()
&& mTokenizer[mTokenizer[mIndex+1]->matchIndex+1]->text=='(') {
//function pointer
Expand Down
24 changes: 22 additions & 2 deletions RedPandaIDE/parser/cpptokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ QString CppTokenizer::getForInit()
QString CppTokenizer::getNextToken(TokenType *pTokenType, bool bSkipArray, bool bSkipBlock)
{
QString result;
int backupIndex;
bool done = false;
*pTokenType=TokenType::Normal;
while (true) {
Expand Down Expand Up @@ -759,7 +758,28 @@ void CppTokenizer::skipTemplateArgs()
if (*mCurrent != '<')
return;

skipPair('<', '>');
if (skipAngleBracketPair())
return;
QChar* lastBracketPos = mCurrent;
bool shouldExit=false;
while (true) {
switch(mCurrent->unicode()) {
case '\0':
case ';':
case '}':
case '{':
shouldExit=true;
break;
case '>':
lastBracketPos = mCurrent;
break;
}
if (shouldExit)
break;
mCurrent++;
}
if (*lastBracketPos=='>')
mCurrent = lastBracketPos+1; //skip '>';
}

void CppTokenizer::skipToEOL()
Expand Down
1 change: 1 addition & 0 deletions RedPandaIDE/parser/cpptokenizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class CppTokenizer
void skipAssignment();
void skipDoubleQuotes();
void skipPair(const QChar& cStart, const QChar cEnd);
void skipParenthesis();
bool skipAngleBracketPair();
void skipRawString();
void skipSingleQuote();
Expand Down

0 comments on commit 6a6dc12

Please sign in to comment.