Notepad++ Custom Function List (Basic)

Borret Source

I am trying to use Notepad++ as my new editor for PicBasic code. I want to be able to use the function list capability, but I have no experience with XML and the Notepad++ website does not explain how to create your own function list parser very well.

For example, an xml function header would look like:

      <parser id="xml_node"

The Notepad++ parser looks like this:

      <parser id="xml_node" displayName="XML Node" commentExpr="&lt;!--([^-]|-(?!-&gt;))*--&gt;">
            <!-- Only match nodes with at least one attribute -->
                mainExpr="&lt;[\w\?]+[\t ]+\w+[\t ]*=[\t ]*&quot;[^&quot;]+&quot;"
                    <nameExpr expr="[^&lt;]*"/>

In Basic I have function headers that look like this:


How do I write the parser to pickup these function headers? If that doesn't work for some reason, I could have a title comment above each function that looks like:


I do know about the Named Bookmark plugin, but it is a much slower way of navigating. If you can please write your answer in a way that will help others who see this to know how to write a parser for their own code language.

Edit: The Named Bookmark feature only works in C++,HTML,... not in a custom language file. So I can't even use that.



answered 3 years ago Bruce J Snyder #1

I am assuming that you are using the PBASIC Notepad++ User Defined Language by Bruce Snyder (me). Unfortunately, the Notepad++ (v6.6.9) Function List feature for user defined languages, and for custom file extensions, seems to be broken.

You can test this for yourself by putting 'c' code into a .bs2 (PBASIC) file and setting up the functionList.xml file to look at a renamed copy of the known, working code for the 'c' language.

The np++ docs for the Function List feature are on this Notepad++ Function List page. The association tags 'ext=' and 'userDefinedLangName=' (in the 'associationMap' section, use one or the other) are supposed to cause np++ to use your parser code (in the 'parser' section), but it doesn't work.

Here is what the functionList \ AssociationMap entry should be:

<association ext=".bs2" id="pbasic_function2"/>

Also, just in case you're not familiar with it, the parser uses Regular Expressions to specify the filters for what it is finding. That is what the cryptic-looking strings are.

PBASIC uses a tick mark for comments (from anywhere to EOL).
PBASIC functions start at the beginning of a line, first character is a letter, the rest of the name can be alphanumeric, and they end with a colon.

Here is what I came up with for the parser, but I can't test it in np++:

<parser id="pbasic_function" displayName="PBASIC Function" commentExpr="('.*)?$">
            <nameExpr expr="\w+"/>

I tested the individual regexp expressions in Python, though.

Hope that helps.

comments powered by Disqus