scilab.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. var COMMON_CONTAINS = [
  11. hljs.C_NUMBER_MODE,
  12. {
  13. className: 'string',
  14. begin: '\'|\"', end: '\'|\"',
  15. contains: [hljs.BACKSLASH_ESCAPE, {begin: '\'\''}]
  16. }
  17. ];
  18. return {
  19. name: 'Scilab',
  20. aliases: ['sci'],
  21. keywords: {
  22. $pattern: /%?\w+/,
  23. keyword: 'abort break case clear catch continue do elseif else endfunction end for function '+
  24. 'global if pause return resume select try then while',
  25. literal:
  26. '%f %F %t %T %pi %eps %inf %nan %e %i %z %s',
  27. built_in: // Scilab has more than 2000 functions. Just list the most commons
  28. 'abs and acos asin atan ceil cd chdir clearglobal cosh cos cumprod deff disp error '+
  29. 'exec execstr exists exp eye gettext floor fprintf fread fsolve imag isdef isempty '+
  30. 'isinfisnan isvector lasterror length load linspace list listfiles log10 log2 log '+
  31. 'max min msprintf mclose mopen ones or pathconvert poly printf prod pwd rand real '+
  32. 'round sinh sin size gsort sprintf sqrt strcat strcmps tring sum system tanh tan '+
  33. 'type typename warning zeros matrix'
  34. },
  35. illegal: '("|#|/\\*|\\s+/\\w+)',
  36. contains: [
  37. {
  38. className: 'function',
  39. beginKeywords: 'function', end: '$',
  40. contains: [
  41. hljs.UNDERSCORE_TITLE_MODE,
  42. {
  43. className: 'params',
  44. begin: '\\(', end: '\\)'
  45. }
  46. ]
  47. },
  48. {
  49. begin: '[a-zA-Z_][a-zA-Z_0-9]*(\'+[\\.\']*|[\\.\']+)', end: '',
  50. relevance: 0
  51. },
  52. {
  53. begin: '\\[', end: '\\]\'*[\\.\']*',
  54. relevance: 0,
  55. contains: COMMON_CONTAINS
  56. },
  57. hljs.COMMENT('//', '$')
  58. ].concat(COMMON_CONTAINS)
  59. };
  60. }
  61. module.exports = scilab;