diff --git a/build/codemirror_grammar.js b/build/codemirror_grammar.js
index 845c049..0e5c916 100644
--- a/build/codemirror_grammar.js
+++ b/build/codemirror_grammar.js
@@ -3010,47 +3010,65 @@ function get_mode( grammar, DEFAULT )
cm_mode.autocomplete = function( cm, options ) {
var keywords = parser.Keywords, list, Pos = _CodeMirror.Pos,
cur = cm.getCursor(), curLine, start = cur.ch, end = start,
- token, len, maxlen = 0, word_re, renderer;
+ token, token_i, word, len, maxword = 0, maxtype = 0, word_re, renderer,
+ i, l, w, wm, wl, pos, pos_i, case_insensitive_match, prefix_match, m1, m2;
list = [];
if ( keywords && keywords.length )
{
options = options || {};
word_re = options.word || W;
+ case_insensitive_match = options[HAS]('caseInsensitiveMatch') ? !!options.caseInsensitiveMatch : true;
+ prefix_match = !!options.prefixMatch;
curLine = cm.getLine(cur.line);
while (end < curLine.length && word_re.test(curLine.charAt(end))) ++end;
while (start && word_re.test(curLine.charAt(start - 1))) --start;
if ( start < end )
{
- token = curLine.slice(start, end); len = token.length;
renderer = options.renderer || function(elt, data, cmpl) {
- var kword = cmpl.text, type = cmpl.meta,
- tab = new Array(data.list.maxlen-kword.length+3).join(" "),
- p1 = cmpl.pos, p2 = p1 + cmpl.match.length;
+ var word = cmpl.text, type = cmpl.meta,
+ tabsize = data.list.maxlen-word.length-type.length+1+2,
+ tab = new Array(tabsize).join(" "),
+ p1 = cmpl.start, p2 = cmpl.end;
elt.innerHTML = [
- kword.slice(0,p1),
- '', kword.slice(p1,p2), '',
- kword.slice(p2),
+ '', word.slice(0,p1),
+ '', word.slice(p1,p2), '',
+ word.slice(p2), '',
tab,
- '', type, ''
+ '', type, ''
].join('');
};
- keywords.reduce(function(list, word) {
- var w = word.word, wm = word.meta, wl = w.length, pos;
- if ( (wl >= len) && ((pos = w.indexOf(token)) >= 0) )
+ token = curLine.slice(start, end); token_i = token.toLowerCase(); len = token.length;
+ for (i=0,l=keywords.length; i maxlen ) maxlen = wl;
- list.push({
- text: w, name: w, meta: wm,
- pos: pos, match: token,
- score: 1000 - wl - 10*pos,
- displayText: w + "\t\t["+wm+"]",
- render: renderer
- });
+ m1 = w.toLowerCase();
+ m2 = token_i;
}
- return list;
- }, list);
+ else
+ {
+ m1 = w;
+ m2 = token;
+ }
+ if ( ((pos_i = m1.indexOf( m2 )) < 0) || (prefix_match && (pos_i > 0)) ) continue;
+ if ( case_insensitive_match ) pos = w.indexOf( token );
+ //else pos = pos_i;
+ if ( wl > maxword ) maxword = wl;
+ if ( wm.length > maxtype ) maxtype = wm.length;
+ list.push({
+ text: w, name: w, meta: wm,
+ start: pos<0?pos_i:pos, end: (pos<0?pos_i:pos) + token.length, match: token,
+ displayText: w + "\t\t["+wm+"]",
+ render: renderer,
+ // longer matches or matches not at start have lower match score
+ score: 1000 - 10*(wl-len) - 2*(pos<0?pos_i+10:pos)
+ });
+ }
if ( list.length ) list = list.sort( by_score );
- list.maxlen = maxlen;
+ list.maxlen = maxword + maxtype;
}
}
return {
diff --git a/build/codemirror_grammar.min.js b/build/codemirror_grammar.min.js
index 7ec3e87..6ecb8bc 100644
--- a/build/codemirror_grammar.min.js
+++ b/build/codemirror_grammar.min.js
@@ -6,4 +6,4 @@
* Transform a grammar specification in JSON format, into a syntax-highlight parser mode for CodeMirror
* https://github.com/foo123/codemirror-grammar
*
-**/!function(t,e,n){"use strict";var r,o="object"==typeof module&&module.exports,s="function"==typeof define&&define.amd;o?module.exports=(module.$deps=module.$deps||{})[e]=module.$deps[e]||n.call(t,{NODE:module})||1:s&&"function"==typeof require&&"function"==typeof require.specified&&require.specified(e)?define(e,["require","exports","module"],function(e,r,o){return n.call(t,{AMD:o})}):e in t||(t[e]=r=n.call(t,{})||1)&&s&&define(e,[],function(){return r})}(this,"CodeMirrorGrammar",function(t){"use strict";function e(t,e){var n=this,r=n.pattern,o=t.s.charAt(t.pos)||null;return o&&r===o?(!1!==e&&t.mov(1),[n.key,o]):!1}function n(t,e){var n=this,r=n.pattern,o=t.s.charAt(t.pos)||null;return o&&-10?!1:(!1!==e&&t.mov(n[o[1]||0].length),[r.key,o[1]>0?n[o[1]]:n])}function s(t,e){var n=this;return!1!==e&&t.end(),[n.key,""]}function l(t,e,n,r){var o=Re(e);if(me===o)return e;if(r[t])return r[t];n=n||0;var s,l=0;return e&&e.isCharList&&(l=1,delete e.isCharList),s=$e&o?new on(t,e,$e,n):ve===o?new on(t,e,ve,n):ye&o?new on(t,e,l?be:ye,n):(Ee|_e)&o?new on(t,e,Ee,n):e,r[t]=s}function u(t,e,n,r,o,s){if(s[t])return s[t];var i,a,c,p,f,h,m,g=0,k=0,d=1;if(i=Pe(e),c=i.length,1===c)m=l(t,Qe(i[0],n,o),0,s);else if(c>1){for(p=(c>>>1)+1,a=0;p>=a;a++)f=Re(i[a]),h=Re(i[c-1-a]),(ve!==f||ve!==h)&&(d=0),_e&f||_e&h?g=1:(Ze(i[a],n)||Ze(i[c-1-a],n))&&(k=1);if(!d||r&&ye&Re(r))if(!r||g||k)if(g||k){for(a=0;c>a;a++)i[a]=_e&Re(i[a])?u(t+"_"+a,i[a],n,r,o,s):l(t+"_"+a,Qe(i[a],n,o),a,s);m=c>1?new ln(t,i):i[0]}else{for(i=i.sort(Ge),a=0;c>a;a++)i[a]=l(t+"_"+a,Qe(i[a],n,o),a,s);m=c>1?new ln(t,i):i[0]}else m=l(t,Ye(i,r),0,s);else i=i.slice().join(""),i.isCharList=1,m=l(t,i,0,s)}return s[t]=m}function i(t,e,n,r,o){if(o[t])return o[t];var s,u,i,a,c,p,f;for(a=[],c=[],s=Le(e),u=0,i=s.length;i>u;u++)p=l(t+"_0_"+u,Qe(s[u][0],n,r),u,o),f=s[u].length>1?Ee!==p.ptype||ye!==Re(s[u][1])||Ze(s[u][1],n)?l(t+"_1_"+u,Qe(s[u][1],n,r),u,o):s[u][1]:p,a.push(p),c.push(f);return o[t]=new sn(t,[a,c])}function a(t,e,n){var r,o,s,l,u,i,a,c,p,f,h,m;if(i=new String(Ie(t)),i.pos=0,1===i.length)f=""+t,e[f]||(e[f]={type:"simple",tokens:t}),t=f;else{for(r=[],o=[],s="",h=[];i.posu[0]&&(u[0]=0),2>u.length?u.push(u[0]):u[1]=u[1].length?parseInt(u[1],10)||w:w,0>u[1]&&(u[1]=0),p=o.pop(),f=""+p+["{",u[0],",",isFinite(u[1])?u[1]:"","}"].join(""),n[f]||(n[f]={type:"group",match:[u[0],u[1]],tokens:[p]}),o.push(f)}else{if("}"===c)continue;if("["===c){for(l="";i.pos1?(f=""+o.join(" "),n[f]||(n[f]={type:"group",match:"sequence",tokens:o}),r.push(f)):o.length&&r.push(o[0]),o=[]):"("===c?(h.push([o,r,s]),o=[],r=[],s=""):")"===c&&(o.length>1?(f=""+o.join(" "),n[f]||(n[f]={type:"group",match:"sequence",tokens:o}),r.push(f)):o.length&&r.push(o[0]),o=[],r.length>1?(f=""+r.join(" | "),n[f]||(n[f]={type:"group",match:"either",tokens:r})):r.length&&(f=r[0]),r=[],m=h.pop(),o=m[0],r=m[1],s=m[2],p=f,f="("+p+")",n[f]||(n[f]=De(e[p]||n[p])),o.push(f))}}else s+=c;s.length&&(e[s]||n[s]||(e[s]={type:"simple",tokens:s}),o.push(s)),s="",o.length>1?(f=""+o.join(" "),n[f]||(n[f]={type:"group",match:"sequence",tokens:o}),r.push(f)):o.length&&r.push(o[0]),o=[],r.length>1?(f=""+r.join(" | "),n[f]||(n[f]={type:"group",match:"either",tokens:r}),t=f):r.length&&(t=r[0]),r=[]}return t}function c(t,e){var n,r,o;for(r in t)t[ce](r)&&(n=r.split(":"),o=n[1]&&Ie(n[1]).length?Ie(n[1]):null,n=n[0],n!==r&&(t[n]=t[r],delete t[r],o&&(xe===Re(t[n])?t[n].type||(t[n].type=o):t[n]={type:o,tokens:t[n]})));for(r in e)e[ce](r)&&(n=r.split(":"),o=n[1]&&Ie(n[1]).length?Ie(n[1]):null,n=n[0],n!==r&&(e[n]=e[r],delete e[r],o&&(xe===Re(e[n])?e[n].type||(e[n].type=o):e[n]={type:o,tokens:e[n]})))}function p(t,e,n,r,o,s,l,c,m,g,k){var d,y,v,b,_,x,C,E,P,L,D,N,z,H,J,oe,ie,ae=null;if(ie=null,B===t)return new un(B,B,t,ie);if(F===t)return new un(F,F,t,ie);if(V===t||null===t)return new un(V,V,t,ie);if(""===t)return new un(G,"NONSPACE",t,ie);if(!1===t||0===t)return new un(I,"EMPTY",t,ie);if(_e&Re(t)&&(oe=t,t="NGRAM_"+oe.join("_"),r[t]||(r[t]={type:"ngram",tokens:oe})),t=""+t,c[t])return c[t];for(n[t]?(d=n[t],Ae&Re(d)&&(d=n[t]={type:"simple",tokens:d})):d=r[t]?r[t]:t,ye&Re(d)&&(d=a(d,n,r),d=n[d]||r[d]);d.extend;)H=d.extend,J=n[H]||r[H],delete d.extend,J&&(Ae&Re(J)&&(J={type:"simple",tokens:J}),d=Be(J,d));if("undefined"==typeof d.type&&(d[ce]("error")?(d.type="action",d.action=["error",d.error,!!d["in-context"]],delete d.error):d[ce]("context-start")?(d.type="action",d.action=["context-start",d["context-start"],!!d["in-context"]],delete d["context-start"]):d[ce]("context-end")?(d.type="action",d.action=["context-end",d["context-end"],!!d["in-context"]],delete d["context-end"]):d[ce]("empty")?(d.type="action",d.action=["empty",d.empty,!!d["in-context"]],delete d.empty):d[ce]("indent")?(d.type="action",d.action=["indent",d.indent,!!d["in-context"]],delete d.indent):d[ce]("outdent")?(d.type="action",d.action=["outdent",d.outdent,!!d["in-context"]],delete d.outdent):d[ce]("unique")?(d.type="action",d.action=["unique",ye&Re(d.unique)?["_DEFAULT_",d.unique]:d.unique,!!d["in-context"]],delete d.unique):d[ce]("push")?(d.type="action",d.action=["push",d.push,!!d["in-context"]],delete d.push):d[ce]("pop")?(d.type="action",d.action=["pop",d.pop,!!d["in-context"]],delete d.pop):d.sequence||d.all?(d.type="group",d.match="sequence",d.tokens=d.sequence||d.all,d.all?delete d.all:delete d.sequence):d.either?(d.type="group",d.match="either",d.tokens=d.either,delete d.either):d.zeroOrMore?(d.type="group",d.match="zeroOrMore",d.tokens=d.zeroOrMore,delete d.zeroOrMore):d.oneOrMore?(d.type="group",d.match="oneOrMore",d.tokens=d.oneOrMore,delete d.oneOrMore):d.zeroOrOne?(d.type="group",d.match="zeroOrOne",d.tokens=d.zeroOrOne,delete d.zeroOrOne):d.comment?(d.type="comment",d.tokens=d.comment,delete d.comment):d.block?(d.type="block",d.tokens=d.block,delete d.block):d["escaped-block"]?(d.type="escaped-block",d.tokens=d["escaped-block"],delete d["escaped-block"]):d.simple?(d.type="simple",d.tokens=d.simple,delete d.simple):d.type="simple"),y=d.type?ue[d.type.toUpperCase().replace(Ke,"")]:U,ie=d.msg||null,U&y){if(B===d.tokens)return ae=new un(B,t,t,ie),c[t]=ae,ae;if(F===d.tokens)return ae=new un(F,t,t,ie),c[t]=ae,ae;if(V===d.tokens||null===d.tokens)return ae=new un(V,t,t,ie),c[t]=ae,ae;if(""===d.tokens)return ae=new un(G,t,t,ie),c[t]=ae,ae;if(!1===d.tokens||0===d.tokens)return ae=new un(I,t,t,ie),c[t]=ae,ae}if(se&y||(d.tokens=Pe(d.tokens)),se&y)d[ce]("action")?"error"===d.action[0]?d.action[0]=$:"context-start"===d.action[0]?d.action[0]=T:"context-end"===d.action[0]?d.action[0]=M:"empty"===d.action[0]?d.action[0]=q:"indent"===d.action[0]?d.action[0]=R:"outdent"===d.action[0]?d.action[0]=j:"unique"===d.action[0]?d.action[0]=O:"push"===d.action[0]?d.action[0]=S:"pop"===d.action[0]&&(d.action[0]=A):d[ce]("error")?d.action=[$,d.error,!!d["in-context"]]:d[ce]("context-start")?d.action=[T,d["context-start"],!!d["in-context"]]:d[ce]("context-end")?d.action=[M,d["context-end"],!!d["in-context"]]:d[ce]("empty")?d.action=[q,d.empty,!!d["in-context"]]:d[ce]("indent")?d.action=[R,d.indent,!!d["in-context"]]:d[ce]("outdent")?d.action=[j,d.outdent,!!d["in-context"]]:d[ce]("unique")?d.action=[O,ye&Re(d.unique)?["_DEFAULT_",d.unique]:d.unique,!!d["in-context"]]:d[ce]("push")?d.action=[S,d.push,!!d["in-context"]]:d[ce]("pop")&&(d.action=[A,d.pop,!!d["in-context"]]),b=d.action.slice(),ae=new an(se,t,b,ie),c[t]=ae;else if(U&y)d.autocomplete&&h(d,t,k),v="undefined"==typeof d.combine?"\\b":d.combine,ae=new un(U,t,u(t,d.tokens.slice(),e,v,s,l),ie),c[t]=ae;else if(K&y)Z&y&&f(d,g),ae=new cn(y,t,i(t,d.tokens.slice(),e,s,l),ie,d.multiline,d.escape,o[t+".inside"]?1:0),c[t]=ae,d.interleave&&m.push(ae.clone());else if(ne&y){for(x=d.tokens.slice(),_e&Re(d.match)?ae=new pn(W,t,null,ie,d.match[0],d.match[1]):(_=le[d.match.toUpperCase()],ae=X===_?new pn(X,t,null,ie,0,1):te===_?new pn(te,t,null,ie,0,w):ee===_?new pn(ee,t,null,ie,1,w):Q&_?new pn(Q,t,null,ie):new pn(Y,t,null,ie)),c[t]=ae,C=[],L=0,D=x.length;D>L;L++)C=C.concat(p(x[L],e,n,r,o,s,l,c,m,g,k));ae.set(C)}else if(re&y){for(ae=Le(d.tokens.slice()).slice(),E=[],L=0,D=ae.length;D>L;L++)E[L]=ae[L].slice(),ae[L]=new pn(re,t+"_NGRAM_"+L,null,ie);for(c[t]=ae,L=0,D=ae.length;D>L;L++){for(P=E[L],C=[],N=0,z=P.length;z>N;N++)C=C.concat(p(P[N],e,n,r,o,s,l,c,m,g,k));ae[L].set(C)}}return c[t]}function f(t,e){var n,r,o,s,l,u=Le(t.tokens.slice());for(s=0,l=u.length;l>s;s++)n=u[s][0],r=u[s].length>1?u[s][1]:u[s][0],o=u[s].length>2?u[s][2]:"",null===r?(e.line=e.line||[],e.line.push(n)):(e.block=e.block||[],e.block.push([n,r,o]))}function h(t,e,n){var r=[].concat(Pe(t.tokens)).map(function(t){return{word:t,meta:e}});n.autocomplete=(n.autocomplete||[]).concat(r)}function m(t){var e,n,r,o,s,l,u,i,a,f,h,m,g,k,d,y;if(t.__parsed)return t;for(h={},m={},g={},d={},y={},k=[],t=De(t),e=t.RegExpID||null,t.RegExpID=null,delete t.RegExpID,l=t.Lex||{},t.Lex=null,delete t.Lex,u=t.Syntax||{},t.Syntax=null,delete t.Syntax,s=t.Style||{},c(l,u),o=t.Parser||[],r=o.length,n=[],i=0;r>i;i++)a=o[i],f=p(a,e,l,u,s,h,m,g,k,d,y)||null,f&&(_e&Re(f)?n=n.concat(f):n.push(f));return t.Parser=n,t.cTokens=k,t.Style=s,t.Comments=d,t.Keywords=y,t.Extra=t.Extra||{},t.__parsed=1,t}function g(t,e){var n=new gn(m(t),{DEFAULT:e||k,ERROR:d}),r=function(t,e){return{startState:function(){var t=new hn;return t},copyState:function(t){var e=t.clone();return e},token:function(t,e){return n.getToken(t,e)},indent:function(r,o,s){return n.indent(r,o,s,t,e)},lineComment:n.LC,blockCommentStart:n.BCS,blockCommentEnd:n.BCE,blockCommentContinue:n.BCC,blockCommentLead:n.BCL,electricChars:n.Extra.electricChars||!1,fold:n.Extra.fold||!1}};return r.supportGrammarAnnotations=!1,r.validator=function(t){if(!r.supportGrammarAnnotations||!t||!t.length)return[];var e,o,s=[],l=n.parse(t,v);if(!l)return s;for(e in l)l.hasOwnProperty(e)&&(o=l[e],s.push({message:o[4]||"Syntax Error",severity:"error",from:CodeMirror.Pos(o[0],o[1]),to:CodeMirror.Pos(o[2],o[3])}));return s},r.autocomplete=function(t,e){var r,o,s,l,u,i,a=n.Keywords,c=mn.Pos,p=t.getCursor(),f=p.ch,h=f,m=0;if(r=[],a&&a.length){for(e=e||{},u=e.word||kn,o=t.getLine(p.line);hf&&(s=o.slice(f,h),l=s.length,i=e.renderer||function(t,e,n){var r=n.text,o=n.meta,s=new Array(e.list.maxlen-r.length+3).join(" "),l=n.pos,u=l+n.match.length;t.innerHTML=[r.slice(0,l),'',r.slice(l,u),"",r.slice(u),s,'',o,""].join("")},a.reduce(function(t,e){var n,r=e.word,o=e.meta,u=r.length;return u>=l&&(n=r.indexOf(s))>=0&&(u>m&&(m=u),t.push({text:r,name:r,meta:o,pos:n,match:s,score:1e3-u-10*n,displayText:r+" ["+o+"]",render:i})),t},r),r.length&&(r=r.sort(dn)),r.maxlen=m)}return{list:r,from:c(p.line,f),to:c(p.line,h)}},r}var k,d,y=1,v=2,b=4,_=8,x=~b,C=~_,E=b|_,w=1/0,$=4,O=8,S=16,A=32,q=64,R=128,j=256,T=512,M=1024,P=2,L=4,D=8,B=4,N=8,F=16,V=32,z=B|F,I=64,G=128,U=256,K=512,H=513,Z=514,Q=1024,Y=2048,J=Y,W=4096,X=4097,te=4098,ee=4099,ne=8192,re=16384,oe=Y|re,se=32768,le={EITHER:Q,ALL:J,SEQUENCE:Y,ZEROORONE:X,ZEROORMORE:te,ONEORMORE:ee,REPEATED:W},ue={ACTION:se,BLOCK:K,COMMENT:Z,ESCAPEDBLOCK:H,SIMPLE:U,GROUP:ne,NGRAM:re},ie=void 0,ae="prototype",ce="hasOwnProperty",pe="propertyIsEnumerable",fe=(Object.keys,Array[ae],Object[ae]),he=(Function[ae],fe.toString),me=4,ge=5,ke=6,de=8,ye=16,ve=17,be=18,_e=32,xe=64,Ce=128,Ee=256,we=512,$e=1024,Oe=2048,Se=4096,Ae=ye|_e,qe={"[object Number]":me,"[object String]":ye,"[object Array]":_e,"[object RegExp]":Ee,"[object Date]":we,"[object Function]":Ce,"[object Object]":xe},Re=function(t){if(null===t)return $e;if(!0===t||!1===t||t instanceof Boolean)return de;if(ie===t)return Oe;var e=qe[he.call(t)]||Se;return me===e||t instanceof Number?isNaN(t)?ke:isFinite(t)?me:ge:ye===e||t instanceof String?1===t.length?ve:ye:_e===e||t instanceof Array?_e:Ee===e||t instanceof RegExp?Ee:we===e||t instanceof Date?we:Ce===e||t instanceof Function?Ce:xe===e?xe:Se},je=function(){var t,e,n,r,o,s,l=arguments,u=l.length;for(t=l[0]||{},o=1;u>o;o++)if(e=l[o],xe===Re(e))for(r in e)e[ce](r)&&e[pe](r)&&(n=e[r],s=Re(n),t[r]=me&s?0+n:we&s?new Date(n):Ae&s?n.slice():n);return t},Te=Object.create,Me=function(t,e){var n,r=arguments.length,o="constructor";return 0===r?(t=Object,e={}):1===r?(e=t||{},t=Object):(t=t||Object,e=e||{}),e[ce](o)||(e[o]=function(){}),n=e[o],delete e[o],n[ae]=je(Te(t[ae]),e),n[ae][o]=n,n},Pe=function(t,e){return e||_e!==Re(t)?[t]:t},Le=function(t,e){return t=Pe(t),(e||_e!==Re(t[0]))&&(t=[t]),t},De=function(t,e){var n,r,o,s,l=Re(t),u=0;if(me===Re(e)?e>0?(u=e,e=!0):e=!1:e=!1!==e,xe===l){r={};for(o in t)t[ce](o)&&t[pe](o)&&(n=Re(t[o]),r[o]=xe===n?e?De(t[o],u>0?u-1:e):t[o]:_e===n?e?De(t[o],u>0?u-1:e):t[o].slice():we&n?new Date(t[o]):ye&n?t[o].slice():me&n?0+t[o]:t[o])}else if(_e===l)for(s=t.length,r=new Array(s),o=0;s>o;o++)n=Re(t[o]),r[o]=xe===n?e?De(t[o],u>0?u-1:e):t[o]:_e===n?e?De(t[o],u>0?u-1:e):t[o].slice():we&n?new Date(t[o]):ye&n?t[o].slice():me&n?0+t[o]:t[o];else r=we&l?new Date(t):ye&l?t.slice():me&l?0+t:t;return r},Be=function(){var t,e,n,r,o,s,l,u,i,a,c=arguments,p=c.length;if(1>p)return null;for(e=De(c[0]),n=1;p>n;n++)if(t=c[n])for(r in t)if(t[ce](r)&&t[pe](r))if(e[ce](r)&&e[pe](r)){if(i=Re(e[r]),a=Re(t[r]),xe===i&&xe===a)e[r]=Be(e[r],t[r]);else if(_e===i&&_e===a){if(l=e[r],u=t[r],s=u.length,!s)continue;if(l.length)for(o=0;s>o;o++)0>l.indexOf(u[o])&&l.push(u[o]);else e[r]=u.slice()}}else e[r]=De(t[r]);return e},Ne=/([.*+?^${}()|[\]\/\\\-])/g,Fe=function(t){return t.replace(Ne,"\\$1")},Ve=function(t,e,n){var r,o,s,l,u,i=!0===n?0:1;for(ye&Re(e)&&(e=[e,e],i=0),o=t.length,u="",r=0;o>r;)s=t.charAt(r),o>r+1&&"$"===s?(l=t.charCodeAt(r+1),36===l?(u+="$",r+=2):l>=48&&57>=l?(u+=e[i+l-48]||"",r+=2):(u+=s,r+=1)):(u+=s,r+=1);return u},ze=/^\s+|\s+$/g,Ie=String[ae].trim?function(t){return t.trim()}:function(t){return t.replace(ze,"")},Ge=function(t,e){return e.length-t.length},Ue=/\r\n|\r|\n/g,Ke=/[\-_]/g,He=/^([\[\]{}()*+?|'"]|\s)/,Ze=function(t,e){return ye&Re(e)&&ye&Re(t)&&e.length&&e.length<=t.length&&e==t.substr(0,e.length)},Qe=function(t,e,n){if(!t||me===Re(t))return t;var r,o=e?e.length||0:0;if(o&&e===t.substr(0,o)){var s,l,u,r,i,a=t.substr(o),c=a.charAt(0),p="";for(r=a.length;r--&&(i=a.charAt(r),c!==i);)"i"===i.toLowerCase()&&(p="i");return s=a.substring(1,r),l="^("+s+")",n[l]||(u=new RegExp(l,p),n[l]=u),n[l]}return t},Ye=function(t,e){var n,r="";return ye&Re(e)&&(r=e),n=t.sort(Ge).map(Fe).join("|"),[new RegExp("^("+n+")"+r),1]},Je=0,We=function(){return++Je},Xe=function(t){return[t||"uuid",++Je,(new Date).getTime()].join("_")},tn=Math.max,en=/^[\s\u00a0]+/,nn=/[^\s\u00a0]/,rn=Me({constructor:function(t){var e=this;e._=null,e.s=t?""+t:"",e.start=e.pos=0,e.lCP=e.lCV=0,e.lS=0},_:null,s:"",start:0,pos:0,lCP:0,lCV:0,lS:0,dispose:function(){var t=this;return t._=null,t.s=null,t.start=null,t.pos=null,t.lCP=null,t.lCV=null,t.lS=null,t},toString:function(){return this.s},sol:function(){return 0===this.pos},eol:function(){return this.pos>=this.s.length},end:function(){var t=this;return t.pos=t.s.length,t},mov:function(t){var e=this;return 0>t?e.pos=tn(0,e.pos-t):e.pos+=t,e},bck:function(t){var e=this;return e.pos=tn(0,t),e},sft:function(){var t=this;return t.start=t.pos,t},nxt:function(){var t,e=this,n=e.s;return e.poss;++s)l+=" "==t.charAt(s)?n-l%n:1;return l},rn._=function(t){var e=new rn;return e._=t,e.s=""+t.string,e.start=t.start,e.pos=t.pos,e.lCP=t.lastColumnPos,e.lCV=t.lastColumnValue,e.lS=t.lineStart,e};var on,sn,ln,un,an,cn,pn,fn=Me({constructor:function(t){this._=t||[]},_:null,dispose:function(){var t=this;return t._=null,t},toString:function(){return this._.slice().reverse().join("\n")},clone:function(){return new fn(this._.slice())},isEmpty:function(){return 0>=this._.length},pos:function(){return this._.length},peek:function(t){var e=this,n=e._;if(t=arguments.length?t:-1,n.length){if(0>t&&0<=n.length+t)return n[n.length+t];if(t>=0&&tn;n++)if(r=s[n].match(t,e))return u?[n,r[1]]:r;return!1}}),sn=Me(on,{constructor:function(t,e){var n=this;n.type=D,n.name=t,n.pattern=e,n.pattern[0]=new ln(n.name+"_Start",n.pattern[0],!1)},match:function(t,e){var n,r,o,s,l,u=this,i=u.pattern,a=i[0],c=i[1];return(r=a.match(t,e))?(n=c[r[0]],s=Re(n),l=a.pattern[r[0]].ptype,Ee===l&&(me===s?(o=r[1][n+1],n=new on(u.name+"_End",o,o.length>1?ye:ve)):ye===s&&(o=Ve(n,r[1]),n=new on(u.name+"_End",o,o.length>1?ye:ve))),n):!1}}),un=Me({constructor:function(t,e,n,r){var o=this;o.type=t||U,o.name=e,o.token=n,o.status=0,o.msg=r||null,o.$msg=null,o.$clone=null,B===o.name?o.name="":F===o.name?o.name="":V===o.name?o.name="":N===o.name?o.name="":I===o.name?o.name="":G===o.name&&(o.name="")},name:null,type:null,token:null,status:0,msg:null,$msg:null,$clone:null,$id:null,dispose:function(){var t=this;return t.type=null,t.name=null,t.token=null,t.status=null,t.msg=null,t.$msg=null,t.$clone=null,t.$id=null,t},clone:function(){var t,e,n,r=this,o=r.$clone;if(t=new r.constructor,t.type=r.type,t.name=r.name,t.token=r.token,t.msg=r.msg,o&&o.length)for(e=0,n=o.length;n>e;e++)t[o[e]]=r[o[e]];return t},get:function(t,e){var n=this,r=n.token,o=n.type,s=n.name,l=null;if(n.$msg=n.msg||null,e.token=null,B===o){if(B&e.status&&t.sol())return!0}else if(F===o){if(t.sol())return!0}else if(V===o){if(t.spc(),t.eol())return s}else{if(I===o)return n.status=0,!0;if(G===o)n.status&b&&t.spc()&&!t.eol()&&(n.status|=_),n.status&=x;else if(l=r.match(t))return e.token={name:s,value:t.cur(),token:l[1]},s}return n.status&&n.$msg&&(n.$msg=Ve(n.$msg,s,!0)),!1},req:function(t){var e=this;return t?e.status|=b:e.status&=x,e},err:function(t,e,n,r,o){var s,l=this,u=l.name;return s=l.$msg?l.$msg:l.status&b?'Token "'+u+'" Expected':'Syntax Error: "'+u+'"',t&&t.status&v&&(t.err[e+"_"+n+"_"+r+"_"+o+"_"+u]=[e,n,r,o,s]),s},toString:function(){var t=this;return["[","Token: ",t.name,", ",t.token?t.token.toString():null,"]"].join("")}}),an=Me(un,{constructor:function(t,e,n,r){var o=this;o.type=t||se,o.name=e,o.token=n,o.status=0,o.msg=r||null,o.$msg=null,o.$clone=null},get:function(t,e){var n,r,o,s,l,u,i,a,c,p,f,h=this,m=h.token||null,g=e.queu,k=e.symb,d=e.ctx,y=e.token,b=e.err,x=!!(e.status&v);if(h.status=0,h.$msg=null,m){if(l=h.msg,n=m[0],r=m[1],c=!!m[2],u=e.line,a=t.pos,i=y&&y.value?a-y.value.length:i-1,$===n)return x&&(h.$msg=l?l:"Error",p=u+"_"+i+"_"+u+"_"+a+"_"+h.name,b[p]=[u,i,u,a,h.err()]),h.status|=_,!1;if(T===n)d.unshift({symb:{},queu:[]});else if(M===n)d.length&&d.shift();else if(q===n)c?d.length&&(d[0].queu.length=0):g.length=0;else if(O===n){if(c){if(!d.length)return!0;k=d[0].symb}if(y){if(o=r[1],s=r[0],o=me===Re(o)?y.token[o]:Ve(o,y.token,!0),k[ce](s)||(k[s]={}),k[s][ce](o))return x&&(h.$msg=l?Ve(l,o,!0):'Duplicate "'+o+'"',f=h.err(),p=k[s][o][0]+"_"+k[s][o][1]+"_"+k[s][o][2]+"_"+k[s][o][3]+"_"+h.name,b[p]=[k[s][o][0],k[s][o][1],k[s][o][2],k[s][o][3],f],p=u+"_"+i+"_"+u+"_"+a+"_"+h.name,b[p]=[u,i,u,a,f]),h.status|=_,!1;k[s][o]=[u,i,u,a]}}else if(A===n){if(c){if(!d.length)return!0;g=d[0].queu}if(r){if(y&&(r=me===Re(r)?y.token[r]:Ve(r,y.token)),!g.length||r!==g[0][0])return x&&(g.length?(h.$msg=l?Ve(l,[g[0][0],r],!0):'Tokens do not match "'+g[0][0]+'","'+r+'"',f=h.err(),p=g[0][1]+"_"+g[0][2]+"_"+g[0][3]+"_"+g[0][4]+"_"+h.name,b[p]=[g[0][1],g[0][2],g[0][3],g[0][4],f],p=u+"_"+i+"_"+u+"_"+a+"_"+h.name,b[p]=[u,i,u,a,f]):(h.$msg=l?Ve(l,["",r],!0):'Token does not match "'+r+'"',f=h.err(),p=u+"_"+i+"_"+u+"_"+a+"_"+h.name,b[p]=[u,i,u,a,f])),g.shift(),h.status|=_,!1;g.shift()}else g.shift()}else if(S===n&&r){if(c){if(!d.length)return!0;g=d[0].queu}y&&(r=me===Re(r)?y.token[r]:Ve(r,y.token)),g.unshift([r,u,i,u,a])}}return!0}}),cn=Me(un,{constructor:function(t,e,n,r,o,s,l){var u=this;u.type=t,u.name=e,u.token=n,u.status=0,u.msg=r||null,u.mline="undefined"==typeof o?1:o,u.esc=s||"\\",u.inter=l,u.$msg=null,u.$clone=["mline","esc","inter"]},inter:0,mline:0,esc:null,get:function(t,e){var n,r,o,s,l,u,i,a,c,p,f,h,m,g,k=this,d=0,y=0,v="",b=k.mline,_=k.token,C=k.name,E=k.type,w=k.inter,$=w?C+".inside":C,O=0,S=H===E,A=k.esc,q="",R="",j="",T="",M=e.stack;if(k.$msg=k.msg||null,m=e.line,g=t.pos,Z===E&&(k.status&=x),l=0,e.block&&e.block.name===C?(y=1,n=e.block.end,l=1,u=$,p=e.block.s,h=e.block.i,f=e.block.e,q=e.block._s,R=e.block._i,T=""):!e.block&&(n=_.match(t))&&(y=1,p=[m,g],h=[[m,t.pos],[m,t.pos]],f=[m,t.pos],q=t.cur(),R="",T="",j="",e.block={name:C,end:n,s:p,i:h,e:f,_s:q,_i:R,_e:j},u=C),y){if(o=M.pos(),s=$e===n.type,w){if(l&&s&&t.sol())return k.status&=x,e.current=null,e.block=null,!1;if(!l)return M.pushAt(o,k.clone(),"$id",C),u}if(d=n.match(t),r=b,c=0,d)u=s?$:C,j=t.cur().slice(T.length);else for(a=t.pos;!t.eol();){if(i=t.pos,!(S&&O||!n.match(t))){w&&t.pos>i&&i>a?(u=$,t.bck(i),c=1):(u=C,d=1),j=t.cur().slice(T.length);break}v=t.nxt(),T+=v,O=!O&&v===A}return r=b||S&&O,h[1]=[m,i],f=[m,t.pos],d||!r&&!c?e.block=null:(e.block.i=h,e.block.e=f,e.block._i+=T,e.block._e=j,e.stack.pushAt(o,k.clone(),"$id",C)),e.token={name:C,value:t.cur(),token:[q+R+T+j,R+T,q,j]},u}return k.status&&k.$msg&&(k.$msg=Ve(k.$msg,C,!0)),!1}}),pn=Me(un,{constructor:function(t,e,n,r,o,s){var l=this;l.type=t?t:W,l.name=e||null,l.token=null,l.status=0,l.msg=r||null,l.min=o||0,l.max=s||w,l.found=0,l.$msg=null,l.$clone=["min","max","found"],n&&l.set(n)},min:0,max:1,found:0,set:function(t){return t&&(this.token=Pe(t)),this},get:function(t,e){var n,r,o,s,l,u,i,a,c,p,f,h,m,g,k,d=this,y=d.type,v=d.token,E=v.length;if(d.$msg=d.msg||null,d.status&=C,h=t.pos,l=e.stack,Q===y){for(p=0,f=0,d.status|=b,u=[],n=0;E>n;n++){if(o=v[n].clone().req(1),s=o.get(t,e),o.status&b&&(p++,u.push(o.err())),!1!==s)return s;o.status&_&&(f++,t.bck(h))}return p>0?d.status|=b:d.status&=x,E===f&&p>0?d.status|=_:d.status&=C,d.status&&!d.$msg&&u.length&&(d.$msg=u.join(" | ")),!1}if(oe&y){k=y&Y?1:0,k?d.status|=b:d.status&=x,m=l.pos(),g=d.name+"_"+We(),r=0;do o=v[r].clone().req(k),s=o.get(t,e),r++;while(E>r&&!0===s&&z&o.type);if(r>=E)return o.status&_?(k?d.status|=_:d.status&=C,t.bck(h)):k&&o.status&b&&(d.status|=_),d.status&&!d.$msg&&(d.$msg=o.err()),s;if(!1!==s){if(!0!==s)for(n=E-1;n>=r;n--)l.pushAt(m+E-n-1,v[n].clone().req(1),"$id",g);return s}return o.status&_?(k?d.status|=_:d.status&=C,t.bck(h)):k&&o.status&b&&(d.status|=_),d.status&&!d.$msg&&(d.$msg=o.err()),!1}for(p=0,i=d.found,a=d.min,c=d.max,d.status&=x,m=l.pos(),g=d.name+"_"+We(),u=[],n=0;E>n;n++){if(o=v[n].clone().req(1),s=o.get(t,e),!1!==s){if(++i,c>=i)return d.found=i,l.pushAt(m,d.clone(),"$id",g),d.found=0,s;break}o.status&b&&(p++,u.push(o.err())),o.status&_&&t.bck(h)}return a>i?d.status|=b:d.status&=x,i>c||a>i&&p>0?d.status|=_:d.status&=C,d.status&&!d.$msg&&u.length&&(d.$msg=u.join(" | ")),!1}});var mn=CodeMirror||{Pass:{toString:function(){return"CodeMirror.Pass"}}};k=null,d="error";{var gn=Me({constructor:function(t,e){var n=this;n.Extra=t.Extra||{},n.LC=t.Comments.line?t.Comments.line[0]:null,n.BCS=t.Comments.block?t.Comments.block[0][0]:null,n.BCE=t.Comments.block?t.Comments.block[0][1]:null,n.BCC=n.BCL=t.Comments.block?t.Comments.block[0][2]:null,n.DEF=e.DEFAULT,n.ERR=t.Style.error||e.ERROR,n.Keywords=t.Keywords.autocomplete||null,n.Tokens=t.Parser||[],n.cTokens=t.cTokens.length?t.cTokens:null,n.Style=t.Style},Extra:null,LC:null,BCS:null,BCE:null,BCL:null,BCC:null,ERR:null,DEF:null,Keywords:null,cTokens:null,Tokens:null,Style:null,dispose:function(){var t=this;return t.Extra=null,t.LC=null,t.BCS=null,t.BCE=null,t.BCL=null,t.BCC=null,t.ERR=null,t.DEF=null,t.Keywords=null,t.cTokens=null,t.Tokens=null,t.Style=null,t},parse:function(t,e){t=t||"";var n,r,o,s,l,u,i,a,c=this,p=t.split(Ue),f=p.length;if(e=e||y,i=!!(e&v),a=!!(e&y),s=new hn(0,0,e),s.parseAll=1,a)for(r=[],n=0;f>n;n++){for(s.line=n,l=new rn(p[n]),o=[];!l.eol();)o.push(c.getToken(l,s));r.push(o)}else for(n=0;f>n;n++)for(s.line=n,l=new rn(p[n]);!l.eol();)c.getToken(l,s);return u=a&&i?{tokens:r,errors:s.err}:a?r:s.err,l.dispose(),s.dispose(),u},getToken:function(t,e){var n,r,o,s,l,u,i,a,c=this,p=c.cTokens,f=c.Tokens,h=f.length,m=!!e.parseAll,g=c.Style,k=c.DEF,d=c.ERR;if(t=m?t:rn._(t),m?0===e.line?e.status|=B:e.status&=~B:t.sol()?e.status|=B:e.status&=~B,u=e.stack,t.sol()&&!u.isEmpty()&&V===u.peek().type&&u.pop(),(u.isEmpty()||G!==u.peek().type)&&t.spc())return m?{value:t.cur(1),type:k}:t.upd()&&k;for(a=e.line;!u.isEmpty()&&!t.eol();){if(p)for(r=0;rn;n++)if(i=t.pos,s=f[n],o=s.get(t,e),!1!==o){if(!0!==o){for(o=g[o]||k;!u.isEmpty()&&se===u.peek().type;)l=u.pop(),l.get(t,e);return m?{value:t.cur(1),type:o}:t.upd()&&o}}else if(s.status&E)return u.empty("$id",s.$id),t.nxt(),o=d,s.err(e,a,i,a,t.pos),m?{value:t.cur(1),type:o}:t.upd()&&o;return t.nxt(),m?{value:t.cur(1),type:k}:t.upd()&&k},indent:function(t,e,n,r){var o=(r.indentUnit||4,mn.Pass);return o}}),kn=/[\w$]/,dn=function(t,e){return e.score-t.score};t.CodeMirrorGrammar={VERSION:"2.1.1",clone:De,extend:Be,parse:m,getMode:g}}return t.CodeMirrorGrammar});
\ No newline at end of file
+**/!function(t,e,n){"use strict";var r,o="object"==typeof module&&module.exports,s="function"==typeof define&&define.amd;o?module.exports=(module.$deps=module.$deps||{})[e]=module.$deps[e]||n.call(t,{NODE:module})||1:s&&"function"==typeof require&&"function"==typeof require.specified&&require.specified(e)?define(e,["require","exports","module"],function(e,r,o){return n.call(t,{AMD:o})}):e in t||(t[e]=r=n.call(t,{})||1)&&s&&define(e,[],function(){return r})}(this,"CodeMirrorGrammar",function(t){"use strict";function e(t,e){var n=this,r=n.pattern,o=t.s.charAt(t.pos)||null;return o&&r===o?(!1!==e&&t.mov(1),[n.key,o]):!1}function n(t,e){var n=this,r=n.pattern,o=t.s.charAt(t.pos)||null;return o&&-10?!1:(!1!==e&&t.mov(n[o[1]||0].length),[r.key,o[1]>0?n[o[1]]:n])}function s(t,e){var n=this;return!1!==e&&t.end(),[n.key,""]}function l(t,e,n,r){var o=Re(e);if(me===o)return e;if(r[t])return r[t];n=n||0;var s,l=0;return e&&e.isCharList&&(l=1,delete e.isCharList),s=$e&o?new on(t,e,$e,n):ve===o?new on(t,e,ve,n):ye&o?new on(t,e,l?be:ye,n):(we|xe)&o?new on(t,e,we,n):e,r[t]=s}function u(t,e,n,r,o,s){if(s[t])return s[t];var i,a,c,p,f,h,m,g=0,k=0,d=1;if(i=Le(e),c=i.length,1===c)m=l(t,Qe(i[0],n,o),0,s);else if(c>1){for(p=(c>>>1)+1,a=0;p>=a;a++)f=Re(i[a]),h=Re(i[c-1-a]),(ve!==f||ve!==h)&&(d=0),xe&f||xe&h?g=1:(Ze(i[a],n)||Ze(i[c-1-a],n))&&(k=1);if(!d||r&&ye&Re(r))if(!r||g||k)if(g||k){for(a=0;c>a;a++)i[a]=xe&Re(i[a])?u(t+"_"+a,i[a],n,r,o,s):l(t+"_"+a,Qe(i[a],n,o),a,s);m=c>1?new ln(t,i):i[0]}else{for(i=i.sort(Ge),a=0;c>a;a++)i[a]=l(t+"_"+a,Qe(i[a],n,o),a,s);m=c>1?new ln(t,i):i[0]}else m=l(t,Ye(i,r),0,s);else i=i.slice().join(""),i.isCharList=1,m=l(t,i,0,s)}return s[t]=m}function i(t,e,n,r,o){if(o[t])return o[t];var s,u,i,a,c,p,f;for(a=[],c=[],s=Pe(e),u=0,i=s.length;i>u;u++)p=l(t+"_0_"+u,Qe(s[u][0],n,r),u,o),f=s[u].length>1?we!==p.ptype||ye!==Re(s[u][1])||Ze(s[u][1],n)?l(t+"_1_"+u,Qe(s[u][1],n,r),u,o):s[u][1]:p,a.push(p),c.push(f);return o[t]=new sn(t,[a,c])}function a(t,e,n){var r,o,s,l,u,i,a,c,p,f,h,m;if(i=new String(ze(t)),i.pos=0,1===i.length)f=""+t,e[f]||(e[f]={type:"simple",tokens:t}),t=f;else{for(r=[],o=[],s="",h=[];i.posu[0]&&(u[0]=0),2>u.length?u.push(u[0]):u[1]=u[1].length?parseInt(u[1],10)||E:E,0>u[1]&&(u[1]=0),p=o.pop(),f=""+p+["{",u[0],",",isFinite(u[1])?u[1]:"","}"].join(""),n[f]||(n[f]={type:"group",match:[u[0],u[1]],tokens:[p]}),o.push(f)}else{if("}"===c)continue;if("["===c){for(l="";i.pos1?(f=""+o.join(" "),n[f]||(n[f]={type:"group",match:"sequence",tokens:o}),r.push(f)):o.length&&r.push(o[0]),o=[]):"("===c?(h.push([o,r,s]),o=[],r=[],s=""):")"===c&&(o.length>1?(f=""+o.join(" "),n[f]||(n[f]={type:"group",match:"sequence",tokens:o}),r.push(f)):o.length&&r.push(o[0]),o=[],r.length>1?(f=""+r.join(" | "),n[f]||(n[f]={type:"group",match:"either",tokens:r})):r.length&&(f=r[0]),r=[],m=h.pop(),o=m[0],r=m[1],s=m[2],p=f,f="("+p+")",n[f]||(n[f]=De(e[p]||n[p])),o.push(f))}}else s+=c;s.length&&(e[s]||n[s]||(e[s]={type:"simple",tokens:s}),o.push(s)),s="",o.length>1?(f=""+o.join(" "),n[f]||(n[f]={type:"group",match:"sequence",tokens:o}),r.push(f)):o.length&&r.push(o[0]),o=[],r.length>1?(f=""+r.join(" | "),n[f]||(n[f]={type:"group",match:"either",tokens:r}),t=f):r.length&&(t=r[0]),r=[]}return t}function c(t,e){var n,r,o;for(r in t)t[ce](r)&&(n=r.split(":"),o=n[1]&&ze(n[1]).length?ze(n[1]):null,n=n[0],n!==r&&(t[n]=t[r],delete t[r],o&&(_e===Re(t[n])?t[n].type||(t[n].type=o):t[n]={type:o,tokens:t[n]})));for(r in e)e[ce](r)&&(n=r.split(":"),o=n[1]&&ze(n[1]).length?ze(n[1]):null,n=n[0],n!==r&&(e[n]=e[r],delete e[r],o&&(_e===Re(e[n])?e[n].type||(e[n].type=o):e[n]={type:o,tokens:e[n]})))}function p(t,e,n,r,o,s,l,c,m,g,k){var d,y,v,b,x,_,C,w,L,P,D,N,V,H,J,oe,ie,ae=null;if(ie=null,B===t)return new un(B,B,t,ie);if(F===t)return new un(F,F,t,ie);if(I===t||null===t)return new un(I,I,t,ie);if(""===t)return new un(G,"NONSPACE",t,ie);if(!1===t||0===t)return new un(z,"EMPTY",t,ie);if(xe&Re(t)&&(oe=t,t="NGRAM_"+oe.join("_"),r[t]||(r[t]={type:"ngram",tokens:oe})),t=""+t,c[t])return c[t];for(n[t]?(d=n[t],Ae&Re(d)&&(d=n[t]={type:"simple",tokens:d})):d=r[t]?r[t]:t,ye&Re(d)&&(d=a(d,n,r),d=n[d]||r[d]);d.extend;)H=d.extend,J=n[H]||r[H],delete d.extend,J&&(Ae&Re(J)&&(J={type:"simple",tokens:J}),d=Be(J,d));if("undefined"==typeof d.type&&(d[ce]("error")?(d.type="action",d.action=["error",d.error,!!d["in-context"]],delete d.error):d[ce]("context-start")?(d.type="action",d.action=["context-start",d["context-start"],!!d["in-context"]],delete d["context-start"]):d[ce]("context-end")?(d.type="action",d.action=["context-end",d["context-end"],!!d["in-context"]],delete d["context-end"]):d[ce]("empty")?(d.type="action",d.action=["empty",d.empty,!!d["in-context"]],delete d.empty):d[ce]("indent")?(d.type="action",d.action=["indent",d.indent,!!d["in-context"]],delete d.indent):d[ce]("outdent")?(d.type="action",d.action=["outdent",d.outdent,!!d["in-context"]],delete d.outdent):d[ce]("unique")?(d.type="action",d.action=["unique",ye&Re(d.unique)?["_DEFAULT_",d.unique]:d.unique,!!d["in-context"]],delete d.unique):d[ce]("push")?(d.type="action",d.action=["push",d.push,!!d["in-context"]],delete d.push):d[ce]("pop")?(d.type="action",d.action=["pop",d.pop,!!d["in-context"]],delete d.pop):d.sequence||d.all?(d.type="group",d.match="sequence",d.tokens=d.sequence||d.all,d.all?delete d.all:delete d.sequence):d.either?(d.type="group",d.match="either",d.tokens=d.either,delete d.either):d.zeroOrMore?(d.type="group",d.match="zeroOrMore",d.tokens=d.zeroOrMore,delete d.zeroOrMore):d.oneOrMore?(d.type="group",d.match="oneOrMore",d.tokens=d.oneOrMore,delete d.oneOrMore):d.zeroOrOne?(d.type="group",d.match="zeroOrOne",d.tokens=d.zeroOrOne,delete d.zeroOrOne):d.comment?(d.type="comment",d.tokens=d.comment,delete d.comment):d.block?(d.type="block",d.tokens=d.block,delete d.block):d["escaped-block"]?(d.type="escaped-block",d.tokens=d["escaped-block"],delete d["escaped-block"]):d.simple?(d.type="simple",d.tokens=d.simple,delete d.simple):d.type="simple"),y=d.type?ue[d.type.toUpperCase().replace(Ke,"")]:U,ie=d.msg||null,U&y){if(B===d.tokens)return ae=new un(B,t,t,ie),c[t]=ae,ae;if(F===d.tokens)return ae=new un(F,t,t,ie),c[t]=ae,ae;if(I===d.tokens||null===d.tokens)return ae=new un(I,t,t,ie),c[t]=ae,ae;if(""===d.tokens)return ae=new un(G,t,t,ie),c[t]=ae,ae;if(!1===d.tokens||0===d.tokens)return ae=new un(z,t,t,ie),c[t]=ae,ae}if(se&y||(d.tokens=Le(d.tokens)),se&y)d[ce]("action")?"error"===d.action[0]?d.action[0]=$:"context-start"===d.action[0]?d.action[0]=M:"context-end"===d.action[0]?d.action[0]=T:"empty"===d.action[0]?d.action[0]=q:"indent"===d.action[0]?d.action[0]=R:"outdent"===d.action[0]?d.action[0]=j:"unique"===d.action[0]?d.action[0]=O:"push"===d.action[0]?d.action[0]=S:"pop"===d.action[0]&&(d.action[0]=A):d[ce]("error")?d.action=[$,d.error,!!d["in-context"]]:d[ce]("context-start")?d.action=[M,d["context-start"],!!d["in-context"]]:d[ce]("context-end")?d.action=[T,d["context-end"],!!d["in-context"]]:d[ce]("empty")?d.action=[q,d.empty,!!d["in-context"]]:d[ce]("indent")?d.action=[R,d.indent,!!d["in-context"]]:d[ce]("outdent")?d.action=[j,d.outdent,!!d["in-context"]]:d[ce]("unique")?d.action=[O,ye&Re(d.unique)?["_DEFAULT_",d.unique]:d.unique,!!d["in-context"]]:d[ce]("push")?d.action=[S,d.push,!!d["in-context"]]:d[ce]("pop")&&(d.action=[A,d.pop,!!d["in-context"]]),b=d.action.slice(),ae=new an(se,t,b,ie),c[t]=ae;else if(U&y)d.autocomplete&&h(d,t,k),v="undefined"==typeof d.combine?"\\b":d.combine,ae=new un(U,t,u(t,d.tokens.slice(),e,v,s,l),ie),c[t]=ae;else if(K&y)Z&y&&f(d,g),ae=new cn(y,t,i(t,d.tokens.slice(),e,s,l),ie,d.multiline,d.escape,o[t+".inside"]?1:0),c[t]=ae,d.interleave&&m.push(ae.clone());else if(ne&y){for(_=d.tokens.slice(),xe&Re(d.match)?ae=new pn(W,t,null,ie,d.match[0],d.match[1]):(x=le[d.match.toUpperCase()],ae=X===x?new pn(X,t,null,ie,0,1):te===x?new pn(te,t,null,ie,0,E):ee===x?new pn(ee,t,null,ie,1,E):Q&x?new pn(Q,t,null,ie):new pn(Y,t,null,ie)),c[t]=ae,C=[],P=0,D=_.length;D>P;P++)C=C.concat(p(_[P],e,n,r,o,s,l,c,m,g,k));ae.set(C)}else if(re&y){for(ae=Pe(d.tokens.slice()).slice(),w=[],P=0,D=ae.length;D>P;P++)w[P]=ae[P].slice(),ae[P]=new pn(re,t+"_NGRAM_"+P,null,ie);for(c[t]=ae,P=0,D=ae.length;D>P;P++){for(L=w[P],C=[],N=0,V=L.length;V>N;N++)C=C.concat(p(L[N],e,n,r,o,s,l,c,m,g,k));ae[P].set(C)}}return c[t]}function f(t,e){var n,r,o,s,l,u=Pe(t.tokens.slice());for(s=0,l=u.length;l>s;s++)n=u[s][0],r=u[s].length>1?u[s][1]:u[s][0],o=u[s].length>2?u[s][2]:"",null===r?(e.line=e.line||[],e.line.push(n)):(e.block=e.block||[],e.block.push([n,r,o]))}function h(t,e,n){var r=[].concat(Le(t.tokens)).map(function(t){return{word:t,meta:e}});n.autocomplete=(n.autocomplete||[]).concat(r)}function m(t){var e,n,r,o,s,l,u,i,a,f,h,m,g,k,d,y;if(t.__parsed)return t;for(h={},m={},g={},d={},y={},k=[],t=De(t),e=t.RegExpID||null,t.RegExpID=null,delete t.RegExpID,l=t.Lex||{},t.Lex=null,delete t.Lex,u=t.Syntax||{},t.Syntax=null,delete t.Syntax,s=t.Style||{},c(l,u),o=t.Parser||[],r=o.length,n=[],i=0;r>i;i++)a=o[i],f=p(a,e,l,u,s,h,m,g,k,d,y)||null,f&&(xe&Re(f)?n=n.concat(f):n.push(f));return t.Parser=n,t.cTokens=k,t.Style=s,t.Comments=d,t.Keywords=y,t.Extra=t.Extra||{},t.__parsed=1,t}function g(t,e){var n=new gn(m(t),{DEFAULT:e||k,ERROR:d}),r=function(t,e){return{startState:function(){var t=new hn;return t},copyState:function(t){var e=t.clone();return e},token:function(t,e){return n.getToken(t,e)},indent:function(r,o,s){return n.indent(r,o,s,t,e)},lineComment:n.LC,blockCommentStart:n.BCS,blockCommentEnd:n.BCE,blockCommentContinue:n.BCC,blockCommentLead:n.BCL,electricChars:n.Extra.electricChars||!1,fold:n.Extra.fold||!1}};return r.supportGrammarAnnotations=!1,r.validator=function(t){if(!r.supportGrammarAnnotations||!t||!t.length)return[];var e,o,s=[],l=n.parse(t,v);if(!l)return s;for(e in l)l.hasOwnProperty(e)&&(o=l[e],s.push({message:o[4]||"Syntax Error",severity:"error",from:CodeMirror.Pos(o[0],o[1]),to:CodeMirror.Pos(o[2],o[3])}));return s},r.autocomplete=function(t,e){var r,o,s,l,u,i,a,c,p,f,h,m,g,k,d,y,v,b,x,_=n.Keywords,C=mn.Pos,w=t.getCursor(),E=w.ch,$=E,O=0,S=0;if(r=[],_&&_.length){for(e=e||{},a=e.word||kn,y=e[ce]("caseInsensitiveMatch")?!!e.caseInsensitiveMatch:!0,v=!!e.prefixMatch,o=t.getLine(w.line);$E){for(c=e.renderer||function(t,e,n){var r=n.text,o=n.meta,s=e.list.maxlen-r.length-o.length+1+2,l=new Array(s).join(" "),u=n.start,i=n.end;t.innerHTML=['',r.slice(0,u),'',r.slice(u,i),"",r.slice(i),"",l,'',o,""].join("")},s=o.slice(E,$),l=s.toLowerCase(),i=s.length,p=0,f=_.length;f>p;p++)u=_[p],h=u.word,m=u.meta,g=h.length,i>g||(y?(b=h.toLowerCase(),x=l):(b=h,x=s),(d=b.indexOf(x))<0||v&&d>0||(y&&(k=h.indexOf(s)),g>O&&(O=g),m.length>S&&(S=m.length),r.push({text:h,name:h,meta:m,start:0>k?d:k,end:(0>k?d:k)+s.length,match:s,displayText:h+" ["+m+"]",render:c,score:1e3-10*(g-i)-2*(0>k?d+10:k)})));r.length&&(r=r.sort(dn)),r.maxlen=O+S}}return{list:r,from:C(w.line,E),to:C(w.line,$)}},r}var k,d,y=1,v=2,b=4,x=8,_=~b,C=~x,w=b|x,E=1/0,$=4,O=8,S=16,A=32,q=64,R=128,j=256,M=512,T=1024,L=2,P=4,D=8,B=4,N=8,F=16,I=32,V=B|F,z=64,G=128,U=256,K=512,H=513,Z=514,Q=1024,Y=2048,J=Y,W=4096,X=4097,te=4098,ee=4099,ne=8192,re=16384,oe=Y|re,se=32768,le={EITHER:Q,ALL:J,SEQUENCE:Y,ZEROORONE:X,ZEROORMORE:te,ONEORMORE:ee,REPEATED:W},ue={ACTION:se,BLOCK:K,COMMENT:Z,ESCAPEDBLOCK:H,SIMPLE:U,GROUP:ne,NGRAM:re},ie=void 0,ae="prototype",ce="hasOwnProperty",pe="propertyIsEnumerable",fe=(Object.keys,Array[ae],Object[ae]),he=(Function[ae],fe.toString),me=4,ge=5,ke=6,de=8,ye=16,ve=17,be=18,xe=32,_e=64,Ce=128,we=256,Ee=512,$e=1024,Oe=2048,Se=4096,Ae=ye|xe,qe={"[object Number]":me,"[object String]":ye,"[object Array]":xe,"[object RegExp]":we,"[object Date]":Ee,"[object Function]":Ce,"[object Object]":_e},Re=function(t){if(null===t)return $e;if(!0===t||!1===t||t instanceof Boolean)return de;if(ie===t)return Oe;var e=qe[he.call(t)]||Se;return me===e||t instanceof Number?isNaN(t)?ke:isFinite(t)?me:ge:ye===e||t instanceof String?1===t.length?ve:ye:xe===e||t instanceof Array?xe:we===e||t instanceof RegExp?we:Ee===e||t instanceof Date?Ee:Ce===e||t instanceof Function?Ce:_e===e?_e:Se},je=function(){var t,e,n,r,o,s,l=arguments,u=l.length;for(t=l[0]||{},o=1;u>o;o++)if(e=l[o],_e===Re(e))for(r in e)e[ce](r)&&e[pe](r)&&(n=e[r],s=Re(n),t[r]=me&s?0+n:Ee&s?new Date(n):Ae&s?n.slice():n);return t},Me=Object.create,Te=function(t,e){var n,r=arguments.length,o="constructor";return 0===r?(t=Object,e={}):1===r?(e=t||{},t=Object):(t=t||Object,e=e||{}),e[ce](o)||(e[o]=function(){}),n=e[o],delete e[o],n[ae]=je(Me(t[ae]),e),n[ae][o]=n,n},Le=function(t,e){return e||xe!==Re(t)?[t]:t},Pe=function(t,e){return t=Le(t),(e||xe!==Re(t[0]))&&(t=[t]),t},De=function(t,e){var n,r,o,s,l=Re(t),u=0;if(me===Re(e)?e>0?(u=e,e=!0):e=!1:e=!1!==e,_e===l){r={};for(o in t)t[ce](o)&&t[pe](o)&&(n=Re(t[o]),r[o]=_e===n?e?De(t[o],u>0?u-1:e):t[o]:xe===n?e?De(t[o],u>0?u-1:e):t[o].slice():Ee&n?new Date(t[o]):ye&n?t[o].slice():me&n?0+t[o]:t[o])}else if(xe===l)for(s=t.length,r=new Array(s),o=0;s>o;o++)n=Re(t[o]),r[o]=_e===n?e?De(t[o],u>0?u-1:e):t[o]:xe===n?e?De(t[o],u>0?u-1:e):t[o].slice():Ee&n?new Date(t[o]):ye&n?t[o].slice():me&n?0+t[o]:t[o];else r=Ee&l?new Date(t):ye&l?t.slice():me&l?0+t:t;return r},Be=function(){var t,e,n,r,o,s,l,u,i,a,c=arguments,p=c.length;if(1>p)return null;for(e=De(c[0]),n=1;p>n;n++)if(t=c[n])for(r in t)if(t[ce](r)&&t[pe](r))if(e[ce](r)&&e[pe](r)){if(i=Re(e[r]),a=Re(t[r]),_e===i&&_e===a)e[r]=Be(e[r],t[r]);else if(xe===i&&xe===a){if(l=e[r],u=t[r],s=u.length,!s)continue;if(l.length)for(o=0;s>o;o++)0>l.indexOf(u[o])&&l.push(u[o]);else e[r]=u.slice()}}else e[r]=De(t[r]);return e},Ne=/([.*+?^${}()|[\]\/\\\-])/g,Fe=function(t){return t.replace(Ne,"\\$1")},Ie=function(t,e,n){var r,o,s,l,u,i=!0===n?0:1;for(ye&Re(e)&&(e=[e,e],i=0),o=t.length,u="",r=0;o>r;)s=t.charAt(r),o>r+1&&"$"===s?(l=t.charCodeAt(r+1),36===l?(u+="$",r+=2):l>=48&&57>=l?(u+=e[i+l-48]||"",r+=2):(u+=s,r+=1)):(u+=s,r+=1);return u},Ve=/^\s+|\s+$/g,ze=String[ae].trim?function(t){return t.trim()}:function(t){return t.replace(Ve,"")},Ge=function(t,e){return e.length-t.length},Ue=/\r\n|\r|\n/g,Ke=/[\-_]/g,He=/^([\[\]{}()*+?|'"]|\s)/,Ze=function(t,e){return ye&Re(e)&&ye&Re(t)&&e.length&&e.length<=t.length&&e==t.substr(0,e.length)},Qe=function(t,e,n){if(!t||me===Re(t))return t;var r,o=e?e.length||0:0;if(o&&e===t.substr(0,o)){var s,l,u,r,i,a=t.substr(o),c=a.charAt(0),p="";for(r=a.length;r--&&(i=a.charAt(r),c!==i);)"i"===i.toLowerCase()&&(p="i");return s=a.substring(1,r),l="^("+s+")",n[l]||(u=new RegExp(l,p),n[l]=u),n[l]}return t},Ye=function(t,e){var n,r="";return ye&Re(e)&&(r=e),n=t.sort(Ge).map(Fe).join("|"),[new RegExp("^("+n+")"+r),1]},Je=0,We=function(){return++Je},Xe=function(t){return[t||"uuid",++Je,(new Date).getTime()].join("_")},tn=Math.max,en=/^[\s\u00a0]+/,nn=/[^\s\u00a0]/,rn=Te({constructor:function(t){var e=this;e._=null,e.s=t?""+t:"",e.start=e.pos=0,e.lCP=e.lCV=0,e.lS=0},_:null,s:"",start:0,pos:0,lCP:0,lCV:0,lS:0,dispose:function(){var t=this;return t._=null,t.s=null,t.start=null,t.pos=null,t.lCP=null,t.lCV=null,t.lS=null,t},toString:function(){return this.s},sol:function(){return 0===this.pos},eol:function(){return this.pos>=this.s.length},end:function(){var t=this;return t.pos=t.s.length,t},mov:function(t){var e=this;return 0>t?e.pos=tn(0,e.pos-t):e.pos+=t,e},bck:function(t){var e=this;return e.pos=tn(0,t),e},sft:function(){var t=this;return t.start=t.pos,t},nxt:function(){var t,e=this,n=e.s;return e.poss;++s)l+=" "==t.charAt(s)?n-l%n:1;return l},rn._=function(t){var e=new rn;return e._=t,e.s=""+t.string,e.start=t.start,e.pos=t.pos,e.lCP=t.lastColumnPos,e.lCV=t.lastColumnValue,e.lS=t.lineStart,e};var on,sn,ln,un,an,cn,pn,fn=Te({constructor:function(t){this._=t||[]},_:null,dispose:function(){var t=this;return t._=null,t},toString:function(){return this._.slice().reverse().join("\n")},clone:function(){return new fn(this._.slice())},isEmpty:function(){return 0>=this._.length},pos:function(){return this._.length},peek:function(t){var e=this,n=e._;if(t=arguments.length?t:-1,n.length){if(0>t&&0<=n.length+t)return n[n.length+t];if(t>=0&&tn;n++)if(r=s[n].match(t,e))return u?[n,r[1]]:r;return!1}}),sn=Te(on,{constructor:function(t,e){var n=this;n.type=D,n.name=t,n.pattern=e,n.pattern[0]=new ln(n.name+"_Start",n.pattern[0],!1)},match:function(t,e){var n,r,o,s,l,u=this,i=u.pattern,a=i[0],c=i[1];return(r=a.match(t,e))?(n=c[r[0]],s=Re(n),l=a.pattern[r[0]].ptype,we===l&&(me===s?(o=r[1][n+1],n=new on(u.name+"_End",o,o.length>1?ye:ve)):ye===s&&(o=Ie(n,r[1]),n=new on(u.name+"_End",o,o.length>1?ye:ve))),n):!1}}),un=Te({constructor:function(t,e,n,r){var o=this;o.type=t||U,o.name=e,o.token=n,o.status=0,o.msg=r||null,o.$msg=null,o.$clone=null,B===o.name?o.name="":F===o.name?o.name="":I===o.name?o.name="":N===o.name?o.name="":z===o.name?o.name="":G===o.name&&(o.name="")},name:null,type:null,token:null,status:0,msg:null,$msg:null,$clone:null,$id:null,dispose:function(){var t=this;return t.type=null,t.name=null,t.token=null,t.status=null,t.msg=null,t.$msg=null,t.$clone=null,t.$id=null,t},clone:function(){var t,e,n,r=this,o=r.$clone;if(t=new r.constructor,t.type=r.type,t.name=r.name,t.token=r.token,t.msg=r.msg,o&&o.length)for(e=0,n=o.length;n>e;e++)t[o[e]]=r[o[e]];return t},get:function(t,e){var n=this,r=n.token,o=n.type,s=n.name,l=null;if(n.$msg=n.msg||null,e.token=null,B===o){if(B&e.status&&t.sol())return!0}else if(F===o){if(t.sol())return!0}else if(I===o){if(t.spc(),t.eol())return s}else{if(z===o)return n.status=0,!0;if(G===o)n.status&b&&t.spc()&&!t.eol()&&(n.status|=x),n.status&=_;else if(l=r.match(t))return e.token={name:s,value:t.cur(),token:l[1]},s}return n.status&&n.$msg&&(n.$msg=Ie(n.$msg,s,!0)),!1},req:function(t){var e=this;return t?e.status|=b:e.status&=_,e},err:function(t,e,n,r,o){var s,l=this,u=l.name;return s=l.$msg?l.$msg:l.status&b?'Token "'+u+'" Expected':'Syntax Error: "'+u+'"',t&&t.status&v&&(t.err[e+"_"+n+"_"+r+"_"+o+"_"+u]=[e,n,r,o,s]),s},toString:function(){var t=this;return["[","Token: ",t.name,", ",t.token?t.token.toString():null,"]"].join("")}}),an=Te(un,{constructor:function(t,e,n,r){var o=this;o.type=t||se,o.name=e,o.token=n,o.status=0,o.msg=r||null,o.$msg=null,o.$clone=null},get:function(t,e){var n,r,o,s,l,u,i,a,c,p,f,h=this,m=h.token||null,g=e.queu,k=e.symb,d=e.ctx,y=e.token,b=e.err,_=!!(e.status&v);if(h.status=0,h.$msg=null,m){if(l=h.msg,n=m[0],r=m[1],c=!!m[2],u=e.line,a=t.pos,i=y&&y.value?a-y.value.length:i-1,$===n)return _&&(h.$msg=l?l:"Error",p=u+"_"+i+"_"+u+"_"+a+"_"+h.name,b[p]=[u,i,u,a,h.err()]),h.status|=x,!1;if(M===n)d.unshift({symb:{},queu:[]});else if(T===n)d.length&&d.shift();else if(q===n)c?d.length&&(d[0].queu.length=0):g.length=0;else if(O===n){if(c){if(!d.length)return!0;k=d[0].symb}if(y){if(o=r[1],s=r[0],o=me===Re(o)?y.token[o]:Ie(o,y.token,!0),k[ce](s)||(k[s]={}),k[s][ce](o))return _&&(h.$msg=l?Ie(l,o,!0):'Duplicate "'+o+'"',f=h.err(),p=k[s][o][0]+"_"+k[s][o][1]+"_"+k[s][o][2]+"_"+k[s][o][3]+"_"+h.name,b[p]=[k[s][o][0],k[s][o][1],k[s][o][2],k[s][o][3],f],p=u+"_"+i+"_"+u+"_"+a+"_"+h.name,b[p]=[u,i,u,a,f]),h.status|=x,!1;k[s][o]=[u,i,u,a]}}else if(A===n){if(c){if(!d.length)return!0;g=d[0].queu}if(r){if(y&&(r=me===Re(r)?y.token[r]:Ie(r,y.token)),!g.length||r!==g[0][0])return _&&(g.length?(h.$msg=l?Ie(l,[g[0][0],r],!0):'Tokens do not match "'+g[0][0]+'","'+r+'"',f=h.err(),p=g[0][1]+"_"+g[0][2]+"_"+g[0][3]+"_"+g[0][4]+"_"+h.name,b[p]=[g[0][1],g[0][2],g[0][3],g[0][4],f],p=u+"_"+i+"_"+u+"_"+a+"_"+h.name,b[p]=[u,i,u,a,f]):(h.$msg=l?Ie(l,["",r],!0):'Token does not match "'+r+'"',f=h.err(),p=u+"_"+i+"_"+u+"_"+a+"_"+h.name,b[p]=[u,i,u,a,f])),g.shift(),h.status|=x,!1;g.shift()}else g.shift()}else if(S===n&&r){if(c){if(!d.length)return!0;g=d[0].queu}y&&(r=me===Re(r)?y.token[r]:Ie(r,y.token)),g.unshift([r,u,i,u,a])}}return!0}}),cn=Te(un,{constructor:function(t,e,n,r,o,s,l){var u=this;u.type=t,u.name=e,u.token=n,u.status=0,u.msg=r||null,u.mline="undefined"==typeof o?1:o,u.esc=s||"\\",u.inter=l,u.$msg=null,u.$clone=["mline","esc","inter"]},inter:0,mline:0,esc:null,get:function(t,e){var n,r,o,s,l,u,i,a,c,p,f,h,m,g,k=this,d=0,y=0,v="",b=k.mline,x=k.token,C=k.name,w=k.type,E=k.inter,$=E?C+".inside":C,O=0,S=H===w,A=k.esc,q="",R="",j="",M="",T=e.stack;if(k.$msg=k.msg||null,m=e.line,g=t.pos,Z===w&&(k.status&=_),l=0,e.block&&e.block.name===C?(y=1,n=e.block.end,l=1,u=$,p=e.block.s,h=e.block.i,f=e.block.e,q=e.block._s,R=e.block._i,M=""):!e.block&&(n=x.match(t))&&(y=1,p=[m,g],h=[[m,t.pos],[m,t.pos]],f=[m,t.pos],q=t.cur(),R="",M="",j="",e.block={name:C,end:n,s:p,i:h,e:f,_s:q,_i:R,_e:j},u=C),y){if(o=T.pos(),s=$e===n.type,E){if(l&&s&&t.sol())return k.status&=_,e.current=null,e.block=null,!1;if(!l)return T.pushAt(o,k.clone(),"$id",C),u}if(d=n.match(t),r=b,c=0,d)u=s?$:C,j=t.cur().slice(M.length);else for(a=t.pos;!t.eol();){if(i=t.pos,!(S&&O||!n.match(t))){E&&t.pos>i&&i>a?(u=$,t.bck(i),c=1):(u=C,d=1),j=t.cur().slice(M.length);break}v=t.nxt(),M+=v,O=!O&&v===A}return r=b||S&&O,h[1]=[m,i],f=[m,t.pos],d||!r&&!c?e.block=null:(e.block.i=h,e.block.e=f,e.block._i+=M,e.block._e=j,e.stack.pushAt(o,k.clone(),"$id",C)),e.token={name:C,value:t.cur(),token:[q+R+M+j,R+M,q,j]},u}return k.status&&k.$msg&&(k.$msg=Ie(k.$msg,C,!0)),!1}}),pn=Te(un,{constructor:function(t,e,n,r,o,s){var l=this;l.type=t?t:W,l.name=e||null,l.token=null,l.status=0,l.msg=r||null,l.min=o||0,l.max=s||E,l.found=0,l.$msg=null,l.$clone=["min","max","found"],n&&l.set(n)},min:0,max:1,found:0,set:function(t){return t&&(this.token=Le(t)),this},get:function(t,e){var n,r,o,s,l,u,i,a,c,p,f,h,m,g,k,d=this,y=d.type,v=d.token,w=v.length;if(d.$msg=d.msg||null,d.status&=C,h=t.pos,l=e.stack,Q===y){for(p=0,f=0,d.status|=b,u=[],n=0;w>n;n++){if(o=v[n].clone().req(1),s=o.get(t,e),o.status&b&&(p++,u.push(o.err())),!1!==s)return s;o.status&x&&(f++,t.bck(h))}return p>0?d.status|=b:d.status&=_,w===f&&p>0?d.status|=x:d.status&=C,d.status&&!d.$msg&&u.length&&(d.$msg=u.join(" | ")),!1}if(oe&y){k=y&Y?1:0,k?d.status|=b:d.status&=_,m=l.pos(),g=d.name+"_"+We(),r=0;do o=v[r].clone().req(k),s=o.get(t,e),r++;while(w>r&&!0===s&&V&o.type);if(r>=w)return o.status&x?(k?d.status|=x:d.status&=C,t.bck(h)):k&&o.status&b&&(d.status|=x),d.status&&!d.$msg&&(d.$msg=o.err()),s;if(!1!==s){if(!0!==s)for(n=w-1;n>=r;n--)l.pushAt(m+w-n-1,v[n].clone().req(1),"$id",g);return s}return o.status&x?(k?d.status|=x:d.status&=C,t.bck(h)):k&&o.status&b&&(d.status|=x),d.status&&!d.$msg&&(d.$msg=o.err()),!1}for(p=0,i=d.found,a=d.min,c=d.max,d.status&=_,m=l.pos(),g=d.name+"_"+We(),u=[],n=0;w>n;n++){if(o=v[n].clone().req(1),s=o.get(t,e),!1!==s){if(++i,c>=i)return d.found=i,l.pushAt(m,d.clone(),"$id",g),d.found=0,s;break}o.status&b&&(p++,u.push(o.err())),o.status&x&&t.bck(h)}return a>i?d.status|=b:d.status&=_,i>c||a>i&&p>0?d.status|=x:d.status&=C,d.status&&!d.$msg&&u.length&&(d.$msg=u.join(" | ")),!1}});var mn=CodeMirror||{Pass:{toString:function(){return"CodeMirror.Pass"}}};k=null,d="error";{var gn=Te({constructor:function(t,e){var n=this;n.Extra=t.Extra||{},n.LC=t.Comments.line?t.Comments.line[0]:null,n.BCS=t.Comments.block?t.Comments.block[0][0]:null,n.BCE=t.Comments.block?t.Comments.block[0][1]:null,n.BCC=n.BCL=t.Comments.block?t.Comments.block[0][2]:null,n.DEF=e.DEFAULT,n.ERR=t.Style.error||e.ERROR,n.Keywords=t.Keywords.autocomplete||null,n.Tokens=t.Parser||[],n.cTokens=t.cTokens.length?t.cTokens:null,n.Style=t.Style},Extra:null,LC:null,BCS:null,BCE:null,BCL:null,BCC:null,ERR:null,DEF:null,Keywords:null,cTokens:null,Tokens:null,Style:null,dispose:function(){var t=this;return t.Extra=null,t.LC=null,t.BCS=null,t.BCE=null,t.BCL=null,t.BCC=null,t.ERR=null,t.DEF=null,t.Keywords=null,t.cTokens=null,t.Tokens=null,t.Style=null,t},parse:function(t,e){t=t||"";var n,r,o,s,l,u,i,a,c=this,p=t.split(Ue),f=p.length;if(e=e||y,i=!!(e&v),a=!!(e&y),s=new hn(0,0,e),s.parseAll=1,a)for(r=[],n=0;f>n;n++){for(s.line=n,l=new rn(p[n]),o=[];!l.eol();)o.push(c.getToken(l,s));r.push(o)}else for(n=0;f>n;n++)for(s.line=n,l=new rn(p[n]);!l.eol();)c.getToken(l,s);return u=a&&i?{tokens:r,errors:s.err}:a?r:s.err,l.dispose(),s.dispose(),u},getToken:function(t,e){var n,r,o,s,l,u,i,a,c=this,p=c.cTokens,f=c.Tokens,h=f.length,m=!!e.parseAll,g=c.Style,k=c.DEF,d=c.ERR;if(t=m?t:rn._(t),m?0===e.line?e.status|=B:e.status&=~B:t.sol()?e.status|=B:e.status&=~B,u=e.stack,t.sol()&&!u.isEmpty()&&I===u.peek().type&&u.pop(),(u.isEmpty()||G!==u.peek().type)&&t.spc())return m?{value:t.cur(1),type:k}:t.upd()&&k;for(a=e.line;!u.isEmpty()&&!t.eol();){if(p)for(r=0;rn;n++)if(i=t.pos,s=f[n],o=s.get(t,e),!1!==o){if(!0!==o){for(o=g[o]||k;!u.isEmpty()&&se===u.peek().type;)l=u.pop(),l.get(t,e);return m?{value:t.cur(1),type:o}:t.upd()&&o}}else if(s.status&w)return u.empty("$id",s.$id),t.nxt(),o=d,s.err(e,a,i,a,t.pos),m?{value:t.cur(1),type:o}:t.upd()&&o;return t.nxt(),m?{value:t.cur(1),type:k}:t.upd()&&k},indent:function(t,e,n,r){var o=(r.indentUnit||4,mn.Pass);return o}}),kn=/[\w$]/,dn=function(t,e){return e.score-t.score};t.CodeMirrorGrammar={VERSION:"2.1.1",clone:De,extend:Be,parse:m,getMode:g}}return t.CodeMirrorGrammar});
\ No newline at end of file
diff --git a/src/main.js b/src/main.js
index 33e2912..d5c5d74 100644
--- a/src/main.js
+++ b/src/main.js
@@ -347,47 +347,65 @@ function get_mode( grammar, DEFAULT )
cm_mode.autocomplete = function( cm, options ) {
var keywords = parser.Keywords, list, Pos = _CodeMirror.Pos,
cur = cm.getCursor(), curLine, start = cur.ch, end = start,
- token, len, maxlen = 0, word_re, renderer;
+ token, token_i, word, len, maxword = 0, maxtype = 0, word_re, renderer,
+ i, l, w, wm, wl, pos, pos_i, case_insensitive_match, prefix_match, m1, m2;
list = [];
if ( keywords && keywords.length )
{
options = options || {};
word_re = options.word || W;
+ case_insensitive_match = options[HAS]('caseInsensitiveMatch') ? !!options.caseInsensitiveMatch : true;
+ prefix_match = !!options.prefixMatch;
curLine = cm.getLine(cur.line);
while (end < curLine.length && word_re.test(curLine.charAt(end))) ++end;
while (start && word_re.test(curLine.charAt(start - 1))) --start;
if ( start < end )
{
- token = curLine.slice(start, end); len = token.length;
renderer = options.renderer || function(elt, data, cmpl) {
- var kword = cmpl.text, type = cmpl.meta,
- tab = new Array(data.list.maxlen-kword.length+3).join(" "),
- p1 = cmpl.pos, p2 = p1 + cmpl.match.length;
+ var word = cmpl.text, type = cmpl.meta,
+ tabsize = data.list.maxlen-word.length-type.length+1+2,
+ tab = new Array(tabsize).join(" "),
+ p1 = cmpl.start, p2 = cmpl.end;
elt.innerHTML = [
- kword.slice(0,p1),
- '', kword.slice(p1,p2), '',
- kword.slice(p2),
+ '', word.slice(0,p1),
+ '', word.slice(p1,p2), '',
+ word.slice(p2), '',
tab,
- '', type, ''
+ '', type, ''
].join('');
};
- keywords.reduce(function(list, word) {
- var w = word.word, wm = word.meta, wl = w.length, pos;
- if ( (wl >= len) && ((pos = w.indexOf(token)) >= 0) )
+ token = curLine.slice(start, end); token_i = token.toLowerCase(); len = token.length;
+ for (i=0,l=keywords.length; i maxlen ) maxlen = wl;
- list.push({
- text: w, name: w, meta: wm,
- pos: pos, match: token,
- score: 1000 - wl - 10*pos,
- displayText: w + "\t\t["+wm+"]",
- render: renderer
- });
+ m1 = w;
+ m2 = token;
}
- return list;
- }, list);
+ if ( ((pos_i = m1.indexOf( m2 )) < 0) || (prefix_match && (pos_i > 0)) ) continue;
+ if ( case_insensitive_match ) pos = w.indexOf( token );
+ //else pos = pos_i;
+ if ( wl > maxword ) maxword = wl;
+ if ( wm.length > maxtype ) maxtype = wm.length;
+ list.push({
+ text: w, name: w, meta: wm,
+ start: pos<0?pos_i:pos, end: (pos<0?pos_i:pos) + token.length, match: token,
+ displayText: w + "\t\t["+wm+"]",
+ render: renderer,
+ // longer matches or matches not at start have lower match score
+ score: 1000 - 10*(wl-len) - 2*(pos<0?pos_i+10:pos)
+ });
+ }
if ( list.length ) list = list.sort( by_score );
- list.maxlen = maxlen;
+ list.maxlen = maxword + maxtype;
}
}
return {