l0bsterssg

node.js static responsive blog post generator
Log | Files | Refs | README

matlab.js (3627B)


      1 /*
      2 Language: Matlab
      3 Author: Denis Bardadym <bardadymchik@gmail.com>
      4 Contributors: Eugene Nizhibitsky <nizhibitsky@ya.ru>, Egor Rogov <e.rogov@postgrespro.ru>
      5 Website: https://www.mathworks.com/products/matlab.html
      6 Category: scientific
      7 */
      8 
      9 /*
     10   Formal syntax is not published, helpful link:
     11   https://github.com/kornilova-l/matlab-IntelliJ-plugin/blob/master/src/main/grammar/Matlab.bnf
     12 */
     13 function matlab(hljs) {
     14 
     15   var TRANSPOSE_RE = '(\'|\\.\')+';
     16   var TRANSPOSE = {
     17     relevance: 0,
     18     contains: [
     19       { begin: TRANSPOSE_RE }
     20     ]
     21   };
     22 
     23   return {
     24     name: 'Matlab',
     25     keywords: {
     26       keyword:
     27         'arguments break case catch classdef continue else elseif end enumeration 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 max min nanmax nanmin mean nanmean type table ' +
     44         'readtable writetable sortrows sort figure plot plot3 scatter scatter3 cellfun ' +
     45         'legend intersect ismember procrustes hold num2cell '
     46     },
     47     illegal: '(//|"|#|/\\*|\\s+/\\w+)',
     48     contains: [
     49       {
     50         className: 'function',
     51         beginKeywords: 'function', end: '$',
     52         contains: [
     53           hljs.UNDERSCORE_TITLE_MODE,
     54           {
     55             className: 'params',
     56             variants: [
     57               {begin: '\\(', end: '\\)'},
     58               {begin: '\\[', end: '\\]'}
     59             ]
     60           }
     61         ]
     62       },
     63       {
     64         className: 'built_in',
     65         begin: /true|false/,
     66         relevance: 0,
     67         starts: TRANSPOSE
     68       },
     69       {
     70         begin: '[a-zA-Z][a-zA-Z_0-9]*' + TRANSPOSE_RE,
     71         relevance: 0
     72       },
     73       {
     74         className: 'number',
     75         begin: hljs.C_NUMBER_RE,
     76         relevance: 0,
     77         starts: TRANSPOSE
     78       },
     79       {
     80         className: 'string',
     81         begin: '\'', end: '\'',
     82         contains: [
     83           hljs.BACKSLASH_ESCAPE,
     84           {begin: '\'\''}]
     85       },
     86       {
     87         begin: /\]|}|\)/,
     88         relevance: 0,
     89         starts: TRANSPOSE
     90       },
     91       {
     92         className: 'string',
     93         begin: '"', end: '"',
     94         contains: [
     95           hljs.BACKSLASH_ESCAPE,
     96           {begin: '""'}
     97         ],
     98         starts: TRANSPOSE
     99       },
    100       hljs.COMMENT('^\\s*\\%\\{\\s*$', '^\\s*\\%\\}\\s*$'),
    101       hljs.COMMENT('\\%', '$')
    102     ]
    103   };
    104 }
    105 
    106 module.exports = matlab;