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