book_generator/static/js/lib/commonlisp.min.js

1 line
No EOL
2.5 KiB
JavaScript

!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){"use strict";t.defineMode("commonlisp",function(r){var o,i=/^(block|let*|return-from|catch|load-time-value|setq|eval-when|locally|symbol-macrolet|flet|macrolet|tagbody|function|multiple-value-call|the|go|multiple-value-prog1|throw|if|progn|unwind-protect|labels|progv|let|quote)$/,c=/^with|^def|^do|^prog|case$|^cond$|bind$|when$|unless$/,l=/^(?:[+\-]?(?:\d+|\d*\.\d+)(?:[efd][+\-]?\d+)?|[+\-]?\d+(?:\/[+\-]?\d+)?|#b[+\-]?[01]+|#o[+\-]?[0-7]+|#x[+\-]?[\da-f]+)/,n=/[^\s'`,@()\[\]";]/;function u(t){for(var e;e=t.next();)if("\\"==e)t.next();else if(!n.test(e)){t.backUp(1);break}return t.current()}function a(t,e){if(t.eatSpace())return o="ws",null;if(t.match(l))return"number";var n=t.next();if('"'==(n="\\"==n?t.next():n))return(e.tokenize=s)(t,e);if("("==n)return o="open","bracket";if(")"==n||"]"==n)return o="close","bracket";if(";"==n)return t.skipToEnd(),o="ws","comment";if(/['`,@]/.test(n))return null;if("|"==n)return t.skipTo("|")?(t.next(),"symbol"):(t.skipToEnd(),"error");if("#"==n)return"("==(n=t.next())?(o="open","bracket"):/[+\-=\.']/.test(n)||/\d/.test(n)&&t.match(/^\d*#/)?null:"|"==n?(e.tokenize=d)(t,e):":"==n?(u(t),"meta"):"\\"==n?(t.next(),u(t),"string-2"):"error";t=u(t);return"."==t?null:(o="symbol","nil"==t||"t"==t||":"==t.charAt(0)?"atom":"open"==e.lastType&&(i.test(t)||c.test(t))?"keyword":"&"==t.charAt(0)?"variable-2":"variable")}function s(t,e){for(var n,r=!1;n=t.next();){if('"'==n&&!r){e.tokenize=a;break}r=!r&&"\\"==n}return"string"}function d(t,e){for(var n,r;n=t.next();){if("#"==n&&"|"==r){e.tokenize=a;break}r=n}return o="ws","comment"}return{startState:function(){return{ctx:{prev:null,start:0,indentTo:0},lastType:null,tokenize:a}},token:function(t,e){t.sol()&&"number"!=typeof e.ctx.indentTo&&(e.ctx.indentTo=e.ctx.start+1),o=null;var n=e.tokenize(t,e);return"ws"!=o&&(null==e.ctx.indentTo?"symbol"==o&&c.test(t.current())?e.ctx.indentTo=e.ctx.start+r.indentUnit:e.ctx.indentTo="next":"next"==e.ctx.indentTo&&(e.ctx.indentTo=t.column()),e.lastType=o),"open"==o?e.ctx={prev:e.ctx,start:t.column(),indentTo:null}:"close"==o&&(e.ctx=e.ctx.prev||e.ctx),n},indent:function(t,e){var n=t.ctx.indentTo;return"number"==typeof n?n:t.ctx.start+1},closeBrackets:{pairs:'()[]{}""'},lineComment:";;",fold:"brace-paren",blockCommentStart:"#|",blockCommentEnd:"|#"}}),t.defineMIME("text/x-common-lisp","commonlisp")});