haxe.js 3.5 KB

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