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