
"use strict";var ALT=1;var CAT=2;var REP=3;var RNM=4;var TRG=5;var TLS=6;var TBS=7;var PRD=8;var APG_NOT=0;var APG_AND=1;var APG_ACTIVE=1;var APG_MATCH=2;var APG_EMPTY=3;var APG_NOMATCH=4;var OP_STATE=0;var OP_MATCHED=1;var APG_PRE=5;var APG_POST=6;var APG_SEM_OK=1;var APG_SEM_ERROR=0;var APG_SEM_SKIP=2;function ApgLib(strings,rules,ops){this.constructed=false;this.clear=function(){this.startRule=0;this.ruleCount=this.rules.length;this.stats=null;this.ast=null;this.chars=null;this.charEOS=0;this.treeDepth=0;this.trace=null;this.stats=null;this.syntax=null;this.syntaxData=null;this.semantic=null;this.state=[APG_ACTIVE,0];};while(true){if(!isArray(strings)){break;};if(!isArray(rules)){break;};if(!isArray(ops)){break;};if(rules.length===0){break;};if(ops.length===0){break;};this.strings=strings;this.rules=rules;this.opcodes=ops;this.constructed=true;this.clear();break;};this.syntaxInit=function(list){this.syntax=[];if(isArray(list)&&list.length>0){for(var i=0;i<list.length;i+=1){if(list[i]){this.syntax[i]=list[i];}else{this.syntax[i]=false;}}}};this.semanticInit=function(list){this.semantic=[];if(isArray(list)&&list.length>0){for(var i=0;i<list.length;i+=1){if(list[i]){this.semantic[i]=list[i];}}}};this.astInit=function(ast){this.ast=ast;};this.traceInit=function(trace){if(trace){this.trace=trace;}else{this.trace=null;}};this.statsInit=function(stats){this.stats=stats;};this.stateDisplay=function(caption){var html='';if(this.stats){html+='<table id="state-display">';if(typeof(caption)==='string'){html+='<caption>PARSER STATE</caption>';};html+='<tr><th>Parser State:</th><td>'+stateToString(this.state[OP_STATE])+'</td></tr>';html+='<tr><th>Characters Input:</th><td>'+this.charEOS+'</td></tr>';html+='<tr><th>Characters Matched:</th><td>'+this.state[OP_MATCHED]+'</td></tr>';html+='</table>';};return html;};this.evaluateRule=function(ruleIndex,charIndex,state){var length,valid=(ruleIndex<this.rules.length)&&(charIndex<this.chars.length);if(valid){length=this.opcodes.length;this.opcodes[length]=[];this.opcodes[length].opNext=length+1;this.opcodes[length].type=RNM;this.opcodes[length].ruleIndex=ruleIndex;this.opExecute(length,charIndex,state);this.opcodes.length=length;}};this.syntaxAnalysis=function(start,input,data){var ret=false,startOpIndex;while(true){if(typeof(start)!=='number'){break;};if(!isArray(input)){break;};if(start>=this.ruleCount){break;};this.chars=input;this.charEOS=input.length;this.startRule=start;this.syntaxData=data;if(this.ast){this.ast.ast.length=0;};startOpIndex=this.opcodes.length;this.opcodes.push({'type':RNM,'opCount':1,'ruleIndex':this.startRule});this.opExecute(startOpIndex,0,this.state);this.opcodes.pop();if(this.state[OP_STATE]===APG_ACTIVE){break;};if(this.state[OP_MATCHED]!==this.charEOS){this.state[OP_STATE]=APG_NOMATCH;};if(this.state[OP_STATE]!==APG_NOMATCH){ret=true;};break;};return ret;};this.semanticAnalysis=function(data){var i,forRet,ast,ret,downIndex,ruleIndex,upIndex,name,index,count;ret=false;if(this.ast!==null){ast=this.ast.ast;forRet=true;for(i=0;i<ast.length;i+=1){if(ast[i].down){downIndex=i;ruleIndex=ast[downIndex].ruleIndex;if(this.semantic[ruleIndex]){upIndex=ast[downIndex].upIndex;name=rules[ruleIndex].rule;index=ast[upIndex].phraseIndex;count=ast[upIndex].phraseLength;ret=this.semantic[ruleIndex](APG_PRE,this.chars,index,count,data);if(ret===APG_SEM_SKIP){i=upIndex;}else if(ret!==APG_SEM_OK){forRet=false;break;}}}else{upIndex=i;downIndex=ast[upIndex].downIndex;ruleIndex=ast[downIndex].ruleIndex;if(this.semantic[ruleIndex]){upIndex=ast[downIndex].upIndex;name=rules[ruleIndex].rule;index=ast[upIndex].phraseIndex;count=ast[upIndex].phraseLength;ret=this.semantic[ruleIndex](APG_POST,this.chars,index,count,data);if(ret!==APG_SEM_OK){forRet=false;break;}}}};ret=forRet;};return ret;};this.opALT=function(opIndex,charIndex,state){state[OP_STATE]=APG_NOMATCH;state[OP_MATCHED]=0;var childOpIndex,op=this.opcodes[opIndex];if(op.type!==ALT){throw['opALT: type '+opcodeToString(op.type)+' not ALT'];};childOpIndex=opIndex+1;for(;childOpIndex<op.opNext;childOpIndex=this.opcodes[childOpIndex].opNext){this.opExecute(childOpIndex,charIndex,state);if(state[OP_STATE]!==APG_NOMATCH){break;}else if(this.stats!==null){this.stats.backtrack(op);}}};this.opCAT=function(opIndex,charIndex,state){state[OP_STATE]=APG_NOMATCH;state[OP_MATCHED]=0;var op,astLength,catState,catCharIndex,catMatched,childOpIndex;op=this.opcodes[opIndex];if(op.type!==CAT){throw['opCAT: type '+opcodeToString(op.type)+' not CAT'];};astLength=(this.ast)?this.ast.currentLength():0;catState=[APG_NOMATCH,0];catCharIndex=charIndex;catMatched=0;childOpIndex=opIndex+1;for(;childOpIndex<op.opNext;childOpIndex=this.opcodes[childOpIndex].opNext){this.opExecute(childOpIndex,catCharIndex,catState);catCharIndex+=catState[OP_MATCHED];catMatched+=catState[OP_MATCHED];if(catState[OP_STATE]===APG_NOMATCH){break;}};state[OP_MATCHED]=catMatched;if(childOpIndex===op.opNext){state[OP_STATE]=catMatched===0?APG_EMPTY:APG_MATCH;};if(this.ast&&state[OP_STATE]===APG_NOMATCH){this.ast.truncate(astLength);}};this.opREP=function(opIndex,charIndex,state){state[OP_STATE]=APG_NOMATCH;state[OP_MATCHED]=0;var nextState,nextCharIndex,matchedCount,op,childOpIndex,astLength;nextState=[APG_ACTIVE,0];nextCharIndex=charIndex;matchedCount=0;op=this.opcodes[opIndex];childOpIndex=opIndex+1;if(op.type!==REP){throw['opREP: type '+opcodeToString(op.type)+' not REP'];};astLength=(this.ast)?this.ast.currentLength():0;while(true){if(nextCharIndex>=this.charEOS){break;};this.opExecute(childOpIndex,nextCharIndex,nextState);if(nextState[OP_STATE]===APG_NOMATCH){if(this.stats!==null){this.stats.backtrack(op);};break;};if(nextState[OP_STATE]===APG_EMPTY){break;};matchedCount+=1;state[OP_MATCHED]+=nextState[OP_MATCHED];nextCharIndex+=nextState[OP_MATCHED];if(matchedCount===op.max){break;}};if(state[OP_MATCHED]>=op.min){state[OP_STATE]=(state[OP_MATCHED]===0)?APG_EMPTY:APG_MATCH;}else{state[OP_STATE]=APG_NOMATCH;if(this.stats!==null){this.stats.backtrack(op);}};if(this.ast&&state[OP_STATE]===APG_NOMATCH){this.ast.truncate(astLength);}};this.opRNM=function(opIndex,charIndex,state){state[OP_STATE]=APG_ACTIVE;state[OP_MATCHED]=0;var downIndex,astLength,op,rule,ruleOpIndex,ruleDefined;downIndex=0;astLength=0;op=this.opcodes[opIndex];if(op.type!==RNM){throw['opRNM: type '+opcodeToString(op.type)+' not RNM'];};rule=this.rules[op.ruleIndex];ruleOpIndex=rule.opcodeIndex;ruleDefined=this.ast&&this.ast.ruleDefined(op.ruleIndex);if(ruleDefined){astLength=this.ast.currentLength();downIndex=this.ast.down(op.ruleIndex);};if(this.syntax&&this.syntax[op.ruleIndex]){this.syntax[op.ruleIndex](state,this.chars,charIndex,this.syntaxData);};if(state[OP_STATE]===APG_ACTIVE){this.opExecute(ruleOpIndex,charIndex,state);};if(this.syntax&&this.syntax[op.ruleIndex]){this.syntax[op.ruleIndex](state,this.chars,charIndex,this.syntaxData);};if(ruleDefined){if(state[OP_STATE]===APG_NOMATCH){this.ast.truncate(astLength);}else{this.ast.up(downIndex,charIndex,state[OP_MATCHED]);}}};this.opPRD=function(opIndex,charIndex,state){state[OP_STATE]=APG_NOMATCH;state[OP_MATCHED]=0;var op,prdState=[APG_ACTIVE,0];op=this.opcodes[opIndex];if(op.type!==PRD){throw['opPRD: type '+opcodeToString(op.type)+' not PRD'];};if(this.ast){this.ast.inPRD+=1;};this.opExecute((opIndex+1),charIndex,prdState);if(this.ast){this.ast.inPRD-=1;};switch(prdState[OP_STATE]){case APG_EMPTY:case APG_MATCH:if(op.and){state[OP_STATE]=APG_EMPTY;}else{state[OP_STATE]=APG_NOMATCH;state[OP_MATCHED]=prdState[OP_MATCHED];};break;case APG_NOMATCH:if(op.and){state[OP_STATE]=APG_NOMATCH;state[OP_MATCHED]=prdState[OP_MATCHED];}else{state[OP_STATE]=APG_EMPTY;};break;default:throw['opPRD: invalid state '+prdState[OP_STATE]];};if(this.stats!==null){this.stats.backtrack(op);}};this.opTRG=function(opIndex,charIndex,state){state[OP_STATE]=APG_NOMATCH;state[OP_MATCHED]=0;var op=this.opcodes[opIndex];if(op.type!==TRG){throw['opTRG: type '+opcodeToString(op.type)+' not TRG'];};if(charIndex<this.charEOS){if(op.min<=this.chars[charIndex]&&this.chars[charIndex]<=op.max){state[OP_STATE]=APG_MATCH;state[OP_MATCHED]=1;}}};this.opTBS=function(opIndex,charIndex,state){state[OP_STATE]=APG_NOMATCH;state[OP_MATCHED]=0;var i,op,len,stringIndex;op=this.opcodes[opIndex];if(op.type!==TBS){throw['opTBS: type '+opcodeToString(op.type)+' not TBS'];};len=op.length;stringIndex=op.stringIndex;if(len===0){throw['opTBS: string length cannot be 0'];};if((charIndex+len)<=this.charEOS){for(i=0;i<len;i+=1){if(this.chars[charIndex+i]!==this.strings[stringIndex+i]){break;}};state[OP_MATCHED]=i;if(i===len){state[OP_STATE]=APG_MATCH;}}};this.opTLS=function(opIndex,charIndex,state){state[OP_STATE]=APG_NOMATCH;state[OP_MATCHED]=0;var i,code,strChar,len,stringIndex,op;op=this.opcodes[opIndex];if(op.type!==TLS){throw['opTLS: type '+opcodeToString(op.type)+' not TLS'];};len=op.length;stringIndex=op.stringIndex;if(len===0){state[OP_STATE]=APG_EMPTY;}else if((charIndex+len)<=this.charEOS){for(i=0;i<len;i+=1){strChar=this.strings[stringIndex+i];if(strChar>=65&&strChar<=90){strChar+=32;};code=this.chars[charIndex+i];if(code>=65&&code<=90){code+=32;};if(code!==strChar){break;}};state[OP_MATCHED]=i;if(i===len){state[OP_STATE]=APG_MATCH;}}};this.opExecute=function(opIndex,charIndex,state){var op,ret=true;op=this.opcodes[opIndex];this.treeDepth+=1;state[OP_STATE]=APG_ACTIVE;state[OP_MATCHED]=0;if(this.trace!==null){this.trace.traceDown(op,state[OP_STATE],charIndex,state[OP_MATCHED]);};switch(op.type){case ALT:this.opALT(opIndex,charIndex,state);break;case CAT:this.opCAT(opIndex,charIndex,state);break;case RNM:this.opRNM(opIndex,charIndex,state);break;case REP:this.opREP(opIndex,charIndex,state);break;case PRD:this.opPRD(opIndex,charIndex,state);break;case TRG:this.opTRG(opIndex,charIndex,state);break;case TBS:this.opTBS(opIndex,charIndex,state);break;case TLS:this.opTLS(opIndex,charIndex,state);break;default:ret=false;break;};if((state[OP_STATE]!==APG_MATCH)&&(state[OP_STATE]!==APG_NOMATCH)&&(state[OP_STATE]!==APG_EMPTY)){throw['opExecute: invalid state returned'];};if(this.stats!==null){this.stats.collect(op,state);};if(this.trace!==null){this.trace.traceUp(op,state[OP_STATE],charIndex,state[OP_MATCHED]);};this.treeDepth-=1;return ret;};};"use strict";var ASCII_CR=13;var ASCII_LF=10;var ASCII_TAB=9;var ASCII_SPACE=32;var ASCII_MIN=32;var ASCII_MAX=126;var ASCII_LANGLE=60;var ASCII_RANGLE=62;function dec2hex(d){return d.toString(16).toUpperCase();};function hex2dec(h){return parseInt(h,16);};function isArray(a){return(Object.prototype.toString.apply(a)==='[object Array]');};function MsgLog(){this.log=[];this.count=function(){return this.log.length;};this.clear=function(){this.log.length=0;};this.logLine=function(line,offset,len,msg){if(typeof(msg)!=='string'){msg='msg type: '+typeof(msg);};if(typeof(line)!=='number'){line=false;};if(typeof(offset)!=='number'){offset=false;};if(typeof(len)!=='number'){len=false;};this.log.push([line,offset,len,': '+msg]);};this.logMsg=function(msg){if(typeof(msg)!=='string'){msg='msg type: '+typeof(msg);};this.log.push([false,false,false,msg]);};this.logDisplay=function(title){var html='';var i;if(typeof(title)==='string'){html+=title+'<br />';};if(this.log.length===0){html+='&lt;no messages&gt;<br />';}else{for(i=0;i<this.log.length;i+=1){var log=this.log[i];html+=(i+1)+': ';if(!(log[0]===false)){html+=' line: '+log[0];};if(!(log[1]===false)){html+=' offset: '+log[1];};if(!(log[2]===false)){html+=' char: '+log[2];};html+=log[3];html+='<br />';}};return html;};this.logDisplayTable=function(title){var line;var offset;var len;var html='<table class="log-table">';var i;if(typeof(title)==='string'){html+='<caption class="log-caption">'+title+'</caption>';};if(this.log.length===0){html+='<tr><td>0</td><td>&lt;no messages&gt;</td></tr>';}else{for(i=0;i<this.log.length;i+=1){var log=this.log[i];if(log[0]===false){line='-';}else{line=log[0];};if(log[1]===false){offset='-';}else{offset=log[1];};if(log[2]===false){len='-';}else{len=log[2];};if(i%2===0){html+='<tr class="even"><td>'+line+'</td><td>'+offset+'</td><td>'+len+'</td>';html+='<td class="log-msg">'+log[3]+'</td></tr>';}else{html+='<tr class="odd"><td>'+line+'</td><td>'+offset+'</td><td>'+len+'</td>';html+='<td class="log-msg">'+log[3]+'</td></tr>';}}};html+='</table>';return html;};};function apgAssert(condition,msg){if(!condition){var message="apgAssert: failed: ";if(typeof(msg)==='string'){message+=msg;};throw[message];}};function charsToString(chars,phraseIndex,phraseLength){var string='';if(isArray(chars)){var charIndex=(typeof(phraseIndex)==='number')?phraseIndex:0;var charLength=(typeof(phraseLength)==='number')?phraseLength:chars.length;if(charLength>chars.length){charLength=chars.length;};var charEnd=charIndex+charLength;for(var i=charIndex;i<charEnd;i+=1){if(chars[i]){string+=String.fromCharCode(chars[i]);}}};return string;};function grammarToChars(log,string,chars){var ret=true;var lineNo=0;var lineOffset=0;var lineChar=0;if(typeof(string)==='string'&&isArray(chars)){var charIndex=0;var codeIndex=0;chars.length=0;while(charIndex<string.length){var code=string.charCodeAt(charIndex);if(code===ASCII_TAB){code=ASCII_SPACE;}else if(code===ASCII_CR){code=ASCII_LF;if(string.charCodeAt(charIndex+1)===ASCII_LF){charIndex+=1;}}else if(code!==ASCII_LF&&(code<ASCII_MIN||code>ASCII_MAX)){log.logLine(lineNo,lineOffset,lineChar,'stringToChar: non-ASCII character found: '+code);ret=false;};chars[codeIndex]=code;charIndex+=1;codeIndex+=1;lineOffset+=1;lineChar+=1;if(code===ASCII_LF){lineNo+=1;lineChar=0;}};if(chars.length>0&&chars[chars.length-1]!==ASCII_LF){chars[chars.length]=ASCII_LF;};if(chars.length===0){log.logLine(0,0,0,'input string may not be empty');ret=false;}};return ret;};function binaryStringToChars(log,string,chars){var ret=false,test;var stringIndex=0;var charIndex=0;var code,text,strlen;while(true){if(typeof(string)!=='string'){log.logMsg('apgUtilities: binaryStringToChars: string not type \'string\'');};if(!isArray(chars)){log.logMsg('apgUtilities: binaryStringToChars: chars not type \'array\'');};chars.length=0;strlen=string.length;ret=true;while(stringIndex<strlen){code=string.charCodeAt(stringIndex);if(code===9||code===10||code===13||code===32){stringIndex+=1;}else{test=parseInt(string.substring(stringIndex));if(isNaN(test)){log.logMsg('apgUtilities: binaryStringToChars: non-integer at: '+stringIndex);ret=false;break;}else if(test>255){log.logMsg('apgUtilities: binaryStringToChars: integer > 255 at: '+stringIndex);ret=false;break;}else{chars[charIndex]=test;charIndex+=1;for(;stringIndex<strlen;stringIndex+=1){code=string.charCodeAt(stringIndex);if(!(code===9||code===10||code===13||code===32)){continue;};break;}}}};break;};return ret;};function stringToChars(log,string,chars){var ret=false;if(typeof(string)==='string'&&isArray(chars)){var charIndex=0;while(charIndex<string.length){chars[charIndex]=string.charCodeAt(charIndex);charIndex+=1;};if(charIndex>0){ret=true;}};return ret;};function formatString(string){var ret='';var line='';var lineNo=1;var lineLen=0;var lineBeg=0;var linePrint=false;var code;var i=0;for(;i<string.length;i+=1){if(linePrint){ret+=lineNo+':['+lineBeg+']['+(lineLen)+'] '+line+'<br />';line='';lineLen=0;lineBeg=i;lineNo+=1;linePrint=false;};code=string.charCodeAt(i);if(code===ASCII_CR){line+='<span class="non-ascii">CR</span>';if(string.charCodeAt(i+1)!==ASCII_LF){linePrint=true;}}else if(code===ASCII_LF){line+='<span class="non-ascii">LF</span>';linePrint=true;}else if(code<ASCII_MIN||code>ASCII_MAX){line+='<span class="non-ascii">x'+dec2hex(code)+'</span>';}else{line+=string.charAt(i);};lineLen+=1;};if(lineLen>0){ret+=lineNo+':['+lineBeg+']['+(lineLen)+'] '+line+'<br />';};return ret;};function formatChars(chars){var ret='';var line='';var lineNo=1;var lineLen=0;var lineBeg=0;var linePrint=false;var code;var i=0;for(;i<chars.length;i+=1){if(linePrint){ret+=lineNo+':['+lineBeg+']['+(lineLen)+'] '+line+'<br />';line='';lineLen=0;lineBeg=i;lineNo+=1;linePrint=false;};code=chars[i];if(code===ASCII_CR){line+='<span class="non-ascii">CR</span>';if(chars[i+1]!==ASCII_LF){linePrint=true;}}else if(code===ASCII_LF){line+='<span class="non-ascii">LF</span>';linePrint=true;}else if(code<ASCII_MIN||code>ASCII_MAX){line+='<span class="non-ascii">x'+dec2hex(code)+'</span>';}else{line+=String.fromCharCode(chars[i]);};lineLen+=1;};if(lineLen>0){ret+=lineNo+':['+lineBeg+']['+(lineLen)+'] '+line+'<br />';};return ret;};this.charsAreAscii=function(chars){var count=0;var max=1000;var len=(chars.length>max)?max:chars.length;for(var i=0;i<len;i+=1){if(chars[i]===9){count+=1;}else if(chars[i]===10){count+=1;}else if(chars[i]===13){count+=1;}else if(chars[i]>=32&&chars[i]<=127){count+=1;}};return(((count*100)/len)>=25);};function inputIsBinary(chars){var ret=true;var isWhite,value,string;var count=0;var i=0;var len=chars.length;var max=100;while(i<len&&count<max){isWhite=true;while(i<len&&isWhite){if(chars[i]===9||chars[i]===10||chars[i]===13||chars[i]===32){isWhite=true;i+=1;}else{isWhite=false;}};if(i===len){break;};string='';isWhite=false;while(i<len&&!isWhite){if(chars[i]===9||chars[i]===10||chars[i]===13||chars[i]===32){isWhite=true;}else{string+=String.fromCharCode(chars[i]);i+=1;}};value=parseInt(string,10);if(isNaN(value)){ret=false;break;}else{count+=1;}};if(count===0){ret=false;};return ret;};function tableCharsHex(chars){var html='';var htmlHex='';var htmlAscii='';var htmlCount='';var hexChar;var spanEven='<span class="ast-highlight-even">';var spanOdd='<span class="ast-highlight-odd">';var emptyHex='<span class="ast-empty">00</span>';var emptyAscii='<span class="ast-empty">&epsilon;</span>';var count=0;var matchLen=24;htmlCount+='0:<br />';for(var i=0;i<chars.length;i+=1){if(chars[i]<32||chars[i]>126){htmlAscii+='&#46;';}else if(chars[i]===32){htmlAscii+='&nbsp;';}else{htmlAscii+='&#'+chars[i];};hexChar=chars[i].toString(16).toUpperCase();if(hexChar.length===1){htmlHex+='0'+hexChar;}else{htmlHex+=hexChar;};count+=1;if(count===matchLen){htmlHex+='<br />';htmlAscii+='<br />';htmlCount+=i+':<br />';count=0;}else{if(count%4===0){htmlHex+='&nbsp;';}}};html+='<pre><table class="phrase-table"><tr>';html+='<td class="right">'+htmlCount+'</td>';html+='<td>'+htmlHex+'</td>';html+='<td>'+htmlAscii+'</td>';html+='</tr></table></pre>';return html;};function tableChars(chars){var html='';var maxLineLen=0;var line='';var lineNo=1;var lineLen=0;var lineBeg=0;var linePrint=false;var lineBreak=128;var linePrintLen=0;var lineContinue=false;var code;var i=0;html+='<tr>';html+='<td>(a)</td>';html+='<td>(b)</td>';html+='<td>(c)</td>';html+='<td class="log-msg">&nbsp;</td>';html+='</tr>';for(;i<chars.length;i+=1){if(linePrint){if(lineNo%2===0){html+='<tr class="odd">';}else{html+='<tr class="even">';};linePrintLen+=lineLen;if(lineContinue){html+='<td>'+lineNo+':</td>';html+='<td>'+lineBeg+':</td>';html+='<td>&ndash;&gt;:</td>';html+='<td class="log-msg">'+line+'</td></tr>';}else{html+='<td>'+lineNo+':</td>';html+='<td>'+lineBeg+':</td>';html+='<td>'+linePrintLen+':</td>';html+='<td class="log-msg">'+line+'</td></tr>';lineNo+=1;linePrintLen=0;};line='';if(maxLineLen<lineLen){maxLineLen=lineLen;};lineLen=0;lineBeg=i;linePrint=false;lineContinue=false;};code=chars[i];if(code===ASCII_CR){line+='<span class="non-ascii">CR</span>';lineLen+=2;if(chars[i+1]!==ASCII_LF){linePrint=true;}}else if(code===ASCII_LF){line+='<span class="non-ascii">LF</span>';lineLen+=2;linePrint=true;}else if(code<ASCII_MIN||code>ASCII_MAX){line+='<span class="non-ascii">x'+dec2hex(code)+'</span>';lineLen+=3;}else if(chars[i]===32){line+='&nbsp;';lineLen+=1;}else{line+='&#'+chars[i];lineLen+=1;};if(lineLen>=lineBreak){linePrint=true;lineContinue=true;}};if(lineLen>0){linePrintLen+=lineLen;if(lineNo%2===0){html+='<tr class="odd">';}else{html+='<tr class="even">';};html+='<td>'+lineNo+':</td>';html+='<td>'+lineBeg+':</td>';html+='<td>'+linePrintLen+':</td>';html+='<td class="log-msg">'+line+'</td></tr>';};html+='<tr>';html+='<td>(a)</td>';html+='<td>(b)</td>';html+='<td>(c)</td>';html+='<td class="log-msg">&nbsp;</td>';html+='</tr>';html='<table width="'+(maxLineLen*10)+'" class="log-table">'+html+'</table>';html+='<p class="log-msg">';html+='(a) - line number<br />';html+='(b) - first character of line (or line fragment<sup>*</sup>)<br />';html+='(c) - line length (or "&ndash;&gt;" for line fragment<sup>*</sup>)<br /><br />';html+='<sup>*</sup>Lines longer than '+lineBreak+' are displayed as multiple printed fragments<br />';html+='</p>';return html;};function trueToString(value){if(value){return 'TRUE';}else{return 'FALSE';}};function stateToString(state){var ret='unknown';switch(state){case APG_ACTIVE:ret='ACTIVE';break;case APG_EMPTY:ret='EMPTY';break;case APG_NOMATCH:ret='NOMATCH';break;case APG_MATCH:ret='MATCH';break;case APG_PRE:ret='SEMANTIC PRE-BRANCH';break;case APG_POST:ret='SEMANTIC POST-BRANCH';break;};return ret;};function opcodeToString(type){var ret='unknown';switch(type){case ALT:ret='ALT';break;case CAT:ret='CAT';break;case RNM:ret='RNM';break;case PRD:ret='PRD';break;case REP:ret='REP';break;case TRG:ret='TRG';break;case TBS:ret='TBS';break;case TLS:ret='TLS';break;};return ret;};function objEval(obj){var ret='objEval: ';for(var x in obj){ret+=x+": "+obj[x];ret+='<br />\n';};return ret;};function SelecText(testarea){window.document.getElementById("testarea").select();};function dump(arr,level){var dumped_text="";if(!level){level=0;};var level_padding="";for(var j=0;j<level;j+=1){level_padding+="  ";};if(typeof(arr)==='object'){for(var item in arr){var value=arr[item];if(typeof(value)==='object'){dumped_text+=level_padding+"'"+item+"' ...\n";dumped_text+=dump(value,level+1);}else{dumped_text+=level_padding+"'"+item+"' => \"" + value + "\"\n";}}}else{dumped_text="===>"+arr+"<===("+typeof(arr)+")";};return dumped_text;};function htmlentities(texto){var i,carac,letra,novo='';for(i=0;i<texto.length;i++){carac=texto[i].charCodeAt(0);if((carac>47&&carac<58)||(carac>62&&carac<127)){novo+=texto[i];}else{novo+="&#"+carac+";";}};return novo;};function htmlspecialchars(chars){var i,c,html='';for(i=0;i<chars.length;i++){c=chars.charAt(i);switch(c){case '<':html+='&lt;';break;case '>':html+='&gt;';break;case '&':html+='&amp;';break;case '"':html+='&quot;';break;case '\'': html += '&#039;';break;default:html+=c;break;}};return html;};function Circular(){this.lastIndex=0;this.nextIndex=0;this.bufferMax=0;this.itemCount=0;this.bufferSize=0;this.initCollection=function(size){this.bufferSize=size;this.lastIndex=0;this.itemCount=0;this.nextIndex=0;this.sequential=true;};this.collect=function(){if(this.lastIndex>=this.bufferSize){this.lastIndex=0;this.sequential=false;};var ret=this.lastIndex;this.lastIndex+=1;if(this.lastIndex>this.itemCount){this.itemCount=this.lastIndex;};return ret;};this.size=function(){return this.bufferSize;};this.items=function(){return this.itemCount;};this.isSequential=function(){return this.sequential;};this.initReplay=function(){if(this.isSequential()){this.nextIndex=0;}else{this.nextIndex=this.lastIndex;}};this.replay=function(){var ret;if(this.nextIndex>=this.bufferSize){this.nextIndex=0;};ret=this.nextIndex;this.nextIndex+=1;return ret;};this.initReverse=function(){if(this.isSequential()){this.nextIndex=this.itemCount-1;}else{this.nextIndex=this.lastIndex-1;}};this.reverse=function(){var ret;if(this.nextIndex<0){this.nextIndex=this.itemCount-1;if(this.nextIndex<0){return 0;}};ret=this.nextIndex;this.nextIndex-=1;return ret;};};"use strict";function ApgOpcodes(){this.stringTable=[];this.stringTable[0]=61;this.stringTable[1]=47;this.ruleIds=[];this.ruleIds.file=0;this.ruleIds.blankline=1;this.ruleIds.rule=2;this.ruleIds.ruleerror=3;this.ruleIds.alternation=4;this.ruleIds.concatenation=5;this.ruleIds.repetition=6;this.ruleIds.repeat=7;this.ruleIds.predicate=8;this.ruleIds.rep=9;this.ruleIds.element=10;this.ruleIds.group=11;this.ruleIds.option=12;this.ruleIds.prosval=13;this.ruleIds.namedef=14;this.ruleIds.definedas=15;this.ruleIds.incalt=16;this.ruleIds.rnmop=17;this.ruleIds.altop=18;this.ruleIds.catop=19;this.ruleIds.starop=20;this.ruleIds.andop=21;this.ruleIds.notop=22;this.ruleIds.lparen=23;this.ruleIds.rparen=24;this.ruleIds.loption=25;this.ruleIds.roption=26;this.ruleIds.trgop=27;this.ruleIds.tbsop=28;this.ruleIds.tlsop=29;this.ruleIds['rep-min']=30;this.ruleIds['rep-min-max']=31;this.ruleIds['rep-max']=32;this.ruleIds.ltls=33;this.ruleIds.rtls=34;this.ruleIds.drange=35;this.ruleIds.xrange=36;this.ruleIds.brange=37;this.ruleIds.dstring=38;this.ruleIds.xstring=39;this.ruleIds.bstring=40;this.ruleIds.dec=41;this.ruleIds.hex=42;this.ruleIds.bin=43;this.ruleIds.dmin=44;this.ruleIds.dmax=45;this.ruleIds.bmin=46;this.ruleIds.bmax=47;this.ruleIds.xmin=48;this.ruleIds.xmax=49;this.ruleIds.dnum=50;this.ruleIds.bnum=51;this.ruleIds.xnum=52;this.ruleIds.alphanum=53;this.ruleIds.owsp=54;this.ruleIds.wsp=55;this.ruleIds.space=56;this.ruleIds.comment=57;this.ruleIds.lineend=58;this.ruleIds.linecontinue=59;this.ruleIds[0]=53;this.ruleIds[1]=4;this.ruleIds[2]=18;this.ruleIds[3]=21;this.ruleIds[4]=43;this.ruleIds[5]=1;this.ruleIds[6]=47;this.ruleIds[7]=46;this.ruleIds[8]=51;this.ruleIds[9]=37;this.ruleIds[10]=40;this.ruleIds[11]=19;this.ruleIds[12]=57;this.ruleIds[13]=5;this.ruleIds[14]=41;this.ruleIds[15]=15;this.ruleIds[16]=45;this.ruleIds[17]=44;this.ruleIds[18]=50;this.ruleIds[19]=35;this.ruleIds[20]=38;this.ruleIds[21]=10;this.ruleIds[22]=0;this.ruleIds[23]=11;this.ruleIds[24]=42;this.ruleIds[25]=16;this.ruleIds[26]=59;this.ruleIds[27]=58;this.ruleIds[28]=25;this.ruleIds[29]=23;this.ruleIds[30]=33;this.ruleIds[31]=14;this.ruleIds[32]=22;this.ruleIds[33]=12;this.ruleIds[34]=54;this.ruleIds[35]=8;this.ruleIds[36]=13;this.ruleIds[37]=9;this.ruleIds[38]=32;this.ruleIds[39]=30;this.ruleIds[40]=31;this.ruleIds[41]=7;this.ruleIds[42]=6;this.ruleIds[43]=17;this.ruleIds[44]=26;this.ruleIds[45]=24;this.ruleIds[46]=34;this.ruleIds[47]=3;this.ruleIds[48]=2;this.ruleIds[49]=56;this.ruleIds[50]=20;this.ruleIds[51]=28;this.ruleIds[52]=29;this.ruleIds[53]=27;this.ruleIds[54]=55;this.ruleIds[55]=49;this.ruleIds[56]=48;this.ruleIds[57]=52;this.ruleIds[58]=36;this.ruleIds[59]=39;this.rules=[];this.rules[0]=[];this.rules[0].rule='File';this.rules[0].lower='file';this.rules[0].syntax=null;this.rules[0].semantic=null;this.rules[0].opcodeIndex=0;this.rules[1]=[];this.rules[1].rule='BlankLine';this.rules[1].lower='blankline';this.rules[1].syntax=null;this.rules[1].semantic=null;this.rules[1].opcodeIndex=5;this.rules[2]=[];this.rules[2].rule='Rule';this.rules[2].lower='rule';this.rules[2].syntax=null;this.rules[2].semantic=null;this.rules[2].opcodeIndex=14;this.rules[3]=[];this.rules[3].rule='RuleError';this.rules[3].lower='ruleerror';this.rules[3].syntax=null;this.rules[3].semantic=null;this.rules[3].opcodeIndex=24;this.rules[4]=[];this.rules[4].rule='Alternation';this.rules[4].lower='alternation';this.rules[4].syntax=null;this.rules[4].semantic=null;this.rules[4].opcodeIndex=30;this.rules[5]=[];this.rules[5].rule='Concatenation';this.rules[5].lower='concatenation';this.rules[5].syntax=null;this.rules[5].semantic=null;this.rules[5].opcodeIndex=36;this.rules[6]=[];this.rules[6].rule='Repetition';this.rules[6].lower='repetition';this.rules[6].syntax=null;this.rules[6].semantic=null;this.rules[6].opcodeIndex=43;this.rules[7]=[];this.rules[7].rule='Repeat';this.rules[7].lower='repeat';this.rules[7].syntax=null;this.rules[7].semantic=null;this.rules[7].opcodeIndex=47;this.rules[8]=[];this.rules[8].rule='Predicate';this.rules[8].lower='predicate';this.rules[8].syntax=null;this.rules[8].semantic=null;this.rules[8].opcodeIndex=50;this.rules[9]=[];this.rules[9].rule='Rep';this.rules[9].lower='rep';this.rules[9].syntax=null;this.rules[9].semantic=null;this.rules[9].opcodeIndex=55;this.rules[10]=[];this.rules[10].rule='Element';this.rules[10].lower='element';this.rules[10].syntax=null;this.rules[10].semantic=null;this.rules[10].opcodeIndex=68;this.rules[11]=[];this.rules[11].rule='Group';this.rules[11].lower='group';this.rules[11].syntax=null;this.rules[11].semantic=null;this.rules[11].opcodeIndex=76;this.rules[12]=[];this.rules[12].rule='Option';this.rules[12].lower='option';this.rules[12].syntax=null;this.rules[12].semantic=null;this.rules[12].opcodeIndex=80;this.rules[13]=[];this.rules[13].rule='ProsVal';this.rules[13].lower='prosval';this.rules[13].syntax=null;this.rules[13].semantic=null;this.rules[13].opcodeIndex=84;this.rules[14]=[];this.rules[14].rule='NameDef';this.rules[14].lower='namedef';this.rules[14].syntax=null;this.rules[14].semantic=null;this.rules[14].opcodeIndex=91;this.rules[15]=[];this.rules[15].rule='DefinedAs';this.rules[15].lower='definedas';this.rules[15].syntax=null;this.rules[15].semantic=null;this.rules[15].opcodeIndex=92;this.rules[16]=[];this.rules[16].rule='IncAlt';this.rules[16].lower='incalt';this.rules[16].syntax=null;this.rules[16].semantic=null;this.rules[16].opcodeIndex=93;this.rules[17]=[];this.rules[17].rule='RnmOp';this.rules[17].lower='rnmop';this.rules[17].syntax=null;this.rules[17].semantic=null;this.rules[17].opcodeIndex=94;this.rules[18]=[];this.rules[18].rule='AltOp';this.rules[18].lower='altop';this.rules[18].syntax=null;this.rules[18].semantic=null;this.rules[18].opcodeIndex=95;this.rules[19]=[];this.rules[19].rule='CatOp';this.rules[19].lower='catop';this.rules[19].syntax=null;this.rules[19].semantic=null;this.rules[19].opcodeIndex=98;this.rules[20]=[];this.rules[20].rule='StarOp';this.rules[20].lower='starop';this.rules[20].syntax=null;this.rules[20].semantic=null;this.rules[20].opcodeIndex=99;this.rules[21]=[];this.rules[21].rule='AndOp';this.rules[21].lower='andop';this.rules[21].syntax=null;this.rules[21].semantic=null;this.rules[21].opcodeIndex=100;this.rules[22]=[];this.rules[22].rule='NotOp';this.rules[22].lower='notop';this.rules[22].syntax=null;this.rules[22].semantic=null;this.rules[22].opcodeIndex=101;this.rules[23]=[];this.rules[23].rule='Lparen';this.rules[23].lower='lparen';this.rules[23].syntax=null;this.rules[23].semantic=null;this.rules[23].opcodeIndex=102;this.rules[24]=[];this.rules[24].rule='Rparen';this.rules[24].lower='rparen';this.rules[24].syntax=null;this.rules[24].semantic=null;this.rules[24].opcodeIndex=105;this.rules[25]=[];this.rules[25].rule='Loption';this.rules[25].lower='loption';this.rules[25].syntax=null;this.rules[25].semantic=null;this.rules[25].opcodeIndex=108;this.rules[26]=[];this.rules[26].rule='Roption';this.rules[26].lower='roption';this.rules[26].syntax=null;this.rules[26].semantic=null;this.rules[26].opcodeIndex=111;this.rules[27]=[];this.rules[27].rule='TrgOp';this.rules[27].lower='trgop';this.rules[27].syntax=null;this.rules[27].semantic=null;this.rules[27].opcodeIndex=114;this.rules[28]=[];this.rules[28].rule='TbsOp';this.rules[28].lower='tbsop';this.rules[28].syntax=null;this.rules[28].semantic=null;this.rules[28].opcodeIndex=120;this.rules[29]=[];this.rules[29].rule='TlsOp';this.rules[29].lower='tlsop';this.rules[29].syntax=null;this.rules[29].semantic=null;this.rules[29].opcodeIndex=126;this.rules[30]=[];this.rules[30].rule='rep-min';this.rules[30].lower='rep-min';this.rules[30].syntax=null;this.rules[30].semantic=null;this.rules[30].opcodeIndex=133;this.rules[31]=[];this.rules[31].rule='rep-min-max';this.rules[31].lower='rep-min-max';this.rules[31].syntax=null;this.rules[31].semantic=null;this.rules[31].opcodeIndex=135;this.rules[32]=[];this.rules[32].rule='rep-max';this.rules[32].lower='rep-max';this.rules[32].syntax=null;this.rules[32].semantic=null;this.rules[32].opcodeIndex=137;this.rules[33]=[];this.rules[33].rule='Ltls';this.rules[33].lower='ltls';this.rules[33].syntax=null;this.rules[33].semantic=null;this.rules[33].opcodeIndex=139;this.rules[34]=[];this.rules[34].rule='Rtls';this.rules[34].lower='rtls';this.rules[34].syntax=null;this.rules[34].semantic=null;this.rules[34].opcodeIndex=140;this.rules[35]=[];this.rules[35].rule='dRange';this.rules[35].lower='drange';this.rules[35].syntax=null;this.rules[35].semantic=null;this.rules[35].opcodeIndex=141;this.rules[36]=[];this.rules[36].rule='xRange';this.rules[36].lower='xrange';this.rules[36].syntax=null;this.rules[36].semantic=null;this.rules[36].opcodeIndex=146;this.rules[37]=[];this.rules[37].rule='bRange';this.rules[37].lower='brange';this.rules[37].syntax=null;this.rules[37].semantic=null;this.rules[37].opcodeIndex=151;this.rules[38]=[];this.rules[38].rule='dString';this.rules[38].lower='dstring';this.rules[38].syntax=null;this.rules[38].semantic=null;this.rules[38].opcodeIndex=156;this.rules[39]=[];this.rules[39].rule='xString';this.rules[39].lower='xstring';this.rules[39].syntax=null;this.rules[39].semantic=null;this.rules[39].opcodeIndex=163;this.rules[40]=[];this.rules[40].rule='bString';this.rules[40].lower='bstring';this.rules[40].syntax=null;this.rules[40].semantic=null;this.rules[40].opcodeIndex=170;this.rules[41]=[];this.rules[41].rule='Dec';this.rules[41].lower='dec';this.rules[41].syntax=null;this.rules[41].semantic=null;this.rules[41].opcodeIndex=177;this.rules[42]=[];this.rules[42].rule='Hex';this.rules[42].lower='hex';this.rules[42].syntax=null;this.rules[42].semantic=null;this.rules[42].opcodeIndex=180;this.rules[43]=[];this.rules[43].rule='Bin';this.rules[43].lower='bin';this.rules[43].syntax=null;this.rules[43].semantic=null;this.rules[43].opcodeIndex=183;this.rules[44]=[];this.rules[44].rule='dmin';this.rules[44].lower='dmin';this.rules[44].syntax=null;this.rules[44].semantic=null;this.rules[44].opcodeIndex=186;this.rules[45]=[];this.rules[45].rule='dmax';this.rules[45].lower='dmax';this.rules[45].syntax=null;this.rules[45].semantic=null;this.rules[45].opcodeIndex=188;this.rules[46]=[];this.rules[46].rule='bmin';this.rules[46].lower='bmin';this.rules[46].syntax=null;this.rules[46].semantic=null;this.rules[46].opcodeIndex=190;this.rules[47]=[];this.rules[47].rule='bmax';this.rules[47].lower='bmax';this.rules[47].syntax=null;this.rules[47].semantic=null;this.rules[47].opcodeIndex=192;this.rules[48]=[];this.rules[48].rule='xmin';this.rules[48].lower='xmin';this.rules[48].syntax=null;this.rules[48].semantic=null;this.rules[48].opcodeIndex=194;this.rules[49]=[];this.rules[49].rule='xmax';this.rules[49].lower='xmax';this.rules[49].syntax=null;this.rules[49].semantic=null;this.rules[49].opcodeIndex=199;this.rules[50]=[];this.rules[50].rule='dnum';this.rules[50].lower='dnum';this.rules[50].syntax=null;this.rules[50].semantic=null;this.rules[50].opcodeIndex=204;this.rules[51]=[];this.rules[51].rule='bnum';this.rules[51].lower='bnum';this.rules[51].syntax=null;this.rules[51].semantic=null;this.rules[51].opcodeIndex=206;this.rules[52]=[];this.rules[52].rule='xnum';this.rules[52].lower='xnum';this.rules[52].syntax=null;this.rules[52].semantic=null;this.rules[52].opcodeIndex=208;this.rules[53]=[];this.rules[53].rule='alphanum';this.rules[53].lower='alphanum';this.rules[53].syntax=null;this.rules[53].semantic=null;this.rules[53].opcodeIndex=213;this.rules[54]=[];this.rules[54].rule='owsp';this.rules[54].lower='owsp';this.rules[54].syntax=null;this.rules[54].semantic=null;this.rules[54].opcodeIndex=223;this.rules[55]=[];this.rules[55].rule='wsp';this.rules[55].lower='wsp';this.rules[55].syntax=null;this.rules[55].semantic=null;this.rules[55].opcodeIndex=225;this.rules[56]=[];this.rules[56].rule='space';this.rules[56].lower='space';this.rules[56].syntax=null;this.rules[56].semantic=null;this.rules[56].opcodeIndex=227;this.rules[57]=[];this.rules[57].rule='comment';this.rules[57].lower='comment';this.rules[57].syntax=null;this.rules[57].semantic=null;this.rules[57].opcodeIndex=231;this.rules[58]=[];this.rules[58].rule='LineEnd';this.rules[58].lower='lineend';this.rules[58].syntax=null;this.rules[58].semantic=null;this.rules[58].opcodeIndex=235;this.rules[59]=[];this.rules[59].rule='LineContinue';this.rules[59].lower='linecontinue';this.rules[59].syntax=null;this.rules[59].semantic=null;this.rules[59].opcodeIndex=236;this.opcodes=[];this.opcodes[0]=[];this.opcodes[0].opNext=5;this.opcodes[0].type=REP;this.opcodes[0].min=0;this.opcodes[0].max=4294967295;this.opcodes[1]=[];this.opcodes[1].opNext=5;this.opcodes[1].type=ALT;this.opcodes[2]=[];this.opcodes[2].opNext=3;this.opcodes[2].type=RNM;this.opcodes[2].ruleIndex=1;this.opcodes[3]=[];this.opcodes[3].opNext=4;this.opcodes[3].type=RNM;this.opcodes[3].ruleIndex=2;this.opcodes[4]=[];this.opcodes[4].opNext=5;this.opcodes[4].type=RNM;this.opcodes[4].ruleIndex=3;this.opcodes[5]=[];this.opcodes[5].opNext=14;this.opcodes[5].type=ALT;this.opcodes[6]=[];this.opcodes[6].opNext=7;this.opcodes[6].type=RNM;this.opcodes[6].ruleIndex=58;this.opcodes[7]=[];this.opcodes[7].opNext=14;this.opcodes[7].type=CAT;this.opcodes[8]=[];this.opcodes[8].opNext=11;this.opcodes[8].type=ALT;this.opcodes[9]=[];this.opcodes[9].opNext=10;this.opcodes[9].type=TRG;this.opcodes[9].min=59;this.opcodes[9].max=59;this.opcodes[10]=[];this.opcodes[10].opNext=11;this.opcodes[10].type=TRG;this.opcodes[10].min=32;this.opcodes[10].max=32;this.opcodes[11]=[];this.opcodes[11].opNext=13;this.opcodes[11].type=REP;this.opcodes[11].min=0;this.opcodes[11].max=4294967295;this.opcodes[12]=[];this.opcodes[12].opNext=13;this.opcodes[12].type=TRG;this.opcodes[12].min=32;this.opcodes[12].max=127;this.opcodes[13]=[];this.opcodes[13].opNext=14;this.opcodes[13].type=RNM;this.opcodes[13].ruleIndex=58;this.opcodes[14]=[];this.opcodes[14].opNext=24;this.opcodes[14].type=CAT;this.opcodes[15]=[];this.opcodes[15].opNext=16;this.opcodes[15].type=RNM;this.opcodes[15].ruleIndex=14;this.opcodes[16]=[];this.opcodes[16].opNext=17;this.opcodes[16].type=RNM;this.opcodes[16].ruleIndex=54;this.opcodes[17]=[];this.opcodes[17].opNext=20;this.opcodes[17].type=ALT;this.opcodes[18]=[];this.opcodes[18].opNext=19;this.opcodes[18].type=RNM;this.opcodes[18].ruleIndex=16;this.opcodes[19]=[];this.opcodes[19].opNext=20;this.opcodes[19].type=RNM;this.opcodes[19].ruleIndex=15;this.opcodes[20]=[];this.opcodes[20].opNext=21;this.opcodes[20].type=RNM;this.opcodes[20].ruleIndex=54;this.opcodes[21]=[];this.opcodes[21].opNext=22;this.opcodes[21].type=RNM;this.opcodes[21].ruleIndex=4;this.opcodes[22]=[];this.opcodes[22].opNext=23;this.opcodes[22].type=RNM;this.opcodes[22].ruleIndex=54;this.opcodes[23]=[];this.opcodes[23].opNext=24;this.opcodes[23].type=RNM;this.opcodes[23].ruleIndex=58;this.opcodes[24]=[];this.opcodes[24].opNext=30;this.opcodes[24].type=CAT;this.opcodes[25]=[];this.opcodes[25].opNext=29;this.opcodes[25].type=REP;this.opcodes[25].min=0;this.opcodes[25].max=4294967295;this.opcodes[26]=[];this.opcodes[26].opNext=29;this.opcodes[26].type=ALT;this.opcodes[27]=[];this.opcodes[27].opNext=28;this.opcodes[27].type=TRG;this.opcodes[27].min=32;this.opcodes[27].max=127;this.opcodes[28]=[];this.opcodes[28].opNext=29;this.opcodes[28].type=RNM;this.opcodes[28].ruleIndex=59;this.opcodes[29]=[];this.opcodes[29].opNext=30;this.opcodes[29].type=RNM;this.opcodes[29].ruleIndex=58;this.opcodes[30]=[];this.opcodes[30].opNext=36;this.opcodes[30].type=CAT;this.opcodes[31]=[];this.opcodes[31].opNext=32;this.opcodes[31].type=RNM;this.opcodes[31].ruleIndex=5;this.opcodes[32]=[];this.opcodes[32].opNext=36;this.opcodes[32].type=REP;this.opcodes[32].min=0;this.opcodes[32].max=4294967295;this.opcodes[33]=[];this.opcodes[33].opNext=36;this.opcodes[33].type=CAT;this.opcodes[34]=[];this.opcodes[34].opNext=35;this.opcodes[34].type=RNM;this.opcodes[34].ruleIndex=18;this.opcodes[35]=[];this.opcodes[35].opNext=36;this.opcodes[35].type=RNM;this.opcodes[35].ruleIndex=5;this.opcodes[36]=[];this.opcodes[36].opNext=43;this.opcodes[36].type=CAT;this.opcodes[37]=[];this.opcodes[37].opNext=38;this.opcodes[37].type=RNM;this.opcodes[37].ruleIndex=54;this.opcodes[38]=[];this.opcodes[38].opNext=39;this.opcodes[38].type=RNM;this.opcodes[38].ruleIndex=6;this.opcodes[39]=[];this.opcodes[39].opNext=43;this.opcodes[39].type=REP;this.opcodes[39].min=0;this.opcodes[39].max=4294967295;this.opcodes[40]=[];this.opcodes[40].opNext=43;this.opcodes[40].type=CAT;this.opcodes[41]=[];this.opcodes[41].opNext=42;this.opcodes[41].type=RNM;this.opcodes[41].ruleIndex=19;this.opcodes[42]=[];this.opcodes[42].opNext=43;this.opcodes[42].type=RNM;this.opcodes[42].ruleIndex=6;this.opcodes[43]=[];this.opcodes[43].opNext=47;this.opcodes[43].type=ALT;this.opcodes[44]=[];this.opcodes[44].opNext=45;this.opcodes[44].type=RNM;this.opcodes[44].ruleIndex=7;this.opcodes[45]=[];this.opcodes[45].opNext=46;this.opcodes[45].type=RNM;this.opcodes[45].ruleIndex=8;this.opcodes[46]=[];this.opcodes[46].opNext=47;this.opcodes[46].type=RNM;this.opcodes[46].ruleIndex=10;this.opcodes[47]=[];this.opcodes[47].opNext=50;this.opcodes[47].type=CAT;this.opcodes[48]=[];this.opcodes[48].opNext=49;this.opcodes[48].type=RNM;this.opcodes[48].ruleIndex=9;this.opcodes[49]=[];this.opcodes[49].opNext=50;this.opcodes[49].type=RNM;this.opcodes[49].ruleIndex=10;this.opcodes[50]=[];this.opcodes[50].opNext=55;this.opcodes[50].type=CAT;this.opcodes[51]=[];this.opcodes[51].opNext=54;this.opcodes[51].type=ALT;this.opcodes[52]=[];this.opcodes[52].opNext=53;this.opcodes[52].type=RNM;this.opcodes[52].ruleIndex=21;this.opcodes[53]=[];this.opcodes[53].opNext=54;this.opcodes[53].type=RNM;this.opcodes[53].ruleIndex=22;this.opcodes[54]=[];this.opcodes[54].opNext=55;this.opcodes[54].type=RNM;this.opcodes[54].ruleIndex=10;this.opcodes[55]=[];this.opcodes[55].opNext=68;this.opcodes[55].type=ALT;this.opcodes[56]=[];this.opcodes[56].opNext=60;this.opcodes[56].type=CAT;this.opcodes[57]=[];this.opcodes[57].opNext=58;this.opcodes[57].type=RNM;this.opcodes[57].ruleIndex=30;this.opcodes[58]=[];this.opcodes[58].opNext=59;this.opcodes[58].type=RNM;this.opcodes[58].ruleIndex=20;this.opcodes[59]=[];this.opcodes[59].opNext=60;this.opcodes[59].type=RNM;this.opcodes[59].ruleIndex=32;this.opcodes[60]=[];this.opcodes[60].opNext=63;this.opcodes[60].type=CAT;this.opcodes[61]=[];this.opcodes[61].opNext=62;this.opcodes[61].type=RNM;this.opcodes[61].ruleIndex=30;this.opcodes[62]=[];this.opcodes[62].opNext=63;this.opcodes[62].type=RNM;this.opcodes[62].ruleIndex=20;this.opcodes[63]=[];this.opcodes[63].opNext=66;this.opcodes[63].type=CAT;this.opcodes[64]=[];this.opcodes[64].opNext=65;this.opcodes[64].type=RNM;this.opcodes[64].ruleIndex=20;this.opcodes[65]=[];this.opcodes[65].opNext=66;this.opcodes[65].type=RNM;this.opcodes[65].ruleIndex=32;this.opcodes[66]=[];this.opcodes[66].opNext=67;this.opcodes[66].type=RNM;this.opcodes[66].ruleIndex=20;this.opcodes[67]=[];this.opcodes[67].opNext=68;this.opcodes[67].type=RNM;this.opcodes[67].ruleIndex=31;this.opcodes[68]=[];this.opcodes[68].opNext=76;this.opcodes[68].type=ALT;this.opcodes[69]=[];this.opcodes[69].opNext=70;this.opcodes[69].type=RNM;this.opcodes[69].ruleIndex=27;this.opcodes[70]=[];this.opcodes[70].opNext=71;this.opcodes[70].type=RNM;this.opcodes[70].ruleIndex=28;this.opcodes[71]=[];this.opcodes[71].opNext=72;this.opcodes[71].type=RNM;this.opcodes[71].ruleIndex=29;this.opcodes[72]=[];this.opcodes[72].opNext=73;this.opcodes[72].type=RNM;this.opcodes[72].ruleIndex=17;this.opcodes[73]=[];this.opcodes[73].opNext=74;this.opcodes[73].type=RNM;this.opcodes[73].ruleIndex=11;this.opcodes[74]=[];this.opcodes[74].opNext=75;this.opcodes[74].type=RNM;this.opcodes[74].ruleIndex=12;this.opcodes[75]=[];this.opcodes[75].opNext=76;this.opcodes[75].type=RNM;this.opcodes[75].ruleIndex=13;this.opcodes[76]=[];this.opcodes[76].opNext=80;this.opcodes[76].type=CAT;this.opcodes[77]=[];this.opcodes[77].opNext=78;this.opcodes[77].type=RNM;this.opcodes[77].ruleIndex=23;this.opcodes[78]=[];this.opcodes[78].opNext=79;this.opcodes[78].type=RNM;this.opcodes[78].ruleIndex=4;this.opcodes[79]=[];this.opcodes[79].opNext=80;this.opcodes[79].type=RNM;this.opcodes[79].ruleIndex=24;this.opcodes[80]=[];this.opcodes[80].opNext=84;this.opcodes[80].type=CAT;this.opcodes[81]=[];this.opcodes[81].opNext=82;this.opcodes[81].type=RNM;this.opcodes[81].ruleIndex=25;this.opcodes[82]=[];this.opcodes[82].opNext=83;this.opcodes[82].type=RNM;this.opcodes[82].ruleIndex=4;this.opcodes[83]=[];this.opcodes[83].opNext=84;this.opcodes[83].type=RNM;this.opcodes[83].ruleIndex=26;this.opcodes[84]=[];this.opcodes[84].opNext=91;this.opcodes[84].type=CAT;this.opcodes[85]=[];this.opcodes[85].opNext=86;this.opcodes[85].type=TRG;this.opcodes[85].min=60;this.opcodes[85].max=60;this.opcodes[86]=[];this.opcodes[86].opNext=90;this.opcodes[86].type=REP;this.opcodes[86].min=0;this.opcodes[86].max=4294967295;this.opcodes[87]=[];this.opcodes[87].opNext=90;this.opcodes[87].type=ALT;this.opcodes[88]=[];this.opcodes[88].opNext=89;this.opcodes[88].type=TRG;this.opcodes[88].min=32;this.opcodes[88].max=61;this.opcodes[89]=[];this.opcodes[89].opNext=90;this.opcodes[89].type=TRG;this.opcodes[89].min=63;this.opcodes[89].max=127;this.opcodes[90]=[];this.opcodes[90].opNext=91;this.opcodes[90].type=TRG;this.opcodes[90].min=62;this.opcodes[90].max=62;this.opcodes[91]=[];this.opcodes[91].opNext=92;this.opcodes[91].type=RNM;this.opcodes[91].ruleIndex=53;this.opcodes[92]=[];this.opcodes[92].opNext=93;this.opcodes[92].type=TRG;this.opcodes[92].min=61;this.opcodes[92].max=61;this.opcodes[93]=[];this.opcodes[93].opNext=94;this.opcodes[93].type=TBS;this.opcodes[93].length=2;this.opcodes[93].stringIndex=0;this.opcodes[94]=[];this.opcodes[94].opNext=95;this.opcodes[94].type=RNM;this.opcodes[94].ruleIndex=53;this.opcodes[95]=[];this.opcodes[95].opNext=98;this.opcodes[95].type=CAT;this.opcodes[96]=[];this.opcodes[96].opNext=97;this.opcodes[96].type=RNM;this.opcodes[96].ruleIndex=54;this.opcodes[97]=[];this.opcodes[97].opNext=98;this.opcodes[97].type=TRG;this.opcodes[97].min=47;this.opcodes[97].max=47;this.opcodes[98]=[];this.opcodes[98].opNext=99;this.opcodes[98].type=RNM;this.opcodes[98].ruleIndex=55;this.opcodes[99]=[];this.opcodes[99].opNext=100;this.opcodes[99].type=TRG;this.opcodes[99].min=42;this.opcodes[99].max=42;this.opcodes[100]=[];this.opcodes[100].opNext=101;this.opcodes[100].type=TRG;this.opcodes[100].min=38;this.opcodes[100].max=38;this.opcodes[101]=[];this.opcodes[101].opNext=102;this.opcodes[101].type=TRG;this.opcodes[101].min=33;this.opcodes[101].max=33;this.opcodes[102]=[];this.opcodes[102].opNext=105;this.opcodes[102].type=CAT;this.opcodes[103]=[];this.opcodes[103].opNext=104;this.opcodes[103].type=TRG;this.opcodes[103].min=40;this.opcodes[103].max=40;this.opcodes[104]=[];this.opcodes[104].opNext=105;this.opcodes[104].type=RNM;this.opcodes[104].ruleIndex=54;this.opcodes[105]=[];this.opcodes[105].opNext=108;this.opcodes[105].type=CAT;this.opcodes[106]=[];this.opcodes[106].opNext=107;this.opcodes[106].type=RNM;this.opcodes[106].ruleIndex=54;this.opcodes[107]=[];this.opcodes[107].opNext=108;this.opcodes[107].type=TRG;this.opcodes[107].min=41;this.opcodes[107].max=41;this.opcodes[108]=[];this.opcodes[108].opNext=111;this.opcodes[108].type=CAT;this.opcodes[109]=[];this.opcodes[109].opNext=110;this.opcodes[109].type=TRG;this.opcodes[109].min=91;this.opcodes[109].max=91;this.opcodes[110]=[];this.opcodes[110].opNext=111;this.opcodes[110].type=RNM;this.opcodes[110].ruleIndex=54;this.opcodes[111]=[];this.opcodes[111].opNext=114;this.opcodes[111].type=CAT;this.opcodes[112]=[];this.opcodes[112].opNext=113;this.opcodes[112].type=RNM;this.opcodes[112].ruleIndex=54;this.opcodes[113]=[];this.opcodes[113].opNext=114;this.opcodes[113].type=TRG;this.opcodes[113].min=93;this.opcodes[113].max=93;this.opcodes[114]=[];this.opcodes[114].opNext=120;this.opcodes[114].type=CAT;this.opcodes[115]=[];this.opcodes[115].opNext=116;this.opcodes[115].type=TRG;this.opcodes[115].min=37;this.opcodes[115].max=37;this.opcodes[116]=[];this.opcodes[116].opNext=120;this.opcodes[116].type=ALT;this.opcodes[117]=[];this.opcodes[117].opNext=118;this.opcodes[117].type=RNM;this.opcodes[117].ruleIndex=35;this.opcodes[118]=[];this.opcodes[118].opNext=119;this.opcodes[118].type=RNM;this.opcodes[118].ruleIndex=36;this.opcodes[119]=[];this.opcodes[119].opNext=120;this.opcodes[119].type=RNM;this.opcodes[119].ruleIndex=37;this.opcodes[120]=[];this.opcodes[120].opNext=126;this.opcodes[120].type=CAT;this.opcodes[121]=[];this.opcodes[121].opNext=122;this.opcodes[121].type=TRG;this.opcodes[121].min=37;this.opcodes[121].max=37;this.opcodes[122]=[];this.opcodes[122].opNext=126;this.opcodes[122].type=ALT;this.opcodes[123]=[];this.opcodes[123].opNext=124;this.opcodes[123].type=RNM;this.opcodes[123].ruleIndex=38;this.opcodes[124]=[];this.opcodes[124].opNext=125;this.opcodes[124].type=RNM;this.opcodes[124].ruleIndex=39;this.opcodes[125]=[];this.opcodes[125].opNext=126;this.opcodes[125].type=RNM;this.opcodes[125].ruleIndex=40;this.opcodes[126]=[];this.opcodes[126].opNext=133;this.opcodes[126].type=CAT;this.opcodes[127]=[];this.opcodes[127].opNext=128;this.opcodes[127].type=RNM;this.opcodes[127].ruleIndex=33;this.opcodes[128]=[];this.opcodes[128].opNext=132;this.opcodes[128].type=REP;this.opcodes[128].min=0;this.opcodes[128].max=4294967295;this.opcodes[129]=[];this.opcodes[129].opNext=132;this.opcodes[129].type=ALT;this.opcodes[130]=[];this.opcodes[130].opNext=131;this.opcodes[130].type=TRG;this.opcodes[130].min=32;this.opcodes[130].max=33;this.opcodes[131]=[];this.opcodes[131].opNext=132;this.opcodes[131].type=TRG;this.opcodes[131].min=35;this.opcodes[131].max=127;this.opcodes[132]=[];this.opcodes[132].opNext=133;this.opcodes[132].type=RNM;this.opcodes[132].ruleIndex=34;this.opcodes[133]=[];this.opcodes[133].opNext=135;this.opcodes[133].type=REP;this.opcodes[133].min=1;this.opcodes[133].max=4294967295;this.opcodes[134]=[];this.opcodes[134].opNext=135;this.opcodes[134].type=TRG;this.opcodes[134].min=48;this.opcodes[134].max=57;this.opcodes[135]=[];this.opcodes[135].opNext=137;this.opcodes[135].type=REP;this.opcodes[135].min=1;this.opcodes[135].max=4294967295;this.opcodes[136]=[];this.opcodes[136].opNext=137;this.opcodes[136].type=TRG;this.opcodes[136].min=48;this.opcodes[136].max=57;this.opcodes[137]=[];this.opcodes[137].opNext=139;this.opcodes[137].type=REP;this.opcodes[137].min=1;this.opcodes[137].max=4294967295;this.opcodes[138]=[];this.opcodes[138].opNext=139;this.opcodes[138].type=TRG;this.opcodes[138].min=48;this.opcodes[138].max=57;this.opcodes[139]=[];this.opcodes[139].opNext=140;this.opcodes[139].type=TRG;this.opcodes[139].min=34;this.opcodes[139].max=34;this.opcodes[140]=[];this.opcodes[140].opNext=141;this.opcodes[140].type=TRG;this.opcodes[140].min=34;this.opcodes[140].max=34;this.opcodes[141]=[];this.opcodes[141].opNext=146;this.opcodes[141].type=CAT;this.opcodes[142]=[];this.opcodes[142].opNext=143;this.opcodes[142].type=RNM;this.opcodes[142].ruleIndex=41;this.opcodes[143]=[];this.opcodes[143].opNext=144;this.opcodes[143].type=RNM;this.opcodes[143].ruleIndex=44;this.opcodes[144]=[];this.opcodes[144].opNext=145;this.opcodes[144].type=TRG;this.opcodes[144].min=45;this.opcodes[144].max=45;this.opcodes[145]=[];this.opcodes[145].opNext=146;this.opcodes[145].type=RNM;this.opcodes[145].ruleIndex=45;this.opcodes[146]=[];this.opcodes[146].opNext=151;this.opcodes[146].type=CAT;this.opcodes[147]=[];this.opcodes[147].opNext=148;this.opcodes[147].type=RNM;this.opcodes[147].ruleIndex=42;this.opcodes[148]=[];this.opcodes[148].opNext=149;this.opcodes[148].type=RNM;this.opcodes[148].ruleIndex=48;this.opcodes[149]=[];this.opcodes[149].opNext=150;this.opcodes[149].type=TRG;this.opcodes[149].min=45;this.opcodes[149].max=45;this.opcodes[150]=[];this.opcodes[150].opNext=151;this.opcodes[150].type=RNM;this.opcodes[150].ruleIndex=49;this.opcodes[151]=[];this.opcodes[151].opNext=156;this.opcodes[151].type=CAT;this.opcodes[152]=[];this.opcodes[152].opNext=153;this.opcodes[152].type=RNM;this.opcodes[152].ruleIndex=43;this.opcodes[153]=[];this.opcodes[153].opNext=154;this.opcodes[153].type=RNM;this.opcodes[153].ruleIndex=46;this.opcodes[154]=[];this.opcodes[154].opNext=155;this.opcodes[154].type=TRG;this.opcodes[154].min=45;this.opcodes[154].max=45;this.opcodes[155]=[];this.opcodes[155].opNext=156;this.opcodes[155].type=RNM;this.opcodes[155].ruleIndex=47;this.opcodes[156]=[];this.opcodes[156].opNext=163;this.opcodes[156].type=CAT;this.opcodes[157]=[];this.opcodes[157].opNext=158;this.opcodes[157].type=RNM;this.opcodes[157].ruleIndex=41;this.opcodes[158]=[];this.opcodes[158].opNext=159;this.opcodes[158].type=RNM;this.opcodes[158].ruleIndex=50;this.opcodes[159]=[];this.opcodes[159].opNext=163;this.opcodes[159].type=REP;this.opcodes[159].min=0;this.opcodes[159].max=4294967295;this.opcodes[160]=[];this.opcodes[160].opNext=163;this.opcodes[160].type=CAT;this.opcodes[161]=[];this.opcodes[161].opNext=162;this.opcodes[161].type=TRG;this.opcodes[161].min=46;this.opcodes[161].max=46;this.opcodes[162]=[];this.opcodes[162].opNext=163;this.opcodes[162].type=RNM;this.opcodes[162].ruleIndex=50;this.opcodes[163]=[];this.opcodes[163].opNext=170;this.opcodes[163].type=CAT;this.opcodes[164]=[];this.opcodes[164].opNext=165;this.opcodes[164].type=RNM;this.opcodes[164].ruleIndex=42;this.opcodes[165]=[];this.opcodes[165].opNext=166;this.opcodes[165].type=RNM;this.opcodes[165].ruleIndex=52;this.opcodes[166]=[];this.opcodes[166].opNext=170;this.opcodes[166].type=REP;this.opcodes[166].min=0;this.opcodes[166].max=4294967295;this.opcodes[167]=[];this.opcodes[167].opNext=170;this.opcodes[167].type=CAT;this.opcodes[168]=[];this.opcodes[168].opNext=169;this.opcodes[168].type=TRG;this.opcodes[168].min=46;this.opcodes[168].max=46;this.opcodes[169]=[];this.opcodes[169].opNext=170;this.opcodes[169].type=RNM;this.opcodes[169].ruleIndex=52;this.opcodes[170]=[];this.opcodes[170].opNext=177;this.opcodes[170].type=CAT;this.opcodes[171]=[];this.opcodes[171].opNext=172;this.opcodes[171].type=RNM;this.opcodes[171].ruleIndex=43;this.opcodes[172]=[];this.opcodes[172].opNext=173;this.opcodes[172].type=RNM;this.opcodes[172].ruleIndex=51;this.opcodes[173]=[];this.opcodes[173].opNext=177;this.opcodes[173].type=REP;this.opcodes[173].min=0;this.opcodes[173].max=4294967295;this.opcodes[174]=[];this.opcodes[174].opNext=177;this.opcodes[174].type=CAT;this.opcodes[175]=[];this.opcodes[175].opNext=176;this.opcodes[175].type=TRG;this.opcodes[175].min=46;this.opcodes[175].max=46;this.opcodes[176]=[];this.opcodes[176].opNext=177;this.opcodes[176].type=RNM;this.opcodes[176].ruleIndex=51;this.opcodes[177]=[];this.opcodes[177].opNext=180;this.opcodes[177].type=ALT;this.opcodes[178]=[];this.opcodes[178].opNext=179;this.opcodes[178].type=TRG;this.opcodes[178].min=68;this.opcodes[178].max=68;this.opcodes[179]=[];this.opcodes[179].opNext=180;this.opcodes[179].type=TRG;this.opcodes[179].min=100;this.opcodes[179].max=100;this.opcodes[180]=[];this.opcodes[180].opNext=183;this.opcodes[180].type=ALT;this.opcodes[181]=[];this.opcodes[181].opNext=182;this.opcodes[181].type=TRG;this.opcodes[181].min=88;this.opcodes[181].max=88;this.opcodes[182]=[];this.opcodes[182].opNext=183;this.opcodes[182].type=TRG;this.opcodes[182].min=120;this.opcodes[182].max=120;this.opcodes[183]=[];this.opcodes[183].opNext=186;this.opcodes[183].type=ALT;this.opcodes[184]=[];this.opcodes[184].opNext=185;this.opcodes[184].type=TRG;this.opcodes[184].min=66;this.opcodes[184].max=66;this.opcodes[185]=[];this.opcodes[185].opNext=186;this.opcodes[185].type=TRG;this.opcodes[185].min=98;this.opcodes[185].max=98;this.opcodes[186]=[];this.opcodes[186].opNext=188;this.opcodes[186].type=REP;this.opcodes[186].min=1;this.opcodes[186].max=4294967295;this.opcodes[187]=[];this.opcodes[187].opNext=188;this.opcodes[187].type=TRG;this.opcodes[187].min=48;this.opcodes[187].max=57;this.opcodes[188]=[];this.opcodes[188].opNext=190;this.opcodes[188].type=REP;this.opcodes[188].min=1;this.opcodes[188].max=4294967295;this.opcodes[189]=[];this.opcodes[189].opNext=190;this.opcodes[189].type=TRG;this.opcodes[189].min=48;this.opcodes[189].max=57;this.opcodes[190]=[];this.opcodes[190].opNext=192;this.opcodes[190].type=REP;this.opcodes[190].min=1;this.opcodes[190].max=4294967295;this.opcodes[191]=[];this.opcodes[191].opNext=192;this.opcodes[191].type=TRG;this.opcodes[191].min=48;this.opcodes[191].max=49;this.opcodes[192]=[];this.opcodes[192].opNext=194;this.opcodes[192].type=REP;this.opcodes[192].min=1;this.opcodes[192].max=4294967295;this.opcodes[193]=[];this.opcodes[193].opNext=194;this.opcodes[193].type=TRG;this.opcodes[193].min=48;this.opcodes[193].max=49;this.opcodes[194]=[];this.opcodes[194].opNext=199;this.opcodes[194].type=REP;this.opcodes[194].min=1;this.opcodes[194].max=4294967295;this.opcodes[195]=[];this.opcodes[195].opNext=199;this.opcodes[195].type=ALT;this.opcodes[196]=[];this.opcodes[196].opNext=197;this.opcodes[196].type=TRG;this.opcodes[196].min=48;this.opcodes[196].max=57;this.opcodes[197]=[];this.opcodes[197].opNext=198;this.opcodes[197].type=TRG;this.opcodes[197].min=65;this.opcodes[197].max=70;this.opcodes[198]=[];this.opcodes[198].opNext=199;this.opcodes[198].type=TRG;this.opcodes[198].min=97;this.opcodes[198].max=102;this.opcodes[199]=[];this.opcodes[199].opNext=204;this.opcodes[199].type=REP;this.opcodes[199].min=1;this.opcodes[199].max=4294967295;this.opcodes[200]=[];this.opcodes[200].opNext=204;this.opcodes[200].type=ALT;this.opcodes[201]=[];this.opcodes[201].opNext=202;this.opcodes[201].type=TRG;this.opcodes[201].min=48;this.opcodes[201].max=57;this.opcodes[202]=[];this.opcodes[202].opNext=203;this.opcodes[202].type=TRG;this.opcodes[202].min=65;this.opcodes[202].max=70;this.opcodes[203]=[];this.opcodes[203].opNext=204;this.opcodes[203].type=TRG;this.opcodes[203].min=97;this.opcodes[203].max=102;this.opcodes[204]=[];this.opcodes[204].opNext=206;this.opcodes[204].type=REP;this.opcodes[204].min=1;this.opcodes[204].max=4294967295;this.opcodes[205]=[];this.opcodes[205].opNext=206;this.opcodes[205].type=TRG;this.opcodes[205].min=48;this.opcodes[205].max=57;this.opcodes[206]=[];this.opcodes[206].opNext=208;this.opcodes[206].type=REP;this.opcodes[206].min=1;this.opcodes[206].max=4294967295;this.opcodes[207]=[];this.opcodes[207].opNext=208;this.opcodes[207].type=TRG;this.opcodes[207].min=48;this.opcodes[207].max=49;this.opcodes[208]=[];this.opcodes[208].opNext=213;this.opcodes[208].type=REP;this.opcodes[208].min=1;this.opcodes[208].max=4294967295;this.opcodes[209]=[];this.opcodes[209].opNext=213;this.opcodes[209].type=ALT;this.opcodes[210]=[];this.opcodes[210].opNext=211;this.opcodes[210].type=TRG;this.opcodes[210].min=48;this.opcodes[210].max=57;this.opcodes[211]=[];this.opcodes[211].opNext=212;this.opcodes[211].type=TRG;this.opcodes[211].min=65;this.opcodes[211].max=70;this.opcodes[212]=[];this.opcodes[212].opNext=213;this.opcodes[212].type=TRG;this.opcodes[212].min=97;this.opcodes[212].max=102;this.opcodes[213]=[];this.opcodes[213].opNext=223;this.opcodes[213].type=CAT;this.opcodes[214]=[];this.opcodes[214].opNext=217;this.opcodes[214].type=ALT;this.opcodes[215]=[];this.opcodes[215].opNext=216;this.opcodes[215].type=TRG;this.opcodes[215].min=97;this.opcodes[215].max=122;this.opcodes[216]=[];this.opcodes[216].opNext=217;this.opcodes[216].type=TRG;this.opcodes[216].min=65;this.opcodes[216].max=90;this.opcodes[217]=[];this.opcodes[217].opNext=223;this.opcodes[217].type=REP;this.opcodes[217].min=0;this.opcodes[217].max=4294967295;this.opcodes[218]=[];this.opcodes[218].opNext=223;this.opcodes[218].type=ALT;this.opcodes[219]=[];this.opcodes[219].opNext=220;this.opcodes[219].type=TRG;this.opcodes[219].min=97;this.opcodes[219].max=122;this.opcodes[220]=[];this.opcodes[220].opNext=221;this.opcodes[220].type=TRG;this.opcodes[220].min=65;this.opcodes[220].max=90;this.opcodes[221]=[];this.opcodes[221].opNext=222;this.opcodes[221].type=TRG;this.opcodes[221].min=48;this.opcodes[221].max=57;this.opcodes[222]=[];this.opcodes[222].opNext=223;this.opcodes[222].type=TRG;this.opcodes[222].min=45;this.opcodes[222].max=45;this.opcodes[223]=[];this.opcodes[223].opNext=225;this.opcodes[223].type=REP;this.opcodes[223].min=0;this.opcodes[223].max=4294967295;this.opcodes[224]=[];this.opcodes[224].opNext=225;this.opcodes[224].type=RNM;this.opcodes[224].ruleIndex=56;this.opcodes[225]=[];this.opcodes[225].opNext=227;this.opcodes[225].type=REP;this.opcodes[225].min=1;this.opcodes[225].max=4294967295;this.opcodes[226]=[];this.opcodes[226].opNext=227;this.opcodes[226].type=RNM;this.opcodes[226].ruleIndex=56;this.opcodes[227]=[];this.opcodes[227].opNext=231;this.opcodes[227].type=ALT;this.opcodes[228]=[];this.opcodes[228].opNext=229;this.opcodes[228].type=TRG;this.opcodes[228].min=32;this.opcodes[228].max=32;this.opcodes[229]=[];this.opcodes[229].opNext=230;this.opcodes[229].type=RNM;this.opcodes[229].ruleIndex=57;this.opcodes[230]=[];this.opcodes[230].opNext=231;this.opcodes[230].type=RNM;this.opcodes[230].ruleIndex=59;this.opcodes[231]=[];this.opcodes[231].opNext=235;this.opcodes[231].type=CAT;this.opcodes[232]=[];this.opcodes[232].opNext=233;this.opcodes[232].type=TRG;this.opcodes[232].min=59;this.opcodes[232].max=59;this.opcodes[233]=[];this.opcodes[233].opNext=235;this.opcodes[233].type=REP;this.opcodes[233].min=0;this.opcodes[233].max=4294967295;this.opcodes[234]=[];this.opcodes[234].opNext=235;this.opcodes[234].type=TRG;this.opcodes[234].min=32;this.opcodes[234].max=127;this.opcodes[235]=[];this.opcodes[235].opNext=236;this.opcodes[235].type=TRG;this.opcodes[235].min=10;this.opcodes[235].max=10;this.opcodes[236]=[];this.opcodes[236].opNext=239;this.opcodes[236].type=CAT;this.opcodes[237]=[];this.opcodes[237].opNext=238;this.opcodes[237].type=TRG;this.opcodes[237].min=10;this.opcodes[237].max=10;this.opcodes[238]=[];this.opcodes[238].opNext=239;this.opcodes[238].type=TRG;this.opcodes[238].min=32;this.opcodes[238].max=32;};"use strict";function syn_rule(state,chars,phraseIndex,data){if(state[OP_STATE]===APG_NOMATCH&&data.ruleError===false){var lineno,html='';lineno=data.findLine(phraseIndex);if(lineno===false){html+='Line: not found: phraseIndex: '+phraseIndex;data.log.logMsg(html);}else{html+='Line Number: '+(lineno+1);html+=' Character Offset: '+state[OP_MATCHED];html+=' - invalid rule syntax';data.log.logMsg(html);data.log.logMsg(data.formatLine(lineno,phraseIndex+state[OP_MATCHED]));}};data.ruleError=false;};function syn_namedef(state,chars,phraseIndex,data){var lineno,nextChar,ok,html='';if(state[OP_STATE]===APG_NOMATCH){data.ruleError=true;lineno=data.findLine(phraseIndex);if(lineno===false){html+='Line: not found: phraseIndex: '+phraseIndex;data.log.logMsg(html);}else{html+='Line Number: '+(lineno+1);html+=' Character Offset: '+state[OP_MATCHED];html+=' - expected rule name not found';data.log.logMsg(html);data.log.logMsg(data.formatLine(lineno,phraseIndex+state[OP_MATCHED]));}}else if(state[OP_STATE]===APG_MATCH){nextChar=phraseIndex+state[OP_MATCHED];ok=data.chars[nextChar]===ASCII_SPACE||data.chars[nextChar]===ASCII_LF||data.chars[nextChar]===61||data.chars[nextChar]===59;if(!ok){data.ruleError=true;lineno=data.findLine(phraseIndex);if(lineno===false){html+='Line: not found: phraseIndex: '+phraseIndex;data.log.logMsg(html);}else{html+='Line Number: '+(lineno+1);html+=' Character Offset: '+state[OP_MATCHED];html+=' - invalid characters found in rule name definition';data.log.logMsg(html);data.log.logMsg(data.formatLine(lineno,phraseIndex+state[OP_MATCHED]));}}}};function syn_rnmop(state,chars,phraseIndex,data){if(state[OP_STATE]===APG_MATCH){var lineno,nextChar,ok,html='';nextChar=phraseIndex+state[OP_MATCHED];ok=data.chars[nextChar]===ASCII_SPACE||data.chars[nextChar]===ASCII_LF||data.chars[nextChar]===41||data.chars[nextChar]===47||data.chars[nextChar]===59||data.chars[nextChar]===93||data.chars[nextChar]===61;if(!ok){data.ruleError=true;lineno=data.findLine(phraseIndex);if(lineno===false){html+='Line: not found: phraseIndex: '+phraseIndex;data.log.logMsg(html);}else{html+='Line Number: '+(lineno+1);html+=' Character Offset: '+state[OP_MATCHED];html+=' - invalid characters found in rule name';data.log.logMsg(html);data.log.logMsg(data.formatLine(lineno,phraseIndex+state[OP_MATCHED]));}}}};function syn_lparen(state,chars,phraseIndex,data){if(state[OP_STATE]===APG_MATCH){data.lparen.push(phraseIndex);}};function syn_rparen(state,chars,phraseIndex,data){if(state[OP_STATE]===APG_NOMATCH){var offset,lineno,html='';if(data.lparen.length>0){data.ruleError=true;offset=data.lparen.pop();lineno=data.findLine(offset);if(lineno===false){html+='Line: not found: phraseIndex: '+offset;data.log.logMsg(html);}else{html+='Line Number: '+(lineno+1);html+=' Character Offset: '+(offset-data.lineCatalog[lineno].offset);html+=' - group found no with closing paren';data.log.logMsg(html);data.log.logMsg(data.formatLine(lineno,offset));}}}};function syn_loption(state,chars,phraseIndex,data){if(state[OP_STATE]===APG_MATCH){data.loption.push(phraseIndex);}};function syn_roption(state,chars,phraseIndex,data){if(state[OP_STATE]===APG_NOMATCH){var offset,lineno,html='';if(data.loption.length>0){data.ruleError=true;offset=data.loption.pop();lineno=data.findLine(offset);if(lineno===false){html+='Line: not found: phraseIndex: '+offset;data.log.logMsg(html);}else{html+='Line Number: '+(lineno+1);html+=' Character Offset: '+(offset-data.lineCatalog[lineno].offset);html+=' - option found no with closing bracket';data.log.logMsg(html);data.log.logMsg(data.formatLine(lineno,offset));}}}};function syn_ltls(state,chars,phraseIndex,data){if(state[OP_STATE]===APG_MATCH){data.ltls.push(phraseIndex);}};function syn_rtls(state,chars,phraseIndex,data){if(state[OP_STATE]===APG_NOMATCH){var offset,lineno,html='';if(data.ltls.length>0){data.ruleError=true;offset=data.ltls.pop();lineno=data.findLine(offset);if(lineno===false){html+='Line: not found: phraseIndex: '+offset;data.log.logMsg(html);}else{html+='Line Number: '+(lineno+1);html+=' Character Offset: '+(offset-data.lineCatalog[lineno].offset);html+=' - literal string found with no closing double quote';data.log.logMsg(html);data.log.logMsg(data.formatLine(lineno,offset));}}}};function syn_incalt(state,chars,phraseIndex,data){if(state[OP_STATE]===APG_MATCH){var lineno,html='';lineno=data.findLine(phraseIndex);if(lineno===false){html+='Line: not found: phraseIndex: '+phraseIndex;data.log.logMsg(html);}else{html+='Line Number: '+(lineno+1);html+=' Character Offset: '+phraseIndex;html+=' - incremental alternate not recognized by APG';data.log.logMsg(html);data.log.logMsg(data.formatLine(lineno,phraseIndex));}}};function syn_prosval(state,chars,phraseIndex,data){if(state[OP_STATE]===APG_MATCH){var lineno,html='';lineno=data.findLine(phraseIndex);if(lineno===false){html+='Line: not found: phraseIndex: '+phraseIndex;data.log.logMsg(html);}else{html+='Line Number: '+(lineno+1);html+=' Character Offset: '+phraseIndex;html+=' - prose value not recognized by APG';data.log.logMsg(html);data.log.logMsg(data.formatLine(lineno,phraseIndex));}}};function syn_definedas(state,chars,phraseIndex,data){if(state[OP_STATE]===APG_NOMATCH){data.ruleError=true;var lineno,html='';lineno=data.findLine(phraseIndex);if(lineno===false){html+='Line: not found: phraseIndex: '+phraseIndex;data.log.logMsg(html);}else{html+='Line Number: '+(lineno+1);html+=' Character Offset: '+phraseIndex;html+=' - expected defined-as (=) not found';data.log.logMsg(html);data.log.logMsg(data.formatLine(lineno,phraseIndex));}}};function ApgSynCallbacks(log,ruleID){this.catalog=function(chars){this.chars=chars;this.lineCatalog.length=0;var i,lineno=0,count=0,offset=0;for(i=0;i<this.chars.length;i+=1){count+=1;if(this.chars[i]===ASCII_LF){this.lineCatalog[lineno]=[];this.lineCatalog[lineno].offset=offset;this.lineCatalog[lineno].count=count;lineno+=1;offset=i+1;count=0;}}};this.findLine=function(charNo){var i,line,ret=false;for(i=0;i<this.lineCatalog.length;i+=1){line=this.lineCatalog[i];if(line.offset<=charNo&&charNo<(line.offset+line.count)){ret=i;break;}};return ret;};this.formatLine=function(lineNo,offset){var i,code,beg,end,html='',span=false;beg=this.lineCatalog[lineNo].offset;end=beg+this.lineCatalog[lineNo].count;html+='<span class="parse">';for(i=beg;i<end;i+=1){if(i===offset){html+='<span class="parse-error">';span=true;};code=this.chars[i];if(code===ASCII_LF){html+='<span class="non-ascii">LF</span>';}else if(code===ASCII_LANGLE){html+='&lt;';}else if(code===ASCII_RANGLE){html+='&gt;';}else{html+=String.fromCharCode(this.chars[i]);}};if(span===true){html+='</span>';};html+='</span>';return html;};this.dumpLines=function(){var i,html='',error=5,offset;for(i=0;i<this.lineCatalog.length;i+=1){offset=this.lineCatalog[i].offset+error;html+=this.formatLine(i,offset);html+='<br />';};return html;};this.callbackList=function(ruleID,synList){for(var i=0;i<ruleID.length;i+=1){synList[i]=false;};synList[ruleID.rule]=syn_rule;synList[ruleID.namedef]=syn_namedef;synList[ruleID.incalt]=syn_incalt;synList[ruleID.definedas]=syn_definedas;synList[ruleID.prosval]=syn_prosval;synList[ruleID.rnmop]=syn_rnmop;synList[ruleID.loption]=syn_loption;synList[ruleID.roption]=syn_roption;synList[ruleID.rparen]=syn_rparen;synList[ruleID.lparen]=syn_lparen;synList[ruleID.rtls]=syn_rtls;synList[ruleID.ltls]=syn_ltls;};this.synLineNumber=1;this.ruleError=false;this.lparen=[];this.loption=[];this.ltls=[];this.chars=null;this.lineCatalog=[];this.log=log;this.synList=[];this.callbackList(ruleID,this.synList);};"use strict";function sem_file(state,chars,phraseIndex,phraseCount,data){var ret=APG_SEM_OK;switch(state){case APG_PRE:data.log.length=0;data.lineNo=1;data.altStack.length=0;data.catStack.length=0;data.repStack.length=0;data.prdStack.length=0;data.tempOpcodes.length=0;break;case APG_POST:if(data.altStack.length!==0){data.log.logMsg('sem_file: altStack not empty');};if(data.catStack.length!==0){data.log.logMsg('sem_file: catStack not empty');};if(data.repStack.length!==0){data.log.logMsg('sem_file: repStack not empty');};if(data.prdStack.length!==0){data.log.logMsg('sem_file: prdStack not empty');};data.tempToRules();data.tempToRuleIds();data.tempToRNM();data.tempToOpcodes();data.tempOpcodes.length=0;break;};return ret;};function sem_namedef(state,chars,phraseIndex,phraseCount,data){var name,ret=APG_SEM_OK;switch(state){case APG_PRE:name=charsToString(chars,phraseIndex,phraseCount);if(!data.nameSave(name)){data.log.logLine(data.lineNo,phraseIndex,phraseCount,'rule name "'+name+'" multiply defined');};break;case APG_POST:break;};return ret;};function sem_alternation(state,chars,phraseIndex,phraseCount,data){var opIndex,last,ret=APG_SEM_OK;switch(state){case APG_PRE:opIndex=data.tempOpcodes.length;data.altIndex+=1;data.altStack[data.altIndex]=[];data.altStack[data.altIndex].thisOpIndex=opIndex;data.tempOpcodes[opIndex]=[];data.tempOpcodes[opIndex].type=ALT;data.tempOpcodes[opIndex].opNext=0;data.tempOpcodes[opIndex].childCount=1;data.tempOpcodes[opIndex].lineNo=data.lineNo;break;case APG_POST:last=data.altStack.pop();data.altIndex-=1;data.tempOpcodes[last.thisOpIndex].opNext=data.tempOpcodes.length;break;};return ret;};function sem_concatenation(state,chars,phraseIndex,phraseCount,data){var opIndex,last,ret=APG_SEM_OK;switch(state){case APG_PRE:opIndex=data.tempOpcodes.length;data.catIndex+=1;data.catStack[data.catIndex]=[];data.catStack[data.catIndex].thisOpIndex=opIndex;data.tempOpcodes[opIndex]=[];data.tempOpcodes[opIndex].type=CAT;data.tempOpcodes[opIndex].opNext=0;data.tempOpcodes[opIndex].childCount=1;data.tempOpcodes[opIndex].lineNo=data.lineNo;break;case APG_POST:last=data.catStack.pop();data.catIndex-=1;data.tempOpcodes[last.thisOpIndex].opNext=data.tempOpcodes.length;break;};return ret;};function sem_repetition(state,chars,phraseIndex,phraseCount,data){var last,opIndex,ret=APG_SEM_OK;switch(state){case APG_PRE:opIndex=data.tempOpcodes.length;data.repIndex+=1;data.repStack[data.repIndex]=[];data.repStack[data.repIndex].thisOpIndex=opIndex;data.tempOpcodes[opIndex]=[];data.tempOpcodes[opIndex].type=REP;data.tempOpcodes[opIndex].opNext=0;data.tempOpcodes[opIndex].lineNo=data.lineNo;data.tempOpcodes[opIndex].min=1;data.tempOpcodes[opIndex].max=1;break;case APG_POST:last=data.repStack.pop();opIndex=last.thisOpIndex;data.repIndex-=1;data.tempOpcodes[opIndex].opNext=data.tempOpcodes.length;if(data.tempOpcodes[opIndex].min===0&&data.tempOpcodes[opIndex].max===0){data.log.logLine(data.lineNo,phraseIndex,phraseCount,'REP: min = max = 0 is invalid. Use TLS = "".');};break;};return ret;};function sem_predicate(state,chars,phraseIndex,phraseCount,data){var last,opIndex,ret=APG_SEM_OK;switch(state){case APG_PRE:opIndex=data.tempOpcodes.length;data.prdIndex+=1;data.prdStack[data.prdIndex]=[];data.prdStack[data.prdIndex].thisOpIndex=opIndex;data.tempOpcodes[opIndex]=[];data.tempOpcodes[opIndex].type=PRD;data.tempOpcodes[opIndex].opNext=0;data.tempOpcodes[opIndex].and=true;data.tempOpcodes[opIndex].lineNo=data.lineNo;break;case APG_POST:last=data.prdStack.pop();opIndex=last.thisOpIndex;data.prdIndex-=1;data.tempOpcodes[opIndex].opNext=data.tempOpcodes.length;data.tempOpcodes[opIndex].and=last.and;break;};return ret;};function sem_rnm(state,chars,phraseIndex,phraseCount,data){var opIndex,ret=APG_SEM_OK;switch(state){case APG_PRE:opIndex=data.tempOpcodes.length;data.tempOpcodes[opIndex]=[];data.tempOpcodes[opIndex].type=RNM;data.tempOpcodes[opIndex].opNext=opIndex+1;data.tempOpcodes[opIndex].ruleName=charsToString(chars,phraseIndex,phraseCount);data.tempOpcodes[opIndex].ruleIndex=0;data.tempOpcodes[opIndex].lineNo=data.lineNo;break;case APG_POST:break;};return ret;};function sem_trg(state,chars,phraseIndex,phraseCount,data){var opIndex,ret=APG_SEM_OK;switch(state){case APG_PRE:break;case APG_POST:opIndex=data.tempOpcodes.length;data.tempOpcodes[opIndex]=[];data.tempOpcodes[opIndex].type=TRG;data.tempOpcodes[opIndex].opNext=opIndex+1;data.tempOpcodes[opIndex].min=data.dmin;data.tempOpcodes[opIndex].max=data.dmax;data.tempOpcodes[opIndex].lineNo=data.lineNo;if(data.dmax<data.dmin){data.log.logLine(data.lineNo,phraseIndex,phraseCount,'TRG: invalid range: max.+data.dmax+ &lt; min.+data.dmin+');};break;};return ret;};function sem_tbs(state,chars,phraseIndex,phraseCount,data){var i,stringIndex,opIndex,ret=APG_SEM_OK;switch(state){case APG_PRE:data.dnum.length=0;break;case APG_POST:opIndex=data.tempOpcodes.length;if(data.dnum.length===1){data.tempOpcodes[opIndex]=[];data.tempOpcodes[opIndex].type=TRG;data.tempOpcodes[opIndex].opNext=opIndex+1;data.tempOpcodes[opIndex].min=data.dnum[0];data.tempOpcodes[opIndex].max=data.dnum[0];}else{stringIndex=data.stringTable.length;data.tempOpcodes[opIndex]=[];data.tempOpcodes[opIndex].type=TBS;data.tempOpcodes[opIndex].opNext=opIndex+1;data.tempOpcodes[opIndex].length=data.dnum.length;data.tempOpcodes[opIndex].stringIndex=stringIndex;data.tempOpcodes[opIndex].lineNo=data.lineNo;for(i=0;i<data.dnum.length;i+=1){data.stringTable.push(data.dnum[i]);}};data.dnum.length=0;break;};return ret;};function sem_tls(state,chars,phraseIndex,phraseCount,data){var opIndex,string,len,stringIndex,i,ret=APG_SEM_OK;switch(state){case APG_PRE:string=charsToString(chars,phraseIndex,phraseCount);len=string.length;stringIndex=data.stringTable.length;if(string.charAt(0)!=='"'||string.charAt(len-1)!=='"'){data.log.logLine(data.lineNo,phraseIndex,phraseCount,'invalid TLS string string.charAt(0).+string.charAt(0)+');data.log.logLine(data.lineNo,phraseIndex,phraseCount,'invalid TLS string string.charAt(len-1).+string.charAt(len-1)+');data.log.logLine(data.lineNo,phraseIndex,phraseCount,'invalid TLS string .+string+');};for(i=1;i<(len-1);i+=1){data.stringTable.push(string.charCodeAt(i));};opIndex=data.tempOpcodes.length;data.tempOpcodes[opIndex]=[];data.tempOpcodes[opIndex].type=TLS;data.tempOpcodes[opIndex].opNext=opIndex+1;data.tempOpcodes[opIndex].length=len-2;data.tempOpcodes[opIndex].stringIndex=stringIndex;data.tempOpcodes[opIndex].lineNo=data.lineNo;break;case APG_POST:break;};return ret;};function sem_alt(state,chars,phraseIndex,phraseCount,data){var opIndex,ret=APG_SEM_OK;switch(state){case APG_PRE:opIndex=data.altStack[data.altIndex].thisOpIndex;data.tempOpcodes[opIndex].childCount+=1;break;case APG_POST:break;};return ret;};function sem_cat(state,chars,phraseIndex,phraseCount,data){var opIndex,ret=APG_SEM_OK;switch(state){case APG_PRE:opIndex=data.catStack[data.catIndex].thisOpIndex;data.tempOpcodes[opIndex].childCount+=1;break;case APG_POST:break;};return ret;};function sem_and(state,chars,phraseIndex,phraseCount,data){var index,ret=APG_SEM_OK;switch(state){case APG_PRE:index=data.prdStack.length-1;data.prdStack[index].and=true;break;case APG_POST:break;};return ret;};function sem_not(state,chars,phraseIndex,phraseCount,data){var index,ret=APG_SEM_OK;switch(state){case APG_PRE:index=data.prdStack.length-1;data.prdStack[index].and=false;break;case APG_POST:break;};return ret;};function sem_repeat(state,chars,phraseIndex,phraseCount,data){var opIndex,ret=APG_SEM_OK;switch(state){case APG_PRE:opIndex=data.repStack[data.repIndex].thisOpIndex;data.tempOpcodes[opIndex].min=0;data.tempOpcodes[opIndex].max=Infinity;break;case APG_POST:break;};return ret;};function sem_rep_min_max(state,chars,phraseIndex,phraseCount,data){var opIndex,string,ret=APG_SEM_OK;switch(state){case APG_PRE:opIndex=data.repStack[data.repIndex].thisOpIndex;string=charsToString(chars,phraseIndex,phraseCount);data.tempOpcodes[opIndex].min=Number(string);data.tempOpcodes[opIndex].max=data.tempOpcodes[opIndex].min;break;case APG_POST:break;};return ret;};function sem_rep_min(state,chars,phraseIndex,phraseCount,data){var opIndex,string,ret=APG_SEM_OK;switch(state){case APG_PRE:opIndex=data.repStack[data.repIndex].thisOpIndex;string=charsToString(chars,phraseIndex,phraseCount);data.tempOpcodes[opIndex].min=Number(string);break;case APG_POST:break;};return ret;};function sem_rep_max(state,chars,phraseIndex,phraseCount,data){var opIndex,string,ret=APG_SEM_OK;switch(state){case APG_PRE:opIndex=data.repStack[data.repIndex].thisOpIndex;string=charsToString(chars,phraseIndex,phraseCount);data.tempOpcodes[opIndex].max=Number(string);break;case APG_POST:break;};return ret;};function sem_option(state,chars,phraseIndex,phraseCount,data){var last,opIndex,ret=APG_SEM_OK;switch(state){case APG_PRE:opIndex=data.tempOpcodes.length;data.repIndex+=1;data.repStack[data.repIndex]=[];data.repStack[data.repIndex].thisOpIndex=opIndex;data.tempOpcodes[opIndex]=[];data.tempOpcodes[opIndex].type=REP;data.tempOpcodes[opIndex].opNext=0;data.tempOpcodes[opIndex].lineNo=data.lineNo;data.tempOpcodes[opIndex].min=0;data.tempOpcodes[opIndex].max=1;break;case APG_POST:last=data.repStack.pop();data.repIndex-=1;data.tempOpcodes[last.thisOpIndex].opNext=data.tempOpcodes.length;break;};return ret;};function sem_dmin(state,chars,phraseIndex,phraseCount,data){var string,num,ret=APG_SEM_OK;switch(state){case APG_PRE:string=charsToString(chars,phraseIndex,phraseCount);num=Number(string);data.dmin=num;break;case APG_POST:break;};return ret;};function sem_dmax(state,chars,phraseIndex,phraseCount,data){var string,num,ret=APG_SEM_OK;switch(state){case APG_PRE:string=charsToString(chars,phraseIndex,phraseCount);num=Number(string);data.dmax=num;break;case APG_POST:break;};return ret;};function sem_bmin(state,chars,phraseIndex,phraseCount,data){var string,num,ret=APG_SEM_OK;switch(state){case APG_PRE:string=charsToString(chars,phraseIndex,phraseCount);num=parseInt(string,2);data.dmin=num;break;case APG_POST:break;};return ret;};function sem_bmax(state,chars,phraseIndex,phraseCount,data){var string,num,ret=APG_SEM_OK;switch(state){case APG_PRE:string=charsToString(chars,phraseIndex,phraseCount);num=parseInt(string,2);data.dmax=num;break;case APG_POST:break;};return ret;};function sem_xmin(state,chars,phraseIndex,phraseCount,data){var string,num,ret=APG_SEM_OK;switch(state){case APG_PRE:string=charsToString(chars,phraseIndex,phraseCount);num=parseInt(string,16);data.dmin=num;break;case APG_POST:break;};return ret;};function sem_xmax(state,chars,phraseIndex,phraseCount,data){var string,num,ret=APG_SEM_OK;switch(state){case APG_PRE:string=charsToString(chars,phraseIndex,phraseCount);num=parseInt(string,16);data.dmax=num;break;case APG_POST:break;};return ret;};function sem_dnum(state,chars,phraseIndex,phraseCount,data){var string,num,ret=APG_SEM_OK;switch(state){case APG_PRE:string=charsToString(chars,phraseIndex,phraseCount);num=Number(string);data.dnum.push(num);break;case APG_POST:break;};return ret;};function sem_bnum(state,chars,phraseIndex,phraseCount,data){var string,num,ret=APG_SEM_OK;switch(state){case APG_PRE:string=charsToString(chars,phraseIndex,phraseCount);num=parseInt(string,2);data.dnum.push(num);break;case APG_POST:break;};return ret;};function sem_xnum(state,chars,phraseIndex,phraseCount,data){var string,num,ret=APG_SEM_OK;switch(state){case APG_PRE:string=charsToString(chars,phraseIndex,phraseCount);num=parseInt(string,16);data.dnum.push(num);break;case APG_POST:break;};return ret;};function sem_lineend(state,chars,phraseIndex,phraseCount,data){var ret=APG_SEM_OK;switch(state){case APG_PRE:data.lineNo+=1;break;case APG_POST:break;};return ret;};function ApgSemCallbacks(logMsg,ruleID){this.opcodesCount=function(from,to){var i,ret=0;for(i=from;i<to;i+=1){switch(this.tempOpcodes[i].type){case ALT:case CAT:if(this.tempOpcodes[i].childCount>1){ret+=1;};break;case REP:if(!(this.tempOpcodes[i].min===1&&this.tempOpcodes[i].max===1)){ret+=1;};break;case PRD:case RNM:case TRG:case TBS:case TLS:ret+=1;break;}};return ret;};this.tempToOpcodes=function(opcodes,temp){var i,to,index=0;for(i=0;i<this.tempOpcodes.length;i+=1){to=this.tempOpcodes[i].opNext;switch(this.tempOpcodes[i].type){case ALT:case CAT:if(this.tempOpcodes[i].childCount>1){this.opcodes[index]=[];this.opcodes[index].type=this.tempOpcodes[i].type;this.opcodes[index].opNext=index+this.opcodesCount(i,to);this.opcodes[index].childCount=this.tempOpcodes[i].childCount;index+=1;};break;case REP:if(!(this.tempOpcodes[i].min===1&&this.tempOpcodes[i].max===1)){this.opcodes[index]=[];this.opcodes[index].type=this.tempOpcodes[i].type;this.opcodes[index].opNext=index+this.opcodesCount(i,to);this.opcodes[index].min=this.tempOpcodes[i].min;this.opcodes[index].max=this.tempOpcodes[i].max;index+=1;};break;case PRD:this.opcodes[index]=[];this.opcodes[index].type=this.tempOpcodes[i].type;this.opcodes[index].opNext=index+this.opcodesCount(i,to);this.opcodes[index].and=this.tempOpcodes[i].and;index+=1;break;case RNM:this.opcodes[index]=[];this.opcodes[index].type=this.tempOpcodes[i].type;this.opcodes[index].opNext=index+1;this.opcodes[index].ruleIndex=this.tempOpcodes[i].ruleIndex;index+=1;break;case TRG:this.opcodes[index]=[];this.opcodes[index].type=this.tempOpcodes[i].type;this.opcodes[index].opNext=index+1;this.opcodes[index].min=this.tempOpcodes[i].min;this.opcodes[index].max=this.tempOpcodes[i].max;index+=1;break;case TBS:case TLS:this.opcodes[index]=[];this.opcodes[index].type=this.tempOpcodes[i].type;this.opcodes[index].opNext=index+1;this.opcodes[index].length=this.tempOpcodes[i].length;this.opcodes[index].stringIndex=this.tempOpcodes[i].stringIndex;index+=1;break;}};return index;};this.htmlStringTable=function(){var i,html='ApgCallbacks: dump stringTable:<br />';html+='stringTable['+this.stringTable.length+']<br />';for(i=0;i<this.stringTable.length;i+=1){html+='stringTable['+i+'] = '+this.stringTable[i]+';<br />';};html+='<br />';return html;};this.htmlRuleIds=function(){var i,html='ApgCallbacks: dump ruleIds:<br />';html+='ruleIds['+this.rules.length+'];<br />';for(i=0;i<this.rules.length;i+=1){html+='ruleIds['+i+'][\''+this.rules[i].lower+'\'] = ['+i+'];<br />';};html+='<br />';return html;};this.htmlRules=function(){var i,html='ApgCallbacks: dump ruleIds:<br />';html+='rules.+this.rules.length+;<br />';for(i=0;i<this.rules.length;i+=1){html+='       rules['+i+'][\'rule\'] = '+this.rules[i].rule+';<br />';html+='      rules['+i+'][\'lower\'] = '+this.rules[i].lower+';<br />';html+='rules['+i+'][\'opcodeIndex\'] = '+this.rules[i].opcodeIndex+';<br />';html+='<br />';};return html;};this.tempToRules=function(){for(var i=0;i<this.rules.length;i+=1){this.rules[i].opcodeIndex=this.opcodesCount(0,this.rules[i].opcodeIndex);}};function listCompare(lhs,rhs){if(lhs[1]<rhs[1]){return -1;};if(lhs[1]>rhs[1]){return 1;};return 0;};this.tempToRuleIds=function(){var i,list;list=[];for(i=0;i<this.rules.length;i+=1){this.ruleIds[this.rules[i].lower]=i;};for(i=0;i<this.rules.length;i+=1){list[i]=[i,this.rules[i].lower];};list.sort(listCompare);for(i=0;i<this.rules.length;i+=1){this.ruleIds[i]=list[i][0];}};this.tempToRNM=function(){var i,ruleIndex,msg;for(i=0;i<this.tempOpcodes.length;i+=1){if(this.tempOpcodes[i].type===RNM){ruleIndex=this.nameFind(this.tempOpcodes[i].ruleName);if(ruleIndex){this.tempOpcodes[i].ruleIndex=ruleIndex-1;}else{msg='';msg+='rule name "'+this.tempOpcodes[i].ruleName;msg+='" used but not defined';this.log.logLine(this.tempOpcodes[i].lineNo,false,false,msg);}}}};this.htmlOps=function(opcodes,temp){var i,html='';html+='opcodes['+opcodes.length+'];<br />';for(i=0;i<opcodes.length;i+=1){html+='opcodes['+i+'].type = '+opcodeToString(opcodes[i].type)+';<br />';html+='opcodes['+i+'].opNext = '+opcodes[i].opNext+';<br />';switch(opcodes[i].type){case ALT:case CAT:html+='opcodes['+i+'].childCount = '+opcodes[i].childCount+';<br />';break;case TRG:case REP:html+='opcodes['+i+'].min = '+opcodes[i].min+';<br />';html+='opcodes['+i+'].max = '+opcodes[i].max+';<br />';break;case PRD:html+='opcodes['+i+'].and = '+opcodes[i].and+';<br />';break;case RNM:html+='opcodes['+i+'].ruleIndex = '+opcodes[i].ruleIndex+';<br />';html+='opcodes['+i+'].(rule name) = '+this.rules[opcodes[i].ruleIndex].rule+';<br />';break;case TBS:case TLS:html+='opcodes['+i+'].length = '+opcodes[i].length+';<br />';html+='opcodes['+i+'].stringIndex = '+opcodes[i].stringIndex+';<br />';break;};if(temp){html+='opcodes['+i+'].lineNo = '+opcodes[i].lineNo+';<br />';};html+='<br />';};return html;};this.htmlTempOpcodes=function(){var html='ApgCallbacks: dump temp opcodes:<br />';html+=this.htmlOps(this.tempOpcodes,true);return html;};this.htmlOpcodes=function(){var html='ApgCallbacks: dump opcodes:<br />';return html+this.htmlOps(this.opcodes,false);};this.nameSave=function(name){var lower,index,ret=false;while(true){if(typeof(name)!=='string'){break;};if(this.nameFind(name)){break;};lower=name.toLowerCase();index=this.rules.length;this.rules[index]=[];this.rules[index].rule=name;this.rules[index].lower=lower;this.rules[index].syntax=null;this.rules[index].semantic=null;this.rules[index].opcodeIndex=this.tempOpcodes.length;ret=true;break;};return ret;};this.nameFind=function(name){var i,lower,ret=false;while(true){if(typeof(name)!=='string'){break;};lower=name.toLowerCase();for(i=0;i<this.rules.length;i+=1){if(lower===this.rules[i].lower){ret=(i+1);break;}};break;};return ret;};this.callbackList=function(ruleID,semList){for(var i=0;i<ruleID.length;i+=1){semList[i]=false;};semList[ruleID.file]=sem_file;semList[ruleID.namedef]=sem_namedef;semList[ruleID.alternation]=sem_alternation;semList[ruleID.concatenation]=sem_concatenation;semList[ruleID.repetition]=sem_repetition;semList[ruleID.rnmop]=sem_rnm;semList[ruleID.predicate]=sem_predicate;semList[ruleID.andop]=sem_and;semList[ruleID.notop]=sem_not;semList[ruleID.trgop]=sem_trg;semList[ruleID.tbsop]=sem_tbs;semList[ruleID.tlsop]=sem_tls;semList[ruleID.lineend]=sem_lineend;semList[ruleID.repeat]=sem_repeat;semList[ruleID["rep-min-max"]]=sem_rep_min_max;semList[ruleID["rep-min"]]=sem_rep_min;semList[ruleID["rep-max"]]=sem_rep_max;semList[ruleID.dnum]=sem_dnum;semList[ruleID.altop]=sem_alt;semList[ruleID.catop]=sem_cat;semList[ruleID.option]=sem_option;semList[ruleID.dmin]=sem_dmin;semList[ruleID.dmax]=sem_dmax;semList[ruleID.bmin]=sem_bmin;semList[ruleID.bmax]=sem_bmax;semList[ruleID.xmin]=sem_xmin;semList[ruleID.xmax]=sem_xmax;semList[ruleID.dnum]=sem_dnum;semList[ruleID.bnum]=sem_bnum;semList[ruleID.xnum]=sem_xnum;};this.astNodeList=function(semList,astList){for(var i=0;i<semList.length;i+=1){if(semList[i]){astList[i]=true;}else{astList[i]=false;}}};this.clear=function(){this.log.clear();this.altStack.length=0;this.catStack.length=0;this.repStack.length=0;this.prdStack.length=0;this.tempOpcodes.length=0;this.lineNo=1;this.dnum.length=0;this.dmin=0;this.dmax=0;this.prdAnd=true;this.altIndex=-1;this.catIndex=-1;this.repIndex=-1;this.prdIndex=-1;this.opcodes.length=0;this.rules.length=0;this.ruleIds.length=0;this.stringTable.length=0;};this.dottedRuleName=function(name){var i,dotted;dotted=true;for(i=0;i<name.length;i+=1){if(name[i]==="-"){dotted=false;break;}};return dotted;};this.jsGenerator=function(name){var html,i;if(typeof(name)!=='string'){name='ABNFOpcodes';};html='';html+='/********************************************************************<br />';html+='  APG - an ABNF Parser Generator<br />';html+='  Copyright (C) 2009 Coast to Coast Research, Inc.<br />';html+='<br /> ';html+='  This program is free software: you can redistribute it and/or modify<br />';html+='  it under the terms of the GNU General Public License as published by<br />';html+='  the Free Software Foundation, either version 2 of the License, or<br />';html+='  (at your option) any later version.<br />';html+='<br />  ';html+='  This program is distributed in the hope that it will be useful,<br />';html+='  but WITHOUT ANY WARRANTY; without even the implied warranty of<br />';html+='  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br />';html+='  GNU General Public License for more details.<br />';html+='<br />  ';html+='  You should have received a copy of the GNU General Public License<br />';html+='  along with this program.  If not, see<br />';html+='  &lt;http://www.gnu.org/licenses/old-licenses/gpl-2.0.html&gt;<br />';html+='  or write to the Free Software Foundation, Inc.,<br />';html+='  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.<br />';html+='<br />  ';html+='	  author: Lowell Thomas<br />';html+='	          lowell@coasttocoastresearch.com<br />';html+='	          http://www.coasttocoastresearch.com<br />';html+='<br />';html+='*********************************************************************/<br />';html+='function '+name+'()<br />';html+='{<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;// SUMMARY<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;// string table length: '+this.stringTable.length+'<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;';html+='//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rules: ';html+=+this.rules.length+'<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;';html+='//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;opcodes: ';html+=+this.opcodes.length+'<br />';html+='<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;// string table<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;this.stringTable = [];<br />';for(i=0;i<this.stringTable.length;i+=1){html+='&nbsp;&nbsp;&nbsp;&nbsp;this.stringTable['+i+'] = '+this.stringTable[i]+';<br />';};html+='<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;// rule identifiers<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;this.ruleIds = [];<br />';for(i=0;i<this.rules.length;i+=1){if(this.dottedRuleName(this.rules[i].lower)){html+='&nbsp;&nbsp;&nbsp;&nbsp;this.ruleIds.'+this.rules[i].lower+' = '+i+';<br />';}else{html+='&nbsp;&nbsp;&nbsp;&nbsp;this.ruleIds[\''+this.rules[i].lower+'\'] = '+i+';<br />';}};html+='<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;// rule identifiers (alphabetical)<br />';for(i=0;i<this.rules.length;i+=1){html+='&nbsp;&nbsp;&nbsp;&nbsp;this.ruleIds['+i+'] = '+this.ruleIds[i]+';';html+=' // '+this.rules[this.ruleIds[i]].rule+'<br />';};html+='<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;// rules<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;this.rules = [];<br />';for(i=0;i<this.rules.length;i+=1){html+='&nbsp;&nbsp;&nbsp;&nbsp;this.rules['+i+'] = [];<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;this.rules['+i+'].rule = \''+this.rules[i].rule+'\';<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;this.rules['+i+'].lower = \''+this.rules[i].lower+'\';<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;this.rules['+i+'].syntax = null;<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;this.rules['+i+'].semantic = null;<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;this.rules['+i+'].opcodeIndex = '+this.rules[i].opcodeIndex+';<br />';html+='<br />';};html+='&nbsp;&nbsp;&nbsp;&nbsp;// opcodes<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;this.opcodes = [];<br />';for(i=0;i<this.opcodes.length;i+=1){html+='&nbsp;&nbsp;&nbsp;&nbsp;this.opcodes['+i+'] = [];<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;this.opcodes['+i+'].opNext = '+this.opcodes[i].opNext+';<br />';switch(this.opcodes[i].type){case RNM:html+='&nbsp;&nbsp;&nbsp;&nbsp;this.opcodes['+i+'].type = RNM;<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;this.opcodes['+i+'].ruleIndex = '+this.opcodes[i].ruleIndex+';<br />';break;case ALT:html+='&nbsp;&nbsp;&nbsp;&nbsp;this.opcodes['+i+'].type = ALT;<br />';break;case CAT:html+='&nbsp;&nbsp;&nbsp;&nbsp;this.opcodes['+i+'].type = CAT;<br />';break;case REP:html+='&nbsp;&nbsp;&nbsp;&nbsp;this.opcodes['+i+'].type = REP;<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;this.opcodes['+i+'].min = '+this.opcodes[i].min+';<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;this.opcodes['+i+'].max = '+this.opcodes[i].max+';<br />';break;case PRD:html+='&nbsp;&nbsp;&nbsp;&nbsp;this.opcodes['+i+'].type = PRD;<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;this.opcodes['+i+'].and = '+this.opcodes[i].and+';<br />';break;case TRG:html+='&nbsp;&nbsp;&nbsp;&nbsp;this.opcodes['+i+'].type = TRG;<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;this.opcodes['+i+'].min = '+this.opcodes[i].min+';<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;this.opcodes['+i+'].max = '+this.opcodes[i].max+';<br />';break;case TBS:html+='&nbsp;&nbsp;&nbsp;&nbsp;this.opcodes['+i+'].type = TBS;<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;this.opcodes['+i+'].length = '+this.opcodes[i].length+';<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;this.opcodes['+i+'].stringIndex = '+this.opcodes[i].stringIndex+';<br />';break;case TLS:html+='&nbsp;&nbsp;&nbsp;&nbsp;this.opcodes['+i+'].type = TLS;<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;this.opcodes['+i+'].length = '+this.opcodes[i].length+';<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;this.opcodes['+i+'].stringIndex = '+this.opcodes[i].stringIndex+';<br />';break;};html+='<br />';};html+='};<br />';return html;};this.log=logMsg;this.altStack=[];this.catStack=[];this.repStack=[];this.prdStack=[];this.tempOpcodes=[];this.lineNo=1;this.dnum=[];this.dmin=0;this.dmax=0;this.prdAnd=true;this.altIndex=-1;this.catIndex=-1;this.repIndex=-1;this.prdIndex=-1;this.opcodes=[];this.rules=[];this.ruleIds=[];this.stringTable=[];this.astList=[];this.semList=[];this.clear();this.callbackList(ruleID,this.semList);this.astNodeList(this.semList,this.astList);};"use strict";function RuleAttributes(ruleids,rules,opcodes){this.highlight=function(value,which){var html='';if(value===true){if(which){html+='<span class="self-attrs-ok">'+'&radic;'+'</span>';}else{html+='<span class="self-attrs-error">'+'&radic;'+'</span>';}}else if(value===false){html+='x';}else{html+='?';};return html;};this.displayAttrs=function(attrs,ruleName){var html='';html+='<tr>';html+='</td><td class="self-attrs-left">'+ruleName;html+='<td>'+this.highlight(attrs.left,false);html+='</td><td>'+this.highlight(attrs.nested,true);html+='</td><td>'+this.highlight(attrs.right,true);html+='</td><td>'+this.highlight(attrs.empty,true);html+='</td><td>'+this.highlight(!attrs.finite,false);html+='</td><td>'+this.highlight(attrs.cyclic,false);html+='</td>';html+='</tr>';return html;};this.displayStartRuleAttrs=function(){var i,j,count,attrs,html,caption;attrs=[];html='';this.cumulativeAttrs(attrs,0);caption='';caption+='Start Rule Cumulative Attributes';html+='<p>';if(typeof(caption)!=='string'){caption='';};html+='<table class="self-attrs">';if(caption!==''){html+='<caption>'+caption+'</caption>';};html+='<tr><th class="self-attrs-left">RULE NAME</th>';html+='<th>LEFT</th><th>NESTED</th><th>RIGHT</th><th>EMPTY</th><th>INFINITE</th><th>CYCLIC</th></tr>';html+=this.displayAttrs(attrs,this.rules[0].rule);html+='</table>';html+='</p>';html+='<p>';html+='<b>Rules not referenced by start rule:</b><br />';count=0;for(i=0;i<this.ruleCount;i+=1){j=this.ruleIds[i];if(j!==0&&!this.selfAttrs[0].decendents[j]){html+=this.rules[j].rule+'<br />';count+=1;}};if(count===0){html+='&lt;none&gt;';};html+='</p>';return html;};this.displaySelfAttrs=function(){var i,j,html,displayed,caption;html='';displayed=[];caption='Self-Recursive Attributes';if(typeof(caption)!=='string'){caption='';};html+='<table class="self-attrs">';if(caption!==''){html+='<caption>'+caption+'</caption>';};html+='<tr><th class="self-attrs-left">RULE NAME</th>';html+='<th>LEFT</th><th>NESTED</th><th>RIGHT</th><th>EMPTY</th><th>INFINITE</th><th>CYCLIC</th></tr>';for(i=0;i<this.ruleCount;i+=1){j=this.ruleIds[i];if(this.selfAttrs[j].cyclic){html+=this.displayAttrs(this.selfAttrs[j],this.rules[j].rule);displayed[j]=true;}else{displayed[j]=false;}};for(i=0;i<this.ruleCount;i+=1){j=this.ruleIds[i];if(!this.selfAttrs[j].finite&&!displayed[j]){html+=this.displayAttrs(this.selfAttrs[j],this.rules[j].rule);displayed[j]=true;}};for(i=0;i<this.ruleCount;i+=1){j=this.ruleIds[i];if(this.selfAttrs[j].left&&!displayed[j]){html+=this.displayAttrs(this.selfAttrs[j],this.rules[j].rule);displayed[j]=true;}};for(i=0;i<this.ruleCount;i+=1){j=this.ruleIds[i];if(!displayed[j]){html+=this.displayAttrs(this.selfAttrs[j],this.rules[j].rule);}};html+='</table>';return html;};this.displayErrors=function(caption){if(typeof(caption)!=='string'){caption='';};var i,html='';html+='<table>';if(caption!==''){html+='<caption>'+caption+'</caption>';};html+='<tr><th>left</th><th>nested</th><th>right</th><th>empty</th><th>infinite</th><th>cyclic</th><th>rule name</th></tr>';for(i=0;i<this.ruleCount;i+=1){if((this.selfAttrs[i].left===true)||(this.selfAttrs[i].finite===false)||(this.selfAttrs[i].cyclic===true)){html+='<tr><td>'+this.highlight(this.selfAttrs[i].left,true);html+='</td><td>'+this.highlight(this.selfAttrs[i].nested,true);html+='</td><td>'+this.highlight(this.selfAttrs[i].right,true);html+='</td><td>'+this.highlight(this.selfAttrs[i].empty,true);html+='</td><td>'+this.highlight(!this.selfAttrs[i].finite,true);html+='</td><td>'+this.highlight(this.selfAttrs[i].cyclic,true);html+='</td><td>'+this.rules[i].rule;html+='</td></tr>';}};html+='</table>';return html;};this.cumulativeAttrs=function(attrs,startRule){var i,ret=false;while(true){if(!isArray(attrs)){break;};if(typeof(startRule)!=='number'){break;};if(startRule>=this.ruleCount){break;};attrs.length=0;attrs.left=false;attrs.nested=false;attrs.right=false;attrs.empty=false;attrs.finite=true;attrs.cyclic=false;for(i=0;i<this.ruleCount;i+=1){if(i===startRule){if(this.selfAttrs[i].left){attrs.left=true;};if(this.selfAttrs[i].nested){attrs.nested=true;};if(this.selfAttrs[i].right){attrs.right=true;};if(!this.selfAttrs[i].finite){attrs.finite=false;};if(this.selfAttrs[i].cyclic){attrs.cyclic=true;};if(this.selfAttrs[i].empty){attrs.empty=true;}}else if(this.selfAttrs[startRule].decendents[i]){if(this.selfAttrs[i].left){attrs.left=true;};if(!this.selfAttrs[i].finite){attrs.finite=false;};if(this.selfAttrs[i].cyclic){attrs.cyclic=true;}}};ret=true;break;};return ret;};this.catIsEmpty=function(childAttrs,count){var ret=true;for(child=0;child<count;child+=1){if(!childAttrs[child].empty){ret=false;break;}};return ret;};this.catIsCyclic=function(childAttrs,count){var ret=true;for(child=0;child<count;child+=1){if(!childAttrs[child].cyclic){ret=false;break;}};return ret;};this.catIsFinite=function(childAttrs,count){var ret=true;for(child=0;child<count;child+=1){if(!childAttrs[child].finite){ret=false;break;}};return ret;};this.catIsLeft=function(childAttrs,count){var ret=false;for(child=0;child<count;child+=1){if(childAttrs[child].left){ret=true;break;}else if(!childAttrs[child].empty){ret=false;break;}};return ret;};this.catIsRight=function(childAttrs,count){var ret=false;for(child=count-1;child>=0;child-=1){if(childAttrs[child].right){ret=true;break;}else if(!childAttrs[child].empty){ret=false;break;}};return ret;};this.catIsNested=function(childAttrs,count){var ret=false;var leftMost,rightMost;while(true){for(child=0;child<count;child+=1){if(childAttrs[child].nested){ret=true;break;}};if(ret===true){break;};leftMost=-1;for(child=0;child<count;child+=1){if(!childAttrs[child].left&&!childAttrs[child].right){leftMost=child;break;}};if(leftMost===-1){break;};rightMost=-1;for(child=count-1;child>=0;child-=1){if(!childAttrs[child].left&&!childAttrs[child].right){rightMost=child;break;}};if(rightMost===-1){break;};if(rightMost-leftMost<2){break;};for(child=leftMost+1;child<rightMost;child+=1){if(childAttrs[child].left||childAttrs[child].right){ret=true;break;}};break;};return ret;};this.computeOpAttrs=function(opIndex,attrs){var child,x,childCount,childIndex,childAttrs,mostIsEmpty,leftIndex,rightIndex,ruleIndex;childAttrs=[];if(this.trace){this.traceHtml+='&darr;';for(x=0;x<this.traceIndent;x+=1){this.traceHtml+='-';};this.traceHtml+=opcodeToString(this.opcodes[opIndex].type);if(this.opcodes[opIndex].type===RNM){this.traceHtml+='('+this.rules[this.opcodes[opIndex].ruleIndex].rule+')';};this.traceHtml+='<br />';this.traceIndent+=1;};switch(this.opcodes[opIndex].type){case ALT:childIndex=opIndex+1;childCount=this.opcodes[opIndex].childCount;for(child=0;child<childCount;child+=1){childAttrs[child]=[];this.computeOpAttrs(childIndex,childAttrs[child]);childIndex=this.opcodes[childIndex].opNext;};attrs.left=false;attrs.right=false;attrs.nested=false;attrs.empty=false;attrs.finite=false;attrs.cyclic=false;for(child=0;child<childCount;child+=1){attrs.left=childAttrs[child].left?true:attrs.left;attrs.nested=childAttrs[child].nested?true:attrs.nested;attrs.right=childAttrs[child].right?true:attrs.right;attrs.empty=childAttrs[child].empty?true:attrs.empty;attrs.finite=childAttrs[child].finite?true:attrs.finite;attrs.cyclic=childAttrs[child].cyclic?true:attrs.cyclic;};break;case CAT:childIndex=opIndex+1;childCount=this.opcodes[opIndex].childCount;for(child=0;child<childCount;child+=1){childAttrs[child]=[];this.computeOpAttrs(childIndex,childAttrs[child]);childIndex=this.opcodes[childIndex].opNext;};attrs.left=this.catIsLeft(childAttrs,childCount);attrs.right=this.catIsRight(childAttrs,childCount);attrs.nested=this.catIsNested(childAttrs,childCount);attrs.empty=this.catIsEmpty(childAttrs,childCount);attrs.finite=this.catIsFinite(childAttrs,childCount);attrs.cyclic=this.catIsCyclic(childAttrs,childCount);break;case REP:childIndex=opIndex+1;this.computeOpAttrs(childIndex,attrs);attrs.empty=(this.opcodes[opIndex].min===0)?true:attrs.empty;attrs.finite=(this.opcodes[opIndex].min===0)?true:attrs.finite;break;case PRD:attrs.left=false;attrs.nested=false;attrs.right=false;attrs.empty=true;attrs.finite=true;attrs.cyclic=false;break;case RNM:ruleIndex=this.opcodes[opIndex].ruleIndex;this.computeRuleAttrs(ruleIndex,attrs);break;case TLS:case TRG:case TBS:attrs.left=false;attrs.nested=false;attrs.right=false;attrs.empty=false;attrs.finite=true;attrs.cyclic=false;if(this.opcodes[opIndex].type===TLS&&this.opcodes[opIndex].length===0){attrs.empty=true;};break;};if(this.trace){this.traceIndent-=1;this.traceHtml+='&uarr;';for(x=0;x<this.traceIndent;x+=1){this.traceHtml+='-';};this.traceHtml+=opcodeToString(this.opcodes[opIndex].type);if(this.opcodes[opIndex].type===RNM){this.traceHtml+='('+this.rules[this.opcodes[opIndex].ruleIndex].rule+')';};this.traceHtml+='('+attrs.left+','+attrs.nested+','+attrs.right+','+attrs.empty+','+attrs.finite+','+attrs.cyclic+')';this.traceHtml+='<br />';}};this.computeRuleAttrs=function(ruleIndex,attrs){var i,j,save,decendents;while(true){if(this.ruleAttrs[ruleIndex].known){attrs.known=true;attrs.open=false;attrs.left=this.ruleAttrs[ruleIndex].left;attrs.right=this.ruleAttrs[ruleIndex].right;attrs.nested=this.ruleAttrs[ruleIndex].nested;attrs.empty=this.ruleAttrs[ruleIndex].empty;attrs.finite=this.ruleAttrs[ruleIndex].finite;attrs.cyclic=this.ruleAttrs[ruleIndex].cyclic;attrs.decendents=[];decendents=this.ruleAttrs[ruleIndex].decendents;for(i=0;i<this.ruleCount;i+=1){attrs.decendents[i]=decendents[i];};break;};if(this.ruleAttrs[ruleIndex].open){if(ruleIndex===this.startRule){attrs.left=true;attrs.nested=false;attrs.right=true;attrs.empty=false;attrs.finite=false;attrs.cyclic=true;}else{attrs.left=false;attrs.nested=false;attrs.right=false;attrs.empty=false;attrs.finite=false;attrs.cyclic=false;};break;};this.ruleAttrs[ruleIndex].open=true;for(i=0;i<this.ruleCount;i+=1){this.ruleAttrs[ruleIndex].decendents[i]=false;};this.computeOpAttrs(this.rules[ruleIndex].opcodeIndex,attrs);this.ruleAttrs[ruleIndex].open=false;decendents=this.ruleAttrs[ruleIndex].decendents;if(this.trace){this.traceHtml+="trace: rule: "+this.rules[ruleIndex].rule+'<br />';this.traceHtml+='  ancestors: ';for(i=0;i<this.ruleCount;i+=1){if(this.ruleAttrs[i].open){this.traceHtml+=this.rules[i].rule+': ';}};this.traceHtml+='<br />';this.traceHtml+='  decendents: ';for(j=0;j<this.ruleCount;j+=1){if(decendents[j]){this.traceHtml+=this.rules[j].rule+': ';}};this.traceHtml+='<br />';};save=true;if(save){this.ruleAttrs[ruleIndex].known=true;this.ruleAttrs[ruleIndex].left=attrs.left;this.ruleAttrs[ruleIndex].nested=attrs.nested;this.ruleAttrs[ruleIndex].right=attrs.right;this.ruleAttrs[ruleIndex].empty=attrs.empty;this.ruleAttrs[ruleIndex].finite=attrs.finite;this.ruleAttrs[ruleIndex].cyclic=attrs.cyclic;if(this.trace){this.traceHtml+="trace: rule: "+this.rules[ruleIndex].rule+' saved attributes: <br />';this.traceHtml+="("+this.ruleAttrs[ruleIndex].left;this.traceHtml+=","+this.ruleAttrs[ruleIndex].nested;this.traceHtml+=","+this.ruleAttrs[ruleIndex].right;this.traceHtml+=","+this.ruleAttrs[ruleIndex].empty;this.traceHtml+=","+this.ruleAttrs[ruleIndex].finite;this.traceHtml+=","+this.ruleAttrs[ruleIndex].cyclic;this.traceHtml+=')<br />';}};break;}};this.ruleAttrs=[];this.selfAttrs=[];this.ruleIds=ruleids;this.rules=rules;this.opcodes=opcodes;this.ruleCount=rules.length;this.traceHtml='';this.traceIndent=0;this.trace=false;this.startRule=0;this.errors=0;var i,j;for(i=0;i<this.ruleCount;i+=1){this.selfAttrs[i]=[];this.selfAttrs[i].known=false;this.selfAttrs[i].left=false;this.selfAttrs[i].nested=false;this.selfAttrs[i].right=false;this.selfAttrs[i].empty=false;this.selfAttrs[i].finite=false;this.selfAttrs[i].cyclic=false;this.selfAttrs[i].decendents=[];for(j=0;j<this.ruleCount;j+=1){this.selfAttrs[i].decendents[j]=false;}};for(i=0;i<this.ruleCount;i+=1){for(j=0;j<this.ruleCount;j+=1){this.ruleAttrs[j]=[];this.ruleAttrs[j].known=false;this.ruleAttrs[j].open=false;this.ruleAttrs[j].decendents=[];this.ruleAttrs[j].attrs=[];};this.startRule=i;this.computeRuleAttrs(i,this.selfAttrs[i]);if(this.selfAttrs[i].left===true){this.errors+=1;};if(this.selfAttrs[i].finite===false){this.errors+=1;};if(this.selfAttrs[i].cyclic===true){this.errors+=1;};for(j=0;j<this.ruleCount;j+=1){if(this.ruleAttrs[j].known){if(j===this.startRule){if(this.selfAttrs[this.startRule].left||this.selfAttrs[this.startRule].nested||this.selfAttrs[this.startRule].right){this.selfAttrs[this.startRule].decendents[j]=true;}}else{this.selfAttrs[this.startRule].decendents[j]=true;}}}}};"use strict";var DEFAULT_TRACE_ON=true;var DEFAULT_TRACE_DISPLAY='auto';var DEFAULT_MAX_SAVED=100000;var DEFAULT_MAX_DISPLAYED=1000;var DEFAULT_LINE_RANGE='lastN';function Trace(){this.setDefaultFilter=function(filter,count){filter.trace=DEFAULT_TRACE_ON;filter.display=DEFAULT_TRACE_DISPLAY;filter['max-saved']=DEFAULT_MAX_SAVED;filter['max-displayed']=DEFAULT_MAX_DISPLAYED;filter['line-range']=DEFAULT_LINE_RANGE;filter['first-record']=0;filter['line-count']=count;filter['last-record']=0;filter.match=true;filter.nomatch=true;filter.empty=true;filter.ops=[];filter.ops[ALT]=false;filter.ops[CAT]=false;filter.ops[REP]=false;filter.ops[PRD]=false;filter.ops[TRG]=false;filter.ops[TBS]=false;filter.ops[TLS]=false;filter.rules=[];filter['rule-map']=[];filter['rule-names']=[];for(var i=0;i<this.rules.length;i+=1){filter.rules[i]=true;filter['rule-names'][i]=this.rules[i].rule;filter['rule-map'][this.rules[i].rule]=i;}};this.setDefaultParseFilter=function(){this.setDefaultFilter(this.parseFilter,DEFAULT_MAX_SAVED);};this.setDefaultDisplayFilter=function(){this.setDefaultFilter(this.displayFilter,DEFAULT_MAX_DISPLAYED);};this.reconcileRules=function(rules,filter){var tempRules=[];var tempRuleMap=[];var tempRuleNames=[];var i,j,ruleName;for(i=0;i<this.rules.length;i+=1){ruleName=this.rules[i].rule;j=filter['rule-map'][ruleName];if(j===undefined){tempRules[i]=true;}else{tempRules[i]=filter.rules[j];};tempRuleMap[ruleName]=i;tempRuleNames[i]=ruleName;};filter.rules=tempRules;filter['rule-map']=tempRuleMap;filter['rule-names']=tempRuleNames;};this.maskDisplayFilter=function(){this.displayFilter.ops[ALT]=this.parseFilter.ops[ALT]?this.parseFilter.ops[ALT]:undefined;this.displayFilter.ops[CAT]=this.parseFilter.ops[CAT]?this.parseFilter.ops[CAT]:undefined;this.displayFilter.ops[REP]=this.parseFilter.ops[REP]?this.parseFilter.ops[REP]:undefined;this.displayFilter.ops[PRD]=this.parseFilter.ops[PRD]?this.parseFilter.ops[PRD]:undefined;this.displayFilter.ops[TRG]=this.parseFilter.ops[TRG]?this.parseFilter.ops[TRG]:undefined;this.displayFilter.ops[TBS]=this.parseFilter.ops[TBS]?this.parseFilter.ops[TBS]:undefined;this.displayFilter.ops[TLS]=this.parseFilter.ops[TLS]?this.parseFilter.ops[TLS]:undefined;for(var i=0;i<this.rules.length;i+=1){this.displayFilter.rules[i]=this.parseFilter.rules[i]?this.parseFilter.rules[i]:undefined;}};this.setFilter=function(filter,option,value,ruleIndex){switch(option){case 'trace':filter.trace=value;break;case 'max-saved':filter['max-saved']=value;break;case 'display':filter.display=value;break;case 'max-displayed':filter['max-displayed']=value;break;case 'line-range':filter['line-range']=value;break;case 'first-record':filter['first-record']=value;break;case 'line-count':filter['line-count']=value;break;case 'last-record':filter['last-record']=value;break;case 'match':filter.match=value;break;case 'nomatch':filter.nomatch=value;break;case 'empty':filter.empty=value;break;case 'alt':filter.ops[ALT]=value;break;case 'cat':filter.ops[CAT]=value;break;case 'rep':filter.ops[REP]=value;break;case 'prd':filter.ops[PRD]=value;break;case 'trg':filter.ops[TRG]=value;break;case 'tbs':filter.ops[TBS]=value;break;case 'tls':filter.ops[TLS]=value;break;case 'rule':filter.rules[ruleIndex]=value;break;}};this.resetParseFilter=function(){var temp=[];this.setDefaultFilter(temp,DEFAULT_MAX_SAVED);temp.rules=[];temp['rule-map']=[];temp['rule-names']=[];if(this.rules&&this.parseFilter.rules){for(var i=0;i<this.rules.length;i+=1){var ruleName=this.rules[i].rule;temp.rules[i]=true;temp['rule-map'][ruleName]=i;temp['rule-names'][i]=ruleName;}};this.parseFilter=temp;};this.resetDisplayFilter=function(){var temp=[];this.setDefaultFilter(temp,DEFAULT_MAX_DISPLAYED);temp.ops[ALT]=this.displayFilter.ops[ALT]===undefined?undefined:this.displayFilter.ops[ALT];temp.ops[CAT]=this.displayFilter.ops[CAT]===undefined?undefined:this.displayFilter.ops[CAT];temp.ops[REP]=this.displayFilter.ops[REP]===undefined?undefined:this.displayFilter.ops[REP];temp.ops[PRD]=this.displayFilter.ops[PRD]===undefined?undefined:this.displayFilter.ops[PRD];temp.ops[TRG]=this.displayFilter.ops[TRG]===undefined?undefined:this.displayFilter.ops[TRG];temp.ops[TBS]=this.displayFilter.ops[TBS]===undefined?undefined:this.displayFilter.ops[TBS];temp.ops[TLS]=this.displayFilter.ops[TLS]===undefined?undefined:this.displayFilter.ops[TLS];temp.rules=[];temp['rule-map']=[];temp['rule-names']=[];if(this.rules&&this.parseFilter.rules){for(var i=0;i<this.rules.length;i+=1){var ruleName=this.rules[i].rule;temp.rules[i]=this.displayFilter.rules[i]===undefined?undefined:true;temp['rule-map'][ruleName]=i;temp['rule-names'][i]=ruleName;}};this.displayFilter=temp;};this.dumpFilter=function(filter){var html='';html+='<br />';html+='Trace.dumpFilter:';html+='<br />display: '+filter.display;html+='<br />max-saved: '+filter['max-saved'];html+='<br />max-displayed: '+filter['max-displayed'];html+='<br />line-range: '+filter['line-range'];html+='<br />first-record: '+filter['first-record'];html+='<br />line-count: '+filter['line-count'];html+='<br />last-record: '+filter['last-record'];html+='<br />match: '+filter.match;html+='<br />nomatch: '+filter.nomatch;html+='<br />empty: '+filter.empty;html+='<br />alt: '+filter.ops[ALT];html+='<br />cat: '+filter.ops[CAT];html+='<br />rep: '+filter.ops[REP];html+='<br />prd: '+filter.ops[PRD];html+='<br />trg: '+filter.ops[TRG];html+='<br />tbs: '+filter.ops[TBS];html+='<br />tls: '+filter.ops[TLS];for(var i=0;i<filter.rules.length;i+=1){html+='<br />rule['+i+']: '+filter['rule-names'][i]+': '+filter.rules[i];};return html;};this.traceDown=function(op,state,offset,length){var circularSaved;if(this.parseFilter.trace){if(this.parseOpFilter(op)){this.depthStack[this.depth]=[];this.depthStack[this.depth].filteredLine=this.opFilteredLines;this.depthStack[this.depth].savedLine=undefined;this.depthStack[this.depth].savedSequenceNumber=undefined;if(this.firstOpFiltered===-1){this.firstOpFiltered=this.unfilteredLines;};if(this.parseLineFilter(this.unfilteredLines,this.savedLines,this.parseFilter)){if(this.firstSaved===-1){this.firstSaved=this.unfilteredLines;};circularSaved=this.parseCircular.collect();this.depthStack[this.depth].savedLine=circularSaved;this.depthStack[this.depth].savedSequenceNumber=this.unfilteredLines;this.lines[circularSaved]=[];this.lines[circularSaved].dir='down';this.lines[circularSaved].depth=this.depth;this.lines[circularSaved].sequenceNumber=this.unfilteredLines;this.lines[circularSaved].otherSequenceNumber=undefined;this.lines[circularSaved].thisSavedLine=circularSaved;this.lines[circularSaved].otherSavedLine=undefined;this.lines[circularSaved].opType=op.type;this.lines[circularSaved].state=state;this.lines[circularSaved].offset=offset;this.lines[circularSaved].length=length;if(op.type===RNM){this.lines[circularSaved].ruleIndex=op.ruleIndex;};this.savedLines+=1;this.lastSaved=this.unfilteredLines;};this.opFilteredLines+=1;this.depth+=1;this.lastOpFiltered=this.unfilteredLines;};this.unfilteredLines+=1;}};this.traceUp=function(op,state,offset,length){var circularSaved;if(this.parseFilter.trace){if(this.parseOpFilter(op)){this.depth-=1;var otherFilteredLine=this.depthStack[this.depth].filteredLine;var otherSavedLine=this.depthStack[this.depth].savedLine;var otherSequenceNumber=this.depthStack[this.depth].savedSequenceNumber;if(this.firstOpFiltered===-1){this.firstOpFiltered=this.unfilteredLines;};if(this.parseLineFilter(this.unfilteredLines,this.savedLines,this.parseFilter)){if(this.firstSaved===-1){this.firstSaved=this.unfilteredLines;};circularSaved=this.parseCircular.collect();if(otherSavedLine!==undefined){this.lines[otherSavedLine].otherSavedLine=circularSaved;this.lines[otherSavedLine].length=length;this.lines[otherSavedLine].otherSequenceNumber=this.unfilteredLines;};this.lines[circularSaved]=[];this.lines[circularSaved].dir='up';this.lines[circularSaved].depth=this.depth;this.lines[circularSaved].sequenceNumber=this.unfilteredLines;this.lines[circularSaved].otherSequenceNumber=otherSequenceNumber;this.lines[circularSaved].thisSavedLine=circularSaved;this.lines[circularSaved].otherSavedLine=otherSavedLine;this.lines[circularSaved].opType=op.type;this.lines[circularSaved].state=state;this.lines[circularSaved].offset=offset;this.lines[circularSaved].length=length;if(op.type===RNM){this.lines[circularSaved].ruleIndex=op.ruleIndex;};this.savedLines+=1;this.lastSaved=this.unfilteredLines;};this.opFilteredLines+=1;this.lastOpFiltered=this.unfilteredLines;};this.unfilteredLines+=1;}};this.parseOpFilter=function(op){var opMatch=false;if(op.type===RNM&&this.parseFilter.rules[op.ruleIndex]){opMatch=true;}else if(this.parseFilter.ops[op.type]){opMatch=true;};return opMatch;};this.parseLineFilter=function(thisRecord,thisLine,filter){var ret=false;var maxLines;if((thisRecord>=filter['first-record'])){switch(filter['line-range']){case 'firstN':if((thisLine<this.linesMax)){ret=true;};break;case 'record-range':if((thisRecord<=filter['last-record']&&thisLine<filter['max-saved'])){ret=true;};break;case 'lastN':ret=true;break;default:throw['Trace: parseLineFilter: unrecognized filter[\'line-range\']: '+filter['line-range']];break;}};return ret;};this.display=function(){if(this.parseFilter['line-range']=='lastN'&&!this.parseCircularReversed){this.parseReverse();this.parseCircularReversed=true;};this.filterSavedLines();return this.displayFiltered();};this.parseReverse=function(){this.parseCircular.initReverse();this.depthStack.length=0;var i,max,j,depth,line,otherLine;max=this.parseCircular.items();depth=0;for(i=0;i<max;i+=1){j=this.parseCircular.reverse();line=this.lines[j];if(line.dir=='up'){this.depthStack[depth]=[];this.depthStack[depth].depthLine=j;line.otherSequenceNumber=undefined;depth+=1;}else{depth-=1;otherLine=this.depthStack[depth].depthLine;line.otherSequenceNumber=this.lines[otherLine].sequenceNumber;this.lines[otherLine].otherSequenceNumber=line.sequenceNumber;}}};this.filterSavedLines=function(){var i,j;var line,otherLine;this.initDisplay();var max=this.parseCircular.items();this.parseCircular.initReplay();for(i=0;i<max;i+=1){j=this.parseCircular.replay();line=this.lines[j];line.thisFilteredLine=undefined;if(this.displayFilterOp(line)&&this.displayFilterState(line)){if(this.firstOpDisplayed===-1){this.firstOpDisplayed=line.sequenceNumber;};if(this.displayLineFilter(this.displayedLines,line,this.displayFilter)){if(this.firstDisplayed===-1){this.firstDisplayed=line.sequenceNumber;};this.dLines[this.displayCircular.collect()]=j;line.thisFilteredLine=this.displayedLines;if(line.dir==='down'){line.otherFilteredLine=undefined;}else{if(line.otherSavedLine!==undefined){otherLine=this.lines[line.otherSavedLine];otherLine.otherFilteredLine=this.displayedLines;line.otherFilteredLine=otherLine.thisFilteredLine;}};this.displayedLines+=1;this.lastDisplayed=line.sequenceNumber;};this.opDisplayedLines+=1;this.lastOpDisplayed=line.sequenceNumber;}}};this.displayFiltered=function(){var modeDisplay;if(this.displayFilter.display==='ascii'){modeDisplay=this.displayAscii;}else if(this.displayFilter.display==='hex'){modeDisplay=this.displayHex;}else{if(charsAreAscii(this.chars)){modeDisplay=this.displayAscii;}else{modeDisplay=this.displayHex;}};var parseStats='';parseStats+='<table class="log-table">';parseStats+='<caption>PARSER FILTER</caption>';parseStats+='<tr><td>max saved records:&nbsp;</td><td class="log-msg">'+this.parseFilter['max-saved']+'</td></tr>';parseStats+='<tr><td>unfiltered records:&nbsp;</td><td class="log-msg">'+this.unfilteredLines+'</td></tr>';parseStats+='<tr><td>operator filtered records:&nbsp;</td><td class="log-msg">'+this.opFilteredLines+'</td></tr>';parseStats+='<tr><td>first:&nbsp;</td><td class="log-msg">'+this.firstOpFiltered+'</td></tr>';parseStats+='<tr><td>last:&nbsp;</td><td class="log-msg">'+this.lastOpFiltered+'</td></tr>';parseStats+='<tr><td>line-range filtered records:&nbsp;</td><td class="log-msg">'+this.parseCircular.items()+'</td></tr>';parseStats+='<tr><td>first:&nbsp;</td><td class="log-msg">'+this.firstSaved+'</td></tr>';parseStats+='<tr><td>last:&nbsp;</td><td class="log-msg">'+this.lastSaved+'</td></tr>';parseStats+='</table>';var html='';var line,thisLine,otherLine;var i,j;var displayedLine=0;html+='<tr><th>(a)</th><th>(b)</th><th>(c)</th><th>(d)</th><th>(e)</th><th>(f)</th><th>(g)</th>';html+='<th class="log-msg">operator</th><th class="log-msg">phrase</th></tr>';this.displayCircular.initReplay();var max=this.displayCircular.items();for(i=0;i<max;i+=1){j=this.dLines[this.displayCircular.replay()];line=this.lines[j];if(line.thisFilteredLine!==undefined){thisLine=line.sequenceNumber;otherLine=(line.otherSequenceNumber!==undefined)?line.otherSequenceNumber:'--';if(displayedLine%2===0){html+='<tr class="even">';}else{html+='<tr class="odd">';};html+='<td>'+displayedLine+'</td>';html+='<td>'+thisLine+'</td><td>'+otherLine+'</td>';html+='<td>'+line.offset+'</td><td>'+line.length+'</td>';html+='<td>'+line.depth+'</td>';html+='<td>';switch(line.state){case APG_ACTIVE:html+='&darr;&nbsp;';break;case APG_MATCH:html+='<span class="match">&uarr;M</span>';break;case APG_NOMATCH:html+='<span class="nomatch-arrow">&uarr;N</span>';break;case APG_EMPTY:html+='<span class="empty">&uarr;E</span>';break;};html+='</td>';html+='<td class="log-msg">';html+=this.indent(line.depth)+opcodeToString(line.opType);if(line.opType===RNM){html+='('+this.rules[line.ruleIndex].rule+') ';};html+='</td>';html+='<td class="log-msg">';html+=modeDisplay(this.chars,line.offset,line.length,line.state);html+='</td></tr>';displayedLine+=1;}};html+='<tr><th>(a)</th><th>(b)</th><th>(c)</th><th>(d)</th><th>(e)</th><th>(f)</th><th>(g)</th>';html+='<th class="log-msg">operator</th><th class="log-msg">phrase</th></tr>';html='<table class="log-table">'+html+'</table>';html+='<p>';html+='(a)&nbsp;-&nbsp;filtered record number (sequential on displayed records)<br />';html+='(b)&nbsp;-&nbsp;unfiltered record number<br />';html+='(c)&nbsp;-&nbsp;matching unfiltered record number ("--" if matching record not displayed)<br />';html+='(d)&nbsp;-&nbsp;beginning phrase character number<br />';html+='(e)&nbsp;-&nbsp;phrase length<br />';html+='(f)&nbsp;-&nbsp;relative tree depth<br />';html+='(g)&nbsp;-&nbsp;operator state<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&darr;open<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&uarr;final<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;M phrase matched<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;N phrase not matched<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;E phrase matched, empty<br />';html+='operator&nbsp;-&nbsp;ALT, CAT, REP, PRD, TRG, TLS, TBS or RNM(rule name)<br />';html+='phrase&nbsp;&nbsp;&nbsp;-&nbsp;up to 48 characters of the phrase being matched<br />';html+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&para; = End of String<br />';html+='</p>';var displayStats='';displayStats+='<table class="log-table">';displayStats+='<caption>DISPLAY FILTER</caption>';displayStats+='<tr><td>max displayed records:&nbsp;</td><td class="log-msg">'+this.displayFilter['max-displayed']+'</td></tr>';displayStats+='<tr><td>saved records:&nbsp;</td><td class="log-msg">'+this.savedLines+'</td></tr>';displayStats+='<tr><td>operator filtered records:&nbsp;</td><td class="log-msg">'+this.opDisplayedLines+'</td></tr>';displayStats+='<tr><td>first:&nbsp;</td><td class="log-msg">'+this.firstOpDisplayed+'</td></tr>';displayStats+='<tr><td>last:&nbsp;</td><td class="log-msg">'+this.lastOpDisplayed+'</td></tr>';displayStats+='<tr><td>line-range filtered records:&nbsp;</td><td class="log-msg">'+this.displayedLines+'</td></tr>';displayStats+='<tr><td>first:&nbsp;</td><td class="log-msg">'+this.firstDisplayed+'</td></tr>';displayStats+='<tr><td>last:&nbsp;</td><td class="log-msg">'+this.lastDisplayed+'</td></tr>';displayStats+='</table>';var tableHtml='';tableHtml+='<table class="log-table">';tableHtml+='<tr><td>'+parseStats+'</td><td>&nbsp;</td><td>'+displayStats+'</td></tr>';tableHtml+='</table><br />';return tableHtml+html;};this.displayFilterOp=function(line){var opMatch=false;if(line.opType===RNM&&this.displayFilter.rules[line.ruleIndex]){opMatch=true;}else if(this.displayFilter.ops[line.opType]){opMatch=true;};return opMatch;};this.displayFilterState=function(line){var display=false;switch(line.state){case APG_ACTIVE:var otherLine=line.otherSavedLine;if(otherLine===undefined){display=true;}else if(this.lines[otherLine]){switch(this.lines[otherLine].state){case APG_MATCH:if(this.displayFilter.match){display=true;};break;case APG_NOMATCH:if(this.displayFilter.nomatch){display=true;};break;case APG_EMPTY:if(this.displayFilter.empty){display=true;};break;case APG_ACTIVE:throw['Trace: filterStateDisplay: ACTIVE state not allowed here'];}};break;case APG_MATCH:if(this.displayFilter.match){display=true;};break;case APG_NOMATCH:if(this.displayFilter.nomatch){display=true;};break;case APG_EMPTY:if(this.displayFilter.empty){display=true;};break;};return display;};this.displayLineFilter=function(thisLine,line,filter){var ret=false;var thisRecord=line.sequenceNumber;if((thisRecord>=filter['first-record'])){switch(filter['line-range']){case 'firstN':if((thisLine<this.displayMax)){ret=true;};break;case 'record-range':if((thisRecord<=filter['last-record']&&thisLine<filter['max-displayed'])){ret=true;};break;case 'lastN':ret=true;break;default:throw['Trace: displayLineFilter: unrecognized filter[\'line-range\']: '+filter['line-range']];break;}};return ret;};this.indent=function(depth){var html='';for(var i=0;i<depth;i+=1){if(i%2===0){html+='&nbsp;';}else{html+='&#46;';}};return html;};this.displayAscii=function(chars,offset,len,state){var matchLen=48;if(offset<0){offset=0;};var end=offset+matchLen;var lastChar='';if(end>chars.length){end=chars.length;lastChar='<span class="eos">&para;</span>';};var htmlAscii;var count=0;if(state===APG_MATCH){htmlAscii='<span class="match">';}else{htmlAscii='<span class="nomatch">';};for(var i=offset;i<end;i+=1,count+=1){if(chars[i]===10){htmlAscii+='<span class="control-char">LF</span>';}else if(chars[i]===13){htmlAscii+='<span class="control-char">CR</span>';}else if(chars[i]===9){htmlAscii+='<span class="control-char">TAB</span>';}else if(chars[i]===60){htmlAscii+='&lt;';}else if(chars[i]===38){htmlAscii+='&amp;';}else if(chars[i]<32||chars[i]>126){htmlAscii+='<span class="non-ascii">x'+chars[i].toString(16)+'</span>';}else{htmlAscii+=String.fromCharCode(chars[i]);};if(state===APG_MATCH&&(count+1)>=len){htmlAscii+='</span><span class="nomatch">';}};htmlAscii+=lastChar;htmlAscii+='</span>';return htmlAscii;};this.displayHex=function(chars,offset,len,state){var matchLen=16;if(offset<0){offset=0;};var end=offset+matchLen;var htmlHex;var htmlAscii;var count=0;var mid=matchLen/2;var quarter=matchLen/4;if(state===APG_MATCH){htmlHex='<span class="match">';htmlAscii='<span class="match">';}else{htmlHex='<span class="nomatch">';htmlAscii='<span class="nomatch">';};for(var i=offset;i<end;i+=1,count+=1){if(count>0){if(count%quarter===0){htmlHex+='&nbsp;';};if(count%mid===0){htmlHex+='&nbsp;';}};if(i>=chars.length){htmlHex+='..';}else{var hexChar=chars[i].toString(16).toUpperCase();if(hexChar.length===1){htmlHex+='0'+hexChar;}else{htmlHex+=hexChar;};if(chars[i]<32||chars[i]>126){htmlAscii+='.';}else{htmlAscii+=String.fromCharCode(chars[i]);}};if(state===APG_MATCH&&(count+1)>=len){htmlHex+='</span><span class="nomatch">';htmlAscii+='</span><span class="nomatch">';}};htmlHex+='</span>';htmlAscii+='</span>';return htmlHex+'&nbsp;&nbsp;'+htmlAscii;};this.initRules=function(rules){this.rules=rules;this.ruleCount=this.rules.length;this.reconcileRules(rules,this.parseFilter);this.reconcileRules(rules,this.displayFilter);this.initMembers();};this.initChars=function(chars){this.chars=chars;this.initMembers();};this.initMembers=function(){this.lines.length=0;this.linesMax=this.parseFilter['max-saved'];if(this.linesMax>this.parseFilter['line-count']){this.linesMax=this.parseFilter['line-count'];};this.parseCircular.initCollection(this.linesMax);this.parseCircularReversed=false;this.unfilteredLines=0;this.opFilteredLines=0;this.savedLines=0;this.firstOpFiltered=-1;this.lastOpFiltered=-1;this.firstSaved=-1;this.lastSaved=-1;this.initDisplay();};this.initDisplay=function(){this.depthStack.length=0;this.depth=0;this.dLines.length=0;this.displayMax=this.displayFilter['max-displayed'];if(this.displayMax>this.displayFilter['line-count']){this.displayMax=this.displayFilter['line-count'];};this.displayCircular.initCollection(this.displayMax);this.opDisplayedLines=0;this.displayedLines=0;this.firstOpDisplayed=-1;this.lastOpDisplayed=-1;this.firstDisplayed=-1;this.lastDisplayed=-1;};this.rules=[];this.chars=[];this.depthStack=[];this.depth=0;this.lines=[];this.parseFilter=[];this.parseFilter.rules=[];this.parseFilter['rule-map']=[];this.parseFilter['rule-names']=[];this.unfilteredLines=0;this.opFilteredLines=0;this.savedLines=0;this.linesMax=0;this.parseCircular=new Circular();this.parseCircularReversed=false;this.displayFilter=[];this.displayFilter.rules=[];this.displayFilter['rule-map']=[];this.displayFilter['rule-names']=[];this.opDisplayedLines=0;this.displayedLines=0;this.displayMax=0;this.dLines=[];this.displayCircular=new Circular();this.firstOpFiltered=-1;this.lastOpFiltered=-1;this.firstSaved=-1;this.lastSaved=-1;this.firstOpDisplayed=-1;this.lastOpDisplayed=-1;this.firstDisplayed=-1;this.lastDisplayed=-1;this.setDefaultParseFilter();this.setDefaultDisplayFilter();};"use strict";function Stats(rules){this.clear=function(){this.statsALT.match=0;this.statsALT.nomatch=0;this.statsALT.empty=0;this.statsALT.backtrack=0;this.statsCAT.match=0;this.statsCAT.nomatch=0;this.statsCAT.empty=0;this.statsREP.match=0;this.statsREP.nomatch=0;this.statsREP.empty=0;this.statsREP.backtrack=0;this.statsPRD.match=0;this.statsPRD.nomatch=0;this.statsPRD.empty=0;this.statsPRD.backtrack=0;this.statsRNM.match=0;this.statsRNM.nomatch=0;this.statsRNM.empty=0;this.statsTRG.match=0;this.statsTRG.nomatch=0;this.statsTRG.empty=0;this.statsTLS.match=0;this.statsTLS.nomatch=0;this.statsTLS.empty=0;this.statsTBS.match=0;this.statsTBS.nomatch=0;this.statsTBS.empty=0;if(this.rules){for(var i=0;i<this.rules.length;i+=1){this.statsRules[i].match=0;this.statsRules[i].nomatch=0;this.statsRules[i].empty=0;this.statsRules[i].rule=this.rules[i].rule;}}};this.collect=function(op,state){var whichState='';switch(state[OP_STATE]){case APG_MATCH:whichState='match';break;case APG_NOMATCH:whichState='nomatch';break;case APG_EMPTY:whichState='empty';break;default:throw['Trace.collect: invalid state: '+state[OP_STATE]];};switch(op.type){case ALT:this.statsALT[whichState]+=1;break;case CAT:this.statsCAT[whichState]+=1;break;case REP:this.statsREP[whichState]+=1;break;case PRD:this.statsPRD[whichState]+=1;break;case RNM:this.statsRNM[whichState]+=1;if(this.statsRules){this.statsRules[op.ruleIndex][whichState]+=1;};break;case TRG:this.statsTRG[whichState]+=1;break;case TLS:this.statsTLS[whichState]+=1;break;case TBS:this.statsTBS[whichState]+=1;break;default:throw['Trace.collect: invalid opcode type: '+op.type];}};this.backtrack=function(op){switch(op.type){case ALT:this.statsALT.backtrack+=1;break;case REP:this.statsREP.backtrack+=1;break;case PRD:this.statsPRD.backtrack+=1;break;default:throw['Trace.backtrack: invalid opcode type: '+op.type];}};function compareCount(lhs,rhs){var totalLhs,totalRhs;totalLhs=lhs.match+lhs.empty+lhs.nomatch;totalRhs=rhs.match+rhs.empty+rhs.nomatch;if(totalLhs<totalRhs){return 1;};if(totalLhs>totalRhs){return -1;};return 0;};function compareName(lhs,rhs){var nameLhs,nameRhs,lenLhs,lenRhs,len,i;nameLhs=lhs.rule.toLowerCase();nameRhs=rhs.rule.toLowerCase();lenLhs=nameLhs.length;lenRhs=nameRhs.length;len=(lenLhs<lenRhs)?lenLhs:lenRhs;for(i=0;i<len;i+=1){if(nameLhs[i]<nameRhs[i]){return -1;};if(nameLhs[i]>nameRhs[i]){return 1;}};if(lenLhs<lenRhs){return -1;};if(lenLhs>lenRhs){return 1;};return 0;};this.display=function(caption){var i,tot,total,html='';total=[];total.match=this.statsALT.match+this.statsCAT.match+this.statsREP.match+this.statsPRD.match+this.statsRNM.match+this.statsTRG.match+this.statsTBS.match+this.statsTLS.match;total.nomatch=this.statsALT.nomatch+this.statsCAT.nomatch+this.statsREP.nomatch+this.statsPRD.nomatch+this.statsRNM.nomatch+this.statsTRG.nomatch+this.statsTBS.nomatch+this.statsTLS.nomatch;total.empty=this.statsALT.empty+this.statsCAT.empty+this.statsREP.empty+this.statsPRD.empty+this.statsRNM.empty+this.statsTRG.empty+this.statsTBS.empty+this.statsTLS.empty;total.backtrack=this.statsALT.backtrack+this.statsREP.backtrack+this.statsPRD.backtrack;if(this.statsRules){this.statsRules.sort(compareName);this.statsRules.sort(compareCount);};html+='<table class="stats">';if(typeof(caption)==='string'){html+='<caption>'+caption+'</caption>';};html+='<tr>';html+='<th>';html+='';html+='</th>';html+='<th>';html+='MATCH';html+='</th>';html+='<th>';html+='NOMATCH';html+='</th>';html+='<th>';html+='EMPTY';html+='</th>';html+='<th>';html+='ALL';html+='</th>';html+='<th>';html+='BACKTRACKS';html+='</th>';html+='</tr>';html+='<tr>';html+='<td>';html+='ALT';html+='</td>';html+='<td>';html+=this.statsALT.match;html+='</td>';html+='<td>';html+=this.statsALT.nomatch;html+='</td>';html+='<td>';html+=this.statsALT.empty;html+='</td>';html+='<td>';html+=(this.statsALT.match+this.statsALT.nomatch+this.statsALT.empty);html+='</td>';html+='<td>';html+=this.statsALT.backtrack;html+='</td>';html+='</tr>';html+='<tr>';html+='<td>';html+='CAT';html+='</td>';html+='<td>';html+=this.statsCAT.match;html+='</td>';html+='<td>';html+=this.statsCAT.nomatch;html+='</td>';html+='<td>';html+=this.statsCAT.empty;html+='</td>';html+='<td>';html+=(this.statsCAT.match+this.statsCAT.nomatch+this.statsCAT.empty);html+='</td>';html+='<td>';html+='';html+='</td>';html+='</tr>';html+='<tr>';html+='<td>';html+='REP';html+='</td>';html+='<td>';html+=this.statsREP.match;html+='</td>';html+='<td>';html+=this.statsREP.nomatch;html+='</td>';html+='<td>';html+=this.statsREP.empty;html+='</td>';html+='<td>';html+=(this.statsREP.match+this.statsREP.nomatch+this.statsREP.empty);html+='</td>';html+='<td>';html+=this.statsREP.backtrack;html+='</td>';html+='</tr>';html+='<tr>';html+='<td>';html+='PRD';html+='</td>';html+='<td>';html+=this.statsPRD.match;html+='</td>';html+='<td>';html+=this.statsPRD.nomatch;html+='</td>';html+='<td>';html+=this.statsPRD.empty;html+='</td>';html+='<td>';html+=(this.statsPRD.match+this.statsPRD.nomatch+this.statsPRD.empty);html+='</td>';html+='<td>';html+=this.statsPRD.backtrack;html+='</td>';html+='</tr>';html+='<tr>';html+='<td>';html+='RNM';html+='</td>';html+='<td>';html+=this.statsRNM.match;html+='</td>';html+='<td>';html+=this.statsRNM.nomatch;html+='</td>';html+='<td>';html+=this.statsRNM.empty;html+='</td>';html+='<td>';html+=(this.statsRNM.match+this.statsRNM.nomatch+this.statsRNM.empty);html+='</td>';html+='<td>';html+='';html+='</td>';html+='</tr>';html+='<tr>';html+='<td>';html+='TRG';html+='</td>';html+='<td>';html+=this.statsTRG.match;html+='</td>';html+='<td>';html+=this.statsTRG.nomatch;html+='</td>';html+='<td>';html+=this.statsTRG.empty;html+='</td>';html+='<td>';html+=(this.statsTRG.match+this.statsTRG.nomatch+this.statsTRG.empty);html+='</td>';html+='<td>';html+='';html+='</td>';html+='</tr>';html+='<tr>';html+='<td>';html+='TBS';html+='</td>';html+='<td>';html+=this.statsTBS.match;html+='</td>';html+='<td>';html+=this.statsTBS.nomatch;html+='</td>';html+='<td>';html+=this.statsTBS.empty;html+='</td>';html+='<td>';html+=(this.statsTBS.match+this.statsTBS.nomatch+this.statsTBS.empty);html+='</td>';html+='<td>';html+='';html+='</td>';html+='</tr>';html+='<tr>';html+='<td>';html+='TLS';html+='</td>';html+='<td>';html+=this.statsTLS.match;html+='</td>';html+='<td>';html+=this.statsTLS.nomatch;html+='</td>';html+='<td>';html+=this.statsTLS.empty;html+='</td>';html+='<td>';html+=(this.statsTLS.match+this.statsTLS.nomatch+this.statsTLS.empty);html+='</td>';html+='<td>';html+='';html+='</td>';html+='</tr>';html+='<tr>';html+='<td>';html+='TOTAL';html+='</td>';html+='<td>';html+=total.match;html+='</td>';html+='<td>';html+=total.nomatch;html+='</td>';html+='<td>';html+=total.empty;html+='</td>';html+='<td>';html+=(total.match+total.nomatch+total.empty);html+='</td>';html+='<td>';html+=total.backtrack;html+='</td>';html+='</tr>';html+='<tr>';html+='<td colspan="5">';html+='</td>';html+='<th class="stats-hdr"  colspan="6">';html+='RULE NAME';html+='</th>';html+='</tr>';if(this.statsRules){for(i=0;i<this.rules.length;i+=1){tot=this.statsRules[i].match+this.statsRules[i].nomatch+this.statsRules[i].empty;if(tot>0){html+='<tr>';html+='<td>';html+='</td>';html+='<td>';html+=this.statsRules[i].match;html+='</td>';html+='<td>';html+=this.statsRules[i].nomatch;html+='</td>';html+='<td>';html+=this.statsRules[i].empty;html+='</td>';html+='<td>';html+=tot;html+='</td>';html+='<td class="stats-hdr">';html+=this.statsRules[i].rule;html+='</td>';html+='</tr>';}}};html+='</table>';return html;};this.statsALT=[];this.statsCAT=[];this.statsREP=[];this.statsPRD=[];this.statsRNM=[];this.statsTRG=[];this.statsTLS=[];this.statsTBS=[];this.statsRules=null;this.rules=null;if(isArray(rules)){this.rules=rules;this.statsRules=[];for(var i=0;i<this.rules.length;i+=1){this.statsRules[i]=[];}};this.clear();};"use strict";function Ast(list,rules,ruleIds,chars){this.rules=rules;this.chars=chars;this.ruleIds=ruleIds;this.inPRD=0;this.astList=[];this.ast=[];this.rulePhrases=[];this.ruleCount=rules.length;var i;for(i=0;i<this.ruleCount;i+=1){if(list[i]===true){this.astList[i]=[];}else{this.astList[i]=null;};this.rulePhrases[i]=[];};this.clear=function(){this.ast.length=0;};this.ruleDefined=function(ruleIndex){return(this.astList[ruleIndex]!==null);};this.down=function(ruleIndex){var thisIndex=this.ast.length;if(this.inPRD===0){this.ast[thisIndex]=[];this.ast[thisIndex].down=true;this.ast[thisIndex].ruleIndex=ruleIndex;this.ast[thisIndex].upIndex=null;};return thisIndex;};this.up=function(downIndex,phraseIndex,phraseLength){var thisIndex=this.ast.length;if(this.inPRD===0){this.ast[thisIndex]=[];this.ast[thisIndex].down=false;this.ast[thisIndex].downIndex=downIndex;this.ast[thisIndex].phraseIndex=phraseIndex;this.ast[thisIndex].phraseLength=phraseLength;this.ast[downIndex].upIndex=thisIndex;};return thisIndex;};this.truncate=function(length){if(this.inPRD===0){this.ast.length=length;}};this.currentLength=function(){return this.ast.length;};this.countPhrases=function(){for(var i=0;i<this.ast.length;i+=1){if(this.ast[i].down){this.rulePhrases[this.ast[i].ruleIndex].push(this.ast[i].upIndex);}}};this.getDropDownOptions=function(options){for(var i=0;i<this.ruleCount;i+=1){var j=this.ruleIds[i];options[j]=[];options[j].rule=this.rules[j].rule;options[j]['phrase-count']=this.rulePhrases[j].length;}};this.displayPhrasesAscii=function(ruleIndex){var html='';var list=[];var stack=[];var listIndex=0;var node;var nextNode;list=this.rulePhrases[ruleIndex];if(list[listIndex]!==undefined){nextNode=this.ast[list[listIndex]];}else{nextNode=undefined;};for(var i=0;i<this.chars.length;i+=1){if(nextNode&&nextNode.phraseIndex===i){if(nextNode.phraseLength===0){html+='<span class="ast-empty">&epsilon;</span>';while(true){listIndex+=1;nextNode=(list[listIndex]!==undefined)?this.ast[list[listIndex]]:undefined;if(nextNode&&nextNode.phraseIndex===i){html+='<span class="ast-empty">&epsilon;</span>';}else{break;}}}else{if(stack.length%2===0){html+='<span class="ast-highlight-even">';}else{html+='<span class="ast-highlight-odd">';};stack.push(nextNode);listIndex+=1;nextNode=(list[listIndex]!==undefined)?this.ast[list[listIndex]]:undefined;}};if(this.chars[i]===10){html+='<span class="control-char">LF</span><br />';}else if(this.chars[i]===13){html+='<span class="control-char">CR</span>';}else if(this.chars[i]===9){html+='<span class="control-char">TAB</span>';}else if(this.chars[i]<32||this.chars[i]>126){html+='<span class="non-ascii">x'+this.chars[i].toString(16).toUpperCase()+'</span>';}else if(this.chars[i]===32){html+='&nbsp;';}else{html+='&#'+this.chars[i];};if(stack.length>0){node=stack[stack.length-1];while(node&&(node.phraseIndex+node.phraseLength-1)===i){html+='</span>';stack.pop();node=stack[stack.length-1];}}};if(stack.length>0){apgAssert(stack.length===1,'displayPhrasesAscii: stack length: '+stack.length);html+='</span>';stack.pop();};return html;};this.displayPhrasesHex=function(ruleIndex){var html='';var htmlHex='';var htmlAscii='';var list=[];var stack=[];var listIndex=0;var node;var nextNode;var hexChar;var spanEven='<span class="ast-highlight-even">';var spanOdd='<span class="ast-highlight-odd">';var emptyHex='<span class="ast-empty">00</span>';var emptyAscii='<span class="ast-empty">&epsilon;</span>';var count=0;var matchLen=24;list=this.rulePhrases[ruleIndex];if(list[listIndex]!==undefined){nextNode=this.ast[list[listIndex]];}else{nextNode=undefined;};for(var i=0;i<this.chars.length;i+=1){if(nextNode&&nextNode.phraseIndex===i){if(nextNode.phraseLength===0){htmlAscii+=emptyAscii;htmlHex+=emptyHex;count+=1;if(count===matchLen){htmlHex+='<br />';htmlAscii+='<br />';count=0;}else{if(count%4===0){htmlHex+='&nbsp;';}}while(true){listIndex+=1;nextNode=(list[listIndex]!==undefined)?this.ast[list[listIndex]]:undefined;if(nextNode&&nextNode.phraseIndex===i){htmlAscii+=emptyAscii;htmlHex+=emptyHex;count+=1;if(count===matchLen){htmlHex+='<br />';htmlAscii+='<br />';count=0;}else{if(count%4===0){htmlHex+='&nbsp;';}}}else{break;}}}else{if(stack.length%2===0){htmlAscii+=spanEven;htmlHex+=spanEven;}else{htmlAscii+=spanOdd;htmlHex+=spanOdd;};stack.push(nextNode);listIndex+=1;nextNode=(list[listIndex]!==undefined)?this.ast[list[listIndex]]:undefined;}};if(this.chars[i]<32||this.chars[i]>126){htmlAscii+='&#46;';}else if(this.chars[i]===32){htmlAscii+='&nbsp;';}else{htmlAscii+='&#'+this.chars[i];};hexChar=this.chars[i].toString(16).toUpperCase();if(hexChar.length===1){htmlHex+='0'+hexChar;}else{htmlHex+=hexChar;};if(stack.length>0){node=stack[stack.length-1];if((node.phraseIndex+node.phraseLength-1)===i){htmlHex+='</span>';htmlAscii+='</span>';stack.pop();}};count+=1;if(count===matchLen){htmlHex+='<br />';htmlAscii+='<br />';count=0;}else{if(count%4===0){htmlHex+='&nbsp;';}}};if(stack.length>0){apgAssert(stack.length===1,'displayPhrasesHex: stack length: '+stack.length);html+='</span>';stack.pop();};html+='<pre><table class="phrase-table"><tr><td>'+htmlHex+'</td><td>'+htmlAscii+'</td></tr></table></pre>';return html;};function printLine(indent,up,name,phraseIndex,phraseLength,chars){var out="";var i=0;for(;i<indent;i+=1){out+='&nbsp;';};if(up){out+='&uarr;';}else{out+='&darr;';};out+=name+': ['+phraseIndex+']['+phraseLength+']';out+='<br />';return out;};this.dump=function(rules,chars){var i,indent,downIndex,upIndex,ruleIndex,name,index,count;var html='';html+='AST dump:';html+='<br />';indent=0;i=0;for(;i<this.ast.length;i+=1){if(this.ast[i].down){downIndex=i;upIndex=this.ast[downIndex].upIndex;ruleIndex=this.ast[downIndex].ruleIndex;name=rules[ruleIndex].rule;index=this.ast[upIndex].phraseIndex;count=this.ast[upIndex].phraseLength;html+=printLine(indent,false,name,index,count,chars);indent+=1;}else{indent-=1;upIndex=i;downIndex=this.ast[upIndex].downIndex;ruleIndex=this.ast[downIndex].ruleIndex;name=rules[ruleIndex].rule;index=this.ast[upIndex].phraseIndex;count=this.ast[upIndex].phraseLength;html+=printLine(indent,true,name,index,count,chars);}};return html;};};"use strict";var BUTTON_GRAMMAR_PARSE=0;var BUTTON_GRAMMAR_CONFIG=1;var BUTTON_INPUT_PARSE=2;var BUTTON_INPUT_CONFIG=3;var BUTTON_STATE=4;var BUTTON_STRING=5;var BUTTON_PHRASES=6;var BUTTON_STATS=7;var BUTTON_ATTRS=8;var BUTTON_GENERATED_PARSER=9;var BUTTON_MSGLOG=10;var BUTTON_DISPLAY_TRACE=11;var BUTTON_DISPLAY_FILTER=12;var BUTTON_COUNT=13;var CONTROLS_BEGIN=BUTTON_STATE;var CONTROLS_END=BUTTON_COUNT;var IND_GRAMMAR_SUCCESS=0;var IND_GRAMMAR_FAILED=1;var IND_INPUT_SUCCESS=2;var IND_INPUT_FAILED=3;var IND_COUNT=4;function Buttons(){var i;this.ret=[];this.ret['return']=true;this.ret.msg='OK';this.ret.className=0;this.buttons=[];for(i=0;i<BUTTON_COUNT;i+=1){this.buttons[i]=[];};this.buttons[BUTTON_GRAMMAR_PARSE].id='button-generator';this.buttons[BUTTON_GRAMMAR_CONFIG].id='button-filter-grammar';this.buttons[BUTTON_INPUT_PARSE].id='button-parser';this.buttons[BUTTON_INPUT_CONFIG].id='button-filter-input';this.buttons[BUTTON_STATE].id='state';this.buttons[BUTTON_STATS].id='statistics';this.buttons[BUTTON_MSGLOG].id='msg-log';this.buttons[BUTTON_STRING].id='display-string';this.buttons[BUTTON_ATTRS].id='recursion-attrs';this.buttons[BUTTON_DISPLAY_TRACE].id='display-trace';this.buttons[BUTTON_DISPLAY_FILTER].id='filter-trace';this.buttons[BUTTON_GENERATED_PARSER].id='generated-parser';this.buttons[BUTTON_PHRASES].id='phrases';this.openControlId=false;this.indicators=[];for(i=0;i<IND_COUNT;i+=1){this.indicators[i]=[];};this.indicators[IND_GRAMMAR_SUCCESS].id='grammar-success';this.indicators[IND_GRAMMAR_FAILED].id='grammar-failed';this.indicators[IND_INPUT_SUCCESS].id='input-success';this.indicators[IND_INPUT_FAILED].id='input-failed';this.indicators[IND_GRAMMAR_SUCCESS]['active-class']='ind-success';this.indicators[IND_GRAMMAR_FAILED]['active-class']='ind-failed';this.indicators[IND_INPUT_SUCCESS]['active-class']='ind-success';this.indicators[IND_INPUT_FAILED]['active-class']='ind-failed';this.indicators[IND_GRAMMAR_SUCCESS]['inactive-class']='ind';this.indicators[IND_GRAMMAR_FAILED]['inactive-class']='ind';this.indicators[IND_INPUT_SUCCESS]['inactive-class']='ind';this.indicators[IND_INPUT_FAILED]['inactive-class']='ind';this.captureButtonInfo=function(){var i;for(i=0;i<this.buttons.length;i+=1){this.buttons[i].element=document.getElementById(this.buttons[i].id);};for(i=CONTROLS_BEGIN;i<CONTROLS_END;i+=1){this.buttons[i].value=this.buttons[i].element.value.substring(2);this.buttons[i].html='';};for(i=0;i<this.indicators.length;i+=1){this.indicators[i].element=document.getElementById(this.indicators[i].id);}};this.captureButtonStates=function(){for(var i=0;i<this.buttons.length;i+=1){this.buttons[i].disabled=this.buttons[i].element.disabled;this.buttons[i]['class']=this.buttons[i].element.className;this.buttons[i].disabled=this.buttons[i].element.disabled;}};this.disable=function(id){if(typeof(id)==='number'&&id<BUTTON_COUNT){this.buttons[id].element.disabled=true;this.buttons[id].element.className='button-inactive';this.buttons[id].html='';}};this.enable=function(id,parse){if(typeof(id)==='number'&&id<BUTTON_COUNT){this.buttons[id].element.disabled=false;this.buttons[id].element.className=parse?'button-active-parse':'button-active';}};this.disableButtons=function(){for(var i=0;i<this.buttons.length;i+=1){this.buttons[i].element.disabled=true;this.buttons[i].element.className='button-inactive';}};this.controlActivate=function(id,active){if(typeof(id)==='number'&&id>=CONTROLS_BEGIN&&id<CONTROLS_END){if(active){this.buttons[id].element.disabled=false;}else{this.buttons[id].element.disabled=true;}}};this.controlClose=function(iframe){if(this.openControlId){var e=this.buttons[this.openControlId].element;e.value="+ "+this.buttons[this.openControlId].value;e.className="button-active";iframe.innerHTML='';this.openControlId=false;}};this.controlOpen=function(id,iframe,text){var e,haveText;haveText=typeof(text)=='string'?true:false;if(typeof(id)==='number'&&id>=CONTROLS_BEGIN&&id<CONTROLS_END){if(id===this.openControlId){if(text){iframe.innerHTML=text;}}else{this.controlClose(iframe);e=this.buttons[id].element;if(e.disabled===true){this.enable(id);};e.value="-> "+this.buttons[id].value;e.className="button-active-open";if(text){iframe.innerHTML=text;};this.openControlId=id;}}};this.controlCloseP=function(iframe){if(this.openControlId){var e=this.buttons[this.openControlId].element;e.value="+ "+this.buttons[this.openControlId].value;e.className="button-active-parse";iframe.innerHTML='';this.openControlId=false;}};this.controlOpenP=function(id,iframe,text){var e,haveText;haveText=typeof(text)=='string'?true:false;if(typeof(id)==='number'&&id>=CONTROLS_BEGIN&&id<CONTROLS_END){if(id===this.openControlId){if(text){iframe.innerHTML=text;}}else{this.controlCloseP(iframe);e=this.buttons[id].element;if(e.disabled===true){this.enable(id);};e.value="-> "+this.buttons[id].value;e.className="button-active-parse-open";if(text){iframe.innerHTML=text;};this.openControlId=id;}}};this.closeIndicators=function(){for(var i=0;i<IND_COUNT;i+=1){this.indicators[i].element.className=this.indicators[i]['inactive-class'];}};this.setIndicator=function(id,active){if(typeof(id)==='number'&&id<IND_COUNT){if(active){this.indicators[id].element.className=this.indicators[id]['active-class'];}else{this.indicators[id].element.className=this.indicators[id]['inactive-class'];}}};};"use strict";var DEFAULT_GEN_PHRASES=false;var DEFAULT_GEN_TRACE=false;var DEFAULT_GEN_INPUT='ascii';var DEFAULT_GEN_DISPLAY='ascii';var DEFAULT_GEN_RANGE=DEFAULT_LINE_RANGE;var DEFAULT_PARSER_PHRASES=false;var DEFAULT_PARSER_TRACE=false;var DEFAULT_PARSER_INPUT='auto';var DEFAULT_PARSER_DISPLAY=DEFAULT_TRACE_DISPLAY;var DEFAULT_PARSER_RANGE=DEFAULT_LINE_RANGE;function generator_config_reset(config){config.length=0;config.type='generator';config.input=DEFAULT_GEN_INPUT;config.display=DEFAULT_GEN_DISPLAY;config.phrases=DEFAULT_GEN_PHRASES;config.trace=DEFAULT_GEN_TRACE;config.lastNrecords=DEFAULT_MAX_SAVED;config.firstRecordRange=0;config.numberRecordRange=DEFAULT_MAX_SAVED;config.firstRecord=0;config.lastRecord=DEFAULT_MAX_SAVED;config.DlastNrecords=DEFAULT_MAX_DISPLAYED;config.DfirstRecordRange=0;config.DnumberRecordRange=DEFAULT_MAX_DISPLAYED;config.DfirstRecord=0;config.DlastRecord=DEFAULT_MAX_DISPLAYED;};function parser_config_reset(config){config.length=0;config.type='parser';config.input=DEFAULT_PARSER_INPUT;config.display=DEFAULT_PARSER_DISPLAY;config.phrases=DEFAULT_PARSER_PHRASES;config.trace=DEFAULT_PARSER_TRACE;config.lastNrecords=DEFAULT_MAX_SAVED;config.firstRecordRange=0;config.numberRecordRange=DEFAULT_MAX_SAVED;config.firstRecord=0;config.lastRecord=DEFAULT_MAX_SAVED;config.DlastNrecords=DEFAULT_MAX_DISPLAYED;config.DfirstRecordRange=0;config.DnumberRecordRange=DEFAULT_MAX_DISPLAYED;config.DfirstRecord=0;config.DlastRecord=DEFAULT_MAX_DISPLAYED;};var PARSE_GRAMMAR=1;var CONFIGURE_GENERATOR=2;var SELECT_GRAMMAR=3;var PARSE_INPUT=4;var CONFIGURE_PARSER=5;var SELECT_INPUT=6;var DISPLAY_PARSER_STATE=7;var DISPLAY_PARSER_STATS=8;var DISPLAY_RECURSION=9;var DISPLAY_MSGLOG=10;var DISPLAY_GENERATED_PARSER=11;var DISPLAY_STRING=12;var DISPLAY_TRACE=13;var SET_DISPLAY_FILTER=14;var DISPLAY_PHRASE=15;var PAGE_INIT=16;var POPUP_GRAMMAR=17;var POPUP_STRING=18;var POPUP_IFRAME=19;var HELP=20;var POPUP_IPV6_LIST=21;var RESET_PAGE=22;var eventLoop;function EventLoop(){this.eventStack=[];this.iframeBody=false;this.ret=[];this.ret['return']=true;this.ret.msg='OK';this.ret.value=0;this.msgLog=new MsgLog();this.ast=null;this.apgOpcodes=new ApgOpcodes();this.apgSemCallbacks=new ApgSemCallbacks(this.msgLog,this.apgOpcodes.ruleIds);this.apgSynCallbacks=new ApgSynCallbacks(this.msgLog,this.apgOpcodes.ruleIds);this.traceGen=new Trace();this.traceGen.initRules(this.apgOpcodes.rules);this.traceParser=new Trace();this.buttons=new Buttons();this.lastParser='grammar';this.disabledPhraseHtml='<select id="select-tag" class="select-inactive" disabled="true"></select>';this.popupGrammarWindow=undefined;this.popupStringWindow=undefined;this.popupIframeWindow=undefined;this.popupIPv6Window=undefined;this.configureWindow=undefined;this.helpWindow=undefined;this.filterParser=undefined;this.filterWindow=undefined;this.filterRules=undefined;this.filterRuleIds=undefined;this.genConfig=[];this.parserConfig=[];generator_config_reset(this.genConfig);parser_config_reset(this.parserConfig);this.event=function(event){var options,ret=[];try{this.validateEvent(event,ret);if(!ret['return']){throw[ret.msg];};this.eventStack.push(event.id);options='';options+='width="'+screen.width+'",height="'+screen.height+'"';options+=',location=1';options+=',menubar=1';options+=',scrollbars=yes';options+=',status=1';options+=',titlebar=1';options+=',toolbar=1';options+=',resizable=1';switch(event.id){case PARSE_GRAMMAR:this.buttons.disable(BUTTON_GRAMMAR_PARSE);this.buttons.disable(BUTTON_GRAMMAR_CONFIG);this.buttons.disable(BUTTON_INPUT_PARSE);this.buttons.disable(BUTTON_INPUT_CONFIG);this.buttons.closeIndicators();setTimeout(function(){eventLoop.parseGrammar([]);},10);break;case CONFIGURE_GENERATOR:this.openFilter('configure-generator');break;case SELECT_GRAMMAR:document.getElementById("abnf-grammar").select();break;case POPUP_GRAMMAR:this.popup('grammar');break;case HELP:window.open('/interactiveapg/help','',options);break;case PARSE_INPUT:this.buttons.disable(BUTTON_GRAMMAR_PARSE);this.buttons.disable(BUTTON_GRAMMAR_CONFIG);this.buttons.disable(BUTTON_INPUT_PARSE);this.buttons.disable(BUTTON_INPUT_CONFIG);this.buttons.closeIndicators();setTimeout(function(){eventLoop.parseString([]);},10);break;case CONFIGURE_PARSER:this.openFilter('configure-parser');break;case SELECT_INPUT:document.getElementById("input-string").select();break;case POPUP_STRING:this.popup('string');break;case DISPLAY_PARSER_STATE:if(this.lastParser==='grammar'){this.buttons.controlOpen(BUTTON_STATE,this.iframeBody,this.buttons.buttons[BUTTON_STATE].html);}else{this.buttons.controlOpenP(BUTTON_STATE,this.iframeBody,this.buttons.buttons[BUTTON_STATE].html);};break;case DISPLAY_PARSER_STATS:if(this.lastParser==='grammar'){this.buttons.controlOpen(BUTTON_STATS,this.iframeBody,this.buttons.buttons[BUTTON_STATS].html);}else{this.buttons.controlOpenP(BUTTON_STATS,this.iframeBody,this.buttons.buttons[BUTTON_STATS].html);};break;case DISPLAY_RECURSION:this.buttons.controlOpen(BUTTON_ATTRS,this.iframeBody,this.buttons.buttons[BUTTON_ATTRS].html);break;case DISPLAY_MSGLOG:if(this.lastParser==='grammar'){this.buttons.controlOpen(BUTTON_MSGLOG,this.iframeBody,this.buttons.buttons[BUTTON_MSGLOG].html);}else{this.buttons.controlOpenP(BUTTON_MSGLOG,this.iframeBody,this.buttons.buttons[BUTTON_MSGLOG].html);};break;case DISPLAY_GENERATED_PARSER:this.buttons.controlOpen(BUTTON_GENERATED_PARSER,this.iframeBody,this.buttons.buttons[BUTTON_GENERATED_PARSER].html);break;case DISPLAY_STRING:if(this.lastParser==='grammar'){this.buttons.controlOpen(BUTTON_STRING,this.iframeBody,this.buttons.buttons[BUTTON_STRING].html);}else{this.buttons.controlOpenP(BUTTON_STRING,this.iframeBody,this.buttons.buttons[BUTTON_STRING].html);};break;case DISPLAY_PHRASE:if(this.lastParser==='grammar'){this.buttons.controlOpen(BUTTON_PHRASES,this.iframeBody,this.phraseDisplay('grammar'));}else{this.buttons.controlOpenP(BUTTON_PHRASES,this.iframeBody,this.phraseDisplay('parser'));};break;case SET_DISPLAY_FILTER:if(this.lastParser==='grammar'){this.buttons.controlOpen(BUTTON_DISPLAY_FILTER,this.iframeBody);}else{this.buttons.controlOpenP(BUTTON_DISPLAY_FILTER,this.iframeBody);};this.openFilter('display-trace');break;case DISPLAY_TRACE:if(this.lastParser==='grammar'){this.buttons.controlOpen(BUTTON_DISPLAY_TRACE,this.iframeBody,this.traceDisplay());}else{this.buttons.controlOpenP(BUTTON_DISPLAY_TRACE,this.iframeBody,this.traceDisplay());};break;case POPUP_IFRAME:this.popup('iframe');break;case POPUP_IPV6_LIST:this.popup('ipv6');break;case RESET_PAGE:this.buttons.controlClose(this.iframeBody);this.buttons.closeIndicators();this.buttons.disable(BUTTON_STATE);this.buttons.disable(BUTTON_STATS);this.buttons.disable(BUTTON_MSGLOG);this.buttons.disable(BUTTON_STRING);this.buttons.disable(BUTTON_ATTRS);this.buttons.disable(BUTTON_DISPLAY_TRACE);this.buttons.disable(BUTTON_DISPLAY_FILTER);this.buttons.disable(BUTTON_GENERATED_PARSER);this.buttons.disable(BUTTON_PHRASES);break;case PAGE_INIT:this.getIframe(ret);this.buttons.captureButtonInfo();break;default:throw['no handler for event[\'id\'] = '+event.id];};this.eventStack.pop();if(!ret['return']){throw[ret.msg];}}catch(e){this.eventStack.length=0;}};this.catchEx=function(e){var x,ret='exception: ';for(x in e){ret+=x+": "+e[x]+'<br />\n';};return ret;};this.phraseDisplay=function(which){var opid,el,phrase,i,displayAscii,config,html='';opid='phrase-option-';phrase=null;for(i=0;i<this.ast.rules.length;i+=1){el=window.document.getElementById(opid+i.toString());if(el&&el.selected===true){phrase=i;break;}};if(phrase!==null){displayAscii=true;config=(which==='grammar')?this.genConfig:this.parserConfig;if(config.display==='ascii'){displayAscii=true;}else if(config.display==='hex'){displayAscii=false;}else{if(charsAreAscii(this.ast.chars)){displayAscii=true;}else{displayAscii=false;}};if(displayAscii){html+=this.ast.displayPhrasesAscii(phrase);}else{html+=this.ast.displayPhrasesHex(phrase);}}else{html+='no phrase selected<br />';};return html;};this.popup=function(which){var hdr,msg,options='';options+='width='+screen.width+',height='+screen.height+'';options+=',location=no';options+=',menubar=no';options+=',scrollbars=yes';options+=',status=no';options+=',titlebar=no';options+=',toolbar=no';options+=',resizable=yes';msg='';msg+='Press "OK" to replace it.\n';msg+='Press "Cancel" to leave it.\n';switch(which){case 'grammar':hdr='ABNF Grammar - a full screen window is already up.\n';if(this.popupGrammarWindow){if(confirm(hdr+msg)){this.popupGrammarWindow.close();this.popupGrammarWindow=window.open('/interactiveapg/popup_grammar','',options);}}else{this.popupGrammarWindow=window.open('/interactiveapg/popup_grammar','',options);};break;case 'string':hdr='Input String - a full screen window is already up.\n';if(this.popupStringWindow){if(confirm(hdr+msg)){this.popupStringWindow.close();this.popupStringWindow=window.open('/interactiveapg/popup_input','',options);}}else{this.popupStringWindow=window.open('/interactiveapg/popup_input','',options);};break;case 'iframe':hdr='iframe - a full screen window is already up.\n';if(this.popupIframeWindow){if(confirm(hdr+msg)){this.popupIframeWindow.close();this.popupIframeWindow=window.open('/interactiveapg/popup_output','',options);}}else{this.popupIframeWindow=window.open('/interactiveapg/popup_output','',options);};break;case 'ipv6':options='width=320,height=600';options+=',location=no';options+=',menubar=no';options+=',scrollbars=yes';options+=',status=no';options+=',titlebar=no';options+=',toolbar=no';options+=',resizable=yes';if(this.popupIPv6Window){alert('IPv6 address list is already open.');}else{this.popupIPv6Window=window.open('/interactiveapg/popup_ipv6','',options);};break;}};this.traceDisplay=function(){var html;html='';if(this.lastParser==='grammar'){html+=this.traceGen.display();}else if(this.lastParser==='input'){html+=this.traceParser.display();};return html;};this.openConfigure=function(){if(!this.configureWindow){var options='';options+='width=320,height=600';options+=',location=no';options+=',menubar=no';options+=',scrollbars=yes';options+=',status=no';options+=',titlebar=no';options+=',toolbar=no';options+=',resizable=no';this.configureWindow=window.open('/interactiveapg/configure','',options);}else{alert('configuration window is already open');}};this.disableDisplayButtons=function(){this.buttons.disable(BUTTON_DISPLAY_TRACE);this.buttons.disable(BUTTON_DISPLAY_FILTER);};this.openFilter=function(which){if(!this.filterWindow){var options='';options+='width=320,height=600';options+=',location=no';options+=',menubar=no';options+=',scrollbars=yes';options+=',status=no';options+=',titlebar=no';options+=',toolbar=no';options+=',resizable=no';if(which==='configure-generator'){this.filterTrace=this.traceGen;this.filterConfig=this.genConfig;this.filterRules=this.apgOpcodes.rules;this.filterRuleIds=this.apgOpcodes.ruleIds;this.filterWindow=window.open('/interactiveapg/generator_config/generator','',options);}else if(which==='configure-parser'){this.filterTrace=this.traceParser;this.filterConfig=this.parserConfig;this.filterRules=this.apgSemCallbacks.rules;this.filterRuleIds=this.apgSemCallbacks.ruleIds;this.filterWindow=window.open('/interactiveapg/generator_config/parser','',options);}else if(which==='display-trace'){if(this.lastParser==='grammar'){this.filterTrace=this.traceGen;this.filterConfig=this.genConfig;this.filterRules=this.apgOpcodes.rules;this.filterRuleIds=this.apgOpcodes.ruleIds;this.filterWindow=window.open('/interactiveapg/dtrace','',options);}else if(this.lastParser==='input'){this.filterTrace=this.traceParser;this.filterConfig=this.parserConfig;this.filterRules=this.apgSemCallbacks.rules;this.filterRuleIds=this.apgSemCallbacks.ruleIds;this.filterWindow=window.open('/interactiveapg/dtrace','',options);}}else if(which==='configure'){}else if(which==='help'){}}else{alert('requested window is already open');}};this.validateEvent=function(event,ret){ret['return']=true;while(true){if(!isArray(event)){ret['return']=false;ret.msg='event is not an array';break;};if(typeof(event.id)==='undefined'){ret['return']=false;ret.msg='event[\'id\'] does not exist';break;};for(var i=0;i<this.eventStack.length;i+=1){if(event.id===this.eventStack[i]){ret['return']=false;ret.msg='event[\'id\'] handler may not call itself';break;}};break;}};this.log=function(msg){this.msgLog.logMsg(msg);};this.getIframe=function(ret){var grammarFrame,grammarFrameDoc,iframeBody;ret['return']=false;ret.value=undefined;while(true){if(this.iframeBody){ret['return']=true;ret.value=this.iframeBody;break;};grammarFrame=document.getElementById("displayFrame");if(!grammarFrame){ret.msg='getIframe: cannot get display frame';break;};grammarFrameDoc=grammarFrame.contentDocument;if(grammarFrameDoc===undefined||grammarFrameDoc===null){grammarFrameDoc=grammarFrame.contentWindow.document;};if(!grammarFrameDoc){ret.msg='getIframe: cannot get display frame document';break;};iframeBody=grammarFrameDoc.getElementById('body');if(!iframeBody){ret.msg='getIframe: cannot get display frame body';break;};this.iframeBody=iframeBody;ret.value=iframeBody;ret['return']=true;break;};return ret.value;};this.resetControls=function(which){var i,select;this.buttons.controlClose(this.iframeBody);for(i=CONTROLS_BEGIN;i<=CONTROLS_END;i+=1){this.buttons.disable(i);};select=window.document.getElementById('select-phrases');select.innerHTML='';select.className='button-inactive';if(which==='grammar'){this.buttons.disable(BUTTON_INPUT_PARSE);this.buttons.disable(BUTTON_INPUT_CONFIG);this.buttons.setIndicator(IND_GRAMMAR_SUCCESS,false);this.buttons.setIndicator(IND_GRAMMAR_FAILED,false);}else if(which==='input'){this.buttons.setIndicator(IND_INPUT_SUCCESS,false);this.buttons.setIndicator(IND_INPUT_FAILED,false);}};this.parseGrammar=function(ret){this.ast=null;var test,i,indicator,controlToOpen,activateState,activateStats,activateAttrs,activateMsgLog,activateGen,activateString,activatePhrases,activateTrace,activateTraceFilter,buttons,stringChars,attrs,apgStats,parser,grammar,list,select;indicator=false;controlToOpen=false;activateState=false;activateStats=false;activateAttrs=false;activateMsgLog=false;activateGen=false;activateString=false;activatePhrases=false;activateTrace=false;activateTraceFilter=false;buttons=this.buttons.buttons;ret['return']=false;while(true){this.lastParser='grammar';this.resetControls('grammar');this.msgLog.clear();activateMsgLog=true;controlToOpen=BUTTON_MSGLOG;apgStats=new Stats(this.apgOpcodes.rules);parser=new ApgLib(this.apgOpcodes.stringTable,this.apgOpcodes.rules,this.apgOpcodes.opcodes);if(!parser.constructed){ret.msg="parseGrammar: ApgLib constructor failed";this.log(ret.msg);break;};parser.statsInit(apgStats);parser.syntaxInit(this.apgSynCallbacks.synList);parser.semanticInit(this.apgSemCallbacks.semList);stringChars=[];grammar=document.getElementById("abnf-grammar");test=grammarToChars(this.msgLog,grammar.value,stringChars);activateString=true;if(this.genConfig.display==='hex'){buttons[BUTTON_STRING].html=tableCharsHex(stringChars);}else if(this.genConfig.display==='ascii'){buttons[BUTTON_STRING].html=tableChars(stringChars);}else{if(charsAreAscii(stringChars)){buttons[BUTTON_STRING].html=tableChars(stringChars);}else{buttons[BUTTON_STRING].html=tableCharsHex(stringChars);}};if(!test){ret.msg="parseGrammar: input grammar string empty or invalid";this.log(ret.msg);break;};if(this.genConfig.phrases){list=[];for(i=0;i<this.apgOpcodes.rules.length;i+=1){list[i]=true;};this.ast=new Ast(list,this.apgOpcodes.rules,this.apgOpcodes.ruleIds,stringChars);}else{this.ast=new Ast(this.apgSemCallbacks.astList,this.apgOpcodes.rules,stringChars);};parser.astInit(this.ast);if(this.genConfig.trace===true){this.traceGen.initChars(stringChars);this.traceGen.setFilter(this.traceGen.displayFilter,'display',this.genConfig.display);this.traceGen.setFilter(this.traceGen.parseFilter,'trace',this.genConfig.trace);parser.traceInit(this.traceGen);activateTrace=true;activateTraceFilter=this.genConfig.display;};parser.stats.clear();this.apgSynCallbacks.catalog(stringChars);test=parser.syntaxAnalysis(0,stringChars,this.apgSynCallbacks);activateState=true;activateStats=true;buttons[BUTTON_STATE].html=parser.stateDisplay();buttons[BUTTON_STATS].html=parser.stats.display();controlToOpen=BUTTON_STATE;activatePhrases=this.genConfig.phrases;if(this.msgLog.count()!==0){ret.msg='grammarParser: syntaxAnalysis analysis errors encountered';controlToOpen=BUTTON_MSGLOG;break;};if(!test){ret.msg='grammarParser: syntaxAnalysis analysis errors of unknown type encountered';this.log(ret.msg);controlToOpen=BUTTON_MSGLOG;break;};this.apgSemCallbacks.clear();parser.semanticAnalysis(this.apgSemCallbacks);if((this.msgLog.count()!==0)){ret.msg='grammarParser: semantic analysis errors encountered';controlToOpen=BUTTON_MSGLOG;break;};attrs=new RuleAttributes(this.apgSemCallbacks.ruleIds,this.apgSemCallbacks.rules,this.apgSemCallbacks.opcodes);buttons[BUTTON_ATTRS].html=attrs.displaySelfAttrs();buttons[BUTTON_ATTRS].html+=attrs.displayStartRuleAttrs();activateAttrs=true;for(i=0;i<attrs.ruleCount;i+=1){if(attrs.selfAttrs[i].left||attrs.selfAttrs[i].infinite||attrs.selfAttrs[i].cyclic){this.log('Rule Attributes: rule "'+attrs.rules[i].rule+'" cannot be parsed');}};if(attrs.errors>0){controlToOpen=BUTTON_ATTRS;}else{buttons[BUTTON_GENERATED_PARSER].html=this.apgSemCallbacks.jsGenerator();activateGen=true;indicator=true;};ret['return']=true;break;};buttons[BUTTON_MSGLOG].html=this.msgLog.logDisplay();this.buttons.setIndicator(IND_GRAMMAR_SUCCESS,indicator);this.buttons.setIndicator(IND_GRAMMAR_FAILED,!indicator);if(activateState){this.buttons.enable(BUTTON_STATE);};if(activateStats){this.buttons.enable(BUTTON_STATS);};if(activateMsgLog&&(this.msgLog.count()>0)){this.buttons.enable(BUTTON_MSGLOG);};if(activateGen){this.buttons.enable(BUTTON_GENERATED_PARSER);};if(activateString){this.buttons.enable(BUTTON_STRING);};if(activateTrace){this.buttons.enable(BUTTON_DISPLAY_TRACE);};if(activateTraceFilter){this.buttons.enable(BUTTON_DISPLAY_FILTER);};if(activateAttrs){this.buttons.enable(BUTTON_ATTRS);this.buttons.enable(BUTTON_INPUT_PARSE);this.buttons.enable(BUTTON_INPUT_CONFIG);this.traceParser.initRules(this.apgSemCallbacks.rules);};select=window.document.getElementById('select-phrases');if(activatePhrases){this.buttons.enable(BUTTON_PHRASES);select.innerHTML=this.phraseDropDown();}else{select.innerHTML=this.disabledPhraseHtml;};this.buttons.controlOpen(controlToOpen,this.iframeBody,buttons[controlToOpen].html);this.buttons.enable(BUTTON_GRAMMAR_PARSE);this.buttons.enable(BUTTON_GRAMMAR_CONFIG);};this.phraseDropDown=function(){var i,j,options,html='';this.ast.countPhrases();options=[];this.ast.getDropDownOptions(options);if(this.lastParser==='grammar'){html+='<select id="select-tag" class="select-active">';}else if(this.lastParser==='input'){html+='<select id="select-tag" class="select-active-parse">';};html+='<option id="phrase-option-none" value="none">select a phrase</option>';for(i=0;i<this.ast.rules.length;i+=1){j=this.ast.ruleIds[i];if(options[j]['phrase-count']>0){html+='<option id="phrase-option-'+j+'" value="'+j+'">';html+=options[j].rule+' ('+options[j]['phrase-count']+')</option><br />';}};html+='</select>';return html;};this.convertStringToChars=function(chars){var testChars,string,test,ret=false;testChars=[];string=document.getElementById("input-string").value;if(this.parserConfig.input==='ascii'){ret=stringToChars(this.msgLog,string,chars);}else if(this.parserConfig.input==='hex'){ret=binaryStringToChars(this.msgLog,string,chars);}else if(this.parserConfig.input==='auto'){test=stringToChars(this.msgLog,string,testChars);if(test&&inputIsBinary(testChars)){ret=binaryStringToChars(this.msgLog,string,chars);}else{ret=stringToChars(this.msgLog,string,chars);}};return ret;};this.parseString=function(ret){var test,indicator,controlToOpen,activateState,activateStats,activateAttrs,activateMsgLog,activateGen,activateString,activatePhrases,activateTrace,activateTraceFilter,buttons,stringChars,apgStats,parser,select,list,i;indicator=false;controlToOpen=false;activateState=false;activateStats=false;activateAttrs=false;activateMsgLog=false;activateGen=false;activateString=false;activatePhrases=false;activateTrace=false;activateTraceFilter=false;buttons=this.buttons.buttons;ret['return']=false;while(true){this.lastParser='input';this.resetControls('input');this.msgLog.clear();activateMsgLog=true;controlToOpen=BUTTON_MSGLOG;apgStats=new Stats(this.apgSemCallbacks.rules);parser=new ApgLib(this.apgSemCallbacks.stringTable,this.apgSemCallbacks.rules,this.apgSemCallbacks.opcodes);if(!parser.constructed){ret.msg="parseString: ApgLib constructor failed";this.log(ret.msg);break;};parser.statsInit(apgStats);stringChars=[];test=this.convertStringToChars(stringChars);activateString=true;if(this.parserConfig.display==='hex'){buttons[BUTTON_STRING].html=tableCharsHex(stringChars);}else if(this.parserConfig.display==='ascii'){buttons[BUTTON_STRING].html=tableChars(stringChars);}else{if(charsAreAscii(stringChars)){buttons[BUTTON_STRING].html=tableChars(stringChars);}else{buttons[BUTTON_STRING].html=tableCharsHex(stringChars);}};if(this.parserConfig.phrases){list=[];for(i=0;i<this.apgSemCallbacks.rules.length;i+=1){list[i]=true;};this.ast=new Ast(list,this.apgSemCallbacks.rules,this.apgSemCallbacks.ruleIds,stringChars);parser.astInit(this.ast);};if(this.parserConfig.trace===true){this.traceParser.initChars(stringChars);this.traceParser.setFilter(this.traceParser.parseFilter,'trace',true);this.traceParser.setFilter(this.traceParser.displayFilter,'display',this.parserConfig.display);this.traceParser.maskDisplayFilter();parser.traceInit(this.traceParser);activateTrace=true;activateTraceFilter=this.parserConfig.display;};parser.stats.clear();test=parser.syntaxAnalysis(0,stringChars);activateState=true;activateStats=true;activatePhrases=this.parserConfig.phrases;buttons[BUTTON_STATE].html=parser.stateDisplay();buttons[BUTTON_STATS].html=parser.stats.display();controlToOpen=BUTTON_STATE;if(!test){ret.msg="parseString: syntaxAnalysis failed";this.log(ret.msg);break;};indicator=true;ret['return']=true;break;};buttons[BUTTON_MSGLOG].html=this.msgLog.logDisplay();this.buttons.setIndicator(IND_INPUT_SUCCESS,indicator);this.buttons.setIndicator(IND_INPUT_FAILED,!indicator);this.buttons.setIndicator(IND_GRAMMAR_SUCCESS,false);this.buttons.setIndicator(IND_GRAMMAR_FAILED,false);if(activateState){this.buttons.enable(BUTTON_STATE,true);};if(activateStats){this.buttons.enable(BUTTON_STATS,true);};if(activateMsgLog&&(this.msgLog.count()>0)){this.buttons.enable(BUTTON_MSGLOG,true);};if(activateString){this.buttons.enable(BUTTON_STRING,true);};if(activateTrace){this.buttons.enable(BUTTON_DISPLAY_TRACE,true);};if(activateTraceFilter){this.buttons.enable(BUTTON_DISPLAY_FILTER,true);};select=window.document.getElementById('select-phrases');if(activatePhrases){this.buttons.enable(BUTTON_PHRASES,true);select.innerHTML=this.phraseDropDown();}else{select.innerHTML=this.disabledPhraseHtml;};this.buttons.controlOpenP(controlToOpen,this.iframeBody,buttons[controlToOpen].html);this.buttons.enable(BUTTON_GRAMMAR_PARSE);this.buttons.enable(BUTTON_GRAMMAR_CONFIG);this.buttons.enable(BUTTON_INPUT_PARSE);this.buttons.enable(BUTTON_INPUT_CONFIG);};};function fireEvent(eventName){var event=[];switch(eventName){case 'generator':event.id=PARSE_GRAMMAR;break;case 'configure-generator':event.id=CONFIGURE_GENERATOR;break;case 'parser':event.id=PARSE_INPUT;break;case 'input-filter-trace':event.id=CONFIGURE_PARSER;break;case 'display-state':event.id=DISPLAY_PARSER_STATE;break;case 'display-stats':event.id=DISPLAY_PARSER_STATS;break;case 'display-attrs':event.id=DISPLAY_RECURSION;break;case 'display-msglog':event.id=DISPLAY_MSGLOG;break;case 'display-string':event.id=DISPLAY_STRING;break;case 'display-generated':event.id=DISPLAY_GENERATED_PARSER;break;case 'phrases':event.id=DISPLAY_PHRASE;break;case 'display-trace':event.id=DISPLAY_TRACE;break;case 'filter-trace':event.id=SET_DISPLAY_FILTER;break;case 'page-init':event.id=PAGE_INIT;break;case 'select-grammar':event.id=SELECT_GRAMMAR;break;case 'select-input':event.id=SELECT_INPUT;break;case 'popup-grammar':event.id=POPUP_GRAMMAR;break;case 'popup-string':event.id=POPUP_STRING;break;case 'popup-iframe':event.id=POPUP_IFRAME;break;case 'help':event.id=HELP;break;case 'ipv6popup':event.id=POPUP_IPV6_LIST;break;case 'reset-page':event.id=RESET_PAGE;break;default:break;};eventLoop.event(event);};eventLoop=new EventLoop();


