- fix: Keyword asm is not correctly parsed.

This commit is contained in:
Roy Qu 2023-07-05 09:01:38 +08:00
parent b65ad80235
commit 56f03a52d5
5 changed files with 25 additions and 24 deletions

View File

@ -28,6 +28,7 @@ Red Panda C++ Version 2.23
- fix: GLFW project template.
- fix: Inherited class/struct members are not correctly shown in the completion suggestions.
- enhancement: Sort symbols by their declaration pos in the Class Browser, if not sort by alpha order.
- fix: Keyword asm is not correctly parsed.
Red Panda C++ Version 2.22

View File

@ -2595,10 +2595,10 @@ void CppParser::handleKeyword(KeywordType skipType)
// Skip to {
mIndex = indexOfNextLeftBrace(mIndex);
break;
case KeywordType::MoveToRightBrace:
// Skip pass {}
mIndex = indexPassBraces(mIndex);
break;
// case KeywordType::MoveToRightBrace:
// // Skip pass {}
// mIndex = indexPassBraces(mIndex);
// break;
default:
break;
}
@ -5950,22 +5950,22 @@ int CppParser::indexPassParenthesis(int index)
return index;
}
int CppParser::indexPassBraces(int index)
{
int tokenCount = mTokenizer.tokenCount();
while (index<tokenCount) {
switch(mTokenizer[index]->text[0].unicode()) {
case '{':
return mTokenizer[index]->matchIndex+1;
case '(':
index = mTokenizer[index]->matchIndex+1;
break;
default:
index++;
}
}
return index;
}
//int CppParser::indexPassBraces(int index)
//{
// int tokenCount = mTokenizer.tokenCount();
// while (index<tokenCount) {
// switch(mTokenizer[index]->text[0].unicode()) {
// case '{':
// return mTokenizer[index]->matchIndex+1;
// case '(':
// index = mTokenizer[index]->matchIndex+1;
// break;
// default:
// index++;
// }
// }
// return index;
//}
void CppParser::skipNextSemicolon(int index)
{

View File

@ -653,7 +653,7 @@ private:
int indexOfNextColon(int index);
int indexOfNextLeftBrace(int index);
int indexPassParenthesis(int index);
int indexPassBraces(int index);
// int indexPassBraces(int index);
int skipAssignment(int index, int endIndex);
void skipNextSemicolon(int index);
int moveToEndOfStatement(int index, bool checkLambda, int endIndex=-1);

View File

@ -127,8 +127,8 @@ void initParser()
CppKeywords.insert("_Pragma",KeywordType::SkipNextParenthesis);
// Skip to }
CppKeywords.insert("asm",KeywordType::MoveToRightBrace);
CppKeywords.insert("__asm",KeywordType::MoveToRightBrace);
CppKeywords.insert("asm",KeywordType::SkipNextParenthesis);
CppKeywords.insert("__asm",KeywordType::SkipNextParenthesis);
// Skip to {
// wont handle

View File

@ -62,7 +62,7 @@ enum class KeywordType {
SkipNextColon, // move to : and skip it
SkipNextParenthesis, // move to ) and skip it
MoveToLeftBrace,// move to {
MoveToRightBrace, // move to }
// MoveToRightBrace, // move to }
For, //for
Catch, //catch
Public, // public