<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Trouble making a functionList parser for MATLAB]]></title><description><![CDATA[<h4>I fail to spot the mistakes, which break my &lt;parser&gt; for MATLAB</h4>
<p dir="auto"><strong>System:</strong> Windows7,  Notepad++ v7.3.1(32-bit).</p>
<p dir="auto">After a great deal of experimenting and cutting down, these are my additions to  <code>functionList.xml</code>.  (To avoid word-wrap in the preview, I have truncated some comments.)</p>
<h4>Results so far</h4>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>m-file</th>
<th>function list</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>function_scalar_return.m</code></td>
<td>displays “[ out, val ] = function_scalar_return( val )” <em>as expected</em></td>
</tr>
<tr>
<td><code>function_multi_return.m</code></td>
<td>displays “[ out, val ] = function_multi_return( val )” <em>as expected</em></td>
</tr>
<tr>
<td><code>function_no_return_comments.m</code></td>
<td>displays “function_no_return( val )” and  <strong>“function_no_return_C2( val )”</strong></td>
</tr>
<tr>
<td><code>class_basic_no_return.m</code></td>
<td>displays only the filename, “class_basic_no_return.m”; nothing of the content</td>
</tr>
<tr>
<td><code>class_basic_handle.m</code></td>
<td>displays only the filename, “class_basic_handle.m”; nothing of the content</td>
</tr>
</tbody>
</table>
<p dir="auto">.<br />
With only the &lt;function&gt; block in the &lt;parser&gt;, functionList honors  multi-line-comments; <strong>“function_no_return_C2( val )”</strong> is <strong>not</strong> shown!</p>
<p dir="auto">I have “verified” the effect of all regular expressions with TextFX Quick Find/Replace. Is there a better way? It would be valuable to be able to dump the text-buffer to a log-file after each “operation”.</p>
<p dir="auto">I have an awkward feeling that I’m missing something basic and need help.</p>
<p dir="auto">Best regards<br />
Per</p>
<pre><code>&lt;association langID="44" id="matlab" /&gt; 

&lt;parser 
    id          = "matlab" 
    displayName = "Matlab Node" 
    commentExpr = "(?s:%\{.*?%\})|(?m-s:%.*$)"             
&gt;
    &lt;classRange
        mainExpr = "(?x)(?s-m)          # '.' matches new line; '^','$' match beginning ...
                    classdef\h+\K       # match until 'classdef' followed by space and ...
                    [A-Za-z][\w_]+      # match valid matlab name
                    .*?$                # match whatever, up to the end of the text buffer
                    "
    &gt;
        &lt;className&gt;
            &lt;nameExpr   
                expr = "(?x)(?m-s)          # '.' doesn't match new line; '^','$' match ...
                        ^[A-Za-z][\w_]+     # match valid matlab name
                        " 
            /&gt;
        &lt;/className&gt;
        &lt;function
            mainExpr = "(?x)(?s-m)      # '.' matches new line; '^','$' match beginning ...
                        methods\K       # match until first 'methods' and discard it 
                        .+$             # match whatever, until end of text buffer
                        " 
        &gt;
            &lt;functionName&gt;
                &lt;funcNameExpr   
                    expr = "(?x)(?m-s)      # '.' doesn't match new line; '^','$' match ...
                            ^\h{2,}         # match at least two leading whitespaces 
                            function        # match 'function'
                            \h+\K           # match whitespaces and discard what's ...
                            [^%;]+          # match whatever, until '%',';' or the ...
                            "
                /&gt; 
            &lt;/functionName&gt;
        &lt;/function&gt;
    &lt;/classRange&gt;
    &lt;function
        mainExpr = "(?x)(?m-s)      # '.' doesn't match new line; '^','$' match ...
                    ^\h*function    #  match 'function' preceeded by optional whitespace
                    \h+\K           # match whitespaces and discard what's matched ...
                    .*$             # math the rest of the line
                    "
    &gt;
        &lt;functionName&gt;
            &lt;nameExpr 
                expr = "(?x)(?m-s)  # '.' doesn't match new line; '^','$' match begin...
                        [A-Za-z\[]  # match the first char of a valid function signature  
                        [^%;]*+     # match whatever, until '%',';' or the end of the line
                        "
            /&gt;
        &lt;/functionName&gt;
    &lt;/function&gt;
&lt;/parser&gt;
</code></pre>
<p dir="auto"><strong>Some MATLAB files, which I use for testing</strong></p>
<p dir="auto"><code>function_scalar_return.m</code></p>
<pre><code>function    [ out, val ] = function_scalar_return( val )
    out = 17;
end        
</code></pre>
<p dir="auto"><code>function_multi_return.m</code></p>
<pre><code>function    [ out, val ] = function_multi_return( val )
    out = 17;
end        
</code></pre>
<p dir="auto"><code>function_no_return_comments.m</code></p>
<pre><code>function    function_no_return_comments( val )
    [~]=17;
end        
% function    function_no_return_C1( val )
%     [~]=17;
% end        
%{
function    function_no_return_C2( val )
    [~]=17;
end        
%}
</code></pre>
<p dir="auto"><code>class_basic_no_return.m</code></p>
<pre><code>classdef    class_basic_no_return
    methods
        function    no_return( this )
        end        
    end
end
</code></pre>
<p dir="auto"><code>class_basic_handle.m</code></p>
<pre><code>classdef    class_basic_handle &lt;  handle
    properties
        prop
    end
    methods
        function this = basic_handle( val )
            this.prop = val;
        end
        function    no_return( this )
        end        
        function    out = scalar_return( this )
            out = 17;
        end
    end
end
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/topic/13505/trouble-making-a-functionlist-parser-for-matlab</link><generator>RSS for Node</generator><lastBuildDate>Sat, 10 Oct 2026 01:45:21 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/13505.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 23 Mar 2017 05:10:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Fri, 30 Jun 2017 04:37:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mapje71" aria-label="Profile: MAPJe71">@<bdi>MAPJe71</bdi></a></p>
<p dir="auto">I’ve finally uploaded some &lt;parser&gt;-elements to the <a href="https://uk.mathworks.com/matlabcentral/fileexchange/63587-a-notepad++-function-list-for-matlab" rel="nofollow ugc">Matlab File Exchange</a>.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/25280</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/25280</guid><dc:creator><![CDATA[Per Isakson]]></dc:creator><pubDate>Fri, 30 Jun 2017 04:37:20 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Thu, 20 Apr 2017 20:32:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/per-isakson" aria-label="Profile: Per-Isakson">@<bdi>Per-Isakson</bdi></a></p>
<p dir="auto">*indentation ;-)</p>
<p dir="auto">Glad you found a parser that meets your needs!<br />
I propose to wait for feedback from other Matlab users (I’m not one of them) before including it in an official N++ release.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23735</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23735</guid><dc:creator><![CDATA[MAPJe71]]></dc:creator><pubDate>Thu, 20 Apr 2017 20:32:30 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Thu, 20 Apr 2017 06:53:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mapje71" aria-label="Profile: MAPJe71">@<bdi>MAPJe71</bdi></a></p>
<p dir="auto">Thank you for your latest parser.</p>
<p dir="auto">I’ve tested your latest parser and the parser I attach below with the files in a couple of real Matlab programs.</p>
<p dir="auto">Your latest parser handles <em>“multiple ‘methods’ sections”</em> well in most cases. I failed to spot what characterizes the few cases, which show methods as functions.</p>
<p dir="auto">One lesson I learned is that I must be more careful so that the test cases covers all relevant parts of the syntax of the target language. I previously missed that</p>
<ul>
<li>the keyword, <code>end</code>, is used as index, e.g <code>A(end)</code> is the last element of the vector <code>A</code>.</li>
<li>apostrophe, <code>'</code>, is shorthand for the function, <code>transpose</code>, e.g. <code>A'</code> is equal to <code>transpose(A)</code></li>
</ul>
<p dir="auto">My latest parser works as expected, i.e. I haven’t seen it fail yet. However, it puts higher requirements on the target Matlab code; it will fail with more files.</p>
<p dir="auto">I have included two parsers in <code>functionList.xml</code>, one for the UDL matlab2. I switch between the two<br />
by the menu entries, <code>Language|matlab2</code> and  <code>Language|M|Matlab</code>, respectively. The obviously overtakes the extension, <code>.m2</code>.</p>
<p dir="auto">I plan to upload my parsers to <a href="http://uk.mathworks.com/matlabcentral/fileexchange" rel="nofollow ugc">Matlab File Exchange</a> to see it I get any interest.</p>
<pre><code>&lt;!-- P09, KISS, full function signature 
Limitations and requirements
1.1 The keyword, 'classdef', shall start a new line; no indentions
1.2 The keyword, 'end', which match 'classdef', shall start a new line
1.3 No keyword, 'end', shall start a new line inside the classdef block
2.1 The keyword, 'function', optionally indented, shall start a new line 
3.1 The line of the last keyword, 'end', shall be ended by a new line character
4.1 Nested functions are displayed as methods and sub-functions, respectively.
5.1 Block comments must not be nested; no block comment inside a block comment
6.1 Function blocks shall be ended by the keyword, 'end'
7.1 The file shall contain at least one method or function
/--&gt;
            &lt;parser
                displayName="MATLAB - MATrix LABoratory"
                id         ="matlab2_syntax"
                commentExpr=   "(?x)                        # free-spacing
                                (?m)                        # ^ and $ match at line breaks
                                (?-s)                       # dot does NOT match new line
                                (?:                         # Multi Line Comment, (MLC)
                                    (?:^\h*\x25\x7B\h*$)    # '%{' with optional space
                                    (?s:.*?)                # lazy: any character up till
                                    (?:^\h*\x25\x7D\h*$)    # '%}' with optional space
                                )                           #
                                |                           # or
                                (?:                         # Single Line Comment (SLC)
                                    (?:                     #
                                        \x25                # '%'
                                        |                   # or
                                        \x2D{3}             # '...' 
                                    ).*?$                   # and up till end of line
                                )                           #
                                |                           # or
                                (?:\x27(?:.*?)*\x27)        # String Literal - Single Quoted - on one line
                            "
            &gt;
                 &lt;classRange
                    mainExpr = "(?x)                        # free-spacing
                                (?m)                        # ^ and $ match at line breaks
                                (?s)                        # dot matches new line
                                (?-i)                       # case-sensitive
                                ^classdef\h+                # start-of-class indicator at start-of-line
                                (?:.*?)                     # whatever, until...
                                ^end                        # end-of-class indicator at start-of-line
                                "
                &gt;
                    &lt;className&gt;
                        &lt;nameExpr expr="(?x)                # free-spacing
                                (?-i)                       # case-sensitive
                                \bclassdef                  # case-sensitive start-of-class indicator
                                \h+                         # required whitespace
                                (?:\([^)]*?\)\h+)?          # optional class-attributes
                                \K                          # discard text matched so far
                                [A-Za-z]\w*                 # valid Matlab identifiers; class name
                            "
                        /&gt;
                    &lt;/className&gt;
                    &lt;function
                        mainExpr="(?x)                      # free-spacing
                                (?m)                        # ^ and $ match at line breaks
                                (?s)                        # dot matches new line
                                (?-i)                       # case-sensitive
                                ^\h+                        # required intendation
                                function                    # start-of-function indicator
                                \h+                         # required whitespace separator
                                .*?$                        # whatever, up till the end of line
                            "
                    &gt;
                        &lt;functionName&gt;
                            &lt;funcNameExpr expr="(?x)        # free-spacing
                                    function\h+             # start-of-function indicator
                                    \K                      # discard text matched so far
                                    (?:                     # optional return value(s)
                                        (?:                 #
                                            \w+             # ...single variable name
                                            |               # or
                                            \[[\h,\w]*\]    # ...one or more names in square brackets
                                        )                   #
                                        \h*=\h*             # ...a separator with optional whitespace
                                    )?                      #
                                    \b                      # ensure word boundary
                                    [A-Za-z]\w*             # valid Matlab identifiers; method name
                                    \b                      # ensure word boundary for name
                                    (?:                     # optional parameter list
                                        \h*                 # ...optional leading whitespace
                                        \(                  # ...start-of-parameter-list indicator
                                        [\h,\w~]*           # ...with optional parameters
                                        (?:                 #
                                            \)              # ...up till end-of-parameter-list indicator
                                            |               # or
                                            \.{3}           # ...continuation-line indicator
                                        )
                                    )?
                                "
                            /&gt;
                        &lt;/functionName&gt;
                    &lt;/function&gt;
                &lt;/classRange&gt;
                &lt;function
                    mainExpr="(?x)                          # free-spacing
                                (?m)                        # ^ and $ match at line breaks
                                (?s)                        # dot matches new line
                                (?-i)                       # case-sensitive
                                ^\h*                        # optional intendation
                                function                    # start-of-function indicator
                                \h+                         # required whitespace separator
                                .*?$                        # whatever, until end of line
                        "
                &gt;
                    &lt;functionName&gt;
                        &lt;nameExpr expr="(?x)                # free-spacing (see `RegEx - Pattern Modifiers`)
                                function\h+                 # start-of-function indicator
                                (?:\.{3}.*$)?               # optional continuation-line indicator
                                \K                          # discard text matched so far
                                (?:                         # optional return value(s)
                                    (?:                     #
                                        \w+                 # ...single variable name
                                        |                   # or
                                        \[[\h,\w]*\]        # ...one or more variable names in brackets
                                    )                       #
                                    \h*=\h*                 # ...followed by a separator with optional whitespace
                                )?                          #
                                [A-Za-z]\w*                 # valid Matlab identifiers; function name
                                \b                          # ensure word boundary for name
                                (?:                         # optional parameter list
                                    \h*                     # ...optional leading whitespace
                                    \(                      # ...start-of-parameter-list indicator
                                    [\h,\w~]*               # ...with optional parameters
                                    (?:                     #
                                        \)                  # ...until end-of-parameter-list indicator
                                        |                   # or
                                        \.{3}               # ...or continuation-line indicator
                                    )
                                )?
                            "
                        /&gt;
                    &lt;/functionName&gt;
                &lt;/function&gt;
            &lt;/parser&gt;
</code></pre>
<p dir="auto">Alternate  &lt;functionName&gt; block to show method and function name (without input and output arguments)</p>
<pre><code>                    &lt;functionName&gt;
                        &lt;nameExpr expr="(?x)                # free-spacing (see `RegEx - Pattern Modifiers`)
                                function\h+                 # start-of-function indicator
                                (?:\.{3}.*$)?               # optional continuation-line indicator
                                (?:                         # optional return value(s)
                                    (?:                     #
                                        \w+                 # ...single variable name
                                        |                   # or
                                        \[[\h,\w]*\]        # ...one or more variable names in brackets
                                    )                       #
                                    \h*=\h*                 # ...followed by a separator with optional whitespace
                                )?                          #
                                \K                          # discard text matched so far
                                [A-Za-z]\w*                 # valid Matlab identifiers; function name
                                \b                          # ensure word boundary for name
                            "
                        /&gt;
                    &lt;/functionName&gt;</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/23718</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23718</guid><dc:creator><![CDATA[Per Isakson]]></dc:creator><pubDate>Thu, 20 Apr 2017 06:53:15 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Wed, 12 Apr 2017 18:38:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/per-isakson" aria-label="Profile: Per-Isakson">@<bdi>Per-Isakson</bdi></a></p>
<p dir="auto">The latest:</p>
<pre><code class="language-xml">&lt;!--
|   Note(s):
|   1)  One-line class definitions are not supported;
|   2)  Nested functions are not supported;
|   3)  All functions require an 'end' statement;
|   4)  In some situations where a multi-line/block comment contains function definition(s),
|       the function(s) is/are still displayed as global function(s).
\--&gt;
&lt;parser
	displayName="MATLAB - MATrix LABoratory"
	id         ="matlab_syntax"
	commentExpr="(?x)                                    # free-spacing (see `RegEx - Pattern Modifiers`)
					(?'MLC'                              # Multi Line Comment
						(?m)                             # ...^ and $ match at line breaks
						^%\{$                            # ...start-of-comment indicator
						(?:                              # ...followed by zero or more characters
							[^%]                         # ...not start of start-of-comment indicator
						|	%(?![%{}])                   # ...not being an SLC or a start- or end-of-comment indicator
						|	(?&amp;amp;MLC)
						)*?
						^%\}$                            # ...end-of-comment indicator
					)
				|	(?m-s:%.*$)                          # Single Line Comment (SLC)
				|	(?s:\x22(?:[^\x22\x5C]|\x5C.)*\x22)  # String Literal - Double Quoted
				|	(?s:\x27(?:[^\x27\x5C]|\x5C.)*\x27)  # String Literal - Single Quoted
				"
