- fix: Hex number with 'f' in not is not correctly colored.

This commit is contained in:
Roy Qu 2023-03-05 18:08:08 +08:00
parent f93d5cdd9e
commit 27d993e500
2 changed files with 36 additions and 9 deletions

View File

@ -6,6 +6,7 @@ Red Panda C++ Version 2.17
- enhancement: Add "address" in the memory view's mouse tip. - enhancement: Add "address" in the memory view's mouse tip.
- enhancement: Show mousetip for numbers in the GNU assembly file. - enhancement: Show mousetip for numbers in the GNU assembly file.
- enhancement: Open offline gnu as/x86 assembly manual if exists. - enhancement: Open offline gnu as/x86 assembly manual if exists.
- fix: Hex number with 'f' in not is not correctly colored.
Red Panda C++ Version 2.16 Red Panda C++ Version 2.16

View File

@ -684,14 +684,18 @@ void CppSyntaxer::numberProc()
if (mTokenId != TokenId::Number) { if (mTokenId != TokenId::Number) {
return; return;
} }
mRun++;
break; break;
case '.': case '.':
if (mTokenId != TokenId::Octal) { if (mTokenId == TokenId::Number) {
mTokenId = TokenId::Float; mTokenId = TokenId::Float;
} else if (mTokenId == TokenId::Hex) {
mTokenId = TokenId::HexFloat;
} else { } else {
mTokenId = TokenId::Unknown; mTokenId = TokenId::Unknown;
return; return;
} }
mRun++;
break; break;
case '0': case '0':
case '1': case '1':
@ -701,38 +705,60 @@ void CppSyntaxer::numberProc()
case '5': case '5':
case '6': case '6':
case '7': case '7':
mRun++;
break;
case '8': case '8':
case '9': case '9':
if (mTokenId == TokenId::Octal)
return;
else {
mRun++;
break;
}
case 'a': case 'a':
case 'b': case 'b':
case 'c': case 'c':
case 'd': case 'd':
case 'f':
case 'A': case 'A':
case 'B': case 'B':
case 'C': case 'C':
case 'D': case 'D':
case 'F':
if (mTokenId != TokenId::Hex
&& mTokenId != TokenId::HexFloat)
return;
else {
mRun++;
break;
}
mRun++;
break; break;
case 'e': case 'e':
case 'E': case 'E':
if (mTokenId==TokenId::Number) { if (mTokenId==TokenId::Number || mTokenId == TokenId::Float) {
mTokenId = TokenId::Float; mTokenId = TokenId::Float;
mRun++; mRun++;
if (mRun < mLineSize && (mLine[mRun]== '+' || mLine[mRun]== '-')) // number = float, but no exponent. an arithmetic operator if (mRun < mLineSize && (mLine[mRun]== '+' || mLine[mRun]== '-')) // number = float, but no exponent. an arithmetic operator
mRun++; mRun++;
break; } else if (mTokenId==TokenId::Octal) {
} return;
} else
mRun++;
break; break;
case 'p': case 'p':
case 'P': case 'P':
mTokenId = TokenId::Float; if (mTokenId==TokenId::Hex || mTokenId==TokenId::HexFloat) {
mRun++; mTokenId = TokenId::HexFloat;
if (mRun < mLineSize && (mLine[mRun]== '+' || mLine[mRun]== '-')) // number = float, but no exponent. an arithmetic operator
mRun++; mRun++;
break; if (mRun < mLineSize && (mLine[mRun]== '+' || mLine[mRun]== '-')) // number = float, but no exponent. an arithmetic operator
mRun++;
break;
} else
return;
default: default:
return; return;
} }
mRun+=1;
} }
} }