haxe.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. module.exports = function(hljs) {
  2. var IDENT_RE = '[a-zA-Z_$][a-zA-Z0-9_$]*';
  3. var IDENT_FUNC_RETURN_TYPE_RE = '([*]|[a-zA-Z_$][a-zA-Z0-9_$]*)';
  4. var HAXE_BASIC_TYPES = 'Int Float String Bool Dynamic Void Array ';
  5. return {
  6. aliases: ['hx'],
  7. keywords: {
  8. keyword: 'break case cast catch continue default do dynamic else enum extern ' +
  9. 'for function here if import in inline never new override package private get set ' +
  10. 'public return static super switch this throw trace try typedef untyped using var while ' +
  11. HAXE_BASIC_TYPES,
  12. built_in:
  13. 'trace this',
  14. literal:
  15. 'true false null _'
  16. },
  17. contains: [
  18. { className: 'string', // interpolate-able strings
  19. begin: '\'', end: '\'',
  20. contains: [
  21. hljs.BACKSLASH_ESCAPE,
  22. { className: 'subst', // interpolation
  23. begin: '\\$\\{', end: '\\}'
  24. },
  25. { className: 'subst', // interpolation
  26. begin: '\\$', end: '\\W}'
  27. }
  28. ]
  29. },
  30. hljs.QUOTE_STRING_MODE,
  31. hljs.C_LINE_COMMENT_MODE,
  32. hljs.C_BLOCK_COMMENT_MODE,
  33. hljs.C_NUMBER_MODE,
  34. { className: 'meta', // compiler meta
  35. begin: '@:', end: '$'
  36. },
  37. { className: 'meta', // compiler conditionals
  38. begin: '#', end: '$',
  39. keywords: {'meta-keyword': 'if else elseif end error'}
  40. },
  41. { className: 'type', // function types
  42. begin: ':[ \t]*', end: '[^A-Za-z0-9_ \t\\->]',
  43. excludeBegin: true, excludeEnd: true,
  44. relevance: 0
  45. },
  46. { className: 'type', // types
  47. begin: ':[ \t]*', end: '\\W',
  48. excludeBegin: true, excludeEnd: true
  49. },
  50. { className: 'type', // instantiation
  51. begin: 'new *', end: '\\W',
  52. excludeBegin: true, excludeEnd: true
  53. },
  54. { className: 'class', // enums
  55. beginKeywords: 'enum', end: '\\{',
  56. contains: [
  57. hljs.TITLE_MODE
  58. ]
  59. },
  60. { className: 'class', // abstracts
  61. beginKeywords: 'abstract', end: '[\\{$]',
  62. contains: [
  63. { className: 'type',
  64. begin: '\\(', end: '\\)',
  65. excludeBegin: true, excludeEnd: true
  66. },
  67. { className: 'type',
  68. begin: 'from +', end: '\\W',
  69. excludeBegin: true, excludeEnd: true
  70. },
  71. { className: 'type',
  72. begin: 'to +', end: '\\W',
  73. excludeBegin: true, excludeEnd: true
  74. },
  75. hljs.TITLE_MODE
  76. ],
  77. keywords: {
  78. keyword: 'abstract from to'
  79. }
  80. },
  81. { className: 'class', // classes
  82. begin: '\\b(class|interface) +', end: '[\\{$]', excludeEnd: true,
  83. keywords: 'class interface',
  84. contains: [
  85. { className: 'keyword',
  86. begin: '\\b(extends|implements) +',
  87. keywords: 'extends implements',
  88. contains: [
  89. {
  90. className: 'type',
  91. begin: hljs.IDENT_RE,
  92. relevance: 0
  93. }
  94. ]
  95. },
  96. hljs.TITLE_MODE
  97. ]
  98. },
  99. { className: 'function',
  100. beginKeywords: 'function', end: '\\(', excludeEnd: true,
  101. illegal: '\\S',
  102. contains: [
  103. hljs.TITLE_MODE
  104. ]
  105. }
  106. ],
  107. illegal: /<\//
  108. };
  109. };