Does anyone have parsing rules for the Notepad++ F

2019-02-16 04:42发布

I'me using Notepad++ for editing rake files and I'd like to be able to use the function list plugin.

I've been unable to find any parsing rules on line, and the "Language Parsing Rules" dialog is not very clearly documented.

I'm parsing methods into the list with the following, but would like to also display tasks.

Function Begin:  [ \t]*def[ \t]+
Function List Name: [a-zA-Z0-9_\.]*

This isn't very clean, and won't capture functions that end with ? or !, but it is a start.

My task rule, which isn't working is:

Function Begin: [ \t]*task[ \t]+
Function List Name: :[a-zA-Z0-9_\.]*
Function End: [ \t]+do

Any suggestions most welcome.

thanks

4条回答
Bombasti
2楼-- · 2019-02-16 05:05

I'm using the following parser for the new functionList.xml. It recognizes most of classes modules and method definitions exept if multiple definitions are on the same line. E.g.

module A; module B; class C end; end; end;

In the above case it will just recognize "module A"

Everything is just presented as function including "class" "module" or "def" keyword. It is does not use the hierarchy provided by classrange.

  <parser id="rb_function" displayName="Ruby" >
    <function
        mainExpr="^[\s]*(def|class|module)[\s]+(self\.)?[\S]+;?"
        displayMode="$className->$functionName" >
      <functionName>
        <nameExpr expr="(def|class|module)[^\(;]*" />
      </functionName>
    </function>
  </parser>
查看更多
beautiful°
3楼-- · 2019-02-16 05:10

Maybe you can use the below settings which you can add in yourFunctionListRules.xml file:

<Language name="Ruby" imagelistpath="C:\Documents and Settings\king_cao\Application Data\Notepad++\plugins\config\C++.flb">
        <Group name="CLASS" subgroup="FUNCTION" icon="1" child="11" autoexp="4" matchcase="1" fendtobbeg="" bbegtobend="" keywords="">
            <Rules regexbeg="^class\s+" regexfunc="[\w_]+" regexend="" bodybegin="" bodyend="^end$" sep="" />
        </Group>
        <Group name="FUNCTION" subgroup="" icon="9" child="17" autoexp="4" matchcase="1" fendtobbeg="" bbegtobend="" keywords="">
            <Rules regexbeg="^[\s\t]+def\s+" regexfunc="[\w_]+" regexend="" bodybegin="" bodyend="^[\s\t]+end$" sep="" />
        </Group>
        <Group name="GlobalFunction" subgroup="" icon="9" child="17" autoexp="4" matchcase="1" fendtobbeg="" bbegtobend="" keywords="">
            <Rules regexbeg="^def\s+" regexfunc="[\w_]+" regexend="" bodybegin="" bodyend="^end$" sep="" />
        </Group>
        <Group name="MODULE" subgroup="FUNCTION" icon="8" child="11" autoexp="4" matchcase="1" fendtobbeg="" bbegtobend="" keywords="">
            <Rules regexbeg="^module\s+" regexfunc="[\w_]+" regexend="" bodybegin="" bodyend="^end$" sep="" />
        </Group>
</Language>
查看更多
女痞
4楼-- · 2019-02-16 05:18

Since version 6.4 there is no need for a plugin! Check out the new function list feature: http://notepad-plus-plus.org/features/function-list.html

Language support is coming, perhaps asking here would help: https://sourceforge.net/p/notepad-plus/discussion/331753/thread/b9d2fe00/

查看更多
女痞
5楼-- · 2019-02-16 05:25

Here is my rules. Still not perfect yet. Don't know how to config subgroups.

<Language name="Ruby" imagelistpath="">
    <CommList param1="#" param2="" />
    <CommList param1="//" param2="" />
    <CommList param1="/\*" param2="\*/" />
    <Group name="MODULE" subgroup="" icon="0" child="0" autoexp="0" matchcase="1" fendtobbeg="" bbegtobend="" keywords="">
        <Rules regexbeg="^[\s\t]*module\s+" regexfunc="[\w]+" regexend="" bodybegin="" bodyend="" sep="" />
    </Group>
    <Group name="CLASS" subgroup="" icon="0" child="0" autoexp="0" matchcase="1" fendtobbeg="" bbegtobend="" keywords="">
        <Rules regexbeg="^[\s\t]*class\s+" regexfunc="[\w]+" regexend="" bodybegin="" bodyend="" sep="" />
    </Group>
    <Group name="FUNCTION" subgroup="" icon="0" child="0" autoexp="0" matchcase="1" fendtobbeg="" bbegtobend="" keywords="">
        <Rules regexbeg="^[\s\t]*def\s+" regexfunc="[\w\?!\.=]+" regexend="" bodybegin="" bodyend="" sep="" />
    </Group>
</Language>
查看更多
登录 后发表回答