&gt;
	&lt;classRange
		mainExpr    ="(?x)                               # free-spacing (see `RegEx - Pattern Modifiers`)
				(?s-i)                                   # dot matches at line breaks, case-sensitive
				\bclassdef\b                             # start-of-class indicator
				.*?                                      # whatever, up till...
				(?=                                      # ...start-of-class-body indicator
					\b
					(?:e(?:numeration|vents)|methods|properties)
					\b
				)
			"
		openSymbole ="(?x)                               # free-spacing (see `RegEx - Pattern Modifiers`)
				\b                                       # ensure leading word boundary for start-of-block indicator
				(?-i:                                    # case-sensitive start-of-block indicators
					e(?:numeration|vents)
				|	f(?:or|unction)
				|	if
				|	methods
				|	p(?:arfor|roperties)
				|	switch
				|	try
				|	while
				)
				\b
			"
		closeSymbole="(?x)                               # free-spacing (see `RegEx - Pattern Modifiers`)
				\b                                       # ensure leading word boundary for end-of-block indicator
				(?-i:                                    # case-sensitive
					end                                  # end-of-block indicator
				)
				\b                                       # ensure trailing word boundary for end-of-block indicator
			"
	&gt;
		&lt;className&gt;
			&lt;nameExpr expr="(?x)                         # free-spacing (see `RegEx - Pattern Modifiers`)
					\b(?-i:classdef)                     # case-sensitive start-of-class indicator
					\h+                                  # required whitespace
					(?:\([^)]*?\)\h+)?                   # optional class-attributes
					\K                                   # discard text matched so far
					[A-Za-z]\w*                          # valid character combination for identifiers i.e. class name
				"
			/&gt;
		&lt;/className&gt;
		&lt;function
			mainExpr="(?x)                               # free-spacing (see `RegEx - Pattern Modifiers`)
					(?ms-i)                              # ^, $ and dot match at line breaks, case-sensitive
					(?:	^                                # a function can be found at start-of-line
					|	[,;]                             # ...or after a separator
					)\h*                                 # ...optionally followed by whitespace
					\K                                   # discard text matched so far
					\bfunction                           # ensure word boundary for start-of-function indicator
					\s+                                  # required whitespace separator
					.*?                                  # whatever, until...
					\bend\b                              # ...the first end-of-block indicator
				"
		&gt;
			&lt;functionName&gt;
				&lt;funcNameExpr expr="(?x)                 # free-spacing (see `RegEx - Pattern Modifiers`)
						function\s+                      # start-of-function indicator
						(?:\.{3}\s+)?                    # optional continuation-line indicator
						\K                               # discard text matched so far
						(?:                              # optional return value(s)
							(?:	\w+                      # ...single variable name
							|	\[[\h,\w]*\]             # ...or one or more variable names in brackets
							)\h*=\h*                     # ...followed by a separator with optional whitespace
						)?
						[A-Za-z]\w*                      # valid character combination for identifiers i.e. function name
						\b                               # ensure word boundary for name
						(?:                              # optional parameter list
							\s*                          # ...optional leading whitespace
							\(                           # ...start-of-parameter-list indicator
							[\h,\w~]*                    # ...with optional parameters
							(?:	\)                       # ...until end-of-parameter-list indicator
							|	\.{3}                    # ...or continuation-line indicator
							)
						)?
					"
				/&gt;
				&lt;!-- comment out the following node to display the method with its parameters --&gt;
