var Location = {
  PRE_SUBJECT: 0,
  WRITING_SUB_URI: 1,
  WRITING_BNODE_URI: 2,
  PRE_PRED: 3,
  WRITING_PRED_URI: 4,
  PRE_OBJ: 5,
  WRITING_OBJ_URI: 6,
  WRITING_OBJ_BNODE: 7,
  WRITING_OBJ_LITERAL: 8,
  WRITING_LIT_LANG: 9,
  WRITING_LIT_TYPE: 10,
  POST_OBJ: 11,
  ERROR: 12
};
function transitState(t, n) {
  var r = t.location;
  t.location = r == Location.PRE_SUBJECT && n == "<" ? Location.WRITING_SUB_URI : r == Location.PRE_SUBJECT && n == "_" ? Location.WRITING_BNODE_URI : r == Location.PRE_PRED && n == "<" ? Location.WRITING_PRED_URI : r == Location.PRE_OBJ && n == "<" ? Location.WRITING_OBJ_URI : r == Location.PRE_OBJ && n == "_" ? Location.WRITING_OBJ_BNODE : r == Location.PRE_OBJ && n == '"' ? Location.WRITING_OBJ_LITERAL : r == Location.WRITING_SUB_URI && n == ">" || r == Location.WRITING_BNODE_URI && n == " " ? Location.PRE_PRED : r == Location.WRITING_PRED_URI && n == ">" ? Location.PRE_OBJ : r == Location.WRITING_OBJ_URI && n == ">" || r == Location.WRITING_OBJ_BNODE && n == " " || r == Location.WRITING_OBJ_LITERAL && n == '"' || r == Location.WRITING_LIT_LANG && n == " " || r == Location.WRITING_LIT_TYPE && n == ">" ? Location.POST_OBJ : r == Location.WRITING_OBJ_LITERAL && n == "@" ? Location.WRITING_LIT_LANG : r == Location.WRITING_OBJ_LITERAL && n == "^" ? Location.WRITING_LIT_TYPE : n == " " && (r == Location.PRE_SUBJECT || r == Location.PRE_PRED || r == Location.PRE_OBJ || r == Location.POST_OBJ) ? r : r == Location.POST_OBJ && n == "." ? Location.PRE_SUBJECT : Location.ERROR;
}
const ntriples = {
  name: "ntriples",
  startState: function() {
    return {
      location: Location.PRE_SUBJECT,
      uris: [],
      anchors: [],
      bnodes: [],
      langs: [],
      types: []
    };
  },
  token: function(e, n) {
    var r = e.next();
    if (r == "<") {
      transitState(n, r);
      var i = "";
      return e.eatWhile(function(e2) {
        return e2 != "#" && e2 != ">" ? (i += e2, true) : false;
      }), n.uris.push(i), e.match("#", false) ? "variable" : (e.next(), transitState(n, ">"), "variable");
    }
    if (r == "#") {
      var a = "";
      return e.eatWhile(function(e2) {
        return e2 != ">" && e2 != " " ? (a += e2, true) : false;
      }), n.anchors.push(a), "url";
    }
    if (r == ">") return transitState(n, ">"), "variable";
    if (r == "_") {
      transitState(n, r);
      var o = "";
      return e.eatWhile(function(e2) {
        return e2 == " " ? false : (o += e2, true);
      }), n.bnodes.push(o), e.next(), transitState(n, " "), "builtin";
    }
    if (r == '"') return transitState(n, r), e.eatWhile(function(e2) {
      return e2 != '"';
    }), e.next(), e.peek() != "@" && e.peek() != "^" && transitState(n, '"'), "string";
    if (r == "@") {
      transitState(n, "@");
      var s = "";
      return e.eatWhile(function(e2) {
        return e2 == " " ? false : (s += e2, true);
      }), n.langs.push(s), e.next(), transitState(n, " "), "string.special";
    }
    if (r == "^") {
      e.next(), transitState(n, "^");
      var c = "";
      return e.eatWhile(function(e2) {
        return e2 == ">" ? false : (c += e2, true);
      }), n.types.push(c), e.next(), transitState(n, ">"), "variable";
    }
    r == " " && transitState(n, r), r == "." && transitState(n, r);
  }
};
export {
  ntriples as t
};
