修复了不能正确处理字符、字符串中的'和"字符的问题

This commit is contained in:
梦凌汐 2024-12-19 17:58:46 +08:00
parent 273ecc77b0
commit b4e10279d2

View File

@ -206,7 +206,8 @@ private:
!maybeOperatorOrDelimiterWith2Letters(preprocessedText[currentIndex])) {
if(preprocessedText[currentIndex] == '\"') {
currentToken += preprocessedText[currentIndex++];
while(preprocessedText[currentIndex] != '\"') {
while(currentIndex < preprocessedText.length()) {
if(preprocessedText[currentIndex] == '\"' && preprocessedText[currentIndex - 1] != '\\') break;
currentToken += preprocessedText[currentIndex++];
}
currentToken += preprocessedText[currentIndex++];
@ -215,7 +216,8 @@ private:
}
if(preprocessedText[currentIndex] == '\'') {
currentToken += preprocessedText[currentIndex++];
while(preprocessedText[currentIndex] != '\'') {
while(currentIndex < preprocessedText.length()) {
if(preprocessedText[currentIndex] == '\'' && preprocessedText[currentIndex - 1] != '\\') break;
currentToken += preprocessedText[currentIndex++];
}
currentToken += preprocessedText[currentIndex++];