function forEach(e, c) {
  for (var l = 0; l < e.length; l++) c(e[l], l);
}
function some(e, c) {
  for (var l = 0; l < e.length; l++) if (c(e[l], l)) return true;
  return false;
}
var words = {
  unnamedDefinition: ["interface"],
  namedDefinition: [
    "module",
    "library",
    "macro",
    "C-struct",
    "C-union",
    "C-function",
    "C-callable-wrapper"
  ],
  typeParameterizedDefinition: [
    "class",
    "C-subtype",
    "C-mapped-subtype"
  ],
  otherParameterizedDefinition: [
    "method",
    "function",
    "C-variable",
    "C-address"
  ],
  constantSimpleDefinition: ["constant"],
  variableSimpleDefinition: ["variable"],
  otherSimpleDefinition: [
    "generic",
    "domain",
    "C-pointer-type",
    "table"
  ],
  statement: [
    "if",
    "block",
    "begin",
    "method",
    "case",
    "for",
    "select",
    "when",
    "unless",
    "until",
    "while",
    "iterate",
    "profiling",
    "dynamic-bind"
  ],
  separator: [
    "finally",
    "exception",
    "cleanup",
    "else",
    "elseif",
    "afterwards"
  ],
  other: [
    "above",
    "below",
    "by",
    "from",
    "handler",
    "in",
    "instance",
    "let",
    "local",
    "otherwise",
    "slot",
    "subclass",
    "then",
    "to",
    "keyed-by",
    "virtual"
  ],
  signalingCalls: [
    "signal",
    "error",
    "cerror",
    "break",
    "check-type",
    "abort"
  ]
};
words.otherDefinition = words.unnamedDefinition.concat(words.namedDefinition).concat(words.otherParameterizedDefinition), words.definition = words.typeParameterizedDefinition.concat(words.otherDefinition), words.parameterizedDefinition = words.typeParameterizedDefinition.concat(words.otherParameterizedDefinition), words.simpleDefinition = words.constantSimpleDefinition.concat(words.variableSimpleDefinition).concat(words.otherSimpleDefinition), words.keyword = words.statement.concat(words.separator).concat(words.other);
var symbolPattern = "[-_a-zA-Z?!*@<>$%]+", symbol = /* @__PURE__ */ RegExp("^" + symbolPattern), patterns = {
  symbolKeyword: symbolPattern + ":",
  symbolClass: "<" + symbolPattern + ">",
  symbolGlobal: "\\*" + symbolPattern + "\\*",
  symbolConstant: "\\$" + symbolPattern
}, patternStyles = {
  symbolKeyword: "atom",
  symbolClass: "tag",
  symbolGlobal: "variableName.standard",
  symbolConstant: "variableName.constant"
};
for (var patternName in patterns) patterns.hasOwnProperty(patternName) && (patterns[patternName] = /* @__PURE__ */ RegExp("^" + patterns[patternName]));
patterns.keyword = [/^with(?:out)?-[-_a-zA-Z?!*@<>$%]+/];
var styles = {};
styles.keyword = "keyword", styles.definition = "def", styles.simpleDefinition = "def", styles.signalingCalls = "builtin";
var wordLookup = {}, styleLookup = {};
forEach([
  "keyword",
  "definition",
  "simpleDefinition",
  "signalingCalls"
], function(c) {
  forEach(words[c], function(e) {
    wordLookup[e] = c, styleLookup[e] = styles[c];
  });
});
function chain(e, c, l) {
  return c.tokenize = l, l(e, c);
}
function tokenBase(e, l) {
  var u = e.peek();
  if (u == "'" || u == '"') return e.next(), chain(e, l, tokenString(u, "string"));
  if (u == "/") {
    if (e.next(), e.eat("*")) return chain(e, l, tokenComment);
    if (e.eat("/")) return e.skipToEnd(), "comment";
    e.backUp(1);
  } else if (/[+\-\d\.]/.test(u)) {
    if (e.match(/^[+-]?[0-9]*\.[0-9]*([esdx][+-]?[0-9]+)?/i) || e.match(/^[+-]?[0-9]+([esdx][+-]?[0-9]+)/i) || e.match(/^[+-]?\d+/)) return "number";
  } else if (u == "#") return e.next(), u = e.peek(), u == '"' ? (e.next(), chain(e, l, tokenString('"', "string"))) : u == "b" ? (e.next(), e.eatWhile(/[01]/), "number") : u == "x" ? (e.next(), e.eatWhile(/[\da-f]/i), "number") : u == "o" ? (e.next(), e.eatWhile(/[0-7]/), "number") : u == "#" ? (e.next(), "punctuation") : u == "[" || u == "(" ? (e.next(), "bracket") : e.match(/f|t|all-keys|include|key|next|rest/i) ? "atom" : (e.eatWhile(/[-a-zA-Z]/), "error");
  else if (u == "~") return e.next(), u = e.peek(), u == "=" ? (e.next(), u = e.peek(), u == "=" && e.next(), "operator") : "operator";
  else if (u == ":") {
    if (e.next(), u = e.peek(), u == "=") return e.next(), "operator";
    if (u == ":") return e.next(), "punctuation";
  } else if ("[](){}".indexOf(u) != -1) return e.next(), "bracket";
  else if (".,".indexOf(u) != -1) return e.next(), "punctuation";
  else if (e.match("end")) return "keyword";
  for (var m in patterns) if (patterns.hasOwnProperty(m)) {
    var h = patterns[m];
    if (h instanceof Array && some(h, function(c) {
      return e.match(c);
    }) || e.match(h)) return patternStyles[m];
  }
  return /[+\-*\/^=<>&|]/.test(u) ? (e.next(), "operator") : e.match("define") ? "def" : (e.eatWhile(/[\w\-]/), wordLookup.hasOwnProperty(e.current()) ? styleLookup[e.current()] : e.current().match(symbol) ? "variable" : (e.next(), "variableName.standard"));
}
function tokenComment(e, c) {
  for (var l = false, u = false, d = 0, f; f = e.next(); ) {
    if (f == "/" && l) if (d > 0) d--;
    else {
      c.tokenize = tokenBase;
      break;
    }
    else f == "*" && u && d++;
    l = f == "*", u = f == "/";
  }
  return "comment";
}
function tokenString(e, c) {
  return function(l, u) {
    for (var d = false, f, p = false; (f = l.next()) != null; ) {
      if (f == e && !d) {
        p = true;
        break;
      }
      d = !d && f == "\\";
    }
    return (p || !d) && (u.tokenize = tokenBase), c;
  };
}
const dylan = {
  name: "dylan",
  startState: function() {
    return {
      tokenize: tokenBase,
      currentIndent: 0
    };
  },
  token: function(e, c) {
    return e.eatSpace() ? null : c.tokenize(e, c);
  },
  languageData: { commentTokens: { block: {
    open: "/*",
    close: "*/"
  } } }
};
export {
  dylan as t
};