&lt;!--				&lt;funcNameExpr expr="(?:(?:\w+|\[[\h,\w]*\])\h*=\h*)?[A-Za-z]\w*" /&gt; --&gt;
			&lt;/functionName&gt;
		&lt;/function&gt;
	&lt;/classRange&gt;
	&lt;function
		mainExpr="(?x)                                   # free-spacing (see `RegEx - Pattern Modifiers`)
				(?ms-i)                                  # ^, $ and dot match at line breaks, case-sensitive
				^\h*                                     # optional leading whitespace at start-of-line
				function\b                               # start-of-function indicator
				.*?                                      # whatever, until...
				\bend\b                                  # ...the first end-of-block indicator
			"
	&gt;
		&lt;functionName&gt;
			&lt;nameExpr expr="(?x)                         # free-spacing (see `RegEx - Pattern Modifiers`)
					function\s+                          # start-of-function indicator
					(?:\.{3}\s+)?                        # optional continuation-line indicator
					\K                                   # discard text matched so far
					(?:                                  # optional return value(s)
						(?:	\w+                          # ...single variable name
						|	\[[\h,\w]*\]                 # ...or one or more variable names in brackets
						)\h*=\h*                         # ...followed by a separator with optional whitespace
					)?
					[A-Za-z]\w*                          # valid character combination for identifiers i.e. function name
					\b                                   # ensure word boundary for name
					(?:                                  # optional parameter list
						\s*                              # ...optional leading whitespace
						\(                               # ...start-of-parameter-list indicator
						[\h,\w~]*                        # ...with optional parameters
						(?:	\)                           # ...until end-of-parameter-list indicator
						|	\.{3}                        # ...or continuation-line indicator
						)
					)?
				"
			/&gt;
			&lt;!-- comment out the following node to display the method with its parameters --&gt;
&lt;!--			&lt;nameExpr expr="(?:(?:\w+|\[[\h,\w]*\])\h*=\h*)?[A-Za-z]\w*" /&gt; --&gt;
		&lt;/functionName&gt;
	&lt;/function&gt;
