-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
scilab.js
71 lines (69 loc) · 2.07 KB
/
scilab.js
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
/*
Language: Scilab
Author: Sylvestre Ledru <sylvestre.ledru@scilab-enterprises.com>
Origin: matlab.js
Description: Scilab is a port from Matlab
Website: https://www.scilab.org
Category: scientific
*/
export default function(hljs) {
const COMMON_CONTAINS = [
hljs.C_NUMBER_MODE,
{
className: 'string',
begin: '\'|\"',
end: '\'|\"',
contains: [
hljs.BACKSLASH_ESCAPE,
{ begin: '\'\'' }
]
}
];
return {
name: 'Scilab',
aliases: [ 'sci' ],
keywords: {
$pattern: /%?\w+/,
keyword: 'abort break case clear catch continue do elseif else endfunction end for function '
+ 'global if pause return resume select try then while',
literal:
'%f %F %t %T %pi %eps %inf %nan %e %i %z %s',
built_in: // Scilab has more than 2000 functions. Just list the most commons
'abs and acos asin atan ceil cd chdir clearglobal cosh cos cumprod deff disp error '
+ 'exec execstr exists exp eye gettext floor fprintf fread fsolve imag isdef isempty '
+ 'isinfisnan isvector lasterror length load linspace list listfiles log10 log2 log '
+ 'max min msprintf mclose mopen ones or pathconvert poly printf prod pwd rand real '
+ 'round sinh sin size gsort sprintf sqrt strcat strcmps tring sum system tanh tan '
+ 'type typename warning zeros matrix'
},
illegal: '("|#|/\\*|\\s+/\\w+)',
contains: [
{
className: 'function',
beginKeywords: 'function',
end: '$',
contains: [
hljs.UNDERSCORE_TITLE_MODE,
{
className: 'params',
begin: '\\(',
end: '\\)'
}
]
},
// seems to be a guard against [ident]' or [ident].
// perhaps to prevent attributes from flagging as keywords?
{
begin: '[a-zA-Z_][a-zA-Z_0-9]*[\\.\']+',
relevance: 0
},
{
begin: '\\[',
end: '\\][\\.\']*',
relevance: 0,
contains: COMMON_CONTAINS
},
hljs.COMMENT('//', '$')
].concat(COMMON_CONTAINS)
};
}