UNPKG

2.14 kBJavaScriptView Raw
1/*
2Language: Scilab
3Author: Sylvestre Ledru <sylvestre.ledru@scilab-enterprises.com>
4Origin: matlab.js
5Description: Scilab is a port from Matlab
6Website: https://www.scilab.org
7Category: scientific
8*/
9
10function scilab(hljs) {
11 const COMMON_CONTAINS = [
12 hljs.C_NUMBER_MODE,
13 {
14 className: 'string',
15 begin: '\'|\"',
16 end: '\'|\"',
17 contains: [ hljs.BACKSLASH_ESCAPE,
18 {
19 begin: '\'\''
20 } ]
21 }
22 ];
23
24 return {
25 name: 'Scilab',
26 aliases: [ 'sci' ],
27 keywords: {
28 $pattern: /%?\w+/,
29 keyword: 'abort break case clear catch continue do elseif else endfunction end for function ' +
30 'global if pause return resume select try then while',
31 literal:
32 '%f %F %t %T %pi %eps %inf %nan %e %i %z %s',
33 built_in: // Scilab has more than 2000 functions. Just list the most commons
34 'abs and acos asin atan ceil cd chdir clearglobal cosh cos cumprod deff disp error ' +
35 'exec execstr exists exp eye gettext floor fprintf fread fsolve imag isdef isempty ' +
36 'isinfisnan isvector lasterror length load linspace list listfiles log10 log2 log ' +
37 'max min msprintf mclose mopen ones or pathconvert poly printf prod pwd rand real ' +
38 'round sinh sin size gsort sprintf sqrt strcat strcmps tring sum system tanh tan ' +
39 'type typename warning zeros matrix'
40 },
41 illegal: '("|#|/\\*|\\s+/\\w+)',
42 contains: [
43 {
44 className: 'function',
45 beginKeywords: 'function',
46 end: '$',
47 contains: [
48 hljs.UNDERSCORE_TITLE_MODE,
49 {
50 className: 'params',
51 begin: '\\(',
52 end: '\\)'
53 }
54 ]
55 },
56 // seems to be a guard against [ident]' or [ident].
57 // perhaps to prevent attributes from flagging as keywords?
58 {
59 begin: '[a-zA-Z_][a-zA-Z_0-9]*[\\.\']+',
60 relevance: 0
61 },
62 {
63 begin: '\\[',
64 end: '\\][\\.\']*',
65 relevance: 0,
66 contains: COMMON_CONTAINS
67 },
68 hljs.COMMENT('//', '$')
69 ].concat(COMMON_CONTAINS)
70 };
71}
72
73export { scilab as default };