如何将Lua函数添加到Notepad ++ functionList.XML

Pig*_*let 7 regex xml lua notepad++

Notepad ++提供了一个功能列表.

我目前正在使用Notepad ++ 6.5

functionList.xml使用正则表达式定义函数名称的解析器.

以下代码定义了c函数的解析器

<parser id="c_function" displayName="C source" commentExpr="((/\*.*?\*)/|(//.*?$))">
    <function
        mainExpr="^[\t ]*((static|const|virtual)[\s]+)?[\w:]+([\s]+[\w]+)?([\s]+|\*[\s]+|[\s]+\*|[\s]+\*[\s]+)([\w_]+[\s]*::)?(?!(if|while|for))[\w_]+[\s]*\([^\)\(]*\)([\s]*const[\s]*)?[\n\s]*\{"
        displayMode="$functionName">
            <functionName>
                <nameExpr expr="(?!(if|while|for))[\w_~]+[\s]*\("/>
                <nameExpr expr="(?!(if|while|for))[\w_~]+"/>
                </functionName>         </function>
</parser>
Run Code Online (Sandbox Code Playgroud)

我在网上尝试了我的正则表达式,一切都很好.但它不能以某种方式对functionList.xml起作用.功能列表保持为空.

这对于Lua函数看起来如何?

这是我的尝试:

<parser id="lua_function" displayName="Lua Function" commentExpr="((--\[\[\*.*?\*)/|(--.*[\n\s\w\t]*\]\]))">
            <function
                mainExpr="^[\t\s]*(function)[\s]+[\w]+\("
                displayMode="$functionName">
                <functionName>
                    <nameExpr expr="(?:(function[\s]+))[\w]+"/>
                </functionName>
            </function>
        </parser>
Run Code Online (Sandbox Code Playgroud)

And*_*rew 5

我将自己的定义用于Notepad ++。主要区别在于支持以下功能:local SomeFunction = function() endfunction SomeObject:Func() end。它还具有一些基本的lua表视图兼容性。

<!-- Basic lua parser for functionList.xml in Notepad++ 6.5.3 -->
<!-- See http://notepad-plus-plus.org/features/function-list.html -->
<parser id="lua_function" displayName="Lua" commentExpr="--.*?$">
    <!-- Basic lua table view, nested lua table not supported -->
    <classRange
        mainExpr="[.\w]+[\s]*=[\s]*\{"
        openSymbole="\{"
        closeSymbole="\}"
        displayMode="node">
        <className>
            <nameExpr expr="[.\w]+"/>
        </className>
        <function
            mainExpr="[.\w]+[\s]*=[\s]*['&quot;]?[\w]+['&quot;]?">
            <functionName>
                <funcNameExpr expr=".*"/>
            </functionName>
        </function>
    </classRange>
    <!-- Basic lua functions support -->
    <function 
        mainExpr="(function[\s]+[.\w]+(:[\w]+)?)|([.\w]+[\s]*=[\s]*function)"
        displayMode="$className->$functionName">
        <functionName>
            <nameExpr expr="((?<=function)[\s]+[.:\w]+)|(([.\w]+)(?=([\s]*=[\s]*function)))"/>
        </functionName>
        <className>
            <nameExpr expr="[.\w]+(?=:)"/>
        </className>
    </function>
</parser>
Run Code Online (Sandbox Code Playgroud)

同时添加关联

<association id="lua_function" langID="23" />
Run Code Online (Sandbox Code Playgroud)