2 lines
41 KiB
JavaScript
2 lines
41 KiB
JavaScript
|
|
(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(global){global.graphlibDot=require("./index")}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./index":2}],2:[function(require,module,exports){var read=require("./lib/read-one"),readMany=require("./lib/read-many"),write=require("./lib/write-one"),version=require("./lib/version");module.exports={graphlib:require("./lib/graphlib"),read:read,readMany:readMany,write:write,version:version,type:"dot",buffer:false}},{"./lib/graphlib":5,"./lib/read-many":7,"./lib/read-one":8,"./lib/version":9,"./lib/write-one":10}],3:[function(require,module,exports){"use strict";var _=require("./lodash"),Graph=require("./graphlib").Graph;module.exports=buildGraph;function buildGraph(parseTree){var isDirected=parseTree.type!=="graph",isMultigraph=!parseTree.strict,defaultStack=[{node:{},edge:{}}],id=parseTree.id,g=new Graph({directed:isDirected,multigraph:isMultigraph,compound:true});g.setGraph(id===null?{}:{id:id});_.each(parseTree.stmts,function(stmt){handleStmt(g,stmt,defaultStack)});return g}function handleStmt(g,stmt,defaultStack,sg){switch(stmt.type){case"node":handleNodeStmt(g,stmt,defaultStack,sg);break;case"edge":handleEdgeStmt(g,stmt,defaultStack,sg);break;case"subgraph":handleSubgraphStmt(g,stmt,defaultStack,sg);break;case"attr":handleAttrStmt(g,stmt,defaultStack);break;case"inlineAttr":handleInlineAttrsStmt(g,stmt,defaultStack,sg);break}}function handleNodeStmt(g,stmt,defaultStack,sg){var v=stmt.id,attrs=stmt.attrs;maybeCreateNode(g,v,defaultStack,sg);_.merge(g.node(v),attrs)}function handleEdgeStmt(g,stmt,defaultStack,sg){var attrs=stmt.attrs,prev,curr;_.each(stmt.elems,function(elem){handleStmt(g,elem,defaultStack,sg);switch(elem.type){case"node":curr=[elem.id];break;case"subgraph":curr=collectNodeIds(elem);break}_.each(prev,function(v){_.each(curr,function(w){var name;if(g.hasEdge(v,w)&&g.isMultigraph()){name=_.uniqueId("edge")}if(!g.hasEdge(v,w,name)){g.setEdge(v,w,_.clone(_.last(defaultStack).edge),name)}_.merge(g.edge(v,w,name),attrs)})});prev=curr})}function handleSubgraphStmt(g,stmt,defaultStack,sg){var id=stmt.id;if(id===undefined){id=generateSubgraphId(g)}defaultStack.push(_.clone(_.last(defaultStack)));maybeCreateNode(g,id,defaultStack,sg);_.each(stmt.stmts,function(s){handleStmt(g,s,defaultStack,id)});if(!g.children(id).length){g.removeNode(id)}defaultStack.pop()}function handleAttrStmt(g,stmt,defaultStack){_.merge(_.last(defaultStack)[stmt.attrType],stmt.attrs)}function handleInlineAttrsStmt(g,stmt,defaultStack,sg){_.merge(sg?g.node(sg):g.graph(),stmt.attrs)}function generateSubgraphId(g){var id;do{id=_.uniqueId("sg")}while(g.hasNode(id));return id}function maybeCreateNode(g,v,defaultStack,sg){if(!g.hasNode(v)){g.setNode(v,_.clone(_.last(defaultStack).node));g.setParent(v,sg)}}function collectNodeIds(stmt){var ids={},stack=[],curr;var push=stack.push.bind(stack);push(stmt);while(stack.length){curr=stack.pop();switch(curr.type){case"node":ids[curr.id]=true;break;case"edge":_.each(curr.elems,push);break;case"subgraph":_.each(curr.stmts,push);break}}return _.keys(ids)}},{"./graphlib":5,"./lodash":6}],4:[function(require,module,exports){module.exports=function(){function peg$subclass(child,parent){function ctor(){this.constructor=child}ctor.prototype=parent.prototype;child.prototype=new ctor}function SyntaxError(message,expected,found,offset,line,column){this.message=message;this.expected=expected;this.found=found;this.offset=offset;this.line=line;this.column=column;this.name="SyntaxError"}peg$subclass(SyntaxError,Error);function parse(input){var options=arguments.length>1
|
||
|
|
peg$currPos++}else{s3=peg$FAILED;if(peg$silentFails===0){peg$fail(peg$c81)}}}}while(s3!==peg$FAILED){s2.push(s3);s3=peg$currPos;if(input.substr(peg$currPos,2)===peg$c75){s4=peg$c75;peg$currPos+=2}else{s4=peg$FAILED;if(peg$silentFails===0){peg$fail(peg$c76)}}if(s4!==peg$FAILED){peg$reportedPos=s3;s4=peg$c77()}s3=s4;if(s3===peg$FAILED){s3=peg$currPos;if(input.charCodeAt(peg$currPos)===92){s4=peg$c78;peg$currPos++}else{s4=peg$FAILED;if(peg$silentFails===0){peg$fail(peg$c79)}}if(s4!==peg$FAILED){if(peg$c80.test(input.charAt(peg$currPos))){s5=input.charAt(peg$currPos);peg$currPos++}else{s5=peg$FAILED;if(peg$silentFails===0){peg$fail(peg$c81)}}if(s5!==peg$FAILED){peg$reportedPos=s3;s4=peg$c82(s5);s3=s4}else{peg$currPos=s3;s3=peg$c1}}else{peg$currPos=s3;s3=peg$c1}if(s3===peg$FAILED){if(peg$c80.test(input.charAt(peg$currPos))){s3=input.charAt(peg$currPos);peg$currPos++}else{s3=peg$FAILED;if(peg$silentFails===0){peg$fail(peg$c81)}}}}}if(s2!==peg$FAILED){if(input.charCodeAt(peg$currPos)===34){s3=peg$c73;peg$currPos++}else{s3=peg$FAILED;if(peg$silentFails===0){peg$fail(peg$c74)}}if(s3!==peg$FAILED){peg$reportedPos=s0;s1=peg$c83(s2);s0=s1}else{peg$currPos=s0;s0=peg$c1}}else{peg$currPos=s0;s0=peg$c1}}else{peg$currPos=s0;s0=peg$c1}}}}peg$silentFails--;if(s0===peg$FAILED){s1=peg$FAILED;if(peg$silentFails===0){peg$fail(peg$c59)}}return s0}function peg$parsenode(){var s0,s1;s0=peg$currPos;if(input.substr(peg$currPos,4).toLowerCase()===peg$c84){s1=input.substr(peg$currPos,4);peg$currPos+=4}else{s1=peg$FAILED;if(peg$silentFails===0){peg$fail(peg$c85)}}if(s1!==peg$FAILED){peg$reportedPos=s0;s1=peg$c86(s1)}s0=s1;return s0}function peg$parseedge(){var s0,s1;s0=peg$currPos;if(input.substr(peg$currPos,4).toLowerCase()===peg$c87){s1=input.substr(peg$currPos,4);peg$currPos+=4}else{s1=peg$FAILED;if(peg$silentFails===0){peg$fail(peg$c88)}}if(s1!==peg$FAILED){peg$reportedPos=s0;s1=peg$c86(s1)}s0=s1;return s0}function peg$parsegraph(){var s0,s1;s0=peg$currPos;if(input.substr(peg$currPos,5).toLowerCase()===peg$c89){s1=input.substr(peg$currPos,5);peg$currPos+=5}else{s1=peg$FAILED;if(peg$silentFails===0){peg$fail(peg$c90)}}if(s1!==peg$FAILED){peg$reportedPos=s0;s1=peg$c86(s1)}s0=s1;return s0}function peg$parsedigraph(){var s0,s1;s0=peg$currPos;if(input.substr(peg$currPos,7).toLowerCase()===peg$c91){s1=input.substr(peg$currPos,7);peg$currPos+=7}else{s1=peg$FAILED;if(peg$silentFails===0){peg$fail(peg$c92)}}if(s1!==peg$FAILED){peg$reportedPos=s0;s1=peg$c86(s1)}s0=s1;return s0}function peg$parsesubgraph(){var s0,s1;s0=peg$currPos;if(input.substr(peg$currPos,8).toLowerCase()===peg$c93){s1=input.substr(peg$currPos,8);peg$currPos+=8}else{s1=peg$FAILED;if(peg$silentFails===0){peg$fail(peg$c94)}}if(s1!==peg$FAILED){peg$reportedPos=s0;s1=peg$c86(s1)}s0=s1;return s0}function peg$parsestrict(){var s0,s1;s0=peg$currPos;if(input.substr(peg$currPos,6).toLowerCase()===peg$c95){s1=input.substr(peg$currPos,6);peg$currPos+=6}else{s1=peg$FAILED;if(peg$silentFails===0){peg$fail(peg$c96)}}if(s1!==peg$FAILED){peg$reportedPos=s0;s1=peg$c86(s1)}s0=s1;return s0}function peg$parsegraphType(){var s0,s1;s0=peg$parsegraph();if(s0===peg$FAILED){s0=peg$currPos;s1=peg$parsedigraph();if(s1!==peg$FAILED){peg$reportedPos=s0;s1=peg$c97(s1)}s0=s1}return s0}function peg$parsewhitespace(){var s0,s1;peg$silentFails++;s0=[];if(peg$c99.test(input.charAt(peg$currPos))){s1=input.charAt(peg$currPos);peg$currPos++}else{s1=peg$FAILED;if(peg$silentFails===0){peg$fail(peg$c100)}}if(s1!==peg$FAILED){while(s1!==peg$FAILED){s0.push(s1);if(peg$c99.test(input.charAt(peg$currPos))){s1=input.charAt(peg$currPos);peg$currPos++}else{s1=peg$FAILED;if(peg$silentFails===0){peg$fail(peg$c100)}}}}else{s0=peg$c1}peg$silentFails--;if(s0===peg$FAILED){s1=peg$FAILED;if(peg$silentFails===0){peg$fail(peg$c98)}}return s0}function peg$parsecomment(){var s0,s1,s2,s3,s4,s5;peg$silentFails++;s0=peg$currPos;if(input.substr(peg$currPos,2)===peg$c102){s1=peg$c102;peg$currPos+=2}else{s1=peg$FAILED;if(peg$silentFails===0){peg$fail(peg$c103)}}if(s1!==peg$FAILED){s2=[];if(peg$c104.test(input.charAt(peg$currPos))){s3=input.charAt(peg$
|