var Identifier = "[a-zA-Z\\$][a-zA-Z0-9\\$]*", pBase = "(?:\\d+)", pFloat = "(?:\\.\\d+|\\d+\\.\\d*|\\d+)", pFloatBase = "(?:\\.\\w+|\\w+\\.\\w*|\\w+)", pPrecision = "(?:`(?:`?" + pFloat + ")?)", reBaseForm = /* @__PURE__ */ RegExp("(?:" + pBase + "(?:\\^\\^" + pFloatBase + pPrecision + "?(?:\\*\\^[+-]?\\d+)?))"), reFloatForm = /* @__PURE__ */ RegExp("(?:" + pFloat + pPrecision + "?(?:\\*\\^[+-]?\\d+)?)"), reIdInContext = /* @__PURE__ */ RegExp("(?:`?)(?:" + Identifier + ")(?:`(?:" + Identifier + "))*(?:`?)");
function tokenBase(e, c) {
  var l = e.next();
  return l === '"' ? (c.tokenize = tokenString, c.tokenize(e, c)) : l === "(" && e.eat("*") ? (c.commentLevel++, c.tokenize = tokenComment, c.tokenize(e, c)) : (e.backUp(1), e.match(reBaseForm, true, false) || e.match(reFloatForm, true, false) ? "number" : e.match(/(?:In|Out)\[[0-9]*\]/, true, false) ? "atom" : e.match(/([a-zA-Z\$][a-zA-Z0-9\$]*(?:`[a-zA-Z0-9\$]+)*::usage)/, true, false) ? "meta" : e.match(/([a-zA-Z\$][a-zA-Z0-9\$]*(?:`[a-zA-Z0-9\$]+)*::[a-zA-Z\$][a-zA-Z0-9\$]*):?/, true, false) ? "string.special" : e.match(/([a-zA-Z\$][a-zA-Z0-9\$]*\s*:)(?:(?:[a-zA-Z\$][a-zA-Z0-9\$]*)|(?:[^:=>~@\^\&\*\)\[\]'\?,\|])).*/, true, false) || e.match(/[a-zA-Z\$][a-zA-Z0-9\$]*_+[a-zA-Z\$][a-zA-Z0-9\$]*/, true, false) || e.match(/[a-zA-Z\$][a-zA-Z0-9\$]*_+/, true, false) || e.match(/_+[a-zA-Z\$][a-zA-Z0-9\$]*/, true, false) ? "variableName.special" : e.match(/\\\[[a-zA-Z\$][a-zA-Z0-9\$]*\]/, true, false) ? "character" : e.match(/(?:\[|\]|{|}|\(|\))/, true, false) ? "bracket" : e.match(/(?:#[a-zA-Z\$][a-zA-Z0-9\$]*|#+[0-9]?)/, true, false) ? "variableName.constant" : e.match(reIdInContext, true, false) ? "keyword" : e.match(/(?:\\|\+|\-|\*|\/|,|;|\.|:|@|~|=|>|<|&|\||_|`|'|\^|\?|!|%)/, true, false) ? "operator" : (e.next(), "error"));
}
function tokenString(e, c) {
  for (var l, u = false, d = false; (l = e.next()) != null; ) {
    if (l === '"' && !d) {
      u = true;
      break;
    }
    d = !d && l === "\\";
  }
  return u && !d && (c.tokenize = tokenBase), "string";
}
function tokenComment(e, c) {
  for (var l, u; c.commentLevel > 0 && (u = e.next()) != null; ) l === "(" && u === "*" && c.commentLevel++, l === "*" && u === ")" && c.commentLevel--, l = u;
  return c.commentLevel <= 0 && (c.tokenize = tokenBase), "comment";
}
const mathematica = {
  name: "mathematica",
  startState: function() {
    return {
      tokenize: tokenBase,
      commentLevel: 0
    };
  },
  token: function(e, c) {
    return e.eatSpace() ? null : c.tokenize(e, c);
  },
  languageData: { commentTokens: { block: {
    open: "(*",
    close: "*)"
  } } }
};
export {
  mathematica as t
};
