function parseWords(e){for(var r={},t=e.split(" "),n=0;n<t.length;++n)r[t[n]]=!0;return r}var keywords=parseWords("Tcl safe after append array auto_execok auto_import auto_load auto_mkindex auto_mkindex_old auto_qualify auto_reset bgerror binary break catch cd close concat continue dde eof encoding error eval exec exit expr fblocked fconfigure fcopy file fileevent filename filename flush for foreach format gets glob global history http if incr info interp join lappend lindex linsert list llength load lrange lreplace lsearch lset lsort memory msgcat namespace open package parray pid pkg::create pkg_mkIndex proc puts pwd re_syntax read regex regexp registry regsub rename resource return scan seek set socket source split string subst switch tcl_endOfWord tcl_findLibrary tcl_startOfNextWord tcl_wordBreakAfter tcl_startOfPreviousWord tcl_wordBreakBefore tcltest tclvars tell time trace unknown unset update uplevel upvar variable vwait"),functions=parseWords("if elseif else and not or eq ne in ni for foreach while switch"),isOperatorChar=/[+\-*&%=<>!?^\/\|]/;function chain(e,r,t){return r.tokenize=t,t(e,r)}function tokenBase(e,r){var t=r.beforeParams;r.beforeParams=!1;var n=e.next();if('"'!=n&&"'"!=n||!r.inParams){if(/[\[\]{}\(\),;\.]/.test(n))return "("==n&&t?r.inParams=!0:")"==n&&(r.inParams=!1),null;if(/\d/.test(n))return e.eatWhile(/[\w\.]/),"number";if("#"==n)return e.eat("*")?chain(e,r,tokenComment):"#"==n&&e.match(/ *\[ *\[/)?chain(e,r,tokenUnparsed):(e.skipToEnd(),"comment");if('"'==n)return e.skipTo(/"/),"comment";if("$"==n)return e.eatWhile(/[$_a-z0-9A-Z\.{:]/),e.eatWhile(/}/),r.beforeParams=!0,"builtin";if(isOperatorChar.test(n))return e.eatWhile(isOperatorChar),"comment";e.eatWhile(/[\w\$_{}\xa1-\uffff]/);var a=e.current().toLowerCase();return keywords&&keywords.propertyIsEnumerable(a)?"keyword":functions&&functions.propertyIsEnumerable(a)?(r.beforeParams=!0,"keyword"):null}return chain(e,r,tokenString(n))}function tokenString(e){return function(r,t){for(var n,a=!1,o=!1;null!=(n=r.next());){if(n==e&&!a){o=!0;break}a=!a&&"\\"==n;}return o&&(t.tokenize=tokenBase),"string"}}function tokenComment(e,r){for(var t,n=!1;t=e.next();){if("#"==t&&n){r.tokenize=tokenBase;break}n="*"==t;}return "comment"}function tokenUnparsed(e,r){for(var t,n=0;t=e.next();){if("#"==t&&2==n){r.tokenize=tokenBase;break}"]"==t?n++:" "!=t&&(n=0);}return "meta"}const tcl={startState:function(){return {tokenize:tokenBase,beforeParams:!1,inParams:!1}},token:function(e,r){return e.eatSpace()?null:r.tokenize(e,r)},languageData:{commentTokens:{line:"#"}}};

export { tcl };
