cal.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. module.exports = function(hljs) {
  2. var KEYWORDS =
  3. 'div mod in and or not xor asserterror begin case do downto else end exit for if of repeat then to ' +
  4. 'until while with var';
  5. var LITERALS = 'false true';
  6. var COMMENT_MODES = [
  7. hljs.C_LINE_COMMENT_MODE,
  8. hljs.COMMENT(
  9. /\{/,
  10. /\}/,
  11. {
  12. relevance: 0
  13. }
  14. ),
  15. hljs.COMMENT(
  16. /\(\*/,
  17. /\*\)/,
  18. {
  19. relevance: 10
  20. }
  21. )
  22. ];
  23. var STRING = {
  24. className: 'string',
  25. begin: /'/, end: /'/,
  26. contains: [{begin: /''/}]
  27. };
  28. var CHAR_STRING = {
  29. className: 'string', begin: /(#\d+)+/
  30. };
  31. var DATE = {
  32. className: 'number',
  33. begin: '\\b\\d+(\\.\\d+)?(DT|D|T)',
  34. relevance: 0
  35. };
  36. var DBL_QUOTED_VARIABLE = {
  37. className: 'string', // not a string technically but makes sense to be highlighted in the same style
  38. begin: '"',
  39. end: '"'
  40. };
  41. var PROCEDURE = {
  42. className: 'function',
  43. beginKeywords: 'procedure', end: /[:;]/,
  44. keywords: 'procedure|10',
  45. contains: [
  46. hljs.TITLE_MODE,
  47. {
  48. className: 'params',
  49. begin: /\(/, end: /\)/,
  50. keywords: KEYWORDS,
  51. contains: [STRING, CHAR_STRING]
  52. }
  53. ].concat(COMMENT_MODES)
  54. };
  55. var OBJECT = {
  56. className: 'class',
  57. begin: 'OBJECT (Table|Form|Report|Dataport|Codeunit|XMLport|MenuSuite|Page|Query) (\\d+) ([^\\r\\n]+)',
  58. returnBegin: true,
  59. contains: [
  60. hljs.TITLE_MODE,
  61. PROCEDURE
  62. ]
  63. };
  64. return {
  65. case_insensitive: true,
  66. keywords: { keyword: KEYWORDS, literal: LITERALS },
  67. illegal: /\/\*/,
  68. contains: [
  69. STRING, CHAR_STRING,
  70. DATE, DBL_QUOTED_VARIABLE,
  71. hljs.NUMBER_MODE,
  72. OBJECT,
  73. PROCEDURE
  74. ]
  75. };
  76. };