diff --git a/Matlab.tmbundle/Syntaxes/MATLAB.tmLanguage b/Matlab.tmbundle/Syntaxes/MATLAB.tmLanguage index 3026c3f..a116e88 100644 --- a/Matlab.tmbundle/Syntaxes/MATLAB.tmLanguage +++ b/Matlab.tmbundle/Syntaxes/MATLAB.tmLanguage @@ -114,6 +114,10 @@ include #curly_brackets + + include + #metaclass_literal + rules_after_command_dual @@ -827,41 +831,16 @@ true|false + comment + Metadata query for class properties name - meta.metaclass.matlab - begin - (\?) - beginCaptures - - 1 - - name - keyword.operator.other.question.matlab - - - end - (?=\)|,) - patterns - - - name - entity.other.class.matlab - match - (?<=[\s.<])[a-zA-Z][a-zA-Z0-9_]*(?=\s|,|\)) - - - name - entity.name.namespace.matlab - match - [a-zA-Z][a-zA-Z0-9_]* - - - name - punctuation.accessor.dot.matlab - match - \. - - + keyword.operator.other.question.matlab + match + (?<!\w)\?(?=\w) + + + include + #metaclass_literal include @@ -2992,7 +2971,7 @@ name variable.other.readwrite.matlab match - (?<![a-zA-Z0-9_]|\.)[a-zA-Z][a-zA-Z0-9_]*(?![a-zA-Z0-9_]|(?:\(|\{|\.\()) + (?<![a-zA-Z0-9_]|\.|\?)[a-zA-Z][a-zA-Z0-9_]*(?![a-zA-Z0-9_]|(?:\(|\{|\.\()) property_access @@ -3003,6 +2982,32 @@ match \. + metaclass_literal + + comment + Accessing a metaclass via the ? operator + name + meta.metaclass.matlab + begin + (?<=\?)(?=[a-zA-Z]) + end + (?<=[a-zA-Z0-9_])(?![a-zA-Z0-9_]|\.|\(|{) + patterns + + + name + entity.other.class.matlab + match + (?<=[.\?])[a-zA-Z][a-zA-Z0-9_]*(?![a-zA-Z0-9_.]) + + + name + entity.name.namespace.matlab + match + [a-zA-Z][a-zA-Z0-9_]* + + + diff --git a/test/t89MetaclassLiterals.m b/test/t89MetaclassLiterals.m new file mode 100644 index 0000000..be88c75 --- /dev/null +++ b/test/t89MetaclassLiterals.m @@ -0,0 +1,17 @@ +% SYNTAX TEST "source.matlab" "Metaclasses: https://github.com/mathworks/MATLAB-Language-grammar/issues/89" +classdef (AllowedSubclasses = {?SubClass1,?namespace1.SubClass2}) SuperClass +% ^^^^^^^^^ meta.metaclass.matlab entity.other.class.matlab +% ^^^^^^^^^^^^^^^^^^^^ meta.metaclass.matlab +% ^^^^^^^^^^ entity.name.namespace.matlab +% ^^^^^^^^^ entity.other.class.matlab + methods + function foo() + x = ?namespace2.cls +% ^^^^^^^^^^^^^^ meta.metaclass.matlab +% ^^^^^^^^^^ entity.name.namespace.matlab +% ^^^ entity.other.class.matlab + y = ?MyClass +% ^^^^^^^ meta.metaclass.matlab entity.other.class.matlab + end + end +end