From aa04cfed5f4c18b6a0a4aef7e94b4bfea1c4b4b8 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Thu, 12 May 2016 00:06:48 -0400 Subject: [PATCH] Update --- dist/syndicatecompiler.js | 2 +- dist/syndicatecompiler.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/syndicatecompiler.js b/dist/syndicatecompiler.js index 6444701..9de2422 100644 --- a/dist/syndicatecompiler.js +++ b/dist/syndicatecompiler.js @@ -10,7 +10,7 @@ var path = require('path'); var ohm = require('ohm-js'); var ES5 = require('./es5.js'); -var grammarSource = Buffer("Ly8gLSotIGphdmFzY3JpcHQgLSotCi8vIFN5bnRhY3RpYyBleHRlbnNpb25zIHRvIEVTNSBmb3IgU3luZGljYXRlL2pzLiBTZWUgY29tcGlsZXIuanMgZm9yCi8vIHRoZSByZXN0IG9mIHRoZSB0cmFuc2xhdG9yLgoKU3luZGljYXRlIDw6IEVTNSB7CiAgLy8tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KICAvLyBFeHRlbnNpb25zIHRvIGV4cHJlc3Npb25zLgoKICBTdGF0ZW1lbnQKICAgICs9IEFjdG9yU3RhdGVtZW50CiAgICB8IERhdGFzcGFjZVN0YXRlbWVudAogICAgfCBBY3RvckZhY2V0U3RhdGVtZW50CiAgICB8IEFzc2VydGlvblR5cGVEZWNsYXJhdGlvblN0YXRlbWVudAogICAgfCBTZW5kTWVzc2FnZVN0YXRlbWVudAoKICBBY3RvclN0YXRlbWVudAogICAgPSBhY3RvciBDYWxsRXhwcmVzc2lvbiBCbG9jayAtLSB3aXRoQ29uc3RydWN0b3IKICAgIHwgYWN0b3IgQmxvY2sgICAgICAgICAgICAgICAgLS0gbm9Db25zdHJ1Y3RvcgoKICBEYXRhc3BhY2VTdGF0ZW1lbnQKICAgID0gZ3JvdW5kIG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LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCiAgLy8gS2V5d29yZHMuIFdlIGRvbid0IGFkZCB0aGVtIHRvIHRoZSAia2V5d29yZCIgcHJvZHVjdGlvbiBiZWNhdXNlCiAgLy8gd2UgZG9uJ3Qgd2FudCB0byBtYWtlIHRoZW0gdW5hdmFpbGFibGUgdG8gcHJvZ3JhbXMgYXMKICAvLyBpZGVudGlmaWVycy4KCiAgYWN0b3IgPSAiYWN0b3IiIH5pZGVudGlmaWVyUGFydAogIGFzc2VydCA9ICJhc3NlcnQiIH5pZGVudGlmaWVyUGFydAogIGFzc2VydGVkID0gImFzc2VydGVkIiB+aWRlbnRpZmllclBhcnQKICBhc3NlcnRpb24gPSAiYXNzZXJ0aW9uIiB+aWRlbnRpZmllclBhcnQKICBkYXRhc3BhY2UgPSAiZGF0YXNwYWNlIiB+aWRlbnRpZmllclBhcnQKICBkdXJpbmcgPSAiZHVyaW5nIiB+aWRlbnRpZmllclBhcnQKICBncm91bmQgPSAiZ3JvdW5kIiB+aWRlbnRpZmllclBhcnQKICBtZXNzYWdlID0gIm1lc3NhZ2UiIH5pZGVudGlmaWVyUGFydAogIG1ldGFsZXZlbCA9ICJtZXRhbGV2ZWwiIH5pZGVudGlmaWVyUGFydAogIG9uID0gIm9uIiB+aWRlbnRpZmllclBhcnQKICByZWFjdCA9ICJyZWFjdCIgfmlkZW50aWZpZXJQYXJ0CiAgcmV0cmFjdGVkID0gInJldHJhY3RlZCIgfmlkZW50aWZpZXJQYXJ0CiAgdHlwZSA9ICJ0eXBlIiB+aWRlbnRpZmllclBhcnQKICB1bnRpbCA9ICJ1bnRpbCIgfmlkZW50aWZpZXJQYXJ0CiAgd2hlbiA9ICJ3aGVuIiB+aWRlbnRpZmllclBhcnQKfQo=","base64").toString(); var grammar = ohm.grammar(grammarSource, { ES5: ES5.grammar }); var semantics = grammar.extendSemantics(ES5.semantics); diff --git a/dist/syndicatecompiler.min.js b/dist/syndicatecompiler.min.js index 72eb475..c491c5a 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":rhsExpr.buildSubscription(this.args.acc,this.args.mode);break;case"instantiated":lhsExpr.buildSubscription(this.args.acc,this.args.mode);break;case"projection":{this.args.acc.push("(Syndicate._$("+JSON.stringify(i.slice(1))+",");rhsExpr.buildSubscription(this.args.acc,this.args.mode);this.args.acc.push("))");break}default:throw new Error("Unexpected buildSubscription mode "+this.args.mode)}}else{lhsExpr.buildSubscription(this.args.acc,this.args.mode);_assignmentOperator.buildSubscription(this.args.acc,this.args.mode);rhsExpr.buildSubscription(this.args.acc,this.args.mode)}},identifier:function(_name){var i=this.interval.contents;if(i[0]==="$"&&i.length>1){switch(this.args.mode){case"pattern":this.args.acc.push("_");break;case"instantiated":this.args.acc.push(i.slice(1));break;case"projection":this.args.acc.push("(Syndicate._$("+JSON.stringify(i.slice(1))+"))");break;default:throw new Error("Unexpected buildSubscription mode "+this.args.mode)}}else{this.args.acc.push(i)}},_terminal:function(){this.args.acc.push(this.interval.contents)},_nonterminal:function(children){var self=this;forEachChild(children,function(c){c.buildSubscription(self.args.acc,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":rhsExpr.buildSubscription(this.args.acc,this.args.mode);break;case"instantiated":lhsExpr.buildSubscription(this.args.acc,this.args.mode);break;case"projection":{this.args.acc.push("(Syndicate._$("+JSON.stringify(i.slice(1))+",");rhsExpr.buildSubscription(this.args.acc,this.args.mode);this.args.acc.push("))");break}default:throw new Error("Unexpected buildSubscription mode "+this.args.mode)}}else{lhsExpr.buildSubscription(this.args.acc,this.args.mode);_assignmentOperator.buildSubscription(this.args.acc,this.args.mode);rhsExpr.buildSubscription(this.args.acc,this.args.mode)}},identifier:function(_name){var i=this.interval.contents;if(i[0]==="$"&&i.length>1){switch(this.args.mode){case"pattern":this.args.acc.push("_");break;case"instantiated":this.args.acc.push(i.slice(1));break;case"projection":this.args.acc.push("(Syndicate._$("+JSON.stringify(i.slice(1))+"))");break;default:throw new Error("Unexpected buildSubscription mode "+this.args.mode)}}else{this.args.acc.push(i)}},_terminal:function(){this.args.acc.push(this.interval.contents)},_nonterminal:function(children){var self=this;forEachChild(children,function(c){c.buildSubscription(self.args.acc,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;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}');return decl.define("alnum",[],this.alt(this.app("letter").withInterval(decl.sourceInterval(60,66)),this.app("digit").withInterval(decl.sourceInterval(73,78))).withInterval(decl.sourceInterval(60,78)),"an alpha-numeric character").define("letter",[],this.alt(this.app("lower").withInterval(decl.sourceInterval(107,112)),this.app("upper").withInterval(decl.sourceInterval(119,124)),this.app("unicodeLtmo").withInterval(decl.sourceInterval(131,142))).withInterval(decl.sourceInterval(107,142)),"a letter").define("digit",[],this.range("0","9").withInterval(decl.sourceInterval(169,177)),"a digit").define("hexDigit",[],this.alt(this.app("digit").withInterval(decl.sourceInterval(219,224)),this.range("a","f").withInterval(decl.sourceInterval(231,239)),this.range("A","F").withInterval(decl.sourceInterval(246,254))).withInterval(decl.sourceInterval(219,254)),"a hexadecimal digit").define("ListOf",["elem","sep"],this.alt(this.app("NonemptyListOf",[this.param(0),this.param(1)]).withInterval(decl.sourceInterval(282,307)),this.app("EmptyListOf",[this.param(0),this.param(1)]).withInterval(decl.sourceInterval(314,336))).withInterval(decl.sourceInterval(282,336))).define("NonemptyListOf",["elem","sep"],this.seq(this.param(0),this.star(this.seq(this.param(1),this.param(0)).withInterval(decl.sourceInterval(378,386))).withInterval(decl.sourceInterval(377,388))).withInterval(decl.sourceInterval(372,388))).define("EmptyListOf",["elem","sep"],this.seq().withInterval(decl.sourceInterval(438,438))).define("listOf",["elem","sep"],this.alt(this.app("nonemptyListOf",[this.param(0),this.param(1)]).withInterval(decl.sourceInterval(462,487)),this.app("emptyListOf",[this.param(0),this.param(1)]).withInterval(decl.sourceInterval(494,516))).withInterval(decl.sourceInterval(462,516))).define("nonemptyListOf",["elem","sep"],this.seq(this.param(0),this.star(this.seq(this.param(1),this.param(0)).withInterval(decl.sourceInterval(558,566))).withInterval(decl.sourceInterval(557,568))).withInterval(decl.sourceInterval(552,568))).define("emptyListOf",["elem","sep"],this.seq().withInterval(decl.sourceInterval(616,616))).build()})},{"..":50}],11:[function(require,module,exports){var ohm=require("..");module.exports=ohm.makeRecipe(function(){var decl=this.newGrammar("Ohm").withSource('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? "=" "|"? Alt -- define\n | ident Formals? ":=" "|"? Alt -- override\n | ident Formals? "+=" "|"? Alt -- extend\n\n Formals\n = "<" ListOf ">"\n\n Params\n = "<" ListOf ">"\n\n Alt\n = Term ("|" Term)*\n\n Term\n = Seq caseName -- inline\n | Seq\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}').withDefaultStartRule("Grammars");return decl.define("Grammars",[],this.star(this.app("Grammar").withInterval(decl.sourceInterval(24,31))).withInterval(decl.sourceInterval(24,32))).define("Grammar",[],this.seq(this.app("ident").withInterval(decl.sourceInterval(50,55)),this.opt(this.app("SuperGrammar").withInterval(decl.sourceInterval(56,68))).withInterval(decl.sourceInterval(56,69)),this.terminal("{").withInterval(decl.sourceInterval(70,73)),this.star(this.app("Rule").withInterval(decl.sourceInterval(74,78))).withInterval(decl.sourceInterval(74,79)),this.terminal("}").withInterval(decl.sourceInterval(80,83))).withInterval(decl.sourceInterval(50,83))).define("SuperGrammar",[],this.seq(this.terminal("<:").withInterval(decl.sourceInterval(106,110)),this.app("ident").withInterval(decl.sourceInterval(111,116))).withInterval(decl.sourceInterval(106,116))).define("Rule_define",[],this.seq(this.app("ident").withInterval(decl.sourceInterval(131,136)),this.opt(this.app("Formals").withInterval(decl.sourceInterval(137,144))).withInterval(decl.sourceInterval(137,145)),this.opt(this.app("ruleDescr").withInterval(decl.sourceInterval(146,155))).withInterval(decl.sourceInterval(146,156)),this.terminal("=").withInterval(decl.sourceInterval(157,160)),this.opt(this.terminal("|").withInterval(decl.sourceInterval(162,165))).withInterval(decl.sourceInterval(162,166)),this.app("Alt").withInterval(decl.sourceInterval(167,170))).withInterval(decl.sourceInterval(131,170))).define("Rule_override",[],this.seq(this.app("ident").withInterval(decl.sourceInterval(188,193)),this.opt(this.app("Formals").withInterval(decl.sourceInterval(194,201))).withInterval(decl.sourceInterval(194,202)),this.terminal(":=").withInterval(decl.sourceInterval(214,218)),this.opt(this.terminal("|").withInterval(decl.sourceInterval(219,222))).withInterval(decl.sourceInterval(219,223)),this.app("Alt").withInterval(decl.sourceInterval(224,227))).withInterval(decl.sourceInterval(188,227))).define("Rule_extend",[],this.seq(this.app("ident").withInterval(decl.sourceInterval(247,252)),this.opt(this.app("Formals").withInterval(decl.sourceInterval(253,260))).withInterval(decl.sourceInterval(253,261)),this.terminal("+=").withInterval(decl.sourceInterval(273,277)),this.opt(this.terminal("|").withInterval(decl.sourceInterval(278,281))).withInterval(decl.sourceInterval(278,282)),this.app("Alt").withInterval(decl.sourceInterval(283,286))).withInterval(decl.sourceInterval(247,286))).define("Rule",[],this.alt(this.app("Rule_define").withInterval(decl.sourceInterval(131,170)),this.app("Rule_override").withInterval(decl.sourceInterval(188,227)),this.app("Rule_extend").withInterval(decl.sourceInterval(247,286))).withInterval(decl.sourceInterval(131,297))).define("Formals",[],this.seq(this.terminal("<").withInterval(decl.sourceInterval(315,318)),this.app("ListOf",[this.app("ident").withInterval(decl.sourceInterval(326,331)),this.terminal(",").withInterval(decl.sourceInterval(333,336))]).withInterval(decl.sourceInterval(319,337)),this.terminal(">").withInterval(decl.sourceInterval(338,341))).withInterval(decl.sourceInterval(315,341))).define("Params",[],this.seq(this.terminal("<").withInterval(decl.sourceInterval(358,361)),this.app("ListOf",[this.app("Seq").withInterval(decl.sourceInterval(369,372)),this.terminal(",").withInterval(decl.sourceInterval(374,377))]).withInterval(decl.sourceInterval(362,378)),this.terminal(">").withInterval(decl.sourceInterval(379,382))).withInterval(decl.sourceInterval(358,382))).define("Alt",[],this.seq(this.app("Term").withInterval(decl.sourceInterval(396,400)),this.star(this.seq(this.terminal("|").withInterval(decl.sourceInterval(402,405)),this.app("Term").withInterval(decl.sourceInterval(406,410))).withInterval(decl.sourceInterval(402,410))).withInterval(decl.sourceInterval(401,412))).withInterval(decl.sourceInterval(396,412))).define("Term_inline",[],this.seq(this.app("Seq").withInterval(decl.sourceInterval(427,430)),this.app("caseName").withInterval(decl.sourceInterval(431,439))).withInterval(decl.sourceInterval(427,439))).define("Term",[],this.alt(this.app("Term_inline").withInterval(decl.sourceInterval(427,439)),this.app("Seq").withInterval(decl.sourceInterval(456,459))).withInterval(decl.sourceInterval(427,459))).define("Seq",[],this.star(this.app("Iter").withInterval(decl.sourceInterval(473,477))).withInterval(decl.sourceInterval(473,478))).define("Iter_star",[],this.seq(this.app("Pred").withInterval(decl.sourceInterval(493,497)),this.terminal("*").withInterval(decl.sourceInterval(498,501))).withInterval(decl.sourceInterval(493,501))).define("Iter_plus",[],this.seq(this.app("Pred").withInterval(decl.sourceInterval(517,521)),this.terminal("+").withInterval(decl.sourceInterval(522,525))).withInterval(decl.sourceInterval(517,525))).define("Iter_opt",[],this.seq(this.app("Pred").withInterval(decl.sourceInterval(541,545)),this.terminal("?").withInterval(decl.sourceInterval(546,549))).withInterval(decl.sourceInterval(541,549))).define("Iter",[],this.alt(this.app("Iter_star").withInterval(decl.sourceInterval(493,501)),this.app("Iter_plus").withInterval(decl.sourceInterval(517,525)),this.app("Iter_opt").withInterval(decl.sourceInterval(541,549)),this.app("Pred").withInterval(decl.sourceInterval(564,568))).withInterval(decl.sourceInterval(493,568))).define("Pred_not",[],this.seq(this.terminal("~").withInterval(decl.sourceInterval(583,586)),this.app("Lex").withInterval(decl.sourceInterval(587,590))).withInterval(decl.sourceInterval(583,590))).define("Pred_lookahead",[],this.seq(this.terminal("&").withInterval(decl.sourceInterval(605,608)),this.app("Lex").withInterval(decl.sourceInterval(609,612))).withInterval(decl.sourceInterval(605,612))).define("Pred",[],this.alt(this.app("Pred_not").withInterval(decl.sourceInterval(583,590)),this.app("Pred_lookahead").withInterval(decl.sourceInterval(605,612)),this.app("Lex").withInterval(decl.sourceInterval(633,636))).withInterval(decl.sourceInterval(583,636))).define("Lex_lex",[],this.seq(this.terminal("#").withInterval(decl.sourceInterval(650,653)),this.app("Base").withInterval(decl.sourceInterval(654,658))).withInterval(decl.sourceInterval(650,658))).define("Lex",[],this.alt(this.app("Lex_lex").withInterval(decl.sourceInterval(650,658)),this.app("Base").withInterval(decl.sourceInterval(673,677))).withInterval(decl.sourceInterval(650,677))).define("Base_application",[],this.seq(this.app("ident").withInterval(decl.sourceInterval(692,697)),this.opt(this.app("Params").withInterval(decl.sourceInterval(698,704))).withInterval(decl.sourceInterval(698,705)),this.not(this.alt(this.seq(this.opt(this.app("ruleDescr").withInterval(decl.sourceInterval(708,717))).withInterval(decl.sourceInterval(708,718)),this.terminal("=").withInterval(decl.sourceInterval(719,722))).withInterval(decl.sourceInterval(708,722)),this.terminal(":=").withInterval(decl.sourceInterval(725,729)),this.terminal("+=").withInterval(decl.sourceInterval(732,736))).withInterval(decl.sourceInterval(708,736))).withInterval(decl.sourceInterval(706,737))).withInterval(decl.sourceInterval(692,737))).define("Base_range",[],this.seq(this.app("terminal").withInterval(decl.sourceInterval(760,768)),this.terminal("..").withInterval(decl.sourceInterval(769,773)),this.app("terminal").withInterval(decl.sourceInterval(774,782))).withInterval(decl.sourceInterval(760,782))).define("Base_terminal",[],this.app("terminal").withInterval(decl.sourceInterval(822,830))).define("Base_paren",[],this.seq(this.terminal("(").withInterval(decl.sourceInterval(887,890)),this.app("Alt").withInterval(decl.sourceInterval(891,894)),this.terminal(")").withInterval(decl.sourceInterval(895,898))).withInterval(decl.sourceInterval(887,898))).define("Base",[],this.alt(this.app("Base_application").withInterval(decl.sourceInterval(692,737)),this.app("Base_range").withInterval(decl.sourceInterval(760,782)),this.app("Base_terminal").withInterval(decl.sourceInterval(822,830)),this.app("Base_paren").withInterval(decl.sourceInterval(887,898))).withInterval(decl.sourceInterval(692,942))).define("ruleDescr",[],this.seq(this.terminal("(").withInterval(decl.sourceInterval(984,987)),this.app("ruleDescrText").withInterval(decl.sourceInterval(988,1001)),this.terminal(")").withInterval(decl.sourceInterval(1002,1005))).withInterval(decl.sourceInterval(984,1005)),"a rule description").define("ruleDescrText",[],this.star(this.seq(this.not(this.terminal(")").withInterval(decl.sourceInterval(1031,1034))).withInterval(decl.sourceInterval(1030,1034)),this.app("any").withInterval(decl.sourceInterval(1035,1038))).withInterval(decl.sourceInterval(1030,1038))).withInterval(decl.sourceInterval(1029,1040))).define("caseName",[],this.seq(this.terminal("--").withInterval(decl.sourceInterval(1059,1063)),this.star(this.seq(this.not(this.terminal("\n").withInterval(decl.sourceInterval(1066,1070))).withInterval(decl.sourceInterval(1065,1070)),this.app("space").withInterval(decl.sourceInterval(1071,1076))).withInterval(decl.sourceInterval(1065,1076))).withInterval(decl.sourceInterval(1064,1078)),this.app("name").withInterval(decl.sourceInterval(1079,1083)),this.star(this.seq(this.not(this.terminal("\n").withInterval(decl.sourceInterval(1086,1090))).withInterval(decl.sourceInterval(1085,1090)),this.app("space").withInterval(decl.sourceInterval(1091,1096))).withInterval(decl.sourceInterval(1085,1096))).withInterval(decl.sourceInterval(1084,1098)),this.alt(this.terminal("\n").withInterval(decl.sourceInterval(1100,1104)),this.la(this.terminal("}").withInterval(decl.sourceInterval(1108,1111))).withInterval(decl.sourceInterval(1107,1111))).withInterval(decl.sourceInterval(1100,1111))).withInterval(decl.sourceInterval(1059,1112))).define("name",[],this.seq(this.app("nameFirst").withInterval(decl.sourceInterval(1137,1146)),this.star(this.app("nameRest").withInterval(decl.sourceInterval(1147,1155))).withInterval(decl.sourceInterval(1147,1156))).withInterval(decl.sourceInterval(1137,1156)),"a name").define("nameFirst",[],this.alt(this.terminal("_").withInterval(decl.sourceInterval(1176,1179)),this.app("letter").withInterval(decl.sourceInterval(1186,1192))).withInterval(decl.sourceInterval(1176,1192))).define("nameRest",[],this.alt(this.terminal("_").withInterval(decl.sourceInterval(1211,1214)),this.app("alnum").withInterval(decl.sourceInterval(1221,1226))).withInterval(decl.sourceInterval(1211,1226))).define("ident",[],this.app("name").withInterval(decl.sourceInterval(1259,1263)),"an identifier").define("terminal",[],this.seq(this.terminal('"').withInterval(decl.sourceInterval(1282,1286)),this.star(this.app("terminalChar").withInterval(decl.sourceInterval(1287,1299))).withInterval(decl.sourceInterval(1287,1300)),this.terminal('"').withInterval(decl.sourceInterval(1301,1305))).withInterval(decl.sourceInterval(1282,1305))).define("terminalChar",[],this.alt(this.app("escapeChar").withInterval(decl.sourceInterval(1328,1338)),this.seq(this.not(this.terminal("\\").withInterval(decl.sourceInterval(1346,1350))).withInterval(decl.sourceInterval(1345,1350)),this.not(this.terminal('"').withInterval(decl.sourceInterval(1352,1356))).withInterval(decl.sourceInterval(1351,1356)),this.not(this.terminal("\n").withInterval(decl.sourceInterval(1358,1362))).withInterval(decl.sourceInterval(1357,1362)),this.app("any").withInterval(decl.sourceInterval(1363,1366))).withInterval(decl.sourceInterval(1345,1366))).withInterval(decl.sourceInterval(1328,1366))).define("escapeChar_backslash",[],this.terminal("\\\\").withInterval(decl.sourceInterval(1409,1415))).define("escapeChar_doubleQuote",[],this.terminal('\\"').withInterval(decl.sourceInterval(1471,1477))).define("escapeChar_singleQuote",[],this.terminal("\\'").withInterval(decl.sourceInterval(1535,1541))).define("escapeChar_backspace",[],this.terminal("\\b").withInterval(decl.sourceInterval(1599,1604))).define("escapeChar_lineFeed",[],this.terminal("\\n").withInterval(decl.sourceInterval(1661,1666))).define("escapeChar_carriageReturn",[],this.terminal("\\r").withInterval(decl.sourceInterval(1722,1727))).define("escapeChar_tab",[],this.terminal("\\t").withInterval(decl.sourceInterval(1789,1794))).define("escapeChar_unicodeEscape",[],this.seq(this.terminal("\\u").withInterval(decl.sourceInterval(1845,1850)),this.app("hexDigit").withInterval(decl.sourceInterval(1851,1859)),this.app("hexDigit").withInterval(decl.sourceInterval(1860,1868)),this.app("hexDigit").withInterval(decl.sourceInterval(1869,1877)),this.app("hexDigit").withInterval(decl.sourceInterval(1878,1886))).withInterval(decl.sourceInterval(1845,1886))).define("escapeChar_hexEscape",[],this.seq(this.terminal("\\x").withInterval(decl.sourceInterval(1911,1916)),this.app("hexDigit").withInterval(decl.sourceInterval(1917,1925)),this.app("hexDigit").withInterval(decl.sourceInterval(1926,1934))).withInterval(decl.sourceInterval(1911,1934))).define("escapeChar",[],this.alt(this.app("escapeChar_backslash").withInterval(decl.sourceInterval(1409,1415)),this.app("escapeChar_doubleQuote").withInterval(decl.sourceInterval(1471,1477)),this.app("escapeChar_singleQuote").withInterval(decl.sourceInterval(1535,1541)),this.app("escapeChar_backspace").withInterval(decl.sourceInterval(1599,1604)),this.app("escapeChar_lineFeed").withInterval(decl.sourceInterval(1661,1666)),this.app("escapeChar_carriageReturn").withInterval(decl.sourceInterval(1722,1727)),this.app("escapeChar_tab").withInterval(decl.sourceInterval(1789,1794)),this.app("escapeChar_unicodeEscape").withInterval(decl.sourceInterval(1845,1886)),this.app("escapeChar_hexEscape").withInterval(decl.sourceInterval(1911,1934))).withInterval(decl.sourceInterval(1409,1966)),"an escape sequence").extend("space",[],this.app("comment").withInterval(decl.sourceInterval(1982,1989))).define("comment_singleLine",[],this.seq(this.terminal("//").withInterval(decl.sourceInterval(2007,2011)),this.star(this.seq(this.not(this.terminal("\n").withInterval(decl.sourceInterval(2014,2018))).withInterval(decl.sourceInterval(2013,2018)),this.app("any").withInterval(decl.sourceInterval(2019,2022))).withInterval(decl.sourceInterval(2013,2022))).withInterval(decl.sourceInterval(2012,2024)),this.terminal("\n").withInterval(decl.sourceInterval(2025,2029))).withInterval(decl.sourceInterval(2007,2029))).define("comment_multiLine",[],this.seq(this.terminal("/*").withInterval(decl.sourceInterval(2051,2055)),this.star(this.seq(this.not(this.terminal("*/").withInterval(decl.sourceInterval(2058,2062))).withInterval(decl.sourceInterval(2057,2062)),this.app("any").withInterval(decl.sourceInterval(2063,2066))).withInterval(decl.sourceInterval(2057,2066))).withInterval(decl.sourceInterval(2056,2068)),this.terminal("*/").withInterval(decl.sourceInterval(2069,2073))).withInterval(decl.sourceInterval(2051,2073))).define("comment",[],this.alt(this.app("comment_singleLine").withInterval(decl.sourceInterval(2007,2029)),this.app("comment_multiLine").withInterval(decl.sourceInterval(2051,2073))).withInterval(decl.sourceInterval(2007,2087))).define("tokens",[],this.star(this.app("token").withInterval(decl.sourceInterval(2100,2105))).withInterval(decl.sourceInterval(2100,2106))).define("token",[],this.alt(this.app("caseName").withInterval(decl.sourceInterval(2118,2126)),this.app("comment").withInterval(decl.sourceInterval(2129,2136)),this.app("ident").withInterval(decl.sourceInterval(2139,2144)),this.app("operator").withInterval(decl.sourceInterval(2147,2155)),this.app("punctuation").withInterval(decl.sourceInterval(2158,2169)),this.app("terminal").withInterval(decl.sourceInterval(2172,2180)),this.app("any").withInterval(decl.sourceInterval(2183,2186))).withInterval(decl.sourceInterval(2118,2186))).define("operator",[],this.alt(this.terminal("<:").withInterval(decl.sourceInterval(2201,2205)),this.terminal("=").withInterval(decl.sourceInterval(2208,2211)),this.terminal(":=").withInterval(decl.sourceInterval(2214,2218)),this.terminal("+=").withInterval(decl.sourceInterval(2221,2225)),this.terminal("*").withInterval(decl.sourceInterval(2228,2231)),this.terminal("+").withInterval(decl.sourceInterval(2234,2237)),this.terminal("?").withInterval(decl.sourceInterval(2240,2243)),this.terminal("~").withInterval(decl.sourceInterval(2246,2249)),this.terminal("&").withInterval(decl.sourceInterval(2252,2255))).withInterval(decl.sourceInterval(2201,2255))).define("punctuation",[],this.alt(this.terminal("<").withInterval(decl.sourceInterval(2273,2276)),this.terminal(">").withInterval(decl.sourceInterval(2279,2282)),this.terminal(",").withInterval(decl.sourceInterval(2285,2288)),this.terminal("--").withInterval(decl.sourceInterval(2291,2295))).withInterval(decl.sourceInterval(2273,2295))).build()})},{"..":50}],12:[function(require,module,exports){var ohm=require("..");module.exports=ohm.makeRecipe(function(){var decl=this.newGrammar("OperationsAndAttributes").withSource('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}').withDefaultStartRule("AttributeSignature");return decl.define("AttributeSignature",[],this.app("name").withInterval(decl.sourceInterval(54,58))).define("OperationSignature",[],this.seq(this.app("name").withInterval(decl.sourceInterval(87,91)),this.opt(this.app("Formals").withInterval(decl.sourceInterval(92,99))).withInterval(decl.sourceInterval(92,100))).withInterval(decl.sourceInterval(87,100))).define("Formals",[],this.seq(this.terminal("(").withInterval(decl.sourceInterval(118,121)),this.app("ListOf",[this.app("name").withInterval(decl.sourceInterval(129,133)),this.terminal(",").withInterval(decl.sourceInterval(135,138))]).withInterval(decl.sourceInterval(122,139)),this.terminal(")").withInterval(decl.sourceInterval(140,143))).withInterval(decl.sourceInterval(118,143))).define("name",[],this.seq(this.app("nameFirst").withInterval(decl.sourceInterval(168,177)),this.star(this.app("nameRest").withInterval(decl.sourceInterval(178,186))).withInterval(decl.sourceInterval(178,187))).withInterval(decl.sourceInterval(168,187)),"a name").define("nameFirst",[],this.alt(this.terminal("_").withInterval(decl.sourceInterval(207,210)),this.app("letter").withInterval(decl.sourceInterval(217,223))).withInterval(decl.sourceInterval(207,223))).define("nameRest",[],this.alt(this.terminal("_").withInterval(decl.sourceInterval(242,245)),this.app("alnum").withInterval(decl.sourceInterval(252,257))).withInterval(decl.sourceInterval(242,257))).build(); })},{"..":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 pexprs=require("./pexprs");function Builder(){}Builder.prototype={newGrammar:function(name){return new GrammarDecl(name)},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){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){if(this.isBuiltIn()){throw new Error("Why would anyone want to generate a recipe for the "+this.name+" grammar?!?!")}var sb=new common.StringBuffer;if(optVarName){sb.append("var "+optVarName+" = ")}sb.append("(function() {\n");var superGrammarDecl="";if(!this.superGrammar.isBuiltIn()){sb.append(this.superGrammar.toRecipe("buildSuperGrammar"));superGrammarDecl=" .withSuperGrammar(buildSuperGrammar.call(this))\n"}sb.append(" var decl = this.newGrammar("+JSON.stringify(this.name)+")\n");if(this.definitionInterval){sb.append(" .withSource("+JSON.stringify(this.definitionInterval.contents)+")\n")}sb.append(superGrammarDecl);if(this.defaultStartRule){sb.append(' .withDefaultStartRule("'+this.defaultStartRule+'")\n')}sb.append(" return decl\n");var self=this;Object.keys(this.ruleBodies).forEach(function(ruleName){var body=self.ruleBodies[ruleName];sb.append(" .");if(self.superGrammar.ruleBodies[ruleName]){sb.append(body instanceof pexprs.Extend?"extend":"override")}else{sb.append("define")}var formals=self.ruleFormals[ruleName];var formalsString="["+formals.map(JSON.stringify).join(", ")+"]";sb.append("("+JSON.stringify(ruleName)+", "+formalsString+", ");body.outputRecipe(sb,formals,self.definitionInterval);if(!self.superGrammar.ruleBodies[ruleName]&&self.ruleDescriptions[ruleName]){sb.append(", "+JSON.stringify(self.ruleDescriptions[ruleName]))}sb.append(")\n")});sb.append(" .build();\n});\n");return sb.contents()},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;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}});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,