scilab.js 1.8 KB

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