1

C++ ハイライトのデフォルトの字句解析器はあまり具体的ではありません。

少なくとも別の色を指定できるようにしたい:

型キーワード (void、int、float など) 命令キーワード (if while do return for など) クラス関連キーワード (テンプレート クラスの仮想フレンド) 型修飾子キーワード (static const extern unsigned など)

LexerCPPソースでこれを見つけました:

const char *QsciLexerCPX::keywords(int set) const
{
    if (set == 1)
        return
            "and and_eq asm auto bitand bitor bool break case "
            "catch char class compl const const_cast continue "
            "default delete do double dynamic_cast else enum "
            "explicit export extern false float for friend goto if "
            "inline int long mutable namespace new not not_eq "
            "operator or or_eq private protected public register "
            "reinterpret_cast return short signed sizeof static "
            "static_cast struct switch template this throw true "
            "try typedef typeid typename union unsigned using "
            "virtual void volatile wchar_t while xor xor_eq";

    if (set == 3)
        return
            "a addindex addtogroup anchor arg attention author b "
            "brief bug c class code date def defgroup deprecated "
            "dontinclude e em endcode endhtmlonly endif "
            "endlatexonly endlink endverbatim enum example "
            "exception f$ f[ f] file fn hideinitializer "
            "htmlinclude htmlonly if image include ingroup "
            "internal invariant interface latexonly li line link "
            "mainpage name namespace nosubgrouping note overload "
            "p page par param post pre ref relates remarks return "
            "retval sa section see showinitializer since skip "
            "skipline struct subsection test throw todo typedef "
            "union until var verbatim verbinclude version warning "
            "weakgroup $ @ \\ & < > # { }";

私はこれを試しました-qscilexercpp.cppをコピーして新しいファイル名qscilexercxx.cppに貼り付けます-上記のコードをスイッチで適切なスイッチに置き換えます:

switch(set)
    {
    case Oper:
        //operators
        return
        "and and_eq bitand bitor "
        "catch compl const_cast "
        "delete dynamic_cast "
        "new not not_eq "
        "operator or or_eq "
        "reinterpret_cast sizeof "
        "static_cast throw "
        "try typeid typename "
        "xor xor_eq";

    case BaseType:
        // basic types
        return
        "bool char double enum float int long "
        "short struct union void wchar_t";

    case ClassRelated:
        // class/template-related
        return
        "class inline friend private protected public "
        "template this virtual";

    case Misc:
        // misc
        return
        "asm namespace typedef using";

    case Modifiers:
        // type modifiers
        return
        "auto const explicit extern mutable register "
        "signed static unsigned volatile";

    case Instruct:
        return
        "break case continue default do else "
        "for goto if return switch while";
    }

適切な列挙型を作成した後:

    Oper = 20,
    BaseType = 21,
    ClassRelated = 22,
    Misc = 23,
    Modifiers = 24,
    Instruct = 25

既存のものの終わりに。

現在、私のテキストのほとんどは黒です。返されたキーワードの enum と char 配列の間のリンクについて何かを見逃していたと確信しています...

誰かが私を何かに案内したり、助けたりできますか?

4

0 に答える 0