| 5 |
lars |
1 |
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
|
2 |
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
|
|
3 |
|
|
|
4 |
(function(mod) {
|
|
|
5 |
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|
|
6 |
mod(require("../../lib/codemirror"));
|
|
|
7 |
else if (typeof define == "function" && define.amd) // AMD
|
|
|
8 |
define(["../../lib/codemirror"], mod);
|
|
|
9 |
else // Plain browser env
|
|
|
10 |
mod(CodeMirror);
|
|
|
11 |
})(function(CodeMirror) {
|
|
|
12 |
"use strict";
|
|
|
13 |
|
|
|
14 |
CodeMirror.defineMode("clike", function(config, parserConfig) {
|
|
|
15 |
var indentUnit = config.indentUnit,
|
|
|
16 |
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
|
|
|
17 |
dontAlignCalls = parserConfig.dontAlignCalls,
|
|
|
18 |
keywords = parserConfig.keywords || {},
|
|
|
19 |
types = parserConfig.types || {},
|
|
|
20 |
builtin = parserConfig.builtin || {},
|
|
|
21 |
blockKeywords = parserConfig.blockKeywords || {},
|
|
|
22 |
defKeywords = parserConfig.defKeywords || {},
|
|
|
23 |
atoms = parserConfig.atoms || {},
|
|
|
24 |
hooks = parserConfig.hooks || {},
|
|
|
25 |
multiLineStrings = parserConfig.multiLineStrings,
|
|
|
26 |
indentStatements = parserConfig.indentStatements !== false,
|
|
|
27 |
indentSwitch = parserConfig.indentSwitch !== false,
|
|
|
28 |
namespaceSeparator = parserConfig.namespaceSeparator;
|
|
|
29 |
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
|
|
|
30 |
|
|
|
31 |
var curPunc, isDefKeyword;
|
|
|
32 |
|
|
|
33 |
function tokenBase(stream, state) {
|
|
|
34 |
var ch = stream.next();
|
|
|
35 |
if (hooks[ch]) {
|
|
|
36 |
var result = hooks[ch](stream, state);
|
|
|
37 |
if (result !== false) return result;
|
|
|
38 |
}
|
|
|
39 |
if (ch == '"' || ch == "'") {
|
|
|
40 |
state.tokenize = tokenString(ch);
|
|
|
41 |
return state.tokenize(stream, state);
|
|
|
42 |
}
|
|
|
43 |
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
|
|
44 |
curPunc = ch;
|
|
|
45 |
return null;
|
|
|
46 |
}
|
|
|
47 |
if (/\d/.test(ch)) {
|
|
|
48 |
stream.eatWhile(/[\w\.]/);
|
|
|
49 |
return "number";
|
|
|
50 |
}
|
|
|
51 |
if (ch == "/") {
|
|
|
52 |
if (stream.eat("*")) {
|
|
|
53 |
state.tokenize = tokenComment;
|
|
|
54 |
return tokenComment(stream, state);
|
|
|
55 |
}
|
|
|
56 |
if (stream.eat("/")) {
|
|
|
57 |
stream.skipToEnd();
|
|
|
58 |
return "comment";
|
|
|
59 |
}
|
|
|
60 |
}
|
|
|
61 |
if (isOperatorChar.test(ch)) {
|
|
|
62 |
stream.eatWhile(isOperatorChar);
|
|
|
63 |
return "operator";
|
|
|
64 |
}
|
|
|
65 |
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
|
|
|
66 |
if (namespaceSeparator) while (stream.match(namespaceSeparator))
|
|
|
67 |
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
|
|
|
68 |
|
|
|
69 |
var cur = stream.current();
|
|
|
70 |
if (keywords.propertyIsEnumerable(cur)) {
|
|
|
71 |
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
|
|
72 |
if (defKeywords.propertyIsEnumerable(cur)) isDefKeyword = true;
|
|
|
73 |
return "keyword";
|
|
|
74 |
}
|
|
|
75 |
if (types.propertyIsEnumerable(cur)) return "variable-3";
|
|
|
76 |
if (builtin.propertyIsEnumerable(cur)) {
|
|
|
77 |
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
|
|
78 |
return "builtin";
|
|
|
79 |
}
|
|
|
80 |
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
|
|
81 |
return "variable";
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
function tokenString(quote) {
|
|
|
85 |
return function(stream, state) {
|
|
|
86 |
var escaped = false, next, end = false;
|
|
|
87 |
while ((next = stream.next()) != null) {
|
|
|
88 |
if (next == quote && !escaped) {end = true; break;}
|
|
|
89 |
escaped = !escaped && next == "\\";
|
|
|
90 |
}
|
|
|
91 |
if (end || !(escaped || multiLineStrings))
|
|
|
92 |
state.tokenize = null;
|
|
|
93 |
return "string";
|
|
|
94 |
};
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
function tokenComment(stream, state) {
|
|
|
98 |
var maybeEnd = false, ch;
|
|
|
99 |
while (ch = stream.next()) {
|
|
|
100 |
if (ch == "/" && maybeEnd) {
|
|
|
101 |
state.tokenize = null;
|
|
|
102 |
break;
|
|
|
103 |
}
|
|
|
104 |
maybeEnd = (ch == "*");
|
|
|
105 |
}
|
|
|
106 |
return "comment";
|
|
|
107 |
}
|
|
|
108 |
|
|
|
109 |
function Context(indented, column, type, align, prev) {
|
|
|
110 |
this.indented = indented;
|
|
|
111 |
this.column = column;
|
|
|
112 |
this.type = type;
|
|
|
113 |
this.align = align;
|
|
|
114 |
this.prev = prev;
|
|
|
115 |
}
|
|
|
116 |
function isStatement(type) {
|
|
|
117 |
return type == "statement" || type == "switchstatement" || type == "namespace";
|
|
|
118 |
}
|
|
|
119 |
function pushContext(state, col, type) {
|
|
|
120 |
var indent = state.indented;
|
|
|
121 |
if (state.context && isStatement(state.context.type) && !isStatement(type))
|
|
|
122 |
indent = state.context.indented;
|
|
|
123 |
return state.context = new Context(indent, col, type, null, state.context);
|
|
|
124 |
}
|
|
|
125 |
function popContext(state) {
|
|
|
126 |
var t = state.context.type;
|
|
|
127 |
if (t == ")" || t == "]" || t == "}")
|
|
|
128 |
state.indented = state.context.indented;
|
|
|
129 |
return state.context = state.context.prev;
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
function typeBefore(stream, state) {
|
|
|
133 |
if (state.prevToken == "variable" || state.prevToken == "variable-3") return true;
|
|
|
134 |
if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, stream.start))) return true;
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
function isTopScope(context) {
|
|
|
138 |
for (;;) {
|
|
|
139 |
if (!context || context.type == "top") return true;
|
|
|
140 |
if (context.type == "}" && context.prev.type != "namespace") return false;
|
|
|
141 |
context = context.prev;
|
|
|
142 |
}
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
// Interface
|
|
|
146 |
|
|
|
147 |
return {
|
|
|
148 |
startState: function(basecolumn) {
|
|
|
149 |
return {
|
|
|
150 |
tokenize: null,
|
|
|
151 |
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
|
|
152 |
indented: 0,
|
|
|
153 |
startOfLine: true,
|
|
|
154 |
prevToken: null
|
|
|
155 |
};
|
|
|
156 |
},
|
|
|
157 |
|
|
|
158 |
token: function(stream, state) {
|
|
|
159 |
var ctx = state.context;
|
|
|
160 |
if (stream.sol()) {
|
|
|
161 |
if (ctx.align == null) ctx.align = false;
|
|
|
162 |
state.indented = stream.indentation();
|
|
|
163 |
state.startOfLine = true;
|
|
|
164 |
}
|
|
|
165 |
if (stream.eatSpace()) return null;
|
|
|
166 |
curPunc = isDefKeyword = null;
|
|
|
167 |
var style = (state.tokenize || tokenBase)(stream, state);
|
|
|
168 |
if (style == "comment" || style == "meta") return style;
|
|
|
169 |
if (ctx.align == null) ctx.align = true;
|
|
|
170 |
|
|
|
171 |
if ((curPunc == ";" || curPunc == ":" || curPunc == ","))
|
|
|
172 |
while (isStatement(state.context.type)) popContext(state);
|
|
|
173 |
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
|
|
174 |
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
|
|
175 |
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
|
|
176 |
else if (curPunc == "}") {
|
|
|
177 |
while (isStatement(ctx.type)) ctx = popContext(state);
|
|
|
178 |
if (ctx.type == "}") ctx = popContext(state);
|
|
|
179 |
while (isStatement(ctx.type)) ctx = popContext(state);
|
|
|
180 |
}
|
|
|
181 |
else if (curPunc == ctx.type) popContext(state);
|
|
|
182 |
else if (indentStatements &&
|
|
|
183 |
(((ctx.type == "}" || ctx.type == "top") && curPunc != ";") ||
|
|
|
184 |
(isStatement(ctx.type) && curPunc == "newstatement"))) {
|
|
|
185 |
var type = "statement";
|
|
|
186 |
if (curPunc == "newstatement" && indentSwitch && stream.current() == "switch")
|
|
|
187 |
type = "switchstatement";
|
|
|
188 |
else if (style == "keyword" && stream.current() == "namespace")
|
|
|
189 |
type = "namespace";
|
|
|
190 |
pushContext(state, stream.column(), type);
|
|
|
191 |
}
|
|
|
192 |
|
|
|
193 |
if (style == "variable" &&
|
|
|
194 |
((state.prevToken == "def" ||
|
|
|
195 |
(parserConfig.typeFirstDefinitions && typeBefore(stream, state) &&
|
|
|
196 |
isTopScope(state.context) && stream.match(/^\s*\(/, false)))))
|
|
|
197 |
style = "def";
|
|
|
198 |
|
|
|
199 |
if (hooks.token) {
|
|
|
200 |
var result = hooks.token(stream, state, style);
|
|
|
201 |
if (result !== undefined) style = result;
|
|
|
202 |
}
|
|
|
203 |
|
|
|
204 |
if (style == "def" && parserConfig.styleDefs === false) style = "variable";
|
|
|
205 |
|
|
|
206 |
state.startOfLine = false;
|
|
|
207 |
state.prevToken = isDefKeyword ? "def" : style || curPunc;
|
|
|
208 |
return style;
|
|
|
209 |
},
|
|
|
210 |
|
|
|
211 |
indent: function(state, textAfter) {
|
|
|
212 |
if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
|
|
|
213 |
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
|
|
214 |
if (isStatement(ctx.type) && firstChar == "}") ctx = ctx.prev;
|
|
|
215 |
var closing = firstChar == ctx.type;
|
|
|
216 |
var switchBlock = ctx.prev && ctx.prev.type == "switchstatement";
|
|
|
217 |
if (isStatement(ctx.type))
|
|
|
218 |
return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
|
|
|
219 |
if (ctx.align && (!dontAlignCalls || ctx.type != ")"))
|
|
|
220 |
return ctx.column + (closing ? 0 : 1);
|
|
|
221 |
if (ctx.type == ")" && !closing)
|
|
|
222 |
return ctx.indented + statementIndentUnit;
|
|
|
223 |
|
|
|
224 |
return ctx.indented + (closing ? 0 : indentUnit) +
|
|
|
225 |
(!closing && switchBlock && !/^(?:case|default)\b/.test(textAfter) ? indentUnit : 0);
|
|
|
226 |
},
|
|
|
227 |
|
|
|
228 |
electricInput: indentSwitch ? /^\s*(?:case .*?:|default:|\{\}?|\})$/ : /^\s*[{}]$/,
|
|
|
229 |
blockCommentStart: "/*",
|
|
|
230 |
blockCommentEnd: "*/",
|
|
|
231 |
lineComment: "//",
|
|
|
232 |
fold: "brace"
|
|
|
233 |
};
|
|
|
234 |
});
|
|
|
235 |
|
|
|
236 |
function words(str) {
|
|
|
237 |
var obj = {}, words = str.split(" ");
|
|
|
238 |
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
|
|
239 |
return obj;
|
|
|
240 |
}
|
|
|
241 |
var cKeywords = "auto if break case register continue return default do sizeof " +
|
|
|
242 |
"static else struct switch extern typedef float union for " +
|
|
|
243 |
"goto while enum const volatile";
|
|
|
244 |
var cTypes = "int long char short double float unsigned signed void size_t ptrdiff_t";
|
|
|
245 |
|
|
|
246 |
function cppHook(stream, state) {
|
|
|
247 |
if (!state.startOfLine) return false;
|
|
|
248 |
for (;;) {
|
|
|
249 |
if (stream.skipTo("\\")) {
|
|
|
250 |
stream.next();
|
|
|
251 |
if (stream.eol()) {
|
|
|
252 |
state.tokenize = cppHook;
|
|
|
253 |
break;
|
|
|
254 |
}
|
|
|
255 |
} else {
|
|
|
256 |
stream.skipToEnd();
|
|
|
257 |
state.tokenize = null;
|
|
|
258 |
break;
|
|
|
259 |
}
|
|
|
260 |
}
|
|
|
261 |
return "meta";
|
|
|
262 |
}
|
|
|
263 |
|
|
|
264 |
function pointerHook(_stream, state) {
|
|
|
265 |
if (state.prevToken == "variable-3") return "variable-3";
|
|
|
266 |
return false;
|
|
|
267 |
}
|
|
|
268 |
|
|
|
269 |
function cpp11StringHook(stream, state) {
|
|
|
270 |
stream.backUp(1);
|
|
|
271 |
// Raw strings.
|
|
|
272 |
if (stream.match(/(R|u8R|uR|UR|LR)/)) {
|
|
|
273 |
var match = stream.match(/"([^\s\\()]{0,16})\(/);
|
|
|
274 |
if (!match) {
|
|
|
275 |
return false;
|
|
|
276 |
}
|
|
|
277 |
state.cpp11RawStringDelim = match[1];
|
|
|
278 |
state.tokenize = tokenRawString;
|
|
|
279 |
return tokenRawString(stream, state);
|
|
|
280 |
}
|
|
|
281 |
// Unicode strings/chars.
|
|
|
282 |
if (stream.match(/(u8|u|U|L)/)) {
|
|
|
283 |
if (stream.match(/["']/, /* eat */ false)) {
|
|
|
284 |
return "string";
|
|
|
285 |
}
|
|
|
286 |
return false;
|
|
|
287 |
}
|
|
|
288 |
// Ignore this hook.
|
|
|
289 |
stream.next();
|
|
|
290 |
return false;
|
|
|
291 |
}
|
|
|
292 |
|
|
|
293 |
function cppLooksLikeConstructor(word) {
|
|
|
294 |
var lastTwo = /(\w+)::(\w+)$/.exec(word);
|
|
|
295 |
return lastTwo && lastTwo[1] == lastTwo[2];
|
|
|
296 |
}
|
|
|
297 |
|
|
|
298 |
// C#-style strings where "" escapes a quote.
|
|
|
299 |
function tokenAtString(stream, state) {
|
|
|
300 |
var next;
|
|
|
301 |
while ((next = stream.next()) != null) {
|
|
|
302 |
if (next == '"' && !stream.eat('"')) {
|
|
|
303 |
state.tokenize = null;
|
|
|
304 |
break;
|
|
|
305 |
}
|
|
|
306 |
}
|
|
|
307 |
return "string";
|
|
|
308 |
}
|
|
|
309 |
|
|
|
310 |
// C++11 raw string literal is <prefix>"<delim>( anything )<delim>", where
|
|
|
311 |
// <delim> can be a string up to 16 characters long.
|
|
|
312 |
function tokenRawString(stream, state) {
|
|
|
313 |
// Escape characters that have special regex meanings.
|
|
|
314 |
var delim = state.cpp11RawStringDelim.replace(/[^\w\s]/g, '\\$&');
|
|
|
315 |
var match = stream.match(new RegExp(".*?\\)" + delim + '"'));
|
|
|
316 |
if (match)
|
|
|
317 |
state.tokenize = null;
|
|
|
318 |
else
|
|
|
319 |
stream.skipToEnd();
|
|
|
320 |
return "string";
|
|
|
321 |
}
|
|
|
322 |
|
|
|
323 |
function def(mimes, mode) {
|
|
|
324 |
if (typeof mimes == "string") mimes = [mimes];
|
|
|
325 |
var words = [];
|
|
|
326 |
function add(obj) {
|
|
|
327 |
if (obj) for (var prop in obj) if (obj.hasOwnProperty(prop))
|
|
|
328 |
words.push(prop);
|
|
|
329 |
}
|
|
|
330 |
add(mode.keywords);
|
|
|
331 |
add(mode.types);
|
|
|
332 |
add(mode.builtin);
|
|
|
333 |
add(mode.atoms);
|
|
|
334 |
if (words.length) {
|
|
|
335 |
mode.helperType = mimes[0];
|
|
|
336 |
CodeMirror.registerHelper("hintWords", mimes[0], words);
|
|
|
337 |
}
|
|
|
338 |
|
|
|
339 |
for (var i = 0; i < mimes.length; ++i)
|
|
|
340 |
CodeMirror.defineMIME(mimes[i], mode);
|
|
|
341 |
}
|
|
|
342 |
|
|
|
343 |
def(["text/x-csrc", "text/x-c", "text/x-chdr"], {
|
|
|
344 |
name: "clike",
|
|
|
345 |
keywords: words(cKeywords),
|
|
|
346 |
types: words(cTypes + " bool _Complex _Bool float_t double_t intptr_t intmax_t " +
|
|
|
347 |
"int8_t int16_t int32_t int64_t uintptr_t uintmax_t uint8_t uint16_t " +
|
|
|
348 |
"uint32_t uint64_t"),
|
|
|
349 |
blockKeywords: words("case do else for if switch while struct"),
|
|
|
350 |
defKeywords: words("struct"),
|
|
|
351 |
typeFirstDefinitions: true,
|
|
|
352 |
atoms: words("null true false"),
|
|
|
353 |
hooks: {"#": cppHook, "*": pointerHook},
|
|
|
354 |
modeProps: {fold: ["brace", "include"]}
|
|
|
355 |
});
|
|
|
356 |
|
|
|
357 |
def(["text/x-c++src", "text/x-c++hdr"], {
|
|
|
358 |
name: "clike",
|
|
|
359 |
keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try explicit new " +
|
|
|
360 |
"static_cast typeid catch operator template typename class friend private " +
|
|
|
361 |
"this using const_cast inline public throw virtual delete mutable protected " +
|
|
|
362 |
"alignas alignof constexpr decltype nullptr noexcept thread_local final " +
|
|
|
363 |
"static_assert override"),
|
|
|
364 |
types: words(cTypes + " bool wchar_t"),
|
|
|
365 |
blockKeywords: words("catch class do else finally for if struct switch try while"),
|
|
|
366 |
defKeywords: words("class namespace struct enum union"),
|
|
|
367 |
typeFirstDefinitions: true,
|
|
|
368 |
atoms: words("true false null"),
|
|
|
369 |
hooks: {
|
|
|
370 |
"#": cppHook,
|
|
|
371 |
"*": pointerHook,
|
|
|
372 |
"u": cpp11StringHook,
|
|
|
373 |
"U": cpp11StringHook,
|
|
|
374 |
"L": cpp11StringHook,
|
|
|
375 |
"R": cpp11StringHook,
|
|
|
376 |
token: function(stream, state, style) {
|
|
|
377 |
if (style == "variable" && stream.peek() == "(" &&
|
|
|
378 |
(state.prevToken == ";" || state.prevToken == null ||
|
|
|
379 |
state.prevToken == "}") &&
|
|
|
380 |
cppLooksLikeConstructor(stream.current()))
|
|
|
381 |
return "def";
|
|
|
382 |
}
|
|
|
383 |
},
|
|
|
384 |
namespaceSeparator: "::",
|
|
|
385 |
modeProps: {fold: ["brace", "include"]}
|
|
|
386 |
});
|
|
|
387 |
|
|
|
388 |
def("text/x-java", {
|
|
|
389 |
name: "clike",
|
|
|
390 |
keywords: words("abstract assert break case catch class const continue default " +
|
|
|
391 |
"do else enum extends final finally float for goto if implements import " +
|
|
|
392 |
"instanceof interface native new package private protected public " +
|
|
|
393 |
"return static strictfp super switch synchronized this throw throws transient " +
|
|
|
394 |
"try volatile while"),
|
|
|
395 |
types: words("byte short int long float double boolean char void Boolean Byte Character Double Float " +
|
|
|
396 |
"Integer Long Number Object Short String StringBuffer StringBuilder Void"),
|
|
|
397 |
blockKeywords: words("catch class do else finally for if switch try while"),
|
|
|
398 |
defKeywords: words("class interface package enum"),
|
|
|
399 |
typeFirstDefinitions: true,
|
|
|
400 |
atoms: words("true false null"),
|
|
|
401 |
hooks: {
|
|
|
402 |
"@": function(stream) {
|
|
|
403 |
stream.eatWhile(/[\w\$_]/);
|
|
|
404 |
return "meta";
|
|
|
405 |
}
|
|
|
406 |
},
|
|
|
407 |
modeProps: {fold: ["brace", "import"]}
|
|
|
408 |
});
|
|
|
409 |
|
|
|
410 |
def("text/x-csharp", {
|
|
|
411 |
name: "clike",
|
|
|
412 |
keywords: words("abstract as async await base break case catch checked class const continue" +
|
|
|
413 |
" default delegate do else enum event explicit extern finally fixed for" +
|
|
|
414 |
" foreach goto if implicit in interface internal is lock namespace new" +
|
|
|
415 |
" operator out override params private protected public readonly ref return sealed" +
|
|
|
416 |
" sizeof stackalloc static struct switch this throw try typeof unchecked" +
|
|
|
417 |
" unsafe using virtual void volatile while add alias ascending descending dynamic from get" +
|
|
|
418 |
" global group into join let orderby partial remove select set value var yield"),
|
|
|
419 |
types: words("Action Boolean Byte Char DateTime DateTimeOffset Decimal Double Func" +
|
|
|
420 |
" Guid Int16 Int32 Int64 Object SByte Single String Task TimeSpan UInt16 UInt32" +
|
|
|
421 |
" UInt64 bool byte char decimal double short int long object" +
|
|
|
422 |
" sbyte float string ushort uint ulong"),
|
|
|
423 |
blockKeywords: words("catch class do else finally for foreach if struct switch try while"),
|
|
|
424 |
defKeywords: words("class interface namespace struct var"),
|
|
|
425 |
typeFirstDefinitions: true,
|
|
|
426 |
atoms: words("true false null"),
|
|
|
427 |
hooks: {
|
|
|
428 |
"@": function(stream, state) {
|
|
|
429 |
if (stream.eat('"')) {
|
|
|
430 |
state.tokenize = tokenAtString;
|
|
|
431 |
return tokenAtString(stream, state);
|
|
|
432 |
}
|
|
|
433 |
stream.eatWhile(/[\w\$_]/);
|
|
|
434 |
return "meta";
|
|
|
435 |
}
|
|
|
436 |
}
|
|
|
437 |
});
|
|
|
438 |
|
|
|
439 |
function tokenTripleString(stream, state) {
|
|
|
440 |
var escaped = false;
|
|
|
441 |
while (!stream.eol()) {
|
|
|
442 |
if (!escaped && stream.match('"""')) {
|
|
|
443 |
state.tokenize = null;
|
|
|
444 |
break;
|
|
|
445 |
}
|
|
|
446 |
escaped = stream.next() == "\\" && !escaped;
|
|
|
447 |
}
|
|
|
448 |
return "string";
|
|
|
449 |
}
|
|
|
450 |
|
|
|
451 |
def("text/x-scala", {
|
|
|
452 |
name: "clike",
|
|
|
453 |
keywords: words(
|
|
|
454 |
|
|
|
455 |
/* scala */
|
|
|
456 |
"abstract case catch class def do else extends false final finally for forSome if " +
|
|
|
457 |
"implicit import lazy match new null object override package private protected return " +
|
|
|
458 |
"sealed super this throw trait try type val var while with yield _ : = => <- <: " +
|
|
|
459 |
"<% >: # @ " +
|
|
|
460 |
|
|
|
461 |
/* package scala */
|
|
|
462 |
"assert assume require print println printf readLine readBoolean readByte readShort " +
|
|
|
463 |
"readChar readInt readLong readFloat readDouble " +
|
|
|
464 |
|
|
|
465 |
":: #:: "
|
|
|
466 |
),
|
|
|
467 |
types: words(
|
|
|
468 |
"AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " +
|
|
|
469 |
"Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral Iterable " +
|
|
|
470 |
"Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " +
|
|
|
471 |
"Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " +
|
|
|
472 |
"StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector " +
|
|
|
473 |
|
|
|
474 |
/* package java.lang */
|
|
|
475 |
"Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
|
|
|
476 |
"Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
|
|
|
477 |
"Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
|
|
|
478 |
"StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
|
|
|
479 |
),
|
|
|
480 |
multiLineStrings: true,
|
|
|
481 |
blockKeywords: words("catch class do else finally for forSome if match switch try while"),
|
|
|
482 |
defKeywords: words("class def object package trait type val var"),
|
|
|
483 |
atoms: words("true false null"),
|
|
|
484 |
indentStatements: false,
|
|
|
485 |
indentSwitch: false,
|
|
|
486 |
hooks: {
|
|
|
487 |
"@": function(stream) {
|
|
|
488 |
stream.eatWhile(/[\w\$_]/);
|
|
|
489 |
return "meta";
|
|
|
490 |
},
|
|
|
491 |
'"': function(stream, state) {
|
|
|
492 |
if (!stream.match('""')) return false;
|
|
|
493 |
state.tokenize = tokenTripleString;
|
|
|
494 |
return state.tokenize(stream, state);
|
|
|
495 |
},
|
|
|
496 |
"'": function(stream) {
|
|
|
497 |
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
|
|
|
498 |
return "atom";
|
|
|
499 |
}
|
|
|
500 |
},
|
|
|
501 |
modeProps: {closeBrackets: {triples: '"'}}
|
|
|
502 |
});
|
|
|
503 |
|
|
|
504 |
def(["x-shader/x-vertex", "x-shader/x-fragment"], {
|
|
|
505 |
name: "clike",
|
|
|
506 |
keywords: words("sampler1D sampler2D sampler3D samplerCube " +
|
|
|
507 |
"sampler1DShadow sampler2DShadow " +
|
|
|
508 |
"const attribute uniform varying " +
|
|
|
509 |
"break continue discard return " +
|
|
|
510 |
"for while do if else struct " +
|
|
|
511 |
"in out inout"),
|
|
|
512 |
types: words("float int bool void " +
|
|
|
513 |
"vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 " +
|
|
|
514 |
"mat2 mat3 mat4"),
|
|
|
515 |
blockKeywords: words("for while do if else struct"),
|
|
|
516 |
builtin: words("radians degrees sin cos tan asin acos atan " +
|
|
|
517 |
"pow exp log exp2 sqrt inversesqrt " +
|
|
|
518 |
"abs sign floor ceil fract mod min max clamp mix step smoothstep " +
|
|
|
519 |
"length distance dot cross normalize ftransform faceforward " +
|
|
|
520 |
"reflect refract matrixCompMult " +
|
|
|
521 |
"lessThan lessThanEqual greaterThan greaterThanEqual " +
|
|
|
522 |
"equal notEqual any all not " +
|
|
|
523 |
"texture1D texture1DProj texture1DLod texture1DProjLod " +
|
|
|
524 |
"texture2D texture2DProj texture2DLod texture2DProjLod " +
|
|
|
525 |
"texture3D texture3DProj texture3DLod texture3DProjLod " +
|
|
|
526 |
"textureCube textureCubeLod " +
|
|
|
527 |
"shadow1D shadow2D shadow1DProj shadow2DProj " +
|
|
|
528 |
"shadow1DLod shadow2DLod shadow1DProjLod shadow2DProjLod " +
|
|
|
529 |
"dFdx dFdy fwidth " +
|
|
|
530 |
"noise1 noise2 noise3 noise4"),
|
|
|
531 |
atoms: words("true false " +
|
|
|
532 |
"gl_FragColor gl_SecondaryColor gl_Normal gl_Vertex " +
|
|
|
533 |
"gl_MultiTexCoord0 gl_MultiTexCoord1 gl_MultiTexCoord2 gl_MultiTexCoord3 " +
|
|
|
534 |
"gl_MultiTexCoord4 gl_MultiTexCoord5 gl_MultiTexCoord6 gl_MultiTexCoord7 " +
|
|
|
535 |
"gl_FogCoord gl_PointCoord " +
|
|
|
536 |
"gl_Position gl_PointSize gl_ClipVertex " +
|
|
|
537 |
"gl_FrontColor gl_BackColor gl_FrontSecondaryColor gl_BackSecondaryColor " +
|
|
|
538 |
"gl_TexCoord gl_FogFragCoord " +
|
|
|
539 |
"gl_FragCoord gl_FrontFacing " +
|
|
|
540 |
"gl_FragData gl_FragDepth " +
|
|
|
541 |
"gl_ModelViewMatrix gl_ProjectionMatrix gl_ModelViewProjectionMatrix " +
|
|
|
542 |
"gl_TextureMatrix gl_NormalMatrix gl_ModelViewMatrixInverse " +
|
|
|
543 |
"gl_ProjectionMatrixInverse gl_ModelViewProjectionMatrixInverse " +
|
|
|
544 |
"gl_TexureMatrixTranspose gl_ModelViewMatrixInverseTranspose " +
|
|
|
545 |
"gl_ProjectionMatrixInverseTranspose " +
|
|
|
546 |
"gl_ModelViewProjectionMatrixInverseTranspose " +
|
|
|
547 |
"gl_TextureMatrixInverseTranspose " +
|
|
|
548 |
"gl_NormalScale gl_DepthRange gl_ClipPlane " +
|
|
|
549 |
"gl_Point gl_FrontMaterial gl_BackMaterial gl_LightSource gl_LightModel " +
|
|
|
550 |
"gl_FrontLightModelProduct gl_BackLightModelProduct " +
|
|
|
551 |
"gl_TextureColor gl_EyePlaneS gl_EyePlaneT gl_EyePlaneR gl_EyePlaneQ " +
|
|
|
552 |
"gl_FogParameters " +
|
|
|
553 |
"gl_MaxLights gl_MaxClipPlanes gl_MaxTextureUnits gl_MaxTextureCoords " +
|
|
|
554 |
"gl_MaxVertexAttribs gl_MaxVertexUniformComponents gl_MaxVaryingFloats " +
|
|
|
555 |
"gl_MaxVertexTextureImageUnits gl_MaxTextureImageUnits " +
|
|
|
556 |
"gl_MaxFragmentUniformComponents gl_MaxCombineTextureImageUnits " +
|
|
|
557 |
"gl_MaxDrawBuffers"),
|
|
|
558 |
indentSwitch: false,
|
|
|
559 |
hooks: {"#": cppHook},
|
|
|
560 |
modeProps: {fold: ["brace", "include"]}
|
|
|
561 |
});
|
|
|
562 |
|
|
|
563 |
def("text/x-nesc", {
|
|
|
564 |
name: "clike",
|
|
|
565 |
keywords: words(cKeywords + "as atomic async call command component components configuration event generic " +
|
|
|
566 |
"implementation includes interface module new norace nx_struct nx_union post provides " +
|
|
|
567 |
"signal task uses abstract extends"),
|
|
|
568 |
types: words(cTypes),
|
|
|
569 |
blockKeywords: words("case do else for if switch while struct"),
|
|
|
570 |
atoms: words("null true false"),
|
|
|
571 |
hooks: {"#": cppHook},
|
|
|
572 |
modeProps: {fold: ["brace", "include"]}
|
|
|
573 |
});
|
|
|
574 |
|
|
|
575 |
def("text/x-objectivec", {
|
|
|
576 |
name: "clike",
|
|
|
577 |
keywords: words(cKeywords + "inline restrict _Bool _Complex _Imaginery BOOL Class bycopy byref id IMP in " +
|
|
|
578 |
"inout nil oneway out Protocol SEL self super atomic nonatomic retain copy readwrite readonly"),
|
|
|
579 |
types: words(cTypes),
|
|
|
580 |
atoms: words("YES NO NULL NILL ON OFF true false"),
|
|
|
581 |
hooks: {
|
|
|
582 |
"@": function(stream) {
|
|
|
583 |
stream.eatWhile(/[\w\$]/);
|
|
|
584 |
return "keyword";
|
|
|
585 |
},
|
|
|
586 |
"#": cppHook
|
|
|
587 |
},
|
|
|
588 |
modeProps: {fold: "brace"}
|
|
|
589 |
});
|
|
|
590 |
|
|
|
591 |
def("text/x-squirrel", {
|
|
|
592 |
name: "clike",
|
|
|
593 |
keywords: words("base break clone continue const default delete enum extends function in class" +
|
|
|
594 |
" foreach local resume return this throw typeof yield constructor instanceof static"),
|
|
|
595 |
types: words(cTypes),
|
|
|
596 |
blockKeywords: words("case catch class else for foreach if switch try while"),
|
|
|
597 |
defKeywords: words("function local class"),
|
|
|
598 |
typeFirstDefinitions: true,
|
|
|
599 |
atoms: words("true false null"),
|
|
|
600 |
hooks: {"#": cppHook},
|
|
|
601 |
modeProps: {fold: ["brace", "include"]}
|
|
|
602 |
});
|
|
|
603 |
|
|
|
604 |
});
|