From f91e35192fc884b99c42e29d4b9e37bda1c21a82 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 9 Feb 2023 21:01:01 +0800 Subject: [PATCH] - fix: preprocessors is not correctly suggested. - fix: javadoc-style docstring is not correctly suggested - enhancement: Better syntax color for asm files. --- NEWS.md | 3 + RedPandaIDE/editor.cpp | 259 ++++++++++-------- RedPandaIDE/translations/RedPandaIDE_zh_CN.ts | 58 ++-- RedPandaIDE/widgets/codecompletionpopup.cpp | 126 ++++----- RedPandaIDE/widgets/codecompletionpopup.h | 4 +- libs/qsynedit/qsynedit/syntaxer/asm.cpp | 21 +- libs/qsynedit/qsynedit/syntaxer/asm.h | 3 +- 7 files changed, 260 insertions(+), 214 deletions(-) diff --git a/NEWS.md b/NEWS.md index 6b5c4a20..6a9c7837 100644 --- a/NEWS.md +++ b/NEWS.md @@ -15,6 +15,9 @@ Red Panda C++ Version 2.11 - enhancement: Support compile asm files using nasm in the project. - fix: Project parser should not parse non-c/cpp files. - enhancement: Add "assembler" tab in the project options dialog's custom compiler parameters. + - fix: preprocessors is not correctly suggested. + - fix: javadoc-style docstring is not correctly suggested + - enhancement: Better syntax color for asm files. Red Panda C++ Version 2.10 diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 7b3a73a7..a990d342 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -31,6 +31,7 @@ #include #include #include "qsynedit/syntaxer/cpp.h" +#include "qsynedit/syntaxer/asm.h" #include "syntaxermanager.h" #include "qsynedit/exporter/rtfexporter.h" #include "qsynedit/exporter/htmlexporter.h" @@ -119,7 +120,8 @@ Editor::Editor(QWidget *parent, const QString& filename, } if (mProject) { - mParser = mProject->cppParser(); + if (syntaxer->language() == QSynedit::ProgrammingLanguage::CPP) + mParser = mProject->cppParser(); } else { initParser(); } @@ -832,65 +834,84 @@ void Editor::keyPressEvent(QKeyEvent *event) if (isIdentChar(ch)) { mLastIdCharPressed++; if (pSettings->codeCompletion().enabled() - && pSettings->codeCompletion().showCompletionWhileInput() ) { - if (mParser && mParser->isIncludeLine(lineText()) - && mLastIdCharPressed==pSettings->codeCompletion().minCharRequired()) { - // is a #include line - processCommand(QSynedit::EditCommand::Char,ch,nullptr); - showHeaderCompletion(false); - handled=true; - return; - } else if (mLastIdCharPressed==pSettings->codeCompletion().minCharRequired()){ - QString lastWord = getPreviousWordAtPositionForSuggestion(caretXY()); - if (mParser && !lastWord.isEmpty()) { - if (lastWord == "using") { - processCommand(QSynedit::EditCommand::Char,ch,nullptr); - showCompletion(lastWord,false, CodeCompletionType::ComplexKeyword); - handled=true; - return; - } else if (lastWord == "namespace") { - processCommand(QSynedit::EditCommand::Char,ch,nullptr); - showCompletion(lastWord,false, CodeCompletionType::Namespaces); - handled=true; - return; - } else if (CppTypeKeywords.contains(lastWord)) { - PStatement currentScope = mParser->findScopeStatement(mFilename,caretY()); - while(currentScope && currentScope->kind==StatementKind::skBlock) { - currentScope = currentScope->parentScope.lock(); - } - if (!currentScope || currentScope->kind == StatementKind::skNamespace - || currentScope->kind == StatementKind::skClass) { - //may define a function - processCommand(QSynedit::EditCommand::Char,ch,nullptr); - showCompletion(lastWord,false,CodeCompletionType::FunctionWithoutDefinition); - handled=true; - return; - } - if (lastWord == "long" || - lastWord == "short" || - lastWord == "signed" || - lastWord == "unsigned" - ) { + && pSettings->codeCompletion().showCompletionWhileInput() + && mLastIdCharPressed==pSettings->codeCompletion().minCharRequired()) { + if (mParser) { + if (mParser->isIncludeLine(lineText())) { + // is a #include line + processCommand(QSynedit::EditCommand::Char,ch,nullptr); + showHeaderCompletion(false); + handled=true; + return; + } else { + QString lastWord = getPreviousWordAtPositionForSuggestion(caretXY()); + if (mParser && !lastWord.isEmpty()) { + if (lastWord == "using") { processCommand(QSynedit::EditCommand::Char,ch,nullptr); showCompletion(lastWord,false, CodeCompletionType::ComplexKeyword); handled=true; return; + } else if (lastWord == "namespace") { + processCommand(QSynedit::EditCommand::Char,ch,nullptr); + showCompletion(lastWord,false, CodeCompletionType::Namespaces); + handled=true; + return; + } else if (CppTypeKeywords.contains(lastWord)) { + PStatement currentScope = mParser->findScopeStatement(mFilename,caretY()); + while(currentScope && currentScope->kind==StatementKind::skBlock) { + currentScope = currentScope->parentScope.lock(); + } + if (!currentScope || currentScope->kind == StatementKind::skNamespace + || currentScope->kind == StatementKind::skClass) { + //may define a function + processCommand(QSynedit::EditCommand::Char,ch,nullptr); + showCompletion(lastWord,false,CodeCompletionType::FunctionWithoutDefinition); + handled=true; + return; + } + if (lastWord == "long" || + lastWord == "short" || + lastWord == "signed" || + lastWord == "unsigned" + ) { + processCommand(QSynedit::EditCommand::Char,ch,nullptr); + showCompletion(lastWord,false, CodeCompletionType::ComplexKeyword); + handled=true; + return; + } + + + //last word is a type keyword, this is a var or param define, and dont show suggestion + return; } + PStatement statement = mParser->findStatementOf( + mFilename, + lastWord, + caretY()); + StatementKind kind = getKindOfStatement(statement); + if (kind == StatementKind::skClass + || kind == StatementKind::skEnumClassType + || kind == StatementKind::skEnumType + || kind == StatementKind::skTypedef) { + PStatement currentScope = mParser->findScopeStatement(mFilename,caretY()); + while(currentScope && currentScope->kind==StatementKind::skBlock) { + currentScope = currentScope->parentScope.lock(); + } + if (!currentScope || currentScope->kind == StatementKind::skNamespace) { + //may define a function + processCommand(QSynedit::EditCommand::Char,ch,nullptr); + showCompletion("",false,CodeCompletionType::FunctionWithoutDefinition); + handled=true; + return; + } - //last word is a type keyword, this is a var or param define, and dont show suggestion - return; + //last word is a typedef/class/struct, this is a var or param define, and dont show suggestion + return; + } } - PStatement statement = mParser->findStatementOf( - mFilename, - lastWord, - caretY()); - StatementKind kind = getKindOfStatement(statement); - if (kind == StatementKind::skClass - || kind == StatementKind::skEnumClassType - || kind == StatementKind::skEnumType - || kind == StatementKind::skTypedef) { - + lastWord = getPreviousWordAtPositionForCompleteFunctionDefinition(caretXY()); + if (mParser && !lastWord.isEmpty()) { PStatement currentScope = mParser->findScopeStatement(mFilename,caretY()); while(currentScope && currentScope->kind==StatementKind::skBlock) { currentScope = currentScope->parentScope.lock(); @@ -902,53 +923,38 @@ void Editor::keyPressEvent(QKeyEvent *event) handled=true; return; } - - //last word is a typedef/class/struct, this is a var or param define, and dont show suggestion - return; } + processCommand(QSynedit::EditCommand::Char,ch,nullptr); + showCompletion("",false,CodeCompletionType::Normal); + handled=true; + return; } - lastWord = getPreviousWordAtPositionForCompleteFunctionDefinition(caretXY()); - if (mParser && !lastWord.isEmpty()) { - PStatement currentScope = mParser->findScopeStatement(mFilename,caretY()); - while(currentScope && currentScope->kind==StatementKind::skBlock) { - currentScope = currentScope->parentScope.lock(); - } - if (!currentScope || currentScope->kind == StatementKind::skNamespace) { - //may define a function - processCommand(QSynedit::EditCommand::Char,ch,nullptr); - showCompletion("",false,CodeCompletionType::FunctionWithoutDefinition); - handled=true; - return; - } - } - processCommand(QSynedit::EditCommand::Char,ch,nullptr); - showCompletion("",false,CodeCompletionType::Normal); - handled=true; - return; + } else if (syntaxer()) { + //show keywords + showCompletion("",false,CodeCompletionType::KeywordsOnly); } } } else { - //preprocessor ? - if (mParser && (mLastIdCharPressed=0) && (ch=='#') && lineText().isEmpty()) { - if (pSettings->codeCompletion().enabled() - && pSettings->codeCompletion().showCompletionWhileInput() ) { - mLastIdCharPressed++; - processCommand(QSynedit::EditCommand::Char,ch,nullptr); - showCompletion("",false,CodeCompletionType::Normal); - handled=true; - return; - } - } - //javadoc directive? - if (mParser && (mLastIdCharPressed=0) && (ch=='#') && - lineText().trimmed().startsWith('*')) { - if (pSettings->codeCompletion().enabled() - && pSettings->codeCompletion().showCompletionWhileInput() ) { - mLastIdCharPressed++; - processCommand(QSynedit::EditCommand::Char,ch,nullptr); - showCompletion("",false,CodeCompletionType::Normal); - handled=true; - return; + if (pSettings->codeCompletion().enabled() + && pSettings->codeCompletion().showCompletionWhileInput() ) { + if (mParser) { + //preprocessor ? + if ((mLastIdCharPressed==0) && (ch=='#') && lineText().isEmpty()) { + mLastIdCharPressed++; + processCommand(QSynedit::EditCommand::Char,ch,nullptr); + showCompletion("",false,CodeCompletionType::Normal); + handled=true; + return; + } + //javadoc directive? + if ((mLastIdCharPressed==0) && (ch=='@') && + lineText().trimmed().startsWith('*')) { + mLastIdCharPressed++; + processCommand(QSynedit::EditCommand::Char,ch,nullptr); + showCompletion("",false,CodeCompletionType::Normal); + handled=true; + return; + } } } mLastIdCharPressed = 0; @@ -3183,11 +3189,16 @@ void Editor::showCompletion(const QString& preWord,bool autoComplete, CodeComple } if (!pSettings->codeCompletion().enabled()) return; - if (!mParser || !mParser->enabled()) - return; + if (type==CodeCompletionType::KeywordsOnly) { + if (!syntaxer()) + return; + } else { + if (!mParser || !mParser->enabled()) + return; - if (!syntaxer()) - return; + if (!syntaxer()) + return; + } if (mCompletionPopup->isVisible()) // already in search, don't do it again return; @@ -3229,12 +3240,16 @@ void Editor::showCompletion(const QString& preWord,bool autoComplete, CodeComple mCompletionPopup->setRecordUsage(pSettings->codeCompletion().recordUsage()); mCompletionPopup->setSortByScope(pSettings->codeCompletion().sortByScope()); mCompletionPopup->setShowKeywords(pSettings->codeCompletion().showKeywords()); - mCompletionPopup->setShowCodeSnippets(pSettings->codeCompletion().showCodeIns()); + if (type!=CodeCompletionType::Normal) + mCompletionPopup->setShowCodeSnippets(false); + else { + mCompletionPopup->setShowCodeSnippets(pSettings->codeCompletion().showCodeIns()); + if (pSettings->codeCompletion().showCodeIns()) { + mCompletionPopup->setCodeSnippets(pMainWindow->codeSnippetManager()->snippets()); + } + } mCompletionPopup->setHideSymbolsStartWithUnderline(pSettings->codeCompletion().hideSymbolsStartsWithUnderLine()); mCompletionPopup->setHideSymbolsStartWithTwoUnderline(pSettings->codeCompletion().hideSymbolsStartsWithTwoUnderLine()); - if (pSettings->codeCompletion().showCodeIns()) { - mCompletionPopup->setCodeSnippets(pMainWindow->codeSnippetManager()->snippets()); - } mCompletionPopup->setIgnoreCase(pSettings->codeCompletion().ignoreCase()); mCompletionPopup->resize(pSettings->codeCompletion().width(), pSettings->codeCompletion().height()); @@ -3249,18 +3264,30 @@ void Editor::showCompletion(const QString& preWord,bool autoComplete, CodeComple return onCompletionKeyPressed(event); }); mCompletionPopup->setParser(mParser); + if (mParser) { + mCompletionPopup->setCurrentScope( + mParser->findScopeStatement(mFilename, caretY()) + ); + } pMainWindow->functionTip()->hide(); mCompletionPopup->show(); // Scan the current function body - mCompletionPopup->setCurrentScope( - mParser->findScopeStatement(mFilename, caretY()) - ); QSet keywords; if (syntaxer()) { if (syntaxer()->language() != QSynedit::ProgrammingLanguage::CPP ) { - keywords = syntaxer()->keywords(); + if (syntaxer()->language()==QSynedit::ProgrammingLanguage::Assembly) { + keywords = QSynedit::ASMSyntaxer::Directives; + foreach(const QString& keyword, QSynedit::ASMSyntaxer::Registers) { + keywords.insert(keyword); + } + foreach(const QString& keyword, QSynedit::ASMSyntaxer::Instructions) { + keywords.insert(keyword); + } + } else { + keywords = syntaxer()->keywords(); + } } else { if (mUseCppSyntax) { foreach (const QString& keyword, CppKeywords.keys()) { @@ -4289,15 +4316,17 @@ void Editor::setProject(Project *pProject) return; mProject = pProject; if (mProject) { - mParser = mProject->cppParser(); - if (isVisible()) { - if (mParser && mParser->parsing()) { - connect(mParser.get(), - &CppParser::onEndParsing, - this, - &QSynedit::QSynEdit::invalidate); - } else { - invalidate(); + if (syntaxer()->language() == QSynedit::ProgrammingLanguage::CPP) { + mParser = mProject->cppParser(); + if (isVisible()) { + if (mParser && mParser->parsing()) { + connect(mParser.get(), + &CppParser::onEndParsing, + this, + &QSynedit::QSynEdit::invalidate); + } else { + invalidate(); + } } } } else { diff --git a/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts b/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts index 0117bf3d..ef3386c6 100644 --- a/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts @@ -849,7 +849,7 @@ p, li { white-space: pre-wrap; } Assembler - 汇编 + 汇编器(NASM) @@ -1084,7 +1084,7 @@ Are you really want to continue? Locate nasm - + 定位nasm程序 @@ -1111,12 +1111,12 @@ Are you really want to continue? Searching... - 正在查找... + 正在查找... Abort - 中止 + 中止 @@ -1402,13 +1402,13 @@ Are you really want to continue? 失败 - - - - - - - + + + + + + + Error 错误 @@ -1417,8 +1417,8 @@ Are you really want to continue? 无法写入文件"%1" - - + + Error Load File 载入文件错误 @@ -1447,44 +1447,44 @@ Are you really want to continue? 继续保存? - + Save As 另存为 - + File %1 already openned! 文件%1已经被打开! - + The text to be copied exceeds count limit! 要复制的内容超过了行数限制! - + The text to be copied exceeds character limit! 要复制的内容超过了字符数限制! - + The text to be cut exceeds count limit! 要剪切的内容超过了行数限制! - + The text to be cut exceeds character limit! 要剪切的内容超过了字符数限制! - + Print Document 打印文档 - - - + + + Ctrl+click for more info Ctrl+单击以获取更多信息 @@ -1493,27 +1493,27 @@ Are you really want to continue? 未找到符号'%1'! - + astyle not found 找不到astyle程序 - + Can't find astyle in "%1". 找不到astyle程序"%1". - + Break point condition 断点条件 - + Enter the condition of the breakpoint: 输入当前断点的生效条件: - + Readonly 只读 @@ -7346,7 +7346,7 @@ Are you really want to continue? Assembler - 汇编 + 汇编器 diff --git a/RedPandaIDE/widgets/codecompletionpopup.cpp b/RedPandaIDE/widgets/codecompletionpopup.cpp index 70962f40..05272d0b 100644 --- a/RedPandaIDE/widgets/codecompletionpopup.cpp +++ b/RedPandaIDE/widgets/codecompletionpopup.cpp @@ -104,6 +104,10 @@ void CodeCompletionPopup::prepareSearch( mIncludedFiles = mParser->getFileIncludes(filename); getCompletionListForNamespaces(preWord,filename,line); break; + case CodeCompletionType::KeywordsOnly: + mIncludedFiles.clear(); + getKeywordCompletionFor(customKeywords); + break; default: mIncludedFiles = mParser->getFileIncludes(filename); getCompletionFor(ownerExpression,memberOperator,memberExpression, filename,line, customKeywords); @@ -419,21 +423,12 @@ void CodeCompletionPopup::filterList(const QString &member) { QMutexLocker locker(&mMutex); mCompletionStatementList.clear(); - if (!mParser) - return; - if (!mParser->enabled()) - return; +// if (!mParser) +// return; +// if (!mParser->enabled()) +// return; //we don't need to freeze here since we use smart pointers // and data have been retrieved from the parser -// if (!mParser->freeze()) -// return; -// { -// auto action = finally([this]{ -// mParser->unFreeze(); -// }); -// if (mParserSerialId!=mParser->serialId()) { -// return; -// } mCompletionStatementList.clear(); mCompletionStatementList.reserve(mFullCompletionStatementList.size()); @@ -539,6 +534,16 @@ void CodeCompletionPopup::filterList(const QString &member) // } } +void CodeCompletionPopup::getKeywordCompletionFor(const QSet &customKeywords) +{ + //add keywords + if (!customKeywords.isEmpty()) { + foreach (const QString& keyword,customKeywords) { + addKeyword(keyword); + } + } +} + void CodeCompletionPopup::getCompletionFor( QStringList ownerExpression, const QString& memberOperator, @@ -547,18 +552,58 @@ void CodeCompletionPopup::getCompletionFor( int line, const QSet& customKeywords) { - if(!mParser) { + + if (memberOperator.isEmpty() && ownerExpression.isEmpty() && memberExpression.isEmpty()) + return; + + if (memberOperator.isEmpty()) { + //C++ preprocessor directives + if (mMemberPhrase.startsWith('#')) { + if (mShowKeywords) { + foreach (const QString& keyword, CppDirectives) { + addKeyword(keyword); + } + } + return; + } + + //docstring tags (javadoc style) + if (mMemberPhrase.startsWith('@')) { + if (mShowKeywords) { + foreach (const QString& keyword,JavadocTags) { + addKeyword(keyword); + } + } + return; + } + + //the identifier to be completed is not a member of variable/class + if (mShowCodeSnippets) { + //add custom code templates + foreach (const PCodeSnippet& codeIn,mCodeSnippets) { + if (!codeIn->code.isEmpty()) { + PStatement statement = std::make_shared(); + statement->command = codeIn->prefix; + statement->value = codeIn->code; + statement->kind = StatementKind::skUserCodeSnippet; + statement->fullName = codeIn->prefix; + statement->usageCount = 0; + mFullCompletionStatementList.append(statement); + } + } + } + if (mShowKeywords) { //add keywords + if (!customKeywords.isEmpty()) { foreach (const QString& keyword,customKeywords) { addKeyword(keyword); } + } } - return; } - if (!mParser->enabled()) - return; - if (memberOperator.isEmpty() && ownerExpression.isEmpty() && memberExpression.isEmpty()) + + if (!mParser || !mParser->enabled()) return; if (!mParser->freeze()) @@ -569,51 +614,6 @@ void CodeCompletionPopup::getCompletionFor( }); if (memberOperator.isEmpty()) { - //C++ preprocessor directives - if (mMemberPhrase.startsWith('#')) { - if (mShowKeywords) { - foreach (const QString& keyword, CppDirectives) { - addKeyword(keyword); - } - } - return; - } - - //docstring tags (javadoc style) - if (mMemberPhrase.startsWith('@')) { - if (mShowKeywords) { - foreach (const QString& keyword,JavadocTags) { - addKeyword(keyword); - } - } - return; - } - - //the identifier to be completed is not a member of variable/class - if (mShowCodeSnippets) { - //add custom code templates - foreach (const PCodeSnippet& codeIn,mCodeSnippets) { - if (!codeIn->code.isEmpty()) { - PStatement statement = std::make_shared(); - statement->command = codeIn->prefix; - statement->value = codeIn->code; - statement->kind = StatementKind::skUserCodeSnippet; - statement->fullName = codeIn->prefix; - statement->usageCount = 0; - mFullCompletionStatementList.append(statement); - } - } - } - - if (mShowKeywords) { - //add keywords - if (!customKeywords.isEmpty()) { - foreach (const QString& keyword,customKeywords) { - addKeyword(keyword); - } - } - } - PStatement scopeStatement = mCurrentScope; // repeat until reach global while (scopeStatement) { diff --git a/RedPandaIDE/widgets/codecompletionpopup.h b/RedPandaIDE/widgets/codecompletionpopup.h index d5f480db..ac942f43 100644 --- a/RedPandaIDE/widgets/codecompletionpopup.h +++ b/RedPandaIDE/widgets/codecompletionpopup.h @@ -41,7 +41,8 @@ enum class CodeCompletionType { Normal, ComplexKeyword, FunctionWithoutDefinition, - Namespaces + Namespaces, + KeywordsOnly }; class CodeCompletionListItemDelegate: public QStyledItemDelegate { @@ -133,6 +134,7 @@ private: int line); void addStatement(const PStatement& statement, const QString& fileName, int line); void filterList(const QString& member); + void getKeywordCompletionFor(const QSet& customKeywords); void getCompletionFor( QStringList ownerExpression, const QString& memberOperator, diff --git a/libs/qsynedit/qsynedit/syntaxer/asm.cpp b/libs/qsynedit/qsynedit/syntaxer/asm.cpp index f8bb84a0..a3a41011 100644 --- a/libs/qsynedit/qsynedit/syntaxer/asm.cpp +++ b/libs/qsynedit/qsynedit/syntaxer/asm.cpp @@ -37,7 +37,7 @@ const QSet ASMSyntaxer::Registers { "r15h","r15l","r15w","r15d" }; -const QSet ASMSyntaxer::Keywords { +const QSet ASMSyntaxer::Instructions { "movb","movw","movl","movq", "leab","leaw","leal","leaq", "incb","incw","incl","incq", @@ -76,7 +76,7 @@ const QSet ASMSyntaxer::Keywords { "ja","jae","jb","jbe","jc","jcxz","je","jecxz","jg","jge","jl","jle","jmp","jna","jnae","jnb","jnbe","jnc", "jne","jng","jnge","jnl","jnle","jno","jnp","jns","jnz","jo","jp","jpe","jpo","js","jz","lahf","lar","lds", "lea","leave","les","lfs","lgdt","lgs","lidt","lldt","lmsw","lock","lods","lodsb","lodsd","lodsw", - "loop","loope","loopne","loopnz","loopz","lsl","lss","ltr","mov","movd","movq"," movs","movsb", + "loop","loope","loopne","loopnz","loopz","lsl","lss","ltr","mov","movd","movq","movs","movsb", "movsd","movsw","movsx","movzx","mul","neg","nop","not","or","out","outs","outsb","outsd","outsw", "packssdw","packsswb","packuswb","paddb","paddd","paddsb","paddsw","paddusb","paddusw", "paddw","pand","pandn","pavgusb","pcmpeqb","pcmpeqd","pcmpeqw","pcmpgtb","pcmpgtd","pcmpgtw", @@ -91,7 +91,13 @@ const QSet ASMSyntaxer::Keywords { "setna","setnae","setnb","setnbe","setnc","setne","setng","setnge","setnl","setnle","setno", "setnp","setns","setnz","seto","setp","setpo","sets","setz","sgdt","shl","shld","shr","shrd","sidt", "sldt","smsw","stc","std","sti","stos","stosb","stosd","stosw","str","sub","test","verr","verw", - "wait","wbinvd","xadd","xchg","xlat","xlatb","xor" + "wait","wbinvd","xadd","xchg","xlat","xlatb","xor", +}; + +const QSet ASMSyntaxer::Directives { + "section","global","extern","segment", + "db","dw","dd","dq","dt","do","dy","dz", + "resb","resw","resd","resq","rest","reso","resy","resz", }; @@ -160,10 +166,12 @@ void ASMSyntaxer::IdentProc(IdentPrefix prefix) mTokenID = TokenId::Directive; break; default: - if (Keywords.contains(s)) + if (Instructions.contains(s)) mTokenID = TokenId::Instruction; else if (Registers.contains(s)) mTokenID = TokenId::Register; + else if (Directives.contains(s)) + mTokenID = TokenId::Directive; else if (mLine[mRun]==':') mTokenID = TokenId::Label; else @@ -460,7 +468,10 @@ void ASMSyntaxer::resetState() QSet ASMSyntaxer::keywords() const { - return Keywords; + QSet result=Instructions; + result.unite(Directives); + result.unite(Registers); + return result; } const PTokenAttribute &ASMSyntaxer::directiveAttribute() const diff --git a/libs/qsynedit/qsynedit/syntaxer/asm.h b/libs/qsynedit/qsynedit/syntaxer/asm.h index 88d4c592..787e242c 100644 --- a/libs/qsynedit/qsynedit/syntaxer/asm.h +++ b/libs/qsynedit/qsynedit/syntaxer/asm.h @@ -53,8 +53,9 @@ public: const PTokenAttribute &labelAttribute() const; const PTokenAttribute ®isterAttribute() const; - static const QSet Keywords; + static const QSet Instructions; static const QSet Registers; + static const QSet Directives; private: QChar* mLine; QString mLineString;