3 lines
4.3 KiB
JavaScript
3 lines
4.3 KiB
JavaScript
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
// Distributed under an MIT license: https://codemirror.net/5/LICENSE
|
|
(function(d){"object"==typeof exports&&"object"==typeof module?d(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],d):d(CodeMirror)})(function(d){function m(d,k){for(var f=0;f<d.length;f++)k(d[f],f)}function r(d,k){for(var f=0;f<d.length;f++)if(k(d[f],f))return!0;return!1}d.defineMode("dylan",function(d){function k(a,e,b){e.tokenize=b;return b(a,e)}function f(a,e){var b=a.peek();if("'"==b||'"'==b)return a.next(),k(a,e,n(b,"string"));if("/"==b){a.next();if(a.eat("*"))return k(a,e,t);if(a.eat("/"))return a.skipToEnd(),"comment";a.backUp(1)}else if(/[+\-\d\.]/.test(b)){if(a.match(/^[+-]?[0-9]*\.[0-9]*([esdx][+-]?[0-9]+)?/i)||a.match(/^[+-]?[0-9]+([esdx][+-]?[0-9]+)/i)||a.match(/^[+-]?\d+/))return"number"}else{if("#"==b){a.next();b=a.peek();if('"'==b)return a.next(),k(a,e,n('"',"string"));if("b"==b)return a.next(),a.eatWhile(/[01]/),"number";if("x"==b)return a.next(),a.eatWhile(/[\da-f]/i),"number";if("o"==b)return a.next(),a.eatWhile(/[0-7]/),"number";if("#"==b)return a.next(),"punctuation";if("["==b||"("==b)return a.next(),"bracket";if(a.match(/f|t|all-keys|include|key|next|rest/i))return"atom";a.eatWhile(/[-a-zA-Z]/);return"error"}if("~"==b)return a.next(),b=a.peek(),"\x3d"==b&&(a.next(),b=a.peek(),"\x3d"==b&&a.next()),"operator";if(":"==b){a.next();b=a.peek();if("\x3d"==b)return a.next(),"operator";if(":"==b)return a.next(),"punctuation"}else{if(-1!="[](){}".indexOf(b))return a.next(),"bracket";if(-1!=".,".indexOf(b))return a.next(),"punctuation";if(a.match("end"))return"keyword"}}for(var c in g)if(g.hasOwnProperty(c)&&(e=g[c],e instanceof Array&&r(e,function(b){return a.match(b)})||a.match(e)))return u[c];if(/[+\-*\/^=<>&|]/.test(b))return a.next(),"operator";if(a.match("define"))return"def";a.eatWhile(/[\w\-]/);if(p.hasOwnProperty(a.current()))return q[a.current()];if(a.current().match(v))return"variable";a.next();return"variable-2"}function t(a,c){for(var b=!1,e=!1,d=0,h;h=a.next();){if("/"==h&&b)if(0<d)d--;else{c.tokenize=f;break}else"*"==h&&e&&d++;b="*"==h;e="/"==h}return"comment"}function n(a,c){return function(b,e){for(var d=!1,h,g=!1;null!=(h=b.next());){if(h==a&&!d){g=!0;break}d=!d&&"\\"==h}if(g||!d)e.tokenize=f;return c}}var c={unnamedDefinition:["interface"],namedDefinition:"module library macro C-struct C-union C-function C-callable-wrapper".split(" "),typeParameterizedDefinition:["class","C-subtype","C-mapped-subtype"],otherParameterizedDefinition:["method","function","C-variable","C-address"],constantSimpleDefinition:["constant"],variableSimpleDefinition:["variable"],otherSimpleDefinition:["generic","domain","C-pointer-type","table"],statement:"if block begin method case for select when unless until while iterate profiling dynamic-bind".split(" "),separator:"finally exception cleanup else elseif afterwards".split(" "),other:"above below by from handler in instance let local otherwise slot subclass then to keyed-by virtual".split(" "),signalingCalls:"signal error cerror break check-type abort".split(" ")};c.otherDefinition=c.unnamedDefinition.concat(c.namedDefinition).concat(c.otherParameterizedDefinition);c.definition=c.typeParameterizedDefinition.concat(c.otherDefinition);c.parameterizedDefinition=c.typeParameterizedDefinition.concat(c.otherParameterizedDefinition);c.simpleDefinition=c.constantSimpleDefinition.concat(c.variableSimpleDefinition).concat(c.otherSimpleDefinition);c.keyword=c.statement.concat(c.separator).concat(c.other);var v=/^[-_a-zA-Z?!*@<>$%]+/,g={symbolKeyword:"[-_a-zA-Z?!*@\x3c\x3e$%]+:",symbolClass:"\x3c[-_a-zA-Z?!*@\x3c\x3e$%]+\x3e",symbolGlobal:"\\*[-_a-zA-Z?!*@\x3c\x3e$%]+\\*",symbolConstant:"\\$[-_a-zA-Z?!*@\x3c\x3e$%]+"},u={symbolKeyword:"atom",symbolClass:"tag",symbolGlobal:"variable-2",symbolConstant:"variable-3"},l;for(l in g)g.hasOwnProperty(l)&&(g[l]=new RegExp("^"+g[l]));g.keyword=[/^with(?:out)?-[-_a-zA-Z?!*@<>$%]+/];var w={keyword:"keyword",definition:"def",simpleDefinition:"def",signalingCalls:"builtin"},p={},q={};m(["keyword","definition","simpleDefinition","signalingCalls"],function(a){m(c[a],function(c){p[c]=a;q[c]=w[a]})});return{startState:function(){return{tokenize:f,currentIndent:0}},token:function(a,c){return a.eatSpace()?null:c.tokenize(a,c)},blockCommentStart:"/*",blockCommentEnd:"*/"}});d.defineMIME("text/x-dylan","dylan")}); |