autorefresh.js
9 years ago
clike.js
10 years ago
codemirror.css
9 years ago
codemirror.js
9 years ago
htmlmixed.js
10 years ago
javascript.js
10 years ago
matchbrackets.js
10 years ago
php.js
10 years ago
xml.js
10 years ago
clike.js
648 lines
| 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 cpp14Literal(stream) { |
| 270 | stream.eatWhile(/[\w\.']/); |
| 271 | return "number"; |
| 272 | } |
| 273 | |
| 274 | function cpp11StringHook(stream, state) { |
| 275 | stream.backUp(1); |
| 276 | // Raw strings. |
| 277 | if (stream.match(/(R|u8R|uR|UR|LR)/)) { |
| 278 | var match = stream.match(/"([^\s\\()]{0,16})\(/); |
| 279 | if (!match) { |
| 280 | return false; |
| 281 | } |
| 282 | state.cpp11RawStringDelim = match[1]; |
| 283 | state.tokenize = tokenRawString; |
| 284 | return tokenRawString(stream, state); |
| 285 | } |
| 286 | // Unicode strings/chars. |
| 287 | if (stream.match(/(u8|u|U|L)/)) { |
| 288 | if (stream.match(/["']/, /* eat */ false)) { |
| 289 | return "string"; |
| 290 | } |
| 291 | return false; |
| 292 | } |
| 293 | // Ignore this hook. |
| 294 | stream.next(); |
| 295 | return false; |
| 296 | } |
| 297 | |
| 298 | function cppLooksLikeConstructor(word) { |
| 299 | var lastTwo = /(\w+)::(\w+)$/.exec(word); |
| 300 | return lastTwo && lastTwo[1] == lastTwo[2]; |
| 301 | } |
| 302 | |
| 303 | // C#-style strings where "" escapes a quote. |
| 304 | function tokenAtString(stream, state) { |
| 305 | var next; |
| 306 | while ((next = stream.next()) != null) { |
| 307 | if (next == '"' && !stream.eat('"')) { |
| 308 | state.tokenize = null; |
| 309 | break; |
| 310 | } |
| 311 | } |
| 312 | return "string"; |
| 313 | } |
| 314 | |
| 315 | // C++11 raw string literal is <prefix>"<delim>( anything )<delim>", where |
| 316 | // <delim> can be a string up to 16 characters long. |
| 317 | function tokenRawString(stream, state) { |
| 318 | // Escape characters that have special regex meanings. |
| 319 | var delim = state.cpp11RawStringDelim.replace(/[^\w\s]/g, '\\$&'); |
| 320 | var match = stream.match(new RegExp(".*?\\)" + delim + '"')); |
| 321 | if (match) |
| 322 | state.tokenize = null; |
| 323 | else |
| 324 | stream.skipToEnd(); |
| 325 | return "string"; |
| 326 | } |
| 327 | |
| 328 | function def(mimes, mode) { |
| 329 | if (typeof mimes == "string") mimes = [mimes]; |
| 330 | var words = []; |
| 331 | function add(obj) { |
| 332 | if (obj) for (var prop in obj) if (obj.hasOwnProperty(prop)) |
| 333 | words.push(prop); |
| 334 | } |
| 335 | add(mode.keywords); |
| 336 | add(mode.types); |
| 337 | add(mode.builtin); |
| 338 | add(mode.atoms); |
| 339 | if (words.length) { |
| 340 | mode.helperType = mimes[0]; |
| 341 | CodeMirror.registerHelper("hintWords", mimes[0], words); |
| 342 | } |
| 343 | |
| 344 | for (var i = 0; i < mimes.length; ++i) |
| 345 | CodeMirror.defineMIME(mimes[i], mode); |
| 346 | } |
| 347 | |
| 348 | def(["text/x-csrc", "text/x-c", "text/x-chdr"], { |
| 349 | name: "clike", |
| 350 | keywords: words(cKeywords), |
| 351 | types: words(cTypes + " bool _Complex _Bool float_t double_t intptr_t intmax_t " + |
| 352 | "int8_t int16_t int32_t int64_t uintptr_t uintmax_t uint8_t uint16_t " + |
| 353 | "uint32_t uint64_t"), |
| 354 | blockKeywords: words("case do else for if switch while struct"), |
| 355 | defKeywords: words("struct"), |
| 356 | typeFirstDefinitions: true, |
| 357 | atoms: words("null true false"), |
| 358 | hooks: {"#": cppHook, "*": pointerHook}, |
| 359 | modeProps: {fold: ["brace", "include"]} |
| 360 | }); |
| 361 | |
| 362 | def(["text/x-c++src", "text/x-c++hdr"], { |
| 363 | name: "clike", |
| 364 | keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try explicit new " + |
| 365 | "static_cast typeid catch operator template typename class friend private " + |
| 366 | "this using const_cast inline public throw virtual delete mutable protected " + |
| 367 | "alignas alignof constexpr decltype nullptr noexcept thread_local final " + |
| 368 | "static_assert override"), |
| 369 | types: words(cTypes + " bool wchar_t"), |
| 370 | blockKeywords: words("catch class do else finally for if struct switch try while"), |
| 371 | defKeywords: words("class namespace struct enum union"), |
| 372 | typeFirstDefinitions: true, |
| 373 | atoms: words("true false null"), |
| 374 | hooks: { |
| 375 | "#": cppHook, |
| 376 | "*": pointerHook, |
| 377 | "u": cpp11StringHook, |
| 378 | "U": cpp11StringHook, |
| 379 | "L": cpp11StringHook, |
| 380 | "R": cpp11StringHook, |
| 381 | "0": cpp14Literal, |
| 382 | "1": cpp14Literal, |
| 383 | "2": cpp14Literal, |
| 384 | "3": cpp14Literal, |
| 385 | "4": cpp14Literal, |
| 386 | "5": cpp14Literal, |
| 387 | "6": cpp14Literal, |
| 388 | "7": cpp14Literal, |
| 389 | "8": cpp14Literal, |
| 390 | "9": cpp14Literal, |
| 391 | token: function(stream, state, style) { |
| 392 | if (style == "variable" && stream.peek() == "(" && |
| 393 | (state.prevToken == ";" || state.prevToken == null || |
| 394 | state.prevToken == "}") && |
| 395 | cppLooksLikeConstructor(stream.current())) |
| 396 | return "def"; |
| 397 | } |
| 398 | }, |
| 399 | namespaceSeparator: "::", |
| 400 | modeProps: {fold: ["brace", "include"]} |
| 401 | }); |
| 402 | |
| 403 | def("text/x-java", { |
| 404 | name: "clike", |
| 405 | keywords: words("abstract assert break case catch class const continue default " + |
| 406 | "do else enum extends final finally float for goto if implements import " + |
| 407 | "instanceof interface native new package private protected public " + |
| 408 | "return static strictfp super switch synchronized this throw throws transient " + |
| 409 | "try volatile while"), |
| 410 | types: words("byte short int long float double boolean char void Boolean Byte Character Double Float " + |
| 411 | "Integer Long Number Object Short String StringBuffer StringBuilder Void"), |
| 412 | blockKeywords: words("catch class do else finally for if switch try while"), |
| 413 | defKeywords: words("class interface package enum"), |
| 414 | typeFirstDefinitions: true, |
| 415 | atoms: words("true false null"), |
| 416 | hooks: { |
| 417 | "@": function(stream) { |
| 418 | stream.eatWhile(/[\w\$_]/); |
| 419 | return "meta"; |
| 420 | } |
| 421 | }, |
| 422 | modeProps: {fold: ["brace", "import"]} |
| 423 | }); |
| 424 | |
| 425 | def("text/x-csharp", { |
| 426 | name: "clike", |
| 427 | keywords: words("abstract as async await base break case catch checked class const continue" + |
| 428 | " default delegate do else enum event explicit extern finally fixed for" + |
| 429 | " foreach goto if implicit in interface internal is lock namespace new" + |
| 430 | " operator out override params private protected public readonly ref return sealed" + |
| 431 | " sizeof stackalloc static struct switch this throw try typeof unchecked" + |
| 432 | " unsafe using virtual void volatile while add alias ascending descending dynamic from get" + |
| 433 | " global group into join let orderby partial remove select set value var yield"), |
| 434 | types: words("Action Boolean Byte Char DateTime DateTimeOffset Decimal Double Func" + |
| 435 | " Guid Int16 Int32 Int64 Object SByte Single String Task TimeSpan UInt16 UInt32" + |
| 436 | " UInt64 bool byte char decimal double short int long object" + |
| 437 | " sbyte float string ushort uint ulong"), |
| 438 | blockKeywords: words("catch class do else finally for foreach if struct switch try while"), |
| 439 | defKeywords: words("class interface namespace struct var"), |
| 440 | typeFirstDefinitions: true, |
| 441 | atoms: words("true false null"), |
| 442 | hooks: { |
| 443 | "@": function(stream, state) { |
| 444 | if (stream.eat('"')) { |
| 445 | state.tokenize = tokenAtString; |
| 446 | return tokenAtString(stream, state); |
| 447 | } |
| 448 | stream.eatWhile(/[\w\$_]/); |
| 449 | return "meta"; |
| 450 | } |
| 451 | } |
| 452 | }); |
| 453 | |
| 454 | function tokenTripleString(stream, state) { |
| 455 | var escaped = false; |
| 456 | while (!stream.eol()) { |
| 457 | if (!escaped && stream.match('"""')) { |
| 458 | state.tokenize = null; |
| 459 | break; |
| 460 | } |
| 461 | escaped = stream.next() == "\\" && !escaped; |
| 462 | } |
| 463 | return "string"; |
| 464 | } |
| 465 | |
| 466 | def("text/x-scala", { |
| 467 | name: "clike", |
| 468 | keywords: words( |
| 469 | |
| 470 | /* scala */ |
| 471 | "abstract case catch class def do else extends false final finally for forSome if " + |
| 472 | "implicit import lazy match new null object override package private protected return " + |
| 473 | "sealed super this throw trait try type val var while with yield _ : = => <- <: " + |
| 474 | "<% >: # @ " + |
| 475 | |
| 476 | /* package scala */ |
| 477 | "assert assume require print println printf readLine readBoolean readByte readShort " + |
| 478 | "readChar readInt readLong readFloat readDouble " + |
| 479 | |
| 480 | ":: #:: " |
| 481 | ), |
| 482 | types: words( |
| 483 | "AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " + |
| 484 | "Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral Iterable " + |
| 485 | "Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " + |
| 486 | "Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " + |
| 487 | "StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector " + |
| 488 | |
| 489 | /* package java.lang */ |
| 490 | "Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " + |
| 491 | "Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " + |
| 492 | "Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " + |
| 493 | "StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void" |
| 494 | ), |
| 495 | multiLineStrings: true, |
| 496 | blockKeywords: words("catch class do else finally for forSome if match switch try while"), |
| 497 | defKeywords: words("class def object package trait type val var"), |
| 498 | atoms: words("true false null"), |
| 499 | indentStatements: false, |
| 500 | indentSwitch: false, |
| 501 | hooks: { |
| 502 | "@": function(stream) { |
| 503 | stream.eatWhile(/[\w\$_]/); |
| 504 | return "meta"; |
| 505 | }, |
| 506 | '"': function(stream, state) { |
| 507 | if (!stream.match('""')) return false; |
| 508 | state.tokenize = tokenTripleString; |
| 509 | return state.tokenize(stream, state); |
| 510 | }, |
| 511 | "'": function(stream) { |
| 512 | stream.eatWhile(/[\w\$_\xa1-\uffff]/); |
| 513 | return "atom"; |
| 514 | } |
| 515 | }, |
| 516 | modeProps: {closeBrackets: {triples: '"'}} |
| 517 | }); |
| 518 | |
| 519 | def("text/x-kotlin", { |
| 520 | name: "clike", |
| 521 | keywords: words( |
| 522 | /*keywords*/ |
| 523 | "package as typealias class interface this super val " + |
| 524 | "var fun for is in This throw return " + |
| 525 | "break continue object if else while do try when !in !is as?" + |
| 526 | |
| 527 | /*soft keywords*/ |
| 528 | "file import where by get set abstract enum open inner override private public internal " + |
| 529 | "protected catch finally out final vararg reified dynamic companion constructor init " + |
| 530 | "sealed field property receiver param sparam lateinit data inline noinline tailrec " + |
| 531 | "external annotation crossinline" |
| 532 | ), |
| 533 | types: words( |
| 534 | /* package java.lang */ |
| 535 | "Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " + |
| 536 | "Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " + |
| 537 | "Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " + |
| 538 | "StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void" |
| 539 | ), |
| 540 | multiLineStrings: true, |
| 541 | blockKeywords: words("catch class do else finally for if where try while enum"), |
| 542 | defKeywords: words("class val var object package interface fun"), |
| 543 | atoms: words("true false null this"), |
| 544 | modeProps: {closeBrackets: {triples: '"'}} |
| 545 | }); |
| 546 | |
| 547 | def(["x-shader/x-vertex", "x-shader/x-fragment"], { |
| 548 | name: "clike", |
| 549 | keywords: words("sampler1D sampler2D sampler3D samplerCube " + |
| 550 | "sampler1DShadow sampler2DShadow " + |
| 551 | "const attribute uniform varying " + |
| 552 | "break continue discard return " + |
| 553 | "for while do if else struct " + |
| 554 | "in out inout"), |
| 555 | types: words("float int bool void " + |
| 556 | "vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 " + |
| 557 | "mat2 mat3 mat4"), |
| 558 | blockKeywords: words("for while do if else struct"), |
| 559 | builtin: words("radians degrees sin cos tan asin acos atan " + |
| 560 | "pow exp log exp2 sqrt inversesqrt " + |
| 561 | "abs sign floor ceil fract mod min max clamp mix step smoothstep " + |
| 562 | "length distance dot cross normalize ftransform faceforward " + |
| 563 | "reflect refract matrixCompMult " + |
| 564 | "lessThan lessThanEqual greaterThan greaterThanEqual " + |
| 565 | "equal notEqual any all not " + |
| 566 | "texture1D texture1DProj texture1DLod texture1DProjLod " + |
| 567 | "texture2D texture2DProj texture2DLod texture2DProjLod " + |
| 568 | "texture3D texture3DProj texture3DLod texture3DProjLod " + |
| 569 | "textureCube textureCubeLod " + |
| 570 | "shadow1D shadow2D shadow1DProj shadow2DProj " + |
| 571 | "shadow1DLod shadow2DLod shadow1DProjLod shadow2DProjLod " + |
| 572 | "dFdx dFdy fwidth " + |
| 573 | "noise1 noise2 noise3 noise4"), |
| 574 | atoms: words("true false " + |
| 575 | "gl_FragColor gl_SecondaryColor gl_Normal gl_Vertex " + |
| 576 | "gl_MultiTexCoord0 gl_MultiTexCoord1 gl_MultiTexCoord2 gl_MultiTexCoord3 " + |
| 577 | "gl_MultiTexCoord4 gl_MultiTexCoord5 gl_MultiTexCoord6 gl_MultiTexCoord7 " + |
| 578 | "gl_FogCoord gl_PointCoord " + |
| 579 | "gl_Position gl_PointSize gl_ClipVertex " + |
| 580 | "gl_FrontColor gl_BackColor gl_FrontSecondaryColor gl_BackSecondaryColor " + |
| 581 | "gl_TexCoord gl_FogFragCoord " + |
| 582 | "gl_FragCoord gl_FrontFacing " + |
| 583 | "gl_FragData gl_FragDepth " + |
| 584 | "gl_ModelViewMatrix gl_ProjectionMatrix gl_ModelViewProjectionMatrix " + |
| 585 | "gl_TextureMatrix gl_NormalMatrix gl_ModelViewMatrixInverse " + |
| 586 | "gl_ProjectionMatrixInverse gl_ModelViewProjectionMatrixInverse " + |
| 587 | "gl_TexureMatrixTranspose gl_ModelViewMatrixInverseTranspose " + |
| 588 | "gl_ProjectionMatrixInverseTranspose " + |
| 589 | "gl_ModelViewProjectionMatrixInverseTranspose " + |
| 590 | "gl_TextureMatrixInverseTranspose " + |
| 591 | "gl_NormalScale gl_DepthRange gl_ClipPlane " + |
| 592 | "gl_Point gl_FrontMaterial gl_BackMaterial gl_LightSource gl_LightModel " + |
| 593 | "gl_FrontLightModelProduct gl_BackLightModelProduct " + |
| 594 | "gl_TextureColor gl_EyePlaneS gl_EyePlaneT gl_EyePlaneR gl_EyePlaneQ " + |
| 595 | "gl_FogParameters " + |
| 596 | "gl_MaxLights gl_MaxClipPlanes gl_MaxTextureUnits gl_MaxTextureCoords " + |
| 597 | "gl_MaxVertexAttribs gl_MaxVertexUniformComponents gl_MaxVaryingFloats " + |
| 598 | "gl_MaxVertexTextureImageUnits gl_MaxTextureImageUnits " + |
| 599 | "gl_MaxFragmentUniformComponents gl_MaxCombineTextureImageUnits " + |
| 600 | "gl_MaxDrawBuffers"), |
| 601 | indentSwitch: false, |
| 602 | hooks: {"#": cppHook}, |
| 603 | modeProps: {fold: ["brace", "include"]} |
| 604 | }); |
| 605 | |
| 606 | def("text/x-nesc", { |
| 607 | name: "clike", |
| 608 | keywords: words(cKeywords + "as atomic async call command component components configuration event generic " + |
| 609 | "implementation includes interface module new norace nx_struct nx_union post provides " + |
| 610 | "signal task uses abstract extends"), |
| 611 | types: words(cTypes), |
| 612 | blockKeywords: words("case do else for if switch while struct"), |
| 613 | atoms: words("null true false"), |
| 614 | hooks: {"#": cppHook}, |
| 615 | modeProps: {fold: ["brace", "include"]} |
| 616 | }); |
| 617 | |
| 618 | def("text/x-objectivec", { |
| 619 | name: "clike", |
| 620 | keywords: words(cKeywords + "inline restrict _Bool _Complex _Imaginery BOOL Class bycopy byref id IMP in " + |
| 621 | "inout nil oneway out Protocol SEL self super atomic nonatomic retain copy readwrite readonly"), |
| 622 | types: words(cTypes), |
| 623 | atoms: words("YES NO NULL NILL ON OFF true false"), |
| 624 | hooks: { |
| 625 | "@": function(stream) { |
| 626 | stream.eatWhile(/[\w\$]/); |
| 627 | return "keyword"; |
| 628 | }, |
| 629 | "#": cppHook |
| 630 | }, |
| 631 | modeProps: {fold: "brace"} |
| 632 | }); |
| 633 | |
| 634 | def("text/x-squirrel", { |
| 635 | name: "clike", |
| 636 | keywords: words("base break clone continue const default delete enum extends function in class" + |
| 637 | " foreach local resume return this throw typeof yield constructor instanceof static"), |
| 638 | types: words(cTypes), |
| 639 | blockKeywords: words("case catch class else for foreach if switch try while"), |
| 640 | defKeywords: words("function local class"), |
| 641 | typeFirstDefinitions: true, |
| 642 | atoms: words("true false null"), |
| 643 | hooks: {"#": cppHook}, |
| 644 | modeProps: {fold: ["brace", "include"]} |
| 645 | }); |
| 646 | |
| 647 | }); |
| 648 |