]> luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/angelscript.js
Initial commit.
[flow-web.git] / static / highlight / languages / angelscript.js
1 /*! `angelscript` grammar compiled for Highlight.js 11.11.1 */
2 (function(){
3 var hljsGrammar = (function () {
4 'use strict';
5
6 /*
7 Language: AngelScript
8 Author: Melissa Geels <melissa@nimble.tools>
9 Category: scripting
10 Website: https://www.angelcode.com/angelscript/
11 */
12
13 /** @type LanguageFn */
14 function angelscript(hljs) {
15 const builtInTypeMode = {
16 className: 'built_in',
17 begin: '\\b(void|bool|int8|int16|int32|int64|int|uint8|uint16|uint32|uint64|uint|string|ref|array|double|float|auto|dictionary)'
18 };
19
20 const objectHandleMode = {
21 className: 'symbol',
22 begin: '[a-zA-Z0-9_]+@'
23 };
24
25 const genericMode = {
26 className: 'keyword',
27 begin: '<',
28 end: '>',
29 contains: [
30 builtInTypeMode,
31 objectHandleMode
32 ]
33 };
34
35 builtInTypeMode.contains = [ genericMode ];
36 objectHandleMode.contains = [ genericMode ];
37
38 const KEYWORDS = [
39 "for",
40 "in|0",
41 "break",
42 "continue",
43 "while",
44 "do|0",
45 "return",
46 "if",
47 "else",
48 "case",
49 "switch",
50 "namespace",
51 "is",
52 "cast",
53 "or",
54 "and",
55 "xor",
56 "not",
57 "get|0",
58 "in",
59 "inout|10",
60 "out",
61 "override",
62 "set|0",
63 "private",
64 "public",
65 "const",
66 "default|0",
67 "final",
68 "shared",
69 "external",
70 "mixin|10",
71 "enum",
72 "typedef",
73 "funcdef",
74 "this",
75 "super",
76 "import",
77 "from",
78 "interface",
79 "abstract|0",
80 "try",
81 "catch",
82 "protected",
83 "explicit",
84 "property"
85 ];
86
87 return {
88 name: 'AngelScript',
89 aliases: [ 'asc' ],
90
91 keywords: KEYWORDS,
92
93 // avoid close detection with C# and JS
94 illegal: '(^using\\s+[A-Za-z0-9_\\.]+;$|\\bfunction\\s*[^\\(])',
95
96 contains: [
97 { // 'strings'
98 className: 'string',
99 begin: '\'',
100 end: '\'',
101 illegal: '\\n',
102 contains: [ hljs.BACKSLASH_ESCAPE ],
103 relevance: 0
104 },
105
106 // """heredoc strings"""
107 {
108 className: 'string',
109 begin: '"""',
110 end: '"""'
111 },
112
113 { // "strings"
114 className: 'string',
115 begin: '"',
116 end: '"',
117 illegal: '\\n',
118 contains: [ hljs.BACKSLASH_ESCAPE ],
119 relevance: 0
120 },
121
122 hljs.C_LINE_COMMENT_MODE, // single-line comments
123 hljs.C_BLOCK_COMMENT_MODE, // comment blocks
124
125 { // metadata
126 className: 'string',
127 begin: '^\\s*\\[',
128 end: '\\]'
129 },
130
131 { // interface or namespace declaration
132 beginKeywords: 'interface namespace',
133 end: /\{/,
134 illegal: '[;.\\-]',
135 contains: [
136 { // interface or namespace name
137 className: 'symbol',
138 begin: '[a-zA-Z0-9_]+'
139 }
140 ]
141 },
142
143 { // class declaration
144 beginKeywords: 'class',
145 end: /\{/,
146 illegal: '[;.\\-]',
147 contains: [
148 { // class name
149 className: 'symbol',
150 begin: '[a-zA-Z0-9_]+',
151 contains: [
152 {
153 begin: '[:,]\\s*',
154 contains: [
155 {
156 className: 'symbol',
157 begin: '[a-zA-Z0-9_]+'
158 }
159 ]
160 }
161 ]
162 }
163 ]
164 },
165
166 builtInTypeMode, // built-in types
167 objectHandleMode, // object handles
168
169 { // literals
170 className: 'literal',
171 begin: '\\b(null|true|false)'
172 },
173
174 { // numbers
175 className: 'number',
176 relevance: 0,
177 begin: '(-?)(\\b0[xXbBoOdD][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?f?|\\.\\d+f?)([eE][-+]?\\d+f?)?)'
178 }
179 ]
180 };
181 }
182
183 return angelscript;
184
185 })();
186
187 hljs.registerLanguage('angelscript', hljsGrammar);
188 })();