mirror of
https://github.com/MeowLynxSea/ceditor.git
synced 2025-07-09 10:54:37 +00:00
修复了部分位数警告
This commit is contained in:
parent
fb6216135a
commit
2de85f56d4
@ -23,7 +23,7 @@ else j=b-a;\n\
|
|||||||
lexicalAnalysis.printProcessedText();
|
lexicalAnalysis.printProcessedText();
|
||||||
MyVector<Token> tokens = lexicalAnalysis.tokenize();
|
MyVector<Token> tokens = lexicalAnalysis.tokenize();
|
||||||
std::cout << "Tokenized text: " << std::endl;
|
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) {
|
if(tokens[i].type == CodeTokenType::TOKEN_TYPE_IDENTIFIER) {
|
||||||
std::cout << std::fixed << std::setw(25) << std::setfill(' ') << std::right << "Identifier: ";
|
std::cout << std::fixed << std::setw(25) << std::setfill(' ') << std::right << "Identifier: ";
|
||||||
} else if(tokens[i].type == CodeTokenType::TOKEN_TYPE_NUMBER) {
|
} 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;
|
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;
|
std::cout << tokens[i].value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ private:
|
|||||||
int syn = -1;
|
int syn = -1;
|
||||||
|
|
||||||
int searchReserveWord(std::string word) {
|
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]) {
|
if (word == reserveWord[i]) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@ -107,7 +107,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool isLetter(char c) {
|
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 true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -172,7 +172,7 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scan(int & currentIndex) {
|
void Scan(size_t & currentIndex) {
|
||||||
currentToken = "";
|
currentToken = "";
|
||||||
|
|
||||||
if(preprocessedText[currentIndex] == ' ' || preprocessedText[currentIndex] == '\n' || preprocessedText[currentIndex] == '\t') {
|
if(preprocessedText[currentIndex] == ' ' || preprocessedText[currentIndex] == '\n' || preprocessedText[currentIndex] == '\t') {
|
||||||
@ -320,7 +320,7 @@ public:
|
|||||||
|
|
||||||
MyVector<Token> tokenize() {
|
MyVector<Token> tokenize() {
|
||||||
syn = -1;
|
syn = -1;
|
||||||
int currentIndex = 0;
|
size_t currentIndex = 0;
|
||||||
tokens.clear();
|
tokens.clear();
|
||||||
while(syn != static_cast<int>(CodeTokenType::TOKEN_TYPE_EOF) && syn != static_cast<int>(CodeTokenType::TOKEN_TYPE_UNDEFINED)) {
|
while(syn != static_cast<int>(CodeTokenType::TOKEN_TYPE_EOF) && syn != static_cast<int>(CodeTokenType::TOKEN_TYPE_UNDEFINED)) {
|
||||||
Scan(currentIndex);
|
Scan(currentIndex);
|
||||||
|
Loading…
Reference in New Issue
Block a user