axapta.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*
  2. Language: Microsoft X++
  3. Description: X++ is a language used in Microsoft Dynamics 365, Dynamics AX, and Axapta.
  4. Author: Dmitri Roudakov <dmitri@roudakov.ru>
  5. Website: https://dynamics.microsoft.com/en-us/ax-overview/
  6. Category: enterprise
  7. */
  8. /** @type LanguageFn */
  9. function axapta(hljs) {
  10. const IDENT_RE = hljs.UNDERSCORE_IDENT_RE;
  11. const BUILT_IN_KEYWORDS = [
  12. 'anytype',
  13. 'boolean',
  14. 'byte',
  15. 'char',
  16. 'container',
  17. 'date',
  18. 'double',
  19. 'enum',
  20. 'guid',
  21. 'int',
  22. 'int64',
  23. 'long',
  24. 'real',
  25. 'short',
  26. 'str',
  27. 'utcdatetime',
  28. 'var'
  29. ];
  30. const LITERAL_KEYWORDS = [
  31. 'default',
  32. 'false',
  33. 'null',
  34. 'true'
  35. ];
  36. const NORMAL_KEYWORDS = [
  37. 'abstract',
  38. 'as',
  39. 'asc',
  40. 'avg',
  41. 'break',
  42. 'breakpoint',
  43. 'by',
  44. 'byref',
  45. 'case',
  46. 'catch',
  47. 'changecompany',
  48. 'class',
  49. 'client',
  50. 'client',
  51. 'common',
  52. 'const',
  53. 'continue',
  54. 'count',
  55. 'crosscompany',
  56. 'delegate',
  57. 'delete_from',
  58. 'desc',
  59. 'display',
  60. 'div',
  61. 'do',
  62. 'edit',
  63. 'else',
  64. 'eventhandler',
  65. 'exists',
  66. 'extends',
  67. 'final',
  68. 'finally',
  69. 'firstfast',
  70. 'firstonly',
  71. 'firstonly1',
  72. 'firstonly10',
  73. 'firstonly100',
  74. 'firstonly1000',
  75. 'flush',
  76. 'for',
  77. 'forceliterals',
  78. 'forcenestedloop',
  79. 'forceplaceholders',
  80. 'forceselectorder',
  81. 'forupdate',
  82. 'from',
  83. 'generateonly',
  84. 'group',
  85. 'hint',
  86. 'if',
  87. 'implements',
  88. 'in',
  89. 'index',
  90. 'insert_recordset',
  91. 'interface',
  92. 'internal',
  93. 'is',
  94. 'join',
  95. 'like',
  96. 'maxof',
  97. 'minof',
  98. 'mod',
  99. 'namespace',
  100. 'new',
  101. 'next',
  102. 'nofetch',
  103. 'notexists',
  104. 'optimisticlock',
  105. 'order',
  106. 'outer',
  107. 'pessimisticlock',
  108. 'print',
  109. 'private',
  110. 'protected',
  111. 'public',
  112. 'readonly',
  113. 'repeatableread',
  114. 'retry',
  115. 'return',
  116. 'reverse',
  117. 'select',
  118. 'server',
  119. 'setting',
  120. 'static',
  121. 'sum',
  122. 'super',
  123. 'switch',
  124. 'this',
  125. 'throw',
  126. 'try',
  127. 'ttsabort',
  128. 'ttsbegin',
  129. 'ttscommit',
  130. 'unchecked',
  131. 'update_recordset',
  132. 'using',
  133. 'validtimestate',
  134. 'void',
  135. 'where',
  136. 'while'
  137. ];
  138. const KEYWORDS = {
  139. keyword: NORMAL_KEYWORDS,
  140. built_in: BUILT_IN_KEYWORDS,
  141. literal: LITERAL_KEYWORDS
  142. };
  143. const CLASS_DEFINITION = {
  144. variants: [
  145. { match: [
  146. /(class|interface)\s+/,
  147. IDENT_RE,
  148. /\s+(extends|implements)\s+/,
  149. IDENT_RE
  150. ] },
  151. { match: [
  152. /class\s+/,
  153. IDENT_RE
  154. ] }
  155. ],
  156. scope: {
  157. 2: "title.class",
  158. 4: "title.class.inherited"
  159. },
  160. keywords: KEYWORDS
  161. };
  162. return {
  163. name: 'X++',
  164. aliases: [ 'x++' ],
  165. keywords: KEYWORDS,
  166. contains: [
  167. hljs.C_LINE_COMMENT_MODE,
  168. hljs.C_BLOCK_COMMENT_MODE,
  169. hljs.APOS_STRING_MODE,
  170. hljs.QUOTE_STRING_MODE,
  171. hljs.C_NUMBER_MODE,
  172. {
  173. className: 'meta',
  174. begin: '#',
  175. end: '$'
  176. },
  177. CLASS_DEFINITION
  178. ]
  179. };
  180. }
  181. export { axapta as default };