UNPKG

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