main
Last change
on this file since cfc16a3 was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
2.1 KB
|
Rev | Line | |
---|
[d24f17c] | 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 | const 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 | const LITERALS = 'false true';
|
---|
| 14 | const 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 | const STRING = {
|
---|
| 32 | className: 'string',
|
---|
| 33 | begin: /'/,
|
---|
| 34 | end: /'/,
|
---|
| 35 | contains: [{
|
---|
| 36 | begin: /''/
|
---|
| 37 | }]
|
---|
| 38 | };
|
---|
| 39 | const CHAR_STRING = {
|
---|
| 40 | className: 'string',
|
---|
| 41 | begin: /(#\d+)+/
|
---|
| 42 | };
|
---|
| 43 | const DATE = {
|
---|
| 44 | className: 'number',
|
---|
| 45 | begin: '\\b\\d+(\\.\\d+)?(DT|D|T)',
|
---|
| 46 | relevance: 0
|
---|
| 47 | };
|
---|
| 48 | const DBL_QUOTED_VARIABLE = {
|
---|
| 49 | className: 'string', // not a string technically but makes sense to be highlighted in the same style
|
---|
| 50 | begin: '"',
|
---|
| 51 | end: '"'
|
---|
| 52 | };
|
---|
| 53 |
|
---|
| 54 | const PROCEDURE = {
|
---|
| 55 | className: 'function',
|
---|
| 56 | beginKeywords: 'procedure',
|
---|
| 57 | end: /[:;]/,
|
---|
| 58 | keywords: 'procedure|10',
|
---|
| 59 | contains: [
|
---|
| 60 | hljs.TITLE_MODE,
|
---|
| 61 | {
|
---|
| 62 | className: 'params',
|
---|
| 63 | begin: /\(/,
|
---|
| 64 | end: /\)/,
|
---|
| 65 | keywords: KEYWORDS,
|
---|
| 66 | contains: [
|
---|
| 67 | STRING,
|
---|
| 68 | CHAR_STRING
|
---|
| 69 | ]
|
---|
| 70 | }
|
---|
| 71 | ].concat(COMMENT_MODES)
|
---|
| 72 | };
|
---|
| 73 |
|
---|
| 74 | const OBJECT = {
|
---|
| 75 | className: 'class',
|
---|
| 76 | begin: 'OBJECT (Table|Form|Report|Dataport|Codeunit|XMLport|MenuSuite|Page|Query) (\\d+) ([^\\r\\n]+)',
|
---|
| 77 | returnBegin: true,
|
---|
| 78 | contains: [
|
---|
| 79 | hljs.TITLE_MODE,
|
---|
| 80 | PROCEDURE
|
---|
| 81 | ]
|
---|
| 82 | };
|
---|
| 83 |
|
---|
| 84 | return {
|
---|
| 85 | name: 'C/AL',
|
---|
| 86 | case_insensitive: true,
|
---|
| 87 | keywords: {
|
---|
| 88 | keyword: KEYWORDS,
|
---|
| 89 | literal: LITERALS
|
---|
| 90 | },
|
---|
| 91 | illegal: /\/\*/,
|
---|
| 92 | contains: [
|
---|
| 93 | STRING,
|
---|
| 94 | CHAR_STRING,
|
---|
| 95 | DATE,
|
---|
| 96 | DBL_QUOTED_VARIABLE,
|
---|
| 97 | hljs.NUMBER_MODE,
|
---|
| 98 | OBJECT,
|
---|
| 99 | PROCEDURE
|
---|
| 100 | ]
|
---|
| 101 | };
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | module.exports = cal;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.