function wordRegexp(e) {
  return /* @__PURE__ */ RegExp("^((" + e.join(")|(") + "))\\b");
}
var singleOperators = /* @__PURE__ */ RegExp("^[\\+\\-\\*/&|\\^~<>!@'\\\\]"), singleDelimiters = /* @__PURE__ */ RegExp("^[\\(\\[\\{\\},:=;\\.]"), doubleOperators = /* @__PURE__ */ RegExp("^((==)|(~=)|(<=)|(>=)|(<<)|(>>)|(\\.[\\+\\-\\*/\\^\\\\]))"), doubleDelimiters = /* @__PURE__ */ RegExp("^((!=)|(\\+=)|(\\-=)|(\\*=)|(/=)|(&=)|(\\|=)|(\\^=))"), tripleDelimiters = /* @__PURE__ */ RegExp("^((>>=)|(<<=))"), expressionEnd = /* @__PURE__ */ RegExp("^[\\]\\)]"), identifiers = /* @__PURE__ */ RegExp("^[_A-Za-z\xA1-\uFFFF][_A-Za-z0-9\xA1-\uFFFF]*"), builtins = wordRegexp(/* @__PURE__ */ "error.eval.function.abs.acos.atan.asin.cos.cosh.exp.log.prod.sum.log10.max.min.sign.sin.sinh.sqrt.tan.reshape.break.zeros.default.margin.round.ones.rand.syn.ceil.floor.size.clear.zeros.eye.mean.std.cov.det.eig.inv.norm.rank.trace.expm.logm.sqrtm.linspace.plot.title.xlabel.ylabel.legend.text.grid.meshgrid.mesh.num2str.fft.ifft.arrayfun.cellfun.input.fliplr.flipud.ismember".split(".")), keywords = wordRegexp(/* @__PURE__ */ "return.case.switch.else.elseif.end.endif.endfunction.if.otherwise.do.for.while.try.catch.classdef.properties.events.methods.global.persistent.endfor.endwhile.printf.sprintf.disp.until.continue.pkg".split("."));
function tokenTranspose(e, d) {
  return !e.sol() && e.peek() === "'" ? (e.next(), d.tokenize = tokenBase, "operator") : (d.tokenize = tokenBase, tokenBase(e, d));
}
function tokenComment(e, d) {
  return e.match(/^.*%}/) ? (d.tokenize = tokenBase, "comment") : (e.skipToEnd(), "comment");
}
function tokenBase(p, m) {
  if (p.eatSpace()) return null;
  if (p.match("%{")) return m.tokenize = tokenComment, p.skipToEnd(), "comment";
  if (p.match(/^[%#]/)) return p.skipToEnd(), "comment";
  if (p.match(/^[0-9\.+-]/, false)) {
    if (p.match(/^[+-]?0x[0-9a-fA-F]+[ij]?/)) return p.tokenize = tokenBase, "number";
    if (p.match(/^[+-]?\d*\.\d+([EeDd][+-]?\d+)?[ij]?/) || p.match(/^[+-]?\d+([EeDd][+-]?\d+)?[ij]?/)) return "number";
  }
  if (p.match(wordRegexp([
    "nan",
    "NaN",
    "inf",
    "Inf"
  ]))) return "number";
  var h = p.match(/^"(?:[^"]|"")*("|$)/) || p.match(/^'(?:[^']|'')*('|$)/);
  return h ? h[1] ? "string" : "error" : p.match(keywords) ? "keyword" : p.match(builtins) ? "builtin" : p.match(identifiers) ? "variable" : p.match(singleOperators) || p.match(doubleOperators) ? "operator" : p.match(singleDelimiters) || p.match(doubleDelimiters) || p.match(tripleDelimiters) ? null : p.match(expressionEnd) ? (m.tokenize = tokenTranspose, null) : (p.next(), "error");
}
const octave = {
  name: "octave",
  startState: function() {
    return { tokenize: tokenBase };
  },
  token: function(e, d) {
    var f = d.tokenize(e, d);
    return (f === "number" || f === "variable") && (d.tokenize = tokenTranspose), f;
  },
  languageData: { commentTokens: { line: "%" } }
};
export {
  octave as t
};
