function words(e) {
  for (var c = {}, l = e.split(" "), u = 0; u < l.length; ++u) c[l[u]] = true;
  return c;
}
var pBuiltins = "ABS ACOS ARITY ASIN ATAN AVG BAGSIZE BINSTORAGE BLOOM BUILDBLOOM CBRT CEIL CONCAT COR COS COSH COUNT COUNT_STAR COV CONSTANTSIZE CUBEDIMENSIONS DIFF DISTINCT DOUBLEABS DOUBLEAVG DOUBLEBASE DOUBLEMAX DOUBLEMIN DOUBLEROUND DOUBLESUM EXP FLOOR FLOATABS FLOATAVG FLOATMAX FLOATMIN FLOATROUND FLOATSUM GENERICINVOKER INDEXOF INTABS INTAVG INTMAX INTMIN INTSUM INVOKEFORDOUBLE INVOKEFORFLOAT INVOKEFORINT INVOKEFORLONG INVOKEFORSTRING INVOKER ISEMPTY JSONLOADER JSONMETADATA JSONSTORAGE LAST_INDEX_OF LCFIRST LOG LOG10 LOWER LONGABS LONGAVG LONGMAX LONGMIN LONGSUM MAX MIN MAPSIZE MONITOREDUDF NONDETERMINISTIC OUTPUTSCHEMA  PIGSTORAGE PIGSTREAMING RANDOM REGEX_EXTRACT REGEX_EXTRACT_ALL REPLACE ROUND SIN SINH SIZE SQRT STRSPLIT SUBSTRING SUM STRINGCONCAT STRINGMAX STRINGMIN STRINGSIZE TAN TANH TOBAG TOKENIZE TOMAP TOP TOTUPLE TRIM TEXTLOADER TUPLESIZE UCFIRST UPPER UTF8STORAGECONVERTER ", pKeywords = "VOID IMPORT RETURNS DEFINE LOAD FILTER FOREACH ORDER CUBE DISTINCT COGROUP JOIN CROSS UNION SPLIT INTO IF OTHERWISE ALL AS BY USING INNER OUTER ONSCHEMA PARALLEL PARTITION GROUP AND OR NOT GENERATE FLATTEN ASC DESC IS STREAM THROUGH STORE MAPREDUCE SHIP CACHE INPUT OUTPUT STDERROR STDIN STDOUT LIMIT SAMPLE LEFT RIGHT FULL EQ GT LT GTE LTE NEQ MATCHES TRUE FALSE DUMP", pTypes = "BOOLEAN INT LONG FLOAT DOUBLE CHARARRAY BYTEARRAY BAG TUPLE MAP ", builtins = words(pBuiltins), keywords = words(pKeywords), types = words(pTypes), isOperatorChar = /[*+\-%<>=&?:\/!|]/;
function chain(e, c, l) {
  return c.tokenize = l, l(e, c);
}
function tokenComment(e, c) {
  for (var l = false, u; u = e.next(); ) {
    if (u == "/" && l) {
      c.tokenize = tokenBase;
      break;
    }
    l = u == "*";
  }
  return "comment";
}
function tokenString(e) {
  return function(c, l) {
    for (var u = false, d, f = false; (d = c.next()) != null; ) {
      if (d == e && !u) {
        f = true;
        break;
      }
      u = !u && d == "\\";
    }
    return (f || !u) && (l.tokenize = tokenBase), "error";
  };
}
function tokenBase(e, c) {
  var l = e.next();
  return l == '"' || l == "'" ? chain(e, c, tokenString(l)) : /[\[\]{}\(\),;\.]/.test(l) ? null : /\d/.test(l) ? (e.eatWhile(/[\w\.]/), "number") : l == "/" ? e.eat("*") ? chain(e, c, tokenComment) : (e.eatWhile(isOperatorChar), "operator") : l == "-" ? e.eat("-") ? (e.skipToEnd(), "comment") : (e.eatWhile(isOperatorChar), "operator") : isOperatorChar.test(l) ? (e.eatWhile(isOperatorChar), "operator") : (e.eatWhile(/[\w\$_]/), keywords && keywords.propertyIsEnumerable(e.current().toUpperCase()) && !e.eat(")") && !e.eat(".") ? "keyword" : builtins && builtins.propertyIsEnumerable(e.current().toUpperCase()) ? "builtin" : types && types.propertyIsEnumerable(e.current().toUpperCase()) ? "type" : "variable");
}
const pig = {
  name: "pig",
  startState: function() {
    return {
      tokenize: tokenBase,
      startOfLine: true
    };
  },
  token: function(e, c) {
    return e.eatSpace() ? null : c.tokenize(e, c);
  },
  languageData: { autocomplete: (pBuiltins + pTypes + pKeywords).split(" ") }
};
export {
  pig as t
};
