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