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

标签 xml regex 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>

我在线尝试了我的正则表达式,一切正常。但它不适用于 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>

最佳答案

我对 Notepad++ 使用自己的定义。它的主要区别在于支持以下函数:local SomeFunction = function() endfunction SomeObject:Func() end。它还具有一些基本的 lua TableView 兼容性。

<!-- 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>

同时添加关联

<association id="lua_function" langID="23" />

关于xml - 如何将 Lua 函数添​​加到 Notepad++ functionList.XML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19246077/

相关文章:

MySQL:从文件名导入时间戳

python - 在使用多个正则表达式分析单个字符串时,线程或多处理能否提高性能?

oop - 函数如何进入 Lua 中的表?

scripting - 开始编写Lua脚本

xml - 当我重复项目时,如何在 grxml 文件中使用语义标记?

java - Spring 验证在来自 ServletContext 资源的 XML 文档中有错误

javascript - 将文本应用于图像(不推送它)

java正则表达式匹配特定的url

python - 提取分隔符之间具有特定长度的整数

Lua 嵌套表获取元素