diff --git a/README.md b/README.md index 004ac74..e6f1b90 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,6 @@ var xml_grammar = { "Extra" : { "fold" : "xml" - //"match" : "xml" //"electricChars" : "<" }, @@ -113,8 +112,8 @@ var xml_grammar = { ,"doctype:block" : ["RE::/"] ,"meta:block" : ["RE::/<\\?[_a-zA-Z][\\w\\._\\-]*/", "?>"] ,"cdata:block" : [""] - ,"open_tag" : "RE::/<([_a-zA-Z][_a-zA-Z0-9\\-]*)/" - ,"close_tag" : "RE::/<\\/([_a-zA-Z][_a-zA-Z0-9\\-]*)>/" + ,"open_tag" : "RE::/<((?:[_a-zA-Z][_a-zA-Z0-9\\-]*:)?[_a-zA-Z][_a-zA-Z0-9\\-]*)\\b/" + ,"close_tag" : "RE::/<\\/((?:[_a-zA-Z][_a-zA-Z0-9\\-]*:)?[_a-zA-Z][_a-zA-Z0-9\\-]*)>/" ,"attribute" : "RE::/[_a-zA-Z][_a-zA-Z0-9\\-]*/" ,"string:line-block" : [["\""], ["'"]] ,"number" : ["RE::/[0-9]\\d*/", "RE::/#[0-9a-fA-F]+/"] @@ -122,24 +121,25 @@ var xml_grammar = { ,"text" : "RE::/[^<&]+/" // actions - ,"tag_ctx:action" : {"context":true} - ,"\\tag_ctx:action" : {"context":false} - ,"unique_id:action" : {"unique":["xml", "$1"],"msg":"Duplicate id value \"$0\""} - ,"unique_att:action" : {"unique":["tag", "$0"],"msg":"Duplicate attribute \"$0\"","in-context":true} - ,"tag_opened:action" : {"push":"<$1>","ci":true} - ,"tag_closed:action" : {"pop":"<$1>","ci":true,"msg":"Tags \"$0\" and \"$1\" do not match"} - ,"tag_autoclosed:action" : {"pop":null} - ,"out_of_place:error" : "\"$2$3\" can only be at the beginning of XML document" + ,"@tag:action" : {"context":true} + ,"tag@:action" : {"context":false} + ,"@unique_id:action" : {"unique":["xml", "$1"],"msg":"Duplicate id value \"$0\"","mode":"hash"} + ,"@unique_att:action" : {"unique":["att", "$0"],"msg":"Duplicate attribute \"$0\"","mode":"hash","in-context":true} + ,"@tag_opened:action" : {"push":"<$1>","ci":true} + ,"@tag_closed:action" : {"pop":"<$1>","ci":true,"msg":"Tags \"$0\" and \"$1\" do not match"} + ,"@tag_autoclosed:action" : {"pop":null} + ,"@autocomplete:action" : {"define":["autocomplete","$1"],"msg":false,"autocomplete":true,"mode":"hash"} + ,"@out_of_place:error" : "\"$2$3\" can only be at the beginning of XML document" }, // Syntax model (optional) "Syntax" : { - "tag_att" : "'id'.attribute unique_att '=' string unique_id | attribute unique_att '=' (string | number)" - ,"start_tag" : "open_tag.tag tag_ctx tag_opened tag_att* ('>'.tag | '/>'.tag tag_autoclosed) \\tag_ctx" - ,"end_tag" : "close_tag.tag tag_closed" - ,"xml" : "(^^1 declaration? doctype?) (declaration.error out_of_place | doctype.error out_of_place | comment | meta | cdata | start_tag | end_tag | atom | text)*" + "tag_att" : "'id'.attribute @unique_att '=' string @unique_id | attribute @unique_att '=' (string | number)" + ,"start_tag" : "open_tag.tag @tag @autocomplete @tag_opened tag_att* ('>'.tag | '/>'.tag @tag_autoclosed) tag@" + ,"end_tag" : "close_tag.tag @autocomplete @tag_closed" + ,"xml" : "(^^1 declaration? doctype?) (declaration.error @out_of_place | doctype.error @out_of_place | comment | meta | cdata | start_tag | end_tag | atom | text)*" }, @@ -210,6 +210,7 @@ Result: ![xml-grammar-1](/test/grammar-xml.png) ![xml-grammar-2](/test/grammar-xml-2.png) +![xml-grammar-2](/test/grammar-xml-3.png) diff --git a/beeld.config b/beeld.config index 77d3d7f..868e1fa 100644 --- a/beeld.config +++ b/beeld.config @@ -49,7 +49,7 @@ tasks =[{}] replace =[{}] "@@ROOT@@" = "this" - "@@VERSION@@" = "4.2.0" + "@@VERSION@@" = "4.2.1" "@@MODULE@@" = "CodeMirrorGrammar" @ diff --git a/build/codemirror_grammar.js b/build/codemirror_grammar.js index b0561ae..fd635ef 100644 --- a/build/codemirror_grammar.js +++ b/build/codemirror_grammar.js @@ -1,7 +1,7 @@ /** * * CodeMirrorGrammar -* @version: 4.2.0 +* @version: 4.2.1 * * Transform a grammar specification in JSON format, into a syntax-highlight parser mode for CodeMirror * https://github.com/foo123/codemirror-grammar @@ -23,7 +23,7 @@ else if ( !(name in root) ) /* Browser/WebWorker/.. */ "use strict"; /** * EditorGrammar Codebase -* @version: 4.2.0 +* @version: 4.2.1 * * https://github.com/foo123/editor-grammar **/ @@ -84,9 +84,9 @@ $T_EMPTY$ = '$|EMPTY|$', $T_NONSPACE$ = '$|NONSPACE|$' ; var undef = undefined, - PROTO = 'prototype', HAS = 'hasOwnProperty', IS_ENUM = 'propertyIsEnumerable', - OP = Object[PROTO], toString = OP.toString, Extend = Object.create, + PROTO = 'prototype', OP = Object[PROTO], Extend = Object.create, MAX = Math.max, MIN = Math.min, LOWER = 'toLowerCase', CHAR = 'charAt', + toString = OP.toString, HAS = OP.hasOwnProperty, IS_ENUM = OP.propertyIsEnumerable, // types INF = Infinity, @@ -259,7 +259,7 @@ function clone( o, deep ) co = { }; for (k in o) { - if ( !o[HAS](k) || !o[IS_ENUM](k) ) continue; + if ( !HAS.call(o,k) || !IS_ENUM.call(o,k) ) continue; T2 = get_type( o[k] ); if ( T_OBJ === T2 ) co[k] = deep ? clone( o[k], level>0 ? level-1 : deep ) : o[k]; @@ -321,8 +321,8 @@ function extend(/* var args here.. */) for (k in o2) { - if ( !o2[HAS](k) || !o2[IS_ENUM](k) ) continue; - if ( o[HAS](k) && o[IS_ENUM](k) ) + if ( !HAS.call(o2,k) || !IS_ENUM.call(o2,k) ) continue; + if ( HAS.call(o,k) && IS_ENUM.call(o,k) ) { T = get_type( o[k] ); T2 = get_type( o2[k] ); if ( T_OBJ === T && T_OBJ === T2 ) @@ -409,7 +409,7 @@ function Merge(/* var args here.. */) { for (p in o2) { - if ( !o2[HAS](p) || !o2[IS_ENUM](p) ) continue; + if ( !HAS.call(o2,p) || !IS_ENUM.call(o2,p) ) continue; v = o2[p]; T = get_type( v ); @@ -448,7 +448,7 @@ function Class( O, C ) O = O || Object; C = C || { }; } - if ( !C[HAS](CTOR) ) C[CTOR] = function( ){ }; + if ( !HAS.call(C,CTOR) ) C[CTOR] = function( ){ }; ctor = C[CTOR]; delete C[CTOR]; ctor[PROTO] = Merge( Extend(O[PROTO]), C ); ctor[PROTO][CTOR] = ctor; @@ -933,7 +933,7 @@ function preprocess_grammar( grammar ) G = conf[i++]; for (t in G) { - if ( !G[HAS](t) ) continue; + if ( !HAS.call(G,t) ) continue; id = t.split(':'); type = id[1] && trim(id[1]).length ? trim(id[1]) : null; id = trim(id[0]); @@ -1019,7 +1019,7 @@ function preprocess_grammar( grammar ) G = Lex; for (id in G) { - if ( !G[HAS](id) ) continue; + if ( !HAS.call(G,id) ) continue; tok = G[id]; // allow tokens to extend / reference other tokens while ( tok['extend'] ) @@ -1045,12 +1045,16 @@ function preprocess_grammar( grammar ) G = Lex; for (id in G) { - if ( !G[HAS](id) ) continue; + if ( !HAS.call(G,id) ) continue; tok = G[id]; if ( tok.type ) { tl = tok.type = tok.type[LOWER](); - if ( 'line-block' === tl ) + if ( 'action' === tl ) + { + tok.options = tok.options||{}; + } + else if ( 'line-block' === tl ) { tok.type = 'block'; tok.multiline = false; @@ -1117,79 +1121,92 @@ function preprocess_grammar( grammar ) else if ( tok['nop'] ) { tok.type = 'action'; - tok.action = [ 'nop', tok.nop, false ]; + tok.options = tok.options||{}; + tok.action = [ 'nop', tok.nop, tok.options ]; tok.nop = true; } else if ( tok['error'] ) { tok.type = 'action'; - tok.action = [ 'error', tok.error, !!tok['in-context'], !!tok['in-hypercontext'] ]; + tok.options = tok.options||{}; + tok.action = [ 'error', tok.error, tok.options ]; del(tok,'error'); } - else if ( tok[HAS]('hypercontext') ) + else if ( HAS.call(tok,'hypercontext') ) { tok.type = 'action'; - tok.action = [ !!tok.hypercontext ? 'hypercontext-start' : 'hypercontext-end', tok['hypercontext'], !!tok['in-context'], !!tok['in-hypercontext'] ]; + tok.options = tok.options||{}; + tok.action = [ !!tok.hypercontext ? 'hypercontext-start' : 'hypercontext-end', tok['hypercontext'], tok.options ]; del(tok,'hypercontext'); } - else if ( tok[HAS]('context') ) + else if ( HAS.call(tok,'context') ) { tok.type = 'action'; - tok.action = [ !!tok.context ? 'context-start' : 'context-end', tok['context'], !!tok['in-context'], !!tok['in-hypercontext'] ]; + tok.options = tok.options||{}; + tok.action = [ !!tok.context ? 'context-start' : 'context-end', tok['context'], tok.options ]; del(tok,'context'); } else if ( tok['indent'] ) { tok.type = 'action'; - tok.action = [ 'indent', tok.indent, !!tok['in-context'], !!tok['in-hypercontext'] ]; + tok.options = tok.options||{}; + tok.action = [ 'indent', tok.indent, tok.options ]; del(tok,'indent'); } else if ( tok['outdent'] ) { tok.type = 'action'; - tok.action = [ 'outdent', tok.outdent, !!tok['in-context'], !!tok['in-hypercontext'] ]; + tok.options = tok.options||{}; + tok.action = [ 'outdent', tok.outdent, tok.options ]; del(tok,'outdent'); } else if ( tok['define'] ) { tok.type = 'action'; - tok.action = [ 'define', T_STR&get_type(tok.define) ? ['*', tok.define] : tok.define, !!tok['in-context'], !!tok['in-hypercontext'] ]; + tok.options = tok.options||{}; + tok.action = [ 'define', T_STR&get_type(tok.define) ? ['*', tok.define] : tok.define, tok.options ]; del(tok,'define'); } else if ( tok['undefine'] ) { tok.type = 'action'; - tok.action = [ 'undefine', T_STR&get_type(tok.undefine) ? ['*', tok.undefine] : tok.undefine, !!tok['in-context'], !!tok['in-hypercontext'] ]; + tok.options = tok.options||{}; + tok.action = [ 'undefine', T_STR&get_type(tok.undefine) ? ['*', tok.undefine] : tok.undefine, tok.options ]; del(tok,'undefine'); } else if ( tok['defined'] ) { tok.type = 'action'; - tok.action = [ 'defined', T_STR&get_type(tok.defined) ? ['*', tok.defined] : tok.defined, !!tok['in-context'], !!tok['in-hypercontext'] ]; + tok.options = tok.options||{}; + tok.action = [ 'defined', T_STR&get_type(tok.defined) ? ['*', tok.defined] : tok.defined, tok.options ]; del(tok,'defined'); } else if ( tok['notdefined'] ) { tok.type = 'action'; - tok.action = [ 'notdefined', T_STR&get_type(tok.notdefined) ? ['*', tok.notdefined] : tok.notdefined, !!tok['in-context'], !!tok['in-hypercontext'] ]; + tok.options = tok.options||{}; + tok.action = [ 'notdefined', T_STR&get_type(tok.notdefined) ? ['*', tok.notdefined] : tok.notdefined, tok.options ]; del(tok,'notdefined'); } else if ( tok['unique'] ) { tok.type = 'action'; - tok.action = [ 'unique', T_STR&get_type(tok.unique) ? ['*', tok.unique] : tok.unique, !!tok['in-context'], !!tok['in-hypercontext'] ]; + tok.options = tok.options||{}; + tok.action = [ 'unique', T_STR&get_type(tok.unique) ? ['*', tok.unique] : tok.unique, tok.options ]; del(tok,'unique'); } else if ( tok['push'] ) { tok.type = 'action'; - tok.action = [ 'push', tok.push, !!tok['in-context'], !!tok['in-hypercontext'] ]; + tok.options = tok.options||{}; + tok.action = [ 'push', tok.push, tok.options ]; del(tok,'push'); } - else if ( tok[HAS]('pop') ) + else if ( HAS.call(tok,'pop') ) { tok.type = 'action'; - tok.action = [ 'pop', tok.pop, !!tok['in-context'], !!tok['in-hypercontext'] ]; + tok.options = tok.options||{}; + tok.action = [ 'pop', tok.pop, tok.options ]; del(tok,'pop'); } else @@ -1199,19 +1216,23 @@ function preprocess_grammar( grammar ) } if ( 'action' === tok.type ) { - tok.ci = !!(tok.caseInsesitive||tok.ci); - tok.autocomplete = !!tok.autocomplete; + tok.options = tok.options||{}; + tok.options['in-context'] = !!(tok.options['in-context'] || tok['in-context']); + tok.options['in-hypercontext'] = !!(tok.options['in-hypercontext'] || tok['in-hypercontext']); + tok.options.ci = tok.ci = !!(tok.options.caseInsesitive || tok.options.ci || tok.caseInsesitive || tok.ci); + tok.options.autocomplete = !!(tok.options.autocomplete || tok.autocomplete); + tok.options.mode = tok.options.mode || tok.mode; } else if ( 'block' === tok.type || 'comment' === tok.type ) { - tok.multiline = tok[HAS]('multiline') ? !!tok.multiline : true; + tok.multiline = HAS.call(tok,'multiline') ? !!tok.multiline : true; if ( !(T_STR & get_type(tok.escape)) ) tok.escape = false; } else if ( 'simple' === tok.type ) { //tok.autocomplete = !!tok.autocomplete; tok.meta = !!tok.autocomplete && (T_STR & get_type(tok.meta)) ? tok.meta : null; - //tok.combine = !tok[HAS]('combine') ? true : tok.combine; + //tok.combine = !HAS.call(tok,'combine') ? true : tok.combine; tok.ci = !!(tok.caseInsesitive||tok.ci); } } @@ -1220,7 +1241,7 @@ function preprocess_grammar( grammar ) G = Syntax; for (id in G) { - if ( !G[HAS](id) ) continue; + if ( !HAS.call(G,id) ) continue; tok = G[id]; if ( T_OBJ === get_type(tok) && !tok.type ) { @@ -1351,19 +1372,27 @@ function preprocess_grammar( grammar ) function generate_dynamic_autocompletion( state, follows ) { follows = follows || []; - var list, symb; + var list, symb, n, entry; list = state.ctx; while ( list ) { symb = list.val.symb; while ( symb ) { - if ( symb.val[1][7] ) + entry = symb.val[1]; + if ( entry[7] ) { - follows.push( {word:symb.val[1][5], meta:(symb.val[1][6]||'')+' at ('+(symb.val[1][0]+1)+','+(symb.val[1][1]+1)+')', ci:symb.val[1][8], token:symb.val[1][6], pos:[symb.val[1][0]+1,symb.val[1][1]+1,symb.val[1][2]+1,symb.val[1][3]+1]} ); + follows.push( {word:entry[5], meta:(entry[6]||'')+' at ('+(entry[0]+1)+','+(entry[1]+1)+')', ci:entry[8], token:entry[6], pos:[entry[0]+1,entry[1]+1,entry[2]+1,entry[3]+1]} ); } symb = symb.prev; } + symb = list.val.tabl; + for(n in symb) + { + if ( !HAS.call(symb, n) || !symb[n][7] ) continue; + entry = symb[n]; + follows.push( {word:entry[5], meta:(entry[6]||'')+' at ('+(entry[0]+1)+','+(entry[1]+1)+')', ci:entry[8], token:entry[6], pos:[entry[0]+1,entry[1]+1,entry[2]+1,entry[3]+1]} ); + } list = list.prev; } list = state.hctx; @@ -1372,23 +1401,39 @@ function generate_dynamic_autocompletion( state, follows ) symb = list.val.symb; while ( symb ) { - if ( symb.val[1][7] ) + entry = symb.val[1]; + if ( entry[7] ) { - follows.push( {word:symb.val[1][5], meta:(symb.val[1][6]||'')+' at ('+(symb.val[1][0]+1)+','+(symb.val[1][1]+1)+')', ci:symb.val[1][8], token:symb.val[1][6], pos:[symb.val[1][0]+1,symb.val[1][1]+1,symb.val[1][2]+1,symb.val[1][3]+1]} ); + follows.push( {word:entry[5], meta:(entry[6]||'')+' at ('+(entry[0]+1)+','+(entry[1]+1)+')', ci:entry[8], token:entry[6], pos:[entry[0]+1,entry[1]+1,entry[2]+1,entry[3]+1]} ); } symb = symb.prev; } + symb = list.val.tabl; + for(n in symb) + { + if ( !HAS.call(symb, n) || !symb[n][7] ) continue; + entry = symb[n]; + follows.push( {word:entry[5], meta:(entry[6]||'')+' at ('+(entry[0]+1)+','+(entry[1]+1)+')', ci:entry[8], token:entry[6], pos:[entry[0]+1,entry[1]+1,entry[2]+1,entry[3]+1]} ); + } list = list.prev; } symb = state.symb; while ( symb ) { - if ( symb.val[1][7] ) + entry = symb.val[1]; + if ( entry[7] ) { - follows.push( {word:symb.val[1][5], meta:(symb.val[1][6]||'')+' at ('+(symb.val[1][0]+1)+','+(symb.val[1][1]+1)+')', ci:symb.val[1][8], token:symb.val[1][6], pos:[symb.val[1][0]+1,symb.val[1][1]+1,symb.val[1][2]+1,symb.val[1][3]+1]} ); + follows.push( {word:entry[5], meta:(entry[6]||'')+' at ('+(entry[0]+1)+','+(entry[1]+1)+')', ci:entry[8], token:entry[6], pos:[entry[0]+1,entry[1]+1,entry[2]+1,entry[3]+1]} ); } symb = symb.prev; } + symb = state.tabl; + for(n in symb) + { + if ( !HAS.call(symb, n) || !symb[n][7] ) continue; + entry = symb[n]; + follows.push( {word:entry[5], meta:(entry[6]||'')+' at ('+(entry[0]+1)+','+(entry[1]+1)+')', ci:entry[8], token:entry[6], pos:[entry[0]+1,entry[1]+1,entry[2]+1,entry[3]+1]} ); + } return follows; } function generate_autocompletion( token, follows, hash, dynamic ) @@ -1423,7 +1468,7 @@ function generate_autocompletion( token, follows, hash, dynamic ) for(j=0,m=tok.autocompletions.length; j 1) ) { - if ( !hash[HAS]('w_'+tok.token.pattern) ) + if ( !HAS.call(hash,'w_'+tok.token.pattern) ) { follows.push( {word:''+tok.token.pattern, meta:tok.name, ci:!!tok.ci} ); hash['w_'+tok.token.pattern] = 1; @@ -1994,25 +2039,32 @@ function get_tokenizer( tokenID, RegExpID, Lex, Syntax, Style, if ( T_ACTION & $type$ ) { - if ( !token[HAS]('action') ) - { - if ( token[HAS]('nop') ) token.action = [A_NOP, token.nop, !!token['in-context'], !!token['in-hypercontext'], false]; - else if ( token[HAS]('error') ) token.action = [A_ERROR, token.error, false, false, false]; - else if ( token[HAS]('context') ) token.action = [!!token.context?A_CTXSTART:A_CTXEND, token['context'], false, false, false]; - else if ( token[HAS]('hypercontext') ) token.action = [!!token.hypercontext?A_HYPCTXSTART:A_HYPCTXEND, token['hypercontext'], false, false, false]; - else if ( token[HAS]('context-start') ) token.action = [A_CTXSTART, token['context-start'], false, false, false]; - else if ( token[HAS]('context-end') ) token.action = [A_CTXEND, token['context-end'], false, false, false]; - else if ( token[HAS]('hypercontext-start') ) token.action = [A_HYPCTXSTART, token['hypcontext-start'], false, false, false]; - else if ( token[HAS]('hypercontext-end') ) token.action = [A_HYPCTXEND, token['hypcontext-end'], false, false, false]; - else if ( token[HAS]('push') ) token.action = [A_MCHSTART, token.push, !!token['in-context'], !!token['in-hypercontext'], token['autocomplete']]; - else if ( token[HAS]('pop') ) token.action = [A_MCHEND, token.pop, !!token['in-context'], !!token['in-hypercontext'], false]; - else if ( token[HAS]('define') ) token.action = [A_DEFINE, T_STR&get_type(token.define)?['*',token.define]:token.define, !!token['in-context'], !!token['in-hypercontext'], token['autocomplete']]; - else if ( token[HAS]('undefine') ) token.action = [A_UNDEFINE, T_STR&get_type(token.undefine)?['*',token.undefine]:token.undefine, !!token['in-context'], !!token['in-hypercontext'], token['autocomplete']]; - else if ( token[HAS]('defined') ) token.action = [A_DEFINED, T_STR&get_type(token.defined)?['*',token.defined]:token.defined, !!token['in-context'], !!token['in-hypercontext'], false]; - else if ( token[HAS]('notdefined') ) token.action = [A_NOTDEFINED, T_STR&get_type(token.notdefined)?['*',token.notdefined]:token.notdefined, !!token['in-context'], !!token['in-hypercontext'], false]; - else if ( token[HAS]('unique') ) token.action = [A_UNIQUE, T_STR&get_type(token.unique)?['*',token.unique]:token.unique, !!token['in-context'], !!token['in-hypercontext'], token['autocomplete']]; - else if ( token[HAS]('indent') ) token.action = [A_INDENT, token.indent, !!token['in-context'], !!token['in-hypercontext'], false]; - else if ( token[HAS]('outdent') ) token.action = [A_OUTDENT, token.outdent, !!token['in-context'], !!token['in-hypercontext'], false]; + token.options = token.options||{}; + token.options['in-context'] = !!(token.options['in-context'] || token['in-context']); + token.options['in-hypercontext'] = !!(token.options['in-hypercontext'] || token['in-hypercontext']); + token.options.ci = token.ci = !!(token.options.caseInsesitive || token.options.ci || token.caseInsesitive || token.ci); + token.options.autocomplete = !!(token.options.autocomplete || token.autocomplete); + token.options.mode = token.options.mode || token.mode; + + if ( !HAS.call(token,'action') ) + { + if ( HAS.call(token,'nop') ) token.action = [A_NOP, token.nop, token['options']]; + else if ( HAS.call(token,'error') ) token.action = [A_ERROR, token.error, token['options']]; + else if ( HAS.call(token,'context') ) token.action = [!!token.context?A_CTXSTART:A_CTXEND, token['context'], token['options']]; + else if ( HAS.call(token,'hypercontext') ) token.action = [!!token.hypercontext?A_HYPCTXSTART:A_HYPCTXEND, token['hypercontext'], token['options']]; + else if ( HAS.call(token,'context-start') ) token.action = [A_CTXSTART, token['context-start'], token['options']]; + else if ( HAS.call(token,'context-end') ) token.action = [A_CTXEND, token['context-end'], token['options']]; + else if ( HAS.call(token,'hypercontext-start') ) token.action = [A_HYPCTXSTART, token['hypcontext-start'], token['options']]; + else if ( HAS.call(token,'hypercontext-end') ) token.action = [A_HYPCTXEND, token['hypcontext-end'], token['options']]; + else if ( HAS.call(token,'push') ) token.action = [A_MCHSTART, token.push, token['options']]; + else if ( HAS.call(token,'pop') ) token.action = [A_MCHEND, token.pop, token['options']]; + else if ( HAS.call(token,'define') ) token.action = [A_DEFINE, T_STR&get_type(token.define)?['*',token.define]:token.define, token['options']]; + else if ( HAS.call(token,'undefine') ) token.action = [A_UNDEFINE, T_STR&get_type(token.undefine)?['*',token.undefine]:token.undefine, token['options']]; + else if ( HAS.call(token,'defined') ) token.action = [A_DEFINED, T_STR&get_type(token.defined)?['*',token.defined]:token.defined, token['options']]; + else if ( HAS.call(token,'notdefined') ) token.action = [A_NOTDEFINED, T_STR&get_type(token.notdefined)?['*',token.notdefined]:token.notdefined, token['options']]; + else if ( HAS.call(token,'unique') ) token.action = [A_UNIQUE, T_STR&get_type(token.unique)?['*',token.unique]:token.unique, token['options']]; + else if ( HAS.call(token,'indent') ) token.action = [A_INDENT, token.indent, token['options']]; + else if ( HAS.call(token,'outdent') ) token.action = [A_OUTDENT, token.outdent, token['options']]; } else { @@ -2035,8 +2087,9 @@ function get_tokenizer( tokenID, RegExpID, Lex, Syntax, Style, if ( false === token.msg ) $msg$ = false; // NOP action, no action if ( token.nop ) token.action[0] = A_NOP; + //if ( token.action.length < 3 ) token.action.push( token.options ); $token$ = new tokenizer( T_ACTION, tokenID, token.action.slice(), $msg$, $modifier$ ); - $token$.ci = !!token.caseInsensitive||token.ci; + $token$.ci = !!(token.options.caseInsensitive || token.options.ci || token.caseInsensitive || token.ci); // pre-cache tokenizer to handle recursive calls to same tokenizer cachedTokens[ tokenID ] = $token$; } @@ -2099,9 +2152,9 @@ function get_tokenizer( tokenID, RegExpID, Lex, Syntax, Style, get_blockmatcher( tokenID, $tokens$.slice(), RegExpID, cachedRegexes, cachedMatchers ), $msg$ ); - $token$.empty = token[HAS]('empty') ? !!token.empty : true; - $token$.mline = token[HAS]('multiline') ? !!token.multiline : true; - $token$.esc = token[HAS]('escape') ? token.escape : false; + $token$.empty = HAS.call(token,'empty') ? !!token.empty : true; + $token$.mline = HAS.call(token,'multiline') ? !!token.multiline : true; + $token$.esc = HAS.call(token,'escape') ? token.escape : false; // allow block delims / block interior to have different styles $token$.inter = !!Style[ tokenID + '.inside' ]; if ( (T_COMMENT === $type$) && token.interleave ) interleavedTokens.push( t_clone( $token$ ) ); @@ -2196,14 +2249,14 @@ function get_block_types( grammar, the_styles ) blocks = [], visited = {}; for (t in Style ) { - if ( !Style[HAS](t) ) continue; + if ( !HAS.call(Style,t) ) continue; T = Lex[t] || Syntax[t]; if ( T && ('block' == T.type || 'comment' === T.type) ) { if ( the_styles && (Style[ t+'.inside' ]||Style[ t ]) ) { t = Style[ t+'.inside' ] || Style[ t ]; - if ( !visited[HAS](t) ) + if ( !HAS.call(visited,t) ) { blocks.push( t ); visited[t] = 1; @@ -2211,7 +2264,7 @@ function get_block_types( grammar, the_styles ) } else if ( !the_styles ) { - if ( !visited[HAS](t) ) + if ( !HAS.call(visited,t) ) { blocks.push( t ); visited[t] = 1; @@ -2610,58 +2663,63 @@ function error_( state, l1, c1, l2, c2, t, err ) //return state; } -function find_key( list, key/*, recursive, least, hash*/ ) +function find_key( list, key, hash ) { - /*if ( hash ) + var match = null; + if ( hash ) { - return list && list[HAS](key) ? list[key] : null; - } - else if ( recursive ) - { - var nodeNext, listNext, node, match; - listNext = null; - while ( list ) + if ( list && HAS.call(list,key) ) { - node = list.val.symb; nodeNext = null; - while ( node ) - { - if ( key === node.val[0] ) - { - match = {list:list, listPrev:list.prev, listNext:listNext, node:node, nodePrev:node.prev, nodeNext:nodeNext, val:node.val[1]}; - return match; - } - nodeNext = node; node = node.prev; - } - listNext = list; list = list.prev; + match = {list:list, key:key, val:list[key]}; } } else - {*/ - var next = null, match = null; + { + var next = null, root = list; while ( list ) { if ( key === list.val[0] ) { - match = {node:list, nodePrev:list.prev, nodeNext:next, val:list.val[1]}; - /*if ( !least )*/ return match; + match = {list:root, node:list, nodePrev:list.prev, nodeNext:next, key:key, val:list.val[1]}; + break; } next = list; list = list.prev; } - return match; - /*}*/ + } + return match; } -function add_key( list, key, val/*, hash*/ ) +function add_key( list, key, val, hash ) { - /*if ( hash ) + if ( hash ) { list[key] = val; return list; } else - {*/ + { return new Stack([key,val], list); - /*}*/ + } +} + +function del_key( match, hash ) +{ + if ( hash ) + { + delete match.list[match.key]; + } + else + { + if ( match.nodeNext ) + { + match.nodeNext.prev = match.nodePrev; + } + else + { + match.list = match.list.prev; + } + } + return match.list; } function push_at( state, pos, token ) @@ -2808,9 +2866,9 @@ function t_action( a, stream, state, token ) { var self = a, action_def = self.token || null, action, case_insensitive = self.ci, aid = self.name, - t, t0, ns, msg, queu, symb, found, autocomplete, + t, t0, ns, msg, queu, symb, found, raw = false, l1, c1, l2, c2, in_ctx, in_hctx, err, t_str, is_block, - no_state_errors = !(state.status & ERRORS); + options, hash, list, no_state_errors = !(state.status & ERRORS); self.status = 0; self.$msg = null; @@ -2820,20 +2878,22 @@ function t_action( a, stream, state, token ) // NOP action, return OR partial block not completed yet, postpone if ( A_NOP === action_def[ 0 ] || is_block && !token.block ) return true; - action = action_def[ 0 ]; t = action_def[ 1 ]; in_ctx = action_def[ 2 ]; in_hctx = action_def[ 3 ]; - autocomplete = action_def[ 4 ]; msg = self.msg; + action = action_def[ 0 ]; t = action_def[ 1 ]; options = action_def[ 2 ] || {}; msg = self.msg; + in_ctx = options['in-context']; in_hctx = options['in-hypercontext']; if ( is_block /*&& token.block*/ ) { t_str = token.block.match || token.block.str; l1 = token.block.pos[0][0]; c1 = token.block.pos[0][1]; l2 = token.block.pos[0][2]; c2 = token.block.pos[0][3]; + raw = true; } else { t_str = token.match || token.str; l1 = token.pos[0]; c1 = token.pos[1]; l2 = token.pos[2]; c2 = token.pos[3]; + raw = false; } if ( A_CTXEND === action ) @@ -2843,7 +2903,7 @@ function t_action( a, stream, state, token ) else if ( A_CTXSTART === action ) { - state.ctx = new Stack({symb:null,queu:null}, state.ctx); + state.ctx = new Stack({tabl:{},symb:null,queu:null}, state.ctx); } else if ( A_HYPCTXEND === action ) @@ -2853,150 +2913,92 @@ function t_action( a, stream, state, token ) else if ( A_HYPCTXSTART === action ) { - state.hctx = new Stack({symb:null,queu:null}, state.hctx); + state.hctx = new Stack({tabl:{},symb:null,queu:null}, state.hctx); } else if ( A_DEFINE === action ) { + hash = "hash" === options.mode; + list = hash ? "tabl" : "symb"; t0 = t[1]; ns = t[0]; - t0 = group_replace( t0, t_str, true ); + t0 = group_replace( t0, t_str, raw ); if ( case_insensitive ) t0 = t0[LOWER](); ns += '::'+t0; if ( in_hctx && state.hctx ) { - found = find_key(state.hctx.val.symb, ns); + found = find_key(state.hctx.val[list], ns, hash); } else if ( in_ctx && state.ctx ) { - found = find_key(state.ctx.val.symb, ns); - } - else if ( state.symb ) - { - found = find_key(state.symb, ns); + found = find_key(state.ctx.val[list], ns, hash); } else { - found = null; + found = find_key(state[list], ns, hash); } - if ( !found /*|| (found.val[0] > l1) || ((found.val[0] === l1) && (found.val[1] > c1)) || ((found.val[0] === l1) && (found.val[1] === c1) && ((found.val[2] > l2) || (found.val[3] > c2)))*/ ) + if ( !found ) { - /*if ( found ) - { - found.val[0] = l1; found.val[1] = c1; - found.val[2] = l2; found.val[3] = c2; - } - else - {*/ if ( in_hctx && state.hctx ) - { - state.hctx.val.symb = add_key(state.hctx.val.symb, ns, [l1, c1, l2, c2, ns, t0, token.type, autocomplete, case_insensitive]); - } + state.hctx.val[list] = add_key(state.hctx.val[list], ns, [l1, c1, l2, c2, ns, t0, token.type, !!options.autocomplete, case_insensitive], hash); else if ( in_ctx && state.ctx ) - { - state.ctx.val.symb = add_key(state.ctx.val.symb, ns, [l1, c1, l2, c2, ns, t0, token.type, autocomplete, case_insensitive]); - } + state.ctx.val[list] = add_key(state.ctx.val[list], ns, [l1, c1, l2, c2, ns, t0, token.type, !!options.autocomplete, case_insensitive], hash); else - { - state.symb = add_key(state.symb, ns, [l1, c1, l2, c2, ns, t0, token.type, autocomplete, case_insensitive]); - } - /*}*/ + state[list] = add_key(state[list], ns, [l1, c1, l2, c2, ns, t0, token.type, !!options.autocomplete, case_insensitive], hash); } } else if ( A_UNDEFINE === action ) { + hash = "hash" === options.mode; + list = hash ? "tabl" : "symb"; t0 = t[1]; ns = t[0]; - t0 = group_replace( t0, t_str, true ); + t0 = group_replace( t0, t_str, raw ); if ( case_insensitive ) t0 = t0[LOWER](); ns += '::'+t0; if ( in_hctx && state.hctx ) { - found = find_key(state.hctx.val.symb, ns); + found = find_key(state.hctx.val[list], ns, hash); } else if ( in_ctx && state.ctx ) { - found = find_key(state.ctx.val.symb, ns); - } - else if ( state.symb ) - { - found = find_key(state.symb, ns); + found = find_key(state.ctx.val[list], ns, hash); } else { - return true; + found = find_key(state[list], ns, hash); } - if ( found /*&& ((found.val[0] < l1) || ((found.val[0] === l1) && (found.val[1] <= c1)))*/ ) + if ( found ) { - /*if ( found.list ) - { - if ( found.nodeNext ) - { - found.nodeNext.prev = found.nodePrev; - } - else - { - if ( in_hctx && state.hctx ) - { - state.hctx.val.symb = found.listPrev; - } - else if ( in_ctx && state.ctx ) - { - state.ctx.val.symb = found.listPrev; - } - else - { - state.symb = found.listPrev; - } - } - } + if ( in_hctx && state.hctx ) + state.hctx.val[list] = del_key( found, hash ); + else if ( in_ctx && state.ctx ) + state.ctx.val[list] = del_key( found, hash ); else - {*/ - if ( found.nodeNext ) - { - found.nodeNext.prev = found.nodePrev; - } - else - { - if ( in_hctx && state.hctx ) - { - state.hctx.val.symb = state.hctx.val.symb.prev; - } - else if ( in_ctx && state.ctx ) - { - state.ctx.val.symb = state.ctx.val.symb.prev; - } - else - { - state.symb = state.symb.prev; - } - } - /*}*/ + state[list] = del_key( found, hash ); } } else if ( A_DEFINED === action ) { + hash = "hash" === options.mode; + list = hash ? "tabl" : "symb"; t0 = t[1]; ns = t[0]; - t0 = group_replace( t0, t_str, true ); + t0 = group_replace( t0, t_str, raw ); if ( case_insensitive ) t0 = t0[LOWER](); ns += '::'+t0; if ( in_hctx && state.hctx ) { - found = find_key(state.hctx.val.symb, ns); + found = find_key(state.hctx.val[list], ns, hash); } else if ( in_ctx && state.ctx ) { - found = find_key(state.ctx.val.symb, ns); - } - else if ( state.symb ) - { - found = find_key(state.symb, ns); + found = find_key(state.ctx.val[list], ns, hash); } else { - found = null; + found = find_key(state[list], ns, hash); } - if ( !found /*|| (found.val[0] > l1) || ((found.val[0] === l1) && (found.val[1] > c1)) || ((found.val[0] === l1) && (found.val[1] === c1) && ((found.val[2] > l2) || (found.val[3] > c2)))*/ ) + if ( !found ) { // undefined if ( false !== msg ) @@ -3014,27 +3016,25 @@ function t_action( a, stream, state, token ) else if ( A_NOTDEFINED === action ) { + hash = "hash" === options.mode; + list = hash ? "tabl" : "symb"; t0 = t[1]; ns = t[0]; - t0 = group_replace( t0, t_str, true ); + t0 = group_replace( t0, t_str, raw ); if ( case_insensitive ) t0 = t0[LOWER](); ns += '::'+t0; if ( in_hctx && state.hctx ) { - found = find_key(state.hctx.val.symb, ns); + found = find_key(state.hctx.val[list], ns, hash); } else if ( in_ctx && state.ctx ) { - found = find_key(state.ctx.val.symb, ns); - } - else if ( state.symb ) - { - found = find_key(state.symb, ns); + found = find_key(state.ctx.val[list], ns, hash); } else { - return true; + found = find_key(state[list], ns, hash); } - if ( found /*&& ((found.val[0] < l1) || ((found.val[0] === l1) && (found.val[1] <= c1)) || ((found.val[0] === l1) && (found.val[1] === c1) && ((found.val[2] <= l2) && (found.val[3] <= c2))))*/ ) + if ( found ) { // defined if ( false !== msg ) @@ -3065,24 +3065,26 @@ function t_action( a, stream, state, token ) else if ( A_UNIQUE === action ) { + hash = "hash" === options.mode; + list = hash ? "tabl" : "symb"; if ( in_hctx ) { - if ( state.hctx ) symb = state.hctx.val.symb; + if ( state.hctx ) symb = state.hctx.val[list]; else return true; } else if ( in_ctx ) { - if ( state.ctx ) symb = state.ctx.val.symb; + if ( state.ctx ) symb = state.ctx.val[list]; else return true; } else { - symb = state.symb; + symb = state[list]; } t0 = t[1]; ns = t[0]; - t0 = group_replace( t0, t_str, true ); + t0 = group_replace( t0, t_str, raw ); if ( case_insensitive ) t0 = t0[LOWER](); - ns += '::'+t0; found = find_key(symb, ns); + ns += '::'+t0; found = find_key(symb, ns, hash); if ( found ) { // duplicate @@ -3101,17 +3103,11 @@ function t_action( a, stream, state, token ) else { if ( in_hctx ) - { - state.hctx.val.symb = add_key(state.hctx.val.symb, ns, [l1, c1, l2, c2, ns, t0, token.type, autocomplete, case_insensitive]); - } + state.hctx.val[list] = add_key(state.hctx.val[list], ns, [l1, c1, l2, c2, ns, t0, token.type, !!options.autocomplete, case_insensitive], hash); else if ( in_ctx ) - { - state.ctx.val.symb = add_key(state.ctx.val.symb, ns, [l1, c1, l2, c2, ns, t0, token.type, autocomplete, case_insensitive]); - } + state.ctx.val[list] = add_key(state.ctx.val[list], ns, [l1, c1, l2, c2, ns, t0, token.type, !!options.autocomplete, case_insensitive], hash); else - { - state.symb = add_key(state.symb, ns, [l1, c1, l2, c2, ns, t0, token.type, autocomplete, case_insensitive]); - } + state[list] = add_key(state[list], ns, [l1, c1, l2, c2, ns, t0, token.type, !!options.autocomplete, case_insensitive], hash); } } @@ -3133,7 +3129,7 @@ function t_action( a, stream, state, token ) } if ( t ) { - t = group_replace( t, t_str ); + t = group_replace( t, t_str, raw ); if ( case_insensitive ) t = t[LOWER](); if ( !queu || t !== queu.val[0] ) { @@ -3214,7 +3210,7 @@ function t_action( a, stream, state, token ) { queu = state.queu; } - t = group_replace( t, t_str ); + t = group_replace( t, t_str, raw ); if ( case_insensitive ) t = t[LOWER](); self.$msg = msg ? group_replace( msg, t, true ) @@ -3801,8 +3797,9 @@ function State( unique, s ) self.outer = s.outer ? [s.outer[0], s.outer[1], new State(unique, s.outer[2])] : null; self.queu = s.queu || null; self.symb = s.symb || null; - self.ctx = s.ctx ? new Stack({symb:s.ctx.val.symb,queu:s.ctx.val.queu}, s.ctx.prev) : null; - self.hctx = s.hctx ? new Stack({symb:s.hctx.val.symb,queu:s.hctx.val.queu}, s.hctx.prev) : null; + self.tabl = s.tabl || null; + self.ctx = s.ctx ? new Stack({tabl:s.ctx.val.tabl,symb:s.ctx.val.symb,queu:s.ctx.val.queu}, s.ctx.prev) : null; + self.hctx = s.hctx ? new Stack({tabl:s.hctx.val.tabl,symb:s.hctx.val.symb,queu:s.hctx.val.queu}, s.hctx.prev) : null; self.err = s.err || null; self.$eol$ = s.$eol$; self.$blank$ = s.$blank$; } @@ -3818,6 +3815,7 @@ function State( unique, s ) self.outer = null; self.queu = null; self.symb = null; + self.tabl = {}; self.ctx = null; self.hctx = null; self.err = self.status & ERRORS ? {} : null; @@ -3867,6 +3865,7 @@ function state_dispose( state ) state.outer = null; state.queu = null; state.symb = null; + state.tabl = null; state.ctx = null; state.hctx = null; state.err = null; @@ -4462,27 +4461,30 @@ var Parser = Class({ return ret; } - ,autocompletion: function( state, min_found, dynamic ) { - var stack = state.stack, token, type, - hash = {}, dynToks = dynamic ? generate_dynamic_autocompletion( state ) : null, - follows = generate_autocompletion( [ state.token ], [], hash, dynToks ); + ,autocompletion: function( state, min_found, dynamic_tokens ) { + var stack = state.stack, token, type, hash = {}, + follows = generate_autocompletion( [ state.token ], [], hash, dynamic_tokens ); min_found = min_found || 0; while( stack ) { token = stack.val; type = token.type; if ( T_REPEATED & type ) { - follows = generate_autocompletion( [ token ], follows, hash, dynToks ); + follows = generate_autocompletion( [ token ], follows, hash, dynamic_tokens ); if ( (0 < token.min) && (min_found < follows.length) ) break; } else if ( (T_SIMPLE === type) || (T_ALTERNATION === type) || (T_SEQUENCE_OR_NGRAM & type) ) { - follows = generate_autocompletion( [ token ], follows, hash, dynToks ); + follows = generate_autocompletion( [ token ], follows, hash, dynamic_tokens ); if ( min_found < follows.length ) break; } stack = stack.prev; } - return dynToks && dynToks.length ? dynToks.concat(follows) : follows; + return dynamic_tokens && dynamic_tokens.length ? dynamic_tokens.concat(follows) : follows; + } + + ,dynamic_autocompletion: function( state ) { + return state ? generate_dynamic_autocompletion( state ) || null : null; } // overriden @@ -4491,7 +4493,7 @@ var Parser = Class({ if ( false === parser ) { // remove - if ( self.$subgrammars[HAS](name) ) + if ( HAS.call(self.$subgrammars,name) ) delete self.$subgrammars[name]; } else if ( parser ) @@ -4910,7 +4912,7 @@ var Matcher = { /** * * CodeMirrorGrammar -* @version: 4.2.0 +* @version: 4.2.1 * * Transform a grammar specification in JSON format, into a syntax-highlight parser mode for CodeMirror * https://github.com/foo123/codemirror-grammar @@ -5055,12 +5057,12 @@ var CodeMirrorParser = Class(Parser, { if ( !code_errors ) return errors; options = options || {}; - err_type = options[HAS]('type') ? options.type : "error"; - err_msg = options[HAS]('msg') ? options.msg : "Syntax Error"; + err_type = HAS.call(options,'type') ? options.type : "error"; + err_msg = HAS.call(options,'msg') ? options.msg : "Syntax Error"; for (err in code_errors) { - if ( !code_errors[HAS](err) ) continue; + if ( !HAS.call(code_errors,err) ) continue; error = code_errors[err]; errors.push({ message: error[4] || err_msg, @@ -5075,16 +5077,18 @@ var CodeMirrorParser = Class(Parser, { // adapted from codemirror anyword-hint helper ,autocomplete: function( cm, options, CodeMirror ) { options = options || {}; - var parser = this, list = [], - prefix_match = options[HAS]('prefixMatch') ? !!options.prefixMatch : true, - in_context = options[HAS]('inContext')? !!options.inContext : false, - dynamic = options[HAS]('dynamic')? !!options.dynamic : false, - case_insensitive_match = options[HAS]('caseInsensitiveMatch') ? !!options.caseInsensitiveMatch : false, + var parser = this, state, list = [], + prefix_match = HAS.call(options,'prefixMatch') ? !!options.prefixMatch : true, + in_context = HAS.call(options,'inContext')? !!options.inContext : false, + dynamic = HAS.call(options,'dynamic')? !!options.dynamic : false, + case_insensitive_match = HAS.call(options,'caseInsensitiveMatch') ? !!options.caseInsensitiveMatch : false, cur = cm.getCursor(), curLine, start0 = cur.ch, start = start0, end0 = start0, end = end0, - token, token_i, len, maxlen = 0, word_re, renderer, - case_insensitive_match, prefix_match, in_context, dynamic, sort_by_score, score; - if ( dynamic || !!parser.$grammar.$autocomplete ) + token, token_i, len, maxlen = 0, word_re, renderer, sort_by_score, score, + grammar_tokens = parser.$grammar.$autocomplete && parser.$grammar.$autocomplete.length ? parser.$grammar.$autocomplete : null, + dynamic_tokens + ; + if ( dynamic || grammar_tokens ) { word_re = options.word || RE_W; curLine = cm.getLine(cur.line); while (start && word_re.test(curLine[CHAR](start - 1))) --start; @@ -5094,6 +5098,8 @@ var CodeMirrorParser = Class(Parser, { renderer = options.renderer || null; sort_by_score = false; score = 1000; + state = cm.getTokenAt( CodeMirror.Pos( cur.line, start ), true ).state.state; + var suggest = function suggest( list, word ){ var w = word.word, wl = w.length, wm, case_insensitive_word, @@ -5137,20 +5143,18 @@ var CodeMirrorParser = Class(Parser, { return list; }; - if ( dynamic || in_context ) + dynamic_tokens = dynamic ? parser.dynamic_autocompletion( state ) : null; + + if ( in_context ) { sort_by_score = false; - list = operate(parser.autocompletion( cm.getTokenAt( CodeMirror.Pos( cur.line, start ), true ).state.state, null, dynamic ), suggest, list); - if ( !list.length && !!self.$grammar.$autocomplete ) - { - sort_by_score = true; - list = operate(parser.$grammar.$autocomplete, suggest, list); - } + list = operate(parser.autocompletion( state, null, dynamic_tokens ), suggest, list); } - else + if ( dynamic_tokens && !dynamic_tokens.length ) dynamic_tokens = null; + if ( !list.length && (dynamic_tokens || grammar_tokens) ) { sort_by_score = true; - list = operate(parser.$grammar.$autocomplete, suggest, list); + list = operate((dynamic_tokens || []).concat(grammar_tokens || []), suggest, list); } if ( list.length ) list = list.sort( by_score ); list.maxlen = maxlen; @@ -5331,7 +5335,7 @@ function get_mode( grammar, DEFAULT, CodeMirror ) { var s = cm.getTokenAt( cm.getCursor() ).state, parser = (s && s.parser) || CMode.$parser; options = autocompleter.options /*|| Mode.autocompleter.options*/ || options || {}; - if ( !options[HAS]('renderer') ) options.renderer = autocompleter.renderer /*|| Mode.autocompleter.renderer*/ || autocomplete_renderer; + if ( !HAS.call(options,'renderer') ) options.renderer = autocompleter.renderer /*|| Mode.autocompleter.renderer*/ || autocomplete_renderer; return parser.autocomplete( cm, options, CodeMirror ); } }; @@ -5454,7 +5458,7 @@ function get_mode( grammar, DEFAULT, CodeMirror ) [/DOC_MARKDOWN]**/ var CodeMirrorGrammar = { - VERSION: "4.2.0", + VERSION: "4.2.1", // clone a grammar /**[DOC_MARKDOWN] diff --git a/build/codemirror_grammar.min.js b/build/codemirror_grammar.min.js index 680172d..40c1455 100644 --- a/build/codemirror_grammar.min.js +++ b/build/codemirror_grammar.min.js @@ -1,11 +1,11 @@ /** * * CodeMirrorGrammar -* @version: 4.2.0 +* @version: 4.2.1 * * Transform a grammar specification in JSON format, into a syntax-highlight parser mode for CodeMirror * https://github.com/foo123/codemirror-grammar * https://github.com/foo123/editor-grammar * -**/!function(e,t,n){"use strict";"object"==typeof module&&module.exports?(module.$deps=module.$deps||{})&&(module.exports=module.$deps[t]=n.call(e)):"function"==typeof define&&define.amd&&"function"==typeof require&&"function"==typeof require.specified&&require.specified(t)?define(t,["module"],function(t){return n.moduleUri=t.uri,n.call(e)}):t in e||(e[t]=n.call(e)||1)&&"function"==typeof define&&define.amd&&define(function(){return e[t]})}(this,"CodeMirrorGrammar",function(){"use strict";function e(e){var t=0;return null===e?t=_t:!0===e||!1===e||e instanceof Boolean?t=Nt:gt===e?t=Et:(t=Zt[bt.call(e)]||St,t=Pt===t||e instanceof Number?isNaN(e)?Dt:isFinite(e)?Pt:Tt:Ft===t||e instanceof String?1===e.length?At:Ft:Rt===t||e instanceof Array?Rt:zt===t||e instanceof RegExp?zt:Gt===t||e instanceof Date?Gt:Bt===t||e instanceof Function?Bt:jt===t?jt:St),t}function t(e,t,n,r){var o,l,s,i,a,u,c=e.length;if(arguments.length<4&&(r=c-1),0>r&&(r+=c),arguments.length<3&&(n=0),n>r)return[];if(n===r)return[t(e[n],n,n,r)];for(s=r-n+1,i=15&s,a=1&i,u=new Array(s),a&&(u[0]=t(e[n],n,n,r)),o=a;i>o;o+=2)l=n+o,u[o]=t(e[l],l,n,r),u[o+1]=t(e[l+1],l+1,n,r);for(o=i;s>o;o+=16)l=n+o,u[o]=t(e[l],l,n,r),u[o+1]=t(e[l+1],l+1,n,r),u[o+2]=t(e[l+2],l+2,n,r),u[o+3]=t(e[l+3],l+3,n,r),u[o+4]=t(e[l+4],l+4,n,r),u[o+5]=t(e[l+5],l+5,n,r),u[o+6]=t(e[l+6],l+6,n,r),u[o+7]=t(e[l+7],l+7,n,r),u[o+8]=t(e[l+8],l+8,n,r),u[o+9]=t(e[l+9],l+9,n,r),u[o+10]=t(e[l+10],l+10,n,r),u[o+11]=t(e[l+11],l+11,n,r),u[o+12]=t(e[l+12],l+12,n,r),u[o+13]=t(e[l+13],l+13,n,r),u[o+14]=t(e[l+14],l+14,n,r),u[o+15]=t(e[l+15],l+15,n,r);return u}function n(e,t,n,r,o){var l,s,i,a,u,c=e.length,p=n;if(arguments.length<5&&(o=c-1),0>o&&(o+=c),arguments.length<4&&(r=0),r>o)return p;if(r===o)return t(p,e[r],r);for(i=o-r+1,a=15&i,u=1&a,u&&(p=t(p,e[r],r)),l=u;a>l;l+=2)s=r+l,p=t(t(p,e[s],s),e[s+1],s+1);for(l=a;i>l;l+=16)s=r+l,p=t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(p,e[s],s),e[s+1],s+1),e[s+2],s+2),e[s+3],s+3),e[s+4],s+4),e[s+5],s+5),e[s+6],s+6),e[s+7],s+7),e[s+8],s+8),e[s+9],s+9),e[s+10],s+10),e[s+11],s+11),e[s+12],s+12),e[s+13],s+13),e[s+14],s+14),e[s+15],s+15);return p}function r(e,t,n,r){if(t>n)return r;if(t===n)return e(t,r,t,n),r;var o,l,s=n-t+1,i=15&s,a=1&i;for(a&&e(t,r,t,n),o=a;i>o;o+=2)l=t+o,e(l,r,t,n),e(++l,r,t,n);for(o=i;s>o;o+=16)l=t+o,e(l,r,t,n),e(++l,r,t,n),e(++l,r,t,n),e(++l,r,t,n),e(++l,r,t,n),e(++l,r,t,n),e(++l,r,t,n),e(++l,r,t,n),e(++l,r,t,n),e(++l,r,t,n),e(++l,r,t,n),e(++l,r,t,n),e(++l,r,t,n),e(++l,r,t,n),e(++l,r,t,n),e(++l,r,t,n);return r}function o(t,n){var r,l,s,i,a=e(t),u=0;if(Pt===e(n)?n>0?(u=n,n=!0):n=!1:n=!1!==n,jt===a){l={};for(s in t)t[xt](s)&&t[vt](s)&&(r=e(t[s]),jt===r?l[s]=n?o(t[s],u>0?u-1:n):t[s]:Rt===r?l[s]=n?o(t[s],u>0?u-1:n):t[s].slice():Gt===r?l[s]=new Date(t[s]):Ft&r?l[s]=t[s].slice():Pt&r?l[s]=0+t[s]:l[s]=t[s])}else if(Rt===a)for(i=t.length,l=new Array(i),s=0;i>s;s++)r=e(t[s]),jt===r?l[s]=n?o(t[s],u>0?u-1:n):t[s]:Rt===r?l[s]=n?o(t[s],u>0?u-1:n):t[s].slice():Gt===r?l[s]=new Date(t[s]):Ft&r?l[s]=t[s].slice():Pt&r?l[s]=0+t[s]:l[s]=t[s];else l=Gt===a?new Date(t):Ft&a?t.slice():Pt&a?0+t:t;return l}function l(){var t,n,r,s,i,a,u,c,p,f,m=arguments,h=m.length;if(1>h)return null;for(n=o(m[0]),r=1;h>r;r++)if(t=m[r])for(s in t)if(t[xt](s)&&t[vt](s))if(n[xt](s)&&n[vt](s)){if(p=e(n[s]),f=e(t[s]),jt===p&&jt===f)n[s]=l(n[s],t[s]);else if(Rt===p&&Rt===f){if(u=n[s],c=t[s],a=c.length,!a)continue;if(u.length)for(i=0;a>i;i++)0>u.indexOf(c[i])&&u.push(c[i]);else n[s]=c.slice()}}else n[s]=o(t[s]);return n}function s(){return!0}function i(t,n){return n||Rt!==e(t)?[t]:t}function a(t,n){return t=i(t),(n||Rt!==e(t[0]))&&(t=[t]),t}function u(t,n){return Ft&e(n)&&Ft&e(t)&&n.length&&n.length<=t.length&&n===t.substr(0,n.length)}function c(e,t,n){return n?e[t]=gt:delete e[t],e}function p(e){return(e||"id_")+ ++en}function f(e){return(e||"uuid")+"_"+ ++en+"_"+(new Date).getTime()}function m(){var t,n,r,o,l,s,i=arguments,a=i.length;for(t=i[0]||{},l=1;a>l;l++)if(n=i[l],jt===e(n))for(o in n)n[xt](o)&&n[vt](o)&&(r=n[o],s=e(r),Pt&s?t[o]=0+r:Gt&s?t[o]=new Date(r):Yt&s?t[o]=r.slice():t[o]=r);return t}function h(e,t){var n,r=arguments.length,o="constructor";return 0===r?(e=Object,t={}):1===r?(t=e||{},e=Object):(e=e||Object,t=t||{}),t[xt](o)||(t[o]=function(){}),n=t[o],delete t[o],n[yt]=m(wt(e[yt]),t),n[yt][o]=n,n}function d(e){return"&"===e?"&":"<"===e?"<":">"===e?">":'"'===e?""":"'"}function k(e){return"&#"+e.charCodeAt(0)+";"}function g(e,t){return e.replace(nn,t?d:k)}function y(e){return e.replace(tn,"\\$1")}function x(e,t){t=t||{l:0,x:0,i:0,g:0};var e=new RegExp(e,(t.g?"g":"")+(t.i?"i":""));return e.xflags=t,e}function v(e,t,n,r){var o,l=e.pos||0,s=e.length,i=t.length,a="";if(n)if(r)for(;s>l;)if(o=!1,n===e[Lt](l)&&(o=!0,l+=1),t===e.substr(l,i)){if(l+=i,!o)break;a+=t}else a+=e[Lt](l++);else for(;s>l;)if(o=!1,n===e[Lt](l)&&(o=!0,l+=1,a+=n),t===e.substr(l,i)){if(l+=i,!o)break;a+=t}else a+=e[Lt](l++);else for(;s>l;){if(t===e.substr(l,i)){l+=i;break}a+=e[Lt](l++)}return e.pos=l,a}function $(t,n,r,o){var l,s,i,a,u,c=!0===r?0:1,p=o?"\\":"$",f=o?92:36;for(Ft&e(n)&&(o&&(n=y(n)),n=[n,n,n],c=0),s=t.length,u="",l=0;s>l;)i=t[Lt](l),s>l+1&&p===i?(a=t.charCodeAt(l+1),f===a?(u+=p,l+=2):a>=48&&57>=a?(u+=n[c+a-48]||"",l+=2):(u+=i,l+=1)):(u+=i,l+=1);return u}function b(t,n,r,o){if(!t||(Pt|zt)&e(t))return t;var l,s=n?n.length||0:0,i="",a={g:0,i:0,x:0,l:0};if(Ft&e(o)?i=o:o&&(i=on),s&&t.substr(0,s)===n){var u,c,p,l,f,m=t.substr(s),h=m[Lt](0);for(l=m.length;l--&&(f=m[Lt](l),h!==f);)"i"===f.toLowerCase()?a.i=1:"x"===f.toLowerCase()?a.x=1:"l"===f.toLowerCase()&&(a.l=1);return u=m.substring(1,l),"^"===u.charAt(0)?(a.l=1,c="^("+u.slice(1)+")"):c="^("+u+")",p=c,(a.x||a.l||a.i)&&(c=(a.l?"l":"")+(a.x?"x":"")+(a.i?"i":"")+"::"+c),r[c]||(p=x(p,a),r[c]=p),r[c]}return i?(p=c="^("+y(t)+")"+i,r[c]||(p=x(p,a),r[c]=p),r[c]):t}function w(n,r,o){var l,s="";return Ft&e(r)?s=r:r&&(s=on),l=t(n.sort(Jt),y).join("|"),[x("^("+l+")"+s,{l:0,x:0,i:o?1:0}),1]}function C(t,n,r,o){var l=e(n);if(Pt===l)return n;if(o[t])return o[t];r=r||0;var s,i=0;return n&&n.isCharList&&(i=1,c(n,"isCharList")),s=_t===l?new R(Ae,t,n,_t,r):At===l?new R(Ae,t,n,At,r):Ht&l?new R(Ae,t,n,zt,r):Ft&l?new R(Ae,t,n,i?It:Ft,r):n,o[t]=s}function O(t,n,r,o,l,s,a,c){if(a[t])return a[t];var p,f,m,h,d,k,g,y=0,x=0,v=1,$=Ft&e(o)?!0:!!o;if(p=i(n),m=p.length,1===m)g=C(t,b(p[0],r,s,o),0,a);else if(m>1){for(h=(m>>>1)+1,f=0;h>=f;f++)d=e(p[f]),k=e(p[m-1-f]),At===d&&At===k||(v=0),Rt&d||Rt&k?y=1:(zt&d||zt&k||u(p[f],r)||u(p[m-1-f],r))&&(x=1);if(v&&!$)p=p.slice().join(""),p.isCharList=1,g=C(t,p,0,a);else if(!$||y||x)if(y||x){for(f=0;m>f;f++)Rt&e(p[f])?p[f]=O(t+"_"+f,p[f],r,o,l,s,a):p[f]=C(t+"_"+f,b(p[f],r,s),f,a);g=m>1?new R(Ie,t,p):p[0]}else{for(c&&(c.keywords=i(n).slice()),p=p.sort(Jt),f=0;m>f;f++)p[f]=C(t+"_"+f,b(p[f],r,s),f,a);g=m>1?new R(Ie,t,p):p[0]}else c&&(c.keywords=i(n).slice()),g=C(t,w(p,o,l),0,a)}return a[t]=g}function q(t,n,o,l,s){if(s[t])return s[t];var i=a(n),c=[],p=[];return r(function(n){var r,a,f,m;r=C(t+"_0_"+n,b(i[n][0],o,l),n,s),i[n].length>1?(f=u(i[n][1],o),m=f&&ln.test(i[n][1]),zt!==r.ptype||Ft!==e(i[n][1])||!m&&f?a=C(t+"_1_"+n,b(i[n][1],o,l),n,s):m?(a=new String(i[n][1]),a.regex_pattern=o):a=i[n][1]):a=r,c.push(r),p.push(a)},0,i.length-1),s[t]=new R(Re,t,[c,p])}function L(e,t){var n=a(e.tokens.slice());r(function(e){var r=n[e][0],o=n[e].length>1?n[e][1]:n[e][0],l=n[e].length>2?n[e][2]:"";null===o?(t.line=t.line||[],t.line.push(r)):(t.block=t.block||[],t.block.push([r,o,l]))},0,n.length-1)}function M(e,n,r,o){var l=e.meta||r,s=!(!e.caseInsesitive&&!e.ci),i=t(n,function(e){return{word:e,meta:l,ci:s}});return o.autocomplete=(o.autocomplete||[]).concat(i),i}function S(t){t.Lex||(t.Lex={}),t.Syntax||(t.Syntax={});var n,r,o,s,i,a,u,p,f,m,h,d=t.Lex,k=t.Syntax,g=[d,k],y=g.length;for(h=0;y>h;){m=g[h++];for(o in m)m[xt](o)&&(n=o.split(":"),r=n[1]&&Vt(n[1]).length?Vt(n[1]):null,n=Vt(n[0]),n.length||(n=o,r=null),n!==o&&(m[n]=m[o],c(m,o),r&&(r=r[qt](),s=m[n],i=e(s),jt===i?m[n].type||(m[n].type=r):(m[n]={type:r},"error"===r?(m[n].type="action",m[n].error=s):"nop"===r?(m[n].type="action",m[n].nop=!0):"group"===r?(m[n].type="sequence",m[n].tokens=s):"action"===r&&Ft===i?m[n][s]=!0:m[n].tokens=s))),d===m&&(Wt&e(m[n])&&(m[n]={type:"simple",tokens:m[n]}),s=m[n],s.type&&(p=s.type=s.type[qt](),"line-block"===p?(s.type="block",s.multiline=!1,s.escape=!1):"escaped-line-block"===p?(s.type="block",s.multiline=!1,s.escape="\\"):"escaped-block"===p&&(s.type="block",s.multiline=!0,s.escape="\\"))))}m=d;for(n in m)if(m[xt](n))for(s=m[n];s.extend;)a=s.extend,c(s,"extend"),u=d[a],u&&(Wt&e(u)&&(u=d[a]={type:"simple",tokens:u}),s=l(u,s));m=d;for(n in m)m[xt](n)&&(s=m[n],s.type?(p=s.type=s.type[qt](),"line-block"===p?(s.type="block",s.multiline=!1,s.escape=!1):"escaped-line-block"===p?(s.type="block",s.multiline=!1,s.escape="\\"):"escaped-block"===p&&(s.type="block",s.multiline=!0,s.escape="\\")):s["escaped-line-block"]?(s.type="block",s.multiline=!1,s.escape||(s.escape="\\"),s.tokens=s["escaped-line-block"],c(s,"escaped-line-block")):s["escaped-block"]?(s.type="block",s.multiline=!0,s.escape||(s.escape="\\"),s.tokens=s["escaped-block"],c(s,"escaped-block")):s["line-block"]?(s.type="block",s.multiline=!1,s.escape=!1,s.tokens=s["line-block"],c(s,"line-block")):s.comment?(s.type="comment",s.escape=!1,s.tokens=s.comment,c(s,"comment")):s.block?(s.type="block",s.tokens=s.block,c(s,"block")):s.simple?(s.type="simple",s.tokens=s.simple,c(s,"simple")):s.nop?(s.type="action",s.action=["nop",s.nop,!1],s.nop=!0):s.error?(s.type="action",s.action=["error",s.error,!!s["in-context"],!!s["in-hypercontext"]],c(s,"error")):s[xt]("hypercontext")?(s.type="action",s.action=[s.hypercontext?"hypercontext-start":"hypercontext-end",s.hypercontext,!!s["in-context"],!!s["in-hypercontext"]],c(s,"hypercontext")):s[xt]("context")?(s.type="action",s.action=[s.context?"context-start":"context-end",s.context,!!s["in-context"],!!s["in-hypercontext"]],c(s,"context")):s.indent?(s.type="action",s.action=["indent",s.indent,!!s["in-context"],!!s["in-hypercontext"]],c(s,"indent")):s.outdent?(s.type="action",s.action=["outdent",s.outdent,!!s["in-context"],!!s["in-hypercontext"]],c(s,"outdent")):s.define?(s.type="action",s.action=["define",Ft&e(s.define)?["*",s.define]:s.define,!!s["in-context"],!!s["in-hypercontext"]],c(s,"define")):s.undefine?(s.type="action",s.action=["undefine",Ft&e(s.undefine)?["*",s.undefine]:s.undefine,!!s["in-context"],!!s["in-hypercontext"]],c(s,"undefine")):s.defined?(s.type="action",s.action=["defined",Ft&e(s.defined)?["*",s.defined]:s.defined,!!s["in-context"],!!s["in-hypercontext"]],c(s,"defined")):s.notdefined?(s.type="action",s.action=["notdefined",Ft&e(s.notdefined)?["*",s.notdefined]:s.notdefined,!!s["in-context"],!!s["in-hypercontext"]],c(s,"notdefined")):s.unique?(s.type="action",s.action=["unique",Ft&e(s.unique)?["*",s.unique]:s.unique,!!s["in-context"],!!s["in-hypercontext"]],c(s,"unique")):s.push?(s.type="action",s.action=["push",s.push,!!s["in-context"],!!s["in-hypercontext"]],c(s,"push")):s[xt]("pop")?(s.type="action",s.action=["pop",s.pop,!!s["in-context"],!!s["in-hypercontext"]],c(s,"pop")):s.type="simple","action"===s.type?(s.ci=!(!s.caseInsesitive&&!s.ci),s.autocomplete=!!s.autocomplete):"block"===s.type||"comment"===s.type?(s.multiline=s[xt]("multiline")?!!s.multiline:!0,Ft&e(s.escape)||(s.escape=!1)):"simple"===s.type&&(s.meta=s.autocomplete&&Ft&e(s.meta)?s.meta:null,s.ci=!(!s.caseInsesitive&&!s.ci)));m=k;for(n in m)m[xt](n)&&(s=m[n],jt!==e(s)||s.type?s.type&&(p=s.type=s.type[qt](),"group"===p&&s.match?(i=e(s.match),Ft&i?(f=s.match[qt](),"alternation"===f||"either"===f?(s.type="alternation",c(s,"match")):"sequence"===f||"all"===f?(s.type="sequence",c(s,"match")):"zeroorone"===f?(s.type="zeroOrOne",c(s,"match")):"zeroormore"===f?(s.type="zeroOrMore",c(s,"match")):"oneormore"===f?(s.type="oneOrMore",c(s,"match")):(s.type="sequence",c(s,"match"))):Rt&i&&(s.type="repeat",s.repeat=s.match,c(s,"match"))):"either"===p?s.type="alternation":"all"===p?s.type="sequence":"lookahead"===p?s.type="positiveLookahead":"grammar"===p&&(s.type="subgrammar"),"subgrammar"!==s.type||s.tokens||(s.tokens=n)):s.ngram||s["n-gram"]?(s.type="ngram",s.tokens=s.ngram||s["n-gram"],s["n-gram"]?c(s,"n-gram"):c(s,"ngram")):s.sequence||s.all?(s.type="sequence",s.tokens=s.sequence||s.all,s.all?c(s,"all"):c(s,"sequence")):s.alternation||s.either?(s.type="alternation",s.tokens=s.alternation||s.either,s.either?c(s,"either"):c(s,"alternation")):s.zeroOrOne?(s.type="zeroOrOne",s.tokens=s.zeroOrOne,c(s,"zeroOrOne")):s.zeroOrMore?(s.type="zeroOrMore",s.tokens=s.zeroOrMore,c(s,"zeroOrMore")):s.oneOrMore?(s.type="oneOrMore",s.tokens=s.oneOrMore,c(s,"oneOrMore")):s.positiveLookahead||s.lookahead?(s.type="positiveLookahead",s.tokens=s.positiveLookahead||s.lookahead,s.lookahead?c(s,"lookahead"):c(s,"positiveLookahead")):s.negativeLookahead?(s.type="negativeLookahead",s.tokens=s.negativeLookahead,c(s,"negativeLookahead")):(s.subgrammar||s.grammar)&&(s.type="subgrammar",s.tokens=s.subgrammar||s.grammar,s.subgrammar?c(s,"subgrammar"):c(s,"grammar")));return t}function E(e,t){t=t||[];var n,r;for(n=e.ctx;n;){for(r=n.val.symb;r;)r.val[1][7]&&t.push({word:r.val[1][5],meta:(r.val[1][6]||"")+" at ("+(r.val[1][0]+1)+","+(r.val[1][1]+1)+")",ci:r.val[1][8],token:r.val[1][6],pos:[r.val[1][0]+1,r.val[1][1]+1,r.val[1][2]+1,r.val[1][3]+1]}),r=r.prev;n=n.prev}for(n=e.hctx;n;){for(r=n.val.symb;r;)r.val[1][7]&&t.push({word:r.val[1][5],meta:(r.val[1][6]||"")+" at ("+(r.val[1][0]+1)+","+(r.val[1][1]+1)+")",ci:r.val[1][8],token:r.val[1][6],pos:[r.val[1][0]+1,r.val[1][1]+1,r.val[1][2]+1,r.val[1][3]+1]}),r=r.prev;n=n.prev}for(r=e.symb;r;)r.val[1][7]&&t.push({word:r.val[1][5],meta:(r.val[1][6]||"")+" at ("+(r.val[1][0]+1)+","+(r.val[1][1]+1)+")",ci:r.val[1][8],token:r.val[1][6],pos:[r.val[1][0]+1,r.val[1][1]+1,r.val[1][2]+1,r.val[1][3]+1]}),r=r.prev;return t}function _(t,n,r,o){if(r=r||{},n=n||[],!t||!t.length)return n;var l,s,i,a,u,c,p;for(l=0,s=t.length;s>l;l++)if(u=t[l])if(We===u.type){if(o&&o.length&&u.name)for(i=o.length-1;i>=0;i--)o[i].token&&(u.name===o[i].token||u.name.length>o[i].token.length&&u.name.slice(0,o[i].token.length)===o[i].token||u.name.lengthi;i++)p=u.autocompletions[i],r[xt]("w_"+p.word)||(n.push(p),r["w_"+p.word]=1);else Ft===u.token.ptype&&Ft&e(u.token.pattern)&&u.token.pattern.length>1&&(r[xt]("w_"+u.token.pattern)||(n.push({word:""+u.token.pattern,meta:u.name,ci:!!u.ci}),r["w_"+u.token.pattern]=1))}else if(Ve===u.type)_(u.token,n,r,o);else if(it&u.type){i=0,a=u.token.length;do _([c=u.token[i++]],n,r,o);while(a>i&&(Qe&c.type&&1>c.min||je===c.type))}else Qe&u.type&&_([u.token[0]],n,r,o);return n}function P(t,n,r,o){for(var l;Ft&e(l=n[t]||r[t]);)t=l;return o?t:n[t]||r[t]||t}function T(e,t){return e.length>1?r(t?function(t,n){var r=n[n.length-1],o=e[t];r===o||n.push(o)}:function(t,n){var r=n[n.length-1],o=e[t];sn.test(o)&&sn.test(r)&&r===o||n.push(o)},1,e.length-1,[e[0]]):e}function D(n,r,l){var s,i,a,u,c,p,f,m,h,d,k,g,y,$,b,w=!1;if(b=n.modifier?n.modifier:null,m=new String(Vt(n)),m.pos=0,1===m.length)g=""+n,r[g]||l[g]||(r[g]={type:"simple",tokens:n}),n=g;else{for(s=[],i=[],a="",y=[];m.posc[0]&&(c[0]=0),2>c.length?c.push(c[0]):c[1].length?c[1]=parseInt(c[1],10)||Mt:c[1]=Mt,0>c[1]&&(c[1]=0),k=i[i.length-1],g=""+k+["{",c[0],",",isFinite(c[1])?c[1]:"","}"].join(""),l[g]||(l[g]={type:"repeat",repeat:[c[0],c[1]],tokens:[k]}),i[i.length-1]=g):a+=h;else{if("}"===h){a+=h;continue}"&"===h||"!"===h?i.length?(k=i[i.length-1],g=""+k+h,l[g]||(l[g]={type:"!"===h?"negativeLookahead":"positiveLookahead",tokens:[k]}),i[i.length-1]=g):a+=h:"|"===h?(w=!1,i=T(i),i.length>1?(g=""+i.join(" "),l[g]||(l[g]={type:"sequence",tokens:i}),s.push(g)):i.length?s.push(i[0]):a+=h,i=[]):"("===h?(y.push([i,s,a]),i=[],s=[],a=""):")"===h&&(i=T(i),i.length>1?(g=""+i.join(" "),l[g]||(l[g]={type:"sequence",tokens:i}),s.push(g)):i.length&&s.push(i[0]),i=[],s=T(s,1),s.length>1?(g=""+s.join(" | "),l[g]||(l[g]={type:"alternation",tokens:s})):s.length&&(g=s[0]),s=[],$=y.pop(),i=$[0],s=$[1],a=$[2],k=g,g="("+k+")",l[g]||(l[g]=o(P(k,r,l))),i.push(g))}}else a+=h;a.length&&(w?(i.length&&(k=i[i.length-1],g=k+"."+a,p=r[g]||l[g],p||(f=P(k,r,l),l[g]=Ft&e(f)?new String(f):o(f),l[g].modifier=a),i[i.length-1]=g),w=!1):"0"===a?(r[dt]||(r[dt]={type:"simple",tokens:0}),i.push(dt)):"^^"===a?(r[ct]||(r[ct]={type:"simple",tokens:Be}),i.push(ct)):"^^1"===a?(r[pt]||(r[pt]={type:"simple",tokens:ze}),i.push(pt)):"^"===a?(r[ft]||(r[ft]={type:"simple",tokens:Ue}),i.push(ft)):"$"===a?(r[mt]||(r[mt]={type:"simple",tokens:Ge}),i.push(mt)):(r[a]||l[a]||(r[a]={type:"simple",tokens:a}),i.push(a))),a="",i=T(i),i.length>1?(g=""+i.join(" "),l[g]||(l[g]={type:"sequence",tokens:i}),s.push(g)):i.length&&s.push(i[0]),i=[],s=T(s,1),s.length>1?(g=""+s.join(" | "),l[g]||(l[g]={type:"alternation",tokens:s}),n=g):s.length&&(n=s[0]),s=[]}return b&&(r[n]||l[n])&&((r[n]||l[n]).modifier=b),n}function N(o,l,s,u,c,p,f,m,h,d,k){var g,y,x,v,$,b,w,C=null,S=null,E=null;if(Be===o||ze===o||Ue===o||Ge===o)return new z(o,Be===o?ct:ze===o?$T_FBNL$:Ue===o?ft:mt,o,S);if(!1===o||0===o)return new z(Ye,dt,0,S);if(""===o)return new z(He,kt,"",S);if(null===o)return new z(We,ht,_t,S,E);if(Rt&e(o)&&(x=o,o="NGRAM_"+x.join("_"),u[o]||(u[o]={type:"ngram",tokens:x})),o=""+o,m[o])return m[o];if($=P(o,s,u),Ft&e($)&&($=D($,s,u),$=s[$]||u[$]||null),!$)return null;if(g=$.type?ut[$.type[qt]().replace(Xt,"")]||We:We,S=$.msg||null,E=$.modifier||null,y=$.tokens,We&g){if(Be===y||ze===y||Ue===y||Ge===y||!1===y||0===y)return C=new z(y||Ye,o,y||0,S),m[o]=C,C;if(""===y)return C=new z(He,o,"",S),m[o]=C,C;if(null===y)return C=new z(We,o,_t,S,E),m[o]=C,C;if(!y)return null}if(je&g)$[xt]("action")?"nop"===$.action[0]?$.action[0]=be:"error"===$.action[0]?$.action[0]=we:"context-start"===$.action[0]?$.action[0]=Se:"context-end"===$.action[0]?$.action[0]=Ee:"hypercontext-start"===$.action[0]?$.action[0]=_e:"hypercontext-end"===$.action[0]?$.action[0]=Pe:"push"===$.action[0]?$.action[0]=Te:"pop"===$.action[0]?$.action[0]=De:"define"===$.action[0]?$.action[0]=Ce:"undefine"===$.action[0]?$.action[0]=Oe:"defined"===$.action[0]?$.action[0]=qe:"notdefined"===$.action[0]?$.action[0]=Le:"unique"===$.action[0]?$.action[0]=Me:"indent"===$.action[0]?$.action[0]=Ne:"outdent"===$.action[0]&&($.action[0]=Fe):$[xt]("nop")?$.action=[be,$.nop,!!$["in-context"],!!$["in-hypercontext"],!1]:$[xt]("error")?$.action=[we,$.error,!1,!1,!1]:$[xt]("context")?$.action=[$.context?Se:Ee,$.context,!1,!1,!1]:$[xt]("hypercontext")?$.action=[$.hypercontext?_e:Pe,$.hypercontext,!1,!1,!1]:$[xt]("context-start")?$.action=[Se,$["context-start"],!1,!1,!1]:$[xt]("context-end")?$.action=[Ee,$["context-end"],!1,!1,!1]:$[xt]("hypercontext-start")?$.action=[_e,$["hypcontext-start"],!1,!1,!1]:$[xt]("hypercontext-end")?$.action=[Pe,$["hypcontext-end"],!1,!1,!1]:$[xt]("push")?$.action=[Te,$.push,!!$["in-context"],!!$["in-hypercontext"],$.autocomplete]:$[xt]("pop")?$.action=[De,$.pop,!!$["in-context"],!!$["in-hypercontext"],!1]:$[xt]("define")?$.action=[Ce,Ft&e($.define)?["*",$.define]:$.define,!!$["in-context"],!!$["in-hypercontext"],$.autocomplete]:$[xt]("undefine")?$.action=[Oe,Ft&e($.undefine)?["*",$.undefine]:$.undefine,!!$["in-context"],!!$["in-hypercontext"],$.autocomplete]:$[xt]("defined")?$.action=[qe,Ft&e($.defined)?["*",$.defined]:$.defined,!!$["in-context"],!!$["in-hypercontext"],!1]:$[xt]("notdefined")?$.action=[Le,Ft&e($.notdefined)?["*",$.notdefined]:$.notdefined,!!$["in-context"],!!$["in-hypercontext"],!1]:$[xt]("unique")?$.action=[Me,Ft&e($.unique)?["*",$.unique]:$.unique,!!$["in-context"],!!$["in-hypercontext"],$.autocomplete]:$[xt]("indent")?$.action=[Ne,$.indent,!!$["in-context"],!!$["in-hypercontext"],!1]:$[xt]("outdent")&&($.action=[Fe,$.outdent,!!$["in-context"],!!$["in-hypercontext"],!1]),!1===$.msg&&(S=!1),$.nop&&($.action[0]=be),C=new z(je,o,$.action.slice(),S,E),C.ci=!!$.caseInsensitive||$.ci,m[o]=C;else if(y=i(y),We&g){w=$.autocomplete?M($,Yt&e($.autocomplete)?i($.autocomplete):y,o,k):null;var _={};if(b="undefined"!=typeof $.combine?$.combine:!!(Rt&e($.tokens)),C=new z(We,o,O(o,y.slice(),l,b,!(!$.caseInsensitive&&!$.ci),p,f,_),S,E,null,w),_.keywords&&(C.keywords=_.keywords.join("|")),m[o]=C,null!=$.except){var T,F,A=i($.except),I=A.length,R=[];for(T=0;I>T;T++)A[T]&&(F=N(A[T],l,s,u,c,p,f,m,h,d,k),F&&R.push(F));R.length&&(C.except=R)}}else Ze&g?(Ke===g&&L($,d),C=new z(g,o,q(o,y.slice(),l,p,f),S),C.empty=$[xt]("empty")?!!$.empty:!0,C.mline=$[xt]("multiline")?!!$.multiline:!0,C.esc=$[xt]("escape")?$.escape:!1,C.inter=!!c[o+".inside"],Ke===g&&$.interleave&&h.push(U(C)),E&&(C.modifier=E),m[o]=C):at&g&&(st===g?m[o]=new z(st,o,y,S,E):lt===g?(v=a(y),C=t(v,function(e,t){return new z(lt,o+"_NGRAM_"+t,null,S,E)}),m[o]=C,r(function(e){C[e].token=i(n(v[e],function(e,t){return e.concat(N(t,l,s,u,c,p,f,m,h,d,k))},[]))},0,v.length-1)):(rt===g||ot===g?C=new z(g,o,null,S,E):Qe&g&&Rt&e($.repeat)?(C=new z(Qe,o,null,S,E),C.min=$.repeat[0],C.max=$.repeat[1]):Xe===g?(C=new z(Xe,o,null,S,E),C.min=0,C.max=1):et===g?(C=new z(et,o,null,S,E),C.min=0,C.max=Mt):tt===g?(C=new z(tt,o,null,S,E),C.min=1,C.max=Mt):C=Ve===g?new z(Ve,o,null,S,E):new z(Je,o,null,S,E),m[o]=C,C.token=i(n(y,function(e,t){return e.concat(N(t,l,s,u,c,p,f,m,h,d,k))},[]))));return m[o]}function F(e,t){var n,r,o=e.Style,l=e.Lex,s=e.Syntax,i=[],a={};for(n in o)o[xt](n)&&(r=l[n]||s[n],!r||"block"!=r.type&&"comment"!==r.type||(t&&(o[n+".inside"]||o[n])?(n=o[n+".inside"]||o[n],a[xt](n)||(i.push(n),a[n]=1)):t||a[xt](n)||(i.push(n),a[n]=1)));return i}function A(t){var n={};return t.Lex=t.Lex||{},t.Syntax=t.Syntax||{},t=S(t),t.Parser&&t.Parser.length&&r(function o(l,s){var i,a,u,c=s[l];n[c]||(Rt&e(c)&&(i=c,c="NGRAM_"+i.join("_"),t.Syntax[c]||(t.Syntax[c]={type:"ngram",tokens:i})),a=P(c,t.Lex,t.Syntax),Ft&e(a)&&(a=D(a,t.Lex,t.Syntax),a=t.Lex[a]||t.Syntax[a]||null),a&&(n[c]=a,u=a.type?ut[a.type[qt]().replace(Xt,"")]||We:We,at&u&&r(o,0,a.tokens.length-1,a.tokens)))},0,t.Parser.length-1,t.Parser),t}function I(t){var r,l,s,i,a,u,c,p,f,m,h,d,k,g;return t.__parsed?t:(r=t.RegExpID||null,s=t.Extra?o(t.Extra):{},i=t.Style?o(t.Style):{},a=null,u=null,c=t.Lex?o(t.Lex):{},p=t.Syntax?o(t.Syntax):{},f={},m={},h={},k={},g={},d=[],l=t.Parser?o(t.Parser):[],t=S({Style:i,Fold:a,Match:u,Lex:c,Syntax:p,$parser:null,$interleaved:null,$comments:null,$autocomplete:null,$extra:s,__parsed:0}),t.$parser=n(l,function(t,n){var o=N(n,r,c,p,i,f,m,h,d,k,g)||null;return o&&(Rt&e(o)?t=t.concat(o):t.push(o)),t},[]),t.$interleaved=d&&d.length?d:null,t.$comments=k,t.$autocomplete=g&&g.autocomplete&&g.autocomplete.length?g.autocomplete:null,t.__parsed=1,t)}function R(t,n,r,o,l){var s,i,a=this;s=a.type=t,a.name=n,a.pattern=r,i=a.ptype=o||Ft,a.key=l||0,Ie===s?a.key=!1!==l:Re===s?a.pattern[0]=new R(Ie,n+"_Start",r[0],null,!1):_t===i?a.pattern=null:zt===i&&(a.pattern=zt&e(r)?[r,0]:[r[0],r[1]||0])}function j(t,n,r,o){var l,s,i,a,u,c,p,f,m,h,d,k=t,g=k.type,y=k.pattern,x=k.key;if(Re===g){if(l=k.name,i=y[0],a=y[1],c=j(i,n,r,o))return u=a[c[0]],f=e(u),m=i.pattern[c[0]].ptype,zt===m&&Ut&f&&(u.regex_pattern?(p=$(u,c[1]),u=new R(Ae,l+"_End",b(p,u.regex_pattern,{}),zt)):(p=Pt&f?c[1][u+1]:$(u,c[1]),u=new R(Ae,l+"_End",p,p.length>1?Ft:At))),u}else if(Ie===g){for(h=0,d=y.length;d>h;h++)if(p=j(y[h],n,r,o))return x?[h,p[1]]:p}else{if(s=k.ptype,_t===s)return!1!==r&&n.end(),[x,""];if(zt===s){if(p=y[0].xflags.l?n.match(y[0]):n.slice(n.pos).match(y[0]),p&&0===p.index)return!1!==r&&n.mov(p[y[1]||0].length),[x,y[1]>0?p[y[1]]:p]}else if(It===s){if(!0===o){p=-1;var v,w;for(d=y.length-1;d>=0;d--)v=n.indexOf(y[Lt](d),n.pos),v>-1&&(-1===p||p>v)&&(p=v,w=y[Lt](d));if(p>-1)return!1!==r&&(n.pos=p+1),[x,w]}else if(p=n[Lt](n.pos)||null,p&&-1-1)return!1!==r&&(n.pos=p+1),[x,y]}else if(p=n[Lt](n.pos)||null,y===p)return!1!==r&&n.mov(1),[x,p]}else if(Ft===s)if(d=y.length,!0===o){if(p=n.indexOf(y,n.pos),p>-1)return!1!==r&&(n.pos=p+d),[x,y]}else if(y===n.substr(n.pos,d))return!1!==r&&n.mov(d),[x,y]}return!1}function B(e,t){this.val=e||null,t?this.prev=t:this.prev=null}function z(e,t,n,r,o,l,s,i){var a=this;a.type=e,a.name=t,a.token=n,a.modifier=o||null,a.except=l||null,a.autocompletions=s||null,a.keywords=i||null,a.pos=null,a.msg=!1===r?!1:r||null,a.$msg=null,a.status=0,a.empty=!1,a.ci=!1,a.mline=!0,a.esc=!1,a.inter=!1,a.found=0,a.min=0,a.max=1,a.i0=0,a.$id=null}function G(){var e=this;e.T=0,e.id=null,e.type=null,e.match=null,e.str="",e.pos=null,e.block=null,e.space=null}function U(e,t,n,r){var o=new z(e.type,e.name,e.token,e.msg,e.modifier,e.except,e.autocompletions,e.keywords);return o.empty=e.empty,o.ci=e.ci,o.mline=e.mline,o.esc=e.esc,o.inter=e.inter,o.found=e.found,o.min=e.min,o.max=e.max,o.i0=e.i0,t&&(o.status|=ge),n&&(o.modifier=n),r&&(o.$id=r),o}function Y(e){var t=e.name;return e.$msg?e.$msg:e.status&ge?'Token "'+t+'"'+(e.keywords?": "+e.keywords:"")+" Expected":'Syntax Error: "'+t+'"'}function H(e,t,n,r,o,l,s){e.status&de&&e.err&&(e.err[""+t+"_"+n+"_"+r+"_"+o+"_"+(l?l.name:"ERROR")]=[t,n,r,o,s||Y(l)])}function W(e,t){for(var n=null,r=null;e;){if(t===e.val[0])return r={node:e,nodePrev:e.prev,nodeNext:n,val:e.val[1]};n=e,e=e.prev}return r}function Z(e,t,n){return new B([t,n],e)}function K(e,t,n){if(e.stack===t)t=e.stack=new B(n,e.stack);else{for(var r=e.stack;r&&r.prev!==t;)r=r.prev;t=new B(n,t),r&&(r.prev=t)}return t}function V(e,t){if(null==e)return null;if(t){for(var n=new B(e.val),r=n,o=e;o.prev;)r.prev=new B(o.prev.val),o=o.prev,r=r.prev;return n}return e}function J(e,t,n,r){var o,l,s,i,a,u=1/0,c=null,p=1/0;if(l=t.pos,t.spc(),s=t.pos,o=e.stack,t.post.pos?i.pos:t.pos+1,e.stack=o,t.pos>=t.length)););e.stack=o,t.post.pos?(u=t.pos,c=o,p=a):u===t.pos&&p>a&&(u=t.pos,c=o,p=a),t.pos=s,o=o.prev,a++}u=l&&t.pos===s}function Q(e,t,n,r){if(!e)return!1;var o=e.type,l=at&o?ne:Ze&o?te:je&o?X:ee;return l(e,t,n,r)}function X(t,n,r,o){var l,s,i,a,u,c,p,f,m,h,d,k,g,y,x,v,b,w,C=t,O=C.token||null,q=C.ci,L=C.name,M=!(r.status&de);if(C.status=0,C.$msg=null,!O||!o||!o.pos)return!0;if(w=!!(Ze&o.T),be===O[0]||w&&!o.block)return!0;if(l=O[0],s=O[1],y=O[2],x=O[3],m=O[4],u=C.msg,w?(b=o.block.match||o.block.str,h=o.block.pos[0][0],d=o.block.pos[0][1],k=o.block.pos[0][2],g=o.block.pos[0][3]):(b=o.match||o.str,h=o.pos[0],d=o.pos[1],k=o.pos[2],g=o.pos[3]),Ee===l)r.ctx=r.ctx?r.ctx.prev:null;else if(Se===l)r.ctx=new B({symb:null,queu:null},r.ctx);else if(Pe===l)r.hctx=r.hctx?r.hctx.prev:null;else if(_e===l)r.hctx=new B({symb:null,queu:null},r.hctx);else if(Ce===l)i=s[1],a=s[0],i=$(i,b,!0),q&&(i=i[qt]()),a+="::"+i,f=x&&r.hctx?W(r.hctx.val.symb,a):y&&r.ctx?W(r.ctx.val.symb,a):r.symb?W(r.symb,a):null,f||(x&&r.hctx?r.hctx.val.symb=Z(r.hctx.val.symb,a,[h,d,k,g,a,i,o.type,m,q]):y&&r.ctx?r.ctx.val.symb=Z(r.ctx.val.symb,a,[h,d,k,g,a,i,o.type,m,q]):r.symb=Z(r.symb,a,[h,d,k,g,a,i,o.type,m,q]));else if(Oe===l){if(i=s[1],a=s[0],i=$(i,b,!0),q&&(i=i[qt]()),a+="::"+i,x&&r.hctx)f=W(r.hctx.val.symb,a);else if(y&&r.ctx)f=W(r.ctx.val.symb,a);else{if(!r.symb)return!0;f=W(r.symb,a)}f&&(f.nodeNext?f.nodeNext.prev=f.nodePrev:x&&r.hctx?r.hctx.val.symb=r.hctx.val.symb.prev:y&&r.ctx?r.ctx.val.symb=r.ctx.val.symb.prev:r.symb=r.symb.prev)}else if(qe===l){if(i=s[1],a=s[0],i=$(i,b,!0),q&&(i=i[qt]()),a+="::"+i,f=x&&r.hctx?W(r.hctx.val.symb,a):y&&r.ctx?W(r.ctx.val.symb,a):r.symb?W(r.symb,a):null,!f)return!1!==u&&(C.$msg=u?$(u,i,!0):'Undefined "'+i+'"',v=Y(C),H(r,h,d,k,g,C,v),C.status|=ye),!1}else if(Le===l){if(i=s[1],a=s[0],i=$(i,b,!0),q&&(i=i[qt]()),a+="::"+i,x&&r.hctx)f=W(r.hctx.val.symb,a);else if(y&&r.ctx)f=W(r.ctx.val.symb,a);else{if(!r.symb)return!0;f=W(r.symb,a)}if(f)return!1!==u&&(C.$msg=u?$(u,i,!0):'Defined "'+i+'"',v=Y(C),H(r,f.val[0],f.val[1],f.val[2],f.val[3],C,v),H(r,h,d,k,g,C,v),C.status|=ye),!1}if(M)return!0;if(we===l)return!u&&Ft&e(s)&&(u=s),C.$msg=u?$(u,b,!0):'Error "'+L+'"',H(r,h,d,k,g,C,Y(C)),C.status|=ye,!1;if(Me===l){if(x){if(!r.hctx)return!0;p=r.hctx.val.symb}else if(y){if(!r.ctx)return!0;p=r.ctx.val.symb}else p=r.symb;if(i=s[1],a=s[0],i=$(i,b,!0),q&&(i=i[qt]()),a+="::"+i,f=W(p,a))return!1!==u&&(C.$msg=u?$(u,i,!0):'Duplicate "'+i+'"',v=Y(C),H(r,f.val[0],f.val[1],f.val[2],f.val[3],C,v),H(r,h,d,k,g,C,v),C.status|=ye),!1;x?r.hctx.val.symb=Z(r.hctx.val.symb,a,[h,d,k,g,a,i,o.type,m,q]):y?r.ctx.val.symb=Z(r.ctx.val.symb,a,[h,d,k,g,a,i,o.type,m,q]):r.symb=Z(r.symb,a,[h,d,k,g,a,i,o.type,m,q])}else if(De===l){if(x){if(!r.hctx)return!0;c=r.hctx.val.queu}else if(y){if(!r.ctx)return!0;c=r.ctx.val.queu}else c=r.queu;if(s){if(s=$(s,b),q&&(s=s[qt]()),!c||s!==c.val[0])return!1!==u&&(c?(C.$msg=u?$(u,[c.val[0],s],!0):'Mismatched "'+c.val[0]+'","'+s+'"',v=Y(C),H(r,c.val[1],c.val[2],c.val[3],c.val[4],C,v),H(r,h,d,k,g,C,v),c=c.prev):(C.$msg=u?$(u,["",s],!0):'Missing matching "'+s+'"',v=Y(C),H(r,h,d,k,g,C,v)),C.status|=ye),x?r.hctx&&(r.hctx.val.queu=c):y?r.ctx&&(r.ctx.val.queu=c):r.queu=c,!1;c=c?c.prev:null}else c=c?c.prev:null;x?r.hctx&&(r.hctx.val.queu=c):y?r.ctx&&(r.ctx.val.queu=c):r.queu=c}else if(Te===l&&s){if(x){if(!r.hctx)return!0;c=r.hctx.val.queu}else if(y){if(!r.ctx)return!0;c=r.ctx.val.queu}else c=r.queu;s=$(s,b),q&&(s=s[qt]()),C.$msg=u?$(u,s,!0):'Missing matching "'+s+'"',c=new B([s,h,d,k,g,Y(C)],c),x?r.hctx&&(r.hctx.val.queu=c):y?r.ctx&&(r.ctx.val.queu=c):r.queu=c}return!0}function ee(e,t,n,r,o){var l,s,i=e,a=i.token,u=i.modifier,c=i.type,p=i.name,f=i.except,m=n.line,h=t.pos,d=null,k=!1;if(i.status&=ve,i.$msg=o?null:i.msg||null,i.pos=t.pos,f&&!o){s=oe(n,t);for(var g=0,y=f.length;y>g;g++)if(l=f[g],i!==l&&We===l.type&&ee(l,t,n,r,1))return i.pos=l.pos,oe(n,t,s),!1}if(Be===c)k=0===n.line;else if(ze===c)k=n.bline+1===n.line;else if(Ue===c)k=t.sol();else if(Ge===c)t.spc(),t.eol()?k=p:(i.pos=t.pos,t.bck(h));else if(Ye===c)i.status=0,k=!0;else if(He===c){if(null==r.space||t.eol()?t.spc()&&!t.eol()?(i.pos=t.pos,t.bck(h),i.status&ge&&(i.status|=ye)):k=!0:i.status&ge&&(i.status|=ye),i.status&=xe,!0===k)return k}else _t===a?(t.end(),k=u||p):(d=j(a,t))&&(d=d[1],k=u||p);return o?k:(!1!==k&&(r.T=c,r.id=p,r.type=k,r.str=t.sel(h,t.pos),r.match=d,r.pos=[m,h,m,t.pos]),!k&&i.status&&i.$msg&&(i.$msg=$(i.$msg,p,!0)),k)}function te(e,t,n,r){var o,l,s,i,a,u,c,p,f,m,h,d,k,g,y,x,v,b,w,C,O,q,L=e,M=L.name,S=L.type,E=L.modifier,_=L.token,P=L.mline,T=L.inter,D=T?M+".inside":M,N=L.esc,F=!!N,A="",I="",R="",B="",z=L.$id||M,G=n.outer,Y=G&&G[2],H=G&&G[1]; -if(L.status&=ve,L.$msg=L.msg||null,L.pos=t.pos,C=n.line,O=t.pos,Ke===S&&(L.status&=xe),y=L.status&ge,s=0,i=0,n.block&&n.block.name===M?(i=1,s=1,g=D,o=n.block.end,p=n.block.sp,m=n.block.ip,f=n.block.ep,A=n.block.s,I=n.block.i):!n.block&&(o=j(_,t))&&(i=1,g=M,v=t.pos,p=[C,O],m=[[C,v],[C,v]],f=[C,v],A=t.sel(O,v),I="",B="",n.block={name:M,end:o,sp:p,ip:m,ep:f,s:A,i:I,e:B}),i){if(w=n.stack,l=_t===o.ptype,x=l||L.empty,T){if(l&&s&&t.sol())return L.status&=xe,n.block=null,!1;if(!s)return v=t.pos,r.T=S,r.id=M,r.type=E||g,r.str=t.sel(O,v),r.match=null,r.pos=[C,O,C,v],K(n,w,U(L,y,0,z)),E||g}if(v=t.pos,a=H?l&&t.eol():j(o,t),c=P,u=0,a)g=l?D:M,B=t.sel(v,t.pos);else if(b=t.pos,d=!1,H||F||It!==o.ptype&&At!==o.ptype&&Ft!==o.ptype){for(;!t.eol();){if(H){if(Q(H,t,Y,r)){if(t.pos>b){l&&(a=1);break}return!0}if(l){k=t.nxt(1),R+=k;continue}}if(v=t.pos,!d&&j(o,t)){T&&t.pos>v&&v>b?(g=D,t.bck(v),u=1):(g=M,a=1),B=t.sel(v,t.pos);break}k=t.nxt(1),R+=k,d=F&&!d&&N===k,v=t.pos}l&&t.eol()&&(a=1)}else(q=j(o,t,!0,!0))?T&&t.pos>v+q[1].length?(g=D,t.mov(-q[1].length),u=1,R=t.sel(v,t.pos)):(g=M,a=1,R=t.sel(v,t.pos-q[1].length),B=q[1]):(t.end(),g=D,u=1,R=t.sel(v,t.pos));return c=P||F&&d,I+=R,m[1]=[C,v],f=[C,t.pos],a&&!x&&m[0][0]===m[1][0]&&m[0][1]===m[1][1]?(n.block=null,!1):(a||!c&&!u?n.block=null:(n.block.ip=m,n.block.ep=f,n.block.i=I,n.block.e=B,K(n,w,U(L,y,0,z))),r.T=S,r.id=M,r.type=E||g,r.str=t.sel(O,t.pos),r.match=null,r.pos=[C,O,f[0],f[1]],L.pos=t.pos,n.block||(h=A+I+B,r.block={str:h,match:[h,I,A,B],part:[h,A,I,B],pos:[[p[0],p[1],f[0],f[1]],[p[0],p[1],m[0][0],m[0][1]],[m[0][0],m[0][1],m[1][0],m[1][1]],[m[1][0],m[1][1],f[0],f[1]]]}),E||g)}return L.status&&L.$msg&&(L.$msg=$(L.$msg,M,!0)),!1}function ne(e,t,n,r){var o,l,s,i,a,u,c,f,m,h,d,k,g,y,x,v=e,$=v.type,b=(v.name,v.token),w=b.length,C=v.modifier;if(v.status&=ve,v.$msg=v.msg||null,f=t.pos,m=n.stack,v.pos=t.pos,u=0,c=0,st===$){v.status&=ve;var O=new String(b[0]),q=n.stack?n.stack.val:null;return O.subgrammar=1,O.next=q?new z(rt,q.name,[q]):null,O.required=q?q.status&ge:0,O}if(Ve===$){for(g=p(),v.status|=ge,k=[],x=oe(n,t),d=0,h=d;w>h;h++){if(o=U(b[h],1,C,g),l=Q(o,t,n,r),v.pos=o.pos,o.status&ge&&(u++,k.push(Y(o))),!1!==l)return l;o.status&ye&&(c++,oe(n,t,x))}return u>0?v.status|=ge:v.status&=xe,w===c&&u>0?v.status|=ye:v.status&=ve,v.status&&!v.$msg&&k.length&&(v.$msg=k.join(" | ")),!1}if(it&$){y=!!($&Je),g=v.$id||p(),y?v.status|=ge:v.status&=xe,x=oe(n,t),d=0;do o=U(b[d++],y,C,g),l=Q(o,t,n,r);while(w>d&&(!0===l&&nt&o.type||!1===l&&!(o.status&ge)));if(v.pos=o.pos,!1!==l){if(!0!==l||Ye!==o.type)for(h=w-1;h>=d;h--)m=K(n,m,U(b[h],1,C,g));return l.subgrammar&&w>d&&(l.next=new z(rt,b[d].name,[b[d]]),l.required=b[d].status&ge),l}return o.status&ye?(y?v.status|=ye:v.status&=ve,oe(n,t,x)):y&&o.status&ge&&(v.status|=ye),v.status&&!v.$msg&&(v.$msg=Y(o)),!1}if(nt&$)return st&b[0].type?!0:(x=oe(n,t,null,!1),l=Q(U(b[0],0),t,n,r),oe(n,t,x),ot===$?!1===l:!1!==l);for(g=v.$id||p(),s=v.found,i=v.min,a=v.max,v.status=0,k=[],x=oe(n,t),h=0;w>h;h++){if(o=U(b[h],1,C,g),l=Q(o,t,n,r),v.pos=o.pos,!1!==l){if(++s,a>=s)return v.found=s,K(n,m,U(v,0,0,p())),v.found=0,l;break}o.status&ge&&(u++,k.push(Y(o))),o.status&ye&&oe(n,t,x)}return i>s&&(v.status|=ge),(s>a||i>s&&u>0)&&(v.status|=ye),v.status&&!v.$msg&&k.length&&(v.$msg=k.join(" | ")),!1}function re(e,t){var n=this;n.id=e?f("state"):"state",t instanceof re?(n.line=t.line,n.bline=t.bline,n.status=t.status,n.stack=V(t.stack,!1),n.token=t.token,n.token2=t.token2,n.block=t.block,n.outer=t.outer?[t.outer[0],t.outer[1],new re(e,t.outer[2])]:null,n.queu=t.queu||null,n.symb=t.symb||null,n.ctx=t.ctx?new B({symb:t.ctx.val.symb,queu:t.ctx.val.queu},t.ctx.prev):null,n.hctx=t.hctx?new B({symb:t.hctx.val.symb,queu:t.hctx.val.queu},t.hctx.prev):null,n.err=t.err||null,n.$eol$=t.$eol$,n.$blank$=t.$blank$):(n.line=-1,n.bline=-1,n.status=t||0,n.stack=null,n.token=null,n.token2=null,n.block=null,n.outer=null,n.queu=null,n.symb=null,n.ctx=null,n.hctx=null,n.err=n.status&de?{}:null,n.$eol$=!0,n.$blank$=!0)}function oe(e,t,n,r){return n?(e.status=n[0],e.block=n[1],e.outer=n[2],e.stack=n[3],t&&t.pos>n[4]&&t.bck(n[4]),void 0):(n=[e.status,e.block,e.outer,e.stack,t?t.pos:1/0],!1===r&&(e.status=0),n)}function le(e){e.id=null,e.line=null,e.bline=null,e.status=null,e.stack=null,e.token=null,e.token2=null,e.block=null,e.outer=null,e.queu=null,e.symb=null,e.ctx=null,e.hctx=null,e.err=null}function se(e,t,n){var r=new String(e);return r.start=t||0,r.pos=n||0,r.sol=function(){return 0===r.pos},r.eol=function(){return r.pos>=r.length},r.end=function(){return r.pos=r.length,r},r.mov=function(e){return r.pos=0>e?Ct(0,r.pos+e):Ot(r.length,r.pos+e),r},r.bck=function(e){return r.pos=Ct(0,e),r},r.sft=function(){return r.start=r.pos,r},r.nxt=function(e,t){var n,o,l="";if(!0===e){for(t=t||se.$NONSPC$;r.posi||i>=t)return s+(t-l);s+=i-l,s+=n-s%n,l=i+1}}function ae(n,r){return Yt&e(n)&&(n=x("\\b("+t(i(n).sort(Jt),y).join("|")+")\\b")),!1===r?function(e){return!e||!n.test(e)}:function(e){return!!e&&n.test(e)}}function ue(e,t,n,r,o,l){for(;;){n.lastIndex=e.col;var s=n.exec(e.text);if(!s){if(e.next()){e.text=e.line(e.row);continue}return}{if(t(e.token(e.row,s.index+1)))return e.col=s.index+s[0].length,s;e.col=s.index+1}}}function ce(e,t,n,r,o,l){for(var s,i,a;;){if(s=e.text.indexOf(o,e.col),-1===s){if(e.next()){e.text=e.line(e.row);continue}return}if(t(e.token(e.row,s+1)))return i=e.text.lastIndexOf(l,s),a=i>-1&&!se.$NOTEMPTY$.test(e.text.slice(i+1,s)),e.col=s+1,a?"autoclosed":"regular";e.col=s+1}}function pe(e,t,n,r,o,l,s,i,a,u){if(-1===e){var c,p,f,m,h,d,k,g,y=1,x=t.first(),v=(l.length,s.length,!1===o);e:for(c=n;c>=x;--c)for(p=t.line(c),f=p.length,m=c===n?r-1:f;;){if(0>m)break;if(h=p.lastIndexOf(l,m),d=p.lastIndexOf(s,m),0>h&&0>d)break;if(m=Ct(h,d),v||u||t.token(c,m+1)==o)if(m===d)++y;else if(0===--y){k=c,g=m;break e}--m}return null==k||a&&k===n&&g===r?!1:[k,g,n,r]}var c,p,f,m,h,d,$,b,y=1,w=t.last(),v=(l.length,s.length,!1===o);e:for(c=n;w>=c;++c)for(p=t.line(c),f=p.length,m=c===n?r:0;;){if(m>=f)break;if(h=p.indexOf(l,m),d=p.indexOf(s,m),0>h&&0>d)break;if(0>h&&(h=f),0>d&&(d=f),m=Ot(h,d),v||u||t.token(c,m+1)==o)if(m===h)++y;else if(0===--y){$=c,b=m;break e}++m}return null==$||a&&n===$&&b===r?!1:[n,r,$,b]}function fe(e,t,n){var r=n.text,o=n.meta,l=n.start,s=n.end,i=t.list.maxlen-r.length-o.length+5;e.innerHTML=['',g(r.slice(0,l)),'',g(r.slice(l,s)),"",g(r.slice(s)),"",new Array(1+i).join(" "),'',g(o),""," "].join(""),e.className=(e.className&&e.className.length?e.className+" ":"")+"cmg-autocomplete-keyword-hint",e.style.position="relative",e.style.width="100%",e.style.maxWidth="120%"}function me(e,t,n){function r(e,t){var o;return o={Mode:r,startState:function(){return{parser:r.$parser,state:new re,inner:{},name:null}},copyState:function(e){return{parser:e.parser,state:new re(0,e.state),inner:e.inner,name:e.name}},token:function(e,t){var n=se(e.string,e.start,e.pos),r=t.parser.get(n,t).type;return e.pos=n.pos,r},indent:function(r,o,l){return r.parser.indent(r.state,o,l,e,t,n)},fold:r.foldType,lineComment:r.$parser.LC,blockCommentStart:r.$parser.BCS,blockCommentEnd:r.$parser.BCE,blockCommentContinue:r.$parser.BCC,blockCommentLead:r.$parser.BCL,electricInput:r.$parser.$grammar.$extra.electricInput||!1,electricChars:r.$parser.$grammar.$extra.electricChars||!1},r.mode=o,o}return n=n||pn,r.$id=f("codemirror_grammar_mode"),r.$parser=new dn.Parser(I(e),t),r.$parser.Mode=r,r.options=function(e,t,n){n=n||{};var o=e.getTokenAt(t).state,l=o&&o.parser||r.$parser;return n.lineComment=l.LC,n.blockCommentStart=l.BCS,n.blockCommentEnd=l.BCE,n.blockCommentContinue=l.BCC,n.blockCommentLead=l.BCL,n.electricInput=l.$grammar.$extra.electricInput||!1,n.electricChars=l.$grammar.$extra.electricChars||!1,n},r.supportGrammarAnnotations=!1,r.validator=function o(e,t){return r.supportGrammarAnnotations&&r.$parser&&e&&e.length?r.$parser.validate(e,o.options||t||{},n):[]},r.linter=r.validator,r.supportAutoCompletion=!0,r.autocompleter=function l(e,t){if(r.supportAutoCompletion){var o=e.getTokenAt(e.getCursor()).state,s=o&&o.parser||r.$parser;return t=l.options||t||{},t[xt]("renderer")||(t.renderer=l.renderer||fe),s.autocomplete(e,t,n)}},r.autocompleter.renderer=fe,r.supportCodeFolding=!0,r.foldType="fold_"+r.$id,r.folder=function(e,t){if(r.supportCodeFolding){var o,l=e.getTokenAt(t).state,s=l&&l.parser||r.$parser;if(o=s.fold(e,t,n))return{from:n.Pos(o[0],o[1]),to:n.Pos(o[2],o[3])}}},r.supportCodeMatching=!0,r.matchType="match_"+r.$id,r.matcher=function s(e){if(r.supportCodeMatching){if(s.clear(e),e.state.$highlightPending)return;var t=e.getTokenAt(e.getCursor()).state,o=t&&t.parser||r.$parser;e.state.$highlightPending=!0,setTimeout(function(){e.operation(function(){e.state.$highlightPending=!1;var t,l=s.options||{},i=l.maxHighlightLineLength||1e3,a=[],u=e.listSelections(),c="CodeMirror-matchingtag",p="CodeMirror-nonmatchingbracket",f=0;for(u.length;1>f;f++)t=o.match(e,u[f].to(),n),null!=t&&(!1===t?(u[f].empty()?(t=u[f].to(),t=[n.Pos(t.line,t.ch-1),t]):t=[u[f].from(),u[f].to()],a.push(e.markText(t[0],t[1],{className:p}))):!1===t.match?a.push(e.markText(n.Pos(t[0],t[1]),n.Pos(t[2],t[3]),{className:p})):"end"===t.match&&e.getLine(t[0]).length<=i?(a.push(e.markText(n.Pos(t[0],t[1]),n.Pos(t[2],t[3]),{className:c})),e.getLine(t[4]).length<=i&&a.push(e.markText(n.Pos(t[4],t[5]),n.Pos(t[6],t[7]),{className:c}))):"start"===t.match&&e.getLine(t[4]).length<=i&&(a.push(e.markText(n.Pos(t[4],t[5]),n.Pos(t[6],t[7]),{className:c})),e.getLine(t[0]).length<=i&&a.push(e.markText(n.Pos(t[0],t[1]),n.Pos(t[2],t[3]),{className:c}))));e.state[r.matchType]=a})},50)}},r.matcher.clear=function(e){e.operation(function(){var t=e.state[r.matchType];if(e.state[r.matchType]=null,t&&t.length)for(var n=0,o=t.length;o>n;n++)t[n].clear()})},r.submode=function(e,t){r.$parser.subparser(e,t.Mode.$parser)},r.dispose=function(){r.$parser&&r.$parser.dispose(),r.$parser=r.validator=r.linter=r.autocompleter=r.folder=r.matcher=r.mode=null},r}var he=1,de=2,ke=32,ge=4,ye=8,xe=~ge,ve=~ye,$e=ge|ye,be=0,we=4,Ce=8,Oe=9,qe=10,Le=11,Me=12,Se=16,Ee=17,_e=18,Pe=19,Te=32,De=33,Ne=128,Fe=129,Ae=2,Ie=4,Re=8,je=4,Be=8,ze=9,Ge=16,Ue=32,Ye=128,He=256,We=512,Ze=1024,Ke=1025,Ve=2048,Je=4096,Qe=8192,Xe=8193,et=8194,tt=8195,nt=16384,rt=nt,ot=16385,lt=32768,st=65536,it=Je|lt,at=Ve|Je|Qe|nt|lt|st,ut={action:je,simple:We,block:Ze,comment:Ke,subgrammar:st,alternation:Ve,sequence:Je,repeat:Qe,zeroorone:Xe,zeroormore:et,oneormore:tt,positivelookahead:rt,negativelookahead:ot,ngram:lt},ct="$|SOF|$",pt="$|NONBLANK|$",ft="$|SOL|$",mt="$|EOL|$",ht="$|ENDLINE|$",dt="$|EMPTY|$",kt="$|NONSPACE|$",gt=void 0,yt="prototype",xt="hasOwnProperty",vt="propertyIsEnumerable",$t=Object[yt],bt=$t.toString,wt=Object.create,Ct=Math.max,Ot=Math.min,qt="toLowerCase",Lt="charAt",Mt=1/0,St=4,Et=8,_t=16,Pt=32,Tt=33,Dt=34,Nt=64,Ft=128,At=129,It=130,Rt=256,jt=512,Bt=1024,zt=2048,Gt=4096,Ut=Ft|Pt,Yt=Ft|Rt,Ht=zt|Rt,Wt=Ft|Rt|zt,Zt={"[object Number]":Pt,"[object String]":Ft,"[object Array]":Rt,"[object RegExp]":zt,"[object Date]":Gt,"[object Function]":Bt,"[object Object]":jt},Kt=/^\s+|\s+$/g,Vt=String[yt].trim?function(e){return e.trim()}:function(e){return e.replace(Kt,"")},Jt=function(e,t){return t.length-e.length},Qt=/\r\n|\r|\n/g,Xt=/[\-_]/g,en=0,tn=/([.*+?^${}()|[\]\/\\\-])/g,nn=/[&"'<>]/g,rn=/^([.!&\[\]{}()*+?\/|'"]|\s)/,on="(\\s|\\W|$)",ln=/(l?i?l?)x(l?i?l?)$/,sn=/[*+]$/;re.prototype.toString=function(){var e=this;return e.id+"_"+e.line+"_"+e.bline+"_"+(e.block?e.block.name:"0")},se.$SPC$=/^[\s\u00a0]+/,se.$NONSPC$=/[^\s\u00a0]/,se.$NOTEMPTY$=/\S/,se.$SPACE$=/^\s*/;var an=h({constructor:function(e,t,n){var r=this;r.$grammar=e,r.$DEF=t||null,r.$ERR=n||null,r.DEF=r.$DEF,r.ERR=r.$ERR,r.$folders=[],r.$matchers=[],r.$subgrammars={}},$grammar:null,$subgrammars:null,$folders:null,$matchers:null,$n$:"name",$t$:"type",$v$:"token",$DEF:null,$ERR:null,DEF:null,ERR:null,dispose:function(){var e=this;return e.$grammar=e.$subgrammars=null,e.$folders=e.$matchers=null,e.$n$=e.$t$=e.$v$=null,e.$DEF=e.$ERR=e.DEF=e.ERR=null,e},token:function(e,t,n){if(t.token2){var r=t.token2[0];return e.pos=t.token2[1],e.sft(),t.token=t.token2[3],t.$eol$=e.eol(),t.$blank$=t.$blank$&&(t.token2[2]||t.$eol$),t.token2=null,r}var o,l,s,i,a,u,c,p,f,m,h,d,k,g,y,x,v,$,b=this,w=b.$grammar,C=w.Style,O=b.DEF,q=b.ERR,r={},L=b.$n$,M=b.$t$,S=b.$v$,E=w.$interleaved,_=w.$parser,P=_.length,T=E?E.length:0,D=t.outer,N=D&&D[2],F=D&&D[1];if(e.sol()&&(t.$eol$&&(t.$blank$&&(t.bline=t.line),t.$eol$=!1,t.line++),t.$blank$=t.bline+1===t.line),t.$actionerr$=!1,t.token=null,i=t.line,a=e.pos,m=!1,d=!0,h=!1,k=!1,D&&b===D[0]){if(r[L]=null,r[M]=O,r[S]=null,F){if(s=new G,Q(F,e,N,s))return t.outer=null,{parser:b,state:N};for(e.nxt(1);!e.eol();){if(Q(F,e,N,s)){if(e.pos>a)break;return t.outer=null,{parser:b,state:N}}e.nxt(1)}}else e.spc(),e.eol()?k=!0:e.end();return r[S]=e.cur(1),t.$eol$=e.eol(),t.$blank$=t.$blank$&&(k||t.$eol$),r}if(t.stack&&Ge===t.stack.val.type&&e.sol()&&(t.stack=t.stack.prev),(!t.stack||null==t.block)&&e.spc()){if(t.stack&&st===t.stack.val.type)return e.bck(a),o=t.stack.val,t.stack=t.stack.prev,m=Q(o,e,t,s),g=""+m,b.$subgrammars[g]?(y=b.$subgrammars[g],x=new re(1,n[g]?n[g]:t.status),N=t):(y=b,x=new re,N=t),x.outer=[b,m.next,N],{parser:y,state:x,toInner:g};d=!0,k=!0}if(r[L]=null,r[M]=O,r[S]=null,d)for(s=new G,k&&(s.space=[a,e.pos],e.sft()),u=0;d&&(t.stack||P>u)&&!e.eol();){if(p=e.pos,f=t.stack,F){if(e.spc(),Q(F,e,N,s))return s.space||e.pos>p?(s.space&&(e.start=s.space[0],e.pos=s.space[1]),r[S]=e.cur(1),t.$eol$=e.eol(),t.$blank$=t.$blank$&&!0,r):(t.outer=null,{parser:D[0],state:N,fromInner:t});e.bck(p)}if(v=!1,T&&!t.block)for(c=0;T>c;c++)if(o=E[c],m=Q(o,e,t,s),!1!==m){v=!0;break}if(d&&!v){if(!t.stack&&u>=P)break;t.stack?(o=t.stack.val,t.stack=t.stack.prev):o=_[u++],m=Q(o,e,t,s)}if(!1===m){if(o.status&$e){t.token=o,k=J(t,e,s,o)||k,h=!0,d=!1;break}}else{if(m.subgrammar)return g=""+m,b.$subgrammars[g]?(y=b.$subgrammars[g],x=new re(1,n[g]?n[g]:t.status),N=t):(y=b,x=new re,N=t),x.outer=[b,m.next,N],s.space?(t.token2=[{parser:y,state:x,toInner:g},e.pos,k,t.token],t.token=null,e.start=s.space[0],e.pos=s.space[1],r[S]=e.cur(1),t.$eol$=e.eol(),t.$blank$=t.$blank$&&!0,r):{parser:y,state:x,toInner:g};if(t.stack&&t.stack.prev&&e.eol()&&Ze&t.stack.val.type&&t.block&&t.block.name===t.stack.val.name)for(c=t.stack.prev;c&&je===c.val.type;)l=c,c=c.prev,$=X(l,e,t,s),l.status&ye?t.$actionerr$=!0:$&&!0!==m&&l.modifier&&(m=l.modifier);else if(t.stack&&je===t.stack.val.type)for(;t.stack&&je===t.stack.val.type;)l=t.stack.val,t.stack=t.stack.prev,$=X(l,e,t,s),l.status&ye?t.$actionerr$=!0:$&&!0!==m&&l.modifier&&(m=l.modifier);if(!0!==m){d=!1;break}}}return d&&(s.space?(e.start=s.space[0],e.pos=s.space[1],m=!1,s.space=null):e.nxt(1)),r[S]=e.cur(1),!1!==m?(m=m?C[m]||O:O,r[L]=o?o.name:null):h?(m=q,t.status&de&&H(t,i,a,i,e.pos,o)):m=O,r[M]=m,s.space&&(t.token2=[r,e.pos,k,t.token],t.token=null,e.start=s.space[0],e.pos=s.space[1],r={},r[L]=null,r[M]=O,r[S]=e.cur(1),k=!0),t.$eol$=e.eol(),t.$blank$=t.$blank$&&(k||t.$eol$),r},get:function(e,t){for(var n=t.parser.token(e,t.state,t.inner);n&&n.parser;)n.fromInner&&t.parser!==n.parser&&(t.state.err=n.fromInner.err,t.name&&(t.inner[t.name]=n.fromInner)),n.state.err=t.state.err,n.state.line=t.state.line,n.state.bline=t.state.bline,n.state.$blank$=t.state.$blank$,n.state.$eol$=t.state.$eol$,n.state.$full_parse$=t.state.$full_parse$,t.state=n.state,t.parser=n.parser,t.name=n.toInner,n=t.parser.get(e,t);return n},tokenize:function(e,t,n,r){if(r=r||[],e.eol())t.state.line++,t.state.$blank$&&t.state.bline++;else for(;!e.eol();)r.push(t.parser.get(e,t));return r},parse:function(e,t){var n,o,l,s,i,a,u=(e||"").split(Qt),c=u.length,p=null;if(t=t||he,l=!!(t&de),s=!!(t&he),o={parser:this,state:new re(0,t),inner:{}},o.state.$full_parse$=!0,r(function(e){u[e]+="\n"},0,c-2),s?p=r(t&ke?function(e,t){o.parser.tokenize(se(u[e]),o,e,t)}:function(e,t){t.push(o.parser.tokenize(se(u[e]),o,e))},0,c-1,[]):r(function(e){var t=se(u[e]);if(t.eol())o.state.line++,o.state.$blank$&&o.state.bline++;else for(;!t.eol();)o.parser.get(t,o)},0,c-1),n=o.state,l&&n.queu)for(;n.queu;)i=n.queu.val,n.queu=n.queu.prev,H(n,i[1],i[2],i[3],i[4],null,i[5]);return a=s&&l?{tokens:p,errors:n.err}:s?p:n.err,le(n),o=n=null,a},autocompletion:function(e,t,n){var r,o,l=e.stack,s={},i=n?E(e):null,a=_([e.token],[],s,i);for(t=t||0;l;){if(r=l.val,o=r.type,Qe&o){if(a=_([r],a,s,i),0=u;++u)if(o=t.line(u),l=t.indentation(o),l>r)i=u,a=o.length;else if(e.test(o))break;return i?[p,s,i,a]:void 0}}},Delimited:function(e,t,n,r){return e&&t&&e.length&&t.length?(n=n||s,function(o){var l,s,i,a,u,c,p=o.row,f=o.col;for(l=o.line(p),i=f,a=0;;){var u=0>=i?-1:l.lastIndexOf(e,i-1);if(-1!==u){if(1===a&&f>u)return;if(n(c=o.token(p,u+1))){s=u+e.length;break}i=u-1}else{if(1===a)return;a=1,i=l.length}}return pe(1,o,p,s,c,e,t,n,!0,r)}):function(){}},MarkedUp:function(e,t,n,r,o){return e=e||s,t=t||"<",n=n||">",r=r||"/",o=o||x(y(t)+"("+y(r)+"?)([a-zA-Z_\\-][a-zA-Z0-9_\\-:]*)",{g:1}),function(l){l.col=0,l.min=l.first(),l.max=l.last(),l.text=l.line(l.row);for(var s,i,a,u,c,p,f,m,h,d=l.row;;){if(s=ue(l,e,o,t,n,r),!s||l.row!==d||!(i=ce(l,e,o,t,n,r)))return;if(!s[1]&&"autoclosed"!==i)for(a=[l.row,l.col],c=s[2],u=null,p=[];;){if(f=ue(l,e,o,t,n,r),d=l.row,m=l.col-(f?f[0].length:0),!f||!(i=ce(l,e,o,t,n,r)))return!1;if("autoclosed"!==i)if(f[1]){for(h=p.length-1;h>=0;--h)if(p[h]===f[2]){p.length=h;break}if(0>h&&(!c||c===f[2]))return[a[0],a[1],d,m]}else p.push(f[2])}}}}},cn={Pattern:function(e,t,n){return function(){}},Delimited:function(e,t,n,r){return e&&t&&e.length&&t.length?(n=n||s,function(o){var l,s=o.col,i=o.row,a=o.line(i),u=!1,c=e.length,p=t.length;return s>=c&&(1===c&&e===a.charAt(s-1)||e===a.slice(s-c,s))?(l=pe(1,o,i,s,u,e,t,n,!1,r),l?(l=[l[0],l[1]-c,l[0],l[1],l[2],l[3],l[2],l[3]+p],l.match="end"):(l=[i,s-c,i,s],l.match=!1),l):s>=p&&(1===p&&t===a.charAt(s-1)||t===a.slice(s-p,s))?(l=pe(-1,o,i,s-p,u,e,t,n,!1,r),l?(l=[l[0],l[1],l[0],l[1]+c,l[2],l[3],l[2],l[3]+p],l.match="start"):(l=[i,s-p,i,s],l.match=!1),l):void 0}):function(){}},MarkedUp:function(e,t,n,r,o){return function(){}}},pn="undefined"!=typeof CodeMirror?CodeMirror:{Pass:{toString:function(){return"CodeMirror.Pass"}}},fn=/[\w$]/,mn=function(e,t){return t.score-e.score},hn=h(an,{constructor:function kn(t,n){var o,l=this,i=null,a=null;if(an.call(l,t,null,"error"),l.DEF=n||l.$DEF,l.ERR=t.Style.error||l.$ERR,l.LC=t.$comments.line?t.$comments.line[0]:null,l.BCS=t.$comments.block?t.$comments.block[0][0]:null,l.BCE=t.$comments.block?t.$comments.block[0][1]:null,l.BCC=l.BCL=t.$comments.block?t.$comments.block[0][2]:null,t.$comments.block&&t.$comments.block.length){o=kn.Type("comment");for(var u=0,c=t.$comments.block.length;c>u;u++)l.$folders.push(kn.Fold.Delimited(t.$comments.block[u][0],t.$comments.block[u][1],o,"comment"))}t.Fold&&Ft&e(t.Fold)?i=t.Fold[qt]():t.$extra.fold&&(i=t.$extra.fold[qt]()),a=t.Match&&Ft&e(t.Match)?t.Match[qt]():t.$extra.match?t.$extra.match[qt]():i;var p=F(t,1);o=p.length?kn.Type(p,!1):s,i&&(i=i.split("+"),r(function(e,t){var n,r=Vt(t[e]);"braces"===r?l.$folders.push(kn.Fold.Delimited("{","}",o)):"brackets"===r?l.$folders.push(kn.Fold.Delimited("[","]",o)):"parens"===r||"parentheses"===r?l.$folders.push(kn.Fold.Delimited("(",")",o)):"brace"===r||"cstyle"===r||"c"===r?(l.$folders.push(kn.Fold.Delimited("{","}",o)),l.$folders.push(kn.Fold.Delimited("[","]",o))):"indent"===r||"indentation"===r?l.$folders.push(kn.Fold.Indented()):"tags"===r||"markup"===r||"html"===r||"xml"===r?(l.$folders.push(kn.Fold.Delimited("",kn.Type(["comment","tag"],!1))),l.$folders.push(kn.Fold.MarkedUp(kn.Type("tag"),"<",">","/"))):-1<(n=r.indexOf(","))&&l.$folders.push(kn.Fold.Delimited(r.slice(0,n),r.slice(n+1),o))},0,i.length-1,i)),a&&(a=a.split("+"),r(function(e,t){var n,r=Vt(t[e]);"braces"===r?l.$matchers.push(kn.Match.Delimited("{","}")):"brackets"===r?l.$matchers.push(kn.Match.Delimited("[","]")):"parens"===r||"parentheses"===r?l.$matchers.push(kn.Match.Delimited("(",")")):"brace"===r||"cstyle"===r||"c"===r?(l.$matchers.push(kn.Match.Delimited("{","}")),l.$matchers.push(kn.Match.Delimited("[","]")),l.$matchers.push(kn.Match.Delimited("(",")"))):"tags"===r||"markup"===r||"html"===r||"xml"===r?l.$matchers.push(kn.Match.MarkedUp(kn.Type("tag"),"<",">","/")):-1<(n=r.indexOf(","))&&l.$matchers.push(kn.Match.Delimited(r.slice(0,n),r.slice(n+1)))},0,a.length-1,a))},LC:null,BCS:null,BCE:null,BCL:null,BCC:null,dispose:function(){var e=this;return e.LC=e.BCS=e.BCE=e.BCL=e.BCC=null,an[yt].dispose.call(e)},validate:function(e,t,n){if(!e||!e.length)return[];var r,o,l,s,i=this,a=[],u=i.parse(e,de);if(!u)return a;t=t||{},l=t[xt]("type")?t.type:"error",s=t[xt]("msg")?t.msg:"Syntax Error";for(r in u)u[xt](r)&&(o=u[r],a.push({message:o[4]||s,severity:l,from:n.Pos(o[0],o[1]),to:n.Pos(o[2],o[3])}));return a},autocomplete:function(e,t,r){t=t||{};var o,l,s,i,a,u,c,p,f,m,h,d,k=this,g=[],p=t[xt]("prefixMatch")?!!t.prefixMatch:!0,f=t[xt]("inContext")?!!t.inContext:!1,m=t[xt]("dynamic")?!!t.dynamic:!1,c=t[xt]("caseInsensitiveMatch")?!!t.caseInsensitiveMatch:!1,y=e.getCursor(),x=y.ch,v=x,$=x,b=$,w=0;if(m||k.$grammar.$autocomplete){for(a=t.word||fn,o=e.getLine(y.line);v&&a.test(o[Lt](v-1));)--v;if(!p)for(;b=i&&(n=t.meta,r=!!g.ci,k=c||r,k?(f=g[qt](),m=s):(f=g,m=l),(a=f.indexOf(m))>=0&&(!p||0===a)&&(o=k?g.indexOf(l):a,y+n.length>w&&(w=y+n.length),e.push({text:g,name:g,meta:n,start:0>o?a:o,end:(0>o?a:o)+l.length,match:l,displayText:g+" ["+n+"]",render:u,score:1e3-10*(y-i)-5*(0>o?a+3:o)}))):(n=t.meta,y+n.length>w&&(w=y+n.length),e.push({text:g,name:g,meta:n,start:0,end:0,match:"",displayText:g+" ["+n+"]",render:u,score:h?1e3-10*y:d--})),e};m||f?(h=!1,g=n(k.autocompletion(e.getTokenAt(r.Pos(y.line,v),!0).state.state,null,m),C,g),!g.length&&self.$grammar.$autocomplete&&(h=!0,g=n(k.$grammar.$autocomplete,C,g))):(h=!0,g=n(k.$grammar.$autocomplete,C,g)),g.length&&(g=g.sort(mn)),g.maxlen=w}return{list:g,from:r.Pos(y.line,v),to:r.Pos(y.line,b)}},indent:function(e,t,n,r,o,l){return l.Pass},iterator:function(e,t){var n=e.getOption("tabSize");return{row:0,col:0,min:0,max:0,line:function(t){return e.getLine(t)},first:function(){return e.firstLine()},last:function(){return e.lastLine()},next:function(){var e=this;if(!(e.row>=e.max))return e.col=0,e.row++,!0},prev:function(){var e=this;if(!(e.row<=e.min))return e.col=0,e.row--,!0},indentation:function(e){return ie(e,null,n)},state:function(n,r){var o=e.getTokenAt(t.Pos(n,r||0)).state;return o.state||o},token:function(n,r){return e.getTokenTypeAt(t.Pos(n,r||0))},tokens:function(t){return e.getLineTokens(t)}}},fold:function(e,t,n){var r,o,l,s=this,i=s.$folders,a=i.length;if(a)for(o=s.iterator(e,n),o.row=t.line,o.col=t.ch||0,r=0;a>r;r++)if((l=i[r](o))||!1===l)return l},match:function(e,t,n){var r,o,l,s=this,i=s.$matchers,a=i.length;if(a)for(o=s.iterator(e,n),o.row=t.line,o.col=t.ch||0,r=0;a>r;r++)if((l=i[r](o))||!1===l)return l}});hn.Type=ae,hn.Fold=un,hn.Match=cn;var dn={VERSION:"4.2.0",clone:o,extend:l,pre_process:A,parse:I,getMode:me,Parser:hn};return dn}); \ No newline at end of file +**/!function(e,t,n){"use strict";"object"==typeof module&&module.exports?(module.$deps=module.$deps||{})&&(module.exports=module.$deps[t]=n.call(e)):"function"==typeof define&&define.amd&&"function"==typeof require&&"function"==typeof require.specified&&require.specified(t)?define(t,["module"],function(t){return n.moduleUri=t.uri,n.call(e)}):t in e||(e[t]=n.call(e)||1)&&"function"==typeof define&&define.amd&&define(function(){return e[t]})}(this,"CodeMirrorGrammar",function(){"use strict";function e(e){var t=0;return null===e?t=Pt:!0===e||!1===e||e instanceof Boolean?t=It:$t===e?t=Et:(t=Kt[qt.call(e)]||_t,t=Tt===t||e instanceof Number?isNaN(e)?Nt:isFinite(e)?Tt:Dt:Ft===t||e instanceof String?1===e.length?At:Ft:jt===t||e instanceof Array?jt:Gt===t||e instanceof RegExp?Gt:Ut===t||e instanceof Date?Ut:zt===t||e instanceof Function?zt:Bt===t?Bt:_t),t}function t(e,t,n,o){var r,l,s,i,a,c,u=e.length;if(arguments.length<4&&(o=u-1),0>o&&(o+=u),arguments.length<3&&(n=0),n>o)return[];if(n===o)return[t(e[n],n,n,o)];for(s=o-n+1,i=15&s,a=1&i,c=new Array(s),a&&(c[0]=t(e[n],n,n,o)),r=a;i>r;r+=2)l=n+r,c[r]=t(e[l],l,n,o),c[r+1]=t(e[l+1],l+1,n,o);for(r=i;s>r;r+=16)l=n+r,c[r]=t(e[l],l,n,o),c[r+1]=t(e[l+1],l+1,n,o),c[r+2]=t(e[l+2],l+2,n,o),c[r+3]=t(e[l+3],l+3,n,o),c[r+4]=t(e[l+4],l+4,n,o),c[r+5]=t(e[l+5],l+5,n,o),c[r+6]=t(e[l+6],l+6,n,o),c[r+7]=t(e[l+7],l+7,n,o),c[r+8]=t(e[l+8],l+8,n,o),c[r+9]=t(e[l+9],l+9,n,o),c[r+10]=t(e[l+10],l+10,n,o),c[r+11]=t(e[l+11],l+11,n,o),c[r+12]=t(e[l+12],l+12,n,o),c[r+13]=t(e[l+13],l+13,n,o),c[r+14]=t(e[l+14],l+14,n,o),c[r+15]=t(e[l+15],l+15,n,o);return c}function n(e,t,n,o,r){var l,s,i,a,c,u=e.length,p=n;if(arguments.length<5&&(r=u-1),0>r&&(r+=u),arguments.length<4&&(o=0),o>r)return p;if(o===r)return t(p,e[o],o);for(i=r-o+1,a=15&i,c=1&a,c&&(p=t(p,e[o],o)),l=c;a>l;l+=2)s=o+l,p=t(t(p,e[s],s),e[s+1],s+1);for(l=a;i>l;l+=16)s=o+l,p=t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(t(p,e[s],s),e[s+1],s+1),e[s+2],s+2),e[s+3],s+3),e[s+4],s+4),e[s+5],s+5),e[s+6],s+6),e[s+7],s+7),e[s+8],s+8),e[s+9],s+9),e[s+10],s+10),e[s+11],s+11),e[s+12],s+12),e[s+13],s+13),e[s+14],s+14),e[s+15],s+15);return p}function o(e,t,n,o){if(t>n)return o;if(t===n)return e(t,o,t,n),o;var r,l,s=n-t+1,i=15&s,a=1&i;for(a&&e(t,o,t,n),r=a;i>r;r+=2)l=t+r,e(l,o,t,n),e(++l,o,t,n);for(r=i;s>r;r+=16)l=t+r,e(l,o,t,n),e(++l,o,t,n),e(++l,o,t,n),e(++l,o,t,n),e(++l,o,t,n),e(++l,o,t,n),e(++l,o,t,n),e(++l,o,t,n),e(++l,o,t,n),e(++l,o,t,n),e(++l,o,t,n),e(++l,o,t,n),e(++l,o,t,n),e(++l,o,t,n),e(++l,o,t,n),e(++l,o,t,n);return o}function r(t,n){var o,l,s,i,a=e(t),c=0;if(Tt===e(n)?n>0?(c=n,n=!0):n=!1:n=!1!==n,Bt===a){l={};for(s in t)Lt.call(t,s)&&Mt.call(t,s)&&(o=e(t[s]),Bt===o?l[s]=n?r(t[s],c>0?c-1:n):t[s]:jt===o?l[s]=n?r(t[s],c>0?c-1:n):t[s].slice():Ut===o?l[s]=new Date(t[s]):Ft&o?l[s]=t[s].slice():Tt&o?l[s]=0+t[s]:l[s]=t[s])}else if(jt===a)for(i=t.length,l=new Array(i),s=0;i>s;s++)o=e(t[s]),Bt===o?l[s]=n?r(t[s],c>0?c-1:n):t[s]:jt===o?l[s]=n?r(t[s],c>0?c-1:n):t[s].slice():Ut===o?l[s]=new Date(t[s]):Ft&o?l[s]=t[s].slice():Tt&o?l[s]=0+t[s]:l[s]=t[s];else l=Ut===a?new Date(t):Ft&a?t.slice():Tt&a?0+t:t;return l}function l(){var t,n,o,s,i,a,c,u,p,f,m=arguments,h=m.length;if(1>h)return null;for(n=r(m[0]),o=1;h>o;o++)if(t=m[o])for(s in t)if(Lt.call(t,s)&&Mt.call(t,s))if(Lt.call(n,s)&&Mt.call(n,s)){if(p=e(n[s]),f=e(t[s]),Bt===p&&Bt===f)n[s]=l(n[s],t[s]);else if(jt===p&&jt===f){if(c=n[s],u=t[s],a=u.length,!a)continue;if(c.length)for(i=0;a>i;i++)0>c.indexOf(u[i])&&c.push(u[i]);else n[s]=u.slice()}}else n[s]=r(t[s]);return n}function s(){return!0}function i(t,n){return n||jt!==e(t)?[t]:t}function a(t,n){return t=i(t),(n||jt!==e(t[0]))&&(t=[t]),t}function c(t,n){return Ft&e(n)&&Ft&e(t)&&n.length&&n.length<=t.length&&n===t.substr(0,n.length)}function u(e,t,n){return n?e[t]=$t:delete e[t],e}function p(e){return(e||"id_")+ ++tn}function f(e){return(e||"uuid")+"_"+ ++tn+"_"+(new Date).getTime()}function m(){var t,n,o,r,l,s,i=arguments,a=i.length;for(t=i[0]||{},l=1;a>l;l++)if(n=i[l],Bt===e(n))for(r in n)Lt.call(n,r)&&Mt.call(n,r)&&(o=n[r],s=e(o),Tt&s?t[r]=0+o:Ut&s?t[r]=new Date(o):Ht&s?t[r]=o.slice():t[r]=o);return t}function h(e,t){var n,o=arguments.length,r="constructor";return 0===o?(e=Object,t={}):1===o?(t=e||{},e=Object):(e=e||Object,t=t||{}),Lt.call(t,r)||(t[r]=function(){}),n=t[r],delete t[r],n[yt]=m(xt(e[yt]),t),n[yt][r]=n,n}function d(e){return"&"===e?"&":"<"===e?"<":">"===e?">":'"'===e?""":"'"}function k(e){return"&#"+e.charCodeAt(0)+";"}function g(e,t){return e.replace(on,t?d:k)}function $(e){return e.replace(nn,"\\$1")}function y(e,t){t=t||{l:0,x:0,i:0,g:0};var e=new RegExp(e,(t.g?"g":"")+(t.i?"i":""));return e.xflags=t,e}function v(e,t,n,o){var r,l=e.pos||0,s=e.length,i=t.length,a="";if(n)if(o)for(;s>l;)if(r=!1,n===e[Ot](l)&&(r=!0,l+=1),t===e.substr(l,i)){if(l+=i,!r)break;a+=t}else a+=e[Ot](l++);else for(;s>l;)if(r=!1,n===e[Ot](l)&&(r=!0,l+=1,a+=n),t===e.substr(l,i)){if(l+=i,!r)break;a+=t}else a+=e[Ot](l++);else for(;s>l;){if(t===e.substr(l,i)){l+=i;break}a+=e[Ot](l++)}return e.pos=l,a}function x(t,n,o,r){var l,s,i,a,c,u=!0===o?0:1,p=r?"\\":"$",f=r?92:36;for(Ft&e(n)&&(r&&(n=$(n)),n=[n,n,n],u=0),s=t.length,c="",l=0;s>l;)i=t[Ot](l),s>l+1&&p===i?(a=t.charCodeAt(l+1),f===a?(c+=p,l+=2):a>=48&&57>=a?(c+=n[u+a-48]||"",l+=2):(c+=i,l+=1)):(c+=i,l+=1);return c}function b(t,n,o,r){if(!t||(Tt|Gt)&e(t))return t;var l,s=n?n.length||0:0,i="",a={g:0,i:0,x:0,l:0};if(Ft&e(r)?i=r:r&&(i=ln),s&&t.substr(0,s)===n){var c,u,p,l,f,m=t.substr(s),h=m[Ot](0);for(l=m.length;l--&&(f=m[Ot](l),h!==f);)"i"===f.toLowerCase()?a.i=1:"x"===f.toLowerCase()?a.x=1:"l"===f.toLowerCase()&&(a.l=1);return c=m.substring(1,l),"^"===c.charAt(0)?(a.l=1,u="^("+c.slice(1)+")"):u="^("+c+")",p=u,(a.x||a.l||a.i)&&(u=(a.l?"l":"")+(a.x?"x":"")+(a.i?"i":"")+"::"+u),o[u]||(p=y(p,a),o[u]=p),o[u]}return i?(p=u="^("+$(t)+")"+i,o[u]||(p=y(p,a),o[u]=p),o[u]):t}function w(n,o,r){var l,s="";return Ft&e(o)?s=o:o&&(s=ln),l=t(n.sort(Qt),$).join("|"),[y("^("+l+")"+s,{l:0,x:0,i:r?1:0}),1]}function C(t,n,o,r){var l=e(n);if(Tt===l)return n;if(r[t])return r[t];o=o||0;var s,i=0;return n&&n.isCharList&&(i=1,u(n,"isCharList")),s=Pt===l?new R(Ae,t,n,Pt,o):At===l?new R(Ae,t,n,At,o):Wt&l?new R(Ae,t,n,Gt,o):Ft&l?new R(Ae,t,n,i?Rt:Ft,o):n,r[t]=s}function O(t,n,o,r,l,s,a,u){if(a[t])return a[t];var p,f,m,h,d,k,g,$=0,y=0,v=1,x=Ft&e(r)?!0:!!r;if(p=i(n),m=p.length,1===m)g=C(t,b(p[0],o,s,r),0,a);else if(m>1){for(h=(m>>>1)+1,f=0;h>=f;f++)d=e(p[f]),k=e(p[m-1-f]),At===d&&At===k||(v=0),jt&d||jt&k?$=1:(Gt&d||Gt&k||c(p[f],o)||c(p[m-1-f],o))&&(y=1);if(v&&!x)p=p.slice().join(""),p.isCharList=1,g=C(t,p,0,a);else if(!x||$||y)if($||y){for(f=0;m>f;f++)jt&e(p[f])?p[f]=O(t+"_"+f,p[f],o,r,l,s,a):p[f]=C(t+"_"+f,b(p[f],o,s),f,a);g=m>1?new R(Re,t,p):p[0]}else{for(u&&(u.keywords=i(n).slice()),p=p.sort(Qt),f=0;m>f;f++)p[f]=C(t+"_"+f,b(p[f],o,s),f,a);g=m>1?new R(Re,t,p):p[0]}else u&&(u.keywords=i(n).slice()),g=C(t,w(p,r,l),0,a)}return a[t]=g}function q(t,n,r,l,s){if(s[t])return s[t];var i=a(n),u=[],p=[];return o(function(n){var o,a,f,m;o=C(t+"_0_"+n,b(i[n][0],r,l),n,s),i[n].length>1?(f=c(i[n][1],r),m=f&&sn.test(i[n][1]),Gt!==o.ptype||Ft!==e(i[n][1])||!m&&f?a=C(t+"_1_"+n,b(i[n][1],r,l),n,s):m?(a=new String(i[n][1]),a.regex_pattern=r):a=i[n][1]):a=o,u.push(o),p.push(a)},0,i.length-1),s[t]=new R(je,t,[u,p])}function L(e,t){var n=a(e.tokens.slice());o(function(e){var o=n[e][0],r=n[e].length>1?n[e][1]:n[e][0],l=n[e].length>2?n[e][2]:"";null===r?(t.line=t.line||[],t.line.push(o)):(t.block=t.block||[],t.block.push([o,r,l]))},0,n.length-1)}function M(e,n,o,r){var l=e.meta||o,s=!(!e.caseInsesitive&&!e.ci),i=t(n,function(e){return{word:e,meta:l,ci:s}});return r.autocomplete=(r.autocomplete||[]).concat(i),i}function S(t){t.Lex||(t.Lex={}),t.Syntax||(t.Syntax={});var n,o,r,s,i,a,c,p,f,m,h,d=t.Lex,k=t.Syntax,g=[d,k],$=g.length;for(h=0;$>h;){m=g[h++];for(r in m)Lt.call(m,r)&&(n=r.split(":"),o=n[1]&&Jt(n[1]).length?Jt(n[1]):null,n=Jt(n[0]),n.length||(n=r,o=null),n!==r&&(m[n]=m[r],u(m,r),o&&(o=o[Ct](),s=m[n],i=e(s),Bt===i?m[n].type||(m[n].type=o):(m[n]={type:o},"error"===o?(m[n].type="action",m[n].error=s):"nop"===o?(m[n].type="action",m[n].nop=!0):"group"===o?(m[n].type="sequence",m[n].tokens=s):"action"===o&&Ft===i?m[n][s]=!0:m[n].tokens=s))),d===m&&(Zt&e(m[n])&&(m[n]={type:"simple",tokens:m[n]}),s=m[n],s.type&&(p=s.type=s.type[Ct](),"line-block"===p?(s.type="block",s.multiline=!1,s.escape=!1):"escaped-line-block"===p?(s.type="block",s.multiline=!1,s.escape="\\"):"escaped-block"===p&&(s.type="block",s.multiline=!0,s.escape="\\"))))}m=d;for(n in m)if(Lt.call(m,n))for(s=m[n];s.extend;)a=s.extend,u(s,"extend"),c=d[a],c&&(Zt&e(c)&&(c=d[a]={type:"simple",tokens:c}),s=l(c,s));m=d;for(n in m)Lt.call(m,n)&&(s=m[n],s.type?(p=s.type=s.type[Ct](),"action"===p?s.options=s.options||{}:"line-block"===p?(s.type="block",s.multiline=!1,s.escape=!1):"escaped-line-block"===p?(s.type="block",s.multiline=!1,s.escape="\\"):"escaped-block"===p&&(s.type="block",s.multiline=!0,s.escape="\\")):s["escaped-line-block"]?(s.type="block",s.multiline=!1,s.escape||(s.escape="\\"),s.tokens=s["escaped-line-block"],u(s,"escaped-line-block")):s["escaped-block"]?(s.type="block",s.multiline=!0,s.escape||(s.escape="\\"),s.tokens=s["escaped-block"],u(s,"escaped-block")):s["line-block"]?(s.type="block",s.multiline=!1,s.escape=!1,s.tokens=s["line-block"],u(s,"line-block")):s.comment?(s.type="comment",s.escape=!1,s.tokens=s.comment,u(s,"comment")):s.block?(s.type="block",s.tokens=s.block,u(s,"block")):s.simple?(s.type="simple",s.tokens=s.simple,u(s,"simple")):s.nop?(s.type="action",s.options=s.options||{},s.action=["nop",s.nop,s.options],s.nop=!0):s.error?(s.type="action",s.options=s.options||{},s.action=["error",s.error,s.options],u(s,"error")):Lt.call(s,"hypercontext")?(s.type="action",s.options=s.options||{},s.action=[s.hypercontext?"hypercontext-start":"hypercontext-end",s.hypercontext,s.options],u(s,"hypercontext")):Lt.call(s,"context")?(s.type="action",s.options=s.options||{},s.action=[s.context?"context-start":"context-end",s.context,s.options],u(s,"context")):s.indent?(s.type="action",s.options=s.options||{},s.action=["indent",s.indent,s.options],u(s,"indent")):s.outdent?(s.type="action",s.options=s.options||{},s.action=["outdent",s.outdent,s.options],u(s,"outdent")):s.define?(s.type="action",s.options=s.options||{},s.action=["define",Ft&e(s.define)?["*",s.define]:s.define,s.options],u(s,"define")):s.undefine?(s.type="action",s.options=s.options||{},s.action=["undefine",Ft&e(s.undefine)?["*",s.undefine]:s.undefine,s.options],u(s,"undefine")):s.defined?(s.type="action",s.options=s.options||{},s.action=["defined",Ft&e(s.defined)?["*",s.defined]:s.defined,s.options],u(s,"defined")):s.notdefined?(s.type="action",s.options=s.options||{},s.action=["notdefined",Ft&e(s.notdefined)?["*",s.notdefined]:s.notdefined,s.options],u(s,"notdefined")):s.unique?(s.type="action",s.options=s.options||{},s.action=["unique",Ft&e(s.unique)?["*",s.unique]:s.unique,s.options],u(s,"unique")):s.push?(s.type="action",s.options=s.options||{},s.action=["push",s.push,s.options],u(s,"push")):Lt.call(s,"pop")?(s.type="action",s.options=s.options||{},s.action=["pop",s.pop,s.options],u(s,"pop")):s.type="simple","action"===s.type?(s.options=s.options||{},s.options["in-context"]=!(!s.options["in-context"]&&!s["in-context"]),s.options["in-hypercontext"]=!(!s.options["in-hypercontext"]&&!s["in-hypercontext"]),s.options.ci=s.ci=!!(s.options.caseInsesitive||s.options.ci||s.caseInsesitive||s.ci),s.options.autocomplete=!(!s.options.autocomplete&&!s.autocomplete),s.options.mode=s.options.mode||s.mode):"block"===s.type||"comment"===s.type?(s.multiline=Lt.call(s,"multiline")?!!s.multiline:!0,Ft&e(s.escape)||(s.escape=!1)):"simple"===s.type&&(s.meta=s.autocomplete&&Ft&e(s.meta)?s.meta:null,s.ci=!(!s.caseInsesitive&&!s.ci)));m=k;for(n in m)Lt.call(m,n)&&(s=m[n],Bt!==e(s)||s.type?s.type&&(p=s.type=s.type[Ct](),"group"===p&&s.match?(i=e(s.match),Ft&i?(f=s.match[Ct](),"alternation"===f||"either"===f?(s.type="alternation",u(s,"match")):"sequence"===f||"all"===f?(s.type="sequence",u(s,"match")):"zeroorone"===f?(s.type="zeroOrOne",u(s,"match")):"zeroormore"===f?(s.type="zeroOrMore",u(s,"match")):"oneormore"===f?(s.type="oneOrMore",u(s,"match")):(s.type="sequence",u(s,"match"))):jt&i&&(s.type="repeat",s.repeat=s.match,u(s,"match"))):"either"===p?s.type="alternation":"all"===p?s.type="sequence":"lookahead"===p?s.type="positiveLookahead":"grammar"===p&&(s.type="subgrammar"),"subgrammar"!==s.type||s.tokens||(s.tokens=n)):s.ngram||s["n-gram"]?(s.type="ngram",s.tokens=s.ngram||s["n-gram"],s["n-gram"]?u(s,"n-gram"):u(s,"ngram")):s.sequence||s.all?(s.type="sequence",s.tokens=s.sequence||s.all,s.all?u(s,"all"):u(s,"sequence")):s.alternation||s.either?(s.type="alternation",s.tokens=s.alternation||s.either,s.either?u(s,"either"):u(s,"alternation")):s.zeroOrOne?(s.type="zeroOrOne",s.tokens=s.zeroOrOne,u(s,"zeroOrOne")):s.zeroOrMore?(s.type="zeroOrMore",s.tokens=s.zeroOrMore,u(s,"zeroOrMore")):s.oneOrMore?(s.type="oneOrMore",s.tokens=s.oneOrMore,u(s,"oneOrMore")):s.positiveLookahead||s.lookahead?(s.type="positiveLookahead",s.tokens=s.positiveLookahead||s.lookahead,s.lookahead?u(s,"lookahead"):u(s,"positiveLookahead")):s.negativeLookahead?(s.type="negativeLookahead",s.tokens=s.negativeLookahead,u(s,"negativeLookahead")):(s.subgrammar||s.grammar)&&(s.type="subgrammar",s.tokens=s.subgrammar||s.grammar,s.subgrammar?u(s,"subgrammar"):u(s,"grammar")));return t}function _(e,t){t=t||[];var n,o,r,l;for(n=e.ctx;n;){for(o=n.val.symb;o;)l=o.val[1],l[7]&&t.push({word:l[5],meta:(l[6]||"")+" at ("+(l[0]+1)+","+(l[1]+1)+")",ci:l[8],token:l[6],pos:[l[0]+1,l[1]+1,l[2]+1,l[3]+1]}),o=o.prev;o=n.val.tabl;for(r in o)Lt.call(o,r)&&o[r][7]&&(l=o[r],t.push({word:l[5],meta:(l[6]||"")+" at ("+(l[0]+1)+","+(l[1]+1)+")",ci:l[8],token:l[6],pos:[l[0]+1,l[1]+1,l[2]+1,l[3]+1]}));n=n.prev}for(n=e.hctx;n;){for(o=n.val.symb;o;)l=o.val[1],l[7]&&t.push({word:l[5],meta:(l[6]||"")+" at ("+(l[0]+1)+","+(l[1]+1)+")",ci:l[8],token:l[6],pos:[l[0]+1,l[1]+1,l[2]+1,l[3]+1]}),o=o.prev;o=n.val.tabl;for(r in o)Lt.call(o,r)&&o[r][7]&&(l=o[r],t.push({word:l[5],meta:(l[6]||"")+" at ("+(l[0]+1)+","+(l[1]+1)+")",ci:l[8],token:l[6],pos:[l[0]+1,l[1]+1,l[2]+1,l[3]+1]}));n=n.prev}for(o=e.symb;o;)l=o.val[1],l[7]&&t.push({word:l[5],meta:(l[6]||"")+" at ("+(l[0]+1)+","+(l[1]+1)+")",ci:l[8],token:l[6],pos:[l[0]+1,l[1]+1,l[2]+1,l[3]+1]}),o=o.prev;o=e.tabl;for(r in o)Lt.call(o,r)&&o[r][7]&&(l=o[r],t.push({word:l[5],meta:(l[6]||"")+" at ("+(l[0]+1)+","+(l[1]+1)+")",ci:l[8],token:l[6],pos:[l[0]+1,l[1]+1,l[2]+1,l[3]+1]}));return t}function E(t,n,o,r){if(o=o||{},n=n||[],!t||!t.length)return n;var l,s,i,a,c,u,p;for(l=0,s=t.length;s>l;l++)if(c=t[l])if(Ze===c.type){if(r&&r.length&&c.name)for(i=r.length-1;i>=0;i--)r[i].token&&(c.name===r[i].token||c.name.length>r[i].token.length&&c.name.slice(0,r[i].token.length)===r[i].token||c.name.lengthi;i++)p=c.autocompletions[i],Lt.call(o,"w_"+p.word)||(n.push(p),o["w_"+p.word]=1);else Ft===c.token.ptype&&Ft&e(c.token.pattern)&&c.token.pattern.length>1&&(Lt.call(o,"w_"+c.token.pattern)||(n.push({word:""+c.token.pattern,meta:c.name,ci:!!c.ci}),o["w_"+c.token.pattern]=1))}else if(Je===c.type)E(c.token,n,o,r);else if(at&c.type){i=0,a=c.token.length;do E([u=c.token[i++]],n,o,r);while(a>i&&(Xe&u.type&&1>u.min||Be===u.type))}else Xe&c.type&&E([c.token[0]],n,o,r);return n}function P(t,n,o,r){for(var l;Ft&e(l=n[t]||o[t]);)t=l;return r?t:n[t]||o[t]||t}function T(e,t){return e.length>1?o(t?function(t,n){var o=n[n.length-1],r=e[t];o===r||n.push(r)}:function(t,n){var o=n[n.length-1],r=e[t];an.test(r)&&an.test(o)&&o===r||n.push(r)},1,e.length-1,[e[0]]):e}function D(n,o,l){var s,i,a,c,u,p,f,m,h,d,k,g,$,x,b,w=!1;if(b=n.modifier?n.modifier:null,m=new String(Jt(n)),m.pos=0,1===m.length)g=""+n,o[g]||l[g]||(o[g]={type:"simple",tokens:n}),n=g;else{for(s=[],i=[],a="",$=[];m.posu[0]&&(u[0]=0),2>u.length?u.push(u[0]):u[1].length?u[1]=parseInt(u[1],10)||St:u[1]=St,0>u[1]&&(u[1]=0),k=i[i.length-1],g=""+k+["{",u[0],",",isFinite(u[1])?u[1]:"","}"].join(""),l[g]||(l[g]={type:"repeat",repeat:[u[0],u[1]],tokens:[k]}),i[i.length-1]=g):a+=h;else{if("}"===h){a+=h;continue}"&"===h||"!"===h?i.length?(k=i[i.length-1],g=""+k+h,l[g]||(l[g]={type:"!"===h?"negativeLookahead":"positiveLookahead",tokens:[k]}),i[i.length-1]=g):a+=h:"|"===h?(w=!1,i=T(i),i.length>1?(g=""+i.join(" "),l[g]||(l[g]={type:"sequence",tokens:i}),s.push(g)):i.length?s.push(i[0]):a+=h,i=[]):"("===h?($.push([i,s,a]),i=[],s=[],a=""):")"===h&&(i=T(i),i.length>1?(g=""+i.join(" "),l[g]||(l[g]={type:"sequence",tokens:i}),s.push(g)):i.length&&s.push(i[0]),i=[],s=T(s,1),s.length>1?(g=""+s.join(" | "),l[g]||(l[g]={type:"alternation",tokens:s})):s.length&&(g=s[0]),s=[],x=$.pop(),i=x[0],s=x[1],a=x[2],k=g,g="("+k+")",l[g]||(l[g]=r(P(k,o,l))),i.push(g))}}else a+=h;a.length&&(w?(i.length&&(k=i[i.length-1],g=k+"."+a,p=o[g]||l[g],p||(f=P(k,o,l),l[g]=Ft&e(f)?new String(f):r(f),l[g].modifier=a),i[i.length-1]=g),w=!1):"0"===a?(o[kt]||(o[kt]={type:"simple",tokens:0}),i.push(kt)):"^^"===a?(o[pt]||(o[pt]={type:"simple",tokens:ze}),i.push(pt)):"^^1"===a?(o[ft]||(o[ft]={type:"simple",tokens:Ge}),i.push(ft)):"^"===a?(o[mt]||(o[mt]={type:"simple",tokens:Ye}),i.push(mt)):"$"===a?(o[ht]||(o[ht]={type:"simple",tokens:Ue}),i.push(ht)):(o[a]||l[a]||(o[a]={type:"simple",tokens:a}),i.push(a))),a="",i=T(i),i.length>1?(g=""+i.join(" "),l[g]||(l[g]={type:"sequence",tokens:i}),s.push(g)):i.length&&s.push(i[0]),i=[],s=T(s,1),s.length>1?(g=""+s.join(" | "),l[g]||(l[g]={type:"alternation",tokens:s}),n=g):s.length&&(n=s[0]),s=[]}return b&&(o[n]||l[n])&&((o[n]||l[n]).modifier=b),n}function N(r,l,s,c,u,p,f,m,h,d,k){var g,$,y,v,x,b,w,C=null,S=null,_=null;if(ze===r||Ge===r||Ye===r||Ue===r)return new z(r,ze===r?pt:Ge===r?$T_FBNL$:Ye===r?mt:ht,r,S);if(!1===r||0===r)return new z(He,kt,0,S);if(""===r)return new z(We,gt,"",S);if(null===r)return new z(Ze,dt,Pt,S,_);if(jt&e(r)&&(y=r,r="NGRAM_"+y.join("_"),c[r]||(c[r]={type:"ngram",tokens:y})),r=""+r,m[r])return m[r];if(x=P(r,s,c),Ft&e(x)&&(x=D(x,s,c),x=s[x]||c[x]||null),!x)return null;if(g=x.type?ut[x.type[Ct]().replace(en,"")]||Ze:Ze,S=x.msg||null,_=x.modifier||null,$=x.tokens,Ze&g){if(ze===$||Ge===$||Ye===$||Ue===$||!1===$||0===$)return C=new z($||He,r,$||0,S),m[r]=C,C;if(""===$)return C=new z(We,r,"",S),m[r]=C,C;if(null===$)return C=new z(Ze,r,Pt,S,_),m[r]=C,C;if(!$)return null}if(Be&g)x.options=x.options||{},x.options["in-context"]=!(!x.options["in-context"]&&!x["in-context"]),x.options["in-hypercontext"]=!(!x.options["in-hypercontext"]&&!x["in-hypercontext"]),x.options.ci=x.ci=!!(x.options.caseInsesitive||x.options.ci||x.caseInsesitive||x.ci),x.options.autocomplete=!(!x.options.autocomplete&&!x.autocomplete),x.options.mode=x.options.mode||x.mode,Lt.call(x,"action")?"nop"===x.action[0]?x.action[0]=we:"error"===x.action[0]?x.action[0]=Ce:"context-start"===x.action[0]?x.action[0]=_e:"context-end"===x.action[0]?x.action[0]=Ee:"hypercontext-start"===x.action[0]?x.action[0]=Pe:"hypercontext-end"===x.action[0]?x.action[0]=Te:"push"===x.action[0]?x.action[0]=De:"pop"===x.action[0]?x.action[0]=Ne:"define"===x.action[0]?x.action[0]=Oe:"undefine"===x.action[0]?x.action[0]=qe:"defined"===x.action[0]?x.action[0]=Le:"notdefined"===x.action[0]?x.action[0]=Me:"unique"===x.action[0]?x.action[0]=Se:"indent"===x.action[0]?x.action[0]=Ie:"outdent"===x.action[0]&&(x.action[0]=Fe):Lt.call(x,"nop")?x.action=[we,x.nop,x.options]:Lt.call(x,"error")?x.action=[Ce,x.error,x.options]:Lt.call(x,"context")?x.action=[x.context?_e:Ee,x.context,x.options]:Lt.call(x,"hypercontext")?x.action=[x.hypercontext?Pe:Te,x.hypercontext,x.options]:Lt.call(x,"context-start")?x.action=[_e,x["context-start"],x.options]:Lt.call(x,"context-end")?x.action=[Ee,x["context-end"],x.options]:Lt.call(x,"hypercontext-start")?x.action=[Pe,x["hypcontext-start"],x.options]:Lt.call(x,"hypercontext-end")?x.action=[Te,x["hypcontext-end"],x.options]:Lt.call(x,"push")?x.action=[De,x.push,x.options]:Lt.call(x,"pop")?x.action=[Ne,x.pop,x.options]:Lt.call(x,"define")?x.action=[Oe,Ft&e(x.define)?["*",x.define]:x.define,x.options]:Lt.call(x,"undefine")?x.action=[qe,Ft&e(x.undefine)?["*",x.undefine]:x.undefine,x.options]:Lt.call(x,"defined")?x.action=[Le,Ft&e(x.defined)?["*",x.defined]:x.defined,x.options]:Lt.call(x,"notdefined")?x.action=[Me,Ft&e(x.notdefined)?["*",x.notdefined]:x.notdefined,x.options]:Lt.call(x,"unique")?x.action=[Se,Ft&e(x.unique)?["*",x.unique]:x.unique,x.options]:Lt.call(x,"indent")?x.action=[Ie,x.indent,x.options]:Lt.call(x,"outdent")&&(x.action=[Fe,x.outdent,x.options]),!1===x.msg&&(S=!1),x.nop&&(x.action[0]=we),C=new z(Be,r,x.action.slice(),S,_),C.ci=!!(x.options.caseInsensitive||x.options.ci||x.caseInsensitive||x.ci),m[r]=C;else if($=i($),Ze&g){w=x.autocomplete?M(x,Ht&e(x.autocomplete)?i(x.autocomplete):$,r,k):null;var E={};if(b="undefined"!=typeof x.combine?x.combine:!!(jt&e(x.tokens)),C=new z(Ze,r,O(r,$.slice(),l,b,!(!x.caseInsensitive&&!x.ci),p,f,E),S,_,null,w),E.keywords&&(C.keywords=E.keywords.join("|")),m[r]=C,null!=x.except){var T,I,F=i(x.except),A=F.length,R=[];for(T=0;A>T;T++)F[T]&&(I=N(F[T],l,s,c,u,p,f,m,h,d,k),I&&R.push(I));R.length&&(C.except=R)}}else Ke&g?(Ve===g&&L(x,d),C=new z(g,r,q(r,$.slice(),l,p,f),S),C.empty=Lt.call(x,"empty")?!!x.empty:!0,C.mline=Lt.call(x,"multiline")?!!x.multiline:!0,C.esc=Lt.call(x,"escape")?x.escape:!1,C.inter=!!u[r+".inside"],Ve===g&&x.interleave&&h.push(U(C)),_&&(C.modifier=_),m[r]=C):ct&g&&(it===g?m[r]=new z(it,r,$,S,_):st===g?(v=a($),C=t(v,function(e,t){return new z(st,r+"_NGRAM_"+t,null,S,_)}),m[r]=C,o(function(e){C[e].token=i(n(v[e],function(e,t){return e.concat(N(t,l,s,c,u,p,f,m,h,d,k))},[]))},0,v.length-1)):(rt===g||lt===g?C=new z(g,r,null,S,_):Xe&g&&jt&e(x.repeat)?(C=new z(Xe,r,null,S,_),C.min=x.repeat[0],C.max=x.repeat[1]):et===g?(C=new z(et,r,null,S,_),C.min=0,C.max=1):tt===g?(C=new z(tt,r,null,S,_),C.min=0,C.max=St):nt===g?(C=new z(nt,r,null,S,_),C.min=1,C.max=St):C=Je===g?new z(Je,r,null,S,_):new z(Qe,r,null,S,_),m[r]=C,C.token=i(n($,function(e,t){return e.concat(N(t,l,s,c,u,p,f,m,h,d,k))},[]))));return m[r]}function I(e,t){var n,o,r=e.Style,l=e.Lex,s=e.Syntax,i=[],a={};for(n in r)Lt.call(r,n)&&(o=l[n]||s[n],!o||"block"!=o.type&&"comment"!==o.type||(t&&(r[n+".inside"]||r[n])?(n=r[n+".inside"]||r[n],Lt.call(a,n)||(i.push(n),a[n]=1)):t||Lt.call(a,n)||(i.push(n),a[n]=1)));return i}function F(t){var n={};return t.Lex=t.Lex||{},t.Syntax=t.Syntax||{},t=S(t),t.Parser&&t.Parser.length&&o(function r(l,s){var i,a,c,u=s[l];n[u]||(jt&e(u)&&(i=u,u="NGRAM_"+i.join("_"),t.Syntax[u]||(t.Syntax[u]={type:"ngram",tokens:i})),a=P(u,t.Lex,t.Syntax),Ft&e(a)&&(a=D(a,t.Lex,t.Syntax),a=t.Lex[a]||t.Syntax[a]||null),a&&(n[u]=a,c=a.type?ut[a.type[Ct]().replace(en,"")]||Ze:Ze,ct&c&&o(r,0,a.tokens.length-1,a.tokens)))},0,t.Parser.length-1,t.Parser),t}function A(t){var o,l,s,i,a,c,u,p,f,m,h,d,k,g;return t.__parsed?t:(o=t.RegExpID||null,s=t.Extra?r(t.Extra):{},i=t.Style?r(t.Style):{},a=null,c=null,u=t.Lex?r(t.Lex):{},p=t.Syntax?r(t.Syntax):{},f={},m={},h={},k={},g={},d=[],l=t.Parser?r(t.Parser):[],t=S({Style:i,Fold:a,Match:c,Lex:u,Syntax:p,$parser:null,$interleaved:null,$comments:null,$autocomplete:null,$extra:s,__parsed:0}),t.$parser=n(l,function(t,n){var r=N(n,o,u,p,i,f,m,h,d,k,g)||null;return r&&(jt&e(r)?t=t.concat(r):t.push(r)),t},[]),t.$interleaved=d&&d.length?d:null,t.$comments=k,t.$autocomplete=g&&g.autocomplete&&g.autocomplete.length?g.autocomplete:null,t.__parsed=1,t)}function R(t,n,o,r,l){var s,i,a=this;s=a.type=t,a.name=n,a.pattern=o,i=a.ptype=r||Ft,a.key=l||0,Re===s?a.key=!1!==l:je===s?a.pattern[0]=new R(Re,n+"_Start",o[0],null,!1):Pt===i?a.pattern=null:Gt===i&&(a.pattern=Gt&e(o)?[o,0]:[o[0],o[1]||0])}function j(t,n,o,r){var l,s,i,a,c,u,p,f,m,h,d,k=t,g=k.type,$=k.pattern,y=k.key;if(je===g){if(l=k.name,i=$[0],a=$[1],u=j(i,n,o,r))return c=a[u[0]],f=e(c),m=i.pattern[u[0]].ptype,Gt===m&&Yt&f&&(c.regex_pattern?(p=x(c,u[1]),c=new R(Ae,l+"_End",b(p,c.regex_pattern,{}),Gt)):(p=Tt&f?u[1][c+1]:x(c,u[1]),c=new R(Ae,l+"_End",p,p.length>1?Ft:At))),c}else if(Re===g){for(h=0,d=$.length;d>h;h++)if(p=j($[h],n,o,r))return y?[h,p[1]]:p}else{if(s=k.ptype,Pt===s)return!1!==o&&n.end(),[y,""];if(Gt===s){if(p=$[0].xflags.l?n.match($[0]):n.slice(n.pos).match($[0]),p&&0===p.index)return!1!==o&&n.mov(p[$[1]||0].length),[y,$[1]>0?p[$[1]]:p]}else if(Rt===s){if(!0===r){p=-1;var v,w;for(d=$.length-1;d>=0;d--)v=n.indexOf($[Ot](d),n.pos),v>-1&&(-1===p||p>v)&&(p=v,w=$[Ot](d));if(p>-1)return!1!==o&&(n.pos=p+1),[y,w]}else if(p=n[Ot](n.pos)||null,p&&-1<$.indexOf(p))return!1!==o&&n.mov(1),[y,p]}else if(At===s){if(!0===r){if(p=n.indexOf($,n.pos),p>-1)return!1!==o&&(n.pos=p+1),[y,$]}else if(p=n[Ot](n.pos)||null,$===p)return!1!==o&&n.mov(1),[y,p]}else if(Ft===s)if(d=$.length,!0===r){if(p=n.indexOf($,n.pos),p>-1)return!1!==o&&(n.pos=p+d),[y,$]}else if($===n.substr(n.pos,d))return!1!==o&&n.mov(d),[y,$]}return!1}function B(e,t){this.val=e||null,t?this.prev=t:this.prev=null}function z(e,t,n,o,r,l,s,i){var a=this;a.type=e,a.name=t,a.token=n,a.modifier=r||null,a.except=l||null,a.autocompletions=s||null,a.keywords=i||null,a.pos=null,a.msg=!1===o?!1:o||null,a.$msg=null,a.status=0,a.empty=!1,a.ci=!1,a.mline=!0,a.esc=!1,a.inter=!1,a.found=0,a.min=0,a.max=1,a.i0=0,a.$id=null}function G(){var e=this;e.T=0,e.id=null,e.type=null,e.match=null,e.str="",e.pos=null,e.block=null,e.space=null}function U(e,t,n,o){var r=new z(e.type,e.name,e.token,e.msg,e.modifier,e.except,e.autocompletions,e.keywords);return r.empty=e.empty,r.ci=e.ci,r.mline=e.mline,r.esc=e.esc,r.inter=e.inter,r.found=e.found,r.min=e.min,r.max=e.max,r.i0=e.i0,t&&(r.status|=$e),n&&(r.modifier=n),o&&(r.$id=o),r}function Y(e){var t=e.name;return e.$msg?e.$msg:e.status&$e?'Token "'+t+'"'+(e.keywords?": "+e.keywords:"")+" Expected":'Syntax Error: "'+t+'"'}function H(e,t,n,o,r,l,s){e.status&ke&&e.err&&(e.err[""+t+"_"+n+"_"+o+"_"+r+"_"+(l?l.name:"ERROR")]=[t,n,o,r,s||Y(l)])}function W(e,t,n){var o=null;if(n)e&&Lt.call(e,t)&&(o={list:e,key:t,val:e[t]});else for(var r=null,l=e;e;){if(t===e.val[0]){o={list:l,node:e,nodePrev:e.prev,nodeNext:r,key:t,val:e.val[1]};break}r=e,e=e.prev}return o}function Z(e,t,n,o){return o?(e[t]=n,e):new B([t,n],e)}function K(e,t){return t?delete e.list[e.key]:e.nodeNext?e.nodeNext.prev=e.nodePrev:e.list=e.list.prev,e.list}function V(e,t,n){if(e.stack===t)t=e.stack=new B(n,e.stack);else{for(var o=e.stack;o&&o.prev!==t;)o=o.prev;t=new B(n,t),o&&(o.prev=t)}return t}function J(e,t){if(null==e)return null;if(t){for(var n=new B(e.val),o=n,r=e;r.prev;)o.prev=new B(r.prev.val),r=r.prev,o=o.prev;return n}return e}function Q(e,t,n,o){var r,l,s,i,a,c=1/0,u=null,p=1/0;if(l=t.pos,t.spc(),s=t.pos,r=e.stack,t.post.pos?i.pos:t.pos+1,e.stack=r,t.pos>=t.length)););e.stack=r,t.post.pos?(c=t.pos,u=r,p=a):c===t.pos&&p>a&&(c=t.pos,u=r,p=a),t.pos=s,r=r.prev,a++}c=l&&t.pos===s}function X(e,t,n,o){if(!e)return!1;var r=e.type,l=ct&r?oe:Ke&r?ne:Be&r?ee:te;return l(e,t,n,o)}function ee(t,n,o,r){var l,s,i,a,c,u,p,f,m,h,d,k,g,$,y,v,b,w,C,O,q=t,L=q.token||null,M=q.ci,S=q.name,_=!1,E=!(o.status&ke);if(q.status=0,q.$msg=null,!L||!r||!r.pos)return!0;if(b=!!(Ke&r.T),we===L[0]||b&&!r.block)return!0;if(l=L[0],s=L[1],w=L[2]||{},c=q.msg,g=w["in-context"],$=w["in-hypercontext"],b?(v=r.block.match||r.block.str,m=r.block.pos[0][0],h=r.block.pos[0][1],d=r.block.pos[0][2],k=r.block.pos[0][3],_=!0):(v=r.match||r.str,m=r.pos[0],h=r.pos[1],d=r.pos[2],k=r.pos[3],_=!1),Ee===l)o.ctx=o.ctx?o.ctx.prev:null;else if(_e===l)o.ctx=new B({tabl:{},symb:null,queu:null},o.ctx);else if(Te===l)o.hctx=o.hctx?o.hctx.prev:null;else if(Pe===l)o.hctx=new B({tabl:{},symb:null,queu:null},o.hctx);else if(Oe===l)C="hash"===w.mode,O=C?"tabl":"symb",i=s[1],a=s[0],i=x(i,v,_),M&&(i=i[Ct]()),a+="::"+i,f=$&&o.hctx?W(o.hctx.val[O],a,C):g&&o.ctx?W(o.ctx.val[O],a,C):W(o[O],a,C),f||($&&o.hctx?o.hctx.val[O]=Z(o.hctx.val[O],a,[m,h,d,k,a,i,r.type,!!w.autocomplete,M],C):g&&o.ctx?o.ctx.val[O]=Z(o.ctx.val[O],a,[m,h,d,k,a,i,r.type,!!w.autocomplete,M],C):o[O]=Z(o[O],a,[m,h,d,k,a,i,r.type,!!w.autocomplete,M],C));else if(qe===l)C="hash"===w.mode,O=C?"tabl":"symb",i=s[1],a=s[0],i=x(i,v,_),M&&(i=i[Ct]()),a+="::"+i,f=$&&o.hctx?W(o.hctx.val[O],a,C):g&&o.ctx?W(o.ctx.val[O],a,C):W(o[O],a,C),f&&($&&o.hctx?o.hctx.val[O]=K(f,C):g&&o.ctx?o.ctx.val[O]=K(f,C):o[O]=K(f,C));else if(Le===l){if(C="hash"===w.mode,O=C?"tabl":"symb",i=s[1],a=s[0],i=x(i,v,_),M&&(i=i[Ct]()),a+="::"+i,f=$&&o.hctx?W(o.hctx.val[O],a,C):g&&o.ctx?W(o.ctx.val[O],a,C):W(o[O],a,C),!f)return!1!==c&&(q.$msg=c?x(c,i,!0):'Undefined "'+i+'"',y=Y(q),H(o,m,h,d,k,q,y),q.status|=ye),!1}else if(Me===l&&(C="hash"===w.mode,O=C?"tabl":"symb",i=s[1],a=s[0],i=x(i,v,_),M&&(i=i[Ct]()),a+="::"+i,f=$&&o.hctx?W(o.hctx.val[O],a,C):g&&o.ctx?W(o.ctx.val[O],a,C):W(o[O],a,C)))return!1!==c&&(q.$msg=c?x(c,i,!0):'Defined "'+i+'"',y=Y(q),H(o,f.val[0],f.val[1],f.val[2],f.val[3],q,y),H(o,m,h,d,k,q,y),q.status|=ye),!1;if(E)return!0;if(Ce===l)return!c&&Ft&e(s)&&(c=s),q.$msg=c?x(c,v,!0):'Error "'+S+'"',H(o,m,h,d,k,q,Y(q)),q.status|=ye,!1;if(Se===l){if(C="hash"===w.mode,O=C?"tabl":"symb",$){if(!o.hctx)return!0;p=o.hctx.val[O]}else if(g){if(!o.ctx)return!0;p=o.ctx.val[O]}else p=o[O];if(i=s[1],a=s[0],i=x(i,v,_),M&&(i=i[Ct]()),a+="::"+i,f=W(p,a,C))return!1!==c&&(q.$msg=c?x(c,i,!0):'Duplicate "'+i+'"',y=Y(q),H(o,f.val[0],f.val[1],f.val[2],f.val[3],q,y),H(o,m,h,d,k,q,y),q.status|=ye),!1;$?o.hctx.val[O]=Z(o.hctx.val[O],a,[m,h,d,k,a,i,r.type,!!w.autocomplete,M],C):g?o.ctx.val[O]=Z(o.ctx.val[O],a,[m,h,d,k,a,i,r.type,!!w.autocomplete,M],C):o[O]=Z(o[O],a,[m,h,d,k,a,i,r.type,!!w.autocomplete,M],C)}else if(Ne===l){if($){if(!o.hctx)return!0;u=o.hctx.val.queu}else if(g){if(!o.ctx)return!0;u=o.ctx.val.queu}else u=o.queu;if(s){if(s=x(s,v,_),M&&(s=s[Ct]()),!u||s!==u.val[0])return!1!==c&&(u?(q.$msg=c?x(c,[u.val[0],s],!0):'Mismatched "'+u.val[0]+'","'+s+'"',y=Y(q),H(o,u.val[1],u.val[2],u.val[3],u.val[4],q,y),H(o,m,h,d,k,q,y),u=u.prev):(q.$msg=c?x(c,["",s],!0):'Missing matching "'+s+'"',y=Y(q),H(o,m,h,d,k,q,y)),q.status|=ye),$?o.hctx&&(o.hctx.val.queu=u):g?o.ctx&&(o.ctx.val.queu=u):o.queu=u,!1;u=u?u.prev:null}else u=u?u.prev:null;$?o.hctx&&(o.hctx.val.queu=u):g?o.ctx&&(o.ctx.val.queu=u):o.queu=u}else if(De===l&&s){if($){if(!o.hctx)return!0; +u=o.hctx.val.queu}else if(g){if(!o.ctx)return!0;u=o.ctx.val.queu}else u=o.queu;s=x(s,v,_),M&&(s=s[Ct]()),q.$msg=c?x(c,s,!0):'Missing matching "'+s+'"',u=new B([s,m,h,d,k,Y(q)],u),$?o.hctx&&(o.hctx.val.queu=u):g?o.ctx&&(o.ctx.val.queu=u):o.queu=u}return!0}function te(e,t,n,o,r){var l,s,i=e,a=i.token,c=i.modifier,u=i.type,p=i.name,f=i.except,m=n.line,h=t.pos,d=null,k=!1;if(i.status&=xe,i.$msg=r?null:i.msg||null,i.pos=t.pos,f&&!r){s=le(n,t);for(var g=0,$=f.length;$>g;g++)if(l=f[g],i!==l&&Ze===l.type&&te(l,t,n,o,1))return i.pos=l.pos,le(n,t,s),!1}if(ze===u)k=0===n.line;else if(Ge===u)k=n.bline+1===n.line;else if(Ye===u)k=t.sol();else if(Ue===u)t.spc(),t.eol()?k=p:(i.pos=t.pos,t.bck(h));else if(He===u)i.status=0,k=!0;else if(We===u){if(null==o.space||t.eol()?t.spc()&&!t.eol()?(i.pos=t.pos,t.bck(h),i.status&$e&&(i.status|=ye)):k=!0:i.status&$e&&(i.status|=ye),i.status&=ve,!0===k)return k}else Pt===a?(t.end(),k=c||p):(d=j(a,t))&&(d=d[1],k=c||p);return r?k:(!1!==k&&(o.T=u,o.id=p,o.type=k,o.str=t.sel(h,t.pos),o.match=d,o.pos=[m,h,m,t.pos]),!k&&i.status&&i.$msg&&(i.$msg=x(i.$msg,p,!0)),k)}function ne(e,t,n,o){var r,l,s,i,a,c,u,p,f,m,h,d,k,g,$,y,v,b,w,C,O,q,L=e,M=L.name,S=L.type,_=L.modifier,E=L.token,P=L.mline,T=L.inter,D=T?M+".inside":M,N=L.esc,I=!!N,F="",A="",R="",B="",z=L.$id||M,G=n.outer,Y=G&&G[2],H=G&&G[1];if(L.status&=xe,L.$msg=L.msg||null,L.pos=t.pos,C=n.line,O=t.pos,Ve===S&&(L.status&=ve),$=L.status&$e,s=0,i=0,n.block&&n.block.name===M?(i=1,s=1,g=D,r=n.block.end,p=n.block.sp,m=n.block.ip,f=n.block.ep,F=n.block.s,A=n.block.i):!n.block&&(r=j(E,t))&&(i=1,g=M,v=t.pos,p=[C,O],m=[[C,v],[C,v]],f=[C,v],F=t.sel(O,v),A="",B="",n.block={name:M,end:r,sp:p,ip:m,ep:f,s:F,i:A,e:B}),i){if(w=n.stack,l=Pt===r.ptype,y=l||L.empty,T){if(l&&s&&t.sol())return L.status&=ve,n.block=null,!1;if(!s)return v=t.pos,o.T=S,o.id=M,o.type=_||g,o.str=t.sel(O,v),o.match=null,o.pos=[C,O,C,v],V(n,w,U(L,$,0,z)),_||g}if(v=t.pos,a=H?l&&t.eol():j(r,t),u=P,c=0,a)g=l?D:M,B=t.sel(v,t.pos);else if(b=t.pos,d=!1,H||I||Rt!==r.ptype&&At!==r.ptype&&Ft!==r.ptype){for(;!t.eol();){if(H){if(X(H,t,Y,o)){if(t.pos>b){l&&(a=1);break}return!0}if(l){k=t.nxt(1),R+=k;continue}}if(v=t.pos,!d&&j(r,t)){T&&t.pos>v&&v>b?(g=D,t.bck(v),c=1):(g=M,a=1),B=t.sel(v,t.pos);break}k=t.nxt(1),R+=k,d=I&&!d&&N===k,v=t.pos}l&&t.eol()&&(a=1)}else(q=j(r,t,!0,!0))?T&&t.pos>v+q[1].length?(g=D,t.mov(-q[1].length),c=1,R=t.sel(v,t.pos)):(g=M,a=1,R=t.sel(v,t.pos-q[1].length),B=q[1]):(t.end(),g=D,c=1,R=t.sel(v,t.pos));return u=P||I&&d,A+=R,m[1]=[C,v],f=[C,t.pos],a&&!y&&m[0][0]===m[1][0]&&m[0][1]===m[1][1]?(n.block=null,!1):(a||!u&&!c?n.block=null:(n.block.ip=m,n.block.ep=f,n.block.i=A,n.block.e=B,V(n,w,U(L,$,0,z))),o.T=S,o.id=M,o.type=_||g,o.str=t.sel(O,t.pos),o.match=null,o.pos=[C,O,f[0],f[1]],L.pos=t.pos,n.block||(h=F+A+B,o.block={str:h,match:[h,A,F,B],part:[h,F,A,B],pos:[[p[0],p[1],f[0],f[1]],[p[0],p[1],m[0][0],m[0][1]],[m[0][0],m[0][1],m[1][0],m[1][1]],[m[1][0],m[1][1],f[0],f[1]]]}),_||g)}return L.status&&L.$msg&&(L.$msg=x(L.$msg,M,!0)),!1}function oe(e,t,n,o){var r,l,s,i,a,c,u,f,m,h,d,k,g,$,y,v=e,x=v.type,b=(v.name,v.token),w=b.length,C=v.modifier;if(v.status&=xe,v.$msg=v.msg||null,f=t.pos,m=n.stack,v.pos=t.pos,c=0,u=0,it===x){v.status&=xe;var O=new String(b[0]),q=n.stack?n.stack.val:null;return O.subgrammar=1,O.next=q?new z(rt,q.name,[q]):null,O.required=q?q.status&$e:0,O}if(Je===x){for(g=p(),v.status|=$e,k=[],y=le(n,t),d=0,h=d;w>h;h++){if(r=U(b[h],1,C,g),l=X(r,t,n,o),v.pos=r.pos,r.status&$e&&(c++,k.push(Y(r))),!1!==l)return l;r.status&ye&&(u++,le(n,t,y))}return c>0?v.status|=$e:v.status&=ve,w===u&&c>0?v.status|=ye:v.status&=xe,v.status&&!v.$msg&&k.length&&(v.$msg=k.join(" | ")),!1}if(at&x){$=!!(x&Qe),g=v.$id||p(),$?v.status|=$e:v.status&=ve,y=le(n,t),d=0;do r=U(b[d++],$,C,g),l=X(r,t,n,o);while(w>d&&(!0===l&&ot&r.type||!1===l&&!(r.status&$e)));if(v.pos=r.pos,!1!==l){if(!0!==l||He!==r.type)for(h=w-1;h>=d;h--)m=V(n,m,U(b[h],1,C,g));return l.subgrammar&&w>d&&(l.next=new z(rt,b[d].name,[b[d]]),l.required=b[d].status&$e),l}return r.status&ye?($?v.status|=ye:v.status&=xe,le(n,t,y)):$&&r.status&$e&&(v.status|=ye),v.status&&!v.$msg&&(v.$msg=Y(r)),!1}if(ot&x)return it&b[0].type?!0:(y=le(n,t,null,!1),l=X(U(b[0],0),t,n,o),le(n,t,y),lt===x?!1===l:!1!==l);for(g=v.$id||p(),s=v.found,i=v.min,a=v.max,v.status=0,k=[],y=le(n,t),h=0;w>h;h++){if(r=U(b[h],1,C,g),l=X(r,t,n,o),v.pos=r.pos,!1!==l){if(++s,a>=s)return v.found=s,V(n,m,U(v,0,0,p())),v.found=0,l;break}r.status&$e&&(c++,k.push(Y(r))),r.status&ye&&le(n,t,y)}return i>s&&(v.status|=$e),(s>a||i>s&&c>0)&&(v.status|=ye),v.status&&!v.$msg&&k.length&&(v.$msg=k.join(" | ")),!1}function re(e,t){var n=this;n.id=e?f("state"):"state",t instanceof re?(n.line=t.line,n.bline=t.bline,n.status=t.status,n.stack=J(t.stack,!1),n.token=t.token,n.token2=t.token2,n.block=t.block,n.outer=t.outer?[t.outer[0],t.outer[1],new re(e,t.outer[2])]:null,n.queu=t.queu||null,n.symb=t.symb||null,n.tabl=t.tabl||null,n.ctx=t.ctx?new B({tabl:t.ctx.val.tabl,symb:t.ctx.val.symb,queu:t.ctx.val.queu},t.ctx.prev):null,n.hctx=t.hctx?new B({tabl:t.hctx.val.tabl,symb:t.hctx.val.symb,queu:t.hctx.val.queu},t.hctx.prev):null,n.err=t.err||null,n.$eol$=t.$eol$,n.$blank$=t.$blank$):(n.line=-1,n.bline=-1,n.status=t||0,n.stack=null,n.token=null,n.token2=null,n.block=null,n.outer=null,n.queu=null,n.symb=null,n.tabl={},n.ctx=null,n.hctx=null,n.err=n.status&ke?{}:null,n.$eol$=!0,n.$blank$=!0)}function le(e,t,n,o){return n?(e.status=n[0],e.block=n[1],e.outer=n[2],e.stack=n[3],t&&t.pos>n[4]&&t.bck(n[4]),void 0):(n=[e.status,e.block,e.outer,e.stack,t?t.pos:1/0],!1===o&&(e.status=0),n)}function se(e){e.id=null,e.line=null,e.bline=null,e.status=null,e.stack=null,e.token=null,e.token2=null,e.block=null,e.outer=null,e.queu=null,e.symb=null,e.tabl=null,e.ctx=null,e.hctx=null,e.err=null}function ie(e,t,n){var o=new String(e);return o.start=t||0,o.pos=n||0,o.sol=function(){return 0===o.pos},o.eol=function(){return o.pos>=o.length},o.end=function(){return o.pos=o.length,o},o.mov=function(e){return o.pos=0>e?bt(0,o.pos+e):wt(o.length,o.pos+e),o},o.bck=function(e){return o.pos=bt(0,e),o},o.sft=function(){return o.start=o.pos,o},o.nxt=function(e,t){var n,r,l="";if(!0===e){for(t=t||ie.$NONSPC$;o.posi||i>=t)return s+(t-l);s+=i-l,s+=n-s%n,l=i+1}}function ce(n,o){return Ht&e(n)&&(n=y("\\b("+t(i(n).sort(Qt),$).join("|")+")\\b")),!1===o?function(e){return!e||!n.test(e)}:function(e){return!!e&&n.test(e)}}function ue(e,t,n,o,r,l){for(;;){n.lastIndex=e.col;var s=n.exec(e.text);if(!s){if(e.next()){e.text=e.line(e.row);continue}return}{if(t(e.token(e.row,s.index+1)))return e.col=s.index+s[0].length,s;e.col=s.index+1}}}function pe(e,t,n,o,r,l){for(var s,i,a;;){if(s=e.text.indexOf(r,e.col),-1===s){if(e.next()){e.text=e.line(e.row);continue}return}if(t(e.token(e.row,s+1)))return i=e.text.lastIndexOf(l,s),a=i>-1&&!ie.$NOTEMPTY$.test(e.text.slice(i+1,s)),e.col=s+1,a?"autoclosed":"regular";e.col=s+1}}function fe(e,t,n,o,r,l,s,i,a,c){if(-1===e){var u,p,f,m,h,d,k,g,$=1,y=t.first(),v=(l.length,s.length,!1===r);e:for(u=n;u>=y;--u)for(p=t.line(u),f=p.length,m=u===n?o-1:f;;){if(0>m)break;if(h=p.lastIndexOf(l,m),d=p.lastIndexOf(s,m),0>h&&0>d)break;if(m=bt(h,d),v||c||t.token(u,m+1)==r)if(m===d)++$;else if(0===--$){k=u,g=m;break e}--m}return null==k||a&&k===n&&g===o?!1:[k,g,n,o]}var u,p,f,m,h,d,x,b,$=1,w=t.last(),v=(l.length,s.length,!1===r);e:for(u=n;w>=u;++u)for(p=t.line(u),f=p.length,m=u===n?o:0;;){if(m>=f)break;if(h=p.indexOf(l,m),d=p.indexOf(s,m),0>h&&0>d)break;if(0>h&&(h=f),0>d&&(d=f),m=wt(h,d),v||c||t.token(u,m+1)==r)if(m===h)++$;else if(0===--$){x=u,b=m;break e}++m}return null==x||a&&n===x&&b===o?!1:[n,o,x,b]}function me(e,t,n){var o=n.text,r=n.meta,l=n.start,s=n.end,i=t.list.maxlen-o.length-r.length+5;e.innerHTML=['',g(o.slice(0,l)),'',g(o.slice(l,s)),"",g(o.slice(s)),"",new Array(1+i).join(" "),'',g(r),""," "].join(""),e.className=(e.className&&e.className.length?e.className+" ":"")+"cmg-autocomplete-keyword-hint",e.style.position="relative",e.style.width="100%",e.style.maxWidth="120%"}function he(e,t,n){function o(e,t){var r;return r={Mode:o,startState:function(){return{parser:o.$parser,state:new re,inner:{},name:null}},copyState:function(e){return{parser:e.parser,state:new re(0,e.state),inner:e.inner,name:e.name}},token:function(e,t){var n=ie(e.string,e.start,e.pos),o=t.parser.get(n,t).type;return e.pos=n.pos,o},indent:function(o,r,l){return o.parser.indent(o.state,r,l,e,t,n)},fold:o.foldType,lineComment:o.$parser.LC,blockCommentStart:o.$parser.BCS,blockCommentEnd:o.$parser.BCE,blockCommentContinue:o.$parser.BCC,blockCommentLead:o.$parser.BCL,electricInput:o.$parser.$grammar.$extra.electricInput||!1,electricChars:o.$parser.$grammar.$extra.electricChars||!1},o.mode=r,r}return n=n||fn,o.$id=f("codemirror_grammar_mode"),o.$parser=new kn.Parser(A(e),t),o.$parser.Mode=o,o.options=function(e,t,n){n=n||{};var r=e.getTokenAt(t).state,l=r&&r.parser||o.$parser;return n.lineComment=l.LC,n.blockCommentStart=l.BCS,n.blockCommentEnd=l.BCE,n.blockCommentContinue=l.BCC,n.blockCommentLead=l.BCL,n.electricInput=l.$grammar.$extra.electricInput||!1,n.electricChars=l.$grammar.$extra.electricChars||!1,n},o.supportGrammarAnnotations=!1,o.validator=function r(e,t){return o.supportGrammarAnnotations&&o.$parser&&e&&e.length?o.$parser.validate(e,r.options||t||{},n):[]},o.linter=o.validator,o.supportAutoCompletion=!0,o.autocompleter=function l(e,t){if(o.supportAutoCompletion){var r=e.getTokenAt(e.getCursor()).state,s=r&&r.parser||o.$parser;return t=l.options||t||{},Lt.call(t,"renderer")||(t.renderer=l.renderer||me),s.autocomplete(e,t,n)}},o.autocompleter.renderer=me,o.supportCodeFolding=!0,o.foldType="fold_"+o.$id,o.folder=function(e,t){if(o.supportCodeFolding){var r,l=e.getTokenAt(t).state,s=l&&l.parser||o.$parser;if(r=s.fold(e,t,n))return{from:n.Pos(r[0],r[1]),to:n.Pos(r[2],r[3])}}},o.supportCodeMatching=!0,o.matchType="match_"+o.$id,o.matcher=function s(e){if(o.supportCodeMatching){if(s.clear(e),e.state.$highlightPending)return;var t=e.getTokenAt(e.getCursor()).state,r=t&&t.parser||o.$parser;e.state.$highlightPending=!0,setTimeout(function(){e.operation(function(){e.state.$highlightPending=!1;var t,l=s.options||{},i=l.maxHighlightLineLength||1e3,a=[],c=e.listSelections(),u="CodeMirror-matchingtag",p="CodeMirror-nonmatchingbracket",f=0;for(c.length;1>f;f++)t=r.match(e,c[f].to(),n),null!=t&&(!1===t?(c[f].empty()?(t=c[f].to(),t=[n.Pos(t.line,t.ch-1),t]):t=[c[f].from(),c[f].to()],a.push(e.markText(t[0],t[1],{className:p}))):!1===t.match?a.push(e.markText(n.Pos(t[0],t[1]),n.Pos(t[2],t[3]),{className:p})):"end"===t.match&&e.getLine(t[0]).length<=i?(a.push(e.markText(n.Pos(t[0],t[1]),n.Pos(t[2],t[3]),{className:u})),e.getLine(t[4]).length<=i&&a.push(e.markText(n.Pos(t[4],t[5]),n.Pos(t[6],t[7]),{className:u}))):"start"===t.match&&e.getLine(t[4]).length<=i&&(a.push(e.markText(n.Pos(t[4],t[5]),n.Pos(t[6],t[7]),{className:u})),e.getLine(t[0]).length<=i&&a.push(e.markText(n.Pos(t[0],t[1]),n.Pos(t[2],t[3]),{className:u}))));e.state[o.matchType]=a})},50)}},o.matcher.clear=function(e){e.operation(function(){var t=e.state[o.matchType];if(e.state[o.matchType]=null,t&&t.length)for(var n=0,r=t.length;r>n;n++)t[n].clear()})},o.submode=function(e,t){o.$parser.subparser(e,t.Mode.$parser)},o.dispose=function(){o.$parser&&o.$parser.dispose(),o.$parser=o.validator=o.linter=o.autocompleter=o.folder=o.matcher=o.mode=null},o}var de=1,ke=2,ge=32,$e=4,ye=8,ve=~$e,xe=~ye,be=$e|ye,we=0,Ce=4,Oe=8,qe=9,Le=10,Me=11,Se=12,_e=16,Ee=17,Pe=18,Te=19,De=32,Ne=33,Ie=128,Fe=129,Ae=2,Re=4,je=8,Be=4,ze=8,Ge=9,Ue=16,Ye=32,He=128,We=256,Ze=512,Ke=1024,Ve=1025,Je=2048,Qe=4096,Xe=8192,et=8193,tt=8194,nt=8195,ot=16384,rt=ot,lt=16385,st=32768,it=65536,at=Qe|st,ct=Je|Qe|Xe|ot|st|it,ut={action:Be,simple:Ze,block:Ke,comment:Ve,subgrammar:it,alternation:Je,sequence:Qe,repeat:Xe,zeroorone:et,zeroormore:tt,oneormore:nt,positivelookahead:rt,negativelookahead:lt,ngram:st},pt="$|SOF|$",ft="$|NONBLANK|$",mt="$|SOL|$",ht="$|EOL|$",dt="$|ENDLINE|$",kt="$|EMPTY|$",gt="$|NONSPACE|$",$t=void 0,yt="prototype",vt=Object[yt],xt=Object.create,bt=Math.max,wt=Math.min,Ct="toLowerCase",Ot="charAt",qt=vt.toString,Lt=vt.hasOwnProperty,Mt=vt.propertyIsEnumerable,St=1/0,_t=4,Et=8,Pt=16,Tt=32,Dt=33,Nt=34,It=64,Ft=128,At=129,Rt=130,jt=256,Bt=512,zt=1024,Gt=2048,Ut=4096,Yt=Ft|Tt,Ht=Ft|jt,Wt=Gt|jt,Zt=Ft|jt|Gt,Kt={"[object Number]":Tt,"[object String]":Ft,"[object Array]":jt,"[object RegExp]":Gt,"[object Date]":Ut,"[object Function]":zt,"[object Object]":Bt},Vt=/^\s+|\s+$/g,Jt=String[yt].trim?function(e){return e.trim()}:function(e){return e.replace(Vt,"")},Qt=function(e,t){return t.length-e.length},Xt=/\r\n|\r|\n/g,en=/[\-_]/g,tn=0,nn=/([.*+?^${}()|[\]\/\\\-])/g,on=/[&"'<>]/g,rn=/^([.!&\[\]{}()*+?\/|'"]|\s)/,ln="(\\s|\\W|$)",sn=/(l?i?l?)x(l?i?l?)$/,an=/[*+]$/;re.prototype.toString=function(){var e=this;return e.id+"_"+e.line+"_"+e.bline+"_"+(e.block?e.block.name:"0")},ie.$SPC$=/^[\s\u00a0]+/,ie.$NONSPC$=/[^\s\u00a0]/,ie.$NOTEMPTY$=/\S/,ie.$SPACE$=/^\s*/;var cn=h({constructor:function(e,t,n){var o=this;o.$grammar=e,o.$DEF=t||null,o.$ERR=n||null,o.DEF=o.$DEF,o.ERR=o.$ERR,o.$folders=[],o.$matchers=[],o.$subgrammars={}},$grammar:null,$subgrammars:null,$folders:null,$matchers:null,$n$:"name",$t$:"type",$v$:"token",$DEF:null,$ERR:null,DEF:null,ERR:null,dispose:function(){var e=this;return e.$grammar=e.$subgrammars=null,e.$folders=e.$matchers=null,e.$n$=e.$t$=e.$v$=null,e.$DEF=e.$ERR=e.DEF=e.ERR=null,e},token:function(e,t,n){if(t.token2){var o=t.token2[0];return e.pos=t.token2[1],e.sft(),t.token=t.token2[3],t.$eol$=e.eol(),t.$blank$=t.$blank$&&(t.token2[2]||t.$eol$),t.token2=null,o}var r,l,s,i,a,c,u,p,f,m,h,d,k,g,$,y,v,x,b=this,w=b.$grammar,C=w.Style,O=b.DEF,q=b.ERR,o={},L=b.$n$,M=b.$t$,S=b.$v$,_=w.$interleaved,E=w.$parser,P=E.length,T=_?_.length:0,D=t.outer,N=D&&D[2],I=D&&D[1];if(e.sol()&&(t.$eol$&&(t.$blank$&&(t.bline=t.line),t.$eol$=!1,t.line++),t.$blank$=t.bline+1===t.line),t.$actionerr$=!1,t.token=null,i=t.line,a=e.pos,m=!1,d=!0,h=!1,k=!1,D&&b===D[0]){if(o[L]=null,o[M]=O,o[S]=null,I){if(s=new G,X(I,e,N,s))return t.outer=null,{parser:b,state:N};for(e.nxt(1);!e.eol();){if(X(I,e,N,s)){if(e.pos>a)break;return t.outer=null,{parser:b,state:N}}e.nxt(1)}}else e.spc(),e.eol()?k=!0:e.end();return o[S]=e.cur(1),t.$eol$=e.eol(),t.$blank$=t.$blank$&&(k||t.$eol$),o}if(t.stack&&Ue===t.stack.val.type&&e.sol()&&(t.stack=t.stack.prev),(!t.stack||null==t.block)&&e.spc()){if(t.stack&&it===t.stack.val.type)return e.bck(a),r=t.stack.val,t.stack=t.stack.prev,m=X(r,e,t,s),g=""+m,b.$subgrammars[g]?($=b.$subgrammars[g],y=new re(1,n[g]?n[g]:t.status),N=t):($=b,y=new re,N=t),y.outer=[b,m.next,N],{parser:$,state:y,toInner:g};d=!0,k=!0}if(o[L]=null,o[M]=O,o[S]=null,d)for(s=new G,k&&(s.space=[a,e.pos],e.sft()),c=0;d&&(t.stack||P>c)&&!e.eol();){if(p=e.pos,f=t.stack,I){if(e.spc(),X(I,e,N,s))return s.space||e.pos>p?(s.space&&(e.start=s.space[0],e.pos=s.space[1]),o[S]=e.cur(1),t.$eol$=e.eol(),t.$blank$=t.$blank$&&!0,o):(t.outer=null,{parser:D[0],state:N,fromInner:t});e.bck(p)}if(v=!1,T&&!t.block)for(u=0;T>u;u++)if(r=_[u],m=X(r,e,t,s),!1!==m){v=!0;break}if(d&&!v){if(!t.stack&&c>=P)break;t.stack?(r=t.stack.val,t.stack=t.stack.prev):r=E[c++],m=X(r,e,t,s)}if(!1===m){if(r.status&be){t.token=r,k=Q(t,e,s,r)||k,h=!0,d=!1;break}}else{if(m.subgrammar)return g=""+m,b.$subgrammars[g]?($=b.$subgrammars[g],y=new re(1,n[g]?n[g]:t.status),N=t):($=b,y=new re,N=t),y.outer=[b,m.next,N],s.space?(t.token2=[{parser:$,state:y,toInner:g},e.pos,k,t.token],t.token=null,e.start=s.space[0],e.pos=s.space[1],o[S]=e.cur(1),t.$eol$=e.eol(),t.$blank$=t.$blank$&&!0,o):{parser:$,state:y,toInner:g};if(t.stack&&t.stack.prev&&e.eol()&&Ke&t.stack.val.type&&t.block&&t.block.name===t.stack.val.name)for(u=t.stack.prev;u&&Be===u.val.type;)l=u,u=u.prev,x=ee(l,e,t,s),l.status&ye?t.$actionerr$=!0:x&&!0!==m&&l.modifier&&(m=l.modifier);else if(t.stack&&Be===t.stack.val.type)for(;t.stack&&Be===t.stack.val.type;)l=t.stack.val,t.stack=t.stack.prev,x=ee(l,e,t,s),l.status&ye?t.$actionerr$=!0:x&&!0!==m&&l.modifier&&(m=l.modifier);if(!0!==m){d=!1;break}}}return d&&(s.space?(e.start=s.space[0],e.pos=s.space[1],m=!1,s.space=null):e.nxt(1)),o[S]=e.cur(1),!1!==m?(m=m?C[m]||O:O,o[L]=r?r.name:null):h?(m=q,t.status&ke&&H(t,i,a,i,e.pos,r)):m=O,o[M]=m,s.space&&(t.token2=[o,e.pos,k,t.token],t.token=null,e.start=s.space[0],e.pos=s.space[1],o={},o[L]=null,o[M]=O,o[S]=e.cur(1),k=!0),t.$eol$=e.eol(),t.$blank$=t.$blank$&&(k||t.$eol$),o},get:function(e,t){for(var n=t.parser.token(e,t.state,t.inner);n&&n.parser;)n.fromInner&&t.parser!==n.parser&&(t.state.err=n.fromInner.err,t.name&&(t.inner[t.name]=n.fromInner)),n.state.err=t.state.err,n.state.line=t.state.line,n.state.bline=t.state.bline,n.state.$blank$=t.state.$blank$,n.state.$eol$=t.state.$eol$,n.state.$full_parse$=t.state.$full_parse$,t.state=n.state,t.parser=n.parser,t.name=n.toInner,n=t.parser.get(e,t);return n},tokenize:function(e,t,n,o){if(o=o||[],e.eol())t.state.line++,t.state.$blank$&&t.state.bline++;else for(;!e.eol();)o.push(t.parser.get(e,t));return o},parse:function(e,t){var n,r,l,s,i,a,c=(e||"").split(Xt),u=c.length,p=null;if(t=t||de,l=!!(t&ke),s=!!(t&de),r={parser:this,state:new re(0,t),inner:{}},r.state.$full_parse$=!0,o(function(e){c[e]+="\n"},0,u-2),s?p=o(t&ge?function(e,t){r.parser.tokenize(ie(c[e]),r,e,t)}:function(e,t){t.push(r.parser.tokenize(ie(c[e]),r,e))},0,u-1,[]):o(function(e){var t=ie(c[e]);if(t.eol())r.state.line++,r.state.$blank$&&r.state.bline++;else for(;!t.eol();)r.parser.get(t,r)},0,u-1),n=r.state,l&&n.queu)for(;n.queu;)i=n.queu.val,n.queu=n.queu.prev,H(n,i[1],i[2],i[3],i[4],null,i[5]);return a=s&&l?{tokens:p,errors:n.err}:s?p:n.err,se(n),r=n=null,a},autocompletion:function(e,t,n){var o,r,l=e.stack,s={},i=E([e.token],[],s,n);for(t=t||0;l;){if(o=l.val,r=o.type,Xe&r){if(i=E([o],i,s,n),0=c;++c)if(r=t.line(c),l=t.indentation(r),l>o)i=c,a=r.length;else if(e.test(r))break;return i?[p,s,i,a]:void 0}}},Delimited:function(e,t,n,o){return e&&t&&e.length&&t.length?(n=n||s,function(r){var l,s,i,a,c,u,p=r.row,f=r.col;for(l=r.line(p),i=f,a=0;;){var c=0>=i?-1:l.lastIndexOf(e,i-1);if(-1!==c){if(1===a&&f>c)return;if(n(u=r.token(p,c+1))){s=c+e.length;break}i=c-1}else{if(1===a)return;a=1,i=l.length}}return fe(1,r,p,s,u,e,t,n,!0,o)}):function(){}},MarkedUp:function(e,t,n,o,r){return e=e||s,t=t||"<",n=n||">",o=o||"/",r=r||y($(t)+"("+$(o)+"?)([a-zA-Z_\\-][a-zA-Z0-9_\\-:]*)",{g:1}),function(l){l.col=0,l.min=l.first(),l.max=l.last(),l.text=l.line(l.row);for(var s,i,a,c,u,p,f,m,h,d=l.row;;){if(s=ue(l,e,r,t,n,o),!s||l.row!==d||!(i=pe(l,e,r,t,n,o)))return;if(!s[1]&&"autoclosed"!==i)for(a=[l.row,l.col],u=s[2],c=null,p=[];;){if(f=ue(l,e,r,t,n,o),d=l.row,m=l.col-(f?f[0].length:0),!f||!(i=pe(l,e,r,t,n,o)))return!1;if("autoclosed"!==i)if(f[1]){for(h=p.length-1;h>=0;--h)if(p[h]===f[2]){p.length=h;break}if(0>h&&(!u||u===f[2]))return[a[0],a[1],d,m]}else p.push(f[2])}}}}},pn={Pattern:function(e,t,n){return function(){}},Delimited:function(e,t,n,o){return e&&t&&e.length&&t.length?(n=n||s,function(r){var l,s=r.col,i=r.row,a=r.line(i),c=!1,u=e.length,p=t.length;return s>=u&&(1===u&&e===a.charAt(s-1)||e===a.slice(s-u,s))?(l=fe(1,r,i,s,c,e,t,n,!1,o),l?(l=[l[0],l[1]-u,l[0],l[1],l[2],l[3],l[2],l[3]+p],l.match="end"):(l=[i,s-u,i,s],l.match=!1),l):s>=p&&(1===p&&t===a.charAt(s-1)||t===a.slice(s-p,s))?(l=fe(-1,r,i,s-p,c,e,t,n,!1,o),l?(l=[l[0],l[1],l[0],l[1]+u,l[2],l[3],l[2],l[3]+p],l.match="start"):(l=[i,s-p,i,s],l.match=!1),l):void 0}):function(){}},MarkedUp:function(e,t,n,o,r){return function(){}}},fn="undefined"!=typeof CodeMirror?CodeMirror:{Pass:{toString:function(){return"CodeMirror.Pass"}}},mn=/[\w$]/,hn=function(e,t){return t.score-e.score},dn=h(cn,{constructor:function gn(t,n){var r,l=this,i=null,a=null;if(cn.call(l,t,null,"error"),l.DEF=n||l.$DEF,l.ERR=t.Style.error||l.$ERR,l.LC=t.$comments.line?t.$comments.line[0]:null,l.BCS=t.$comments.block?t.$comments.block[0][0]:null,l.BCE=t.$comments.block?t.$comments.block[0][1]:null,l.BCC=l.BCL=t.$comments.block?t.$comments.block[0][2]:null,t.$comments.block&&t.$comments.block.length){r=gn.Type("comment");for(var c=0,u=t.$comments.block.length;u>c;c++)l.$folders.push(gn.Fold.Delimited(t.$comments.block[c][0],t.$comments.block[c][1],r,"comment"))}t.Fold&&Ft&e(t.Fold)?i=t.Fold[Ct]():t.$extra.fold&&(i=t.$extra.fold[Ct]()),a=t.Match&&Ft&e(t.Match)?t.Match[Ct]():t.$extra.match?t.$extra.match[Ct]():i;var p=I(t,1);r=p.length?gn.Type(p,!1):s,i&&(i=i.split("+"),o(function(e,t){var n,o=Jt(t[e]);"braces"===o?l.$folders.push(gn.Fold.Delimited("{","}",r)):"brackets"===o?l.$folders.push(gn.Fold.Delimited("[","]",r)):"parens"===o||"parentheses"===o?l.$folders.push(gn.Fold.Delimited("(",")",r)):"brace"===o||"cstyle"===o||"c"===o?(l.$folders.push(gn.Fold.Delimited("{","}",r)),l.$folders.push(gn.Fold.Delimited("[","]",r))):"indent"===o||"indentation"===o?l.$folders.push(gn.Fold.Indented()):"tags"===o||"markup"===o||"html"===o||"xml"===o?(l.$folders.push(gn.Fold.Delimited("",gn.Type(["comment","tag"],!1))),l.$folders.push(gn.Fold.MarkedUp(gn.Type("tag"),"<",">","/"))):-1<(n=o.indexOf(","))&&l.$folders.push(gn.Fold.Delimited(o.slice(0,n),o.slice(n+1),r))},0,i.length-1,i)),a&&(a=a.split("+"),o(function(e,t){var n,o=Jt(t[e]);"braces"===o?l.$matchers.push(gn.Match.Delimited("{","}")):"brackets"===o?l.$matchers.push(gn.Match.Delimited("[","]")):"parens"===o||"parentheses"===o?l.$matchers.push(gn.Match.Delimited("(",")")):"brace"===o||"cstyle"===o||"c"===o?(l.$matchers.push(gn.Match.Delimited("{","}")),l.$matchers.push(gn.Match.Delimited("[","]")),l.$matchers.push(gn.Match.Delimited("(",")"))):"tags"===o||"markup"===o||"html"===o||"xml"===o?l.$matchers.push(gn.Match.MarkedUp(gn.Type("tag"),"<",">","/")):-1<(n=o.indexOf(","))&&l.$matchers.push(gn.Match.Delimited(o.slice(0,n),o.slice(n+1)))},0,a.length-1,a))},LC:null,BCS:null,BCE:null,BCL:null,BCC:null,dispose:function(){var e=this;return e.LC=e.BCS=e.BCE=e.BCL=e.BCC=null,cn[yt].dispose.call(e)},validate:function(e,t,n){if(!e||!e.length)return[];var o,r,l,s,i=this,a=[],c=i.parse(e,ke);if(!c)return a;t=t||{},l=Lt.call(t,"type")?t.type:"error",s=Lt.call(t,"msg")?t.msg:"Syntax Error";for(o in c)Lt.call(c,o)&&(r=c[o],a.push({message:r[4]||s,severity:l,from:n.Pos(r[0],r[1]),to:n.Pos(r[2],r[3])}));return a},autocomplete:function(e,t,o){t=t||{};var r,l,s,i,a,c,u,p,f,m,h=this,d=[],k=Lt.call(t,"prefixMatch")?!!t.prefixMatch:!0,g=Lt.call(t,"inContext")?!!t.inContext:!1,$=Lt.call(t,"dynamic")?!!t.dynamic:!1,y=Lt.call(t,"caseInsensitiveMatch")?!!t.caseInsensitiveMatch:!1,v=e.getCursor(),x=v.ch,b=x,w=x,C=w,O=0,q=h.$grammar.$autocomplete&&h.$grammar.$autocomplete.length?h.$grammar.$autocomplete:null;if($||q){for(c=t.word||mn,l=e.getLine(v.line);b&&c.test(l[Ot](b-1));)--b;if(!k)for(;C=a&&(n=t.meta,o=!!d.ci,h=y||o,h?(c=d[Ct](),m=i):(c=d,m=s),(l=c.indexOf(m))>=0&&(!k||0===l)&&(r=h?d.indexOf(s):l,g+n.length>O&&(O=g+n.length),e.push({text:d,name:d,meta:n,start:0>r?l:r,end:(0>r?l:r)+s.length,match:s,displayText:d+" ["+n+"]",render:u,score:1e3-10*(g-a)-5*(0>r?l+3:r)}))):(n=t.meta,g+n.length>O&&(O=g+n.length),e.push({text:d,name:d,meta:n,start:0,end:0,match:"",displayText:d+" ["+n+"]",render:u,score:p?1e3-10*g:f--})),e};m=$?h.dynamic_autocompletion(r):null,g&&(p=!1,d=n(h.autocompletion(r,null,m),L,d)),m&&!m.length&&(m=null),d.length||!m&&!q||(p=!0,d=n((m||[]).concat(q||[]),L,d)),d.length&&(d=d.sort(hn)),d.maxlen=O}return{list:d,from:o.Pos(v.line,b),to:o.Pos(v.line,C)}},indent:function(e,t,n,o,r,l){return l.Pass},iterator:function(e,t){var n=e.getOption("tabSize");return{row:0,col:0,min:0,max:0,line:function(t){return e.getLine(t)},first:function(){return e.firstLine()},last:function(){return e.lastLine()},next:function(){var e=this;if(!(e.row>=e.max))return e.col=0,e.row++,!0},prev:function(){var e=this;if(!(e.row<=e.min))return e.col=0,e.row--,!0},indentation:function(e){return ae(e,null,n)},state:function(n,o){var r=e.getTokenAt(t.Pos(n,o||0)).state;return r.state||r},token:function(n,o){return e.getTokenTypeAt(t.Pos(n,o||0))},tokens:function(t){return e.getLineTokens(t)}}},fold:function(e,t,n){var o,r,l,s=this,i=s.$folders,a=i.length;if(a)for(r=s.iterator(e,n),r.row=t.line,r.col=t.ch||0,o=0;a>o;o++)if((l=i[o](r))||!1===l)return l},match:function(e,t,n){var o,r,l,s=this,i=s.$matchers,a=i.length;if(a)for(r=s.iterator(e,n),r.row=t.line,r.col=t.ch||0,o=0;a>o;o++)if((l=i[o](r))||!1===l)return l}});dn.Type=ce,dn.Fold=un,dn.Match=pn;var kn={VERSION:"4.2.1",clone:r,extend:l,pre_process:F,parse:A,getMode:he,Parser:dn};return kn}); \ No newline at end of file diff --git a/editor-grammar b/editor-grammar index 466545b..3ad07d6 160000 --- a/editor-grammar +++ b/editor-grammar @@ -1 +1 @@ -Subproject commit 466545b1c2c34e968ea8b80530713782d952b9d1 +Subproject commit 3ad07d6c8ecb614756e302fe89fc7d5405263b23 diff --git a/src/main.js b/src/main.js index c3271d2..7371379 100644 --- a/src/main.js +++ b/src/main.js @@ -146,12 +146,12 @@ var CodeMirrorParser = Class(Parser, { if ( !code_errors ) return errors; options = options || {}; - err_type = options[HAS]('type') ? options.type : "error"; - err_msg = options[HAS]('msg') ? options.msg : "Syntax Error"; + err_type = HAS.call(options,'type') ? options.type : "error"; + err_msg = HAS.call(options,'msg') ? options.msg : "Syntax Error"; for (err in code_errors) { - if ( !code_errors[HAS](err) ) continue; + if ( !HAS.call(code_errors,err) ) continue; error = code_errors[err]; errors.push({ message: error[4] || err_msg, @@ -166,16 +166,18 @@ var CodeMirrorParser = Class(Parser, { // adapted from codemirror anyword-hint helper ,autocomplete: function( cm, options, CodeMirror ) { options = options || {}; - var parser = this, list = [], - prefix_match = options[HAS]('prefixMatch') ? !!options.prefixMatch : true, - in_context = options[HAS]('inContext')? !!options.inContext : false, - dynamic = options[HAS]('dynamic')? !!options.dynamic : false, - case_insensitive_match = options[HAS]('caseInsensitiveMatch') ? !!options.caseInsensitiveMatch : false, + var parser = this, state, list = [], + prefix_match = HAS.call(options,'prefixMatch') ? !!options.prefixMatch : true, + in_context = HAS.call(options,'inContext')? !!options.inContext : false, + dynamic = HAS.call(options,'dynamic')? !!options.dynamic : false, + case_insensitive_match = HAS.call(options,'caseInsensitiveMatch') ? !!options.caseInsensitiveMatch : false, cur = cm.getCursor(), curLine, start0 = cur.ch, start = start0, end0 = start0, end = end0, - token, token_i, len, maxlen = 0, word_re, renderer, - case_insensitive_match, prefix_match, in_context, dynamic, sort_by_score, score; - if ( dynamic || !!parser.$grammar.$autocomplete ) + token, token_i, len, maxlen = 0, word_re, renderer, sort_by_score, score, + grammar_tokens = parser.$grammar.$autocomplete && parser.$grammar.$autocomplete.length ? parser.$grammar.$autocomplete : null, + dynamic_tokens + ; + if ( dynamic || grammar_tokens ) { word_re = options.word || RE_W; curLine = cm.getLine(cur.line); while (start && word_re.test(curLine[CHAR](start - 1))) --start; @@ -185,6 +187,8 @@ var CodeMirrorParser = Class(Parser, { renderer = options.renderer || null; sort_by_score = false; score = 1000; + state = cm.getTokenAt( CodeMirror.Pos( cur.line, start ), true ).state.state; + var suggest = function suggest( list, word ){ var w = word.word, wl = w.length, wm, case_insensitive_word, @@ -228,20 +232,18 @@ var CodeMirrorParser = Class(Parser, { return list; }; - if ( dynamic || in_context ) + dynamic_tokens = dynamic ? parser.dynamic_autocompletion( state ) : null; + + if ( in_context ) { sort_by_score = false; - list = operate(parser.autocompletion( cm.getTokenAt( CodeMirror.Pos( cur.line, start ), true ).state.state, null, dynamic ), suggest, list); - if ( !list.length && !!self.$grammar.$autocomplete ) - { - sort_by_score = true; - list = operate(parser.$grammar.$autocomplete, suggest, list); - } + list = operate(parser.autocompletion( state, null, dynamic_tokens ), suggest, list); } - else + if ( dynamic_tokens && !dynamic_tokens.length ) dynamic_tokens = null; + if ( !list.length && (dynamic_tokens || grammar_tokens) ) { sort_by_score = true; - list = operate(parser.$grammar.$autocomplete, suggest, list); + list = operate((dynamic_tokens || []).concat(grammar_tokens || []), suggest, list); } if ( list.length ) list = list.sort( by_score ); list.maxlen = maxlen; @@ -422,7 +424,7 @@ function get_mode( grammar, DEFAULT, CodeMirror ) { var s = cm.getTokenAt( cm.getCursor() ).state, parser = (s && s.parser) || CMode.$parser; options = autocompleter.options /*|| Mode.autocompleter.options*/ || options || {}; - if ( !options[HAS]('renderer') ) options.renderer = autocompleter.renderer /*|| Mode.autocompleter.renderer*/ || autocomplete_renderer; + if ( !HAS.call(options,'renderer') ) options.renderer = autocompleter.renderer /*|| Mode.autocompleter.renderer*/ || autocomplete_renderer; return parser.autocomplete( cm, options, CodeMirror ); } }; diff --git a/test/grammar-js-scoped.html b/test/grammar-js-scoped.html index 9d89df8..a47537a 100644 --- a/test/grammar-js-scoped.html +++ b/test/grammar-js-scoped.html @@ -45,6 +45,7 @@

CodeMirror (v.0) Grammar (v."] ,"meta:block" : ["RE::/<\\?[_a-zA-Z][\\w\\._\\-]*/", "?>"] ,"cdata:block" : [""] - ,"open_tag" : "RE::/<([_a-zA-Z][_a-zA-Z0-9\\-]*)/" - ,"close_tag" : "RE::/<\\/([_a-zA-Z][_a-zA-Z0-9\\-]*)>/" + ,"open_tag" : "RE::/<((?:[_a-zA-Z][_a-zA-Z0-9\\-]*:)?[_a-zA-Z][_a-zA-Z0-9\\-]*)\\b/" + ,"close_tag" : "RE::/<\\/((?:[_a-zA-Z][_a-zA-Z0-9\\-]*:)?[_a-zA-Z][_a-zA-Z0-9\\-]*)>/" ,"attribute" : "RE::/[_a-zA-Z][_a-zA-Z0-9\\-]*/" ,"string:line-block" : [["\""], ["'"]] ,"number" : ["RE::/[0-9]\\d*/", "RE::/#[0-9a-fA-F]+/"] @@ -45,24 +45,25 @@ var xml_grammar = { ,"text" : "RE::/[^<&]+/" // actions - ,"tag_ctx:action" : {"context":true} - ,"\\tag_ctx:action" : {"context":false} - ,"unique_id:action" : {"unique":["xml", "$1"],"msg":"Duplicate id value \"$0\""} - ,"unique_att:action" : {"unique":["tag", "$0"],"msg":"Duplicate attribute \"$0\"","in-context":true} - ,"tag_opened:action" : {"push":"<$1>","ci":true} - ,"tag_closed:action" : {"pop":"<$1>","ci":true,"msg":"Tags \"$0\" and \"$1\" do not match"} - ,"tag_autoclosed:action" : {"pop":null} - ,"out_of_place:error" : "\"$2$3\" can only be at the beginning of XML document" + ,"@tag:action" : {"context":true} + ,"tag@:action" : {"context":false} + ,"@unique_id:action" : {"unique":["xml", "$1"],"msg":"Duplicate id value \"$0\"","mode":"hash"} + ,"@unique_att:action" : {"unique":["att", "$0"],"msg":"Duplicate attribute \"$0\"","mode":"hash","in-context":true} + ,"@tag_opened:action" : {"push":"<$1>","ci":true} + ,"@tag_closed:action" : {"pop":"<$1>","ci":true,"msg":"Tags \"$0\" and \"$1\" do not match"} + ,"@tag_autoclosed:action" : {"pop":null} + ,"@autocomplete:action" : {"define":["autocomplete","$1"],"msg":false,"autocomplete":true,"mode":"hash"} + ,"@out_of_place:error" : "\"$2$3\" can only be at the beginning of XML document" }, // Syntax model (optional) "Syntax" : { - "tag_att" : "'id'.attribute unique_att '=' string unique_id | attribute unique_att '=' (string | number)" - ,"start_tag" : "open_tag.tag tag_ctx tag_opened tag_att* ('>'.tag | '/>'.tag tag_autoclosed) \\tag_ctx" - ,"end_tag" : "close_tag.tag tag_closed" - ,"xml" : "(^^1 declaration? doctype?) (declaration.error out_of_place | doctype.error out_of_place | comment | meta | cdata | start_tag | end_tag | atom | text)*" + "tag_att" : "'id'.attribute @unique_att '=' string @unique_id | attribute @unique_att '=' (string | number)" + ,"start_tag" : "open_tag.tag @tag @autocomplete @tag_opened tag_att* ('>'.tag | '/>'.tag @tag_autoclosed) tag@" + ,"end_tag" : "close_tag.tag @autocomplete @tag_closed" + ,"xml" : "(^^1 declaration? doctype?) (declaration.error @out_of_place | doctype.error @out_of_place | comment | meta | cdata | start_tag | end_tag | atom | text)*" },