forked from phcode-dev/staging.phcode.dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdylan.js
More file actions
1 lines (1 loc) · 5.23 KB
/
Copy pathdylan.js
File metadata and controls
1 lines (1 loc) · 5.23 KB
1
!function(mod){"object"==typeof exports&&"object"==typeof module?mod(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],mod):mod(CodeMirror)}(function(CodeMirror){"use strict";function forEach(arr,f){for(var i=0;i<arr.length;i++)f(arr[i],i)}function some(arr,f){for(var i=0;i<arr.length;i++)if(f(arr[i],i))return!0;return!1}CodeMirror.defineMode("dylan",function(_config){var words={unnamedDefinition:["interface"],namedDefinition:["module","library","macro","C-struct","C-union","C-function","C-callable-wrapper"],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"],separator:["finally","exception","cleanup","else","elseif","afterwards"],other:["above","below","by","from","handler","in","instance","let","local","otherwise","slot","subclass","then","to","keyed-by","virtual"],signalingCalls:["signal","error","cerror","break","check-type","abort"]};words.otherDefinition=words.unnamedDefinition.concat(words.namedDefinition).concat(words.otherParameterizedDefinition),words.definition=words.typeParameterizedDefinition.concat(words.otherDefinition),words.parameterizedDefinition=words.typeParameterizedDefinition.concat(words.otherParameterizedDefinition),words.simpleDefinition=words.constantSimpleDefinition.concat(words.variableSimpleDefinition).concat(words.otherSimpleDefinition),words.keyword=words.statement.concat(words.separator).concat(words.other);var symbolPattern="[-_a-zA-Z?!*@<>$%]+",symbol=new RegExp("^"+symbolPattern),patterns={symbolKeyword:symbolPattern+":",symbolClass:"<"+symbolPattern+">",symbolGlobal:"\\*"+symbolPattern+"\\*",symbolConstant:"\\$"+symbolPattern},patternStyles={symbolKeyword:"atom",symbolClass:"tag",symbolGlobal:"variable-2",symbolConstant:"variable-3"};for(var patternName in patterns)patterns.hasOwnProperty(patternName)&&(patterns[patternName]=new RegExp("^"+patterns[patternName]));patterns.keyword=[/^with(?:out)?-[-_a-zA-Z?!*@<>$%]+/];var styles={keyword:"keyword",definition:"def",simpleDefinition:"def",signalingCalls:"builtin"},wordLookup={},styleLookup={};function chain(stream,state,f){return state.tokenize=f,f(stream,state)}function tokenBase(stream,state){var ch=stream.peek();if("'"==ch||'"'==ch)return stream.next(),chain(stream,state,tokenString(ch,"string"));if("/"==ch){if(stream.next(),stream.eat("*"))return chain(stream,state,tokenComment);if(stream.eat("/"))return stream.skipToEnd(),"comment";stream.backUp(1)}else if(/[+\-\d\.]/.test(ch)){if(stream.match(/^[+-]?[0-9]*\.[0-9]*([esdx][+-]?[0-9]+)?/i)||stream.match(/^[+-]?[0-9]+([esdx][+-]?[0-9]+)/i)||stream.match(/^[+-]?\d+/))return"number"}else{if("#"==ch)return stream.next(),'"'==(ch=stream.peek())?(stream.next(),chain(stream,state,tokenString('"',"string"))):"b"==ch?(stream.next(),stream.eatWhile(/[01]/),"number"):"x"==ch?(stream.next(),stream.eatWhile(/[\da-f]/i),"number"):"o"==ch?(stream.next(),stream.eatWhile(/[0-7]/),"number"):"#"==ch?(stream.next(),"punctuation"):"["==ch||"("==ch?(stream.next(),"bracket"):stream.match(/f|t|all-keys|include|key|next|rest/i)?"atom":(stream.eatWhile(/[-a-zA-Z]/),"error");if("~"==ch)return stream.next(),"="==(ch=stream.peek())?(stream.next(),"="==(ch=stream.peek())?(stream.next(),"operator"):"operator"):"operator";if(":"==ch){if(stream.next(),"="==(ch=stream.peek()))return stream.next(),"operator";if(":"==ch)return stream.next(),"punctuation"}else{if(-1!="[](){}".indexOf(ch))return stream.next(),"bracket";if(-1!=".,".indexOf(ch))return stream.next(),"punctuation";if(stream.match("end"))return"keyword"}}for(var name in patterns)if(patterns.hasOwnProperty(name)){var pattern=patterns[name];if(pattern instanceof Array&&some(pattern,function(p){return stream.match(p)})||stream.match(pattern))return patternStyles[name]}return/[+\-*\/^=<>&|]/.test(ch)?(stream.next(),"operator"):stream.match("define")?"def":(stream.eatWhile(/[\w\-]/),wordLookup.hasOwnProperty(stream.current())?styleLookup[stream.current()]:stream.current().match(symbol)?"variable":(stream.next(),"variable-2"))}function tokenComment(stream,state){for(var maybeEnd=!1,maybeNested=!1,nestedCount=0,ch;ch=stream.next();){if("/"==ch&&maybeEnd){if(!(nestedCount>0)){state.tokenize=tokenBase;break}nestedCount--}else"*"==ch&&maybeNested&&nestedCount++;maybeEnd="*"==ch,maybeNested="/"==ch}return"comment"}function tokenString(quote,style){return function(stream,state){for(var escaped=!1,next,end=!1;null!=(next=stream.next());){if(next==quote&&!escaped){end=!0;break}escaped=!escaped&&"\\"==next}return!end&&escaped||(state.tokenize=tokenBase),style}}return forEach(["keyword","definition","simpleDefinition","signalingCalls"],function(type){forEach(words[type],function(word){wordLookup[word]=type,styleLookup[word]=styles[type]})}),{startState:function(){return{tokenize:tokenBase,currentIndent:0}},token:function(stream,state){return stream.eatSpace()?null:state.tokenize(stream,state);var style},blockCommentStart:"/*",blockCommentEnd:"*/"}}),CodeMirror.defineMIME("text/x-dylan","dylan")});