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