function wordRegexp(e){return new RegExp("^(("+e.join(")|(")+"))\\b")}var singleOperators=new RegExp("^[\\+\\-\\*/&|\\^~<>!@'\\\\]"),singleDelimiters=new RegExp("^[\\(\\[\\{\\},:=;\\.]"),doubleOperators=new RegExp("^((==)|(~=)|(<=)|(>=)|(<<)|(>>)|(\\.[\\+\\-\\*/\\^\\\\]))"),doubleDelimiters=new RegExp("^((!=)|(\\+=)|(\\-=)|(\\*=)|(/=)|(&=)|(\\|=)|(\\^=))"),tripleDelimiters=new RegExp("^((>>=)|(<<=))"),expressionEnd=new RegExp("^[\\]\\)]"),identifiers=new RegExp("^[_A-Za-z¡-][_A-Za-z0-9¡-]*"),builtins=wordRegexp(["error","eval","function","abs","acos","atan","asin","cos","cosh","exp","log","prod","sum","log10","max","min","sign","sin","sinh","sqrt","tan","reshape","break","zeros","default","margin","round","ones","rand","syn","ceil","floor","size","clear","zeros","eye","mean","std","cov","det","eig","inv","norm","rank","trace","expm","logm","sqrtm","linspace","plot","title","xlabel","ylabel","legend","text","grid","meshgrid","mesh","num2str","fft","ifft","arrayfun","cellfun","input","fliplr","flipud","ismember"]),keywords=wordRegexp(["return","case","switch","else","elseif","end","endif","endfunction","if","otherwise","do","for","while","try","catch","classdef","properties","events","methods","global","persistent","endfor","endwhile","printf","sprintf","disp","until","continue","pkg"]);function tokenTranspose(e,n){return e.sol()||"'"!==e.peek()?(n.tokenize=tokenBase,tokenBase(e,n)):(e.next(),n.tokenize=tokenBase,"operator")}function tokenComment(e,n){return e.match(/^.*%}/)?(n.tokenize=tokenBase,"comment"):(e.skipToEnd(),"comment")}function tokenBase(e,n){if(e.eatSpace())return null;if(e.match("%{"))return n.tokenize=tokenComment,e.skipToEnd(),"comment";if(e.match(/^[%#]/))return e.skipToEnd(),"comment";if(e.match(/^[0-9\.+-]/,!1)){if(e.match(/^[+-]?0x[0-9a-fA-F]+[ij]?/))return e.tokenize=tokenBase,"number";if(e.match(/^[+-]?\d*\.\d+([EeDd][+-]?\d+)?[ij]?/))return "number";if(e.match(/^[+-]?\d+([EeDd][+-]?\d+)?[ij]?/))return "number"}if(e.match(wordRegexp(["nan","NaN","inf","Inf"])))return "number";var t=e.match(/^"(?:[^"]|"")*("|$)/)||e.match(/^'(?:[^']|'')*('|$)/);return t?t[1]?"string":"error":e.match(keywords)?"keyword":e.match(builtins)?"builtin":e.match(identifiers)?"variable":e.match(singleOperators)||e.match(doubleOperators)?"operator":e.match(singleDelimiters)||e.match(doubleDelimiters)||e.match(tripleDelimiters)?null:e.match(expressionEnd)?(n.tokenize=tokenTranspose,null):(e.next(),"error")}const octave={startState:function(){return {tokenize:tokenBase}},token:function(e,n){var t=n.tokenize(e,n);return "number"!==t&&"variable"!==t||(n.tokenize=tokenTranspose),t},languageData:{commentTokens:{line:"%"}}};

export { octave };
