haxe.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. Language: Haxe
  3. Description: Haxe is an open source toolkit based on a modern, high level, strictly typed programming language.
  4. Author: Christopher Kaster <ikasoki@gmail.com> (Based on the actionscript.js language file by Alexander Myadzel)
  5. Contributors: Kenton Hamaluik <kentonh@gmail.com>
  6. Website: https://haxe.org
  7. */
  8. function haxe(hljs) {
  9. const HAXE_BASIC_TYPES = 'Int Float String Bool Dynamic Void Array ';
  10. return {
  11. name: 'Haxe',
  12. aliases: [ 'hx' ],
  13. keywords: {
  14. keyword: 'break case cast catch continue default do dynamic else enum extern '
  15. + 'for function here if import in inline never new override package private get set '
  16. + 'public return static super switch this throw trace try typedef untyped using var while '
  17. + HAXE_BASIC_TYPES,
  18. built_in:
  19. 'trace this',
  20. literal:
  21. 'true false null _'
  22. },
  23. contains: [
  24. {
  25. className: 'string', // interpolate-able strings
  26. begin: '\'',
  27. end: '\'',
  28. contains: [
  29. hljs.BACKSLASH_ESCAPE,
  30. {
  31. className: 'subst', // interpolation
  32. begin: '\\$\\{',
  33. end: '\\}'
  34. },
  35. {
  36. className: 'subst', // interpolation
  37. begin: '\\$',
  38. end: /\W\}/
  39. }
  40. ]
  41. },
  42. hljs.QUOTE_STRING_MODE,
  43. hljs.C_LINE_COMMENT_MODE,
  44. hljs.C_BLOCK_COMMENT_MODE,
  45. hljs.C_NUMBER_MODE,
  46. {
  47. className: 'meta', // compiler meta
  48. begin: '@:',
  49. end: '$'
  50. },
  51. {
  52. className: 'meta', // compiler conditionals
  53. begin: '#',
  54. end: '$',
  55. keywords: { keyword: 'if else elseif end error' }
  56. },
  57. {
  58. className: 'type', // function types
  59. begin: ':[ \t]*',
  60. end: '[^A-Za-z0-9_ \t\\->]',
  61. excludeBegin: true,
  62. excludeEnd: true,
  63. relevance: 0
  64. },
  65. {
  66. className: 'type', // types
  67. begin: ':[ \t]*',
  68. end: '\\W',
  69. excludeBegin: true,
  70. excludeEnd: true
  71. },
  72. {
  73. className: 'type', // instantiation
  74. begin: 'new *',
  75. end: '\\W',
  76. excludeBegin: true,
  77. excludeEnd: true
  78. },
  79. {
  80. className: 'class', // enums
  81. beginKeywords: 'enum',
  82. end: '\\{',
  83. contains: [ hljs.TITLE_MODE ]
  84. },
  85. {
  86. className: 'class', // abstracts
  87. beginKeywords: 'abstract',
  88. end: '[\\{$]',
  89. contains: [
  90. {
  91. className: 'type',
  92. begin: '\\(',
  93. end: '\\)',
  94. excludeBegin: true,
  95. excludeEnd: true
  96. },
  97. {
  98. className: 'type',
  99. begin: 'from +',
  100. end: '\\W',
  101. excludeBegin: true,
  102. excludeEnd: true
  103. },
  104. {
  105. className: 'type',
  106. begin: 'to +',
  107. end: '\\W',
  108. excludeBegin: true,
  109. excludeEnd: true
  110. },
  111. hljs.TITLE_MODE
  112. ],
  113. keywords: { keyword: 'abstract from to' }
  114. },
  115. {
  116. className: 'class', // classes
  117. begin: '\\b(class|interface) +',
  118. end: '[\\{$]',
  119. excludeEnd: true,
  120. keywords: 'class interface',
  121. contains: [
  122. {
  123. className: 'keyword',
  124. begin: '\\b(extends|implements) +',
  125. keywords: 'extends implements',
  126. contains: [
  127. {
  128. className: 'type',
  129. begin: hljs.IDENT_RE,
  130. relevance: 0
  131. }
  132. ]
  133. },
  134. hljs.TITLE_MODE
  135. ]
  136. },
  137. {
  138. className: 'function',
  139. beginKeywords: 'function',
  140. end: '\\(',
  141. excludeEnd: true,
  142. illegal: '\\S',
  143. contains: [ hljs.TITLE_MODE ]
  144. }
  145. ],
  146. illegal: /<\//
  147. };
  148. }
  149. export { haxe as default };