varg=ohm.grammars(contents).ES5;varsemantics=g.semantics();semantics.addAttribute("modifiedSource",modifiedSourceActions);semantics.addAttribute("asES5",{_nonterminal:function(children){returnisUndefined(this.modifiedSource)?this.interval.contents:this.modifiedSource}});module.exports={grammar:g,semantics:semantics,translateNonterminalCode:translateNonterminalCode}}).call(this,require("buffer").Buffer)},{buffer:4,"ohm-js":50,path:8}],3:[function(require,module,exports){"use strict";varcompiler=require("./compiler.js");functiongetUrlContent(url){varreq=newXMLHttpRequest;req.open("GET",url,false);try{req.send();if(req.status===0||req.status===200){returnreq.responseText}}catch(e){console.error("Error while loading "+url,e)}returnfalse}functiontranslateSyndicateScripts(){varscriptNodes=document.querySelectorAll('script[type="text/syndicate-js"]');varallSources=[];for(vari=0;i<scriptNodes.length;i++){varn=scriptNodes[i];varsrcUrl=n.getAttribute("src");allSources.push(srcUrl?getUrlContent(srcUrl):n.innerHTML)}varallSourceText=allSources.join("\n;\n");varoutput=compiler.compileSyndicateSource(allSourceText);varf=newFunction(output);f.call(window)}document.addEventListener("DOMContentLoaded",translateSyndicateScripts,false);module.exports=compiler},{"./compiler.js":1}],4:[function(require,module,exports){(function(global){"use strict";varbase64=require("base64-js");varieee754=require("ieee754");varisArray=require("isarray");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;Buffer.TYPED_ARRAY_SUPPORT=global.TYPED_ARRAY_SUPPORT!==undefined?global.TYPED_ARRAY_SUPPORT:typedArraySupport();exports.kMaxLength=kMaxLength();functiontypedArraySupport(){try{vararr=newUint8Array(1);arr.__proto__={__proto__:Uint8Array.prototype,foo:function(){return42}};returnarr.foo()===42&&typeofarr.subarray==="function"&&arr.subarray(1,1).byteLength===0}catch(e){returnfalse}}functionkMaxLength(){returnBuffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}functioncreateBuffer(that,length){if(kMaxLength()<length){thrownewRangeError("Invalid typed array length")}if(Buffer.TYPED_ARRAY_SUPPORT){that=newUint8Array(length);that.__proto__=Buffer.prototype}else{if(that===null){that=newBuffer(length)}that.length=length}returnthat}functionBuffer(arg,encodingOrOffset,length){if(!Buffer.TYPED_ARRAY_SUPPORT&&!(thisinstanceofBuffer)){returnnewBuffer(arg,encodingOrOffset,length)}if(typeofarg==="number"){if(typeofencodingOrOffset==="string"){thrownewError("If encoding is specified then the first argument must be a string")}returnallocUnsafe(this,arg)}returnfrom(this,arg,encodingOrOffset,length)}Buffer.poolSize=8192;Buffer._augment=function(arr){arr.__proto__=Buffer.prototype;returnarr};functionfrom(that,value,encodingOrOffset,length){if(typeofvalue==="number"){thrownewTypeError('"value" argument must not be a number')}if(typeofArrayBuffer!=="undefined"&&valueinstanceofArrayBuffer){returnfromArrayBuffer(that,value,encodingOrOffset,length)}if(typeofvalue==="string"){returnfromString(that,value,encodingOrOffset)}returnfromObject(that,value)}Buffer.from=function(value,encodingOrOffset,length){returnfrom(null,value,encodingOrOffset,length)};if(Buffer.TYPED_ARRAY_SUPPORT){Buffer.prototype.__proto__=Uint8Array.prototype;Buffer.__proto__=Uint8Array;if(typeofSymbol!=="undefined"&&Symbol.species&&Buffer[Symbol.species]===Buffer){Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:true})}}functionassertSize(size){if(typeofsize!=="number"){thrownewTypeError('"size" argument must be a number')}elseif(size<0){thrownewRangeError('"size" argument must not be negative')}}functionalloc(that,size,fill,encoding){assertSize(size);if(size<=0){returncreateBuffer(that,size)}if(fill!==undefined){returntypeofencoding==="string"?createBuffer(that,size).fill(fill,encoding):createBuffer(that,size).fill(fill)}returncreateBuffer(that,size)}Buffer.alloc=function(size,fill,encoding){returnalloc(null,size,fill,encoding)};functionallocUnsafe(that,size){assertSize(size);that=createBuffer(
if((units-=3)>-1)bytes.push(239,191,189);continue}elseif(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}codePoint=(leadSurrogate-55296<<10|codePoint-56320)+65536}elseif(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189)}leadSurrogate=null;if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}elseif(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}elseif(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}elseif(codePoint<1114112){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{thrownewError("Invalid code point")}}returnbytes}functionasciiToBytes(str){varbyteArray=[];for(vari=0;i<str.length;++i){byteArray.push(str.charCodeAt(i)&255)}returnbyteArray}functionutf16leToBytes(str,units){varc,hi,lo;varbyteArray=[];for(vari=0;i<str.length;++i){if((units-=2)<0)break;c=str.charCodeAt(i);hi=c>>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}returnbyteArray}functionbase64ToBytes(str){returnbase64.toByteArray(base64clean(str))}functionblitBuffer(src,dst,offset,length){for(vari=0;i<length;++i){if(i+offset>=dst.length||i>=src.length)break;dst[i+offset]=src[i]}returni}functionisnan(val){returnval!==val}}).call(this,typeofglobal!=="undefined"?global:typeofself!=="undefined"?self:typeofwindow!=="undefined"?window:{})},{"base64-js":5,ieee754:6,isarray:7}],5:[function(require,module,exports){"use strict";exports.byteLength=byteLength;exports.toByteArray=toByteArray;exports.fromByteArray=fromByteArray;varlookup=[];varrevLookup=[];varArr=typeofUint8Array!=="undefined"?Uint8Array:Array;varcode="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(vari=0,len=code.length;i<len;++i){lookup[i]=code[i];revLookup[code.charCodeAt(i)]=i}revLookup["-".charCodeAt(0)]=62;revLookup["_".charCodeAt(0)]=63;functionplaceHoldersCount(b64){varlen=b64.length;if(len%4>0){thrownewError("Invalid string. Length must be a multiple of 4")}returnb64[len-2]==="="?2:b64[len-1]==="="?1:0}functionbyteLength(b64){returnb64.length*3/4-placeHoldersCount(b64)}functiontoByteArray(b64){vari,j,l,tmp,placeHolders,arr;varlen=b64.length;placeHolders=placeHoldersCount(b64);arr=newArr(len*3/4-placeHolders);l=placeHolders>0?len-4:len;varL=0;for(i=0,j=0;i<l;i+=4,j+=3){tmp=revLookup[b64.charCodeAt(i)]<<18|revLookup[b64.charCodeAt(i+1)]<<12|revLookup[b64.charCodeAt(i+2)]<<6|revLookup[b64.charCodeAt(i+3)];arr[L++]=tmp>>16&255;arr[L++]=tmp>>8&255;arr[L++]=tmp&255}if(placeHolders===2){tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4;arr[L++]=tmp&255}elseif(placeHolders===1){tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2;arr[L++]=tmp>>8&255;arr[L++]=tmp&255}returnarr}functiontripletToBase64(num){returnlookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[num&63]}functionencodeChunk(uint8,start,end){vartmp;varoutput=[];for(vari=start;i<end;i+=3){tmp=(uint8[i]<<16)+(uint8[i+1]<<8)+uint8[i+2];output.push(tripletToBase64(tmp))}returnoutput.join("")}functionfromByteArray(uint8){vartmp;varlen=uint8.length;varextraBytes=len%3;varoutput="";varparts=[];varmaxChunkLength=16383;for(vari=0,len2=len-extraBytes;i<len2;i+=maxChunkLength){parts.push(encodeChunk(uint8,i,i+maxChunkLength>len2?len2:i+maxChunkLength))}if(extraBytes===1){tmp=uint8[len-1];output+=lookup[tmp>>2];output+=lookup[tmp<<4&63];output+="=="}elseif(extraBytes===2){tmp=(uint8[len-2]<<8)+uint8[len-1];output+=lookup[tmp>>10];output+=lookup[tmp>>4&63];output+=lookup[tmp<<2&63];output+="="}parts.push(output);returnparts.join("")}},{}],6:[function(require,module,exports){exports.read=function(buffer,offset,isLE,mLen,nBytes){vare,m;vareLen=nBytes*8-mLen-1;vareMax=(1<<eLen)-1;vareBias=eMax>>1;varnBits=-7;vari=isLE?nBytes-1:0;vard=isLE?-1:1;vars=buffer[offset+i];i+=
}vardetail="expected "+this.getExpectedText();returngetShortMatchErrorMessage(this.getRightmostFailurePosition(),this.state.inputStream.source,detail)})}inherits(MatchFailure,MatchResult);MatchFailure.prototype.toString=function(){return"[MatchFailure at position "+this.getRightmostFailurePosition()+"]"};MatchFailure.prototype.failed=function(){returntrue};MatchFailure.prototype.getRightmostFailurePosition=function(){returnthis.state.getRightmostFailurePosition()};MatchFailure.prototype.getRightmostFailures=function(){returnthis._failures};MatchFailure.prototype.getExpectedText=function(){varsb=newcommon.StringBuffer;varfailures=this.getRightmostFailures();failures=failures.filter(function(failure){return!failure.isFluffy()});for(varidx=0;idx<failures.length;idx++){if(idx>0){if(idx===failures.length-1){sb.append(failures.length>2?", or ":" or ")}else{sb.append(", ")}}sb.append(failures[idx].toString())}returnsb.contents()};MatchFailure.prototype.getInterval=function(){varpos=this.state.getRightmostFailurePosition();returnnewInterval(this.state.inputStream,pos,pos)};module.exports=MatchResult},{"./Interval":41,"./common":48,"./nodes":51,"./util":68,inherits:33}],43:[function(require,module,exports){"use strict";varextend=require("util-extend");functionNamespace(){}Namespace.prototype=Object.create(null);Namespace.asNamespace=function(objOrNamespace){if(objOrNamespaceinstanceofNamespace){returnobjOrNamespace}returnNamespace.createNamespace(objOrNamespace)};Namespace.createNamespace=function(optProps){returnNamespace.extend(Namespace.prototype,optProps)};Namespace.extend=function(namespace,optProps){if(namespace!==Namespace.prototype&&!(namespaceinstanceofNamespace)){thrownewTypeError("not a Namespace object: "+namespace)}varns=Object.create(namespace,{constructor:{value:Namespace,enumerable:false,writable:true,configurable:true}});returnextend(ns,optProps)};Namespace.toString=function(ns){returnObject.prototype.toString.call(ns)};module.exports=Namespace},{"util-extend":35}],44:[function(require,module,exports){"use strict";functionPosInfo(state){this.state=state;this.applicationMemoKeyStack=[];this.memo={};this.currentLeftRecursion=undefined}PosInfo.prototype={isActive:function(application){returnthis.applicationMemoKeyStack.indexOf(application.toMemoKey())>=0},enter:function(application){this.state.enter(application);this.applicationMemoKeyStack.push(application.toMemoKey())},exit:function(){this.state.exit();this.applicationMemoKeyStack.pop()},startLeftRecursion:function(headApplication,memoRec){memoRec.isLeftRecursion=true;memoRec.headApplication=headApplication;memoRec.nextLeftRecursion=this.currentLeftRecursion;this.currentLeftRecursion=memoRec;varapplicationMemoKeyStack=this.applicationMemoKeyStack;varindexOfFirstInvolvedRule=applicationMemoKeyStack.indexOf(headApplication.toMemoKey())+1;varinvolvedApplicationMemoKeys=applicationMemoKeyStack.slice(indexOfFirstInvolvedRule);memoRec.isInvolved=function(applicationMemoKey){returninvolvedApplicationMemoKeys.indexOf(applicationMemoKey)>=0};memoRec.updateInvolvedApplicationMemoKeys=function(){for(varidx=indexOfFirstInvolvedRule;idx<applicationMemoKeyStack.length;idx++){varapplicationMemoKey=applicationMemoKeyStack[idx];if(!this.isInvolved(applicationMemoKey)){involvedApplicationMemoKeys.push(applicationMemoKey)}}}},endLeftRecursion:function(){this.currentLeftRecursion=this.currentLeftRecursion.nextLeftRecursion},shouldUseMemoizedResult:function(memoRec){if(!memoRec.isLeftRecursion){returntrue}varapplicationMemoKeyStack=this.applicationMemoKeyStack;for(varidx=0;idx<applicationMemoKeyStack.length;idx++){varapplicationMemoKey=applicationMemoKeyStack[idx];if(memoRec.isInvolved(applicationMemoKey)){returnfalse}}returntrue}};module.exports=PosInfo},{}],45:[function(require,module,exports){"use strict";varSymbol=require("es6-symbol");varinherits=require("inherits");varMatchResult=require("./MatchResult");varIterationNode=require("./nodes").IterationNode;varcommon=require("./common");functionWrapper(){}Wrapper.prototype.toString=fun
}functionduplicateParameterNames(ruleName,duplicates,body){returncreateError("Duplicate parameter names in rule "+ruleName+": "+duplicates.join(","),body.definitionInterval)}functioninvalidParameter(ruleName,expr){returncreateError("Invalid parameter to rule "+ruleName+": "+expr+" has arity "+expr.getArity()+", but parameter expressions "+"must have arity 1",expr.interval)}functionapplicationOfSyntacticRuleFromLexicalContext(ruleName,applyExpr){returncreateError("Cannot apply syntactic rule "+ruleName+" from here (inside a lexical context)",applyExpr.interval)}functionkleeneExprHasNullableOperand(kleeneExpr){returncreateError("Nullable expression "+kleeneExpr.expr.interval.contents+" is not allowed inside '"+kleeneExpr.operator+"' (possible infinite loop)",kleeneExpr.expr.interval)}functioninconsistentArity(ruleName,expected,actual,expr){returncreateError("Rule "+ruleName+" involves an alternation which has inconsistent arity "+"(expected "+expected+", got "+actual+")",expr.interval)}functionduplicatePropertyNames(duplicates){returncreateError("Object pattern has duplicate property names: "+duplicates.join(", "))}functioninvalidConstructorCall(grammar,ctorName,children){returncreateError("Attempt to invoke constructor "+ctorName+" with invalid or unexpected arguments")}functionmultipleErrors(errors){varmessages=errors.map(function(e){returne.message});returncreateError(["Errors:"].concat(messages).join("\n- "),errors[0].interval)}module.exports={applicationOfSyntacticRuleFromLexicalContext:applicationOfSyntacticRuleFromLexicalContext,cannotExtendUndeclaredRule:cannotExtendUndeclaredRule,cannotOverrideUndeclaredRule:cannotOverrideUndeclaredRule,duplicateGrammarDeclaration:duplicateGrammarDeclaration,duplicateParameterNames:duplicateParameterNames,duplicatePropertyNames:duplicatePropertyNames,duplicateRuleDeclaration:duplicateRuleDeclaration,inconsistentArity:inconsistentArity,intervalSourcesDontMatch:intervalSourcesDontMatch,invalidConstructorCall:invalidConstructorCall,invalidParameter:invalidParameter,grammarSyntaxError:grammarSyntaxError,kleeneExprHasNullableOperand:kleeneExprHasNullableOperand,undeclaredGrammar:undeclaredGrammar,undeclaredRule:undeclaredRule,wrongNumberOfArguments:wrongNumberOfArguments,wrongNumberOfParameters:wrongNumberOfParameters,throwErrors:function(errors){if(errors.length===1){throwerrors[0]}if(errors.length>1){throwmultipleErrors(errors)}}}},{"./Namespace":43}],50:[function(require,module,exports){"use strict";varBuilder=require("./Builder");varGrammar=require("./Grammar");varNamespace=require("./Namespace");varcommon=require("./common");varerrors=require("./errors");varpexprs=require("./pexprs");varutil=require("./util");varisBuffer=require("is-buffer");varohmGrammar;vardocumentInterface={querySelector:function(sel){returndocument.querySelector(sel)},querySelectorAll:function(sel){returndocument.querySelectorAll(sel)}};functionisElement(obj){return!!(obj&&obj.nodeType===1)}functionisUndefined(obj){returnobj===void0}varMAX_ARRAY_INDEX=Math.pow(2,53)-1;functionisArrayLike(obj){if(obj==null){returnfalse}varlength=obj.length;returntypeoflength==="number"&&length>=0&&length<=MAX_ARRAY_INDEX}functionload(url){varreq=newXMLHttpRequest;req.open("GET",url,false);try{req.send();if(req.status===0||req.status===200){returnreq.responseText}}catch(e){}thrownewError("unable to load url "+url)}functionbuildGrammar(match,namespace,optOhmGrammarForTesting){varbuilder=newBuilder;vardecl;varcurrentRuleName;varcurrentRuleFormals;varoverriding=false;varmetaGrammar=optOhmGrammarForTesting||ohmGrammar;varhelpers=metaGrammar.semantics().addOperation("visit",{Grammar:function(n,s,open,rs,close){vargrammarName=n.visit();decl=builder.newGrammar(grammarName,namespace);s.visit();rs.visit();varg=decl.build();g.definitionInterval=this.interval.trimmed();if(grammarNameinnamespace){throwerrors.duplicateGrammarDeclaration(g,namespace)}namespace[grammarName]=g;returng},SuperGrammar:function(_,n){varsuperGrammarName=n.visit();if(superGrammarName==="null"){decl.with
};pexprs.Seq.prototype.introduceParams=function(formals){this.factors.forEach(function(factor,idx,factors){factors[idx]=factor.introduceParams(formals)});returnthis};pexprs.Iter.prototype.introduceParams=pexprs.Not.prototype.introduceParams=pexprs.Lookahead.prototype.introduceParams=pexprs.Lex.prototype.introduceParams=function(formals){this.expr=this.expr.introduceParams(formals);returnthis};pexprs.Apply.prototype.introduceParams=function(formals){varindex=formals.indexOf(this.ruleName);if(index>=0){if(this.args.length>0){thrownewError("Parameterized rules cannot be passed as arguments to another rule.")}returnnewpexprs.Param(index)}else{this.args.forEach(function(arg,idx,args){args[idx]=arg.introduceParams(formals)});returnthis}}},{"./common":48,"./pexprs":67}],60:[function(require,module,exports){"use strict";varcommon=require("./common");varpexprs=require("./pexprs");pexprs.PExpr.prototype.isNullable=function(grammar){returnthis._isNullable(grammar,Object.create(null))};pexprs.PExpr.prototype._isNullable=common.abstract;pexprs.any._isNullable=pexprs.Range.prototype._isNullable=pexprs.Param.prototype._isNullable=pexprs.Plus.prototype._isNullable=pexprs.UnicodeChar.prototype._isNullable=function(grammar,memo){returnfalse};pexprs.end._isNullable=function(grammar,memo){returntrue};pexprs.Terminal.prototype._isNullable=function(grammar,memo){if(typeofthis.obj==="string"){returnthis.obj===""}else{returnfalse}};pexprs.Alt.prototype._isNullable=function(grammar,memo){returnthis.terms.length===0||this.terms.some(function(term){returnterm._isNullable(grammar,memo)})};pexprs.Seq.prototype._isNullable=function(grammar,memo){returnthis.factors.every(function(factor){returnfactor._isNullable(grammar,memo)})};pexprs.Star.prototype._isNullable=pexprs.Opt.prototype._isNullable=pexprs.Not.prototype._isNullable=pexprs.Lookahead.prototype._isNullable=function(grammar,memo){returntrue};pexprs.Lex.prototype._isNullable=function(grammar,memo){returnthis.expr._isNullable(grammar,memo)};pexprs.Apply.prototype._isNullable=function(grammar,memo){varkey=this.toMemoKey();if(!Object.prototype.hasOwnProperty.call(memo,key)){varbody=grammar.ruleBodies[this.ruleName];varinlined=body.substituteParams(this.args);memo[key]=false;memo[key]=inlined._isNullable(grammar,memo)}returnmemo[key]}},{"./common":48,"./pexprs":67}],61:[function(require,module,exports){"use strict";varcommon=require("./common");varpexprs=require("./pexprs");functionescapeString(str){varoutput=JSON.stringify(str);output=output.replace(/[\u2028\u2029]/g,function(char,pos,str){varhex=char.codePointAt(0).toString(16);return"\\u"+"0000".slice(hex.length)+hex});returnoutput}functiongetIntervalInfo(expr,grammarInterval){if(expr.interval&&grammarInterval){varadjusted=expr.interval.relativeTo(grammarInterval);varstart=adjusted.startIdx;varend=adjusted.endIdx;return".withInterval(decl.sourceInterval("+start+", "+end+"))"}return""}pexprs.PExpr.prototype.outputRecipe=common.abstract;pexprs.any.outputRecipe=function(sb,formals,grammarInterval){thrownewError("should never output a recipe for `any` expression")};pexprs.end.outputRecipe=function(sb,formals,grammarInterval){thrownewError("should never output a recipe for `end` expression")};pexprs.Terminal.prototype.outputRecipe=function(sb,formals,grammarInterval){sb.append("this.terminal(");sb.append(typeofthis.obj==="string"?escapeString(this.obj):""+this.obj);sb.append(")"+getIntervalInfo(this,grammarInterval))};pexprs.Range.prototype.outputRecipe=function(sb,formals,grammarInterval){sb.append("this.range(");sb.append(JSON.stringify(this.from));sb.append(", ");sb.append(JSON.stringify(this.to));sb.append(")"+getIntervalInfo(this,grammarInterval))};pexprs.Param.prototype.outputRecipe=function(sb,formals,grammarInterval){sb.append("this.param("+this.index+")"+getIntervalInfo(this,grammarInterval))};pexprs.Alt.prototype.outputRecipe=function(sb,formals,grammarInterval){sb.append("this.alt(");for(varidx=0;idx<this.terms.length;idx++){if(idx>0){sb.append(", ")}this.terms[idx].outputRecipe(sb,formals,grammar