l0bsterssg

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

cal.js (2033B)


      1 /*
      2 Language: C/AL
      3 Author: Kenneth Fuglsang Christensen <kfuglsang@gmail.com>
      4 Description: Provides highlighting of Microsoft Dynamics NAV C/AL code files
      5 Website: https://docs.microsoft.com/en-us/dynamics-nav/programming-in-c-al
      6 */
      7 
      8 /** @type LanguageFn */
      9 function cal(hljs) {
     10   var KEYWORDS =
     11     'div mod in and or not xor asserterror begin case do downto else end exit for if of repeat then to ' +
     12     'until while with var';
     13   var LITERALS = 'false true';
     14   var COMMENT_MODES = [
     15     hljs.C_LINE_COMMENT_MODE,
     16     hljs.COMMENT(
     17       /\{/,
     18       /\}/,
     19       {
     20         relevance: 0
     21       }
     22     ),
     23     hljs.COMMENT(
     24       /\(\*/,
     25       /\*\)/,
     26       {
     27         relevance: 10
     28       }
     29     )
     30   ];
     31   var STRING = {
     32     className: 'string',
     33     begin: /'/, end: /'/,
     34     contains: [{begin: /''/}]
     35   };
     36   var CHAR_STRING = {
     37     className: 'string', begin: /(#\d+)+/
     38   };
     39   var DATE = {
     40       className: 'number',
     41       begin: '\\b\\d+(\\.\\d+)?(DT|D|T)',
     42       relevance: 0
     43   };
     44   var DBL_QUOTED_VARIABLE = {
     45       className: 'string', // not a string technically but makes sense to be highlighted in the same style
     46       begin: '"',
     47       end: '"'
     48   };
     49 
     50   var PROCEDURE = {
     51     className: 'function',
     52     beginKeywords: 'procedure', end: /[:;]/,
     53     keywords: 'procedure|10',
     54     contains: [
     55       hljs.TITLE_MODE,
     56       {
     57         className: 'params',
     58         begin: /\(/, end: /\)/,
     59         keywords: KEYWORDS,
     60         contains: [STRING, CHAR_STRING]
     61       }
     62     ].concat(COMMENT_MODES)
     63   };
     64 
     65   var OBJECT = {
     66     className: 'class',
     67     begin: 'OBJECT (Table|Form|Report|Dataport|Codeunit|XMLport|MenuSuite|Page|Query) (\\d+) ([^\\r\\n]+)',
     68     returnBegin: true,
     69     contains: [
     70       hljs.TITLE_MODE,
     71         PROCEDURE
     72     ]
     73   };
     74 
     75   return {
     76     name: 'C/AL',
     77     case_insensitive: true,
     78     keywords: { keyword: KEYWORDS, literal: LITERALS },
     79     illegal: /\/\*/,
     80     contains: [
     81       STRING, CHAR_STRING,
     82       DATE, DBL_QUOTED_VARIABLE,
     83       hljs.NUMBER_MODE,
     84       OBJECT,
     85       PROCEDURE
     86     ]
     87   };
     88 }
     89 
     90 module.exports = cal;