Skip to content

Commit

Permalink
Merge pull request #73 from watermarkhu/function_definition_multiline
Browse files Browse the repository at this point in the history
Fixes for multiple function definitions
  • Loading branch information
dklilley authored Feb 20, 2024
2 parents 63debc7 + 34843a3 commit f353382
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 63 deletions.
66 changes: 35 additions & 31 deletions Matlab.tmbundle/Syntaxes/MATLAB.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
<key>begin</key>
<string>(?&lt;=\))[^\S\n]*(\()?</string>
<key>end</key>
<string>(\))?[^\S\n]*(?=;|(?&lt;!(?:\.\.\..*))\n|%)</string>
<string>(\))?[^\S\n]*(?=;|(?&lt;!(?:\.{3}.*))\n|%)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
Expand Down Expand Up @@ -262,7 +262,7 @@
</dict>
</array>
<key>end</key>
<string>(?=;|(?&lt;!(?:\.\.\..*))\n|%)</string>
<string>(?=;|(?&lt;!(?:\.{3}.*))\n|%)</string>
</dict>
<key>blocks</key>
<dict>
Expand Down Expand Up @@ -299,7 +299,7 @@
<key>begin</key>
<string>\G(?!$)</string>
<key>end</key>
<string>(?&lt;!\.\.\.)(?:(?=([,;])(?![^(]*\)))|$)</string>
<string>(?&lt;!\.{3})(?:(?=([,;])(?![^(]*\)))|$)</string>
<key>patterns</key>
<array>
<dict>
Expand Down Expand Up @@ -355,7 +355,7 @@
<key>begin</key>
<string>\G(?!$)</string>
<key>end</key>
<string>(?&lt;!\.\.\.)(?:(?=([,;])(?![^(]*\)))|$)</string>
<string>(?&lt;!\.{3})(?:(?=([,;])(?![^(]*\)))|$)</string>
<key>patterns</key>
<array>
<dict>
Expand Down Expand Up @@ -385,7 +385,7 @@
<key>begin</key>
<string>\G(?!$)</string>
<key>end</key>
<string>(?&lt;!\.\.\.)(?:(?=([,;])(?![^(]*\)))|$)</string>
<string>(?&lt;!\.{3})(?:(?=([,;])(?![^(]*\)))|$)</string>
<key>patterns</key>
<array>
<dict>
Expand Down Expand Up @@ -449,7 +449,7 @@
<key>begin</key>
<string>\G(?!$)</string>
<key>end</key>
<string>(?&lt;!\.\.\.)(?:(?=([,;])(?![^(]*\)))|$)</string>
<string>(?&lt;!\.{3})(?:(?=([,;])(?![^(]*\)))|$)</string>
<key>patterns</key>
<array>
<dict>
Expand Down Expand Up @@ -495,7 +495,7 @@
<key>begin</key>
<string>\G(?!$)</string>
<key>end</key>
<string>(?&lt;!\.\.\.)(?:(?=([,;])(?![^(]*\)))|$)</string>
<string>(?&lt;!\.{3})(?:(?=([,;])(?![^(]*\)))|$)</string>
<key>patterns</key>
<array>
<dict>
Expand Down Expand Up @@ -544,7 +544,7 @@
<key>name</key>
<string>meta.case.matlab</string>
<key>match</key>
<string>(\s*)(?&lt;=^|[\s,;])(case)\b(.*?)(?&lt;!\.\.\.)(?:(?=([,;])(?![^(]*\)))|$)</string>
<string>(\s*)(?&lt;=^|[\s,;])(case)\b(.*?)(?&lt;!\.{3})(?:(?=([,;])(?![^(]*\)))|$)</string>
<key>captures</key>
<dict>
<key>2</key>
Expand All @@ -559,7 +559,7 @@
<key>begin</key>
<string>\G(?!$)</string>
<key>end</key>
<string>(?&lt;!\.\.\.)(?:(?=([,;])(?![^(]*\)))|$)</string>
<string>(?&lt;!\.{3})(?:(?=([,;])(?![^(]*\)))|$)</string>
<key>patterns</key>
<array>
<dict>
Expand Down Expand Up @@ -681,7 +681,7 @@
<key>begin</key>
<string>\G</string>
<key>end</key>
<string>(?&lt;!\.\.\.)(?:(?=([,;])(?![^(]*\)))|$)</string>
<string>(?&lt;!\.{3})(?:(?=([,;])(?![^(]*\)))|$)</string>
<key>endCaptures</key>
<dict>
<key>1</key>
Expand Down Expand Up @@ -740,7 +740,7 @@
<key>begin</key>
<string>\G</string>
<key>end</key>
<string>(?&lt;!\.\.\.)(?=\n)</string>
<string>(?&lt;!\.{3})(?=\n)</string>
<key>patterns</key>
<array>
<dict>
Expand Down Expand Up @@ -832,7 +832,7 @@
</dict>
</dict>
<key>end</key>
<string>(?&lt;!\.\.\.)(?=\n)</string>
<string>(?&lt;!\.{3})(?=\n)</string>
<key>patterns</key>
<array>
<dict>
Expand Down Expand Up @@ -902,7 +902,7 @@
</dict>
</array>
<key>end</key>
<string>(?&lt;!\.\.\.)(?=\s*%|\n)</string>
<string>(?&lt;!\.{3})(?=\s*%|\n)</string>
</dict>
</array>
</dict>
Expand Down Expand Up @@ -1251,7 +1251,7 @@
<key>comment</key>
<string> 1 2 3 4 </string>
<key>match</key>
<string>(?&lt;=^|[^.]\n|;|,|=)([^\S\n]*)(?# A&gt; )(\b\w+\b)([^\S\n]+)(?# B&gt; )((?!(\+|-|\*|\.\*|\/|\.\/|\\|\.\\|\^|\.\^|==|~=|&amp;|&amp;&amp;|\||\|\||=|:|&gt;|&gt;=|&lt;|&lt;=|\.\.\.)[^\S\n]?)[^\s({=;%][^\n;%]*)</string>
<string>(?&lt;=^|[^.]\n|;|,|=)([^\S\n]*)(?# A&gt; )(\b\w+\b)([^\S\n]+)(?# B&gt; )((?!(\+|-|\*|\.\*|\/|\.\/|\\|\.\\|\^|\.\^|==|~=|&amp;|&amp;&amp;|\||\|\||=|:|&gt;|&gt;=|&lt;|&lt;=|\.{3})[^\S\n]?)[^\s({=;%][^\n;%]*)</string>
</dict>
<key>comment_block</key>
<dict>
Expand Down Expand Up @@ -1454,7 +1454,7 @@
<key>begin</key>
<string>\G</string>
<key>end</key>
<string>(?&lt;=[\)\n])</string>
<string>(?&lt;=\))|(?&gt;(?&lt;!\.{3}.*)\n)</string>
<key>patterns</key>
<array>
<dict>
Expand All @@ -1463,7 +1463,7 @@
<key>contentName</key>
<string>meta.assignment.variable.output.matlab</string>
<key>begin</key>
<string>\G(?=.*?=)</string>
<string>\G(?=[^\(]*?(?:=|\[|\.{3}))</string>
<key>end</key>
<string>\s*(=)\s*</string>
<key>endCaptures</key>
Expand All @@ -1484,7 +1484,7 @@
</dict>
<dict>
<key>match</key>
<string>(\])\s*\z</string>
<string>(\])\s*</string>
<key>captures</key>
<dict>
<key>1</key>
Expand All @@ -1508,11 +1508,11 @@
</dict>
<dict>
<key>include</key>
<string>#comments</string>
<string>#line_continuation</string>
</dict>
<dict>
<key>include</key>
<string>#line_continuation</string>
<string>#comments</string>
</dict>
</array>
</dict>
Expand All @@ -1522,7 +1522,7 @@
<key>name</key>
<string>entity.name.function.matlab</string>
<key>match</key>
<string>[a-zA-Z][a-zA-Z0-9_.]*(?=[^a-zA-Z0-9_.])</string>
<string>[a-zA-Z][a-zA-Z0-9_]*(?&gt;\.[a-zA-Z0-9_]+)*</string>
<key>patterns</key>
<array>
<dict>
Expand All @@ -1543,7 +1543,7 @@
<key>name</key>
<string>meta.parameters.matlab</string>
<key>begin</key>
<string>(?&lt;=[a-zA-Z0-9_])\s*\(</string>
<string>\s*\(</string>
<key>end</key>
<string>\)</string>
<key>beginCaptures</key>
Expand Down Expand Up @@ -1592,6 +1592,10 @@
</dict>
</array>
</dict>
<dict>
<key>include</key>
<string>#line_continuation</string>
</dict>
<dict>
<key>include</key>
<string>#comments</string>
Expand Down Expand Up @@ -1695,7 +1699,7 @@
<key>begin</key>
<string>([a-zA-Z][a-zA-Z0-9_]*)\s*(\()</string>
<key>end</key>
<string>(\)|(?&lt;!\.\.\..*)\n)</string>
<string>(\)|(?&lt;!\.{3}.*)\n)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
Expand Down Expand Up @@ -1807,7 +1811,7 @@
<key>begin</key>
<string>([a-zA-Z][a-zA-Z0-9_]*)\s*(\.)(\()</string>
<key>end</key>
<string>(\)|(?&lt;!\.\.\..*)\n)</string>
<string>(\)|(?&lt;!\.{3}.*)\n)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
Expand Down Expand Up @@ -1907,7 +1911,7 @@
<key>begin</key>
<string>\(</string>
<key>end</key>
<string>(\)|(?&lt;!\.\.\..*)\n)</string>
<string>(\)|(?&lt;!\.{3}.*)\n)</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
Expand Down Expand Up @@ -2078,7 +2082,7 @@
</dict>
</dict>
<key>end</key>
<string>(\}|(?&lt;!\.\.\..*)\n)</string>
<string>(\}|(?&lt;!\.{3}.*)\n)</string>
<key>comment</key>
<string>We don't include $self here to avoid matching command syntax inside (), [], {}</string>
<key>patterns</key>
Expand Down Expand Up @@ -2117,7 +2121,7 @@
</dict>
</dict>
<key>match</key>
<string>(\.\.\.)(.*)$</string>
<string>(\.{3})(.*)$</string>
</dict>
<key>shell_string</key>
<dict>
Expand Down Expand Up @@ -2273,7 +2277,7 @@
<key>begin</key>
<string>([a-zA-Z][a-zA-Z0-9_]*)(@)\s*([a-zA-Z][a-zA-Z0-9_]*(?:\.[a-zA-Z][a-zA-Z0-9_]*)*)(\()</string>
<key>end</key>
<string>(\)|(?&lt;!\.\.\..*)\n)</string>
<string>(\)|(?&lt;!\.{3}.*)\n)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
Expand Down Expand Up @@ -2508,15 +2512,15 @@
<key>name</key>
<string>keyword.operator.arithmetic.matlab</string>
<key>match</key>
<string>(?&lt;=[a-zA-Z0-9\s])(\+|-|\*|\.\*|/|\./|\\|\.\\|\^|\.\^)(?=[a-zA-Z0-9\s]|(?:\.\.\.))</string>
<string>(?&lt;=[a-zA-Z0-9\s])(\+|-|\*|\.\*|/|\./|\\|\.\\|\^|\.\^)(?=[a-zA-Z0-9\s]|(?:\.{3}))</string>
</dict>
<dict>
<key>comment</key>
<string>Operator symbols</string>
<key>name</key>
<string>keyword.operator.logical.matlab</string>
<key>match</key>
<string>(?&lt;=[a-zA-Z0-9\s])(==|~=|&amp;|&amp;&amp;|\||\|\|)(?=[a-zA-Z0-9\s]|(?:\.\.\.))</string>
<string>(?&lt;=[a-zA-Z0-9\s])(==|~=|&amp;|&amp;&amp;|\||\|\|)(?=[a-zA-Z0-9\s]|(?:\.{3}))</string>
</dict>
<dict>
<key>comment</key>
Expand All @@ -2532,15 +2536,15 @@
<key>name</key>
<string>keyword.operator.vector.colon.matlab</string>
<key>match</key>
<string>(?&lt;=[a-zA-Z0-9_\s(){,]|^):(?=[a-zA-Z0-9_\s()},]|$||(?:\.\.\.))</string>
<string>(?&lt;=[a-zA-Z0-9_\s(){,]|^):(?=[a-zA-Z0-9_\s()},]|$||(?:\.{3}))</string>
</dict>
<dict>
<key>comment</key>
<string>Comparative operators</string>
<key>name</key>
<string>keyword.operator.relational.matlab</string>
<key>match</key>
<string>(?&lt;=[a-zA-Z0-9\s])(&gt;|&gt;=|&lt;|&lt;=)(?=[a-zA-Z0-9\s]|(?:\.\.\.))</string>
<string>(?&lt;=[a-zA-Z0-9\s])(&gt;|&gt;=|&lt;|&lt;=)(?=[a-zA-Z0-9\s]|(?:\.{3}))</string>
</dict>
</array>
</dict>
Expand Down
Loading

0 comments on commit f353382

Please sign in to comment.