var specialChars=/[+\-\/\\*~<>=@%|&?!.,:;^]/,keywords=/true|false|nil|self|super|thisContext/,Context=function(e,t){this.next=e,this.parent=t;},Token=function(e,t,n){this.name=e,this.context=t,this.eos=n;},State=function(){this.context=new Context(next,null),this.expectVariable=!0,this.indentation=0,this.userIndentationDelta=0;};State.prototype.userIndent=function(e,t){this.userIndentationDelta=e>0?e/t-this.indentation:0;};var next=function(e,t,n){var a=new Token(null,t,!1),i=e.next();return '"'===i?a=nextComment(e,new Context(nextComment,t)):"'"===i?a=nextString(e,new Context(nextString,t)):"#"===i?"'"===e.peek()?(e.next(),a=nextSymbol(e,new Context(nextSymbol,t))):e.eatWhile(/[^\s.{}\[\]()]/)?a.name="string.special":a.name="meta":"$"===i?("<"===e.next()&&(e.eatWhile(/[^\s>]/),e.next()),a.name="string.special"):"|"===i&&n.expectVariable?a.context=new Context(nextTemporaries,t):/[\[\]{}()]/.test(i)?(a.name="bracket",a.eos=/[\[{(]/.test(i),"["===i?n.indentation++:"]"===i&&(n.indentation=Math.max(0,n.indentation-1))):specialChars.test(i)?(e.eatWhile(specialChars),a.name="operator",a.eos=";"!==i):/\d/.test(i)?(e.eatWhile(/[\w\d]/),a.name="number"):/[\w_]/.test(i)?(e.eatWhile(/[\w\d_]/),a.name=n.expectVariable?keywords.test(e.current())?"keyword":"variable":null):a.eos=n.expectVariable,a},nextComment=function(e,t){return e.eatWhile(/[^"]/),new Token("comment",e.eat('"')?t.parent:t,!0)},nextString=function(e,t){return e.eatWhile(/[^']/),new Token("string",e.eat("'")?t.parent:t,!1)},nextSymbol=function(e,t){return e.eatWhile(/[^']/),new Token("string.special",e.eat("'")?t.parent:t,!1)},nextTemporaries=function(e,t){var n=new Token(null,t,!1);return "|"===e.next()?(n.context=t.parent,n.eos=!0):(e.eatWhile(/[^|]/),n.name="variable"),n};const smalltalk={startState:function(){return new State},token:function(e,t){if(t.userIndent(e.indentation(),e.indentUnit),e.eatSpace())return null;var n=t.context.next(e,t.context,t);return t.context=n.context,t.expectVariable=n.eos,n.name},blankLine:function(e,t){e.userIndent(0,t);},indent:function(e,t,n){var a=e.context.next===next&&t&&"]"===t.charAt(0)?-1:e.userIndentationDelta;return (e.indentation+a)*n.unit},languageData:{indentOnInput:/^\s*\]$/}};

export { smalltalk };
