- 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: GLFW project template.
- fix: Inherited class/struct members are not correctly shown in the completion suggestions. - 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. - 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 Red Panda C++ Version 2.22

View File

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

View File

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

View File

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

View File

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