haxe.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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: {
  56. 'meta-keyword': 'if else elseif end error'
  57. }
  58. },
  59. {
  60. className: 'type', // function types
  61. begin: ':[ \t]*',
  62. end: '[^A-Za-z0-9_ \t\\->]',
  63. excludeBegin: true,
  64. excludeEnd: true,
  65. relevance: 0
  66. },
  67. {
  68. className: 'type', // types
  69. begin: ':[ \t]*',
  70. end: '\\W',
  71. excludeBegin: true,
  72. excludeEnd: true
  73. },
  74. {
  75. className: 'type', // instantiation
  76. begin: 'new *',
  77. end: '\\W',
  78. excludeBegin: true,
  79. excludeEnd: true
  80. },
  81. {
  82. className: 'class', // enums
  83. beginKeywords: 'enum',
  84. end: '\\{',
  85. contains: [hljs.TITLE_MODE]
  86. },
  87. {
  88. className: 'class', // abstracts
  89. beginKeywords: 'abstract',
  90. end: '[\\{$]',
  91. contains: [
  92. {
  93. className: 'type',
  94. begin: '\\(',
  95. end: '\\)',
  96. excludeBegin: true,
  97. excludeEnd: true
  98. },
  99. {
  100. className: 'type',
  101. begin: 'from +',
  102. end: '\\W',
  103. excludeBegin: true,
  104. excludeEnd: true
  105. },
  106. {
  107. className: 'type',
  108. begin: 'to +',
  109. end: '\\W',
  110. excludeBegin: true,
  111. excludeEnd: true
  112. },
  113. hljs.TITLE_MODE
  114. ],
  115. keywords: {
  116. keyword: 'abstract from to'
  117. }
  118. },
  119. {
  120. className: 'class', // classes
  121. begin: '\\b(class|interface) +',
  122. end: '[\\{$]',
  123. excludeEnd: true,
  124. keywords: 'class interface',
  125. contains: [
  126. {
  127. className: 'keyword',
  128. begin: '\\b(extends|implements) +',
  129. keywords: 'extends implements',
  130. contains: [
  131. {
  132. className: 'type',
  133. begin: hljs.IDENT_RE,
  134. relevance: 0
  135. }
  136. ]
  137. },
  138. hljs.TITLE_MODE
  139. ]
  140. },
  141. {
  142. className: 'function',
  143. beginKeywords: 'function',
  144. end: '\\(',
  145. excludeEnd: true,
  146. illegal: '\\S',
  147. contains: [hljs.TITLE_MODE]
  148. }
  149. ],
  150. illegal: /<\//
  151. };
  152. }
  153. module.exports = haxe;