function c(n){for(var t={},e=n.split(","),r=0;r<e.length;++r){var i=e[r].toUpperCase(),a=e[r].charAt(0).toUpperCase()+e[r].slice(1);t[e[r]]=!0,t[i]=!0,t[a]=!0}return t}function f(n){return n.eatWhile(/[\w\$_]/),"meta"}var g=c("null"),p={"`":f,$:f},d=!1,b=c("abs,access,after,alias,all,and,architecture,array,assert,attribute,begin,block,body,buffer,bus,case,component,configuration,constant,disconnect,downto,else,elsif,end,end block,end case,end component,end for,end generate,end if,end loop,end process,end record,end units,entity,exit,file,for,function,generate,generic,generic map,group,guarded,if,impure,in,inertial,inout,is,label,library,linkage,literal,loop,map,mod,nand,new,next,nor,null,of,on,open,or,others,out,package,package body,port,port map,postponed,procedure,process,pure,range,record,register,reject,rem,report,return,rol,ror,select,severity,signal,sla,sll,sra,srl,subtype,then,to,transport,type,unaffected,units,until,use,variable,wait,when,while,with,xnor,xor"),h=c("architecture,entity,begin,case,port,else,elsif,end,for,function,if"),m=/[&|~><!\)\(*#%@+\/=?\:;}{,\.\^\-\[\]]/,o;function l(n,t){var e=n.next();if(p[e]){var r=p[e](n,t);if(r!==!1)return r}if(e=='"')return t.tokenize=v(e),t.tokenize(n,t);if(e=="'")return t.tokenize=k(e),t.tokenize(n,t);if(/[\[\]{}\(\),;\:\.]/.test(e))return o=e,null;if(/[\d']/.test(e))return n.eatWhile(/[\w\.']/),"number";if(e=="-"&&n.eat("-"))return n.skipToEnd(),"comment";if(m.test(e))return n.eatWhile(m),"operator";n.eatWhile(/[\w\$_]/);var i=n.current();return b.propertyIsEnumerable(i.toLowerCase())?(h.propertyIsEnumerable(i)&&(o="newstatement"),"keyword"):g.propertyIsEnumerable(i)?"atom":"variable"}function k(n){return function(t,e){for(var r=!1,i,a=!1;(i=t.next())!=null;){if(i==n&&!r){a=!0;break}r=!r&&i=="--"}return(a||!(r||d))&&(e.tokenize=l),"string"}}function v(n){return function(t,e){for(var r=!1,i,a=!1;(i=t.next())!=null;){if(i==n&&!r){a=!0;break}r=!r&&i=="--"}return(a||!(r||d))&&(e.tokenize=l),"string.special"}}function y(n,t,e,r,i){this.indented=n,this.column=t,this.type=e,this.align=r,this.prev=i}function s(n,t,e){return n.context=new y(n.indented,t,e,null,n.context)}function u(n){var t=n.context.type;return(t==")"||t=="]"||t=="}")&&(n.indented=n.context.indented),n.context=n.context.prev}const x={name:"vhdl",startState:function(n){return{tokenize:null,context:new y(-n,0,"top",!1),indented:0,startOfLine:!0}},token:function(n,t){var e=t.context;if(n.sol()&&(e.align??(e.align=!1),t.indented=n.indentation(),t.startOfLine=!0),n.eatSpace())return null;o=null;var r=(t.tokenize||l)(n,t);if(r=="comment"||r=="meta")return r;if(e.align??(e.align=!0),(o==";"||o==":")&&e.type=="statement")u(t);else if(o=="{")s(t,n.column(),"}");else if(o=="[")s(t,n.column(),"]");else if(o=="(")s(t,n.column(),")");else if(o=="}"){for(;e.type=="statement";)e=u(t);for(e.type=="}"&&(e=u(t));e.type=="statement";)e=u(t)}else o==e.type?u(t):(e.type=="}"||e.type=="top"||e.type=="statement"&&o=="newstatement")&&s(t,n.column(),"statement");return t.startOfLine=!1,r},indent:function(n,t,e){if(n.tokenize!=l&&n.tokenize!=null)return 0;var r=t&&t.charAt(0),i=n.context,a=r==i.type;return i.type=="statement"?i.indented+(r=="{"?0:e.unit):i.align?i.column+(a?0:1):i.indented+(a?0:e.unit)},languageData:{indentOnInput:/^\s*[{}]$/,commentTokens:{line:"--"}}};export{x as t};
