haxe.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. var 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. { className: 'string', // interpolate-able strings
  25. begin: '\'', end: '\'',
  26. contains: [
  27. hljs.BACKSLASH_ESCAPE,
  28. { className: 'subst', // interpolation
  29. begin: '\\$\\{', end: '\\}'
  30. },
  31. { className: 'subst', // interpolation
  32. begin: '\\$', end: '\\W}'
  33. }
  34. ]
  35. },
  36. hljs.QUOTE_STRING_MODE,
  37. hljs.C_LINE_COMMENT_MODE,
  38. hljs.C_BLOCK_COMMENT_MODE,
  39. hljs.C_NUMBER_MODE,
  40. { className: 'meta', // compiler meta
  41. begin: '@:', end: '$'
  42. },
  43. { className: 'meta', // compiler conditionals
  44. begin: '#', end: '$',
  45. keywords: {'meta-keyword': 'if else elseif end error'}
  46. },
  47. { className: 'type', // function types
  48. begin: ':[ \t]*', end: '[^A-Za-z0-9_ \t\\->]',
  49. excludeBegin: true, excludeEnd: true,
  50. relevance: 0
  51. },
  52. { className: 'type', // types
  53. begin: ':[ \t]*', end: '\\W',
  54. excludeBegin: true, excludeEnd: true
  55. },
  56. { className: 'type', // instantiation
  57. begin: 'new *', end: '\\W',
  58. excludeBegin: true, excludeEnd: true
  59. },
  60. { className: 'class', // enums
  61. beginKeywords: 'enum', end: '\\{',
  62. contains: [
  63. hljs.TITLE_MODE
  64. ]
  65. },
  66. { className: 'class', // abstracts
  67. beginKeywords: 'abstract', end: '[\\{$]',
  68. contains: [
  69. { className: 'type',
  70. begin: '\\(', end: '\\)',
  71. excludeBegin: true, excludeEnd: true
  72. },
  73. { className: 'type',
  74. begin: 'from +', end: '\\W',
  75. excludeBegin: true, excludeEnd: true
  76. },
  77. { className: 'type',
  78. begin: 'to +', end: '\\W',
  79. excludeBegin: true, excludeEnd: true
  80. },
  81. hljs.TITLE_MODE
  82. ],
  83. keywords: {
  84. keyword: 'abstract from to'
  85. }
  86. },
  87. { className: 'class', // classes
  88. begin: '\\b(class|interface) +', end: '[\\{$]', excludeEnd: true,
  89. keywords: 'class interface',
  90. contains: [
  91. { className: 'keyword',
  92. begin: '\\b(extends|implements) +',
  93. keywords: 'extends implements',
  94. contains: [
  95. {
  96. className: 'type',
  97. begin: hljs.IDENT_RE,
  98. relevance: 0
  99. }
  100. ]
  101. },
  102. hljs.TITLE_MODE
  103. ]
  104. },
  105. { className: 'function',
  106. beginKeywords: 'function', end: '\\(', excludeEnd: true,
  107. illegal: '\\S',
  108. contains: [
  109. hljs.TITLE_MODE
  110. ]
  111. }
  112. ],
  113. illegal: /<\//
  114. };
  115. }
  116. module.exports = haxe;