work save

This commit is contained in:
royqh1979@gmail.com 2021-08-09 09:47:36 +08:00
parent 3c3b606cc5
commit 562f599c4f
2 changed files with 72 additions and 1 deletions

View File

@ -3,7 +3,23 @@
CppPreprocessor::CppPreprocessor(QObject *parent) : QObject(parent)
{
mOperators.append("*");
mOperators.append("/");
mOperators.append("+");
mOperators.append("-");
mOperators.append("<");
mOperators.append("<=");
mOperators.append(">");
mOperators.append(">=");
mOperators.append("==");
mOperators.append("!=");
mOperators.append("&");
mOperators.append("^");
mOperators.append("|");
mOperators.append("&&");
mOperators.append("||");
mOperators.append("and");
mOperators.append("or");
}
QString CppPreprocessor::getNextPreprocessor()
@ -302,6 +318,42 @@ bool CppPreprocessor::isIdentChar(const QChar &ch)
return false;
}
bool CppPreprocessor::isLineChar(const QChar &ch)
{
return ch=='\r' || ch == '\n';
}
bool CppPreprocessor::isSpaceChar(const QChar &ch)
{
return ch == ' ' || ch == '\t';
}
bool CppPreprocessor::isOperatorChar(const QChar &ch)
{
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)
{
return (ch>='A' && ch<='Z') || (ch>='a' && ch<='z') || ch == '_';
}
QString CppPreprocessor::lineBreak()
{
return "\n";

View File

@ -76,6 +76,23 @@ private:
* 'A'..'Z', '0'..'9', 'a'..'z', '_', '*', '&', '~'
*/
bool isIdentChar(const QChar& ch);
/*
* '\r','\n'
*/
bool isLineChar(const QChar& ch);
/*
* '\t' ' '
*/
bool isSpaceChar(const QChar& ch);
/*
* '+', '-', '*', '/', '!', '=', '<', '>', '&', '|', '^'
*/
bool isOperatorChar(const QChar& ch);
/*
* 'A'..'Z', 'a'..'z', '_'
*/
bool isMacroIdentChar(const QChar& ch);
QString lineBreak();
@ -100,6 +117,8 @@ private:
bool mParseLocal;
QSet<QString> mScannedFiles;
QSet<QString> mProcessed; // dictionary to save filename already processed
QStringList mOperators;
};
#endif // CPPPREPROCESSOR_H