function words(e) {
  for (var n = {}, r = e.split(" "), i = 0; i < r.length; ++i) n[r[i]] = true;
  return n;
}
var keywords = words("if elsif else stop require"), atoms = words("true false not");
function tokenBase(e, i) {
  var s = e.next();
  if (s == "/" && e.eat("*")) return i.tokenize = tokenCComment, tokenCComment(e, i);
  if (s === "#") return e.skipToEnd(), "comment";
  if (s == '"') return i.tokenize = tokenString(s), i.tokenize(e, i);
  if (s == "(") return i._indent.push("("), i._indent.push("{"), null;
  if (s === "{") return i._indent.push("{"), null;
  if (s == ")" && (i._indent.pop(), i._indent.pop()), s === "}") return i._indent.pop(), null;
  if (s == "," || s == ";" || /[{}\(\),;]/.test(s)) return null;
  if (/\d/.test(s)) return e.eatWhile(/[\d]/), e.eat(/[KkMmGg]/), "number";
  if (s == ":") return e.eatWhile(/[a-zA-Z_]/), e.eatWhile(/[a-zA-Z0-9_]/), "operator";
  e.eatWhile(/\w/);
  var c = e.current();
  return c == "text" && e.eat(":") ? (i.tokenize = tokenMultiLineString, "string") : keywords.propertyIsEnumerable(c) ? "keyword" : atoms.propertyIsEnumerable(c) ? "atom" : null;
}
function tokenMultiLineString(e, n) {
  return n._multiLineString = true, e.sol() ? (e.next() == "." && e.eol() && (n._multiLineString = false, n.tokenize = tokenBase), "string") : (e.eatSpace(), e.peek() == "#" ? (e.skipToEnd(), "comment") : (e.skipToEnd(), "string"));
}
function tokenCComment(e, n) {
  for (var r = false, a; (a = e.next()) != null; ) {
    if (r && a == "/") {
      n.tokenize = tokenBase;
      break;
    }
    r = a == "*";
  }
  return "comment";
}
function tokenString(e) {
  return function(n, r) {
    for (var a = false, o; (o = n.next()) != null && !(o == e && !a); ) a = !a && o == "\\";
    return a || (r.tokenize = tokenBase), "string";
  };
}
const sieve = {
  name: "sieve",
  startState: function(e) {
    return {
      tokenize: tokenBase,
      baseIndent: e || 0,
      _indent: []
    };
  },
  token: function(e, n) {
    return e.eatSpace() ? null : (n.tokenize || tokenBase)(e, n);
  },
  indent: function(e, n, r) {
    var i = e._indent.length;
    return n && n[0] == "}" && i--, i < 0 && (i = 0), i * r.unit;
  },
  languageData: { indentOnInput: /^\s*\}$/ }
};
export {
  sieve as t
};
