scilab.js 1.7 KB

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