&lt;/parser&gt;
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/23548</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23548</guid><dc:creator><![CDATA[MAPJe71]]></dc:creator><pubDate>Wed, 12 Apr 2017 18:38:28 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Wed, 12 Apr 2017 14:36:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/per-isakson" aria-label="Profile: Per-Isakson">@<bdi>Per-Isakson</bdi></a></p>
<p dir="auto">Yep, the colon in the MLC commentExpr is a typo.<br />
FYI: failing to detect multi-line/block comments when the parser has a <code>classRange</code> node appears to be a bug.</p>
<p dir="auto">The only way I can think of right now to document limitations of parsers is to add it as comment in <code>functionList.xml</code>. I will do so for this parser.</p>
<p dir="auto">Although I haven’t found a solution for multiple ‘methods’ sections within a class definition yet, I think the parser should support it presuming it’s used a lot in OO programming.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23534</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23534</guid><dc:creator><![CDATA[MAPJe71]]></dc:creator><pubDate>Wed, 12 Apr 2017 14:36:29 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Sun, 09 Apr 2017 21:59:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mapje71" aria-label="Profile: MAPJe71">@<bdi>MAPJe71</bdi></a></p>
<p dir="auto">There is another Matlab feature, which is a strong candidate for documented limitation. In files defining functions and subfunctions, but no nested functions,  <code>end</code> is optional in the <code>function ... end</code> block. It’s a legacy from long time ago.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23453</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23453</guid><dc:creator><![CDATA[Per Isakson]]></dc:creator><pubDate>Sun, 09 Apr 2017 21:59:48 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Sun, 09 Apr 2017 07:14:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mapje71" aria-label="Profile: MAPJe71">@<bdi>MAPJe71</bdi></a></p>
<p dir="auto">I’m obviously not capable to contribute effectively to the code of this &lt;parser&gt;:-(.  I lack both regarding  knowledge on regular expressions, and understanding of how the &lt;parser&gt;-code produces the function list.</p>
<p dir="auto">How important is a good Matlab-&lt;parser&gt; to Notepad++ ? To me Notepad++ is a valuable complement to Matlab’s editor, which is sluggish and doesn’t support regular expressions, not even wildcards. I use Notepad++ daily. Notepad++ is superior when it comes to large files and browsing large code-bases. Google returns  0.18 million results for “notepad++ matlab”.</p>
<p dir="auto">I send this post rather to help you decide than insisting on specific things being included in the &lt;parser&gt;.  What we achieved so far is good enough for me!</p>
<p dir="auto">Is there a mean to make the user aware of limitations in the capability of a specific &lt;parser&gt;. Documented limitations are more acceptable.</p>
<h4>MLC commentExpr</h4>
<p dir="auto">The colon after ‘MLC’ is that a typo or <code>non-capture</code>?</p>
<p dir="auto"><strong>Proposal:</strong> replace the MLC-code by</p>
<pre><code>(?xms)
(?'OMLC' (?&gt;^\h*%\{\h*$))
.*?
(?'CMLC' (?&gt;^\h*%\}\h*$))
</code></pre>
<p dir="auto"><strong>Justification:</strong> Again Matlab’s syntax  [<a href="http://uk.mathworks.com/help/matlab/matlab_prog/comments.html" rel="nofollow ugc">Add Comments to Programs</a>] is permissive</p>
<ul>
<li>nested multi-line-comments (candidate for documented limitation)</li>
<li>single-line-comments inside MLC</li>
<li>I often comments out code with both SLC and MLC, because Matlab has a feature, Find in Files, which doesn’t honor MLC (bug). MLC allows me to code-fold the comment-out code.</li>
</ul>
<p dir="auto">This should be matched by MLC</p>
<pre><code>%{
some code
%% Section 
%  some other code
%}
</code></pre>
<p dir="auto">This expression is affected by the block-comment-problem.</p>
<h4>Nested functions</h4>
<p dir="auto">Matlab have <a href="http://uk.mathworks.com/help/matlab/matlab_prog/nested-functions.html" rel="nofollow ugc">nested functions</a>. My previous &lt;parser&gt; showed functions nested in functions as ordinary functions and functions nested in methods broke the function list (showed only file name). Your current &lt;parser&gt; ignores nested functions altogether, which is better. Candidate for documented limitation.</p>
<pre><code>function    out = function_scalar_return_nested( val )
    out = 17;
    function nested
    end
end
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/23435</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23435</guid><dc:creator><![CDATA[Per Isakson]]></dc:creator><pubDate>Sun, 09 Apr 2017 07:14:33 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Sat, 08 Apr 2017 12:17:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/per-isakson" aria-label="Profile: Per-Isakson">@<bdi>Per-Isakson</bdi></a></p>
<p dir="auto">Sigh, it was to good to be true ;-)<br />
I’ll will look at it tomorrow.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23426</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23426</guid><dc:creator><![CDATA[MAPJe71]]></dc:creator><pubDate>Sat, 08 Apr 2017 12:17:39 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Sat, 08 Apr 2017 03:25:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mapje71" aria-label="Profile: MAPJe71">@<bdi>MAPJe71</bdi></a></p>
<p dir="auto">Sorry, I’m back with more problems. However, the result so far is good enough for me who know the limitations. Other Matlab users may think differently.</p>
<p dir="auto">My goal is that the &lt;parser&gt; produces the intended result for syntactically correct Matlab files. Exceptions are acceptable for rare and smelly cases. It’s good if something is shown for syntactically incorrect Matlab files - the more the better.</p>
<p dir="auto">The Matlab class syntax, [<a href="http://uk.mathworks.com/help/matlab/class-syntax-guide.html" rel="nofollow ugc">Class Syntax Guide</a>], includes more than I have “communicated” with the test files in this thread.</p>
<p dir="auto"><strong>Problem:</strong>  A Matlab file allows one <code>classdef...end</code> block, which in turn may contain zero or more  <code>methods...end</code> blocks.  <code>classdef</code> shall be the first keyword in the file. The current &lt;parser&gt; displays the functions of the first <code>methods...end</code> block as belonging to the class, i.e. being methods, and erroneously the functions of subsequent <code>methods...end</code> blocks as functions. This is illustrated by the attached m-file.</p>
<p dir="auto">I failed to modify your &lt;parser&gt; to show all function inside the <code>classdef...end</code> block as methods belonging to the class.</p>
<pre><code>classdef (Sealed) aCompleteClassWithFunction &lt; handle
   properties (Access = private)
      Prop1 = datenum(date)
   end
   properties
      Prop2
   end
   events (ListenAccess = protected)
      StateChanged
   end
   methods
      function obj = aCompleteClassWithFunction(x)
         obj.Prop2 = x;
      end
   end
   methods (Access = {?MyOtherClass})
      function d = myMethod(obj)
         d = obj.Prop1 + x;
      end
   end
end
function myUtilityFcn
    A = 17;
