syndicate-2017/dist/syndicatecompiler.min.js

8 lines
260 KiB
JavaScript
Raw Normal View History

2016-04-06 16:22:30 +00:00
(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;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){(function(Buffer){"use strict";var path=require("path");var ohm=require("ohm-js");var ES5=require("./es5.js");var grammarSource=Buffer("Ly8gLSotIGphdmFzY3JpcHQgLSotCi8vIFN5bnRhY3RpYyBleHRlbnNpb25zIHRvIEVTNSBmb3IgU3luZGljYXRlL2pzLiBTZWUgY29tcGlsZXIuanMgZm9yCi8vIHRoZSByZXN0IG9mIHRoZSB0cmFuc2xhdG9yLgoKU3luZGljYXRlIDw6IEVTNSB7CiAgLy8tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KICAvLyBFeHRlbnNpb25zIHRvIGV4cHJlc3Npb25zLgoKICBTdGF0ZW1lbnQKICAgICs9IEFjdG9yU3RhdGVtZW50CiAgICB8IE5ldHdvcmtTdGF0ZW1lbnQKICAgIHwgQWN0b3JGYWNldFN0YXRlbWVudAogICAgfCBBc3NlcnRpb25UeXBlRGVjbGFyYXRpb25TdGF0ZW1lbnQKICAgIHwgU2Vu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ZXJhbCAtLSB3aXRoTWV0YWxldmVsCiAgICB8IExlZnRIYW5kU2lkZUV4cHJlc3Npb24gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtLSBub01ldGFsZXZlbAoKICAvLy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQogIC8vIEtleXdvcmRzLiBXZSBkb24ndCBhZGQgdGhlbSB0byB0aGUgImtleXdvcmQiIHByb2R1Y3Rpb24gYmVjYXVzZQogIC8vIHdlIGRvbid0IHdhbnQgdG8gbWFrZSB0aGVtIHVuYXZhaWxhYmxlIHRvIHByb2dyYW1zIG
var g=ohm.grammars(contents).ES5;var semantics=g.semantics();semantics.addAttribute("modifiedSource",modifiedSourceActions);semantics.addAttribute("asES5",{_nonterminal:function(children){return isUndefined(this.modifiedSource)?this.interval.contents:this.modifiedSource}});module.exports={grammar:g,semantics:semantics}}).call(this,require("buffer").Buffer)},{buffer:4,"ohm-js":50,path:8}],3:[function(require,module,exports){"use strict";var compiler=require("./compiler.js");function getUrlContent(url){var req=new XMLHttpRequest;req.open("GET",url,false);try{req.send();if(req.status===0||req.status===200){return req.responseText}}catch(e){console.error("Error while loading "+url,e)}return false}function translateSyndicateScripts(){var scriptNodes=document.querySelectorAll('script[type="text/syndicate-js"]');var allSources=[];for(var i=0;i<scriptNodes.length;i++){var n=scriptNodes[i];var srcUrl=n.getAttribute("src");allSources.push(srcUrl?getUrlContent(srcUrl):n.innerHTML)}var allSourceText=allSources.join("\n;\n");var output=compiler.compileSyndicateSource(allSourceText);var f=new Function(output);f()}document.addEventListener("DOMContentLoaded",translateSyndicateScripts,false);module.exports=compiler},{"./compiler.js":1}],4:[function(require,module,exports){(function(global){"use strict";var base64=require("base64-js");var ieee754=require("ieee754");var isArray=require("isarray");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;Buffer.poolSize=8192;var rootParent={};Buffer.TYPED_ARRAY_SUPPORT=global.TYPED_ARRAY_SUPPORT!==undefined?global.TYPED_ARRAY_SUPPORT:typedArraySupport();function typedArraySupport(){try{var arr=new Uint8Array(1);arr.foo=function(){return 42};return arr.foo()===42&&typeof arr.subarray==="function"&&arr.subarray(1,1).byteLength===0}catch(e){return false}}function kMaxLength(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Buffer(arg){if(!(this instanceof Buffer)){if(arguments.length>1)return new Buffer(arg,arguments[1]);return new Buffer(arg)}if(!Buffer.TYPED_ARRAY_SUPPORT){this.length=0;this.parent=undefined}if(typeof arg==="number"){return fromNumber(this,arg)}if(typeof arg==="string"){return fromString(this,arg,arguments.length>1?arguments[1]:"utf8")}return fromObject(this,arg)}Buffer._augment=function(arr){arr.__proto__=Buffer.prototype;return arr};function fromNumber(that,length){that=allocate(that,length<0?0:checked(length)|0);if(!Buffer.TYPED_ARRAY_SUPPORT){for(var i=0;i<length;i++){that[i]=0}}return that}function fromString(that,string,encoding){if(typeof encoding!=="string"||encoding==="")encoding="utf8";var length=byteLength(string,encoding)|0;that=allocate(that,length);that.write(string,encoding);return that}function fromObject(that,object){if(Buffer.isBuffer(object))return fromBuffer(that,object);if(isArray(object))return fromArray(that,object);if(object==null){throw new TypeError("must start with number, buffer, array or string")}if(typeof ArrayBuffer!=="undefined"){if(object.buffer instanceof ArrayBuffer){return fromTypedArray(that,object)}if(object instanceof ArrayBuffer){return fromArrayBuffer(that,object)}}if(object.length)return fromArrayLike(that,object);return fromJsonObject(that,object)}function fromBuffer(that,buffer){var length=checked(buffer.length)|0;that=allocate(that,length);buffer.copy(that,0,0,length);return that}function fromArray(that,array){var length=checked(array.length)|0;that=allocate(that,length);for(var i=0;i<length;i+=1){that[i]=array[i]&255}return that}function fromTypedArray(that,array){var length=checked(array.length)|0;that=allocate(that,length);for(var i=0;i<length;i+=1){that[i]=array[i]&255}return that}function fromArrayBuffer(that,array){array.byteLength;if(Buffer.TYPED_ARRAY_SUPPORT){that=new Uint8Array(array);that.__proto__=Buffer.prototype}else{that=fromTypedArray(that,new Uint8Array(array))}return that}function fromArrayLike(that,array){var length=checked(array.length)|0;that=allocate(that,length);for(var i=0;i<length;i+=1){that[i]=array[i]&255}return that}function fromJsonObject(that,object){var array
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<<mLen|m;eLen+=mLen;for(;eLen>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<arr.length;start++){if(arr[start]!=="")break}var end=arr.length-1;for(;end>=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;i<length;i++){if(fromParts[i]!==toParts[i]){samePartsLength=i;break}}var outputParts=[];for(var i=samePartsLength;i<fromParts.length;i++){outputParts.push("..")}outputParts=outputParts.concat(toParts.slice(samePartsLength));return outputParts.join("/")};exports.sep="/";exports.delimiter=":";exports.dirname=function(path){var result=splitPath(path),root=result[0],dir=result[1];if(!root&&!dir){return"."}if(dir){dir=dir.substr(0,dir.length-1)}return root+dir};exports.basename=function(path,ext){var f=splitPath(path)[2];if(ext&&f.substr(-1*ext.length)===ext){f=f.substr(0,f.length-ext.length)}return f};exports.extname=function(path){return splitPath(path)[3]};function filter(xs,f){if(xs.filter)return xs.filter(f);var res=[];for(var i=0;i<xs.length;i++){if(f(xs[i],i,xs))res.push(xs[i])}return res}var substr="ab".substr(-1)==="b"?function(str,start,len){return str.substr(start,len)}:function(str,start,len){if(start<0)start=str.length+start;return str.substr(start,len)}}).call(this,require("_process"))},{_process:9}],9:[function(require,module,exports){var process=module.exports={};var queue=[];var draining=false;var currentQueue;var queueIndex=-1;function cleanUpNextTick(){draining=false;if(currentQueue.length){queue=currentQueue.concat(queue)}else{queueIndex=-1}if(queue.length){drainQueue()}}function drainQueue(){if(draining){return}var timeout=setTimeout(cleanUpNextTick);draining=true;var len=queue.length;while(len){currentQueue=queue;queue=[];while(++queueIndex<len){if(currentQueue){currentQueue[queue
return decl.define("NameNoFormals",[],this.app("name").withInterval(decl.sourceInterval(49,53))).define("NameAndFormals",[],this.seq(this.app("name").withInterval(decl.sourceInterval(78,82)),this.opt(this.app("Formals").withInterval(decl.sourceInterval(83,90))).withInterval(decl.sourceInterval(83,91))).withInterval(decl.sourceInterval(78,91))).define("Formals",[],this.seq(this.prim("(").withInterval(decl.sourceInterval(109,112)),this.app("ListOf",[this.app("name").withInterval(decl.sourceInterval(120,124)),this.prim(",").withInterval(decl.sourceInterval(126,129))]).withInterval(decl.sourceInterval(113,130)),this.prim(")").withInterval(decl.sourceInterval(131,134))).withInterval(decl.sourceInterval(109,134))).define("name",[],this.seq(this.app("nameFirst").withInterval(decl.sourceInterval(159,168)),this.star(this.app("nameRest").withInterval(decl.sourceInterval(169,177))).withInterval(decl.sourceInterval(169,178))).withInterval(decl.sourceInterval(159,178)),"a name").define("nameFirst",[],this.alt(this.prim("_").withInterval(decl.sourceInterval(198,201)),this.app("letter").withInterval(decl.sourceInterval(208,214))).withInterval(decl.sourceInterval(198,214))).define("nameRest",[],this.alt(this.prim("_").withInterval(decl.sourceInterval(233,236)),this.app("alnum").withInterval(decl.sourceInterval(243,248))).withInterval(decl.sourceInterval(233,248))).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={_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:s
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;idx<failures.length;idx++){if(idx>0){if(idx===failures.length-1){sb.append(failures.length>2?", or ":" or ")}else{sb.append(", ")}}sb.append(failures[idx].toString())}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){this.state=state;this.applicationMemoKeyStack=[];this.memo={};this.currentLeftRecursion=undefined}PosInfo.prototype={isActive:function(application){return this.applicationMemoKeyStack.indexOf(application.toMemoKey()
}function multipleErrors(errors){var messages=errors.map(function(e){return e.message});return createError(["Errors:"].concat(messages).join("\n- "),errors[0].interval)}module.exports={applicationOfSyntacticRuleFromLexicalContext:applicationOfSyntacticRuleFromLexicalContext,cannotExtendUndeclaredRule:cannotExtendUndeclaredRule,cannotOverrideUndeclaredRule:cannotOverrideUndeclaredRule,duplicateGrammarDeclaration:duplicateGrammarDeclaration,duplicateParameterNames:duplicateParameterNames,duplicatePropertyNames:duplicatePropertyNames,duplicateRuleDeclaration:duplicateRuleDeclaration,exprMixesValueAndStringExpressions:exprMixesValueAndStringExpressions,inconsistentArity:inconsistentArity,intervalSourcesDontMatch:intervalSourcesDontMatch,invalidConstructorCall:invalidConstructorCall,invalidParameter:invalidParameter,grammarSyntaxError:grammarSyntaxError,kleeneExprHasNullableOperand:kleeneExprHasNullableOperand,undeclaredGrammar:undeclaredGrammar,undeclaredRule:undeclaredRule,wrongNumberOfArguments:wrongNumberOfArguments,wrongNumberOfParameters:wrongNumberOfParameters,throwErrors:function(errors){if(errors.length===1){throw errors[0]}if(errors.length>1){throw multipleErrors(errors)}}}},{"./Namespace":43}],50:[function(require,module,exports){"use strict";var Builder=require("./Builder");var Grammar=require("./Grammar");var Namespace=require("./Namespace");var common=require("./common");var errors=require("./errors");var pexprs=require("./pexprs");var util=require("./util");var isBuffer=require("is-buffer");var ohmGrammar;var documentInterface={querySelector:function(sel){return document.querySelector(sel)},querySelectorAll:function(sel){return document.querySelectorAll(sel)}};function isElement(obj){return!!(obj&&obj.nodeType===1)}function isUndefined(obj){return obj===void 0}var MAX_ARRAY_INDEX=Math.pow(2,53)-1;function isArrayLike(obj){if(obj==null){return false}var length=obj.length;return typeof length==="number"&&length>=0&&length<=MAX_ARRAY_INDEX}function load(url){var req=new XMLHttpRequest;req.open("GET",url,false);try{req.send();if(req.status===0||req.status===200){return req.responseText}}catch(e){}throw new Error("unable to load url "+url)}function buildGrammar(match,namespace,optOhmGrammarForTesting){var builder=new Builder;var decl;var currentRuleName;var currentRuleFormals;var overriding=false;var metaGrammar=optOhmGrammarForTesting||ohmGrammar;var helpers=metaGrammar.semantics().addOperation("visit",{Grammar:function(n,s,open,rs,close){var grammarName=n.visit();decl=builder.newGrammar(grammarName,namespace);s.visit();rs.visit();var g=decl.build();g.definitionInterval=this.interval.trimmed();if(grammarName in namespace){throw errors.duplicateGrammarDeclaration(g,namespace)}namespace[grammarName]=g;return g},SuperGrammar:function(_,n){var superGrammarName=n.visit();if(superGrammarName==="null"){decl.withSuperGrammar(null)}else{if(!namespace||!(superGrammarName in namespace)){throw errors.undeclaredGrammar(superGrammarName,namespace,n.interval)}decl.withSuperGrammar(namespace[superGrammarName])}},Rule_define:function(n,fs,d,_equals,_optBar,b){currentRuleName=n.visit();currentRuleFormals=fs.visit()[0]||[];if(!decl.defaultStartRule&&decl.ensureSuperGrammar()!==Grammar.ProtoBuiltInRules){decl.withDefaultStartRule(currentRuleName)}var body=b.visit();body.definitionInterval=this.interval.trimmed();var description=d.visit()[0];return decl.define(currentRuleName,currentRuleFormals,body,description)},Rule_override:function(n,fs,_colonEquals,_optBar,b){currentRuleName=n.visit();currentRuleFormals=fs.visit()[0]||[];overriding=true;var body=b.visit();body.definitionInterval=this.interval.trimmed();var ans=decl.override(currentRuleName,currentRuleFormals,body);overriding=false;return ans},Rule_extend:function(n,fs,_plusEquals,_optBar,b){currentRuleName=n.visit();currentRuleFormals=fs.visit()[0]||[];var body=b.visit();var ans=decl.extend(currentRuleName,currentRuleFormals,body);decl.ruleBodies[currentRuleName].definitionInterval=this.interval.trimmed();return ans},Formals:function(opointy,fs,cpointy){return fs.visit()},Params:
if(!newValue){return false}var inputStream=state.inputStream;while(true){lrMemoRec.pos=inputStream.pos;lrMemoRec.value=newValue;lrMemoRec.failuresAtRightmostPosition=state.cloneRightmostFailures();if(state.isTracing()){var children=state.trace[state.trace.length-1].children.slice();lrMemoRec.traceEntry=new Trace(state.inputStream,origPos,this,newValue,children)}inputStream.pos=origPos;newValue=this.evalOnce(body,state);if(inputStream.pos<=lrMemoRec.pos){break}}if(state.isTracing()){state.trace.pop();lrMemoRec.traceEntry=null}inputStream.pos=lrMemoRec.pos;return lrMemoRec.value};pexprs.Apply.prototype.entireInputWasConsumed=function(state){if(this.isSyntactic()){state.skipSpaces()}if(!state.eval(pexprs.end)){return false}state.bindings.pop();return true};pexprs.UnicodeChar.prototype.eval=function(state){var origPos=state.skipSpacesIfInSyntacticContext();var inputStream=state.inputStream;var value=inputStream.next();if(value===common.fail||!this.pattern.test(value)){state.processFailure(origPos,this);return false}else{var interval=inputStream.interval(origPos);state.bindings.push(new TerminalNode(state.grammar,value,interval));return true}};pexprs.TypeCheck.prototype.eval=function(state){var inputStream=state.inputStream;var origPos=inputStream.pos;var value=inputStream.next();if(typeof value===this.type){var interval=inputStream.interval(origPos);state.bindings.push(new TerminalNode(state.grammar,value,interval));return true}else{state.processFailure(origPos,this);return false}}},{"./InputStream":40,"./Trace":47,"./common":48,"./nodes":51,"./pexprs":67}],58:[function(require,module,exports){"use strict";var common=require("./common");var pexprs=require("./pexprs");pexprs.PExpr.prototype.getArity=common.abstract;pexprs.any.getArity=pexprs.end.getArity=pexprs.Prim.prototype.getArity=pexprs.Range.prototype.getArity=pexprs.Param.prototype.getArity=pexprs.Apply.prototype.getArity=pexprs.TypeCheck.prototype.getArity=pexprs.UnicodeChar.prototype.getArity=function(){return 1};pexprs.Alt.prototype.getArity=function(){return this.terms.length===0?0:this.terms[0].getArity()};pexprs.Seq.prototype.getArity=function(){var arity=0;for(var idx=0;idx<this.factors.length;idx++){arity+=this.factors[idx].getArity()}return arity};pexprs.Iter.prototype.getArity=function(){return this.expr.getArity()};pexprs.Not.prototype.getArity=function(){return 0};pexprs.Lookahead.prototype.getArity=pexprs.Lex.prototype.getArity=pexprs.Value.prototype.getArity=pexprs.Arr.prototype.getArity=function(){return this.expr.getArity()};pexprs.Obj.prototype.getArity=function(){var arity=this.isLenient?1:0;for(var idx=0;idx<this.properties.length;idx++){arity+=this.properties[idx].pattern.getArity()}return arity}},{"./common":48,"./pexprs":67}],59:[function(require,module,exports){"use strict";var common=require("./common");var errors=require("./errors");var pexprs=require("./pexprs");function typeFromPrimitive(prim){return typeof prim==="string"?pexprs.TYPE_STRING:pexprs.TYPE_VALUE}pexprs.PExpr.prototype.getExprType=function(grammar,optMemo){if(!this.hasOwnProperty("_exprType")){var memo=optMemo||Object.create(null);Object.defineProperty(this,"_exprType",{value:this._calculateExprType(grammar,memo)})}return this._exprType};pexprs.PExpr.prototype._calculateExprType=common.abstract;pexprs.any._calculateExprType=pexprs.UnicodeChar.prototype._calculateExprType=function(grammar,memo){return pexprs.TYPE_STRING};pexprs.end._calculateExprType=function(grammar,memo){return pexprs.TYPE_ANY};pexprs.Range.prototype._calculateExprType=function(grammar,memo){return typeFromPrimitive(this.from)|typeFromPrimitive(this.to)};pexprs.Arr.prototype._calculateExprType=pexprs.Obj.prototype._calculateExprType=pexprs.TypeCheck.prototype._calculateExprType=pexprs.Value.prototype._calculateExprType=function(grammar,memo){return pexprs.TYPE_VALUE};pexprs.Prim.prototype._calculateExprType=function(grammar,memo){return typeFromPrimitive(this.obj)};pexprs.Alt.prototype._calculateExprType=function(grammar,memo){var ans=this.terms.reduce(function(acc,t){return acc|t.getExprType(grammar,memo)},0);
Ll:/[\u0061-\u007A]|[\u00AA-\u00AA]|[\u00B5-\u00B5]|[\u00BA-\u00BA]|[\u00DF-\u00F6]|[\u00F8-\u00FF]|[\u0101-\u0101]|[\u0103-\u0103]|[\u0105-\u0105]|[\u0107-\u0107]|[\u0109-\u0109]|[\u010B-\u010B]|[\u010D-\u010D]|[\u010F-\u010F]|[\u0111-\u0111]|[\u0113-\u0113]|[\u0115-\u0115]|[\u0117-\u0117]|[\u0119-\u0119]|[\u011B-\u011B]|[\u011D-\u011D]|[\u011F-\u011F]|[\u0121-\u0121]|[\u0123-\u0123]|[\u0125-\u0125]|[\u0127-\u0127]|[\u0129-\u0129]|[\u012B-\u012B]|[\u012D-\u012D]|[\u012F-\u012F]|[\u0131-\u0131]|[\u0133-\u0133]|[\u0135-\u0135]|[\u0137-\u0138]|[\u013A-\u013A]|[\u013C-\u013C]|[\u013E-\u013E]|[\u0140-\u0140]|[\u0142-\u0142]|[\u0144-\u0144]|[\u0146-\u0146]|[\u0148-\u0149]|[\u014B-\u014B]|[\u014D-\u014D]|[\u014F-\u014F]|[\u0151-\u0151]|[\u0153-\u0153]|[\u0155-\u0155]|[\u0157-\u0157]|[\u0159-\u0159]|[\u015B-\u015B]|[\u015D-\u015D]|[\u015F-\u015F]|[\u0161-\u0161]|[\u0163-\u0163]|[\u0165-\u0165]|[\u0167-\u0167]|[\u0169-\u0169]|[\u016B-\u016B]|[\u016D-\u016D]|[\u016F-\u016F]|[\u0171-\u0171]|[\u0173-\u0173]|[\u0175-\u0175]|[\u0177-\u0177]|[\u017A-\u017A]|[\u017C-\u017C]|[\u017E-\u0180]|[\u0183-\u0183]|[\u0185-\u0185]|[\u0188-\u0188]|[\u018C-\u018D]|[\u0192-\u0192]|[\u0195-\u0195]|[\u0199-\u019B]|[\u019E-\u019E]|[\u01A1-\u01A1]|[\u01A3-\u01A3]|[\u01A5-\u01A5]|[\u01A8-\u01A8]|[\u01AB-\u01AB]|[\u01AD-\u01AD]|[\u01B0-\u01B0]|[\u01B4-\u01B4]|[\u01B6-\u01B6]|[\u01B9-\u01BA]|[\u01BD-\u01BD]|[\u01C6-\u01C6]|[\u01C9-\u01C9]|[\u01CC-\u01CC]|[\u01CE-\u01CE]|[\u01D0-\u01D0]|[\u01D2-\u01D2]|[\u01D4-\u01D4]|[\u01D6-\u01D6]|[\u01D8-\u01D8]|[\u01DA-\u01DA]|[\u01DC-\u01DD]|[\u01DF-\u01DF]|[\u01E1-\u01E1]|[\u01E3-\u01E3]|[\u01E5-\u01E5]|[\u01E7-\u01E7]|[\u01E9-\u01E9]|[\u01EB-\u01EB]|[\u01ED-\u01ED]|[\u01EF-\u01F0]|[\u01F3-\u01F3]|[\u01F5-\u01F5]|[\u01FB-\u01FB]|[\u01FD-\u01FD]|[\u01FF-\u01FF]|[\u0201-\u0201]|[\u0203-\u0203]|[\u0205-\u0205]|[\u0207-\u0207]|[\u0209-\u0209]|[\u020B-\u020B]|[\u020D-\u020D]|[\u020F-\u020F]|[\u0211-\u0211]|[\u0213-\u0213]|[\u0215-\u0215]|[\u0217-\u0217]|[\u0250-\u02A8]|[\u0390-\u0390]|[\u03AC-\u03CE]|[\u03D0-\u03D1]|[\u03D5-\u03D6]|[\u03E3-\u03E3]|[\u03E5-\u03E5]|[\u03E7-\u03E7]|[\u03E9-\u03E9]|[\u03EB-\u03EB]|[\u03ED-\u03ED]|[\u03EF-\u03F2]|[\u0430-\u044F]|[\u0451-\u045C]|[\u045E-\u045F]|[\u0461-\u0461]|[\u0463-\u0463]|[\u0465-\u0465]|[\u0467-\u0467]|[\u0469-\u0469]|[\u046B-\u046B]|[\u046D-\u046D]|[\u046F-\u046F]|[\u0471-\u0471]|[\u0473-\u0473]|[\u0475-\u0475]|[\u0477-\u0477]|[\u0479-\u0479]|[\u047B-\u047B]|[\u047D-\u047D]|[\u047F-\u047F]|[\u0481-\u0481]|[\u0491-\u0491]|[\u0493-\u0493]|[\u0495-\u0495]|[\u0497-\u0497]|[\u0499-\u0499]|[\u049B-\u049B]|[\u049D-\u049D]|[\u049F-\u049F]|[\u04A1-\u04A1]|[\u04A3-\u04A3]|[\u04A5-\u04A5]|[\u04A7-\u04A7]|[\u04A9-\u04A9]|[\u04AB-\u04AB]|[\u04AD-\u04AD]|[\u04AF-\u04AF]|[\u04B1-\u04B1]|[\u04B3-\u04B3]|[\u04B5-\u04B5]|[\u04B7-\u04B7]|[\u04B9-\u04B9]|[\u04BB-\u04BB]|[\u04BD-\u04BD]|[\u04BF-\u04BF]|[\u04C2-\u04C2]|[\u04C4-\u04C4]|[\u04C8-\u04C8]|[\u04CC-\u04CC]|[\u04D1-\u04D1]|[\u04D3-\u04D3]|[\u04D5-\u04D5]|[\u04D7-\u04D7]|[\u04D9-\u04D9]|[\u04DB-\u04DB]|[\u04DD-\u04DD]|[\u04DF-\u04DF]|[\u04E1-\u04E1]|[\u04E3-\u04E3]|[\u04E5-\u04E5]|[\u04E7-\u04E7]|[\u04E9-\u04E9]|[\u04EB-\u04EB]|[\u04EF-\u04EF]|[\u04F1-\u04F1]|[\u04F3-\u04F3]|[\u04F5-\u04F5]|[\u04F9-\u04F9]|[\u0561-\u0587]|[\u10D0-\u10F6]|[\u1E01-\u1E01]|[\u1E03-\u1E03]|[\u1E05-\u1E05]|[\u1E07-\u1E07]|[\u1E09-\u1E09]|[\u1E0B-\u1E0B]|[\u1E0D-\u1E0D]|[\u1E0F-\u1E0F]|[\u1E11-\u1E11]|[\u1E13-\u1E13]|[\u1E15-\u1E15]|[\u1E17-\u1E17]|[\u1E19-\u1E19]|[\u1E1B-\u1E1B]|[\u1E1D-\u1E1D]|[\u1E1F-\u1E1F]|[\u1E21-\u1E21]|[\u1E23-\u1E23]|[\u1E25-\u1E25]|[\u1E27-\u1E27]|[\u1E29-\u1E29]|[\u1E2B-\u1E2B]|[\u1E2D-\u1E2D]|[\u1E2F-\u1E2F]|[\u1E31-\u1E31]|[\u1E33-\u1E33]|[\u1E35-\u1E35]|[\u1E37-\u1E37]|[\u1E39-\u1E39]|[\u1E3B-\u1E3B]|[\u1E3D-\u1E3D]|[\u1E3F-\u1E3F]|[\u1E41-\u1E41]|[\u1E43-\u1E43]|[\u1E45-\u1E45]|[\u1E47-\u1E47]|[\u1E49-\u1E49]|[\u1E4B-\u1E4B]|[\u1E4D-\u1E4D]|[\u1E4F-\u1E4F]|[\u1E51-\u1E51]|[\u1E53-\u1E53]|[\u1E55-\u1E55]|[\u1E57-\u1E57]|[\u1E59-\u1E59]|[\u1E5B-\u1E5B]|[\u1E5D-\u1E5D]|[\u1E5F-\u1E5F]|[\u1E61-\u1E61]|[\u1E63-\u1E63]|[\u1E65-\u1