matlab.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. Language: Matlab
  3. Author: Denis Bardadym <[email protected]>
  4. Contributors: Eugene Nizhibitsky <[email protected]>
  5. Category: scientific
  6. */
  7. function(hljs) {
  8. var COMMON_CONTAINS = [
  9. hljs.C_NUMBER_MODE,
  10. {
  11. className: 'string',
  12. begin: '\'', end: '\'',
  13. contains: [hljs.BACKSLASH_ESCAPE, {begin: '\'\''}]
  14. }
  15. ];
  16. var TRANSPOSE = {
  17. relevance: 0,
  18. contains: [
  19. {
  20. begin: /'['\.]*/
  21. }
  22. ]
  23. };
  24. return {
  25. keywords: {
  26. keyword:
  27. 'break case catch classdef continue else elseif end enumerated events for function ' +
  28. 'global if methods otherwise parfor persistent properties return spmd switch try while',
  29. built_in:
  30. 'sin sind sinh asin asind asinh cos cosd cosh acos acosd acosh tan tand tanh atan ' +
  31. 'atand atan2 atanh sec secd sech asec asecd asech csc cscd csch acsc acscd acsch cot ' +
  32. 'cotd coth acot acotd acoth hypot exp expm1 log log1p log10 log2 pow2 realpow reallog ' +
  33. 'realsqrt sqrt nthroot nextpow2 abs angle complex conj imag real unwrap isreal ' +
  34. 'cplxpair fix floor ceil round mod rem sign airy besselj bessely besselh besseli ' +
  35. 'besselk beta betainc betaln ellipj ellipke erf erfc erfcx erfinv expint gamma ' +
  36. 'gammainc gammaln psi legendre cross dot factor isprime primes gcd lcm rat rats perms ' +
  37. 'nchoosek factorial cart2sph cart2pol pol2cart sph2cart hsv2rgb rgb2hsv zeros ones ' +
  38. 'eye repmat rand randn linspace logspace freqspace meshgrid accumarray size length ' +
  39. 'ndims numel disp isempty isequal isequalwithequalnans cat reshape diag blkdiag tril ' +
  40. 'triu fliplr flipud flipdim rot90 find sub2ind ind2sub bsxfun ndgrid permute ipermute ' +
  41. 'shiftdim circshift squeeze isscalar isvector ans eps realmax realmin pi i inf nan ' +
  42. 'isnan isinf isfinite j why compan gallery hadamard hankel hilb invhilb magic pascal ' +
  43. 'rosser toeplitz vander wilkinson'
  44. },
  45. illegal: '(//|"|#|/\\*|\\s+/\\w+)',
  46. contains: [
  47. {
  48. className: 'function',
  49. beginKeywords: 'function', end: '$',
  50. contains: [
  51. hljs.UNDERSCORE_TITLE_MODE,
  52. {
  53. className: 'params',
  54. variants: [
  55. {begin: '\\(', end: '\\)'},
  56. {begin: '\\[', end: '\\]'}
  57. ]
  58. }
  59. ]
  60. },
  61. {
  62. begin: /[a-zA-Z_][a-zA-Z_0-9]*'['\.]*/,
  63. returnBegin: true,
  64. relevance: 0,
  65. contains: [
  66. {begin: /[a-zA-Z_][a-zA-Z_0-9]*/, relevance: 0},
  67. TRANSPOSE.contains[0]
  68. ]
  69. },
  70. {
  71. begin: '\\[', end: '\\]',
  72. contains: COMMON_CONTAINS,
  73. relevance: 0,
  74. starts: TRANSPOSE
  75. },
  76. {
  77. begin: '\\{', end: /}/,
  78. contains: COMMON_CONTAINS,
  79. relevance: 0,
  80. starts: TRANSPOSE
  81. },
  82. {
  83. // transpose operators at the end of a function call
  84. begin: /\)/,
  85. relevance: 0,
  86. starts: TRANSPOSE
  87. },
  88. hljs.COMMENT('^\\s*\\%\\{\\s*$', '^\\s*\\%\\}\\s*$'),
  89. hljs.COMMENT('\\%', '$')
  90. ].concat(COMMON_CONTAINS)
  91. };
  92. }