From 6a5f786b6be9b77b085e074f004a2801bc0bc8f5 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Mon, 1 Aug 2016 16:46:13 -0400 Subject: [PATCH] Update --- dist/syndicatecompiler.js | 5 +- dist/syndicatecompiler.min.js | 2 +- examples/location/index.expanded.js | 4 +- examples/todo/index.expanded.js | 50 +++++++++---------- examples/two-buyer-protocol/index.expanded.js | 4 +- 5 files changed, 33 insertions(+), 32 deletions(-) diff --git a/dist/syndicatecompiler.js b/dist/syndicatecompiler.js index 846a5e7..fa66c69 100644 --- a/dist/syndicatecompiler.js +++ b/dist/syndicatecompiler.js @@ -368,7 +368,7 @@ semantics.addOperation('buildSubscription(mode)', { return ES5.translateNonterminalCode(children, function(n) { return n.buildSubscription(self.args.mode); - }); + }) || this.interval.contents; } }); @@ -485,7 +485,8 @@ function translateNonterminalCode(children, nodeTranslator) { var modifiedSourceActions = { _nonterminal: function(children) { return translateNonterminalCode(children, - function(n) { return n.modifiedSource; }); + function(n) { return n.modifiedSource; }) + || this.interval.contents; }, _iter: function(_) { throw new Error('_iter semantic action should never be hit'); diff --git a/dist/syndicatecompiler.min.js b/dist/syndicatecompiler.min.js index 9220a91..aa87590 100644 --- a/dist/syndicatecompiler.min.js +++ b/dist/syndicatecompiler.min.js @@ -1,4 +1,4 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.SyndicateCompiler=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o1){switch(this.args.mode){case"pattern":return rhsExpr.buildSubscription(this.args.mode);case"instantiated":return lhsExpr.buildSubscription(this.args.mode);case"projection":return"(Syndicate._$("+JSON.stringify(i.slice(1))+","+rhsExpr.buildSubscription(this.args.mode)+"))";default:throw new Error("Unexpected buildSubscription mode "+this.args.mode)}}else{return lhsExpr.buildSubscription(this.args.mode)+_assignmentOperator.buildSubscription(this.args.mode)+rhsExpr.buildSubscription(this.args.mode)}},identifier:function(_name){var i=this.interval.contents;if(i[0]==="$"&&i.length>1){switch(this.args.mode){case"pattern":return"_";case"instantiated":return i.slice(1);case"projection":return"(Syndicate._$("+JSON.stringify(i.slice(1))+"))";default:throw new Error("Unexpected buildSubscription mode "+this.args.mode)}}else{return i}},_terminal:function(){return undefined},_nonterminal:function(children){var self=this;return ES5.translateNonterminalCode(children,function(n){return n.buildSubscription(self.args.mode)})}});semantics.addAttribute("bindings",{_default:function(children){var result=[];this.pushBindings(result);return result}});semantics.addOperation("pushBindings(accumulator)",{identifier:function(_name){var i=this.interval.contents;if(i[0]==="$"&&i.length>1){this.args.accumulator.push(i.slice(1))}},_terminal:function(){},_nonterminal:function(children){var self=this;children.forEach(function(c){c.pushBindings(self.args.accumulator)})}});function compileSyndicateSource(inputSource,onError){var parseResult=grammar.match(inputSource);if(parseResult.failed()){if(onError){return onError(parseResult.message,parseResult)}else{console.error(parseResult.message);return false}}else{return'"use strict";\n'+semantics(parseResult).asES5}}module.exports.grammar=grammar;module.exports.semantics=semantics;module.exports.compileSyndicateSource=compileSyndicateSource}).call(this,require("buffer").Buffer)},{"./es5.js":2,buffer:4,"ohm-js":50,path:8}],2:[function(require,module,exports){(function(Buffer){"use strict";var path=require("path");var ohm=require("ohm-js");function isUndefined(x){return x===void 0}function flattenIterNodes(nodes){var result=[];for(var i=0;i1){switch(this.args.mode){case"pattern":return rhsExpr.buildSubscription(this.args.mode);case"instantiated":return lhsExpr.buildSubscription(this.args.mode);case"projection":return"(Syndicate._$("+JSON.stringify(i.slice(1))+","+rhsExpr.buildSubscription(this.args.mode)+"))";default:throw new Error("Unexpected buildSubscription mode "+this.args.mode)}}else{return lhsExpr.buildSubscription(this.args.mode)+_assignmentOperator.buildSubscription(this.args.mode)+rhsExpr.buildSubscription(this.args.mode)}},identifier:function(_name){var i=this.interval.contents;if(i[0]==="$"&&i.length>1){switch(this.args.mode){case"pattern":return"_";case"instantiated":return i.slice(1);case"projection":return"(Syndicate._$("+JSON.stringify(i.slice(1))+"))";default:throw new Error("Unexpected buildSubscription mode "+this.args.mode)}}else{return i}},_terminal:function(){return undefined},_nonterminal:function(children){var self=this;return ES5.translateNonterminalCode(children,function(n){return n.buildSubscription(self.args.mode)})||this.interval.contents}});semantics.addAttribute("bindings",{_default:function(children){var result=[];this.pushBindings(result);return result}});semantics.addOperation("pushBindings(accumulator)",{identifier:function(_name){var i=this.interval.contents;if(i[0]==="$"&&i.length>1){this.args.accumulator.push(i.slice(1))}},_terminal:function(){},_nonterminal:function(children){var self=this;children.forEach(function(c){c.pushBindings(self.args.accumulator)})}});function compileSyndicateSource(inputSource,onError){var parseResult=grammar.match(inputSource);if(parseResult.failed()){if(onError){return onError(parseResult.message,parseResult)}else{console.error(parseResult.message);return false}}else{return'"use strict";\n'+semantics(parseResult).asES5}}module.exports.grammar=grammar;module.exports.semantics=semantics;module.exports.compileSyndicateSource=compileSyndicateSource}).call(this,require("buffer").Buffer)},{"./es5.js":2,buffer:4,"ohm-js":50,path:8}],2:[function(require,module,exports){(function(Buffer){"use strict";var path=require("path");var ohm=require("ohm-js");function isUndefined(x){return x===void 0}function flattenIterNodes(nodes){var result=[];for(var i=0;i=kMaxLength()){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+kMaxLength().toString(16)+" bytes")}return length|0}function SlowBuffer(length){if(+length!=length){length=0}return Buffer.alloc(+length)}Buffer.isBuffer=function isBuffer(b){return!!(b!=null&&b._isBuffer)};Buffer.compare=function compare(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError("Arguments must be Buffers")}if(a===b)return 0;var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase)return utf8ToBytes(string).length;encoding=(""+encoding).toLowerCase();loweredCase=true}}}Buffer.byteLength=byteLength;function slowToString(encoding,start,end){var loweredCase=false;if(start===undefined||start<0){start=0}if(start>this.length){return""}if(end===undefined||end>this.length){end=this.length}if(end<=0){return""}end>>>=0;start>>>=0;if(end<=start){return""}if(!encoding)encoding="utf8";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"binary":return binarySlice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}}Buffer.prototype._isBuffer=true;function swap(b,n,m){var i=b[n];b[n]=b[m];b[m]=i}Buffer.prototype.swap16=function swap16(){var len=this.length;if(len%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var i=0;i0){str=this.toString("hex",0,max).match(/.{2}/g).join(" ");if(this.length>max)str+=" ... "}return""};Buffer.prototype.compare=function compare(target,start,end,thisStart,thisEnd){if(!Buffer.isBuffer(target)){throw new TypeError("Argument must be a Buffer")}if(start===undefined){start=0}if(end===undefined){end=target?target.length:0}if(thisStart===undefined){thisStart=0}if(thisEnd===undefined){thisEnd=this.length}if(start<0||end>target.length||thisStart<0||thisEnd>this.length){throw new RangeError("out of range index")}if(thisStart>=thisEnd&&start>=end){return 0}if(thisStart>=thisEnd){return-1}if(start>=end){return 1}start>>>=0;end>>>=0;thisStart>>>=0;thisEnd>>>=0;if(this===target)return 0;var x=thisEnd-thisStart;var y=end-start;var len=Math.min(x,y);var thisCopy=this.slice(thisStart,thisEnd);var targetCopy=target.slice(start,end);for(var i=0;i2147483647){byteOffset=2147483647}else if(byteOffset<-2147483648){byteOffset=-2147483648}byteOffset>>=0;if(this.length===0)return-1;if(byteOffset>=this.length)return-1;if(byteOffset<0)byteOffset=Math.max(this.length+byteOffset,0);if(typeof val==="string"){val=Buffer.from(val,encoding)}if(Buffer.isBuffer(val)){if(val.length===0){return-1}return arrayIndexOf(this,val,byteOffset,encoding)}if(typeof val==="number"){if(Buffer.TYPED_ARRAY_SUPPORT&&Uint8Array.prototype.indexOf==="function"){return Uint8Array.prototype.indexOf.call(this,val,byteOffset)}return arrayIndexOf(this,[val],byteOffset,encoding)}throw new TypeError("val must be string, number or Buffer")};Buffer.prototype.includes=function includes(val,byteOffset,encoding){return this.indexOf(val,byteOffset,encoding)!==-1};function hexWrite(buf,string,offset,length){offset=Number(offset)||0;var remaining=buf.length-offset;if(!length){length=remaining}else{length=Number(length);if(length>remaining){length=remaining}}var strLen=string.length;if(strLen%2!==0)throw new Error("Invalid hex string");if(length>strLen/2){length=strLen/2}for(var i=0;iremaining)length=remaining;if(string.length>0&&(length<0||offset<0)||offset>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!encoding)encoding="utf8";var loweredCase=false;for(;;){switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"binary":return binaryWrite(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase();loweredCase=true}}};Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);var res=[];var i=start;while(i239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end){var secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:if(firstByte<128){codePoint=firstByte}break;case 2:secondByte=buf[i+1];if((secondByte&192)===128){tempCodePoint=(firstByte&31)<<6|secondByte&63;if(tempCodePoint>127){codePoint=tempCodePoint}}break;case 3:secondByte=buf[i+1];thirdByte=buf[i+2];if((secondByte&192)===128&&(thirdByte&192)===128){tempCodePoint=(firstByte&15)<<12|(secondByte&63)<<6|thirdByte&63;if(tempCodePoint>2047&&(tempCodePoint<55296||tempCodePoint>57343)){codePoint=tempCodePoint}}break;case 4:secondByte=buf[i+1];thirdByte=buf[i+2];fourthByte=buf[i+3];if((secondByte&192)===128&&(thirdByte&192)===128&&(fourthByte&192)===128){tempCodePoint=(firstByte&15)<<18|(secondByte&63)<<12|(thirdByte&63)<<6|fourthByte&63;if(tempCodePoint>65535&&tempCodePoint<1114112){codePoint=tempCodePoint}}}}if(codePoint===null){codePoint=65533;bytesPerSequence=1}else if(codePoint>65535){codePoint-=65536;res.push(codePoint>>>10&1023|55296);codePoint=56320|codePoint&1023}res.push(codePoint);i+=bytesPerSequence}return decodeCodePointsArray(res)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,codePoints)}var res="";var i=0;while(ilen)end=len;var out="";for(var i=start;ilen){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(endlength)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i0&&(mul*=256)){val+=this[offset+--byteLength]*mul}return val};Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function readIntLE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset|0;byteLength=byteLength|0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256)){val+=this[offset+--i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function readInt8(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function readFloatLE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||valuebuf.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;byteLength=byteLength|0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var mul=1;var i=0;this[offset]=value&255;while(++i=0&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,1,255,0);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);this[offset]=value&255;return offset+1};function objectWriteUInt16(buf,value,offset,littleEndian){if(value<0)value=65535+value+1;for(var i=0,j=Math.min(buf.length-offset,2);i>>(littleEndian?i:1-i)*8}}Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8}else{objectWriteUInt16(this,value,offset,true)}return offset+2};Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value&255}else{objectWriteUInt16(this,value,offset,false)}return offset+2};function objectWriteUInt32(buf,value,offset,littleEndian){if(value<0)value=4294967295+value+1;for(var i=0,j=Math.min(buf.length-offset,4);i>>(littleEndian?i:3-i)*8&255}}Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value&255}else{objectWriteUInt32(this,value,offset,true)}return offset+4};Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255}else{objectWriteUInt32(this,value,offset,false)}return offset+4};Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0;var mul=1;var sub=0;this[offset]=value&255;while(++i>0)-sub&255}return offset+byteLength};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset|0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1;var mul=1;var sub=0;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){if(value<0&&sub===0&&this[offset+i+1]!==0){sub=1}this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);if(value<0)value=255+value+1;this[offset]=value&255;return offset+1};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8}else{objectWriteUInt16(this,value,offset,true)}return offset+2};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value&255}else{objectWriteUInt16(this,value,offset,false)}return offset+2};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value&255;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24}else{objectWriteUInt32(this,value,offset,true)}return offset+4};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset|0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255}else{objectWriteUInt32(this,value,offset,false)}return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){if(!noAssert){checkIEEE754(buf,value,offset,4,3.4028234663852886e38,-3.4028234663852886e38)}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){if(!noAssert){checkIEEE754(buf,value,offset,8,1.7976931348623157e308,-1.7976931348623157e308)}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function copy(target,targetStart,start,end){if(!start)start=0;if(!end&&end!==0)end=this.length;if(targetStart>=target.length)targetStart=target.length;if(!targetStart)targetStart=0;if(end>0&&end=this.length)throw new RangeError("sourceStart out of bounds");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-targetStart=0;i--){target[i+targetStart]=this[i+start]}}else if(len<1e3||!Buffer.TYPED_ARRAY_SUPPORT){for(i=0;i>>0;end=end===undefined?this.length:end>>>0;if(!val)val=0;var i;if(typeof val==="number"){for(i=start;i55295&&codePoint<57344){if(!leadSurrogate){if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(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}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189)}leadSurrogate=null;if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<1114112){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){ for(var i=0;i=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function isnan(val){return val!==val}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"base64-js":5,ieee754:6,isarray:7}],5:[function(require,module,exports){"use strict";exports.toByteArray=toByteArray;exports.fromByteArray=fromByteArray;var lookup=[];var revLookup=[];var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;function init(){var code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var i=0,len=code.length;i0){throw new Error("Invalid string. Length must be a multiple of 4")}placeHolders=b64[len-2]==="="?2:b64[len-1]==="="?1:0;arr=new Arr(len*3/4-placeHolders);l=placeHolders>0?len-4:len;var L=0;for(i=0,j=0;i>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}else if(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}return arr}function tripletToBase64(num){return lookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[num&63]}function encodeChunk(uint8,start,end){var tmp;var output=[];for(var i=start;ilen2?len2:i+maxChunkLength))}if(extraBytes===1){tmp=uint8[len-1];output+=lookup[tmp>>2];output+=lookup[tmp<<4&63];output+="=="}else if(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);return parts.join("")}},{}],6:[function(require,module,exports){exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var nBits=-7;var i=isLE?nBytes-1:0;var d=isLE?-1:1;var s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8){}m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8){}if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0;var i=isLE?0:nBytes-1;var d=isLE?1:-1;var s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8){}e=e<0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8){}buffer[offset+i-d]|=s*128}},{}],7:[function(require,module,exports){var toString={}.toString;module.exports=Array.isArray||function(arr){return toString.call(arr)=="[object Array]"}},{}],8:[function(require,module,exports){(function(process){function normalizeArray(parts,allowAboveRoot){var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if(last==="."){parts.splice(i,1)}else if(last===".."){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot){for(;up--;up){parts.unshift("..")}}return parts}var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var splitPath=function(filename){return splitPathRe.exec(filename).slice(1)};exports.resolve=function(){var resolvedPath="",resolvedAbsolute=false;for(var i=arguments.length-1;i>=-1&&!resolvedAbsolute;i--){var path=i>=0?arguments[i]:process.cwd();if(typeof path!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!path){continue}resolvedPath=path+"/"+resolvedPath;resolvedAbsolute=path.charAt(0)==="/"}resolvedPath=normalizeArray(filter(resolvedPath.split("/"),function(p){return!!p}),!resolvedAbsolute).join("/");return(resolvedAbsolute?"/":"")+resolvedPath||"."};exports.normalize=function(path){var isAbsolute=exports.isAbsolute(path),trailingSlash=substr(path,-1)==="/";path=normalizeArray(filter(path.split("/"),function(p){return!!p}),!isAbsolute).join("/");if(!path&&!isAbsolute){path="."}if(path&&trailingSlash){path+="/"}return(isAbsolute?"/":"")+path};exports.isAbsolute=function(path){return path.charAt(0)==="/"};exports.join=function(){var paths=Array.prototype.slice.call(arguments,0);return exports.normalize(filter(paths,function(p,index){if(typeof p!=="string"){throw new TypeError("Arguments to path.join must be strings")}return p}).join("/"))};exports.relative=function(from,to){from=exports.resolve(from).substr(1);to=exports.resolve(to).substr(1);function trim(arr){var start=0;for(;start=0;end--){if(arr[end]!=="")break}if(start>end)return[];return arr.slice(start,end-start+1)}var fromParts=trim(from.split("/"));var toParts=trim(to.split("/"));var length=Math.min(fromParts.length,toParts.length);var samePartsLength=length;for(var i=0;i1){for(var i=1;i\n = NonemptyListOf\n | EmptyListOf\n\n NonemptyListOf\n = elem (sep elem)*\n\n EmptyListOf\n = /* nothing */\n\n listOf\n = nonemptyListOf\n | emptyListOf\n\n nonemptyListOf\n = elem (sep elem)*\n\n emptyListOf\n = /* nothing */\n\n}'},"BuiltInRules",null,null,{alnum:["define",{sourceInterval:[18,78]},"an alpha-numeric character",[],["alt",{sourceInterval:[60,78]},["app",{sourceInterval:[60,66]},"letter",[]],["app",{sourceInterval:[73,78]},"digit",[]]]],letter:["define",{sourceInterval:[82,142]},"a letter",[],["alt",{sourceInterval:[107,142]},["app",{sourceInterval:[107,112]},"lower",[]],["app",{sourceInterval:[119,124]},"upper",[]],["app",{sourceInterval:[131,142]},"unicodeLtmo",[]]]],digit:["define",{sourceInterval:[146,177]},"a digit",[],["range",{sourceInterval:[169,177]},"0","9"]],hexDigit:["define",{sourceInterval:[181,254]},"a hexadecimal digit",[],["alt",{sourceInterval:[219,254]},["app",{sourceInterval:[219,224]},"digit",[]],["range",{sourceInterval:[231,239]},"a","f"],["range",{sourceInterval:[246,254]},"A","F"]]],ListOf:["define",{sourceInterval:[258,336]},null,["elem","sep"],["alt",{sourceInterval:[282,336]},["app",{sourceInterval:[282,307]},"NonemptyListOf",[["param",{},0],["param",{},1]]],["app",{sourceInterval:[314,336]},"EmptyListOf",[["param",{},0],["param",{},1]]]]],NonemptyListOf:["define",{sourceInterval:[340,388]},null,["elem","sep"],["seq",{sourceInterval:[372,388]},["param",{},0],["star",{sourceInterval:[377,388]},["seq",{sourceInterval:[378,386]},["param",{},1],["param",{},0]]]]],EmptyListOf:["define",{sourceInterval:[392,434]},null,["elem","sep"],["seq",{sourceInterval:[438,438]}]],listOf:["define",{sourceInterval:[438,516]},null,["elem","sep"],["alt",{sourceInterval:[462,516]},["app",{sourceInterval:[462,487]},"nonemptyListOf",[["param",{},0],["param",{},1]]],["app",{sourceInterval:[494,516]},"emptyListOf",[["param",{},0],["param",{},1]]]]],nonemptyListOf:["define",{sourceInterval:[520,568]},null,["elem","sep"],["seq",{sourceInterval:[552,568]},["param",{},0],["star",{sourceInterval:[557,568]},["seq",{sourceInterval:[558,566]},["param",{},1],["param",{},0]]]]],emptyListOf:["define",{sourceInterval:[572,614]},null,["elem","sep"],["seq",{sourceInterval:[616,616]}]]}])},{"..":50}],11:[function(require,module,exports){var ohm=require("..");module.exports=ohm.makeRecipe(["grammar",{source:'Ohm {\n\n Grammars\n = Grammar*\n\n Grammar\n = ident SuperGrammar? "{" Rule* "}"\n\n SuperGrammar\n = "<:" ident\n\n Rule\n = ident Formals? ruleDescr? "=" RuleBody -- define\n | ident Formals? ":=" RuleBody -- override\n | ident Formals? "+=" RuleBody -- extend\n\n RuleBody\n = "|"? NonemptyListOf\n\n TopLevelTerm\n = Seq caseName -- inline\n | Seq\n\n Formals\n = "<" ListOf ">"\n\n Params\n = "<" ListOf ">"\n\n Alt\n = NonemptyListOf\n\n Seq\n = Iter*\n\n Iter\n = Pred "*" -- star\n | Pred "+" -- plus\n | Pred "?" -- opt\n | Pred\n\n Pred\n = "~" Lex -- not\n | "&" Lex -- lookahead\n | Lex\n\n Lex\n = "#" Base -- lex\n | Base\n\n Base\n = ident Params? ~(ruleDescr? "=" | ":=" | "+=") -- application\n | terminal ".." terminal -- range\n | terminal -- terminal\n | "(" Alt ")" -- paren\n\n ruleDescr (a rule description)\n = "(" ruleDescrText ")"\n\n ruleDescrText\n = (~")" any)*\n\n caseName\n = "--" (~"\\n" space)* name (~"\\n" space)* ("\\n" | &"}")\n\n name (a name)\n = nameFirst nameRest*\n\n nameFirst\n = "_"\n | letter\n\n nameRest\n = "_"\n | alnum\n\n ident (an identifier)\n = name\n\n terminal\n = "\\"" terminalChar* "\\""\n\n terminalChar\n = escapeChar\n | ~"\\\\" ~"\\"" ~"\\n" any\n\n escapeChar (an escape sequence)\n = "\\\\\\\\" -- backslash\n | "\\\\\\"" -- doubleQuote\n | "\\\\\\\'" -- singleQuote\n | "\\\\b" -- backspace\n | "\\\\n" -- lineFeed\n | "\\\\r" -- carriageReturn\n | "\\\\t" -- tab\n | "\\\\u" hexDigit hexDigit hexDigit hexDigit -- unicodeEscape\n | "\\\\x" hexDigit hexDigit -- hexEscape\n\n space\n += comment\n\n comment\n = "//" (~"\\n" any)* "\\n" -- singleLine\n | "/*" (~"*/" any)* "*/" -- multiLine\n\n tokens = token*\n\n token = caseName | comment | ident | operator | punctuation | terminal | any\n\n operator = "<:" | "=" | ":=" | "+=" | "*" | "+" | "?" | "~" | "&"\n\n punctuation = "<" | ">" | "," | "--"\n}'},"Ohm",null,"Grammars",{Grammars:["define",{sourceInterval:[9,32]},null,[],["star",{sourceInterval:[24,32]},["app",{sourceInterval:[24,31]},"Grammar",[]]]],Grammar:["define",{sourceInterval:[36,83]},null,[],["seq",{sourceInterval:[50,83]},["app",{sourceInterval:[50,55]},"ident",[]],["opt",{sourceInterval:[56,69]},["app",{sourceInterval:[56,68]},"SuperGrammar",[]]],["terminal",{sourceInterval:[70,73]},"{"],["star",{sourceInterval:[74,79]},["app",{sourceInterval:[74,78]},"Rule",[]]],["terminal",{sourceInterval:[80,83]},"}"]]],SuperGrammar:["define",{sourceInterval:[87,116]},null,[],["seq",{sourceInterval:[106,116]},["terminal",{sourceInterval:[106,110]},"<:"],["app",{sourceInterval:[111,116]},"ident",[]]]],Rule_define:["define",{sourceInterval:[131,181]},null,[],["seq",{sourceInterval:[131,170]},["app",{sourceInterval:[131,136]},"ident",[]],["opt",{sourceInterval:[137,145]},["app",{sourceInterval:[137,144]},"Formals",[]]],["opt",{sourceInterval:[146,156]},["app",{sourceInterval:[146,155]},"ruleDescr",[]]],["terminal",{sourceInterval:[157,160]},"="],["app",{sourceInterval:[162,170]},"RuleBody",[]]]],Rule_override:["define",{sourceInterval:[188,240]},null,[],["seq",{sourceInterval:[188,227]},["app",{sourceInterval:[188,193]},"ident",[]],["opt",{sourceInterval:[194,202]},["app",{sourceInterval:[194,201]},"Formals",[]]],["terminal",{sourceInterval:[214,218]},":="],["app",{sourceInterval:[219,227]},"RuleBody",[]]]],Rule_extend:["define",{sourceInterval:[247,297]},null,[],["seq",{sourceInterval:[247,286]},["app",{sourceInterval:[247,252]},"ident",[]],["opt",{sourceInterval:[253,261]},["app",{sourceInterval:[253,260]},"Formals",[]]],["terminal",{sourceInterval:[273,277]},"+="],["app",{sourceInterval:[278,286]},"RuleBody",[]]]],Rule:["define",{sourceInterval:[120,297]},null,[],["alt",{sourceInterval:[131,297]},["app",{sourceInterval:[131,170]},"Rule_define",[]],["app",{sourceInterval:[188,227]},"Rule_override",[]],["app",{sourceInterval:[247,286]},"Rule_extend",[]]]],RuleBody:["define",{sourceInterval:[301,354]},null,[],["seq",{sourceInterval:[316,354]},["opt",{sourceInterval:[316,320]},["terminal",{sourceInterval:[316,319]},"|"]],["app",{sourceInterval:[321,354]},"NonemptyListOf",[["app",{sourceInterval:[336,348]},"TopLevelTerm",[]],["terminal",{sourceInterval:[350,353]},"|"]]]]],TopLevelTerm_inline:["define",{sourceInterval:[377,400]},null,[],["seq",{sourceInterval:[377,389]},["app",{sourceInterval:[377,380]},"Seq",[]],["app",{sourceInterval:[381,389]},"caseName",[]]]],TopLevelTerm:["define",{sourceInterval:[358,410]},null,[],["alt",{sourceInterval:[377,410]},["app",{sourceInterval:[377,389]},"TopLevelTerm_inline",[]],["app",{sourceInterval:[407,410]},"Seq",[]]]],Formals:["define",{sourceInterval:[414,454]},null,[],["seq",{sourceInterval:[428,454]},["terminal",{sourceInterval:[428,431]},"<"],["app",{sourceInterval:[432,450]},"ListOf",[["app",{sourceInterval:[439,444]},"ident",[]],["terminal",{sourceInterval:[446,449]},","]]],["terminal",{sourceInterval:[451,454]},">"]]],Params:["define",{sourceInterval:[458,495]},null,[],["seq",{sourceInterval:[471,495]},["terminal",{sourceInterval:[471,474]},"<"],["app",{sourceInterval:[475,491]},"ListOf",[["app",{sourceInterval:[482,485]},"Seq",[]],["terminal",{sourceInterval:[487,490]},","]]],["terminal",{sourceInterval:[492,495]},">"]]],Alt:["define",{sourceInterval:[499,533]},null,[],["app",{sourceInterval:[509,533]},"NonemptyListOf",[["app",{sourceInterval:[524,527]},"Seq",[]],["terminal",{sourceInterval:[529,532]},"|"]]]],Seq:["define",{sourceInterval:[537,552]},null,[],["star",{sourceInterval:[547,552]},["app",{sourceInterval:[547,551]},"Iter",[]]]],Iter_star:["define",{sourceInterval:[567,584]},null,[],["seq",{sourceInterval:[567,575]},["app",{sourceInterval:[567,571]},"Pred",[]],["terminal",{sourceInterval:[572,575]},"*"]]],Iter_plus:["define",{sourceInterval:[591,608]},null,[],["seq",{sourceInterval:[591,599]},["app",{sourceInterval:[591,595]},"Pred",[]],["terminal",{sourceInterval:[596,599]},"+"]]],Iter_opt:["define",{sourceInterval:[615,631]},null,[],["seq",{sourceInterval:[615,623]},["app",{sourceInterval:[615,619]},"Pred",[]],["terminal",{sourceInterval:[620,623]},"?"]]],Iter:["define",{sourceInterval:[556,642]},null,[],["alt",{sourceInterval:[567,642]},["app",{sourceInterval:[567,575]},"Iter_star",[]],["app",{sourceInterval:[591,599]},"Iter_plus",[]],["app",{sourceInterval:[615,623]},"Iter_opt",[]],["app",{sourceInterval:[638,642]},"Pred",[]]]],Pred_not:["define",{sourceInterval:[657,672]},null,[],["seq",{sourceInterval:[657,664]},["terminal",{sourceInterval:[657,660]},"~"],["app",{sourceInterval:[661,664]},"Lex",[]]]],Pred_lookahead:["define",{sourceInterval:[679,700]},null,[],["seq",{sourceInterval:[679,686]},["terminal",{sourceInterval:[679,682]},"&"],["app",{sourceInterval:[683,686]},"Lex",[]]]],Pred:["define",{sourceInterval:[646,710]},null,[],["alt",{sourceInterval:[657,710]},["app",{sourceInterval:[657,664]},"Pred_not",[]],["app",{sourceInterval:[679,686]},"Pred_lookahead",[]],["app",{sourceInterval:[707,710]},"Lex",[]]]],Lex_lex:["define",{sourceInterval:[724,740]},null,[],["seq",{sourceInterval:[724,732]},["terminal",{sourceInterval:[724,727]},"#"],["app",{sourceInterval:[728,732]},"Base",[]]]],Lex:["define",{sourceInterval:[714,751]},null,[],["alt",{sourceInterval:[724,751]},["app",{sourceInterval:[724,732]},"Lex_lex",[]],["app",{sourceInterval:[747,751]},"Base",[]]]],Base_application:["define",{sourceInterval:[766,827]},null,[],["seq",{sourceInterval:[766,811]},["app",{sourceInterval:[766,771]},"ident",[]],["opt",{sourceInterval:[772,779]},["app",{sourceInterval:[772,778]},"Params",[]]],["not",{sourceInterval:[780,811]},["alt",{sourceInterval:[782,810]},["seq",{sourceInterval:[782,796]},["opt",{sourceInterval:[782,792]},["app",{sourceInterval:[782,791]},"ruleDescr",[]]],["terminal",{sourceInterval:[793,796]},"="]],["terminal",{sourceInterval:[799,803]},":="],["terminal",{sourceInterval:[806,810]},"+="]]]]],Base_range:["define",{sourceInterval:[834,889]},null,[],["seq",{sourceInterval:[834,856]},["app",{sourceInterval:[834,842]},"terminal",[]],["terminal",{sourceInterval:[843,847]},".."],["app",{sourceInterval:[848,856]},"terminal",[]]]],Base_terminal:["define",{sourceInterval:[896,954]},null,[],["app",{sourceInterval:[896,904]},"terminal",[]]],Base_paren:["define",{sourceInterval:[961,1016]},null,[],["seq",{sourceInterval:[961,972]},["terminal",{sourceInterval:[961,964]},"("],["app",{sourceInterval:[965,968]},"Alt",[]],["terminal",{sourceInterval:[969,972]},")"]]],Base:["define",{sourceInterval:[755,1016]},null,[],["alt",{sourceInterval:[766,1016]},["app",{sourceInterval:[766,811]},"Base_application",[]],["app",{sourceInterval:[834,856]},"Base_range",[]],["app",{sourceInterval:[896,904]},"Base_terminal",[]],["app",{sourceInterval:[961,972]},"Base_paren",[]]]],ruleDescr:["define",{sourceInterval:[1020,1079]},"a rule description",[],["seq",{sourceInterval:[1058,1079]},["terminal",{sourceInterval:[1058,1061]},"("],["app",{sourceInterval:[1062,1075]},"ruleDescrText",[]],["terminal",{sourceInterval:[1076,1079]},")"]]],ruleDescrText:["define",{sourceInterval:[1083,1114]},null,[],["star",{sourceInterval:[1103,1114]},["seq",{sourceInterval:[1104,1112]},["not",{sourceInterval:[1104,1108]},["terminal",{sourceInterval:[1105,1108]},")"]],["app",{sourceInterval:[1109,1112]},"any",[]]]]],caseName:["define",{sourceInterval:[1118,1186]},null,[],["seq",{sourceInterval:[1133,1186]},["terminal",{sourceInterval:[1133,1137]},"--"],["star",{sourceInterval:[1138,1152]},["seq",{sourceInterval:[1139,1150]},["not",{sourceInterval:[1139,1144]},["terminal",{sourceInterval:[1140,1144]},"\n"]],["app",{sourceInterval:[1145,1150]},"space",[]]]],["app",{sourceInterval:[1153,1157]},"name",[]],["star",{sourceInterval:[1158,1172]},["seq",{sourceInterval:[1159,1170]},["not",{sourceInterval:[1159,1164]},["terminal",{sourceInterval:[1160,1164]},"\n"]],["app",{sourceInterval:[1165,1170]},"space",[]]]],["alt",{sourceInterval:[1174,1185]},["terminal",{sourceInterval:[1174,1178]},"\n"],["lookahead",{sourceInterval:[1181,1185]},["terminal",{sourceInterval:[1182,1185]},"}"]]]]],name:["define",{sourceInterval:[1190,1230]},"a name",[],["seq",{sourceInterval:[1211,1230]},["app",{sourceInterval:[1211,1220]},"nameFirst",[]],["star",{sourceInterval:[1221,1230]},["app",{sourceInterval:[1221,1229]},"nameRest",[]]]]],nameFirst:["define",{sourceInterval:[1234,1266]},null,[],["alt",{sourceInterval:[1250,1266]},["terminal",{sourceInterval:[1250,1253]},"_"],["app",{sourceInterval:[1260,1266]},"letter",[]]]],nameRest:["define",{sourceInterval:[1270,1300]},null,[],["alt",{sourceInterval:[1285,1300]},["terminal",{sourceInterval:[1285,1288]},"_"],["app",{sourceInterval:[1295,1300]},"alnum",[]]]],ident:["define",{sourceInterval:[1304,1337]},"an identifier",[],["app",{sourceInterval:[1333,1337]},"name",[]]],terminal:["define",{sourceInterval:[1341,1379]},null,[],["seq",{sourceInterval:[1356,1379]},["terminal",{sourceInterval:[1356,1360]},'"'],["star",{sourceInterval:[1361,1374]},["app",{sourceInterval:[1361,1373]},"terminalChar",[]]],["terminal",{sourceInterval:[1375,1379]},'"']]],terminalChar:["define",{sourceInterval:[1383,1440]},null,[],["alt",{sourceInterval:[1402,1440]},["app",{sourceInterval:[1402,1412]},"escapeChar",[]],["seq",{sourceInterval:[1419,1440]},["not",{sourceInterval:[1419,1424]},["terminal",{sourceInterval:[1420,1424]},"\\"]],["not",{sourceInterval:[1425,1430]},["terminal",{sourceInterval:[1426,1430]},'"']],["not",{sourceInterval:[1431,1436]},["terminal",{sourceInterval:[1432,1436]},"\n"]],["app",{sourceInterval:[1437,1440]},"any",[]]]]],escapeChar_backslash:["define",{sourceInterval:[1483,1538]},null,[],["terminal",{sourceInterval:[1483,1489]},"\\\\"]],escapeChar_doubleQuote:["define",{sourceInterval:[1545,1602]},null,[],["terminal",{sourceInterval:[1545,1551]},'\\"']],escapeChar_singleQuote:["define",{sourceInterval:[1609,1666]},null,[],["terminal",{sourceInterval:[1609,1615]},"\\'"]],escapeChar_backspace:["define",{sourceInterval:[1673,1728]},null,[],["terminal",{sourceInterval:[1673,1678]},"\\b"]],escapeChar_lineFeed:["define",{sourceInterval:[1735,1789]},null,[],["terminal",{sourceInterval:[1735,1740]},"\\n"]],escapeChar_carriageReturn:["define",{sourceInterval:[1796,1856]},null,[],["terminal",{sourceInterval:[1796,1801]},"\\r"]],escapeChar_tab:["define",{sourceInterval:[1863,1912]},null,[],["terminal",{sourceInterval:[1863,1868]},"\\t"]],escapeChar_unicodeEscape:["define",{sourceInterval:[1919,1978]},null,[],["seq",{sourceInterval:[1919,1960]},["terminal",{sourceInterval:[1919,1924]},"\\u"],["app",{sourceInterval:[1925,1933]},"hexDigit",[]],["app",{sourceInterval:[1934,1942]},"hexDigit",[]],["app",{sourceInterval:[1943,1951]},"hexDigit",[]],["app",{sourceInterval:[1952,1960]},"hexDigit",[]]]],escapeChar_hexEscape:["define",{sourceInterval:[1985,2040]},null,[],["seq",{sourceInterval:[1985,2008]},["terminal",{sourceInterval:[1985,1990]},"\\x"],["app",{sourceInterval:[1991,1999]},"hexDigit",[]],["app",{sourceInterval:[2e3,2008]},"hexDigit",[]]]],escapeChar:["define",{sourceInterval:[1444,2040]},"an escape sequence",[],["alt",{sourceInterval:[1483,2040]},["app",{sourceInterval:[1483,1489]},"escapeChar_backslash",[]],["app",{sourceInterval:[1545,1551]},"escapeChar_doubleQuote",[]],["app",{sourceInterval:[1609,1615]},"escapeChar_singleQuote",[]],["app",{sourceInterval:[1673,1678]},"escapeChar_backspace",[]],["app",{sourceInterval:[1735,1740]},"escapeChar_lineFeed",[]],["app",{sourceInterval:[1796,1801]},"escapeChar_carriageReturn",[]],["app",{sourceInterval:[1863,1868]},"escapeChar_tab",[]],["app",{sourceInterval:[1919,1960]},"escapeChar_unicodeEscape",[]],["app",{sourceInterval:[1985,2008]},"escapeChar_hexEscape",[]]]],space:["extend",{sourceInterval:[2044,2063]},null,[],["app",{sourceInterval:[2056,2063]},"comment",[]]],comment_singleLine:["define",{sourceInterval:[2081,2118]},null,[],["seq",{sourceInterval:[2081,2103]},["terminal",{sourceInterval:[2081,2085]},"//"],["star",{sourceInterval:[2086,2098]},["seq",{sourceInterval:[2087,2096]},["not",{sourceInterval:[2087,2092]},["terminal",{sourceInterval:[2088,2092]},"\n"]],["app",{sourceInterval:[2093,2096]},"any",[]]]],["terminal",{sourceInterval:[2099,2103]},"\n"]]],comment_multiLine:["define",{sourceInterval:[2125,2161]},null,[],["seq",{sourceInterval:[2125,2147]},["terminal",{sourceInterval:[2125,2129]},"/*"],["star",{sourceInterval:[2130,2142]},["seq",{sourceInterval:[2131,2140]},["not",{sourceInterval:[2131,2136]},["terminal",{sourceInterval:[2132,2136]},"*/"]],["app",{sourceInterval:[2137,2140]},"any",[]]]],["terminal",{sourceInterval:[2143,2147]},"*/"]]],comment:["define",{sourceInterval:[2067,2161]},null,[],["alt",{sourceInterval:[2081,2161]},["app",{sourceInterval:[2081,2103]},"comment_singleLine",[]],["app",{sourceInterval:[2125,2147]},"comment_multiLine",[]]]],tokens:["define",{sourceInterval:[2165,2180]},null,[],["star",{sourceInterval:[2174,2180]},["app",{sourceInterval:[2174,2179]},"token",[]]]],token:["define",{sourceInterval:[2184,2260]},null,[],["alt",{sourceInterval:[2192,2260]},["app",{sourceInterval:[2192,2200]},"caseName",[]],["app",{sourceInterval:[2203,2210]},"comment",[]],["app",{sourceInterval:[2213,2218]},"ident",[]],["app",{sourceInterval:[2221,2229]},"operator",[]],["app",{sourceInterval:[2232,2243]},"punctuation",[]],["app",{sourceInterval:[2246,2254]},"terminal",[]],["app",{sourceInterval:[2257,2260]},"any",[]]]],operator:["define",{sourceInterval:[2264,2329]},null,[],["alt",{sourceInterval:[2275,2329]},["terminal",{sourceInterval:[2275,2279]},"<:"],["terminal",{sourceInterval:[2282,2285]},"="],["terminal",{sourceInterval:[2288,2292]},":="],["terminal",{sourceInterval:[2295,2299]},"+="],["terminal",{sourceInterval:[2302,2305]},"*"],["terminal",{sourceInterval:[2308,2311]},"+"],["terminal",{sourceInterval:[2314,2317]},"?"],["terminal",{sourceInterval:[2320,2323]},"~"],["terminal",{sourceInterval:[2326,2329]},"&"]]],punctuation:["define",{sourceInterval:[2333,2369]},null,[],["alt",{sourceInterval:[2347,2369]},["terminal",{sourceInterval:[2347,2350]},"<"],["terminal",{sourceInterval:[2353,2356]},">"],["terminal",{sourceInterval:[2359,2362]},","],["terminal",{sourceInterval:[2365,2369]},"--"]]]}])},{"..":50}],12:[function(require,module,exports){var ohm=require("..");module.exports=ohm.makeRecipe(["grammar",{source:'OperationsAndAttributes {\n\n AttributeSignature =\n name\n\n OperationSignature =\n name Formals?\n\n Formals\n = "(" ListOf ")"\n\n name (a name)\n = nameFirst nameRest*\n\n nameFirst\n = "_"\n | letter\n\n nameRest\n = "_"\n | alnum\n\n}'},"OperationsAndAttributes",null,"AttributeSignature",{AttributeSignature:["define",{sourceInterval:[29,58]},null,[],["app",{sourceInterval:[54,58]},"name",[]]],OperationSignature:["define",{sourceInterval:[62,100]},null,[],["seq",{sourceInterval:[87,100]},["app",{sourceInterval:[87,91]},"name",[]],["opt",{sourceInterval:[92,100]},["app",{sourceInterval:[92,99]},"Formals",[]]]]],Formals:["define",{sourceInterval:[104,143]},null,[],["seq",{sourceInterval:[118,143]},["terminal",{sourceInterval:[118,121]},"("],["app",{sourceInterval:[122,139]},"ListOf",[["app",{sourceInterval:[129,133]},"name",[]],["terminal",{sourceInterval:[135,138]},","]]],["terminal",{sourceInterval:[140,143]},")"]]],name:["define",{sourceInterval:[147,187]},"a name",[],["seq",{sourceInterval:[168,187]},["app",{sourceInterval:[168,177]},"nameFirst",[]],["star",{sourceInterval:[178,187]},["app",{sourceInterval:[178,186]},"nameRest",[]]]]],nameFirst:["define",{sourceInterval:[191,223]},null,[],["alt",{sourceInterval:[207,223]},["terminal",{sourceInterval:[207,210]},"_"],["app",{sourceInterval:[217,223]},"letter",[]]]],nameRest:["define",{sourceInterval:[227,257]},null,[],["alt",{sourceInterval:[242,257]},["terminal",{sourceInterval:[242,245]},"_"],["app",{sourceInterval:[252,257]},"alnum",[]]]]}])},{"..":50}],13:[function(require,module,exports){"use strict";module.exports={toAST:require("./semantics-toAST").helper,semanticsForToAST:require("./semantics-toAST").semantics}},{"./semantics-toAST":14}],14:[function(require,module,exports){"use strict";var pexprs=require("../src/pexprs");var MatchResult=require("../src/MatchResult");var Grammar=require("../src/Grammar");var extend=require("util-extend");var defaultOperation={_terminal:function(){return this.primitiveValue},_nonterminal:function(children){var ctorName=this._node.ctorName;var mapping=this.args.mapping;if(!mapping.hasOwnProperty(ctorName)){if(this._node instanceof pexprs.Alt||this._node instanceof pexprs.Apply){return children[0].toAST(mapping)}if(this.isLexical()){return this.interval.contents}var realChildren=children.filter(function(child){return!child.isTerminal()});if(realChildren.length===1){return realChildren[0].toAST(mapping)}}if(typeof mapping[ctorName]==="number"){return children[mapping[ctorName]].toAST(mapping)}var propMap=mapping[ctorName]||children;var node={type:ctorName};for(var prop in propMap){var mappedProp=mapping[ctorName]&&mapping[ctorName][prop];if(typeof mappedProp==="number"){node[prop]=children[mappedProp].toAST(mapping)}else if(typeof mappedProp==="string"||typeof mappedProp==="boolean"||mappedProp===null){node[prop]=mappedProp}else if(typeof mappedProp==="object"&&mappedProp instanceof Number){node[prop]=Number(mappedProp)}else if(typeof mappedProp==="function"){node[prop]=mappedProp.call(this,children)}else if(mappedProp===undefined){if(children[prop]&&!children[prop].isTerminal()){node[prop]=children[prop].toAST(mapping)}else{delete node[prop]}}}return node},_iter:function(children){if(this._node.isOptional()){if(this.numChildren===0){return null}else{return children[0].toAST(this.args.mapping)}}return children.map(function(child){return child.toAST(this.args.mapping)},this)},NonemptyListOf:function(first,sep,rest){return[first.toAST(this.args.mapping)].concat(rest.toAST(this.args.mapping))},EmptyListOf:function(){return[]}};function toAST(res,mapping){if(!(res instanceof MatchResult)||res.failed()){ throw new Error("toAST() expects a succesfull MatchResult as first parameter")}mapping=extend({},mapping);var operation=extend({},defaultOperation);for(var termName in mapping){if(typeof mapping[termName]==="function"){operation[termName]=mapping[termName];delete mapping[termName]}}var g=res._cst.grammar;var s=g.semantics().addOperation("toAST(mapping)",operation);return s(res).toAST(mapping)}function semanticsForToAST(g){if(!(g instanceof Grammar)){throw new Error("semanticsToAST() expects a Grammar as parameter")}return g.semantics().addOperation("toAST(mapping)",defaultOperation)}module.exports={helper:toAST,semantics:semanticsForToAST}},{"../src/Grammar":38,"../src/MatchResult":42,"../src/pexprs":67,"util-extend":35}],15:[function(require,module,exports){"use strict";module.exports=require("./is-implemented")()?Symbol:require("./polyfill")},{"./is-implemented":16,"./polyfill":31}],16:[function(require,module,exports){"use strict";module.exports=function(){var symbol;if(typeof Symbol!=="function")return false;symbol=Symbol("test symbol");try{String(symbol)}catch(e){return false}if(typeof Symbol.iterator==="symbol")return true;if(typeof Symbol.isConcatSpreadable!=="object")return false;if(typeof Symbol.iterator!=="object")return false;if(typeof Symbol.toPrimitive!=="object")return false;if(typeof Symbol.toStringTag!=="object")return false;if(typeof Symbol.unscopables!=="object")return false;return true}},{}],17:[function(require,module,exports){"use strict";module.exports=function(x){return x&&(typeof x==="symbol"||x["@@toStringTag"]==="Symbol")||false}},{}],18:[function(require,module,exports){"use strict";var assign=require("es5-ext/object/assign"),normalizeOpts=require("es5-ext/object/normalize-options"),isCallable=require("es5-ext/object/is-callable"),contains=require("es5-ext/string/#/contains"),d;d=module.exports=function(dscr,value){var c,e,w,options,desc;if(arguments.length<2||typeof dscr!=="string"){options=value;value=dscr;dscr=null}else{options=arguments[2]}if(dscr==null){c=w=true;e=false}else{c=contains.call(dscr,"c");e=contains.call(dscr,"e");w=contains.call(dscr,"w")}desc={value:value,configurable:c,enumerable:e,writable:w};return!options?desc:assign(normalizeOpts(options),desc)};d.gs=function(dscr,get,set){var c,e,options,desc;if(typeof dscr!=="string"){options=set;set=get;get=dscr;dscr=null}else{options=arguments[3]}if(get==null){get=undefined}else if(!isCallable(get)){options=get;get=set=undefined}else if(set==null){set=undefined}else if(!isCallable(set)){options=set;set=undefined}if(dscr==null){c=true;e=false}else{c=contains.call(dscr,"c");e=contains.call(dscr,"e")}desc={get:get,set:set,configurable:c,enumerable:e};return!options?desc:assign(normalizeOpts(options),desc)}},{"es5-ext/object/assign":19,"es5-ext/object/is-callable":22,"es5-ext/object/normalize-options":26,"es5-ext/string/#/contains":28}],19:[function(require,module,exports){"use strict";module.exports=require("./is-implemented")()?Object.assign:require("./shim")},{"./is-implemented":20,"./shim":21}],20:[function(require,module,exports){"use strict";module.exports=function(){var assign=Object.assign,obj;if(typeof assign!=="function")return false;obj={foo:"raz"};assign(obj,{bar:"dwa"},{trzy:"trzy"});return obj.foo+obj.bar+obj.trzy==="razdwatrzy"}},{}],21:[function(require,module,exports){"use strict";var keys=require("../keys"),value=require("../valid-value"),max=Math.max;module.exports=function(dest,src){var error,i,l=max(arguments.length,2),assign;dest=Object(value(dest));assign=function(key){try{dest[key]=src[key]}catch(e){if(!error)error=e}};for(i=1;i-1}},{}],31:[function(require,module,exports){"use strict";var d=require("d"),validateSymbol=require("./validate-symbol"),create=Object.create,defineProperties=Object.defineProperties,defineProperty=Object.defineProperty,objPrototype=Object.prototype,Symbol,HiddenSymbol,globalSymbols=create(null);var generateName=function(){var created=create(null);return function(desc){var postfix=0,name;while(created[desc+(postfix||"")])++postfix;desc+=postfix||"";created[desc]=true;name="@@"+desc;defineProperty(objPrototype,name,d.gs(null,function(value){defineProperty(this,name,d(value))}));return name}}();HiddenSymbol=function Symbol(description){if(this instanceof HiddenSymbol)throw new TypeError("TypeError: Symbol is not a constructor");return Symbol(description)};module.exports=Symbol=function Symbol(description){var symbol;if(this instanceof Symbol)throw new TypeError("TypeError: Symbol is not a constructor");symbol=create(HiddenSymbol.prototype);description=description===undefined?"":String(description);return defineProperties(symbol,{__description__:d("",description),__name__:d("",generateName(description))})};defineProperties(Symbol,{"for":d(function(key){if(globalSymbols[key])return globalSymbols[key];return globalSymbols[key]=Symbol(String(key))}),keyFor:d(function(s){var key;validateSymbol(s);for(key in globalSymbols)if(globalSymbols[key]===s)return key}),hasInstance:d("",Symbol("hasInstance")),isConcatSpreadable:d("",Symbol("isConcatSpreadable")),iterator:d("",Symbol("iterator")),match:d("",Symbol("match")),replace:d("",Symbol("replace")),search:d("",Symbol("search")),species:d("",Symbol("species")),split:d("",Symbol("split")),toPrimitive:d("",Symbol("toPrimitive")),toStringTag:d("",Symbol("toStringTag")),unscopables:d("",Symbol("unscopables"))});defineProperties(HiddenSymbol.prototype,{constructor:d(Symbol),toString:d("",function(){return this.__name__})});defineProperties(Symbol.prototype,{toString:d(function(){return"Symbol ("+validateSymbol(this).__description__+")"}),valueOf:d(function(){return validateSymbol(this)})});defineProperty(Symbol.prototype,Symbol.toPrimitive,d("",function(){return validateSymbol(this)}));defineProperty(Symbol.prototype,Symbol.toStringTag,d("c","Symbol"));defineProperty(HiddenSymbol.prototype,Symbol.toPrimitive,d("c",Symbol.prototype[Symbol.toPrimitive]));defineProperty(HiddenSymbol.prototype,Symbol.toStringTag,d("c",Symbol.prototype[Symbol.toStringTag]))},{"./validate-symbol":32,d:18}],32:[function(require,module,exports){"use strict";var isSymbol=require("./is-symbol");module.exports=function(value){if(!isSymbol(value))throw new TypeError(value+" is not a symbol");return value}},{"./is-symbol":17}],33:[function(require,module,exports){if(typeof Object.create==="function"){module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:false,writable:true,configurable:true}})}}else{module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype;ctor.prototype=new TempCtor;ctor.prototype.constructor=ctor}}},{}],34:[function(require,module,exports){module.exports=function(obj){return!!(obj!=null&&obj.constructor&&typeof obj.constructor.isBuffer==="function"&&obj.constructor.isBuffer(obj))}},{}],35:[function(require,module,exports){module.exports=extend;function extend(origin,add){if(!add||typeof add!=="object")return origin;var keys=Object.keys(add);var i=keys.length;while(i--){origin[keys[i]]=add[keys[i]]}return origin}},{}],36:[function(require,module,exports){"use strict";var GrammarDecl=require("./GrammarDecl");var Interval=require("./Interval");var pexprs=require("./pexprs");function Builder(){}Builder.prototype={currentDecl:null,newGrammar:function(name){return new GrammarDecl(name)},grammar:function(metaInfo,name,superGrammar,defaultStartRule,rules){var gDecl=new GrammarDecl(name);if(superGrammar){gDecl.withSuperGrammar(this.fromRecipe(superGrammar))}if(defaultStartRule){gDecl.withDefaultStartRule(defaultStartRule)}if(metaInfo&&metaInfo.source){gDecl.withSource(metaInfo.source)}var self=this;this.currentDecl=gDecl;Object.keys(rules).forEach(function(ruleName){var ruleRecipe=rules[ruleName];var action=ruleRecipe[0];var metaInfo=ruleRecipe[1];var optDescription=ruleRecipe[2];var formals=ruleRecipe[3];var body=self.fromRecipe(ruleRecipe[4]);if(gDecl.interval&&metaInfo&&metaInfo.sourceInterval){body.definitionInterval=new Interval(gDecl.interval.inputStream,metaInfo.sourceInterval[0],metaInfo.sourceInterval[1])}gDecl[action](ruleName,formals,body,optDescription)});this.currentDecl=null;return gDecl.build()},terminal:function(x){return new pexprs.Terminal(x)},range:function(from,to){return new pexprs.Range(from,to)},param:function(index){return new pexprs.Param(index)},alt:function(){var terms=[];for(var idx=0;idx0){optParams=optParams.map(function(param){return param instanceof pexprs.PExpr?param:this.fromRecipe(param)},this)}return new pexprs.Apply(ruleName,optParams)},fromRecipe:function(recipe){var result=this[recipe[0]].apply(this,recipe[0]==="grammar"?recipe.slice(1):recipe.slice(2));var metaInfo=recipe[1];if(metaInfo){if(metaInfo.sourceInterval&&this.currentDecl){result.withInterval(this.currentDecl.sourceInterval.apply(this.currentDecl,metaInfo.sourceInterval))}}return result}};module.exports=Builder},{"./GrammarDecl":39,"./Interval":41,"./pexprs":67}],37:[function(require,module,exports){"use strict";function isValidType(type){return type==="description"||type==="string"||type==="code"}function Failure(pexpr,text,type){if(!isValidType(type)){throw new Error("invalid Failure type: "+type)}this.pexpr=pexpr;this.text=text;this.type=type;this.fluffy=false}Failure.prototype.getPExpr=function(){return this.pexpr};Failure.prototype.getText=function(){return this.text};Failure.prototype.getType=function(){return this.type};Failure.prototype.isDescription=function(){return this.type==="description"};Failure.prototype.isStringTerminal=function(){return this.type==="string"};Failure.prototype.isCode=function(){return this.type==="code"};Failure.prototype.isFluffy=function(){return this.fluffy};Failure.prototype.makeFluffy=function(){this.fluffy=true};Failure.prototype.clearFluffy=function(){this.fluffy=false};Failure.prototype.subsumes=function(that){return this.getText()===that.getText()&&this.type===that.type&&(!this.isFluffy()||this.isFluffy()&&that.isFluffy())};Failure.prototype.toString=function(){return this.type==="string"?JSON.stringify(this.getText()):this.getText()};Failure.prototype.clone=function(){var failure=new Failure(this.pexpr,this.text,this.type);if(this.isFluffy()){failure.makeFluffy()}return failure};Failure.prototype.toKey=function(){return this.toString()+"#"+this.type};module.exports=Failure},{}],38:[function(require,module,exports){"use strict";var MatchResult=require("./MatchResult");var Semantics=require("./Semantics");var State=require("./State");var common=require("./common");var errors=require("./errors");var pexprs=require("./pexprs");function Grammar(name,superGrammar,ruleBodies,ruleFormals,ruleDescriptions,optDefaultStartRule){this.name=name;this.superGrammar=superGrammar;this.ruleBodies=ruleBodies;this.ruleFormals=ruleFormals;this.ruleDescriptions=ruleDescriptions;if(optDefaultStartRule){if(!(optDefaultStartRule in ruleBodies)){throw new Error("Invalid start rule: '"+optDefaultStartRule+"' is not a rule in grammar '"+name+"'")}this.defaultStartRule=optDefaultStartRule}}var ohmGrammar;var buildGrammar;Grammar.initApplicationParser=function(grammar,builderFn){ohmGrammar=grammar;buildGrammar=builderFn};Grammar.prototype={isBuiltIn:function(){return this===Grammar.ProtoBuiltInRules||this===Grammar.BuiltInRules},_match:function(input,opts){var state=new State(this,input,opts);state.evalFromStart();return state},match:function(input,optStartApplication){var state=this._match(input,{startApplication:optStartApplication});return MatchResult.newFor(state)},trace:function(input,optStartApplication){var state=this._match(input,{startApplication:optStartApplication,trace:true});var rootTrace=state.trace[state.trace.length-1];rootTrace.state=state;rootTrace.result=MatchResult.newFor(state);return rootTrace},semantics:function(){return Semantics.createSemantics(this)},extendSemantics:function(superSemantics){return Semantics.createSemantics(this,superSemantics._getSemantics())},_checkTopDownActionDict:function(what,name,actionDict){function isSpecialAction(a){return a==="_iter"||a==="_terminal"||a==="_nonterminal"||a==="_default"}var problems=[];for(var k in actionDict){var v=actionDict[k];if(!isSpecialAction(k)&&!(k in this.ruleBodies)){problems.push("'"+k+"' is not a valid semantic action for '"+this.name+"'")}else if(typeof v!=="function"){problems.push("'"+k+"' must be a function in an action dictionary for '"+this.name+"'")}else{var actual=v.length;var expected=this._topDownActionArity(k);if(actual!==expected){problems.push("Semantic action '"+k+"' has the wrong arity: "+"expected "+expected+", got "+actual)}}}if(problems.length>0){var prettyProblems=problems.map(function(problem){return"- "+problem});var error=new Error("Found errors in the action dictionary of the '"+name+"' "+what+":\n"+prettyProblems.join("\n"));error.problems=problems;throw error}},_topDownActionArity:function(actionName){if(actionName==="_iter"||actionName==="_nonterminal"||actionName==="_default"){return 1}else if(actionName==="_terminal"){return 0}return this.ruleBodies[actionName].getArity()},_inheritsFrom:function(grammar){var g=this.superGrammar;while(g){if(g===grammar){return true}g=g.superGrammar}return false},toRecipe:function(optVarName){var metaInfo={};if(this.definitionInterval){metaInfo.source=this.definitionInterval.contents}var superGrammar=null;if(this.superGrammar&&!this.superGrammar.isBuiltIn()){superGrammar=JSON.parse(this.superGrammar.toRecipe())}var startRule=null;if(this.defaultStartRule){startRule=this.defaultStartRule}var rules={};var self=this;Object.keys(this.ruleBodies).forEach(function(ruleName){var body=self.ruleBodies[ruleName];var isDefinition=!self.superGrammar||!self.superGrammar.ruleBodies[ruleName];var operation;if(isDefinition){operation="define"}else{operation=body instanceof pexprs.Extend?"extend":"override"}var metaInfo={};if(body.definitionInterval&&self.definitionInterval){var adjusted=body.definitionInterval.relativeTo(self.definitionInterval);metaInfo.sourceInterval=[adjusted.startIdx,adjusted.endIdx]}var description=null;if(isDefinition&&self.ruleDescriptions[ruleName]){description=self.ruleDescriptions[ruleName]}var formals=self.ruleFormals[ruleName];var ruleBody=body.outputRecipe(formals,self.definitionInterval);rules[ruleName]=[operation,metaInfo,description,formals,ruleBody]});return JSON.stringify(["grammar",metaInfo,this.name,superGrammar,startRule,rules])},toOperationActionDictionaryTemplate:function(){return this._toOperationOrAttributeActionDictionaryTemplate()},toAttributeActionDictionaryTemplate:function(){return this._toOperationOrAttributeActionDictionaryTemplate()},_toOperationOrAttributeActionDictionaryTemplate:function(){var sb=new common.StringBuffer;sb.append("{");var first=true;for(var ruleName in this.ruleBodies){var body=this.ruleBodies[ruleName];if(first){first=false}else{sb.append(",")}sb.append("\n");sb.append(" ");this.addSemanticActionTemplate(ruleName,body,sb)}sb.append("\n}");return sb.contents()},addSemanticActionTemplate:function(ruleName,body,sb){sb.append(ruleName);sb.append(": function(");var arity=this._topDownActionArity(ruleName);sb.append(common.repeat("_",arity).join(", "));sb.append(") {\n");sb.append(" }")},parseApplication:function(str){var app;if(str.indexOf("<")===-1){app=new pexprs.Apply(str)}else{var cst=ohmGrammar.match(str,"Base_application");app=buildGrammar(cst,{})}if(!(app.ruleName in this.ruleBodies)){throw errors.undeclaredRule(app.ruleName,this.name)}else if(this.ruleFormals[app.ruleName].length!==app.args.length){throw errors.wrongNumberOfParameters(app.ruleName,this.ruleFormals[app.ruleName].length,app.args.length)}return app}};Grammar.ProtoBuiltInRules=new Grammar("ProtoBuiltInRules",undefined,{any:pexprs.any,end:pexprs.end,spaces:new pexprs.Star(new pexprs.Apply("space")),space:new pexprs.Range("\x00"," "),lower:new pexprs.UnicodeChar("Ll"),upper:new pexprs.UnicodeChar("Lu"),unicodeLtmo:new pexprs.UnicodeChar("Ltmo")},{any:[],end:[],spaces:[],space:[],lower:[],upper:[],unicodeLtmo:[]},{any:"any object",end:"end of input",space:"a space",lower:"a lowercase letter",upper:"an uppercase letter"});module.exports=Grammar},{"./MatchResult":42,"./Semantics":45,"./State":46,"./common":48,"./errors":49,"./pexprs":67}],39:[function(require,module,exports){"use strict";var Grammar=require("./Grammar");var InputStream=require("./InputStream");var common=require("./common");var errors=require("./errors");var pexprs=require("./pexprs");function GrammarDecl(name){this.name=name}GrammarDecl.prototype.sourceInterval=function(startIdx,endIdx){var inputStream=this.interval.inputStream;return inputStream.interval(startIdx,endIdx)};GrammarDecl.prototype.ensureSuperGrammar=function(){if(!this.superGrammar){this.withSuperGrammar(this.name==="BuiltInRules"?Grammar.ProtoBuiltInRules:Grammar.BuiltInRules)}return this.superGrammar};GrammarDecl.prototype.installOverriddenOrExtendedRule=function(name,formals,body){var duplicateParameterNames=common.getDuplicates(formals);if(duplicateParameterNames.length>0){throw errors.duplicateParameterNames(name,duplicateParameterNames,body)}var expectedFormals=this.ensureSuperGrammar().ruleFormals[name];var expectedNumFormals=expectedFormals?expectedFormals.length:0;if(formals.length!==expectedNumFormals){throw errors.wrongNumberOfParameters(name,expectedNumFormals,formals.length,body)}return this.install(name,formals,body)};GrammarDecl.prototype.install=function(name,formals,body,optDescription){body=body.introduceParams(formals);this.ruleFormals[name]=formals;if(optDescription){this.ruleDescriptions[name]=optDescription}this.ruleBodies[name]=body;return this};GrammarDecl.prototype.withSuperGrammar=function(superGrammar){if(this.superGrammar){throw new Error("the super grammar of a GrammarDecl cannot be set more than once")}this.superGrammar=superGrammar;this.ruleBodies=Object.create(superGrammar.ruleBodies);this.ruleFormals=Object.create(superGrammar.ruleFormals);this.ruleDescriptions=Object.create(superGrammar.ruleDescriptions);if(!superGrammar.isBuiltIn()){this.defaultStartRule=superGrammar.defaultStartRule}return this};GrammarDecl.prototype.withDefaultStartRule=function(ruleName){this.defaultStartRule=ruleName;return this};GrammarDecl.prototype.withSource=function(source){this.interval=new InputStream(source).interval(0,source.length);return this};GrammarDecl.prototype.build=function(){var grammar=new Grammar(this.name,this.ensureSuperGrammar(),this.ruleBodies,this.ruleFormals,this.ruleDescriptions,this.defaultStartRule);var grammarErrors=[];var grammarHasInvalidApplications=false;Object.keys(grammar.ruleBodies).forEach(function(ruleName){var body=grammar.ruleBodies[ruleName];try{body.assertChoicesHaveUniformArity(ruleName)}catch(e){grammarErrors.push(e)}try{body.assertAllApplicationsAreValid(ruleName,grammar)}catch(e){grammarErrors.push(e);grammarHasInvalidApplications=true}});if(!grammarHasInvalidApplications){Object.keys(grammar.ruleBodies).forEach(function(ruleName){var body=grammar.ruleBodies[ruleName];try{body.assertIteratedExprsAreNotNullable(grammar,ruleName)}catch(e){grammarErrors.push(e)}})}if(grammarErrors.length>0){errors.throwErrors(grammarErrors)}if(this.interval){grammar.definitionInterval=this.interval}return grammar};GrammarDecl.prototype.define=function(name,formals,body,optDescr){this.ensureSuperGrammar();if(this.superGrammar.ruleBodies[name]){throw errors.duplicateRuleDeclaration(name,this.name,this.superGrammar.name,body)}else if(this.ruleBodies[name]){throw errors.duplicateRuleDeclaration(name,this.name,this.name,body)}var duplicateParameterNames=common.getDuplicates(formals);if(duplicateParameterNames.length>0){throw errors.duplicateParameterNames(name,duplicateParameterNames,body)}return this.install(name,formals,body,optDescr)};GrammarDecl.prototype.override=function(name,formals,body){var baseRule=this.ensureSuperGrammar().ruleBodies[name];if(!baseRule){throw errors.cannotOverrideUndeclaredRule(name,this.superGrammar.name,body)}this.installOverriddenOrExtendedRule(name,formals,body);return this};GrammarDecl.prototype.extend=function(name,formals,fragment){var baseRule=this.ensureSuperGrammar().ruleBodies[name];if(!baseRule){throw errors.cannotExtendUndeclaredRule(name,this.superGrammar.name,fragment)}var body=new pexprs.Extend(this.superGrammar,name,fragment);body.interval=fragment.interval;body.definitionInterval=fragment.definitionInterval;this.installOverriddenOrExtendedRule(name,formals,body);return this};module.exports=GrammarDecl},{"./Grammar":38,"./InputStream":40,"./common":48,"./errors":49,"./pexprs":67}],40:[function(require,module,exports){"use strict";var Interval=require("./Interval");function InputStream(source){this.source=source;this.pos=0;this.posInfos=[]}InputStream.prototype={atEnd:function(){return this.pos===this.source.length},next:function(){return this.source[this.pos++]},matchString:function(s){for(var idx=0;idx=that.startIdx&&this.endIdx<=that.endIdx,"other interval does not cover this one");return new Interval(newInputStream,this.startIdx-that.startIdx,this.endIdx-that.startIdx)},trimmed:function(){var contents=this.contents;var startIdx=this.startIdx+contents.match(/^\s*/)[0].length;var endIdx=this.endIdx-contents.match(/\s*$/)[0].length;return new Interval(this.inputStream,startIdx,endIdx)}};Object.defineProperties(Interval.prototype,{contents:{get:function(){if(this._contents===undefined){this._contents=this.inputStream.sourceSlice(this.startIdx,this.endIdx)}return this._contents},enumerable:true},length:{get:function(){return this.endIdx-this.startIdx},enumerable:true}});module.exports=Interval},{"./common":48,"./errors":49,"./util":68}],42:[function(require,module,exports){"use strict";var inherits=require("inherits");var common=require("./common");var nodes=require("./nodes");var util=require("./util");var Interval=require("./Interval");function getShortMatchErrorMessage(pos,source,detail){var errorInfo=util.getLineAndColumn(source,pos);return"Line "+errorInfo.lineNum+", col "+errorInfo.colNum+": "+detail}function MatchResult(state){this.state=state;this._cst=state.bindings[0]}MatchResult.newFor=function(state){var succeeded=state.bindings.length>0;return succeeded?new MatchResult(state):new MatchFailure(state)};MatchResult.prototype.failed=function(){return false};MatchResult.prototype.succeeded=function(){return!this.failed()};MatchResult.prototype.getDiscardedSpaces=function(){if(this.failed()){return[]}var state=this.state;var grammar=state.grammar;var inputStream=state.inputStream;var intervals=[new Interval(inputStream,0,inputStream.source.length)];var s=grammar.semantics().addOperation("subtractTerminals",{_nonterminal:function(children){children.forEach(function(child){child.subtractTerminals()})},_terminal:function(){var t=this;intervals=intervals.map(function(interval){return interval.minus(t.interval)}).reduce(function(xs,ys){return xs.concat(ys)},[])}});s(this).subtractTerminals();s.addOperation("fixIntervals(idxOffset)",{_default:function(children){var idxOffset=this.args.idxOffset;this.interval.inputStream=inputStream;this.interval.startIdx+=idxOffset;this.interval.endIdx+=idxOffset;if(!this.isTerminal()){children.forEach(function(child){child.fixIntervals(idxOffset)})}}});var discardedNodes=intervals.map(function(interval){var r=grammar.match(interval.contents,"spaces");s(r).fixIntervals(interval.startIdx);return r._cst});discardedNodes=new nodes.IterationNode(grammar,discardedNodes,discardedNodes.length===0?new Interval(inputStream,0,0):new Interval(inputStream,discardedNodes[0].interval.startIdx,discardedNodes[discardedNodes.length-1].interval.endIdx));var r=Object.create(this);r._cst=discardedNodes;r.getDiscardedSpaces=function(){return r};return r};function MatchFailure(state){this.state=state;common.defineLazyProperty(this,"_failures",function(){return this.state.getFailures()});common.defineLazyProperty(this,"message",function(){var source=this.state.inputStream.source;if(typeof source!=="string"){return"match failed at position "+this.getRightmostFailurePosition()}var detail="Expected "+this.getExpectedText();return util.getLineAndColumnMessage(source,this.getRightmostFailurePosition())+detail});common.defineLazyProperty(this,"shortMessage",function(){if(typeof this.state.inputStream.source!=="string"){return"match failed at position "+this.getRightmostFailurePosition()}var detail="expected "+this.getExpectedText();return getShortMatchErrorMessage(this.getRightmostFailurePosition(),this.state.inputStream.source,detail)})}inherits(MatchFailure,MatchResult);MatchFailure.prototype.toString=function(){return"[MatchFailure at position "+this.getRightmostFailurePosition()+"]"};MatchFailure.prototype.failed=function(){return true};MatchFailure.prototype.getRightmostFailurePosition=function(){return this.state.getRightmostFailurePosition()};MatchFailure.prototype.getRightmostFailures=function(){return this._failures};MatchFailure.prototype.getExpectedText=function(){var sb=new common.StringBuffer;var failures=this.getRightmostFailures();failures=failures.filter(function(failure){return!failure.isFluffy()});for(var idx=0;idx0){if(idx===failures.length-1){sb.append(failures.length>2?", or ":" or ")}else{sb.append(", ")}}sb.append(failures[idx].toString())}return sb.contents()};MatchFailure.prototype.getInterval=function(){var pos=this.state.getRightmostFailurePosition();return new Interval(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";var extend=require("util-extend");function Namespace(){}Namespace.prototype=Object.create(null);Namespace.asNamespace=function(objOrNamespace){if(objOrNamespace instanceof Namespace){return objOrNamespace}return Namespace.createNamespace(objOrNamespace)};Namespace.createNamespace=function(optProps){return Namespace.extend(Namespace.prototype,optProps)};Namespace.extend=function(namespace,optProps){if(namespace!==Namespace.prototype&&!(namespace instanceof Namespace)){throw new TypeError("not a Namespace object: "+namespace)}var ns=Object.create(namespace,{constructor:{value:Namespace,enumerable:false,writable:true,configurable:true}});return extend(ns,optProps)};Namespace.toString=function(ns){return Object.prototype.toString.call(ns)};module.exports=Namespace},{"util-extend":35}],44:[function(require,module,exports){"use strict";function PosInfo(state){ diff --git a/examples/location/index.expanded.js b/examples/location/index.expanded.js index ab71b3a..ae23234 100644 --- a/examples/location/index.expanded.js +++ b/examples/location/index.expanded.js @@ -105,7 +105,7 @@ Syndicate.Actor.createFacet() }); } } -var _cachedAssertion1468254187624_0 = (function() { var _ = Syndicate.__; return fromBroker(wsurl, locationRecord(id, email, _, _, _)); })(); +var _cachedAssertion1470084347961_0 = (function() { var _ = Syndicate.__; return fromBroker(wsurl, locationRecord(id, email, _, _, _)); })(); Syndicate.Actor.createFacet() .addInitBlock((function() { marker.addListener('click', Syndicate.Dataspace.wrap(function () { @@ -132,6 +132,6 @@ Syndicate.Actor.createFacet() marker.setMap(null); if (selectedMarker === marker) selectedMarker = null; })) -.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1468254187624_0, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1468254187624_0, metalevel: 0 }; }), (function() {})).completeBuild(); })).completeBuild(); })(); +.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1470084347961_0, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1470084347961_0, metalevel: 0 }; }), (function() {})).completeBuild(); })).completeBuild(); })(); }); }).startStepping(); diff --git a/examples/todo/index.expanded.js b/examples/todo/index.expanded.js index fa24f08..ecdb4a1 100644 --- a/examples/todo/index.expanded.js +++ b/examples/todo/index.expanded.js @@ -54,10 +54,10 @@ function todoListItemView(id) { (function () { Syndicate.Actor.createFacet() .onEvent(false, "asserted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(todo(id, _, _), 0); }), (function() { var _ = Syndicate.__; return { assertion: todo(id, (Syndicate._$("title")), (Syndicate._$("completed"))), metalevel: 0 }; }), (function(title, completed) { -var _cachedAssertion1468254188794_0 = (function() { var _ = Syndicate.__; return todo(id, title, completed); })(); +var _cachedAssertion1470084349188_0 = (function() { var _ = Syndicate.__; return todo(id, title, completed); })(); Syndicate.Actor.createFacet() .onEvent(false, "asserted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(show(completed), 0); }), (function() { var _ = Syndicate.__; return { assertion: show(completed), metalevel: 0 }; }), (function() { -var _cachedAssertion1468254188794_1 = (function() { var _ = Syndicate.__; return show(completed); })(); +var _cachedAssertion1470084349188_1 = (function() { var _ = Syndicate.__; return show(completed); })(); Syndicate.Actor.createFacet() .addAssertion((function() { var _ = Syndicate.__; return Syndicate.Patch.assert(this.ui.html('.todo-list', Mustache.render(getTemplate(this.editing @@ -70,8 +70,8 @@ Syndicate.Actor.createFacet() checked: completed ? "checked" : "", }), id), 0); })) -.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1468254188794_1, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1468254188794_1, metalevel: 0 }; }), (function() {})).completeBuild(); })) -.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1468254188794_0, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1468254188794_0, metalevel: 0 }; }), (function() {})).completeBuild(); })) +.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1470084349188_1, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1470084349188_1, metalevel: 0 }; }), (function() {})).completeBuild(); })) +.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1470084349188_0, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1470084349188_0, metalevel: 0 }; }), (function() {})).completeBuild(); })) .onEvent(false, "message", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(this.ui.event('.toggle', 'change', _), 0); }), (function() { var _ = Syndicate.__; return { assertion: this.ui.event('.toggle', 'change', (Syndicate._$("e"))), metalevel: 0 }; }), (function(e) { Syndicate.Dataspace.send(setCompleted(id, e.target.checked)); })) @@ -119,31 +119,31 @@ Syndicate.Actor.createFacet() (function () { Syndicate.Actor.createFacet() .onEvent(false, "asserted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(activeTodoCount(_), 0); }), (function() { var _ = Syndicate.__; return { assertion: activeTodoCount((Syndicate._$("count"))), metalevel: 0 }; }), (function(count) { -var _cachedAssertion1468254188794_2 = (function() { var _ = Syndicate.__; return activeTodoCount(count); })(); +var _cachedAssertion1470084349188_2 = (function() { var _ = Syndicate.__; return activeTodoCount(count); })(); Syndicate.Actor.createFacet() .addAssertion((function() { var _ = Syndicate.__; return Syndicate.Patch.assert(this.ui.context('count').html('.todo-count strong', '' + count), 0); })) -.addAssertion((function() { var _ = Syndicate.__; return (count !== 1) ? Syndicate.Patch.assert(, 0) : Syndicate.Patch.emptyPatch; })) -.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1468254188794_2, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1468254188794_2, metalevel: 0 }; }), (function() {})).completeBuild(); })) +.addAssertion((function() { var _ = Syndicate.__; return (count !== 1) ? Syndicate.Patch.assert(this.ui.context('plural').html('.todo-count span.s', 's'), 0) : Syndicate.Patch.emptyPatch; })) +.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1470084349188_2, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1470084349188_2, metalevel: 0 }; }), (function() {})).completeBuild(); })) .onEvent(false, "asserted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(totalTodoCount(0), 0); }), (function() { var _ = Syndicate.__; return { assertion: totalTodoCount(0), metalevel: 0 }; }), (function() { -var _cachedAssertion1468254188794_3 = (function() { var _ = Syndicate.__; return totalTodoCount(0); })(); +var _cachedAssertion1470084349188_3 = (function() { var _ = Syndicate.__; return totalTodoCount(0); })(); Syndicate.Actor.createFacet() .addAssertion((function() { var _ = Syndicate.__; return Syndicate.Patch.assert(Syndicate.UI.uiAttribute('section.main', 'class', 'hidden'), 0); })) .addAssertion((function() { var _ = Syndicate.__; return Syndicate.Patch.assert(Syndicate.UI.uiAttribute('footer.footer', 'class', 'hidden'), 0); })) -.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1468254188794_3, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1468254188794_3, metalevel: 0 }; }), (function() {})).completeBuild(); })) +.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1470084349188_3, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1470084349188_3, metalevel: 0 }; }), (function() {})).completeBuild(); })) .onEvent(false, "asserted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(completedTodoCount(0), 0); }), (function() { var _ = Syndicate.__; return { assertion: completedTodoCount(0), metalevel: 0 }; }), (function() { -var _cachedAssertion1468254188794_4 = (function() { var _ = Syndicate.__; return completedTodoCount(0); })(); +var _cachedAssertion1470084349188_4 = (function() { var _ = Syndicate.__; return completedTodoCount(0); })(); Syndicate.Actor.createFacet() .addAssertion((function() { var _ = Syndicate.__; return Syndicate.Patch.assert(Syndicate.UI.uiAttribute('button.clear-completed', 'class', 'hidden'), 0); })) -.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1468254188794_4, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1468254188794_4, metalevel: 0 }; }), (function() {})).completeBuild(); })) +.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1470084349188_4, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1470084349188_4, metalevel: 0 }; }), (function() {})).completeBuild(); })) .onEvent(false, "message", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(Syndicate.UI.globalEvent('button.clear-completed', 'click', _), 0); }), (function() { var _ = Syndicate.__; return { assertion: Syndicate.UI.globalEvent('button.clear-completed', 'click', _), metalevel: 0 }; }), (function() { Syndicate.Dataspace.send(clearCompletedTodos()); })) .onEvent(false, "asserted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(allCompleted(), 0); }), (function() { var _ = Syndicate.__; return { assertion: allCompleted(), metalevel: 0 }; }), (function() { -var _cachedAssertion1468254188794_5 = (function() { var _ = Syndicate.__; return allCompleted(); })(); +var _cachedAssertion1470084349188_5 = (function() { var _ = Syndicate.__; return allCompleted(); })(); Syndicate.Actor.createFacet() .addInitBlock((function() { Syndicate.Dataspace.send(Syndicate.UI.setProperty('.toggle-all', 'checked', true)); })) .addDoneBlock((function() { Syndicate.Dataspace.send(Syndicate.UI.setProperty('.toggle-all', 'checked', false)); })) -.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1468254188794_5, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1468254188794_5, metalevel: 0 }; }), (function() {})).completeBuild(); })) +.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1470084349188_5, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1470084349188_5, metalevel: 0 }; }), (function() {})).completeBuild(); })) .onEvent(false, "message", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(Syndicate.UI.globalEvent('.toggle-all', 'change', _), 0); }), (function() { var _ = Syndicate.__; return { assertion: Syndicate.UI.globalEvent('.toggle-all', 'change', (Syndicate._$("e"))), metalevel: 0 }; }), (function(e) { Syndicate.Dataspace.send(setAllCompleted(e.target.checked)); })) @@ -169,27 +169,27 @@ Syndicate.Actor.createFacet() (function () { Syndicate.Actor.createFacet() .onEvent(false, "asserted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(Syndicate.UI.locationHash(_), 0); }), (function() { var _ = Syndicate.__; return { assertion: Syndicate.UI.locationHash((Syndicate._$("hash"))), metalevel: 0 }; }), (function(hash) { -var _cachedAssertion1468254188794_6 = (function() { var _ = Syndicate.__; return Syndicate.UI.locationHash(hash); })(); +var _cachedAssertion1470084349188_6 = (function() { var _ = Syndicate.__; return Syndicate.UI.locationHash(hash); })(); Syndicate.Actor.createFacet() .addAssertion((function() { var _ = Syndicate.__; return Syndicate.Patch.assert(Syndicate.UI.uiAttribute('ul.filters > li > a[href="#'+hash+'"]', 'class', 'selected'), 0); })) -.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1468254188794_6, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1468254188794_6, metalevel: 0 }; }), (function() {})).completeBuild(); })) +.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1470084349188_6, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1470084349188_6, metalevel: 0 }; }), (function() {})).completeBuild(); })) .onEvent(false, "asserted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(Syndicate.UI.locationHash('/'), 0); }), (function() { var _ = Syndicate.__; return { assertion: Syndicate.UI.locationHash('/'), metalevel: 0 }; }), (function() { -var _cachedAssertion1468254188794_7 = (function() { var _ = Syndicate.__; return Syndicate.UI.locationHash('/'); })(); +var _cachedAssertion1470084349188_7 = (function() { var _ = Syndicate.__; return Syndicate.UI.locationHash('/'); })(); Syndicate.Actor.createFacet() .addAssertion((function() { var _ = Syndicate.__; return Syndicate.Patch.assert(show(true), 0); })) .addAssertion((function() { var _ = Syndicate.__; return Syndicate.Patch.assert(show(false), 0); })) -.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1468254188794_7, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1468254188794_7, metalevel: 0 }; }), (function() {})).completeBuild(); })) +.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1470084349188_7, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1470084349188_7, metalevel: 0 }; }), (function() {})).completeBuild(); })) .onEvent(false, "asserted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(Syndicate.UI.locationHash('/active'), 0); }), (function() { var _ = Syndicate.__; return { assertion: Syndicate.UI.locationHash('/active'), metalevel: 0 }; }), (function() { -var _cachedAssertion1468254188794_8 = (function() { var _ = Syndicate.__; return Syndicate.UI.locationHash('/active'); })(); +var _cachedAssertion1470084349188_8 = (function() { var _ = Syndicate.__; return Syndicate.UI.locationHash('/active'); })(); Syndicate.Actor.createFacet() .addAssertion((function() { var _ = Syndicate.__; return Syndicate.Patch.assert(show(false), 0); })) -.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1468254188794_8, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1468254188794_8, metalevel: 0 }; }), (function() {})).completeBuild(); })) +.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1470084349188_8, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1470084349188_8, metalevel: 0 }; }), (function() {})).completeBuild(); })) .onEvent(false, "asserted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(Syndicate.UI.locationHash('/completed'), 0); }), (function() { var _ = Syndicate.__; return { assertion: Syndicate.UI.locationHash('/completed'), metalevel: 0 }; }), (function() { -var _cachedAssertion1468254188794_9 = (function() { var _ = Syndicate.__; return Syndicate.UI.locationHash('/completed'); })(); +var _cachedAssertion1470084349188_9 = (function() { var _ = Syndicate.__; return Syndicate.UI.locationHash('/completed'); })(); Syndicate.Actor.createFacet() .addAssertion((function() { var _ = Syndicate.__; return Syndicate.Patch.assert(show(true), 0); })) -.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1468254188794_9, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1468254188794_9, metalevel: 0 }; }), (function() {})).completeBuild(); })).completeBuild(); })(); +.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1470084349188_9, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1470084349188_9, metalevel: 0 }; }), (function() {})).completeBuild(); })).completeBuild(); })(); }); Syndicate.Actor.spawnActor(new Object(), function() { @@ -218,20 +218,20 @@ Syndicate.Actor.createFacet() todoListItemModel(db.nextId++, title, false); })) .onEvent(false, "asserted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(todo(_, _, _), 0); }), (function() { var _ = Syndicate.__; return { assertion: todo((Syndicate._$("id")), _, _), metalevel: 0 }; }), (function(id) { -var _cachedAssertion1468254188794_10 = (function() { var _ = Syndicate.__; return todo(id, _, _); })(); +var _cachedAssertion1470084349188_10 = (function() { var _ = Syndicate.__; return todo(id, _, _); })(); Syndicate.Actor.createFacet() .onEvent(false, "asserted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(todo(id, _, _), 0); }), (function() { var _ = Syndicate.__; return { assertion: todo(id, (Syndicate._$("title")), (Syndicate._$("completed"))), metalevel: 0 }; }), (function(title, completed) { -var _cachedAssertion1468254188794_11 = (function() { var _ = Syndicate.__; return todo(id, title, completed); })(); +var _cachedAssertion1470084349188_11 = (function() { var _ = Syndicate.__; return todo(id, title, completed); })(); Syndicate.Actor.createFacet() .addInitBlock((function() { db.todos[id] = {id: id, title: title, completed: completed}; localStorage['todos-syndicate'] = JSON.stringify(db); })) -.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1468254188794_11, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1468254188794_11, metalevel: 0 }; }), (function() {})).completeBuild(); })) +.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1470084349188_11, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1470084349188_11, metalevel: 0 }; }), (function() {})).completeBuild(); })) .addDoneBlock((function() { delete db.todos[id]; localStorage['todos-syndicate'] = JSON.stringify(db); })) -.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1468254188794_10, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1468254188794_10, metalevel: 0 }; }), (function() {})).completeBuild(); })).completeBuild(); })(); +.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1470084349188_10, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1470084349188_10, metalevel: 0 }; }), (function() {})).completeBuild(); })).completeBuild(); })(); }); }).startStepping(); diff --git a/examples/two-buyer-protocol/index.expanded.js b/examples/two-buyer-protocol/index.expanded.js index 1a615c9..1d77c46 100644 --- a/examples/two-buyer-protocol/index.expanded.js +++ b/examples/two-buyer-protocol/index.expanded.js @@ -107,10 +107,10 @@ function seller() { (function () { Syndicate.Actor.createFacet() .onEvent(false, "asserted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(Syndicate.observe(bookQuote(_, _)), 0); }), (function() { var _ = Syndicate.__; return { assertion: Syndicate.observe(bookQuote((Syndicate._$("title")), _)), metalevel: 0 }; }), (function(title) { -var _cachedAssertion1468254190138_0 = (function() { var _ = Syndicate.__; return Syndicate.observe(bookQuote(title, _)); })(); +var _cachedAssertion1470084350531_0 = (function() { var _ = Syndicate.__; return Syndicate.observe(bookQuote(title, _)); })(); Syndicate.Actor.createFacet() .addAssertion((function() { var _ = Syndicate.__; return Syndicate.Patch.assert(bookQuote(title, this.priceOf(title)), 0); })) -.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1468254190138_0, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1468254190138_0, metalevel: 0 }; }), (function() {})).completeBuild(); })).completeBuild(); })(); +.onEvent(true, "retracted", (function() { var _ = Syndicate.__; return Syndicate.Patch.sub(_cachedAssertion1470084350531_0, 0); }), (function() { var _ = Syndicate.__; return { assertion: _cachedAssertion1470084350531_0, metalevel: 0 }; }), (function() {})).completeBuild(); })).completeBuild(); })(); /// It also responds to order requests.