scilab.js 2.1 KB

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