function mkParser(e) {
  return {
    name: "mscgen",
    startState: startStateFn,
    copyState: copyStateFn,
    token: produceTokenFunction(e),
    languageData: { commentTokens: {
      line: "#",
      block: {
        open: "/*",
        close: "*/"
      }
    } }
  };
}
const mscgen = mkParser({
  keywords: ["msc"],
  options: [
    "hscale",
    "width",
    "arcgradient",
    "wordwraparcs"
  ],
  constants: [
    "true",
    "false",
    "on",
    "off"
  ],
  attributes: [
    "label",
    "idurl",
    "id",
    "url",
    "linecolor",
    "linecolour",
    "textcolor",
    "textcolour",
    "textbgcolor",
    "textbgcolour",
    "arclinecolor",
    "arclinecolour",
    "arctextcolor",
    "arctextcolour",
    "arctextbgcolor",
    "arctextbgcolour",
    "arcskip"
  ],
  brackets: ["\\{", "\\}"],
  arcsWords: [
    "note",
    "abox",
    "rbox",
    "box"
  ],
  arcsOthers: [
    "\\|\\|\\|",
    "\\.\\.\\.",
    "---",
    "--",
    "<->",
    "==",
    "<<=>>",
    "<=>",
    "\\.\\.",
    "<<>>",
    "::",
    "<:>",
    "->",
    "=>>",
    "=>",
    ">>",
    ":>",
    "<-",
    "<<=",
    "<=",
    "<<",
    "<:",
    "x-",
    "-x"
  ],
  singlecomment: ["//", "#"],
  operators: ["="]
}), msgenny = mkParser({
  keywords: null,
  options: [
    "hscale",
    "width",
    "arcgradient",
    "wordwraparcs",
    "wordwrapentities",
    "watermark"
  ],
  constants: [
    "true",
    "false",
    "on",
    "off",
    "auto"
  ],
  attributes: null,
  brackets: ["\\{", "\\}"],
  arcsWords: [
    "note",
    "abox",
    "rbox",
    "box",
    "alt",
    "else",
    "opt",
    "break",
    "par",
    "seq",
    "strict",
    "neg",
    "critical",
    "ignore",
    "consider",
    "assert",
    "loop",
    "ref",
    "exc"
  ],
  arcsOthers: [
    "\\|\\|\\|",
    "\\.\\.\\.",
    "---",
    "--",
    "<->",
    "==",
    "<<=>>",
    "<=>",
    "\\.\\.",
    "<<>>",
    "::",
    "<:>",
    "->",
    "=>>",
    "=>",
    ">>",
    ":>",
    "<-",
    "<<=",
    "<=",
    "<<",
    "<:",
    "x-",
    "-x"
  ],
  singlecomment: ["//", "#"],
  operators: ["="]
}), xu = mkParser({
  keywords: ["msc", "xu"],
  options: [
    "hscale",
    "width",
    "arcgradient",
    "wordwraparcs",
    "wordwrapentities",
    "watermark"
  ],
  constants: [
    "true",
    "false",
    "on",
    "off",
    "auto"
  ],
  attributes: [
    "label",
    "idurl",
    "id",
    "url",
    "linecolor",
    "linecolour",
    "textcolor",
    "textcolour",
    "textbgcolor",
    "textbgcolour",
    "arclinecolor",
    "arclinecolour",
    "arctextcolor",
    "arctextcolour",
    "arctextbgcolor",
    "arctextbgcolour",
    "arcskip",
    "title",
    "deactivate",
    "activate",
    "activation"
  ],
  brackets: ["\\{", "\\}"],
  arcsWords: [
    "note",
    "abox",
    "rbox",
    "box",
    "alt",
    "else",
    "opt",
    "break",
    "par",
    "seq",
    "strict",
    "neg",
    "critical",
    "ignore",
    "consider",
    "assert",
    "loop",
    "ref",
    "exc"
  ],
  arcsOthers: [
    "\\|\\|\\|",
    "\\.\\.\\.",
    "---",
    "--",
    "<->",
    "==",
    "<<=>>",
    "<=>",
    "\\.\\.",
    "<<>>",
    "::",
    "<:>",
    "->",
    "=>>",
    "=>",
    ">>",
    ":>",
    "<-",
    "<<=",
    "<=",
    "<<",
    "<:",
    "x-",
    "-x"
  ],
  singlecomment: ["//", "#"],
  operators: ["="]
});
function wordRegexpBoundary(e) {
  return RegExp("^\\b(" + e.join("|") + ")\\b", "i");
}
function wordRegexp(e) {
  return RegExp("^(?:" + e.join("|") + ")", "i");
}
function startStateFn() {
  return {
    inComment: false,
    inString: false,
    inAttributeList: false,
    inScript: false
  };
}
function copyStateFn(e) {
  return {
    inComment: e.inComment,
    inString: e.inString,
    inAttributeList: e.inAttributeList,
    inScript: e.inScript
  };
}
function produceTokenFunction(e) {
  return function(s, c) {
    if (s.match(wordRegexp(e.brackets), true, true)) return "bracket";
    if (!c.inComment) {
      if (s.match(/\/\*[^\*\/]*/, true, true)) return c.inComment = true, "comment";
      if (s.match(wordRegexp(e.singlecomment), true, true)) return s.skipToEnd(), "comment";
    }
    if (c.inComment) return s.match(/[^\*\/]*\*\//, true, true) ? c.inComment = false : s.skipToEnd(), "comment";
    if (!c.inString && s.match(/\"(\\\"|[^\"])*/, true, true)) return c.inString = true, "string";
    if (c.inString) return s.match(/[^\"]*\"/, true, true) ? c.inString = false : s.skipToEnd(), "string";
    if (e.keywords && s.match(wordRegexpBoundary(e.keywords), true, true) || s.match(wordRegexpBoundary(e.options), true, true) || s.match(wordRegexpBoundary(e.arcsWords), true, true) || s.match(wordRegexp(e.arcsOthers), true, true)) return "keyword";
    if (e.operators && s.match(wordRegexp(e.operators), true, true)) return "operator";
    if (e.constants && s.match(wordRegexp(e.constants), true, true)) return "variable";
    if (!e.inAttributeList && e.attributes && s.match("[", true, true)) return e.inAttributeList = true, "bracket";
    if (e.inAttributeList) {
      if (e.attributes !== null && s.match(wordRegexpBoundary(e.attributes), true, true)) return "attribute";
      if (s.match("]", true, true)) return e.inAttributeList = false, "bracket";
    }
    return s.next(), null;
  };
}
export {
  msgenny as n,
  xu as r,
  mscgen as t
};
