fix: ">>" not correctly handled in auto var definition

This commit is contained in:
Roy Qu 2024-04-14 09:24:39 +08:00
parent 56310e8363
commit 5d1b874bdf
2 changed files with 18 additions and 7 deletions

View File

@ -4686,7 +4686,7 @@ PEvalStatement CppParser::doEvalExpression(const QString& fileName,
} }
return result; return result;
} else } else
return doEvalPointerArithmetic( return doEvalArithmeticOperation(
fileName, fileName,
phraseExpression, phraseExpression,
pos, pos,
@ -4695,7 +4695,7 @@ PEvalStatement CppParser::doEvalExpression(const QString& fileName,
freeScoped); freeScoped);
} }
PEvalStatement CppParser::doEvalPointerArithmetic(const QString &fileName, const QStringList &phraseExpression, int &pos, const PStatement &scope, const PEvalStatement &previousResult, bool freeScoped) const PEvalStatement CppParser::doEvalArithmeticOperation(const QString &fileName, const QStringList &phraseExpression, int &pos, const PStatement &scope, const PEvalStatement &previousResult, bool freeScoped) const
{ {
if (pos>=phraseExpression.length()) if (pos>=phraseExpression.length())
return PEvalStatement(); return PEvalStatement();
@ -6594,9 +6594,18 @@ QStringList CppParser::splitExpression(const QString &expr)
for(int i=0;i<lines.length();i++) { for(int i=0;i<lines.length();i++) {
syntaxer.setLine(lines[i],i+1); syntaxer.setLine(lines[i],i+1);
while(!syntaxer.eol()) { while(!syntaxer.eol()) {
if (syntaxer.getTokenAttribute()->tokenType()!=QSynedit::TokenType::Comment QSynedit::TokenType tokenType = syntaxer.getTokenAttribute()->tokenType();
&& syntaxer.getTokenAttribute()->tokenType()!=QSynedit::TokenType::Space) QString token = syntaxer.getToken();
result.append(syntaxer.getToken()); if (tokenType == QSynedit::TokenType::Operator) {
if ( token == ">>" ) {
result.append(">");
result.append(">");
} else {
result.append(token);
}
} else if (tokenType!=QSynedit::TokenType::Comment
&& tokenType!=QSynedit::TokenType::Space)
result.append(token);
syntaxer.next(); syntaxer.next();
} }
} }

View File

@ -325,13 +325,15 @@ private:
bool freeScoped, bool freeScoped,
bool expandMacros) const; bool expandMacros) const;
PEvalStatement doEvalPointerArithmetic( /* add + / minus - */
PEvalStatement doEvalArithmeticOperation(
const QString& fileName, const QString& fileName,
const QStringList& phraseExpression, const QStringList& phraseExpression,
int &pos, int &pos,
const PStatement& scope, const PStatement& scope,
const PEvalStatement& previousResult, const PEvalStatement& previousResult,
bool freeScoped) const; bool freeScoped) const;
/* Pointer to members .* / ->* */
PEvalStatement doEvalPointerToMembers( PEvalStatement doEvalPointerToMembers(
const QString& fileName, const QString& fileName,
const QStringList& phraseExpression, const QStringList& phraseExpression,
@ -341,7 +343,7 @@ private:
bool freeScoped) const; bool freeScoped) const;
/* /*
* Dereference / Address-of / Type Cast / Prefix increment and decrement * Dereference * / Address-of & / Type Cast / Prefix increment and decrement
* */ * */
PEvalStatement doEvalTypeCast( PEvalStatement doEvalTypeCast(
const QString& fileName, const QString& fileName,