修复了部分位数警告

This commit is contained in:
梦凌汐 2024-12-16 02:39:12 +08:00
parent fb6216135a
commit 2de85f56d4
2 changed files with 6 additions and 6 deletions

View File

@ -23,7 +23,7 @@ else j=b-a;\n\
lexicalAnalysis.printProcessedText();
MyVector<Token> 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;
}

View File

@ -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<Token> tokenize() {
syn = -1;
int currentIndex = 0;
size_t currentIndex = 0;
tokens.clear();
while(syn != static_cast<int>(CodeTokenType::TOKEN_TYPE_EOF) && syn != static_cast<int>(CodeTokenType::TOKEN_TYPE_UNDEFINED)) {
Scan(currentIndex);