function wordRegexp(e){return new RegExp("^(("+e.join(")|(")+"))\\b")}var builtinArray=["Clamp","Constructor","EnforceRange","Exposed","ImplicitThis","Global","PrimaryGlobal","LegacyArrayClass","LegacyUnenumerableNamedProperties","LenientThis","NamedConstructor","NewObject","NoInterfaceObject","OverrideBuiltins","PutForwards","Replaceable","SameObject","TreatNonObjectAsNull","TreatNullAs","EmptyString","Unforgeable","Unscopeable"],builtins=wordRegexp(builtinArray),typeArray=["unsigned","short","long","unrestricted","float","double","boolean","byte","octet","Promise","ArrayBuffer","DataView","Int8Array","Int16Array","Int32Array","Uint8Array","Uint16Array","Uint32Array","Uint8ClampedArray","Float32Array","Float64Array","ByteString","DOMString","USVString","sequence","object","RegExp","Error","DOMException","FrozenArray","any","void"],types=wordRegexp(typeArray),keywordArray=["attribute","callback","const","deleter","dictionary","enum","getter","implements","inherit","interface","iterable","legacycaller","maplike","partial","required","serializer","setlike","setter","static","stringifier","typedef","optional","readonly","or"],keywords=wordRegexp(keywordArray),atomArray=["true","false","Infinity","NaN","null"],atoms=wordRegexp(atomArray),startDefArray=["callback","dictionary","enum","interface"],startDefs=wordRegexp(startDefArray),endDefArray=["typedef"],endDefs=wordRegexp(endDefArray),singleOperators=/^[:<=>?]/,integers=/^-?([1-9][0-9]*|0[Xx][0-9A-Fa-f]+|0[0-7]*)/,floats=/^-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+)/,identifiers=/^_?[A-Za-z][0-9A-Z_a-z-]*/,identifiersEnd=/^_?[A-Za-z][0-9A-Z_a-z-]*(?=\s*;)/,strings=/^"[^"]*"/,multilineComments=/^\/\*.*?\*\//,multilineCommentsStart=/^\/\*.*/,multilineCommentsEnd=/^.*?\*\//;function readToken(e,t){if(e.eatSpace())return null;if(t.inComment)return e.match(multilineCommentsEnd)?(t.inComment=!1,"comment"):(e.skipToEnd(),"comment");if(e.match("//"))return e.skipToEnd(),"comment";if(e.match(multilineComments))return "comment";if(e.match(multilineCommentsStart))return t.inComment=!0,"comment";if(e.match(/^-?[0-9\.]/,!1)&&(e.match(integers)||e.match(floats)))return "number";if(e.match(strings))return "string";if(t.startDef&&e.match(identifiers))return "def";if(t.endDef&&e.match(identifiersEnd))return t.endDef=!1,"def";if(e.match(keywords))return "keyword";if(e.match(types)){var r=t.lastToken,n=(e.match(/^\s*(.+?)\b/,!1)||[])[1];return ":"===r||"implements"===r||"implements"===n||"="===n?"builtin":"type"}return e.match(builtins)?"builtin":e.match(atoms)?"atom":e.match(identifiers)?"variable":e.match(singleOperators)?"operator":(e.next(),null)}const webIDL={startState:function(){return {inComment:!1,lastToken:"",startDef:!1,endDef:!1}},token:function(e,t){var r=readToken(e,t);if(r){var n=e.current();t.lastToken=n,"keyword"===r?(t.startDef=startDefs.test(n),t.endDef=t.endDef||endDefs.test(n)):t.startDef=!1;}return r},languageData:{autocomplete:builtinArray.concat(typeArray).concat(keywordArray).concat(atomArray)}};

export { webIDL };
