var type,specialForm=/^(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)$/,assumeBody=/^with|^def|^do|^prog|case$|^cond$|bind$|when$|unless$/,numLiteral=/^(?:[+\-]?(?:\d+|\d*\.\d+)(?:[efd][+\-]?\d+)?|[+\-]?\d+(?:\/[+\-]?\d+)?|#b[+\-]?[01]+|#o[+\-]?[0-7]+|#x[+\-]?[\da-f]+)/,symbol=/[^\s'`,@()\[\]";]/;function readSym(e){for(var t;t=e.next();)if("\\"==t)e.next();else if(!symbol.test(t)){e.backUp(1);break}return e.current()}function base(e,t){if(e.eatSpace())return type="ws",null;if(e.match(numLiteral))return "number";var n;if("\\"==(n=e.next())&&(n=e.next()),'"'==n)return (t.tokenize=inString)(e,t);if("("==n)return type="open","bracket";if(")"==n||"]"==n)return type="close","bracket";if(";"==n)return e.skipToEnd(),type="ws","comment";if(/['`,@]/.test(n))return null;if("|"==n)return e.skipTo("|")?(e.next(),"variableName"):(e.skipToEnd(),"error");if("#"==n)return "("==(n=e.next())?(type="open","bracket"):/[+\-=\.']/.test(n)||/\d/.test(n)&&e.match(/^\d*#/)?null:"|"==n?(t.tokenize=inComment)(e,t):":"==n?(readSym(e),"meta"):"\\"==n?(e.next(),readSym(e),"string.special"):"error";var r=readSym(e);return "."==r?null:(type="symbol","nil"==r||"t"==r||":"==r.charAt(0)?"atom":"open"==t.lastType&&(specialForm.test(r)||assumeBody.test(r))?"keyword":"&"==r.charAt(0)?"variableName.special":"variableName")}function inString(e,t){for(var n,r=!1;n=e.next();){if('"'==n&&!r){t.tokenize=base;break}r=!r&&"\\"==n;}return "string"}function inComment(e,t){for(var n,r;n=e.next();){if("#"==n&&"|"==r){t.tokenize=base;break}r=n;}return type="ws","comment"}const commonLisp={startState:function(){return {ctx:{prev:null,start:0,indentTo:0},lastType:null,tokenize:base}},token:function(e,t){e.sol()&&"number"!=typeof t.ctx.indentTo&&(t.ctx.indentTo=t.ctx.start+1),type=null;var n=t.tokenize(e,t);return "ws"!=type&&(null==t.ctx.indentTo?"symbol"==type&&assumeBody.test(e.current())?t.ctx.indentTo=t.ctx.start+e.indentUnit:t.ctx.indentTo="next":"next"==t.ctx.indentTo&&(t.ctx.indentTo=e.column()),t.lastType=type),"open"==type?t.ctx={prev:t.ctx,start:e.column(),indentTo:null}:"close"==type&&(t.ctx=t.ctx.prev||t.ctx),n},indent:function(e){var t=e.ctx.indentTo;return "number"==typeof t?t:e.ctx.start+1},languageData:{commentTokens:{line:";;",block:{open:"#|",close:"|#"}},closeBrackets:{brackets:["(","[","{",'"']}}};

export { commonLisp };