end
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/23420</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23420</guid><dc:creator><![CDATA[Per Isakson]]></dc:creator><pubDate>Sat, 08 Apr 2017 03:25:15 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Fri, 07 Apr 2017 02:02:27 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mapje71" aria-label="Profile: MAPJe71">@<bdi>MAPJe71</bdi></a> ,<br />
Your new parser works like a charm. It even handles <code>WeirdUseOfContinuationLine.m</code>.  Thank you very much!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23390</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23390</guid><dc:creator><![CDATA[Per Isakson]]></dc:creator><pubDate>Fri, 07 Apr 2017 02:02:27 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Fri, 07 Apr 2017 00:29:47 GMT]]></title><description><![CDATA[<p dir="auto">This is what I get …</p>
<p dir="auto"><img src="https://c1.staticflickr.com/3/2877/33070407653_ff9bfcc89a_b.jpg" alt="" class=" img-fluid img-markdown" /></p>
<p dir="auto">with the following &lt;parser&gt; …</p>
<pre><code class="language-xml">&lt;parser
	displayName="MATLAB - MATrix LABoratory"
	id         ="matlab_syntax"
	commentExpr="(?x)                                    # free-spacing (see `RegEx - Pattern Modifiers`)
					(?'MLC':                             # Multi Line Comment
						%\{                              # ...start-of-comment indicator
						(?:                              # ...followed by zero or more characters
							[^%]                         # ...not start of start-of-comment indicator
						|	%(?![%{}])                   # ...not being an SLC or a start- or end-of-comment indicator
						)*?
						%\}                              # ...end-of-comment indicator
					)
				|	(?m-s:\x25.*$)                       # Single Line Comment (SLC)
				|	(?s:\x22(?:[^\x22\x5C]|\x5C.)*\x22)  # String Literal - Double Quoted
				|	(?s:\x27(?:[^\x27\x5C]|\x5C.)*\x27)  # String Literal - Single Quoted
				"
&gt;
	&lt;classRange
		mainExpr    ="(?x)                               # free-spacing (see `RegEx - Pattern Modifiers`)
				(?s-i)                                   # dot matches at line breaks, case-sensitive
				\bclassdef\b                             # start-of-class indicator
				.*?                                      # whatever, until...
				\bmethods\b                              # ...start-of-class-body indicator
			"
		openSymbole ="(?x)                               # free-spacing (see `RegEx - Pattern Modifiers`)
				\b                                       # ensure leading word boundary for start-of-block indicator
				(?-i:                                    # case-sensitive start-of-block indicators
					e(?:numeration|vents)
				|	f(?:or|unction)
				|	if
				|	methods
				|	p(?:arfor|roperties)
				|	switch
				|	try
				|	while
				)
				\b
			"
		closeSymbole="(?x)                               # free-spacing (see `RegEx - Pattern Modifiers`)
				\b                                       # ensure leading word boundary for end-of-block indicator
				(?-i:                                    # case-sensitive
					end                                  # end-of-block indicator
				)
				\b                                       # ensure trailing word boundary for end-of-block indicator
			"
	&gt;
		&lt;className&gt;
			&lt;nameExpr expr="(?x)                         # free-spacing (see `RegEx - Pattern Modifiers`)
					\b(?-i:classdef)                     # case-sensitive start-of-class indicator
					\h+                                  # required whitespace
					(?:\([^)]*?\)\h+)?                   # optional class-attributes
					\K                                   # discard text matched so far
					[A-Za-z]\w*                          # valid character combination for identifiers i.e. class name
				"
			/&gt;
		&lt;/className&gt;
		&lt;function
			mainExpr="(?x)                               # free-spacing (see `RegEx - Pattern Modifiers`)
					(?ms-i)                              # ^, $ and dot match at line breaks, case-sensitive
					(?:	^                                # a function can be found at start-of-line
					|	[,;]                             # ...or after a separator
					)\h*                                 # ...optionally followed by whitespace
					\K                                   # discard text matched so far
					\bfunction                           # ensure word boundary for start-of-function indicator
					\s+                                  # required whitespace separator
					.*?                                  # whatever, until...
					\bend\b                              # ...the first end-of-block indicator
				"
		&gt;
			&lt;functionName&gt;
				&lt;funcNameExpr expr="(?x)                 # free-spacing (see `RegEx - Pattern Modifiers`)
						function\s+                      # start-of-function indicator
						(?:\.{3}\s+)?                    # optional continuation-line indicator
						\K                               # discard text matched so far
						(?:                              # optional return value(s)
							(?:	\w+                      # ...single variable name
							|	\[[\h,\w]*\]             # ...or one or more variable names in brackets
							)\h*=\h*                     # ...followed by a separator with optional whitespace
						)?
						[A-Za-z]\w*                      # valid character combination for identifiers i.e. function name
						\b                               # ensure word boundary for name
						(?:                              # optional parameter list
							\s*                          # ...optional leading whitespace
							\(                           # ...start-of-parameter-list indicator
							[\h,\w~]*                    # ...with optional parameters
							(?:	\)                       # ...until end-of-parameter-list indicator
							|	\.{3}                    # ...or continuation-line indicator
							)
						)?
					"
				/&gt;
				&lt;!-- comment out the following node to display the method with its parameters --&gt;
&lt;!--				&lt;funcNameExpr expr="(?:(?:\w+|\[[\h,\w]*\])\h*=\h*)?[A-Za-z]\w*" /&gt; --&gt;
			&lt;/functionName&gt;
		&lt;/function&gt;
	&lt;/classRange&gt;
	&lt;function
		mainExpr="(?x)                                   # free-spacing (see `RegEx - Pattern Modifiers`)
				(?ms-i)                                  # ^, $ and dot match at line breaks, case-sensitive
				^\h*                                     # optional leading whitespace at start-of-line
				function\b                               # start-of-function indicator
				.*?                                      # whatever, until...
				\bend\b                                  # ...the first end-of-block indicator
			"
	&gt;
		&lt;functionName&gt;
			&lt;nameExpr expr="(?x)                         # free-spacing (see `RegEx - Pattern Modifiers`)
					function\s+                          # start-of-function indicator
					(?:\.{3}\s+)?                        # optional continuation-line indicator
					\K                                   # discard text matched so far
					(?:                                  # optional return value(s)
						(?:	\w+                          # ...single variable name
						|	\[[\h,\w]*\]                 # ...or one or more variable names in brackets
						)\h*=\h*                         # ...followed by a separator with optional whitespace
					)?
					[A-Za-z]\w*                          # valid character combination for identifiers i.e. function name
					\b                                   # ensure word boundary for name
					(?:                                  # optional parameter list
						\s*                              # ...optional leading whitespace
						\(                               # ...start-of-parameter-list indicator
						[\h,\w~]*                        # ...with optional parameters
						(?:	\)                           # ...until end-of-parameter-list indicator
						|	\.{3}                        # ...or continuation-line indicator
						)
					)?
				"
			/&gt;
			&lt;!-- comment out the following node to display the method with its parameters --&gt;
&lt;!--			&lt;nameExpr expr="(?:(?:\w+|\[[\h,\w]*\])\h*=\h*)?[A-Za-z]\w*" /&gt; --&gt;
		&lt;/functionName&gt;
	&lt;/function&gt;
&lt;/parser&gt;
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/23388</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23388</guid><dc:creator><![CDATA[MAPJe71]]></dc:creator><pubDate>Fri, 07 Apr 2017 00:29:47 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Thu, 06 Apr 2017 23:53:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mapje71" aria-label="Profile: MAPJe71">@<bdi>MAPJe71</bdi></a></p>
<blockquote>
<p dir="auto">The single line comment and both double and single quoted string literals are detected just perfectly …</p>
</blockquote>
<p dir="auto">That is not how I interpret what I see om my side. I have no debugging means to see how NPP uses the value of <code>commentExpr</code>. (Or I missed it.) Thus, I resort to indirect tests.</p>
<p dir="auto">With</p>
<ul>
<li>your new value of <code>commentExpr</code> (corrected),</li>
<li><code>classRange.mainExpr</code> using recursion,</li>
<li>the Matlab files attached and</li>
<li>Notepad++ v7.3.3   (32-bit), Build time : Mar  8 2017 - 03:37:37, Admin mode : OFF, Local Conf mode : OFF,   OS : Windows 7 (64-bit), Plugins : …</li>
</ul>
<p dir="auto">Function List  displays a row of dots, a document icon and the file name. The evaluation, which obviously fails, takes a few seconds.</p>
<p dir="auto">With the keyword, <code>while</code>, replaced  by <code>_while</code> the Function List  displays  the expected results without delay.</p>
<p dir="auto">Do you see a different behavior?</p>
<p dir="auto">I’m out of ideas, are there other test I could do?</p>
<pre><code>function    [ out, val ] = function_with_keyword_in_string( val )
    out = 17;
    str = 'string with keyword: while'; 
end
</code></pre>
<pre><code>function    [ out, val ] = function_with_keyword_in_comment( val )
    out = 17;
    % comment with keyword: while
end
</code></pre>
<pre><code>classdef    class_with_keyword_in_comment
    methods
        function    no_return( this )
            % comment with keyword: while
            a = 17;
        end        
    end
end
</code></pre>
<pre><code>classdef    class_with_keyword_in_string
    methods
        function    no_return( this )
            str = 'string with keyword: while'; 
            a = 17;
        end        
    end
end
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/23386</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23386</guid><dc:creator><![CDATA[Per Isakson]]></dc:creator><pubDate>Thu, 06 Apr 2017 23:53:32 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Thu, 06 Apr 2017 14:22:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/per-isakson" aria-label="Profile: Per-Isakson">@<bdi>Per-Isakson</bdi></a></p>
<p dir="auto">There is definitely something weird going with the comment expression. The single line comment and both double and single quoted string literals are detected just perfectly but the multi line comment keeps failing.</p>
<p dir="auto">Oh just noticed that the comment expression I posted has a superfluous <code>(?s:</code> at the start of the “Multi Line Comment”-part.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23371</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23371</guid><dc:creator><![CDATA[MAPJe71]]></dc:creator><pubDate>Thu, 06 Apr 2017 14:22:59 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Thu, 06 Apr 2017 02:05:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mapje71" aria-label="Profile: MAPJe71">@<bdi>MAPJe71</bdi></a>,  thanks for your answer.</p>
<blockquote>
<p dir="auto">The trick here is to handle literate strings as comment regions.</p>
</blockquote>
<p dir="auto">Yes, but I fail to make it work. I copy&amp;pasted your  <code>commentExpr</code> value into the &lt;parser&gt; that I posted yesterday. None of the “keyword in comment and string” test files give the expected result in the Function List, i.e. the same result as yesterday.</p>
<p dir="auto"><strong>Speculation:</strong>  <code>commentExpr</code> has no effect in my &lt;parser&gt;.</p>
<ol>
<li>The “block-comment-problem” is back, i.e. function_no_return_C2 is displayed</li>
<li>With <code>classRange.mainExpr</code> using <code>recursion</code> skipping strings values and comments is needed.</li>
</ol>
]]></description><link>https://community.notepad-plus-plus.org/post/23359</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23359</guid><dc:creator><![CDATA[Per Isakson]]></dc:creator><pubDate>Thu, 06 Apr 2017 02:05:24 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Wed, 05 Apr 2017 20:29:43 GMT]]></title><description><![CDATA[<blockquote>
<p dir="auto">Update the editor window first and then update the Function List</p>
</blockquote>
<p dir="auto">I suspect the recursive part of <code>classRange.mainExpr</code> is giving the RE engine a hard time :-)</p>
<blockquote>
<p dir="auto">More than one Matlab &lt;parser&gt;</p>
</blockquote>
<p dir="auto">Based on current Function List implementation I can think of three solutions: define a &lt;parser&gt; for each use-case and switch between them by …</p>
<ol>
<li>changing the association; this requires a restart of NP++ to take effect;</li>
<li>swapping their parser id,  this also requires a restart of NP++ to take effect;</li>
<li>utilizing file extension association and changing the extension of the file.</li>
</ol>
<blockquote>
<p dir="auto">Keywords embedded in comments and in string values</p>
</blockquote>
<p dir="auto">The <em>trick</em> here is to handle literate strings as comment regions.<br />
e.g.</p>
<pre><code class="language-xml">commentExpr="(?x)                                    # free spacing
				(?s:(?s:%\{.*%\})                    # Multi Line Comment
			|	(?m-s:%.*$)                          # Single Line Comment
			|	(?s:\x22(?:[^\x22\x5C]|\x5C.)*\x22)  # String Literal - Double Quoted
			|	(?s:\x27(?:[^\x27\x5C]|\x5C.)*\x27)  # String Literal - Single Quoted
			"
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/23355</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23355</guid><dc:creator><![CDATA[MAPJe71]]></dc:creator><pubDate>Wed, 05 Apr 2017 20:29:43 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Wed, 05 Apr 2017 01:37:45 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a>  and <a class="plugin-mentions-user plugin-mentions-a" href="/user/mapje71" aria-label="Profile: MAPJe71">@<bdi>MAPJe71</bdi></a></p>
<p dir="auto">Thank you for your answers, especially on Nested Pairs and recursion. Now I have a &lt;parser&gt;, which doesn’t rely on the indentation of the Matlab code and produces correct results for my first set of test files. However, keywords embedded in comments and in string values make the &lt;parser&gt; fail.</p>
<h3>A new  &lt;parser&gt; and some test files</h3>
<pre><code>&lt;parser 
    id          = "matlab" 
    displayName = "Matlab Node" 
    commentExpr =  "(?x)                    # Utilize inline comments (see `RegEx - Pattern Modifiers`)
                    (?s:%\{.*%\})           # Multi Line Comment
                    |(?m-s:\h*%.*$)         # Single Line Comment
                    "
&gt;    
    &lt;classRange
        mainExpr = "(?x)(?s)                                    # dot matches new line
                    (?-i)                                       # case sensitive
                    (                                           # --- open 1st group 
                        \b                                      # word boundary  
                        (                                       # --- open 2nd group
                                classdef                        # keywords that open a 
                            |   e(?:numeration|vents)           # Balanced Construct
                            |   f(?:or|unction)                 # that is closed by 
                            |   if                              # 'end'.
                            |   methods                         #
                            |   p(?:arfor|roperties)            #
                            |   switch                          #
                            |   try                             #
                            |   while                           #
                        )                                       # --- close 2nd group
                        \b                                      # word boundary 
                    )                                           # --- close 1st group
                                        
                    (                                           # open 3rd capturing group    
                        (?:                                     # open non-capturing group
                            (?!                                 # negative look-ahead; if not a keyword
                                \b                              # word boundary  
                                (                               # --- open 4th group
                                        classdef                # keywords, of the 2nd group + 'end',
                                    |   e(?:numeration|vents)   # which must NOT occur,
                                    |   f(?:or|unction)         # at ANY position, of the
                                    |   if                      # present sub-block, till
                                    |   methods                 # its associated 'end' closing word
                                    |   p(?:arfor|roperties)    #
                                    |   switch                  #
                                    |   try                     #
                                    |   while                   #
                                    |   end                     #
                                )                               # --- close 4th group
                                \b                              # word boundary 
                            ).                                  # then one character
                        )+                                      # repeat 
                        |                                       # until keyword found
                        (?R)                                    # recurse RE from start
                    )+                                          # repeat 3rd group
                    \bend\b                                     #      
                    "
    &gt;
        &lt;className&gt;
            &lt;nameExpr 
                expr = "(?x)                    # ok, 10:07 2017-03-25
                        ^\h*                    # optional whitespace
                        classdef                # start-of-class indicator
                        \h+                     # whitespace
                        (                       #
                            \([^\)]*?\)         # (ClassAttributes)
                            \h+                 # whitespace
                        )?                      #
                        \K                      # discarge what's matched so far 
                        [A-Za-z]\w*             # valid identifier, i.e. class name
                        "
            /&gt;
        &lt;/className&gt;
        &lt;function
            mainExpr = "(?x)                    # ok, 10:22 2017-03-25, [2]
                        (?m)                    # ^ and $ match at line breaks
                        (   
                            (^\h*)              # optional whitespace starting line
                            |                   # or
                            ([,;]\h*)           # separator before 'function'
                        )       
                        function                # start-of-function indicator
                        \h+                     # whitespace
                        \K                      # discard what's matched so far 
                        (                       # open optional left hand side, LHS
                            (                   #
                                (\w+)           # single variable name
                                |               # or
                                (\[[\w,\h]*\])  # one or more variable names in brackets 
                            )                   #
                            \h*=\h*             # 
                        )?                      # close optional left hand side
                        [A-Za-z]\w*\b           # function name
                        \h*                     #      
                        (                       # open optional argument list
                            (\([\h,\w~]*\))     # pair of parentheses with optional arguments 
                            |                   # or
                            (                   #  
                                \([\h,\w~]*?    # opening parenthisis and optional arguments
                                (?=\h*\.{3})    # and closed by continuation line
                            )                   #
                        )?                      # close optional argument list
                        "
        &gt;
            &lt;functionName&gt;
                &lt;funcNameExpr 
                    expr = "(?x)                # ok, 12:07 2017-03-25
                            (?m)                # ^ and $ match at line breaks
                            (?-s)               # single-line  
                            (                   # open optional left hand side, LHS
                            ((\w+)|             # single variable name
                            (\[[\w,\h]*\]))     # one or more variable names in brackets 
                            \h*=\h*             # 
                            )?                  # close optional left hand side
                            [A-Za-z]\w*\b       # function name
                            \h*                 #      
                            (                   # open optional argument list
                                (\([\h,\w~]*\)) # pair of parenthisis with optional arguments
                                |               # or
                                (\([\h,\w~]*?   # lazy to avoid trailing whitespace 
                                (?=\h*\.{3}))   # continuation line
                            )?                  # close optional argument list
                    "
                /&gt;
            &lt;/functionName&gt;
        &lt;/function&gt;
    &lt;/classRange&gt;
    &lt;function
        mainExpr = "(?x)            # [3]
                    ^\h*            # optional whitespace
                    function        # start-of-function indicator 
                    \h+             # whitespaces
                    (?-s:.*)        # the rest of the line
                    "
    &gt;
        &lt;functionName&gt;
            &lt;nameExpr 
                expr = "(?x)                    #
                        function                # start-of-function indicator 
                        \h+                     # whitespace        
                        \K                      # discard what's matched so far
                        (                       # open optional left hand side, LHS
                            (                   #
                                (\w+)           # single variable name
                                |               # or
                                \[[\w,\h]*\]    # one or more variable names in brackets 
                            )                   #
                            \h*=\h*             # 
                        )?                      # close optional left hand side
                        [A-Za-z]\w*             # function name
                        \b\h*                   #      
                        (                       # open optional input argument list
                            \([\h,\w~]*\)       # pair of parenthisis with optional arguments or
                            |                   # or     
                            (                   #
                                \([\h,\w]*?     # lazy to avoid trailing whitespace 
                                (?=\h*\.{3})    # 
                            )                   #
                        )?                      # close optional argument list
                        "
            /&gt;
        &lt;/functionName&gt;
    &lt;/function&gt;
&lt;/parser&gt;
</code></pre>
<p dir="auto"><code>function_with_keyword_in_comment.m</code>.  The &lt;parser&gt; fails with this test file. Only the file name is displayed in Function List.</p>
<pre><code>function    [ out, val ] = function_with_keyword_in_comment( val )
    out = 17;
    % comment with keyword: while
end
</code></pre>
<p dir="auto"><code>class_with_keyword_in_block_comment.m</code>. The &lt;parser&gt; fails with this test file. Only the file name is displayed in Function List.</p>
<pre><code>classdef    class_with_keyword_in_block_comment
    methods
        function    no_return( this )
            %{
                comment with keyword: while
            %}
            a = 17;
        end        
    end
end
</code></pre>
<p dir="auto"><code>class_with_keyword_in_string.m</code>. The &lt;parser&gt; fails with this test file. Only the file name is displayed in Function List.</p>
<pre><code>classdef    class_with_keyword_in_string
    methods
        function    no_return( this )
            str = 'string with keyword: while'; 
            a = 17;
        end        
    end
end
</code></pre>
<p dir="auto"><code>OneLineClasses.m</code>. The &lt;parser&gt; displays the expected result in Function List</p>
<pre><code>classdef OneLineClasses,methods,function OneLineMethod(~,str),disp(str),end,function [q]=OneLineMethod(str),disp(str),end,end,end
</code></pre>
<h3>Update the editor window first and then update the Function List</h3>
<p dir="auto"><strong>Problem:</strong> “Browsing” through open files, <code>Next Tab</code>and <code>Previous Tab</code>, is halted for seconds by files that the &lt;parser&gt; fails to process.<br />
<strong>Proposal:</strong>  Let <code>Next Tab</code>and <code>Previous Tab</code> interrupt the &lt;parser&gt; (if working), update the editor window, and then update Function List. While the &lt;parser&gt; is working the update icon could rotate to indicate ongoing work.</p>
<h3>More than one Matlab &lt;parser&gt;</h3>
<p dir="auto">In some use cases I would like to show the full function signature in the Function List and in other only the function name. It’s straight forward to modify the current &lt;parser&gt; to only display function names. However, I cannot think of a good way to switch between the two variants.</p>
<h3>Keywords embedded in comments and in string values</h3>
<p dir="auto">The problem with keywords in comments and string values makes the current &lt;parser&gt; nearly worthless for practical work. I have many “for” and “end” in my comments and string values.</p>
<p dir="auto">There is a simple solution, replace <code>parser.classRange.mainExpr</code> by something simple that requires that files honor the recommended format, e.g. <code>(?m)^classdef\h+(?s:.*?)^end\b</code>.  That’s good enough for me. And I have done a useful exercise with RE.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23334</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23334</guid><dc:creator><![CDATA[Per Isakson]]></dc:creator><pubDate>Wed, 05 Apr 2017 01:37:45 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Wed, 05 Apr 2017 00:26:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/per-isakson" aria-label="Profile: Per-Isakson">@<bdi>Per-Isakson</bdi></a></p>
<blockquote>
<p dir="auto">The “block comment problem” disappeared as a result of changes of the &lt;parser&gt;</p>
</blockquote>
<p dir="auto">Strange indeed.<br />
I presume you applied the changes, could you post the updated parser (even if it’s not the final one)?</p>
<blockquote>
<p dir="auto">I guess this could be handled with regex</p>
</blockquote>
<p dir="auto">Possibly.</p>
<blockquote>
<p dir="auto">but I will not try.</p>
</blockquote>
<p dir="auto">Wise, keep it as challenge for an other revision :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23332</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23332</guid><dc:creator><![CDATA[MAPJe71]]></dc:creator><pubDate>Wed, 05 Apr 2017 00:26:20 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Wed, 05 Apr 2017 00:07:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mapje71" aria-label="Profile: MAPJe71">@<bdi>MAPJe71</bdi></a></p>
<p dir="auto">The “block comment problem” disappeared as a result of changes of the &lt;parser&gt;, which have no obvious coupling to comments. Strange!</p>
<blockquote>
<p dir="auto">MATLAB syntax allows continuation lines.  Could you give an example?</p>
</blockquote>
<pre><code>function ...
    WeirdUseOfContinuationLine ( ...
    str )
    disp( str )
    % This runs as expexted.
end
</code></pre>
<p dir="auto">I guess this could be handled with regex, but I will not try.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23331</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23331</guid><dc:creator><![CDATA[Per Isakson]]></dc:creator><pubDate>Wed, 05 Apr 2017 00:07:19 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Sat, 25 Mar 2017 03:09:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/per-isakson" aria-label="Profile: Per-Isakson">@<bdi>Per-Isakson</bdi></a></p>
<blockquote>
<p dir="auto">The “block comment problem” … put it near the bottom of your priority list.</p>
</blockquote>
<p dir="auto">For me it’s not a MATLAB parser problem only it’s more a FunctionList engine problem …</p>
<ol>
<li>why does it work for other parsers (or at least seems to)?</li>
<li>why does the comment expression work correctly with MATLAB source in RegexBuddy and with ClaudiaFrank’s RegexTester script in Notepad++ but apparently not with Notepad++ Function List engine?</li>
<li>why does the comment expression work correctly when the <code>classRange</code> part of the parser is omitted?</li>
</ol>
<blockquote>
<p dir="auto">this MATLAB &lt;parser&gt; is an exercise … Let me make a more complete version.</p>
</blockquote>
<p dir="auto">I expect “Function List Update 3” PR not to be the last one, so it’s possible to include it in a later update/PR or you could do your own PR.<br />
Either way I’d appreciate it when you keep me in the loop :)</p>
<blockquote>
<p dir="auto">MATLAB syntax allows continuation lines.</p>
</blockquote>
<p dir="auto">Could you give an example?</p>
<blockquote>
<p dir="auto">MATLAB syntax allows definition of class methods (/functions) in separate files.</p>
</blockquote>
<p dir="auto">Not supported as FunctionList operates per file.</p>
<blockquote>
<p dir="auto">Indentation is not significant …</p>
</blockquote>
<p dir="auto">That will make it a challenge to determine the <code>end</code> of a class definition! Determining the <code>end</code> of a function/method definition may not be necessary.</p>
<blockquote>
<p dir="auto">I’ll be back with a new version of the &lt;parser&gt;.</p>
</blockquote>
<p dir="auto">Looking forward to it!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23027</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23027</guid><dc:creator><![CDATA[MAPJe71]]></dc:creator><pubDate>Sat, 25 Mar 2017 03:09:00 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Sat, 25 Mar 2017 01:20:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mapje71" aria-label="Profile: MAPJe71">@<bdi>MAPJe71</bdi></a></p>
<p dir="auto">The “block comment problem”  is still there, but it is <strong>NOT</strong> an issue to me. This problem exists even in the MATLAB IDE. Commenting out code is an anti-pattern. Thus, put it near the bottom of your priority list.</p>
<p dir="auto"><em>“Yes, I intend to include it in PR “Function List Update 3””</em></p>
<p dir="auto">I like that! However, this MATLAB &lt;parser&gt; is an exercise. I guess, it will not be very helpful in serious work. Let me make a more complete version.</p>
<p dir="auto">A “full” &lt;parser&gt; as the first step was obviously a too big an undertaking for me. Now I intend to make a “full” &lt;parser&gt;. However, I see some problems.</p>
<ul>
<li>MATLAB syntax allows continuation lines. Any line may be split into two or more lines. I have failed to handle this with MATLAB regular expressions. I’m not tempted to try again. (Minor issue.)</li>
<li>MATLAB syntax allows definition of class methods (/functions) in separate files. I don’t use that, but it is frequently used by The Mathworks and many users. I cannot see any possibility to handle this.</li>
<li>Indentation is not significant; <code>end</code> is used to close nearly all blocks; and ordinary functions may be defined at the end of class definition files. Together these three pose a major challenge. (My <code>^\h{2,}</code> was a quick and dirty way to handle this.)</li>
</ul>
<p dir="auto">I think, I will use the functionList in two different scenarios, which ask for different versions of the &lt;parser&gt;:</p>
<ul>
<li>Navigation in code, which I know fairly well, e.g. my own old code. In this case I would prefer the functionList to show names only, which is cleaner and fits in a narrow plane.</li>
<li>Analysis of code, which I download from the Internet. In this  case I think the full signature is more useful. (Like in my current exercise.)</li>
</ul>
<p dir="auto"><strong>Conclusion: I’ll be back with a new version of the &lt;parser&gt;.</strong></p>
]]></description><link>https://community.notepad-plus-plus.org/post/23023</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23023</guid><dc:creator><![CDATA[Per Isakson]]></dc:creator><pubDate>Sat, 25 Mar 2017 01:20:47 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Fri, 24 Mar 2017 15:35:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/per-isakson" aria-label="Profile: Per-Isakson">@<bdi>Per-Isakson</bdi></a> glad to hear it works!</p>
<blockquote>
<p dir="auto">Your code works perfectly.</p>
</blockquote>
<p dir="auto">Does this mean the “block comment problem” is no longer an issue for you?</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chcg" aria-label="Profile: chcg">@<bdi>chcg</bdi></a> Yes, I intend to include it in PR “Function List Update 3”.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/22999</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/22999</guid><dc:creator><![CDATA[MAPJe71]]></dc:creator><pubDate>Fri, 24 Mar 2017 15:35:20 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Fri, 24 Mar 2017 08:24:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mapje71" aria-label="Profile: MAPJe71">@<bdi>MAPJe71</bdi></a><br />
Will you take care of creating a functionlist PR for matlab out of this for N++?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/22988</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/22988</guid><dc:creator><![CDATA[chcg]]></dc:creator><pubDate>Fri, 24 Mar 2017 08:24:26 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Fri, 24 Mar 2017 07:07:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/claudia-frank" aria-label="Profile: Claudia-Frank">@<bdi>Claudia-Frank</bdi></a></p>
<p dir="auto">Thank you for the link.</p>
<p dir="auto">How can I earn two points to be allowed to send two post directly after each other.</p>
<p dir="auto">Cheers<br />
Per</p>
]]></description><link>https://community.notepad-plus-plus.org/post/22985</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/22985</guid><dc:creator><![CDATA[Per Isakson]]></dc:creator><pubDate>Fri, 24 Mar 2017 07:07:55 GMT</pubDate></item><item><title><![CDATA[Reply to Trouble making a functionList parser for MATLAB on Fri, 24 Mar 2017 05:56:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mapje71" aria-label="Profile: MAPJe71">@<bdi>MAPJe71</bdi></a></p>
<p dir="auto">Thank you very much for your prompt and detailed answer. Your code works perfectly. Together with your explanation, it  helped me better understand the working of functionList, which in turn effectively helped me to spot my mistakes.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/22983</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/22983</guid><dc:creator><![CDATA[Per Isakson]]></dc:creator><pubDate>Fri, 24 Mar 2017 05:56:56 GMT</pubDate></item></channel></rss>