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