forked from sublimehq/Packages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyntax_test_matlab.m
209 lines (176 loc) · 5.54 KB
/
syntax_test_matlab.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
% SYNTAX TEST "Packages/Matlab/Matlab.sublime-syntax"
%---------------------------------------------
% Matlab OOP test
classdef (Sealed = false) classname < baseclass
% <- keyword.other
% ^ variable.parameter
% ^ keyword.operator.symbols
% ^ constant.language
% ^ entity.name.class
% ^ entity.other.inherited-class
properties (SetAccess = private, GetAccess = true)
% ^ keyword.other
% ^ variable.parameter
% ^ constant.language
% ^ variable.parameter
PropName
end
% ^ keyword.control
methods
% ^ keyword.other
methodName
end
events
% ^ keyword.other
EventName
end
enumeration
% ^ keyword.other
EnumName
end
end
%---------------------------------------------
% Syntax brackets/parens punctuation test
x = [ 1.76 ]
% <- source.matlab meta.variable.other.valid.matlab
% ^ source.matlab keyword.operator.symbols.matlab
% ^ source.matlab punctuation.section.brackets.begin.matlab
% ^^^^ source.matlab meta.brackets.matlab constant.numeric.matlab
% ^ source.matlab punctuation.section.brackets.end.matlab
xAprox = fMetodoDeNewton( xi )
% <- source.matlab meta.variable.other.valid.matlab
% ^ source.matlab keyword.operator.symbols.matlab
% ^ source.matlab meta.variable.other.valid.matlab
% ^ source.matlab punctuation.section.parens.begin.matlab
% ^ source.matlab meta.parens.matlab meta.variable.other.valid.matlab
% ^ source.matlab punctuation.section.parens.end.matlab
%---------------------------------------------
% Block comment test
% Success case
%{
x = 5
% ^ source.matlab comment.block.percentage.matlab
%}
% Invalid block
%{ Not start of block comment
% ^ comment.line.percentage.matlab
x = 5
% ^ keyword.operator.symbols.matlab
%}
%{
%} Not end of block
% ^ comment.block.percentage.matlab
x = 5
% ^ comment.block.percentage.matlab
%}
x = 5 %{ not block comment
% ^ keyword.operator.symbols.matlab
x = 5
% ^ constant.numeric.matlab
%---------------------------------------------
% Function
function y = average(x)
% <- keyword.other
% ^ variable.parameter.output.function.matlab
% ^^^^^^^ entity.name.function.matlab
% ^ variable.parameter.input.function.matlab
if ~isvector(x)
% ^ keyword.operator.symbols.matlab
error('Input must be a vector')
end
y = sum(x)/length(x);
end
function [m,s] = stat(x)
% <- keyword.other
% ^ variable.parameter.output.function.matlab
% ^ -variable.parameter.output.function.matlab
% ^ variable.parameter.output.function.matlab
% ^ keyword.operator.assignment.matlab
% ^^^^ entity.name.function.matlab
% ^ variable.parameter.input.function.matlab
n = length(x);
m = sum(x)/n;
s = sqrt(sum((x-m).^2/n));
end
function m = avg(x,n)
% ^ variable.parameter.output.function.matlab
% ^^^ entity.name.function.matlab
% ^ variable.parameter.input.function.matlab
% ^ variable.parameter.input.function.matlab
m = sum(x)/n;
end
function foo(bar)
% <- keyword.other.matlab
% ^^^ entity.name.function.matlab
% ^^^ meta.function.parameters.matlab variable.parameter.input.function.matlab
end
function x = foo
% <- keyword.other.matlab
% ^ variable.parameter.output.function.matlab
% ^ keyword.operator.assignment.matlab
% ^^^ entity.name.function.matlab
end
function foo
% <- keyword.other.matlab
% ^^^ entity.name.function.matlab
end
function foo % with comment
% <- keyword.other.matlab
% ^^^ entity.name.function.matlab
end
%---------------------------------------------
% Numbers
1
% <- constant.numeric.matlab
.1
% <- constant.numeric.matlab
1.1
% <- constant.numeric.matlab
.1e1
% <- constant.numeric.matlab
1.1e1
% <- constant.numeric.matlab
1e1
% <- constant.numeric.matlab
1i
% <- constant.numeric.matlab
1j
% <- constant.numeric.matlab
1e2j
% <- constant.numeric.matlab
%---------------------------------------------
% transpose
a = a' % is the conjugate and transpose
% ^ -keyword.operator.transpose.matlab
% ^ keyword.operator.transpose.matlab
a = a.' % is the transpose
% ^ -keyword.operator.transpose.matlab
% ^^ keyword.operator.transpose.matlab
x = a[3]' + b(4)' % is the conjugate and transpose
% ^ keyword.operator.transpose.matlab
% ^ keyword.operator.transpose.matlab
l = {l.n}';
% ^ keyword.operator.transpose.matlab
%---------------------------------------------
% String
a = '%'
a = '.' % .'
% ^^^ comment.line.percentage.matlab
'a'a'
% ^ string.quoted.single.matlab invalid.illegal.unescaped-quote.matlab
%^ string.quoted.single.matlab punctuation.definition.string.begin.matlab
% ^ string.quoted.single.matlab
% ^ string.quoted.single.matlab punctuation.definition.string.end.matlab
regexprep(outloc,'.+\\','')
% ^ punctuation.definition.string.begin.matlab
% ^^ meta.parens.matlab string.quoted.single.matlab
% ^^ constant.character.escape.matlab
% ^ punctuation.definition.string.end.matlab
s1="00:06:57";
% ^ punctuation.definition.string.begin.matlab
% ^^^^^^^^ string.quoted.double.matlab
% ^ punctuation.definition.string.end.matlab
%---------------------------------------------
parfor x = 1:10
%^ keyword.control.matlab
end