Current File : /home/pacjaorg/public_html/kmm/media/vendor/codemirror/mode/swift/swift.min.js |
(function(c){typeof exports=="object"&&typeof module=="object"?c(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],c):c(CodeMirror)})(function(c){"use strict";function f(n){for(var i={},e=0;e<n.length;e++)i[n[e]]=!0;return i}var d=f(["_","var","let","actor","class","enum","extension","import","protocol","struct","func","typealias","associatedtype","open","public","internal","fileprivate","private","deinit","init","new","override","self","subscript","super","convenience","dynamic","final","indirect","lazy","required","static","unowned","unowned(safe)","unowned(unsafe)","weak","as","is","break","case","continue","default","else","fallthrough","for","guard","if","in","repeat","switch","where","while","defer","return","inout","mutating","nonmutating","isolated","nonisolated","catch","do","rethrows","throw","throws","async","await","try","didSet","get","set","willSet","assignment","associativity","infix","left","none","operator","postfix","precedence","precedencegroup","prefix","right","Any","AnyObject","Type","dynamicType","Self","Protocol","__COLUMN__","__FILE__","__FUNCTION__","__LINE__"]),p=f(["var","let","actor","class","enum","extension","import","protocol","struct","func","typealias","associatedtype","for"]),v=f(["true","false","nil","self","super","_"]),h=f(["Array","Bool","Character","Dictionary","Double","Float","Int","Int8","Int16","Int32","Int64","Never","Optional","Set","String","UInt8","UInt16","UInt32","UInt64","Void"]),s="+-/*%=|&<>~^?!",_=":;,.(){}[]",x=/^\-?0b[01][01_]*/,y=/^\-?0o[0-7][0-7_]*/,k=/^\-?0x[\dA-Fa-f][\dA-Fa-f_]*(?:(?:\.[\dA-Fa-f][\dA-Fa-f_]*)?[Pp]\-?\d[\d_]*)?/,g=/^\-?\d[\d_]*(?:\.\d[\d_]*)?(?:[Ee]\-?\d[\d_]*)?/,w=/^\$\d+|(`?)[_A-Za-z][_A-Za-z$0-9]*\1/,b=/^\.(?:\$\d+|(`?)[_A-Za-z][_A-Za-z$0-9]*\1)/,z=/^\#[A-Za-z]+/,m=/^@(?:\$\d+|(`?)[_A-Za-z][_A-Za-z$0-9]*\1)/;function l(n,i,e){if(n.sol()&&(i.indented=n.indentation()),n.eatSpace())return null;var t=n.peek();if(t=="/"){if(n.match("//"))return n.skipToEnd(),"comment";if(n.match("/*"))return i.tokenize.push(a),a(n,i)}if(n.match(z))return"builtin";if(n.match(m))return"attribute";if(n.match(x)||n.match(y)||n.match(k)||n.match(g))return"number";if(n.match(b))return"property";if(s.indexOf(t)>-1)return n.next(),"operator";if(_.indexOf(t)>-1)return n.next(),n.match(".."),"punctuation";var r;if(r=n.match(/("""|"|')/)){var o=I.bind(null,r[0]);return i.tokenize.push(o),o(n,i)}if(n.match(w)){var u=n.current();return h.hasOwnProperty(u)?"variable-2":v.hasOwnProperty(u)?"atom":d.hasOwnProperty(u)?(p.hasOwnProperty(u)&&(i.prev="define"),"keyword"):e=="define"?"def":"variable"}return n.next(),null}function A(){var n=0;return function(i,e,t){var r=l(i,e,t);if(r=="punctuation"){if(i.current()=="(")++n;else if(i.current()==")"){if(n==0)return i.backUp(1),e.tokenize.pop(),e.tokenize[e.tokenize.length-1](i,e);--n}}return r}}function I(n,i,e){for(var t=n.length==1,r,o=!1;r=i.peek();)if(o){if(i.next(),r=="(")return e.tokenize.push(A()),"string";o=!1}else{if(i.match(n))return e.tokenize.pop(),"string";i.next(),o=r=="\\"}return t&&e.tokenize.pop(),"string"}function a(n,i){for(var e;e=n.next();)if(e==="/"&&n.eat("*"))i.tokenize.push(a);else if(e==="*"&&n.eat("/")){i.tokenize.pop();break}return"comment"}function C(n,i,e){this.prev=n,this.align=i,this.indented=e}function O(n,i){var e=i.match(/^\s*($|\/[\/\*])/,!1)?null:i.column()+1;n.context=new C(n.context,e,n.indented)}function S(n){n.context&&(n.indented=n.context.indented,n.context=n.context.prev)}c.defineMode("swift",function(n){return{startState:function(){return{prev:null,context:null,indented:0,tokenize:[]}},token:function(i,e){var t=e.prev;e.prev=null;var r=e.tokenize[e.tokenize.length-1]||l,o=r(i,e,t);if(!o||o=="comment"?e.prev=t:e.prev||(e.prev=o),o=="punctuation"){var u=/[\(\[\{]|([\]\)\}])/.exec(i.current());u&&(u[1]?S:O)(e,i)}return o},indent:function(i,e){var t=i.context;if(!t)return 0;var r=/^[\]\}\)]/.test(e);return t.align!=null?t.align-(r?1:0):t.indented+(r?0:n.indentUnit)},electricInput:/^\s*[\)\}\]]$/,lineComment:"//",blockCommentStart:"/*",blockCommentEnd:"*/",fold:"brace",closeBrackets:"()[]{}''\"\"``"}}),c.defineMIME("text/x-swift","swift")});