1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | function matlab(hljs) {
|
14 | const TRANSPOSE_RE = '(\'|\\.\')+';
|
15 | const TRANSPOSE = {
|
16 | relevance: 0,
|
17 | contains: [ { begin: TRANSPOSE_RE } ]
|
18 | };
|
19 |
|
20 | return {
|
21 | name: 'Matlab',
|
22 | keywords: {
|
23 | keyword:
|
24 | 'arguments break case catch classdef continue else elseif end enumeration events for function '
|
25 | + 'global if methods otherwise parfor persistent properties return spmd switch try while',
|
26 | built_in:
|
27 | 'sin sind sinh asin asind asinh cos cosd cosh acos acosd acosh tan tand tanh atan '
|
28 | + 'atand atan2 atanh sec secd sech asec asecd asech csc cscd csch acsc acscd acsch cot '
|
29 | + 'cotd coth acot acotd acoth hypot exp expm1 log log1p log10 log2 pow2 realpow reallog '
|
30 | + 'realsqrt sqrt nthroot nextpow2 abs angle complex conj imag real unwrap isreal '
|
31 | + 'cplxpair fix floor ceil round mod rem sign airy besselj bessely besselh besseli '
|
32 | + 'besselk beta betainc betaln ellipj ellipke erf erfc erfcx erfinv expint gamma '
|
33 | + 'gammainc gammaln psi legendre cross dot factor isprime primes gcd lcm rat rats perms '
|
34 | + 'nchoosek factorial cart2sph cart2pol pol2cart sph2cart hsv2rgb rgb2hsv zeros ones '
|
35 | + 'eye repmat rand randn linspace logspace freqspace meshgrid accumarray size length '
|
36 | + 'ndims numel disp isempty isequal isequalwithequalnans cat reshape diag blkdiag tril '
|
37 | + 'triu fliplr flipud flipdim rot90 find sub2ind ind2sub bsxfun ndgrid permute ipermute '
|
38 | + 'shiftdim circshift squeeze isscalar isvector ans eps realmax realmin pi i|0 inf nan '
|
39 | + 'isnan isinf isfinite j|0 why compan gallery hadamard hankel hilb invhilb magic pascal '
|
40 | + 'rosser toeplitz vander wilkinson max min nanmax nanmin mean nanmean type table '
|
41 | + 'readtable writetable sortrows sort figure plot plot3 scatter scatter3 cellfun '
|
42 | + 'legend intersect ismember procrustes hold num2cell '
|
43 | },
|
44 | illegal: '(//|"|#|/\\*|\\s+/\\w+)',
|
45 | contains: [
|
46 | {
|
47 | className: 'function',
|
48 | beginKeywords: 'function',
|
49 | end: '$',
|
50 | contains: [
|
51 | hljs.UNDERSCORE_TITLE_MODE,
|
52 | {
|
53 | className: 'params',
|
54 | variants: [
|
55 | {
|
56 | begin: '\\(',
|
57 | end: '\\)'
|
58 | },
|
59 | {
|
60 | begin: '\\[',
|
61 | end: '\\]'
|
62 | }
|
63 | ]
|
64 | }
|
65 | ]
|
66 | },
|
67 | {
|
68 | className: 'built_in',
|
69 | begin: /true|false/,
|
70 | relevance: 0,
|
71 | starts: TRANSPOSE
|
72 | },
|
73 | {
|
74 | begin: '[a-zA-Z][a-zA-Z_0-9]*' + TRANSPOSE_RE,
|
75 | relevance: 0
|
76 | },
|
77 | {
|
78 | className: 'number',
|
79 | begin: hljs.C_NUMBER_RE,
|
80 | relevance: 0,
|
81 | starts: TRANSPOSE
|
82 | },
|
83 | {
|
84 | className: 'string',
|
85 | begin: '\'',
|
86 | end: '\'',
|
87 | contains: [ { begin: '\'\'' } ]
|
88 | },
|
89 | {
|
90 | begin: /\]|\}|\)/,
|
91 | relevance: 0,
|
92 | starts: TRANSPOSE
|
93 | },
|
94 | {
|
95 | className: 'string',
|
96 | begin: '"',
|
97 | end: '"',
|
98 | contains: [ { begin: '""' } ],
|
99 | starts: TRANSPOSE
|
100 | },
|
101 | hljs.COMMENT('^\\s*%\\{\\s*$', '^\\s*%\\}\\s*$'),
|
102 | hljs.COMMENT('%', '$')
|
103 | ]
|
104 | };
|
105 | }
|
106 |
|
107 | module.exports = matlab;
|