Permalink
Browse files

• Borrowed the function scope from the ruby bundle, and adjusted it.

• Added preferences to control the symbol list


git-svn-id: http://svn.textmate.org/trunk/Bundles/Matlab.tmbundle@9576 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information...
1 parent 7c4f739 commit ca1e5cf364b17488713f407d32fd403782c32dd2 @mattfoster mattfoster committed May 15, 2008
Showing with 119 additions and 0 deletions.
  1. +22 −0 Preferences/Symbols.tmPreferences
  2. +86 −0 Syntaxes/M.plist
  3. +10 −0 Tests/test_functions.m
  4. +1 −0 info.plist
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>name</key>
+ <string>Symbol List: Functions</string>
+ <key>scope</key>
+ <string>source.matlab meta.function.with-arguments, source.matlab meta.function.without-arguments</string>
+ <key>settings</key>
+ <dict>
+ <key>showInSymbolList</key>
+ <integer>1</integer>
+ <key>symbolTransformation</key>
+ <string>
+ s/^\s*function\s+//;
+ s/(?&gt;.*=)\s*//; # remove output args
+ </string>
+ </dict>
+ <key>uuid</key>
+ <string>5EC2B9C8-1311-4C27-A421-A7982E6418AA</string>
+</dict>
+</plist>
View
@@ -218,6 +218,92 @@
</array>
</dict>
<dict>
+ <key>begin</key>
+ <string>(?x)
+ (?=function\b) # borrowed from ruby bundle
+ (?&lt;=^|\s)(function)\s+ # the function keyword
+ (?&gt;\[(.*)\])? # match various different combination of output arguments
+ ((?&gt;[a-zA-Z_]\w*))?
+ (?&gt;\s*=\s*)?
+ ((?&gt;[a-zA-Z_]\w*(?&gt;[?!]|=(?!&gt;))? )) # the function name
+ (?=[ \t]*[^\s%]) # make sure arguments and not a comment follow
+ \s*(\() # the opening parenthesis for arguments
+ </string>
+ <key>beginCaptures</key>
+ <dict>
+ <key>1</key>
+ <dict>
+ <key>name</key>
+ <string>keyword.control.function.matlab</string>
+ </dict>
+ <key>2</key>
+ <dict>
+ <key>name</key>
+ <string>variable.parameter.output.function.matlab</string>
+ </dict>
+ <key>3</key>
+ <dict>
+ <key>name</key>
+ <string>variable.parameter.output.function.matlab</string>
+ </dict>
+ <key>4</key>
+ <dict>
+ <key>name</key>
+ <string>entity.name.function.matlab</string>
+ </dict>
+ </dict>
+ <key>contentName</key>
+ <string>variable.parameter.input.function.matlab</string>
+ <key>end</key>
+ <string>\)</string>
+ <key>endCaptures</key>
+ <dict>
+ <key>0</key>
+ <dict>
+ <key>name</key>
+ <string>punctuation.definition.parameters.matlab</string>
+ </dict>
+ </dict>
+ <key>name</key>
+ <string>meta.function.with-arguments.matlab</string>
+ </dict>
+ <dict>
+ <key>captures</key>
+ <dict>
+ <key>1</key>
+ <dict>
+ <key>name</key>
+ <string>keyword.control.function.matlab</string>
+ </dict>
+ <key>2</key>
+ <dict>
+ <key>name</key>
+ <string>variable.parameter.output.function.matlab</string>
+ </dict>
+ <key>3</key>
+ <dict>
+ <key>name</key>
+ <string>variable.parameter.output.function.matlab</string>
+ </dict>
+ <key>4</key>
+ <dict>
+ <key>name</key>
+ <string>entity.name.function.matlab</string>
+ </dict>
+ </dict>
+ <key>match</key>
+ <string>(?x)
+ (?=function\b) # borrowed from ruby bundle
+ (?&lt;=^|\s)(function)\s+ # the function keyword
+ (?&gt;\[(.*)\])? # match various different combination of output arguments
+ ((?&gt;[a-zA-Z_]\w*))?
+ (?&gt;\s*=\s*)?
+ ((?&gt;[a-zA-Z_]\w*(?&gt;[?!]|=(?!&gt;))? )) # the function name
+ </string>
+ <key>name</key>
+ <string>meta.function.without-arguments.matlab</string>
+ </dict>
+ <dict>
<key>match</key>
<string>\b(all_va_args|clf|endfor|if|break|endfunction|persistent|catch|endif|return|continue|endwhile|endswitch|try|else|for|unwind_protect|elseif|function|unwind_protect_cleanup|end|global|while|end_try_catch|gplot|end_unwind_protect|gsplot|switch)\b</string>
<key>name</key>
View
@@ -0,0 +1,10 @@
+function [a, b, c] = test_both(a, b, c) % Both input and output arguments
+function a = test_both(a, b, c)
+function test_input(a, b, c)
+function test_neither
+function aa = test
+
+% TODO: Highly crazy, and yet valid syntax.
+% at least it's detected as a function!
+function bb = test3 ...
+ (a, b, c)
View
@@ -135,6 +135,7 @@
<string>9FF80E01-2981-4D11-8E87-872FCCD0304E</string>
<string>41EA6496-FA26-4F74-90B1-F316A4C451AE</string>
<string>FCA472FC-0F54-4C92-BFE1-00880FE1DA3F</string>
+ <string>5EC2B9C8-1311-4C27-A421-A7982E6418AA</string>
</array>
<key>uuid</key>
<string>AF26E7BD-72FF-11D9-B408-000D93589AF6</string>

0 comments on commit ca1e5cf

Please sign in to comment.