'use strict';(function(h){"object"==typeof exports&&"object"==typeof module?h(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],h):h(CodeMirror)})(function(h){function q(a,c,e){return"tlv-"+a.tlvIndentationStyle[c/3]+"-"+e}h.defineMode("verilog",function(a,c){function e(b){var g={};b=b.split(" ");for(var d=0;d<b.length;++d)g[b[d]]=!0;return g}function f(b,g){var d=b.peek(),a;if(m[d]&&0!=(a=m[d](b,g))||m.tokenBase&&0!=(a=m.tokenBase(b,g)))return a;
if(/[,;:\.]/.test(d))return l=b.next(),null;if(C.test(d))return l=b.next(),"bracket";if("`"==d)return b.next(),b.eatWhile(/[\w\$_]/)?"def":null;if("$"==d)return b.next(),b.eatWhile(/[\w\$_]/)?"meta":null;if("#"==d)return b.next(),b.eatWhile(/[\d_.]/),"def";if('"'==d)return b.next(),g.tokenize=E(d),g.tokenize(b,g);if("/"==d){b.next();if(b.eat("*"))return g.tokenize=p,p(b,g);if(b.eat("/"))return b.skipToEnd(),"comment";b.backUp(1)}if(b.match(D)||b.match(F)||b.match(G)||b.match(H)||b.match(I)||b.match(J)||
b.match(D))return"number";if(b.eatWhile(B))return"meta";if(b.eatWhile(/[\w\$_]/))return b=b.current(),A[b]?(k[b]&&(l="newblock"),K[b]&&(l="newstatement"),r=b,"keyword"):"variable";b.next();return null}function E(b){return function(g,d){for(var a=!1,c,e=!1;null!=(c=g.next());){if(c==b&&!a){e=!0;break}a=!a&&"\\"==c}if(e||!a&&!z)d.tokenize=f;return"string"}}function p(b,a){for(var d=!1,g;g=b.next();){if("/"==g&&d){a.tokenize=f;break}d="*"==g}return"comment"}function q(b,a,d,c,e){this.indented=b;this.column=
a;this.type=d;this.align=c;this.prev=e}function n(b,a,d){a=new q(b.indented,a,d,null,b.context);return b.context=a}function t(b){var a=b.context.type;if(")"==a||"]"==a||"}"==a)b.indented=b.context.indented;return b.context=b.context.prev}function u(b,a){if(b==a)return!0;a=a.split(";");for(var d in a)if(b==a[d])return!0;return!1}var v=a.indentUnit,w=c.statementIndentUnit||v,y=c.dontAlignCalls;a=c.noIndentKeywords||[];var z=c.multiLineStrings,m=c.hooks||{},A=e("accept_on alias always always_comb always_ff always_latch and assert assign assume automatic before begin bind bins binsof bit break buf bufif0 bufif1 byte case casex casez cell chandle checker class clocking cmos config const constraint context continue cover covergroup coverpoint cross deassign default defparam design disable dist do edge else end endcase endchecker endclass endclocking endconfig endfunction endgenerate endgroup endinterface endmodule endpackage endprimitive endprogram endproperty endspecify endsequence endtable endtask enum event eventually expect export extends extern final first_match for force foreach forever fork forkjoin function generate genvar global highz0 highz1 if iff ifnone ignore_bins illegal_bins implements implies import incdir include initial inout input inside instance int integer interconnect interface intersect join join_any join_none large let liblist library local localparam logic longint macromodule matches medium modport module nand negedge nettype new nexttime nmos nor noshowcancelled not notif0 notif1 null or output package packed parameter pmos posedge primitive priority program property protected pull0 pull1 pulldown pullup pulsestyle_ondetect pulsestyle_onevent pure rand randc randcase randsequence rcmos real realtime ref reg reject_on release repeat restrict return rnmos rpmos rtran rtranif0 rtranif1 s_always s_eventually s_nexttime s_until s_until_with scalared sequence shortint shortreal showcancelled signed small soft solve specify specparam static string strong strong0 strong1 struct super supply0 supply1 sync_accept_on sync_reject_on table tagged task this throughout time timeprecision timeunit tran tranif0 tranif1 tri tri0 tri1 triand trior trireg type typedef union unique unique0 unsigned until until_with untyped use uwire var vectored virtual void wait wait_order wand weak weak0 weak1 while wildcard wire with within wor xnor xor"),
B=/[\+\-\*\/!~&|^%=?:]/,C=/[\[\]{}()]/,J=/\d[0-9_]*/,F=/\d*\s*'s?d\s*\d[0-9_]*/i,G=/\d*\s*'s?b\s*[xz01][xz01_]*/i,H=/\d*\s*'s?o\s*[xz0-7][xz0-7_]*/i,I=/\d*\s*'s?h\s*[0-9a-fxz?][0-9a-fxz?_]*/i,D=/(\d[\d_]*(\.\d[\d_]*)?E-?[\d_]+)|(\d[\d_]*\.\d[\d_]*)/i,M=/^((\w+)|[)}\]])/,N=/[)}\]]/,l,r;c=e("case checker class clocking config function generate interface module package primitive program property specify sequence table task");var k={};for(x in c)k[x]="end"+x;k.begin="end";k.casex="endcase";k.casez="endcase";
k["do"]="while";k.fork="join;join_any;join_none";k.covergroup="endgroup";for(var O in a){var x=a[O];k[x]&&(k[x]=void 0)}var K=e("always always_comb always_ff always_latch assert assign assume else export for foreach forever if import initial repeat while");return{electricInput:function(){var b=[],a;for(a in k)if(k[a]){var d=k[a].split(";"),c;for(c in d)b.push(d[c])}return new RegExp("[{}()\\[\\]]|("+b.join("|")+")$")}(),startState:function(b){b={tokenize:null,context:new q((b||0)-v,0,"top",!1),indented:0,
startOfLine:!0};m.startState&&m.startState(b);return b},token:function(b,a){var d=a.context;b.sol()&&(null==d.align&&(d.align=!1),a.indented=b.indentation(),a.startOfLine=!0);if(m.token){var c=m.token(b,a);if(void 0!==c)return c}if(b.eatSpace())return null;r=l=null;c=(a.tokenize||f)(b,a);if("comment"==c||"meta"==c||"variable"==c)return c;null==d.align&&(d.align=!0);if(l==d.type)t(a);else if(";"==l&&"statement"==d.type||d.type&&u(r,d.type))for(d=t(a);d&&"statement"==d.type;)d=t(a);else"{"==l?n(a,b.column(),
"}"):"["==l?n(a,b.column(),"]"):"("==l?n(a,b.column(),")"):d&&"endcase"==d.type&&":"==l?n(a,b.column(),"statement"):"newstatement"==l?n(a,b.column(),"statement"):"newblock"!=l||"function"==r&&d&&("statement"==d.type||"endgroup"==d.type)||"task"==r&&d&&"statement"==d.type||(d=k[r],n(a,b.column(),d));a.startOfLine=!1;return c},indent:function(a,c){if(a.tokenize!=f&&null!=a.tokenize)return h.Pass;if(m.indent){var b=m.indent(a);if(0<=b)return b}a=a.context;b=c&&c.charAt(0);"statement"==a.type&&"}"==b&&
(a=a.prev);var e=!1;(c=c.match(M))&&(e=u(c[0],a.type));return"statement"==a.type?a.indented+("{"==b?0:w):N.test(a.type)&&a.align&&!y?a.column+(e?0:1):")"!=a.type||e?a.indented+(e?0:v):a.indented+w},blockCommentStart:"/*",blockCommentEnd:"*/",lineComment:"//"}});h.defineMIME("text/x-verilog",{name:"verilog"});h.defineMIME("text/x-systemverilog",{name:"verilog"});var w={"|":"link",">":"property",$:"variable",$$:"variable","?$":"qualifier","?*":"qualifier","-":"hr","/":"property","/-":"property","@":"variable-3",
"@-":"variable-3","@++":"variable-3","@+=":"variable-3","@+=-":"variable-3","@--":"variable-3","@-=":"variable-3","%+":"tag","%-":"tag","%":"tag",">>":"tag","<<":"tag","<>":"tag","#":"tag","^":"attribute","^^":"attribute","^!":"attribute","*":"variable-2","**":"variable-2","\\":"keyword",'"':"comment"},z={"/":"beh-hier",">":"beh-hier","-":"phys-hier","|":"pipe","?":"when","@":"stage","\\":"keyword"},y=/^([~!@#\$%\^&\*-\+=\?\/\\\|'"<>]+)([\d\w_]*)/,A=/^[! ]  /,B=/^[! ] */,C=/^\/[\/\*]/;h.defineMIME("text/x-tlv",
{name:"verilog",hooks:{electricInput:!1,token:function(a,c){var e=void 0,f;if(a.sol()&&!c.tlvInBlockComment){"\\"==a.peek()&&(e="def",a.skipToEnd(),a.string.match(/\\SV/)?c.tlvCodeActive=!1:a.string.match(/\\TLV/)&&(c.tlvCodeActive=!0));c.tlvCodeActive&&0==a.pos&&0==c.indented&&(f=a.match(B,!1))&&(c.indented=f[0].length);var h=c.indented,p=h/3;if(p<=c.tlvIndentationStyle.length){var L=a.string.length==h,n=3*p;if(n<a.string.length){var t=a.string.slice(n),u=t[0];z[u]&&(f=t.match(y))&&w[f[1]]&&(h+=
3,"\\"==u&&0<n||(c.tlvIndentationStyle[p]=z[u],p++))}if(!L)for(;c.tlvIndentationStyle.length>p;)c.tlvIndentationStyle.pop()}c.tlvNextIndent=h}if(c.tlvCodeActive)if(void 0!==e)e+=" "+q(c,0,"scope-ident");else if(a.pos/3<c.tlvIndentationStyle.length&&(f=a.match(a.sol()?A:/^   /))){e="tlv-indent-"+(0==a.pos%2?"even":"odd")+" "+q(c,a.pos-3,"indent");"!"==f[0].charAt(0)&&(e+=" tlv-alert-line-prefix");var v;(v=a.match(y,!1))&&0<v[2].length&&(e+=" "+q(c,a.pos,"before-scope-ident"))}else c.tlvInBlockComment?
(a.match(/^.*?\*\//)?c.tlvInBlockComment=!1:a.skipToEnd(),e="comment"):(f=a.match(C))&&!c.tlvInBlockComment?("//"==f[0]?a.skipToEnd():c.tlvInBlockComment=!0,e="comment"):(f=a.match(y))?(e=f[1],f=f[2],w.hasOwnProperty(e)&&(0<f.length||a.eol())?(e=w[e],a.column()==c.indented&&(e+=" "+q(c,a.column(),"scope-ident"))):(a.backUp(a.current().length-1),e="tlv-default")):a.match(/^\t+/)?e="tlv-tab":a.match(/^[\[\]{}\(\);:]+/)?e="meta":(f=a.match(/^[mM]4([\+_])?[\w\d_]*/))?e="+"==f[1]?"tlv-m4-plus":"tlv-m4":
a.match(/^ +/)?e=a.eol()?"error":"tlv-default":a.match(/^[\w\d_]+/)?e="number":(a.next(),e="tlv-default");else a.match(/^[mM]4([\w\d_]*)/)&&(e="tlv-m4");return e},indent:function(a){return 1==a.tlvCodeActive?a.tlvNextIndent:-1},startState:function(a){a.tlvIndentationStyle=[];a.tlvCodeActive=!0;a.tlvNextIndent=-1;a.tlvInBlockComment=!1}}})});
