diff --git a/Matlab.tmbundle/Syntaxes/MATLAB.tmLanguage b/Matlab.tmbundle/Syntaxes/MATLAB.tmLanguage
index bed5307..7c10f63 100644
--- a/Matlab.tmbundle/Syntaxes/MATLAB.tmLanguage
+++ b/Matlab.tmbundle/Syntaxes/MATLAB.tmLanguage
@@ -751,38 +751,8 @@
patterns
- comment
- 1 property name 2 size 3 type 4 validator function
- match
- ^\s*([a-zA-Z][a-zA-Z0-9_]*)\s*(\([^\)]*\))?\s*([a-zA-Z][a-zA-Z0-9_\.]*)?\s*({[^}]*})?\s*(.*)$
- captures
-
- 2
-
- name
- storage.type.matlab
-
- 3
-
- name
- storage.type.matlab
-
- 4
-
- name
- storage.type.matlab
-
- 5
-
- patterns
-
-
- include
- $self
-
-
-
-
+ include
+ #validators
include
@@ -1216,6 +1186,61 @@
+
+ begin
+ (?x)
+ (^\s*) # Leading whitespace
+ (arguments)\b(.*)$
+ \s*
+ ( # Optional attributes
+ \( [^)]* \)
+ )?
+ \s*($|(?=%))
+
+ beginCaptures
+
+ 2
+
+ name
+ keyword.control.arguments.matlab
+
+ 3
+
+ patterns
+
+
+ match
+ [a-zA-Z][a-zA-Z0-9_]*
+ name
+ variable.parameter.arguments.matlab
+
+
+
+
+ end
+ ^\s*(end)\b
+ endCaptures
+
+ 1
+
+ name
+ keyword.control.end.arguments.matlab
+
+
+ name
+ meta.arguments.matlab
+ patterns
+
+
+ include
+ #validators
+
+
+ include
+ $self
+
+
+
include
$self
@@ -1428,6 +1453,229 @@
name
keyword.operator.symbols.matlab
+ validators
+
+ comment
+ Property and argument validation. Match an identifier allowing . and ?.
+ begin
+ \s*[,;]?\s*([a-zA-Z][a-zA-Z0-9_\.\?]*)
+ end
+ ([,;\n%=].*)
+ endCaptures
+
+ 1
+
+ patterns
+
+
+ comment
+ Match comments
+ match
+ ([%].*)
+ captures
+
+ 1
+
+ patterns
+
+
+ include
+ $self
+
+
+
+
+
+
+ comment
+ Handle things like arg = val; nextArg
+ match
+ (=[^;,]*)
+ captures
+
+ 1
+
+ patterns
+
+
+ include
+ $self
+
+
+
+
+
+
+ comment
+ End of property/argument patterns which start a new property/argument
+ match
+ ([\n,;].*)
+ captures
+
+ 1
+
+ patterns
+
+
+ include
+ #validators
+
+
+
+
+
+
+
+
+ patterns
+
+
+ include
+ #line_continuation
+
+
+ comment
+ Size declaration
+ match
+ \s*(\([^\)]*\))
+ name
+ storage.type.matlab
+
+
+ comment
+ Type declaration
+ match
+ ([a-zA-Z][a-zA-Z0-9_\.]*)
+ name
+ storage.type.matlab
+
+
+ include
+ #braced_validator_list
+
+
+
+ braced_validator_list
+
+ comment
+ Validator functions. Treated as a recursive group to permit nested brackets, quotes, etc.
+ begin
+ \s*({)\s*
+ beginCaptures
+
+ 1
+
+ name
+ storage.type.matlab
+
+
+ end
+ (})
+ endCaptures
+
+ 1
+
+ name
+ storage.type.matlab
+
+
+ patterns
+
+
+ include
+ #braced_validator_list
+
+
+ include
+ #validator_strings
+
+
+ include
+ #line_continuation
+
+
+ match
+ ([^{}}'"\.]+)
+ captures
+
+ 1
+
+ name
+ storage.type.matlab
+
+
+
+
+ match
+ \.
+ name
+ storage.type.matlab
+
+
+
+ validator_strings
+
+ comment
+ Simplified string patterns nested inside validator functions which don't change scopes of matches.
+ patterns
+
+
+ patterns
+
+
+ begin
+ ((?<=(\[|\(|\{|=|\s|;|:|,|~|<|>|&|\||-|\+|\*|/|\\|\.|\^))|^)'
+ comment
+ Character vector literal (single-quoted)
+ end
+ '(?=(\[|\(|\{|\]|\)|\}|=|~|<|>|&|\||-|\+|\*|/|\\|\.|\^|\s|;|:|,))
+ name
+ storage.type.matlab
+ patterns
+
+
+ match
+ ''
+
+
+ match
+ '(?=.)
+
+
+ match
+ ([^']+)
+
+
+
+
+ begin
+ ((?<=(\[|\(|\{|=|\s|;|:|,|~|<|>|&|\||-|\+|\*|/|\\|\.|\^))|^)"
+ comment
+ String literal (double-quoted)
+ end
+ "(?=(\[|\(|\{|\]|\)|\}|=|~|<|>|&|\||-|\+|\*|/|\\|\.|\^|\||\s|;|:|,))
+ name
+ storage.type.matlab
+ patterns
+
+
+ match
+ ""
+
+
+ match
+ "(?=.)
+
+
+ match
+ [^"]+
+
+
+
+
+
+
+
scopeName
source.matlab
diff --git a/argumentValidation.m b/argumentValidation.m
new file mode 100644
index 0000000..896df39
--- /dev/null
+++ b/argumentValidation.m
@@ -0,0 +1,20 @@
+function argumentValidation(x,~,v,method,flag, opts)
+ % Comment before arguments blocks
+ arguments
+ % Block comment
+ x (1,:) {mustBeNumeric,mustBeReal} % trailing coment
+ ~
+ % Line comment
+ v (1,:) {mustBeNumeric,mustBeReal, mustBeEqualSize(v,x)}
+ method (1,:) char {mustBeMember(method,{'linear','cubic','spline'})} = 'linear' % End of line comment
+ % End block comment
+ end
+ arguments (Repeating)
+ % Trailing flags
+ flag (1,:) string {mustBeMember(flag,["first","second","third"])}
+ end
+ arguments
+ opts.Named (1,:) string {mustBeNumeric(opts.Named), ... Dotdotdot comment
+ mustBeReal}
+ end
+end
\ No newline at end of file