diff --git a/utils/LexicalAnalysis.cpp b/utils/LexicalAnalysis.cpp index ba60cb3..c7b0b67 100644 --- a/utils/LexicalAnalysis.cpp +++ b/utils/LexicalAnalysis.cpp @@ -23,7 +23,7 @@ else j=b-a;\n\ lexicalAnalysis.printProcessedText(); MyVector tokens = lexicalAnalysis.tokenize(); std::cout << "Tokenized text: " << std::endl; - for (int i = 0; i < tokens.size(); i++) { + for (size_t i = 0; i < tokens.size(); i++) { if(tokens[i].type == CodeTokenType::TOKEN_TYPE_IDENTIFIER) { std::cout << std::fixed << std::setw(25) << std::setfill(' ') << std::right << "Identifier: "; } else if(tokens[i].type == CodeTokenType::TOKEN_TYPE_NUMBER) { @@ -45,7 +45,7 @@ else j=b-a;\n\ } std::cout << " " << tokens[i].value << std::endl; } - for (int i = 0; i < tokens.size(); i++) { + for (size_t i = 0; i < tokens.size(); i++) { std::cout << tokens[i].value; } diff --git a/utils/LexicalAnalysis.h b/utils/LexicalAnalysis.h index d1cf706..f26da0c 100644 --- a/utils/LexicalAnalysis.h +++ b/utils/LexicalAnalysis.h @@ -98,7 +98,7 @@ private: int syn = -1; int searchReserveWord(std::string word) { - for(int i = 0; i < reserveWord.size(); i++) { + for(size_t i = 0; i < reserveWord.size(); i++) { if (word == reserveWord[i]) { return i; } @@ -107,7 +107,7 @@ private: } bool isLetter(char c) { - if(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_') { + if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_') { return true; } return false; @@ -172,7 +172,7 @@ private: } } - void Scan(int & currentIndex) { + void Scan(size_t & currentIndex) { currentToken = ""; if(preprocessedText[currentIndex] == ' ' || preprocessedText[currentIndex] == '\n' || preprocessedText[currentIndex] == '\t') { @@ -320,7 +320,7 @@ public: MyVector tokenize() { syn = -1; - int currentIndex = 0; + size_t currentIndex = 0; tokens.clear(); while(syn != static_cast(CodeTokenType::TOKEN_TYPE_EOF) && syn != static_cast(CodeTokenType::TOKEN_TYPE_UNDEFINED)) { Scan(currentIndex);