物管理前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
2.3 KiB

  1. function a(e){return new RegExp("^(("+e.join(")|(")+"))\\b")}var o=new RegExp("^[\\+\\-\\*/&|\\^~<>!@'\\\\]"),c=new RegExp("^[\\(\\[\\{\\},:=;\\.]"),m=new RegExp("^((==)|(~=)|(<=)|(>=)|(<<)|(>>)|(\\.[\\+\\-\\*/\\^\\\\]))"),s=new RegExp("^((!=)|(\\+=)|(\\-=)|(\\*=)|(/=)|(&=)|(\\|=)|(\\^=))"),l=new RegExp("^((>>=)|(<<=))"),u=new RegExp("^[\\]\\)]"),f=new RegExp("^[_A-Za-z¡-￿][_A-Za-z0-9¡-￿]*"),p=a(["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"]),d=a(["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 i(e,n){return!e.sol()&&e.peek()==="'"?(e.next(),n.tokenize=r,"operator"):(n.tokenize=r,r(e,n))}function h(e,n){return e.match(/^.*%}/)?(n.tokenize=r,"comment"):(e.skipToEnd(),"comment")}function r(e,n){if(e.eatSpace())return null;if(e.match("%{"))return n.tokenize=h,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=r,"number";if(e.match(/^[+-]?\d*\.\d+([EeDd][+-]?\d+)?[ij]?/)||e.match(/^[+-]?\d+([EeDd][+-]?\d+)?[ij]?/))return"number"}if(e.match(a(["nan","NaN","inf","Inf"])))return"number";var t=e.match(/^"(?:[^"]|"")*("|$)/)||e.match(/^'(?:[^']|'')*('|$)/);return t?t[1]?"string":"error":e.match(d)?"keyword":e.match(p)?"builtin":e.match(f)?"variable":e.match(o)||e.match(m)?"operator":e.match(c)||e.match(s)||e.match(l)?null:e.match(u)?(n.tokenize=i,null):(e.next(),"error")}const g={name:"octave",startState:function(){return{tokenize:r}},token:function(e,n){var t=n.tokenize(e,n);return(t==="number"||t==="variable")&&(n.tokenize=i),t},languageData:{commentTokens:{line:"%"}}};export{g as octave};