LaravelTest
935 строк · 36.2 Кб
1// CodeMirror, copyright (c) by Marijn Haverbeke and others
2// Distributed under an MIT license: https://codemirror.net/LICENSE
3
4(function(mod) {5if (typeof exports == "object" && typeof module == "object") // CommonJS6mod(require("../../lib/codemirror"));7else if (typeof define == "function" && define.amd) // AMD8define(["../../lib/codemirror"], mod);9else // Plain browser env10mod(CodeMirror);11})(function(CodeMirror) {12"use strict";13
14function Context(indented, column, type, info, align, prev) {15this.indented = indented;16this.column = column;17this.type = type;18this.info = info;19this.align = align;20this.prev = prev;21}
22function pushContext(state, col, type, info) {23var indent = state.indented;24if (state.context && state.context.type == "statement" && type != "statement")25indent = state.context.indented;26return state.context = new Context(indent, col, type, info, null, state.context);27}
28function popContext(state) {29var t = state.context.type;30if (t == ")" || t == "]" || t == "}")31state.indented = state.context.indented;32return state.context = state.context.prev;33}
34
35function typeBefore(stream, state, pos) {36if (state.prevToken == "variable" || state.prevToken == "type") return true;37if (/\S(?:[^- ]>|[*\]])\s*$|\*$/.test(stream.string.slice(0, pos))) return true;38if (state.typeAtEndOfLine && stream.column() == stream.indentation()) return true;39}
40
41function isTopScope(context) {42for (;;) {43if (!context || context.type == "top") return true;44if (context.type == "}" && context.prev.info != "namespace") return false;45context = context.prev;46}47}
48
49CodeMirror.defineMode("clike", function(config, parserConfig) {50var indentUnit = config.indentUnit,51statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,52dontAlignCalls = parserConfig.dontAlignCalls,53keywords = parserConfig.keywords || {},54types = parserConfig.types || {},55builtin = parserConfig.builtin || {},56blockKeywords = parserConfig.blockKeywords || {},57defKeywords = parserConfig.defKeywords || {},58atoms = parserConfig.atoms || {},59hooks = parserConfig.hooks || {},60multiLineStrings = parserConfig.multiLineStrings,61indentStatements = parserConfig.indentStatements !== false,62indentSwitch = parserConfig.indentSwitch !== false,63namespaceSeparator = parserConfig.namespaceSeparator,64isPunctuationChar = parserConfig.isPunctuationChar || /[\[\]{}\(\),;\:\.]/,65numberStart = parserConfig.numberStart || /[\d\.]/,66number = parserConfig.number || /^(?:0x[a-f\d]+|0b[01]+|(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)(u|ll?|l|f)?/i,67isOperatorChar = parserConfig.isOperatorChar || /[+\-*&%=<>!?|\/]/,68isIdentifierChar = parserConfig.isIdentifierChar || /[\w\$_\xa1-\uffff]/,69// An optional function that takes a {string} token and returns true if it70// should be treated as a builtin.71isReservedIdentifier = parserConfig.isReservedIdentifier || false;72
73var curPunc, isDefKeyword;74
75function tokenBase(stream, state) {76var ch = stream.next();77if (hooks[ch]) {78var result = hooks[ch](stream, state);79if (result !== false) return result;80}81if (ch == '"' || ch == "'") {82state.tokenize = tokenString(ch);83return state.tokenize(stream, state);84}85if (numberStart.test(ch)) {86stream.backUp(1)87if (stream.match(number)) return "number"88stream.next()89}90if (isPunctuationChar.test(ch)) {91curPunc = ch;92return null;93}94if (ch == "/") {95if (stream.eat("*")) {96state.tokenize = tokenComment;97return tokenComment(stream, state);98}99if (stream.eat("/")) {100stream.skipToEnd();101return "comment";102}103}104if (isOperatorChar.test(ch)) {105while (!stream.match(/^\/[\/*]/, false) && stream.eat(isOperatorChar)) {}106return "operator";107}108stream.eatWhile(isIdentifierChar);109if (namespaceSeparator) while (stream.match(namespaceSeparator))110stream.eatWhile(isIdentifierChar);111
112var cur = stream.current();113if (contains(keywords, cur)) {114if (contains(blockKeywords, cur)) curPunc = "newstatement";115if (contains(defKeywords, cur)) isDefKeyword = true;116return "keyword";117}118if (contains(types, cur)) return "type";119if (contains(builtin, cur)120|| (isReservedIdentifier && isReservedIdentifier(cur))) {121if (contains(blockKeywords, cur)) curPunc = "newstatement";122return "builtin";123}124if (contains(atoms, cur)) return "atom";125return "variable";126}127
128function tokenString(quote) {129return function(stream, state) {130var escaped = false, next, end = false;131while ((next = stream.next()) != null) {132if (next == quote && !escaped) {end = true; break;}133escaped = !escaped && next == "\\";134}135if (end || !(escaped || multiLineStrings))136state.tokenize = null;137return "string";138};139}140
141function tokenComment(stream, state) {142var maybeEnd = false, ch;143while (ch = stream.next()) {144if (ch == "/" && maybeEnd) {145state.tokenize = null;146break;147}148maybeEnd = (ch == "*");149}150return "comment";151}152
153function maybeEOL(stream, state) {154if (parserConfig.typeFirstDefinitions && stream.eol() && isTopScope(state.context))155state.typeAtEndOfLine = typeBefore(stream, state, stream.pos)156}157
158// Interface159
160return {161startState: function(basecolumn) {162return {163tokenize: null,164context: new Context((basecolumn || 0) - indentUnit, 0, "top", null, false),165indented: 0,166startOfLine: true,167prevToken: null168};169},170
171token: function(stream, state) {172var ctx = state.context;173if (stream.sol()) {174if (ctx.align == null) ctx.align = false;175state.indented = stream.indentation();176state.startOfLine = true;177}178if (stream.eatSpace()) { maybeEOL(stream, state); return null; }179curPunc = isDefKeyword = null;180var style = (state.tokenize || tokenBase)(stream, state);181if (style == "comment" || style == "meta") return style;182if (ctx.align == null) ctx.align = true;183
184if (curPunc == ";" || curPunc == ":" || (curPunc == "," && stream.match(/^\s*(?:\/\/.*)?$/, false)))185while (state.context.type == "statement") popContext(state);186else if (curPunc == "{") pushContext(state, stream.column(), "}");187else if (curPunc == "[") pushContext(state, stream.column(), "]");188else if (curPunc == "(") pushContext(state, stream.column(), ")");189else if (curPunc == "}") {190while (ctx.type == "statement") ctx = popContext(state);191if (ctx.type == "}") ctx = popContext(state);192while (ctx.type == "statement") ctx = popContext(state);193}194else if (curPunc == ctx.type) popContext(state);195else if (indentStatements &&196(((ctx.type == "}" || ctx.type == "top") && curPunc != ";") ||197(ctx.type == "statement" && curPunc == "newstatement"))) {198pushContext(state, stream.column(), "statement", stream.current());199}200
201if (style == "variable" &&202((state.prevToken == "def" ||203(parserConfig.typeFirstDefinitions && typeBefore(stream, state, stream.start) &&204isTopScope(state.context) && stream.match(/^\s*\(/, false)))))205style = "def";206
207if (hooks.token) {208var result = hooks.token(stream, state, style);209if (result !== undefined) style = result;210}211
212if (style == "def" && parserConfig.styleDefs === false) style = "variable";213
214state.startOfLine = false;215state.prevToken = isDefKeyword ? "def" : style || curPunc;216maybeEOL(stream, state);217return style;218},219
220indent: function(state, textAfter) {221if (state.tokenize != tokenBase && state.tokenize != null || state.typeAtEndOfLine) return CodeMirror.Pass;222var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);223var closing = firstChar == ctx.type;224if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;225if (parserConfig.dontIndentStatements)226while (ctx.type == "statement" && parserConfig.dontIndentStatements.test(ctx.info))227ctx = ctx.prev228if (hooks.indent) {229var hook = hooks.indent(state, ctx, textAfter, indentUnit);230if (typeof hook == "number") return hook231}232var switchBlock = ctx.prev && ctx.prev.info == "switch";233if (parserConfig.allmanIndentation && /[{(]/.test(firstChar)) {234while (ctx.type != "top" && ctx.type != "}") ctx = ctx.prev235return ctx.indented236}237if (ctx.type == "statement")238return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);239if (ctx.align && (!dontAlignCalls || ctx.type != ")"))240return ctx.column + (closing ? 0 : 1);241if (ctx.type == ")" && !closing)242return ctx.indented + statementIndentUnit;243
244return ctx.indented + (closing ? 0 : indentUnit) +245(!closing && switchBlock && !/^(?:case|default)\b/.test(textAfter) ? indentUnit : 0);246},247
248electricInput: indentSwitch ? /^\s*(?:case .*?:|default:|\{\}?|\})$/ : /^\s*[{}]$/,249blockCommentStart: "/*",250blockCommentEnd: "*/",251blockCommentContinue: " * ",252lineComment: "//",253fold: "brace"254};255});256
257function words(str) {258var obj = {}, words = str.split(" ");259for (var i = 0; i < words.length; ++i) obj[words[i]] = true;260return obj;261}262function contains(words, word) {263if (typeof words === "function") {264return words(word);265} else {266return words.propertyIsEnumerable(word);267}268}269var cKeywords = "auto if break case register continue return default do sizeof " +270"static else struct switch extern typedef union for goto while enum const " +271"volatile inline restrict asm fortran";272
273// Keywords from https://en.cppreference.com/w/cpp/keyword includes C++20.274var cppKeywords = "alignas alignof and and_eq audit axiom bitand bitor catch " +275"class compl concept constexpr const_cast decltype delete dynamic_cast " +276"explicit export final friend import module mutable namespace new noexcept " +277"not not_eq operator or or_eq override private protected public " +278"reinterpret_cast requires static_assert static_cast template this " +279"thread_local throw try typeid typename using virtual xor xor_eq";280
281var objCKeywords = "bycopy byref in inout oneway out self super atomic nonatomic retain copy " +282"readwrite readonly strong weak assign typeof nullable nonnull null_resettable _cmd " +283"@interface @implementation @end @protocol @encode @property @synthesize @dynamic @class " +284"@public @package @private @protected @required @optional @try @catch @finally @import " +285"@selector @encode @defs @synchronized @autoreleasepool @compatibility_alias @available";286
287var objCBuiltins = "FOUNDATION_EXPORT FOUNDATION_EXTERN NS_INLINE NS_FORMAT_FUNCTION " +288" NS_RETURNS_RETAINEDNS_ERROR_ENUM NS_RETURNS_NOT_RETAINED NS_RETURNS_INNER_POINTER " +289"NS_DESIGNATED_INITIALIZER NS_ENUM NS_OPTIONS NS_REQUIRES_NIL_TERMINATION " +290"NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_END NS_SWIFT_NAME NS_REFINED_FOR_SWIFT"291
292// Do not use this. Use the cTypes function below. This is global just to avoid293// excessive calls when cTypes is being called multiple times during a parse.294var basicCTypes = words("int long char short double float unsigned signed " +295"void bool");296
297// Do not use this. Use the objCTypes function below. This is global just to avoid298// excessive calls when objCTypes is being called multiple times during a parse.299var basicObjCTypes = words("SEL instancetype id Class Protocol BOOL");300
301// Returns true if identifier is a "C" type.302// C type is defined as those that are reserved by the compiler (basicTypes),303// and those that end in _t (Reserved by POSIX for types)304// http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html305function cTypes(identifier) {306return contains(basicCTypes, identifier) || /.+_t$/.test(identifier);307}308
309// Returns true if identifier is a "Objective C" type.310function objCTypes(identifier) {311return cTypes(identifier) || contains(basicObjCTypes, identifier);312}313
314var cBlockKeywords = "case do else for if switch while struct enum union";315var cDefKeywords = "struct enum union";316
317function cppHook(stream, state) {318if (!state.startOfLine) return false319for (var ch, next = null; ch = stream.peek();) {320if (ch == "\\" && stream.match(/^.$/)) {321next = cppHook322break323} else if (ch == "/" && stream.match(/^\/[\/\*]/, false)) {324break325}326stream.next()327}328state.tokenize = next329return "meta"330}331
332function pointerHook(_stream, state) {333if (state.prevToken == "type") return "type";334return false;335}336
337// For C and C++ (and ObjC): identifiers starting with __338// or _ followed by a capital letter are reserved for the compiler.339function cIsReservedIdentifier(token) {340if (!token || token.length < 2) return false;341if (token[0] != '_') return false;342return (token[1] == '_') || (token[1] !== token[1].toLowerCase());343}344
345function cpp14Literal(stream) {346stream.eatWhile(/[\w\.']/);347return "number";348}349
350function cpp11StringHook(stream, state) {351stream.backUp(1);352// Raw strings.353if (stream.match(/^(?:R|u8R|uR|UR|LR)/)) {354var match = stream.match(/^"([^\s\\()]{0,16})\(/);355if (!match) {356return false;357}358state.cpp11RawStringDelim = match[1];359state.tokenize = tokenRawString;360return tokenRawString(stream, state);361}362// Unicode strings/chars.363if (stream.match(/^(?:u8|u|U|L)/)) {364if (stream.match(/^["']/, /* eat */ false)) {365return "string";366}367return false;368}369// Ignore this hook.370stream.next();371return false;372}373
374function cppLooksLikeConstructor(word) {375var lastTwo = /(\w+)::~?(\w+)$/.exec(word);376return lastTwo && lastTwo[1] == lastTwo[2];377}378
379// C#-style strings where "" escapes a quote.380function tokenAtString(stream, state) {381var next;382while ((next = stream.next()) != null) {383if (next == '"' && !stream.eat('"')) {384state.tokenize = null;385break;386}387}388return "string";389}390
391// C++11 raw string literal is <prefix>"<delim>( anything )<delim>", where392// <delim> can be a string up to 16 characters long.393function tokenRawString(stream, state) {394// Escape characters that have special regex meanings.395var delim = state.cpp11RawStringDelim.replace(/[^\w\s]/g, '\\$&');396var match = stream.match(new RegExp(".*?\\)" + delim + '"'));397if (match)398state.tokenize = null;399else400stream.skipToEnd();401return "string";402}403
404function def(mimes, mode) {405if (typeof mimes == "string") mimes = [mimes];406var words = [];407function add(obj) {408if (obj) for (var prop in obj) if (obj.hasOwnProperty(prop))409words.push(prop);410}411add(mode.keywords);412add(mode.types);413add(mode.builtin);414add(mode.atoms);415if (words.length) {416mode.helperType = mimes[0];417CodeMirror.registerHelper("hintWords", mimes[0], words);418}419
420for (var i = 0; i < mimes.length; ++i)421CodeMirror.defineMIME(mimes[i], mode);422}423
424def(["text/x-csrc", "text/x-c", "text/x-chdr"], {425name: "clike",426keywords: words(cKeywords),427types: cTypes,428blockKeywords: words(cBlockKeywords),429defKeywords: words(cDefKeywords),430typeFirstDefinitions: true,431atoms: words("NULL true false"),432isReservedIdentifier: cIsReservedIdentifier,433hooks: {434"#": cppHook,435"*": pointerHook,436},437modeProps: {fold: ["brace", "include"]}438});439
440def(["text/x-c++src", "text/x-c++hdr"], {441name: "clike",442keywords: words(cKeywords + " " + cppKeywords),443types: cTypes,444blockKeywords: words(cBlockKeywords + " class try catch"),445defKeywords: words(cDefKeywords + " class namespace"),446typeFirstDefinitions: true,447atoms: words("true false NULL nullptr"),448dontIndentStatements: /^template$/,449isIdentifierChar: /[\w\$_~\xa1-\uffff]/,450isReservedIdentifier: cIsReservedIdentifier,451hooks: {452"#": cppHook,453"*": pointerHook,454"u": cpp11StringHook,455"U": cpp11StringHook,456"L": cpp11StringHook,457"R": cpp11StringHook,458"0": cpp14Literal,459"1": cpp14Literal,460"2": cpp14Literal,461"3": cpp14Literal,462"4": cpp14Literal,463"5": cpp14Literal,464"6": cpp14Literal,465"7": cpp14Literal,466"8": cpp14Literal,467"9": cpp14Literal,468token: function(stream, state, style) {469if (style == "variable" && stream.peek() == "(" &&470(state.prevToken == ";" || state.prevToken == null ||471state.prevToken == "}") &&472cppLooksLikeConstructor(stream.current()))473return "def";474}475},476namespaceSeparator: "::",477modeProps: {fold: ["brace", "include"]}478});479
480def("text/x-java", {481name: "clike",482keywords: words("abstract assert break case catch class const continue default " +483"do else enum extends final finally for goto if implements import " +484"instanceof interface native new package private protected public " +485"return static strictfp super switch synchronized this throw throws transient " +486"try volatile while @interface"),487types: words("var byte short int long float double boolean char void Boolean Byte Character Double Float " +488"Integer Long Number Object Short String StringBuffer StringBuilder Void"),489blockKeywords: words("catch class do else finally for if switch try while"),490defKeywords: words("class interface enum @interface"),491typeFirstDefinitions: true,492atoms: words("true false null"),493number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+\.?\d*|\.\d+)(?:e[-+]?[\d_]+)?)(u|ll?|l|f)?/i,494hooks: {495"@": function(stream) {496// Don't match the @interface keyword.497if (stream.match('interface', false)) return false;498
499stream.eatWhile(/[\w\$_]/);500return "meta";501}502},503modeProps: {fold: ["brace", "import"]}504});505
506def("text/x-csharp", {507name: "clike",508keywords: words("abstract as async await base break case catch checked class const continue" +509" default delegate do else enum event explicit extern finally fixed for" +510" foreach goto if implicit in interface internal is lock namespace new" +511" operator out override params private protected public readonly ref return sealed" +512" sizeof stackalloc static struct switch this throw try typeof unchecked" +513" unsafe using virtual void volatile while add alias ascending descending dynamic from get" +514" global group into join let orderby partial remove select set value var yield"),515types: words("Action Boolean Byte Char DateTime DateTimeOffset Decimal Double Func" +516" Guid Int16 Int32 Int64 Object SByte Single String Task TimeSpan UInt16 UInt32" +517" UInt64 bool byte char decimal double short int long object" +518" sbyte float string ushort uint ulong"),519blockKeywords: words("catch class do else finally for foreach if struct switch try while"),520defKeywords: words("class interface namespace struct var"),521typeFirstDefinitions: true,522atoms: words("true false null"),523hooks: {524"@": function(stream, state) {525if (stream.eat('"')) {526state.tokenize = tokenAtString;527return tokenAtString(stream, state);528}529stream.eatWhile(/[\w\$_]/);530return "meta";531}532}533});534
535function tokenTripleString(stream, state) {536var escaped = false;537while (!stream.eol()) {538if (!escaped && stream.match('"""')) {539state.tokenize = null;540break;541}542escaped = stream.next() == "\\" && !escaped;543}544return "string";545}546
547function tokenNestedComment(depth) {548return function (stream, state) {549var ch550while (ch = stream.next()) {551if (ch == "*" && stream.eat("/")) {552if (depth == 1) {553state.tokenize = null554break555} else {556state.tokenize = tokenNestedComment(depth - 1)557return state.tokenize(stream, state)558}559} else if (ch == "/" && stream.eat("*")) {560state.tokenize = tokenNestedComment(depth + 1)561return state.tokenize(stream, state)562}563}564return "comment"565}566}567
568def("text/x-scala", {569name: "clike",570keywords: words(571/* scala */572"abstract case catch class def do else extends final finally for forSome if " +573"implicit import lazy match new null object override package private protected return " +574"sealed super this throw trait try type val var while with yield _ " +575
576/* package scala */577"assert assume require print println printf readLine readBoolean readByte readShort " +578"readChar readInt readLong readFloat readDouble"579),580types: words(581"AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " +582"Enumeration Equiv Error Exception Fractional Function IndexedSeq Int Integral Iterable " +583"Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " +584"Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " +585"StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector " +586
587/* package java.lang */588"Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +589"Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +590"Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +591"StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"592),593multiLineStrings: true,594blockKeywords: words("catch class enum do else finally for forSome if match switch try while"),595defKeywords: words("class enum def object package trait type val var"),596atoms: words("true false null"),597indentStatements: false,598indentSwitch: false,599isOperatorChar: /[+\-*&%=<>!?|\/#:@]/,600hooks: {601"@": function(stream) {602stream.eatWhile(/[\w\$_]/);603return "meta";604},605'"': function(stream, state) {606if (!stream.match('""')) return false;607state.tokenize = tokenTripleString;608return state.tokenize(stream, state);609},610"'": function(stream) {611stream.eatWhile(/[\w\$_\xa1-\uffff]/);612return "atom";613},614"=": function(stream, state) {615var cx = state.context616if (cx.type == "}" && cx.align && stream.eat(">")) {617state.context = new Context(cx.indented, cx.column, cx.type, cx.info, null, cx.prev)618return "operator"619} else {620return false621}622},623
624"/": function(stream, state) {625if (!stream.eat("*")) return false626state.tokenize = tokenNestedComment(1)627return state.tokenize(stream, state)628}629},630modeProps: {closeBrackets: {pairs: '()[]{}""', triples: '"'}}631});632
633function tokenKotlinString(tripleString){634return function (stream, state) {635var escaped = false, next, end = false;636while (!stream.eol()) {637if (!tripleString && !escaped && stream.match('"') ) {end = true; break;}638if (tripleString && stream.match('"""')) {end = true; break;}639next = stream.next();640if(!escaped && next == "$" && stream.match('{'))641stream.skipTo("}");642escaped = !escaped && next == "\\" && !tripleString;643}644if (end || !tripleString)645state.tokenize = null;646return "string";647}648}649
650def("text/x-kotlin", {651name: "clike",652keywords: words(653/*keywords*/654"package as typealias class interface this super val operator " +655"var fun for is in This throw return annotation " +656"break continue object if else while do try when !in !is as? " +657
658/*soft keywords*/659"file import where by get set abstract enum open inner override private public internal " +660"protected catch finally out final vararg reified dynamic companion constructor init " +661"sealed field property receiver param sparam lateinit data inline noinline tailrec " +662"external annotation crossinline const operator infix suspend actual expect setparam value"663),664types: words(665/* package java.lang */666"Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +667"Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +668"Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +669"StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void Annotation Any BooleanArray " +670"ByteArray Char CharArray DeprecationLevel DoubleArray Enum FloatArray Function Int IntArray Lazy " +671"LazyThreadSafetyMode LongArray Nothing ShortArray Unit"672),673intendSwitch: false,674indentStatements: false,675multiLineStrings: true,676number: /^(?:0x[a-f\d_]+|0b[01_]+|(?:[\d_]+(\.\d+)?|\.\d+)(?:e[-+]?[\d_]+)?)(u|ll?|l|f)?/i,677blockKeywords: words("catch class do else finally for if where try while enum"),678defKeywords: words("class val var object interface fun"),679atoms: words("true false null this"),680hooks: {681"@": function(stream) {682stream.eatWhile(/[\w\$_]/);683return "meta";684},685'*': function(_stream, state) {686return state.prevToken == '.' ? 'variable' : 'operator';687},688'"': function(stream, state) {689state.tokenize = tokenKotlinString(stream.match('""'));690return state.tokenize(stream, state);691},692"/": function(stream, state) {693if (!stream.eat("*")) return false;694state.tokenize = tokenNestedComment(1);695return state.tokenize(stream, state)696},697indent: function(state, ctx, textAfter, indentUnit) {698var firstChar = textAfter && textAfter.charAt(0);699if ((state.prevToken == "}" || state.prevToken == ")") && textAfter == "")700return state.indented;701if ((state.prevToken == "operator" && textAfter != "}" && state.context.type != "}") ||702state.prevToken == "variable" && firstChar == "." ||703(state.prevToken == "}" || state.prevToken == ")") && firstChar == ".")704return indentUnit * 2 + ctx.indented;705if (ctx.align && ctx.type == "}")706return ctx.indented + (state.context.type == (textAfter || "").charAt(0) ? 0 : indentUnit);707}708},709modeProps: {closeBrackets: {triples: '"'}}710});711
712def(["x-shader/x-vertex", "x-shader/x-fragment"], {713name: "clike",714keywords: words("sampler1D sampler2D sampler3D samplerCube " +715"sampler1DShadow sampler2DShadow " +716"const attribute uniform varying " +717"break continue discard return " +718"for while do if else struct " +719"in out inout"),720types: words("float int bool void " +721"vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 " +722"mat2 mat3 mat4"),723blockKeywords: words("for while do if else struct"),724builtin: words("radians degrees sin cos tan asin acos atan " +725"pow exp log exp2 sqrt inversesqrt " +726"abs sign floor ceil fract mod min max clamp mix step smoothstep " +727"length distance dot cross normalize ftransform faceforward " +728"reflect refract matrixCompMult " +729"lessThan lessThanEqual greaterThan greaterThanEqual " +730"equal notEqual any all not " +731"texture1D texture1DProj texture1DLod texture1DProjLod " +732"texture2D texture2DProj texture2DLod texture2DProjLod " +733"texture3D texture3DProj texture3DLod texture3DProjLod " +734"textureCube textureCubeLod " +735"shadow1D shadow2D shadow1DProj shadow2DProj " +736"shadow1DLod shadow2DLod shadow1DProjLod shadow2DProjLod " +737"dFdx dFdy fwidth " +738"noise1 noise2 noise3 noise4"),739atoms: words("true false " +740"gl_FragColor gl_SecondaryColor gl_Normal gl_Vertex " +741"gl_MultiTexCoord0 gl_MultiTexCoord1 gl_MultiTexCoord2 gl_MultiTexCoord3 " +742"gl_MultiTexCoord4 gl_MultiTexCoord5 gl_MultiTexCoord6 gl_MultiTexCoord7 " +743"gl_FogCoord gl_PointCoord " +744"gl_Position gl_PointSize gl_ClipVertex " +745"gl_FrontColor gl_BackColor gl_FrontSecondaryColor gl_BackSecondaryColor " +746"gl_TexCoord gl_FogFragCoord " +747"gl_FragCoord gl_FrontFacing " +748"gl_FragData gl_FragDepth " +749"gl_ModelViewMatrix gl_ProjectionMatrix gl_ModelViewProjectionMatrix " +750"gl_TextureMatrix gl_NormalMatrix gl_ModelViewMatrixInverse " +751"gl_ProjectionMatrixInverse gl_ModelViewProjectionMatrixInverse " +752"gl_TextureMatrixTranspose gl_ModelViewMatrixInverseTranspose " +753"gl_ProjectionMatrixInverseTranspose " +754"gl_ModelViewProjectionMatrixInverseTranspose " +755"gl_TextureMatrixInverseTranspose " +756"gl_NormalScale gl_DepthRange gl_ClipPlane " +757"gl_Point gl_FrontMaterial gl_BackMaterial gl_LightSource gl_LightModel " +758"gl_FrontLightModelProduct gl_BackLightModelProduct " +759"gl_TextureColor gl_EyePlaneS gl_EyePlaneT gl_EyePlaneR gl_EyePlaneQ " +760"gl_FogParameters " +761"gl_MaxLights gl_MaxClipPlanes gl_MaxTextureUnits gl_MaxTextureCoords " +762"gl_MaxVertexAttribs gl_MaxVertexUniformComponents gl_MaxVaryingFloats " +763"gl_MaxVertexTextureImageUnits gl_MaxTextureImageUnits " +764"gl_MaxFragmentUniformComponents gl_MaxCombineTextureImageUnits " +765"gl_MaxDrawBuffers"),766indentSwitch: false,767hooks: {"#": cppHook},768modeProps: {fold: ["brace", "include"]}769});770
771def("text/x-nesc", {772name: "clike",773keywords: words(cKeywords + " as atomic async call command component components configuration event generic " +774"implementation includes interface module new norace nx_struct nx_union post provides " +775"signal task uses abstract extends"),776types: cTypes,777blockKeywords: words(cBlockKeywords),778atoms: words("null true false"),779hooks: {"#": cppHook},780modeProps: {fold: ["brace", "include"]}781});782
783def("text/x-objectivec", {784name: "clike",785keywords: words(cKeywords + " " + objCKeywords),786types: objCTypes,787builtin: words(objCBuiltins),788blockKeywords: words(cBlockKeywords + " @synthesize @try @catch @finally @autoreleasepool @synchronized"),789defKeywords: words(cDefKeywords + " @interface @implementation @protocol @class"),790dontIndentStatements: /^@.*$/,791typeFirstDefinitions: true,792atoms: words("YES NO NULL Nil nil true false nullptr"),793isReservedIdentifier: cIsReservedIdentifier,794hooks: {795"#": cppHook,796"*": pointerHook,797},798modeProps: {fold: ["brace", "include"]}799});800
801def("text/x-objectivec++", {802name: "clike",803keywords: words(cKeywords + " " + objCKeywords + " " + cppKeywords),804types: objCTypes,805builtin: words(objCBuiltins),806blockKeywords: words(cBlockKeywords + " @synthesize @try @catch @finally @autoreleasepool @synchronized class try catch"),807defKeywords: words(cDefKeywords + " @interface @implementation @protocol @class class namespace"),808dontIndentStatements: /^@.*$|^template$/,809typeFirstDefinitions: true,810atoms: words("YES NO NULL Nil nil true false nullptr"),811isReservedIdentifier: cIsReservedIdentifier,812hooks: {813"#": cppHook,814"*": pointerHook,815"u": cpp11StringHook,816"U": cpp11StringHook,817"L": cpp11StringHook,818"R": cpp11StringHook,819"0": cpp14Literal,820"1": cpp14Literal,821"2": cpp14Literal,822"3": cpp14Literal,823"4": cpp14Literal,824"5": cpp14Literal,825"6": cpp14Literal,826"7": cpp14Literal,827"8": cpp14Literal,828"9": cpp14Literal,829token: function(stream, state, style) {830if (style == "variable" && stream.peek() == "(" &&831(state.prevToken == ";" || state.prevToken == null ||832state.prevToken == "}") &&833cppLooksLikeConstructor(stream.current()))834return "def";835}836},837namespaceSeparator: "::",838modeProps: {fold: ["brace", "include"]}839});840
841def("text/x-squirrel", {842name: "clike",843keywords: words("base break clone continue const default delete enum extends function in class" +844" foreach local resume return this throw typeof yield constructor instanceof static"),845types: cTypes,846blockKeywords: words("case catch class else for foreach if switch try while"),847defKeywords: words("function local class"),848typeFirstDefinitions: true,849atoms: words("true false null"),850hooks: {"#": cppHook},851modeProps: {fold: ["brace", "include"]}852});853
854// Ceylon Strings need to deal with interpolation855var stringTokenizer = null;856function tokenCeylonString(type) {857return function(stream, state) {858var escaped = false, next, end = false;859while (!stream.eol()) {860if (!escaped && stream.match('"') &&861(type == "single" || stream.match('""'))) {862end = true;863break;864}865if (!escaped && stream.match('``')) {866stringTokenizer = tokenCeylonString(type);867end = true;868break;869}870next = stream.next();871escaped = type == "single" && !escaped && next == "\\";872}873if (end)874state.tokenize = null;875return "string";876}877}878
879def("text/x-ceylon", {880name: "clike",881keywords: words("abstracts alias assembly assert assign break case catch class continue dynamic else" +882" exists extends finally for function given if import in interface is let module new" +883" nonempty object of out outer package return satisfies super switch then this throw" +884" try value void while"),885types: function(word) {886// In Ceylon all identifiers that start with an uppercase are types887var first = word.charAt(0);888return (first === first.toUpperCase() && first !== first.toLowerCase());889},890blockKeywords: words("case catch class dynamic else finally for function if interface module new object switch try while"),891defKeywords: words("class dynamic function interface module object package value"),892builtin: words("abstract actual aliased annotation by default deprecated doc final formal late license" +893" native optional sealed see serializable shared suppressWarnings tagged throws variable"),894isPunctuationChar: /[\[\]{}\(\),;\:\.`]/,895isOperatorChar: /[+\-*&%=<>!?|^~:\/]/,896numberStart: /[\d#$]/,897number: /^(?:#[\da-fA-F_]+|\$[01_]+|[\d_]+[kMGTPmunpf]?|[\d_]+\.[\d_]+(?:[eE][-+]?\d+|[kMGTPmunpf]|)|)/i,898multiLineStrings: true,899typeFirstDefinitions: true,900atoms: words("true false null larger smaller equal empty finished"),901indentSwitch: false,902styleDefs: false,903hooks: {904"@": function(stream) {905stream.eatWhile(/[\w\$_]/);906return "meta";907},908'"': function(stream, state) {909state.tokenize = tokenCeylonString(stream.match('""') ? "triple" : "single");910return state.tokenize(stream, state);911},912'`': function(stream, state) {913if (!stringTokenizer || !stream.match('`')) return false;914state.tokenize = stringTokenizer;915stringTokenizer = null;916return state.tokenize(stream, state);917},918"'": function(stream) {919stream.eatWhile(/[\w\$_\xa1-\uffff]/);920return "atom";921},922token: function(_stream, state, style) {923if ((style == "variable" || style == "type") &&924state.prevToken == ".") {925return "variable-2";926}927}928},929modeProps: {930fold: ["brace", "import"],931closeBrackets: {triples: '"'}932}933});934
935});936