function words(e) {
  for (var c = {}, l = e.split(" "), u = 0; u < l.length; ++u) c[l[u]] = true;
  return c;
}
var parserConfig = {
  name: "ttcn-cfg",
  keywords: words("Yes No LogFile FileMask ConsoleMask AppendFile TimeStampFormat LogEventTypes SourceInfoFormat LogEntityName LogSourceInfo DiskFullAction LogFileNumber LogFileSize MatchingHints Detailed Compact SubCategories Stack Single None Seconds DateTime Time Stop Error Retry Delete TCPPort KillTimer NumHCs UnixSocketsEnabled LocalAddress"),
  fileNCtrlMaskOptions: words("TTCN_EXECUTOR TTCN_ERROR TTCN_WARNING TTCN_PORTEVENT TTCN_TIMEROP TTCN_VERDICTOP TTCN_DEFAULTOP TTCN_TESTCASE TTCN_ACTION TTCN_USER TTCN_FUNCTION TTCN_STATISTICS TTCN_PARALLEL TTCN_MATCHING TTCN_DEBUG EXECUTOR ERROR WARNING PORTEVENT TIMEROP VERDICTOP DEFAULTOP TESTCASE ACTION USER FUNCTION STATISTICS PARALLEL MATCHING DEBUG LOG_ALL LOG_NOTHING ACTION_UNQUALIFIED DEBUG_ENCDEC DEBUG_TESTPORT DEBUG_UNQUALIFIED DEFAULTOP_ACTIVATE DEFAULTOP_DEACTIVATE DEFAULTOP_EXIT DEFAULTOP_UNQUALIFIED ERROR_UNQUALIFIED EXECUTOR_COMPONENT EXECUTOR_CONFIGDATA EXECUTOR_EXTCOMMAND EXECUTOR_LOGOPTIONS EXECUTOR_RUNTIME EXECUTOR_UNQUALIFIED FUNCTION_RND FUNCTION_UNQUALIFIED MATCHING_DONE MATCHING_MCSUCCESS MATCHING_MCUNSUCC MATCHING_MMSUCCESS MATCHING_MMUNSUCC MATCHING_PCSUCCESS MATCHING_PCUNSUCC MATCHING_PMSUCCESS MATCHING_PMUNSUCC MATCHING_PROBLEM MATCHING_TIMEOUT MATCHING_UNQUALIFIED PARALLEL_PORTCONN PARALLEL_PORTMAP PARALLEL_PTC PARALLEL_UNQUALIFIED PORTEVENT_DUALRECV PORTEVENT_DUALSEND PORTEVENT_MCRECV PORTEVENT_MCSEND PORTEVENT_MMRECV PORTEVENT_MMSEND PORTEVENT_MQUEUE PORTEVENT_PCIN PORTEVENT_PCOUT PORTEVENT_PMIN PORTEVENT_PMOUT PORTEVENT_PQUEUE PORTEVENT_STATE PORTEVENT_UNQUALIFIED STATISTICS_UNQUALIFIED STATISTICS_VERDICT TESTCASE_FINISH TESTCASE_START TESTCASE_UNQUALIFIED TIMEROP_GUARD TIMEROP_READ TIMEROP_START TIMEROP_STOP TIMEROP_TIMEOUT TIMEROP_UNQUALIFIED USER_UNQUALIFIED VERDICTOP_FINAL VERDICTOP_GETVERDICT VERDICTOP_SETVERDICT VERDICTOP_UNQUALIFIED WARNING_UNQUALIFIED"),
  externalCommands: words("BeginControlPart EndControlPart BeginTestCase EndTestCase"),
  multiLineStrings: true
}, keywords = parserConfig.keywords, fileNCtrlMaskOptions = parserConfig.fileNCtrlMaskOptions, externalCommands = parserConfig.externalCommands, multiLineStrings = parserConfig.multiLineStrings, indentStatements = parserConfig.indentStatements !== false, isOperatorChar = /[\|]/, curPunc;
function tokenBase(e, c) {
  var f = e.next();
  if (f == '"' || f == "'") return c.tokenize = tokenString(f), c.tokenize(e, c);
  if (/[:=]/.test(f)) return curPunc = f, "punctuation";
  if (f == "#") return e.skipToEnd(), "comment";
  if (/\d/.test(f)) return e.eatWhile(/[\w\.]/), "number";
  if (isOperatorChar.test(f)) return e.eatWhile(isOperatorChar), "operator";
  if (f == "[") return e.eatWhile(/[\w_\]]/), "number";
  e.eatWhile(/[\w\$_]/);
  var p = e.current();
  return keywords.propertyIsEnumerable(p) ? "keyword" : fileNCtrlMaskOptions.propertyIsEnumerable(p) ? "atom" : externalCommands.propertyIsEnumerable(p) ? "deleted" : "variable";
}
function tokenString(e) {
  return function(c, l) {
    for (var u = false, d, p = false; (d = c.next()) != null; ) {
      if (d == e && !u) {
        var m = c.peek();
        m && (m = m.toLowerCase(), (m == "b" || m == "h" || m == "o") && c.next()), p = true;
        break;
      }
      u = !u && d == "\\";
    }
    return (p || !(u || multiLineStrings)) && (l.tokenize = null), "string";
  };
}
function Context(e, c, l, u, d) {
  this.indented = e, this.column = c, this.type = l, this.align = u, this.prev = d;
}
function pushContext(e, c, l) {
  var u = e.indented;
  return e.context && e.context.type == "statement" && (u = e.context.indented), e.context = new Context(u, c, l, null, e.context);
}
function popContext(e) {
  var c = e.context.type;
  return (c == ")" || c == "]" || c == "}") && (e.indented = e.context.indented), e.context = e.context.prev;
}
const ttcnCfg = {
  name: "ttcn",
  startState: function() {
    return {
      tokenize: null,
      context: new Context(0, 0, "top", false),
      indented: 0,
      startOfLine: true
    };
  },
  token: function(e, c) {
    var l = c.context;
    if (e.sol() && (l.align ?? (l.align = false), c.indented = e.indentation(), c.startOfLine = true), e.eatSpace()) return null;
    curPunc = null;
    var u = (c.tokenize || tokenBase)(e, c);
    if (u == "comment") return u;
    if (l.align ?? (l.align = true), (curPunc == ";" || curPunc == ":" || curPunc == ",") && l.type == "statement") popContext(c);
    else if (curPunc == "{") pushContext(c, e.column(), "}");
    else if (curPunc == "[") pushContext(c, e.column(), "]");
    else if (curPunc == "(") pushContext(c, e.column(), ")");
    else if (curPunc == "}") {
      for (; l.type == "statement"; ) l = popContext(c);
      for (l.type == "}" && (l = popContext(c)); l.type == "statement"; ) l = popContext(c);
    } else curPunc == l.type ? popContext(c) : indentStatements && ((l.type == "}" || l.type == "top") && curPunc != ";" || l.type == "statement" && curPunc == "newstatement") && pushContext(c, e.column(), "statement");
    return c.startOfLine = false, u;
  },
  languageData: {
    indentOnInput: /^\s*[{}]$/,
    commentTokens: { line: "#" }
  }
};
export {
  ttcnCfg as t
};
