From 7abbe2f6b520d8055e5b503c05c8b0fc2c7f9ee1 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 10 Apr 2024 10:09:04 +0800 Subject: [PATCH] inline functions in tokenizer --- RedPandaIDE/parser/cpptokenizer.cpp | 28 ------------------------ RedPandaIDE/parser/cpptokenizer.h | 33 +++++++++-------------------- 2 files changed, 10 insertions(+), 51 deletions(-) diff --git a/RedPandaIDE/parser/cpptokenizer.cpp b/RedPandaIDE/parser/cpptokenizer.cpp index c732ae11..4d9581d7 100644 --- a/RedPandaIDE/parser/cpptokenizer.cpp +++ b/RedPandaIDE/parser/cpptokenizer.cpp @@ -526,34 +526,6 @@ QString CppTokenizer::getWord() return result; } -bool CppTokenizer::isArguments() -{ - return *mCurrent == '('; -} - -//bool CppTokenizer::isForInit() -//{ -// return (*mCurrent == '(') && (mLastToken == "for"); -//} - -bool CppTokenizer::isNumber() -{ - return isDigitChar(*mCurrent); -} - -bool CppTokenizer::isPreprocessor() -{ - return *mCurrent=='#'; -} - -bool CppTokenizer::isWord() -{ - bool result = isIdentChar(*mCurrent); - if (result && (*(mCurrent+1) == '"')) - result = false; - return result; -} - void CppTokenizer::simplify(QString &output) { //remove \n \r; diff --git a/RedPandaIDE/parser/cpptokenizer.h b/RedPandaIDE/parser/cpptokenizer.h index 08f0482b..ced976a9 100644 --- a/RedPandaIDE/parser/cpptokenizer.h +++ b/RedPandaIDE/parser/cpptokenizer.h @@ -49,31 +49,18 @@ public: void clear(); void tokenize(const QStringList& buffer); void dumpTokens(const QString& fileName); - const PToken& operator[](int i) const { - return mTokenList[i]; - } - int tokenCount() const { - return mTokenList.count(); - } - static bool isIdentChar(const QChar& ch) { - return ch=='_' || ch.isLetter() ; - } - int lambdasCount() const { - return mLambdas.count(); - } + const PToken& operator[](int i) const { return mTokenList[i]; } + int tokenCount() const { return mTokenList.count(); } + static bool isIdentChar(const QChar& ch) { return ch=='_' || ch.isLetter(); } + int lambdasCount() const { return mLambdas.count(); } - int indexOfFirstLambda() const { - return mLambdas.front(); - } - void removeFirstLambda() { - mLambdas.pop_front(); - } + int indexOfFirstLambda() const { return mLambdas.front(); } + void removeFirstLambda() { mLambdas.pop_front(); } private: void addToken(const QString& sText, int iLine, TokenType tokenType); void advance(); void countLines(); - PToken getToken(int index); // QString getForInit(); QString getNextToken( @@ -81,11 +68,11 @@ private: QString getNumber(); QString getPreprocessor(); QString getWord(); - bool isArguments(); + bool isArguments() { return *mCurrent == '('; } // bool isForInit(); - bool isNumber(); - bool isPreprocessor(); - bool isWord(); + bool isNumber() { return isDigitChar(*mCurrent); } + bool isPreprocessor() { return *mCurrent=='#'; } + bool isWord() { return isIdentChar(*mCurrent) && (*(mCurrent+1) != '"') && (*(mCurrent+1) != '\''); } void simplify(QString& output); void simplifyArgs(QString& output); // void skipAssignment();