diff --git a/README.md b/README.md index 3b7aa17a0..322503ebd 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ mermaid ======= -Generation of diagram and flowchart from text in a similar manner as markdown. +Generation of diagrams and flowcharts from text in a similar manner as markdown. -Ever wanted to simplify documentation and avoid heavy tools like visio when explaining your code? +Ever wanted to simplify documentation and avoid heavy tools like Visio when explaining your code? This is why mermaid was born, a simple markdown-like script language for generating charts from text via javascript. -The code below would render to the image +The code below would render the following image ``` graph TD; @@ -38,7 +38,7 @@ This file bundles mermaid with d3 and dagre-d3. * [mermaid without dependencies](http://www.sveido.com/mermaid/dist/mermaid.slim.min.js) -With this file you need to include d3 and dagre-d3 yourself. +With this file you will need to include d3 and dagre-d3 yourself. # Usage @@ -48,7 +48,7 @@ Include mermaid on your web page: ``` -Further down on your page mer maid will look for tags with ```class="mermaid"``` from these tags mermaid will try to +Further down on your page mermaid will look for tags with ```class="mermaid"```. From these tags mermaid will try to read the chart definiton which will be replaced with the svg chart. @@ -91,7 +91,7 @@ This statement declares a new graph and the direction of the graph layout. graph TD ``` -Would declare a graph oriented from top to bottom. +This declares a graph oriented from top to bottom. ![Example 3](http://www.sveido.com/mermaid/img/ex3.png) @@ -99,7 +99,7 @@ Would declare a graph oriented from top to bottom. graph LR ``` -Would declare a graph oriented from left to right. +This declares a graph oriented from left to right. ![Example 4](http://www.sveido.com/mermaid/img/ex4.png) @@ -115,8 +115,8 @@ id1; Note that the id is what is displayed in the box. ### A node with text -It is also possible to set text in the box that differs from the id. If this is done several times it is the last text -found for the node that will be used. Also if you define edges for the node later on you can omit text definitions, the +It is also possible to set text in the box that differs from the id. If this is done several times, it is the last text +found for the node that will be used. Also if you define edges for the node later on, you can omit text definitions. The one previously defined will be used when rendering the box. ``` @@ -141,7 +141,7 @@ id1{This is the text in the box}; ![Decision box](http://www.sveido.com/mermaid/img/ex8.png) ### Styling a node -It is possible to give a node specific styling as thicker border or a different background color. +It is possible to apply specific styles such as a thicker border or a different background color to a node. ``` graph LR; @@ -154,8 +154,7 @@ graph LR; ## Links between nodes -Nodes can be connected with links/edges. It is spoosible to have different types of links and it is also possible to -attach a text string to a link. +Nodes can be connected with links/edges. It is possible to have different types of links or attach a text string to a link. ### A link with arrow head ``` @@ -181,4 +180,4 @@ A---|This is the text|B; ![Text on links](http://www.sveido.com/mermaid/img/ex11.png) # Credits - Many thanks to the [d3](http://d3js.org/) and [dagre-d3](https://github.com/cpettitt/dagre-d3) projects that is used for graph layout and drawing!!! \ No newline at end of file +Many thanks to the [d3](http://d3js.org/) and [dagre-d3](https://github.com/cpettitt/dagre-d3) projects for providing the graphical layout and drawing libraries!!! \ No newline at end of file diff --git a/dist/mermaid.full.js b/dist/mermaid.full.js index 6719b3352..100f6b0b8 100644 --- a/dist/mermaid.full.js +++ b/dist/mermaid.full.js @@ -104,12 +104,12 @@ module.exports={graphlib:require("./lib/graphlib"),dagre:require("./lib/dagre"), } */ var parser = (function(){ -var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,7],$V1=[2,10],$V2=[1,15],$V3=[1,16],$V4=[1,11],$V5=[6,9],$V6=[11,28,29,37],$V7=[11,32,33,34,35],$V8=[9,11,18,20,21,22,23,24,27,32,33,34,35,36],$V9=[9,11,18,20,21,22,23,24,27,28,29,32,33,34,35,36],$Va=[28,29],$Vb=[28,29,36],$Vc=[20,22,24,36],$Vd=[1,67],$Ve=[1,64],$Vf=[1,62],$Vg=[1,65],$Vh=[1,68],$Vi=[1,63],$Vj=[1,66],$Vk=[1,72],$Vl=[11,41],$Vm=[9,11,27,28,29,39,41,43,44]; +var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,7],$V1=[2,10],$V2=[1,15],$V3=[1,16],$V4=[1,11],$V5=[6,9],$V6=[11,28,29,37],$V7=[11,32,33,34,35],$V8=[9,11,18,20,21,22,23,24,32,33,34,35,36],$V9=[9,11,18,20,21,22,23,24,28,29,32,33,34,35,36],$Va=[9,11,18,20,21,22,23,24,27,28,29,32,33,34,35,36],$Vb=[28,29],$Vc=[28,29,36],$Vd=[20,22,24,36],$Ve=[1,66],$Vf=[1,63],$Vg=[1,61],$Vh=[1,64],$Vi=[1,67],$Vj=[1,62],$Vk=[1,65],$Vl=[1,70],$Vm=[11,41],$Vn=[9,11,27,28,29,39,41,43,44]; var parser = {trace: function trace() { }, yy: {}, symbols_: {"error":2,"expressions":3,"graphConfig":4,"statements":5,"EOF":6,"spaceList":7,"GRAPH":8,"SPACE":9,"DIR":10,"SEMI":11,"statement":12,"verticeStatement":13,"styleStatement":14,"vertex":15,"link":16,"alphaNum":17,"SQS":18,"text":19,"SQE":20,"PS":21,"PE":22,"DIAMOND_START":23,"DIAMOND_STOP":24,"alphaNumStatement":25,"alphaNumToken":26,"MINUS":27,"ALPHA":28,"NUM":29,"linkStatement":30,"arrowText":31,"ARROW_POINT":32,"ARROW_CIRCLE":33,"ARROW_CROSS":34,"ARROW_OPEN":35,"PIPE":36,"STYLE":37,"stylesOpt":38,"HEX":39,"style":40,"COMMA":41,"styleComponent":42,"COLON":43,"UNIT":44,"$accept":0,"$end":1}, terminals_: {2:"error",6:"EOF",8:"GRAPH",9:"SPACE",10:"DIR",11:"SEMI",18:"SQS",20:"SQE",21:"PS",22:"PE",23:"DIAMOND_START",24:"DIAMOND_STOP",27:"MINUS",28:"ALPHA",29:"NUM",32:"ARROW_POINT",33:"ARROW_CIRCLE",34:"ARROW_CROSS",35:"ARROW_OPEN",36:"PIPE",37:"STYLE",39:"HEX",41:"COMMA",43:"COLON",44:"UNIT"}, -productions_: [0,[3,3],[3,4],[4,4],[5,3],[5,1],[7,2],[7,1],[12,2],[12,2],[13,0],[13,3],[13,1],[15,4],[15,4],[15,4],[15,1],[17,1],[17,2],[25,1],[25,3],[26,1],[26,1],[16,2],[16,1],[30,1],[30,1],[30,1],[30,1],[31,3],[19,3],[19,3],[19,2],[19,1],[14,5],[14,5],[38,1],[38,3],[40,1],[40,2],[42,1],[42,1],[42,1],[42,1],[42,1],[42,1],[42,1]], +productions_: [0,[3,3],[3,4],[4,4],[5,3],[5,1],[7,2],[7,1],[12,2],[12,2],[13,0],[13,3],[13,1],[15,4],[15,4],[15,4],[15,1],[17,1],[17,2],[25,1],[25,3],[26,1],[26,1],[16,2],[16,1],[30,1],[30,1],[30,1],[30,1],[31,3],[19,3],[19,2],[19,1],[14,5],[14,5],[38,1],[38,3],[40,1],[40,2],[42,1],[42,1],[42,1],[42,1],[42,1],[42,1],[42,1]], performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { /* this == yyval */ @@ -139,7 +139,7 @@ break; case 16: console.log('In vertex:'+$$[$0]); this.$ = $$[$0];yy.addVertex($$[$0]); break; -case 17: case 21: case 22: case 38: +case 17: case 21: case 22: case 37: this.$=$$[$0]; break; case 18: @@ -154,7 +154,7 @@ break; case 23: $$[$0-1].text = $$[$0];this.$ = $$[$0-1]; break; -case 24: case 33: +case 24: case 32: this.$ = $$[$0]; break; case 25: @@ -176,32 +176,29 @@ case 30: this.$ = $$[$0-2] + ' ' +$$[$0]; break; case 31: -this.$ = $$[$0-2] + '-' +$$[$0]; -break; -case 32: this.$ = $$[$0-1]; break; -case 34: +case 33: this.$ = $$[$0-4];yy.addVertex($$[$0-2],undefined,undefined,$$[$0]); break; -case 35: +case 34: console.log('In parser - style: '+$$[$0]);this.$ = $$[$0-4];yy.updateLink($$[$0-2],$$[$0]); break; -case 36: +case 35: this.$ = [$$[$0]] break; -case 37: +case 36: $$[$0-2].push($$[$0]);this.$ = $$[$0-2]; break; -case 39: +case 38: this.$ = $$[$0-1] + $$[$0]; break; -case 40: case 41: case 42: case 43: case 44: case 45: case 46: +case 39: case 40: case 41: case 42: case 43: case 44: case 45: this.$=$$[$0] break; } }, -table: [{3:1,4:2,8:[1,3]},{1:[3]},{5:4,7:5,9:$V0,11:$V1,12:6,13:8,14:9,15:10,17:12,25:13,26:14,28:$V2,29:$V3,37:$V4},{9:[1,17]},{6:[1,18],7:19,9:$V0},{5:20,11:$V1,12:6,13:8,14:9,15:10,17:12,25:13,26:14,28:$V2,29:$V3,37:$V4},o($V5,[2,5]),o($V6,[2,7],{7:21,9:$V0}),{11:[1,22]},{11:[1,23]},{11:[2,12],16:24,30:25,32:[1,26],33:[1,27],34:[1,28],35:[1,29]},{9:[1,30]},o($V7,[2,16],{18:[1,31],21:[1,32],23:[1,33]}),o($V8,[2,17],{25:13,26:14,17:34,28:$V2,29:$V3}),o([9,11,18,20,21,22,23,24,28,29,32,33,34,35,36],[2,19],{27:[1,35]}),o($V9,[2,21]),o($V9,[2,22]),{10:[1,36]},{1:[2,1]},{11:$V1,12:37,13:8,14:9,15:10,17:12,25:13,26:14,28:$V2,29:$V3,37:$V4},{6:[1,38],7:19,9:$V0},o($V6,[2,6]),o($V5,[2,8]),o($V5,[2,9]),{15:39,17:12,25:13,26:14,28:$V2,29:$V3},o($Va,[2,24],{31:40,36:[1,41]}),o($Vb,[2,25]),o($Vb,[2,26]),o($Vb,[2,27]),o($Vb,[2,28]),{17:42,25:13,26:14,28:$V2,29:$V3,39:[1,43]},{17:45,19:44,25:13,26:14,28:$V2,29:$V3},{17:45,19:46,25:13,26:14,28:$V2,29:$V3},{17:45,19:47,25:13,26:14,28:$V2,29:$V3},o($V8,[2,18]),{26:48,28:$V2,29:$V3},{11:[1,49]},o($V5,[2,4]),{1:[2,2]},{11:[2,11]},o($Va,[2,23]),{17:45,19:50,25:13,26:14,28:$V2,29:$V3},{9:[1,51]},{9:[1,52]},{20:[1,53]},o($Vc,[2,33],{9:[1,54],27:[1,55]}),{22:[1,56]},{24:[1,57]},o($V9,[2,20]),o([9,11,28,29,37],[2,3]),{36:[1,58]},{9:$Vd,27:$Ve,28:$Vf,29:$Vg,38:59,39:$Vh,40:60,42:61,43:$Vi,44:$Vj},{9:$Vd,27:$Ve,28:$Vf,29:$Vg,38:69,39:$Vh,40:60,42:61,43:$Vi,44:$Vj},o($V7,[2,13]),o($Vc,[2,32],{25:13,26:14,17:45,19:70,28:$V2,29:$V3}),{17:45,19:71,25:13,26:14,28:$V2,29:$V3},o($V7,[2,14]),o($V7,[2,15]),o($Va,[2,29]),{11:[2,34],41:$Vk},o($Vl,[2,36],{42:73,9:$Vd,27:$Ve,28:$Vf,29:$Vg,39:$Vh,43:$Vi,44:$Vj}),o($Vm,[2,38]),o($Vm,[2,40]),o($Vm,[2,41]),o($Vm,[2,42]),o($Vm,[2,43]),o($Vm,[2,44]),o($Vm,[2,45]),o($Vm,[2,46]),{11:[2,35],41:$Vk},o($Vc,[2,30]),o($Vc,[2,31]),{9:$Vd,27:$Ve,28:$Vf,29:$Vg,39:$Vh,40:74,42:61,43:$Vi,44:$Vj},o($Vm,[2,39]),o($Vl,[2,37],{42:73,9:$Vd,27:$Ve,28:$Vf,29:$Vg,39:$Vh,43:$Vi,44:$Vj})], +table: [{3:1,4:2,8:[1,3]},{1:[3]},{5:4,7:5,9:$V0,11:$V1,12:6,13:8,14:9,15:10,17:12,25:13,26:14,28:$V2,29:$V3,37:$V4},{9:[1,17]},{6:[1,18],7:19,9:$V0},{5:20,11:$V1,12:6,13:8,14:9,15:10,17:12,25:13,26:14,28:$V2,29:$V3,37:$V4},o($V5,[2,5]),o($V6,[2,7],{7:21,9:$V0}),{11:[1,22]},{11:[1,23]},{11:[2,12],16:24,30:25,32:[1,26],33:[1,27],34:[1,28],35:[1,29]},{9:[1,30]},o($V7,[2,16],{18:[1,31],21:[1,32],23:[1,33]}),o($V8,[2,17],{25:13,26:14,17:34,28:$V2,29:$V3}),o($V9,[2,19],{27:[1,35]}),o($Va,[2,21]),o($Va,[2,22]),{10:[1,36]},{1:[2,1]},{11:$V1,12:37,13:8,14:9,15:10,17:12,25:13,26:14,28:$V2,29:$V3,37:$V4},{6:[1,38],7:19,9:$V0},o($V6,[2,6]),o($V5,[2,8]),o($V5,[2,9]),{15:39,17:12,25:13,26:14,28:$V2,29:$V3},o($Vb,[2,24],{31:40,36:[1,41]}),o($Vc,[2,25]),o($Vc,[2,26]),o($Vc,[2,27]),o($Vc,[2,28]),{17:42,25:13,26:14,28:$V2,29:$V3,39:[1,43]},{17:45,19:44,25:13,26:14,28:$V2,29:$V3},{17:45,19:46,25:13,26:14,28:$V2,29:$V3},{17:45,19:47,25:13,26:14,28:$V2,29:$V3},o($V8,[2,18]),{26:48,28:$V2,29:$V3},{11:[1,49]},o($V5,[2,4]),{1:[2,2]},{11:[2,11]},o($Vb,[2,23]),{17:45,19:50,25:13,26:14,28:$V2,29:$V3},{9:[1,51]},{9:[1,52]},{20:[1,53]},o($Vd,[2,32],{9:[1,54]}),{22:[1,55]},{24:[1,56]},o($V9,[2,20]),o([9,11,28,29,37],[2,3]),{36:[1,57]},{9:$Ve,27:$Vf,28:$Vg,29:$Vh,38:58,39:$Vi,40:59,42:60,43:$Vj,44:$Vk},{9:$Ve,27:$Vf,28:$Vg,29:$Vh,38:68,39:$Vi,40:59,42:60,43:$Vj,44:$Vk},o($V7,[2,13]),o($Vd,[2,31],{25:13,26:14,17:45,19:69,28:$V2,29:$V3}),o($V7,[2,14]),o($V7,[2,15]),o($Vb,[2,29]),{11:[2,33],41:$Vl},o($Vm,[2,35],{42:71,9:$Ve,27:$Vf,28:$Vg,29:$Vh,39:$Vi,43:$Vj,44:$Vk}),o($Vn,[2,37]),o($Vn,[2,39]),o($Vn,[2,40]),o($Vn,[2,41]),o($Vn,[2,42]),o($Vn,[2,43]),o($Vn,[2,44]),o($Vn,[2,45]),{11:[2,34],41:$Vl},o($Vd,[2,30]),{9:$Ve,27:$Vf,28:$Vg,29:$Vh,39:$Vi,40:72,42:60,43:$Vj,44:$Vk},o($Vn,[2,38]),o($Vm,[2,36],{42:71,9:$Ve,27:$Vf,28:$Vg,29:$Vh,39:$Vi,43:$Vj,44:$Vk})], defaultActions: {18:[2,1],38:[2,2],39:[2,11]}, parseError: function parseError(str, hash) { if (hash.recoverable) { @@ -780,7 +777,7 @@ mermaid.edges = []; mermaid.graph = { /** - * + * Function called by parser when a node definition has been found * @param id * @param text * @param type @@ -799,16 +796,19 @@ mermaid.graph = { } if(typeof style !== 'undefined'){ if(style !== null){ - console.log('Adding style: '+style); style.forEach(function(s){ mermaid.vertices[id].styles.push(s); }); } } }, - getVertices:function(){ - return mermaid.vertices; - }, + /** + * Function called by parser when a link/edge definition has been found + * @param start + * @param end + * @param type + * @param linktext + */ addLink: function (start, end, type, linktext) { var edge = {start:start, end:end, type:undefined, text:''}; var linktext = type.text; @@ -820,24 +820,49 @@ mermaid.graph = { edge.type = type.type; } mermaid.edges.push(edge); - //console.log('Got link from ' + start + ' to ' + end + ' type:' + type.type + ' linktext:' + linktext); }, + /** + * Updates a link with a style + * @param pos + * @param style + */ updateLink: function (pos, style) { - //mermaid.edges.push(edge); var position = pos.substr(1); - console.log('Got link style for ' + position + ' style ' + style); mermaid.edges[position].style = style; }, + /** + * Called by parser when a graph definition is found, stores the direction of the chart. + * @param dir + */ setDirection: function(dir){ mermaid.direction = dir; }, + /** + * Retrieval function for fetching the found nodes after parsing has completed. + * @returns {{}|*|mermaid.vertices} + */ + getVertices:function(){ + return mermaid.vertices; + }, + /** + * Retrieval function for fetching the found links after parsing has completed. + * @returns {{}|*|mermaid.edges} + */ getEdges: function () { return mermaid.edges; }, + + /** + * Clears the internal graph db so that a new graph can be parsed. + */ clear:function(){ mermaid.vertices = {}; mermaid.edges = []; }, + /** + * + * @returns {string} + */ defaultStyle:function(){ return "fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;fill:#ffa;stroke: #666;"; } @@ -850,28 +875,28 @@ if (typeof mermaid === 'undefined') { } /** - * Function used by parser to store vertices/nodes found in graph script. - * @param vert - * @param g + * Function that adds the vertices found in the graph definition to the graph to be rendered. + * @param vert Object containing the vertices. + * @param g The graph that is to be drawn. */ mermaid.addVertices = function (vert, g) { var keys = Object.keys(vert); + // Iterate through each item in the vertice object (containing all the vertices found) in the graph definition keys.forEach(function (id) { var vertice = vert[id]; var verticeText; - - console.log(vertice.styles.length); - var i; var style = ''; + // Create a compund style definiton from the style definitions found for the node in the graph definition for (i = 0; i < vertice.styles.length; i++) { if (typeof vertice.styles[i] !== 'undefined') { style = style + vertice.styles[i] + ';'; } } + // Use vertice id as text in the box if no text is provided by the graph definition if (vertice.text === undefined) { verticeText = vertice.id; } @@ -879,12 +904,7 @@ mermaid.addVertices = function (vert, g) { verticeText = vertice.text; } - - if (style === '') { - //style = graph.defaultStyle(); - } - - console.log('g.setNode("' + vertice.id + '", { label: "' + verticeText + '" });'); + // Create the node in the graph nased on defined form if (vertice.type === 'round') { g.setNode(vertice.id, {label: verticeText, rx: 5, ry: 5, style: style}); } else { @@ -897,31 +917,23 @@ mermaid.addVertices = function (vert, g) { }); }; +/** + * Add edges to graph based on parsed graph defninition + * @param edges + * @param g + */ mermaid.addEdges = function (edges, g) { edges.forEach(function (edge) { - var type, style; - if(typeof edge.type === 'undefined'){ - type = 'arrow'; - }else{ - type = edge.type; - } - if(typeof edge.style === 'undefined'){ - style = 'arrow'; - }else{ - type = edge.type; - } - - if(type === 'arrow_open'){ + // Set link type for rendering + if(edge.type === 'arrow_open'){ aHead = 'none'; } else{ aHead = 'vee'; } - - var edgeText; - //console.log(vertice); + // Add the edge to the graph if (edge.text === 'undefined') { if(typeof edge.style === 'undefined'){ g.setEdge(edge.start, edge.end,{ arrowheadStyle: "fill: #333", arrowhead: aHead}); @@ -930,7 +942,6 @@ mermaid.addEdges = function (edges, g) { style: edge.style, arrowheadStyle: "fill: #333", arrowhead: aHead }); } - } else { if(typeof edge.style === 'undefined'){ @@ -941,39 +952,28 @@ mermaid.addEdges = function (edges, g) { }); } } - console.log('g.setEdge("' + edge.start + '","' + edge.end + '") ---'); - }); }; +/** + * Draws a chart in the tag with id: id based on the graph definition in text. + * @param text + * @param id + */ mermaid.drawChart = function (text, id) { - - console.log('drawing char with id:' + id); - console.log(text); mermaid.graph.clear(); parser.yy = mermaid.graph; - var err = function () { - console.log('Syntax error!!!'); - }; - + // Parse the graph definition parser.parse(text); - var vert = mermaid.graph.getVertices(); - var edges = mermaid.graph.getEdges(); - - console.log(edges); - - var keys = Object.keys(vert); - + // Fetch the default direction, use TD if none was found var dir; dir = mermaid.direction; if(typeof dir === 'undefined'){ dir='TD'; } - - // Create the input mermaid.graph var g = new dagreD3.graphlib.Graph() .setGraph({ @@ -985,7 +985,9 @@ mermaid.drawChart = function (text, id) { return {}; }); - console.log(g); + // Fetch the verices/nodes and edges/links from the parsed graph definition + var vert = mermaid.graph.getVertices(); + var edges = mermaid.graph.getEdges(); this.addVertices(vert, g); this.addEdges(edges, g); @@ -993,7 +995,7 @@ mermaid.drawChart = function (text, id) { // Create the renderer var render = new dagreD3.render(); - // Add our custom shape + // Add custom shape for rhombus type of boc (decision) render.shapes().question = function (parent, bbox, node) { var w = bbox.width, h = bbox.height * 3, @@ -1048,6 +1050,9 @@ mermaid.drawChart = function (text, id) { svg.attr("height", g.graph().height + 40); }; +/** + * Go through the document and find the chart definitions in there and render the charts + */ mermaid.init = function () { var arr = document.querySelectorAll('.mermaid'); @@ -1069,4 +1074,10 @@ mermaid.init = function () { } ; }; -mermaid.init(); \ No newline at end of file + +/** + * Wait for coument loaded before starting the execution + */ +document.addEventListener('DOMContentLoaded', function(){ + mermaid.init(); + }, false); \ No newline at end of file diff --git a/dist/mermaid.full.min.js b/dist/mermaid.full.min.js index cec9c6fab..57d2549dc 100644 --- a/dist/mermaid.full.min.js +++ b/dist/mermaid.full.min.js @@ -30,4 +30,4 @@ module.exports={graphlib:require("./lib/graphlib"),dagre:require("./lib/dagre"), }));_.each(g.nodes(),function(v){var node=g.node(v);if(_.has(node,"rank")){node.rank-=min}})}function removeEmptyRanks(g){var offset=_.min(_.map(g.nodes(),function(v){return g.node(v).rank}));var layers=[];_.each(g.nodes(),function(v){var rank=g.node(v).rank-offset;if(!_.has(layers,rank)){layers[rank]=[]}layers[rank].push(v)});var delta=0,nodeRankFactor=g.graph().nodeRankFactor;_.each(layers,function(vs,i){if(_.isUndefined(vs)&&i%nodeRankFactor!==0){--delta}else if(delta){_.each(vs,function(v){g.node(v).rank+=delta})}})}function addBorderNode(g,prefix,rank,order){var node={width:0,height:0};if(arguments.length>=4){node.rank=rank;node.order=order}return addDummyNode(g,"border",node,prefix)}function maxRank(g){return _.max(_.map(g.nodes(),function(v){var rank=g.node(v).rank;if(!_.isUndefined(rank)){return rank}}))}function partition(collection,fn){var result={lhs:[],rhs:[]};_.each(collection,function(value){if(fn(value)){result.lhs.push(value)}else{result.rhs.push(value)}});return result}function time(name,fn){var start=_.now();try{return fn()}finally{console.log(name+" time: "+(_.now()-start)+"ms")}}function notime(name,fn){return fn()}},{"./graphlib":33,"./lodash":36}],56:[function(require,module,exports){module.exports="0.6.2"},{}],57:[function(require,module,exports){var lib=require("./lib");module.exports={Graph:lib.Graph,json:require("./lib/json"),alg:require("./lib/alg"),version:lib.version}},{"./lib":73,"./lib/alg":64,"./lib/json":74}],58:[function(require,module,exports){var _=require("../lodash");module.exports=components;function components(g){var visited={},cmpts=[],cmpt;function dfs(v){if(_.has(visited,v))return;visited[v]=true;cmpt.push(v);_.each(g.successors(v),dfs);_.each(g.predecessors(v),dfs)}_.each(g.nodes(),function(v){cmpt=[];dfs(v);if(cmpt.length){cmpts.push(cmpt)}});return cmpts}},{"../lodash":75}],59:[function(require,module,exports){var _=require("../lodash");module.exports=dfs;function dfs(g,vs,order){if(!_.isArray(vs)){vs=[vs]}var acc=[],visited={};_.each(vs,function(v){if(!g.hasNode(v)){throw new Error("Graph does not have node: "+v)}doDfs(g,v,order==="post",visited,acc)});return acc}function doDfs(g,v,postorder,visited,acc){if(!_.has(visited,v)){visited[v]=true;if(!postorder){acc.push(v)}_.each(g.neighbors(v),function(w){doDfs(g,w,postorder,visited,acc)});if(postorder){acc.push(v)}}}},{"../lodash":75}],60:[function(require,module,exports){var dijkstra=require("./dijkstra"),_=require("../lodash");module.exports=dijkstraAll;function dijkstraAll(g,weightFunc,edgeFunc){return _.transform(g.nodes(),function(acc,v){acc[v]=dijkstra(g,v,weightFunc,edgeFunc)},{})}},{"../lodash":75,"./dijkstra":61}],61:[function(require,module,exports){var _=require("../lodash"),PriorityQueue=require("../data/priority-queue");module.exports=dijkstra;var DEFAULT_WEIGHT_FUNC=_.constant(1);function dijkstra(g,source,weightFn,edgeFn){return runDijkstra(g,String(source),weightFn||DEFAULT_WEIGHT_FUNC,edgeFn||function(v){return g.outEdges(v)})}function runDijkstra(g,source,weightFn,edgeFn){var results={},pq=new PriorityQueue,v,vEntry;var updateNeighbors=function(edge){var w=edge.v!==v?edge.v:edge.w,wEntry=results[w],weight=weightFn(edge),distance=vEntry.distance+weight;if(weight<0){throw new Error("dijkstra does not allow negative edge weights. "+"Bad edge: "+edge+" Weight: "+weight)}if(distance0){v=pq.removeMin();vEntry=results[v];if(vEntry.distance===Number.POSITIVE_INFINITY){break}edgeFn(v).forEach(updateNeighbors)}return results}},{"../data/priority-queue":71,"../lodash":75}],62:[function(require,module,exports){var _=require("../lodash"),tarjan=require("./tarjan");module.exports=findCycles;function findCycles(g){return _.filter(tarjan(g),function(cmpt){return cmpt.length>1})}},{"../lodash":75,"./tarjan":69}],63:[function(require,module,exports){var _=require("../lodash");module.exports=floydWarshall;var DEFAULT_WEIGHT_FUNC=_.constant(1);function floydWarshall(g,weightFn,edgeFn){return runFloydWarshall(g,weightFn||DEFAULT_WEIGHT_FUNC,edgeFn||function(v){return g.outEdges(v)})}function runFloydWarshall(g,weightFn,edgeFn){var results={},nodes=g.nodes();nodes.forEach(function(v){results[v]={};results[v][v]={distance:0};nodes.forEach(function(w){if(v!==w){results[v][w]={distance:Number.POSITIVE_INFINITY}}});edgeFn(v).forEach(function(edge){var w=edge.v===v?edge.w:edge.v,d=weightFn(edge);results[v][w]={distance:d,predecessor:v}})});nodes.forEach(function(k){var rowK=results[k];nodes.forEach(function(i){var rowI=results[i];nodes.forEach(function(j){var ik=rowI[k];var kj=rowK[j];var ij=rowI[j];var altDistance=ik.distance+kj.distance;if(altDistance0){v=pq.removeMin();if(_.has(parents,v)){result.setEdge(v,parents[v])}else if(init){throw new Error("Input graph is not connected: "+g)}else{init=true}g.nodeEdges(v).forEach(updateNeighbors)}return result}},{"../data/priority-queue":71,"../graph":72,"../lodash":75}],69:[function(require,module,exports){var _=require("../lodash");module.exports=tarjan;function tarjan(g){var index=0,stack=[],visited={},results=[];function dfs(v){var entry=visited[v]={onStack:true,lowlink:index,index:index++};stack.push(v);g.successors(v).forEach(function(w){if(!_.has(visited,w)){dfs(w);entry.lowlink=Math.min(entry.lowlink,visited[w].lowlink)}else if(visited[w].onStack){entry.lowlink=Math.min(entry.lowlink,visited[w].index)}});if(entry.lowlink===entry.index){var cmpt=[],w;do{w=stack.pop();visited[w].onStack=false;cmpt.push(w)}while(v!==w);results.push(cmpt)}}g.nodes().forEach(function(v){if(!_.has(visited,v)){dfs(v)}});return results}},{"../lodash":75}],70:[function(require,module,exports){var _=require("../lodash");module.exports=topsort;topsort.CycleException=CycleException;function topsort(g){var visited={},stack={},results=[];function visit(node){if(_.has(stack,node)){throw new CycleException}if(!_.has(visited,node)){stack[node]=true;visited[node]=true;_.each(g.predecessors(node),visit);delete stack[node];results.push(node)}}_.each(g.sinks(),visit);if(_.size(visited)!==g.nodeCount()){throw new CycleException}return results}function CycleException(){}},{"../lodash":75}],71:[function(require,module,exports){var _=require("../lodash");module.exports=PriorityQueue;function PriorityQueue(){this._arr=[];this._keyIndices={}}PriorityQueue.prototype.size=function(){return this._arr.length};PriorityQueue.prototype.keys=function(){return this._arr.map(function(x){return x.key})};PriorityQueue.prototype.has=function(key){return _.has(this._keyIndices,key)};PriorityQueue.prototype.priority=function(key){var index=this._keyIndices[key];if(index!==undefined){return this._arr[index].priority}};PriorityQueue.prototype.min=function(){if(this.size()===0){throw new Error("Queue underflow")}return this._arr[0].key};PriorityQueue.prototype.add=function(key,priority){var keyIndices=this._keyIndices;key=String(key);if(!_.has(keyIndices,key)){var arr=this._arr;var index=arr.length;keyIndices[key]=index;arr.push({key:key,priority:priority});this._decrease(index);return true}return false};PriorityQueue.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var min=this._arr.pop();delete this._keyIndices[min.key];this._heapify(0);return min.key};PriorityQueue.prototype.decrease=function(key,priority){var index=this._keyIndices[key];if(priority>this._arr[index].priority){throw new Error("New priority is greater than current priority. "+"Key: "+key+" Old: "+this._arr[index].priority+" New: "+priority)}this._arr[index].priority=priority;this._decrease(index)};PriorityQueue.prototype._heapify=function(i){var arr=this._arr;var l=2*i,r=l+1,largest=i;if(l>1;if(arr[parent].priority1){this.setNode(v,value)}else{this.setNode(v)}},this);return this};Graph.prototype.setNode=function(v,value){if(_.has(this._nodes,v)){if(arguments.length>1){this._nodes[v]=value}return this}this._nodes[v]=arguments.length>1?value:this._defaultNodeLabelFn(v);if(this._isCompound){this._parent[v]=GRAPH_NODE;this._children[v]={};this._children[GRAPH_NODE][v]=true}this._in[v]={};this._preds[v]={};this._out[v]={};this._sucs[v]={};++this._nodeCount;return this};Graph.prototype.node=function(v){return this._nodes[v]};Graph.prototype.hasNode=function(v){return _.has(this._nodes,v)};Graph.prototype.removeNode=function(v){var self=this;if(_.has(this._nodes,v)){var removeEdge=function(e){self.removeEdge(self._edgeObjs[e])};delete this._nodes[v];if(this._isCompound){this._removeFromParentsChildList(v);delete this._parent[v];_.each(this.children(v),function(child){this.setParent(child)},this);delete this._children[v]}_.each(_.keys(this._in[v]),removeEdge);delete this._in[v];delete this._preds[v];_.each(_.keys(this._out[v]),removeEdge);delete this._out[v];delete this._sucs[v];--this._nodeCount}return this};Graph.prototype.setParent=function(v,parent){if(!this._isCompound){throw new Error("Cannot set parent in a non-compound graph")}if(_.isUndefined(parent)){parent=GRAPH_NODE}else{for(var ancestor=parent;!_.isUndefined(ancestor);ancestor=this.parent(ancestor)){if(ancestor===v){throw new Error("Setting "+parent+" as parent of "+v+" would create create a cycle")}}this.setNode(parent)}this.setNode(v);this._removeFromParentsChildList(v);this._parent[v]=parent;this._children[parent][v]=true;return this};Graph.prototype._removeFromParentsChildList=function(v){delete this._children[this._parent[v]][v]};Graph.prototype.parent=function(v){if(this._isCompound){var parent=this._parent[v];if(parent!==GRAPH_NODE){return parent}}};Graph.prototype.children=function(v){if(_.isUndefined(v)){v=GRAPH_NODE}if(this._isCompound){var children=this._children[v];if(children){return _.keys(children)}}else if(v===GRAPH_NODE){return this.nodes()}else if(this.hasNode(v)){return[]}};Graph.prototype.predecessors=function(v){var predsV=this._preds[v];if(predsV){return _.keys(predsV)}};Graph.prototype.successors=function(v){var sucsV=this._sucs[v];if(sucsV){return _.keys(sucsV)}};Graph.prototype.neighbors=function(v){var preds=this.predecessors(v);if(preds){return _.union(preds,this.successors(v))}};Graph.prototype.setDefaultEdgeLabel=function(newDefault){if(!_.isFunction(newDefault)){newDefault=_.constant(newDefault)}this._defaultEdgeLabelFn=newDefault;return this};Graph.prototype.edgeCount=function(){return this._edgeCount};Graph.prototype.edges=function(){return _.values(this._edgeObjs)};Graph.prototype.setPath=function(vs,value){var self=this,args=arguments;_.reduce(vs,function(v,w){if(args.length>1){self.setEdge(v,w,value)}else{self.setEdge(v,w)}return w});return this};Graph.prototype.setEdge=function(){var v,w,name,value,valueSpecified=false;if(_.isPlainObject(arguments[0])){v=arguments[0].v;w=arguments[0].w;name=arguments[0].name;if(arguments.length===2){value=arguments[1];valueSpecified=true}}else{v=arguments[0];w=arguments[1];name=arguments[3];if(arguments.length>2){value=arguments[2];valueSpecified=true}}v=""+v;w=""+w;if(!_.isUndefined(name)){name=""+name}var e=edgeArgsToId(this._isDirected,v,w,name);if(_.has(this._edgeLabels,e)){if(valueSpecified){this._edgeLabels[e]=value}return this}if(!_.isUndefined(name)&&!this._isMultigraph){throw new Error("Cannot set a named edge when isMultigraph = false")}this.setNode(v);this.setNode(w);this._edgeLabels[e]=valueSpecified?value:this._defaultEdgeLabelFn(v,w,name);var edgeObj=edgeArgsToObj(this._isDirected,v,w,name);v=edgeObj.v;w=edgeObj.w;Object.freeze(edgeObj);this._edgeObjs[e]=edgeObj;incrementOrInitEntry(this._preds[w],v);incrementOrInitEntry(this._sucs[v],w);this._in[w][e]=edgeObj;this._out[v][e]=edgeObj;this._edgeCount++;return this};Graph.prototype.edge=function(v,w,name){var e=arguments.length===1?edgeObjToId(this._isDirected,arguments[0]):edgeArgsToId(this._isDirected,v,w,name);return this._edgeLabels[e]};Graph.prototype.hasEdge=function(v,w,name){var e=arguments.length===1?edgeObjToId(this._isDirected,arguments[0]):edgeArgsToId(this._isDirected,v,w,name);return _.has(this._edgeLabels,e)};Graph.prototype.removeEdge=function(v,w,name){var e=arguments.length===1?edgeObjToId(this._isDirected,arguments[0]):edgeArgsToId(this._isDirected,v,w,name),edge=this._edgeObjs[e];if(edge){v=edge.v;w=edge.w;delete this._edgeLabels[e];delete this._edgeObjs[e];decrementOrRemoveEntry(this._preds[w],v);decrementOrRemoveEntry(this._sucs[v],w);delete this._in[w][e];delete this._out[v][e];this._edgeCount--}return this};Graph.prototype.inEdges=function(v,u){var inV=this._in[v];if(inV){var edges=_.values(inV);if(!u){return edges}return _.filter(edges,function(edge){return edge.v===u})}};Graph.prototype.outEdges=function(v,w){var outV=this._out[v];if(outV){var edges=_.values(outV);if(!w){return edges}return _.filter(edges,function(edge){return edge.w===w})}};Graph.prototype.nodeEdges=function(v,w){var inEdges=this.inEdges(v,w);if(inEdges){return inEdges.concat(this.outEdges(v,w))}};function incrementOrInitEntry(map,k){if(_.has(map,k)){map[k]++}else{map[k]=1}}function decrementOrRemoveEntry(map,k){if(!--map[k]){delete map[k]}}function edgeArgsToId(isDirected,v,w,name){if(!isDirected&&v>w){var tmp=v;v=w;w=tmp}return v+EDGE_KEY_DELIM+w+EDGE_KEY_DELIM+(_.isUndefined(name)?DEFAULT_EDGE_NAME:name)}function edgeArgsToObj(isDirected,v,w,name){if(!isDirected&&v>w){var tmp=v;v=w;w=tmp}var edgeObj={v:v,w:w};if(name){edgeObj.name=name}return edgeObj}function edgeObjToId(isDirected,edgeObj){return edgeArgsToId(isDirected,edgeObj.v,edgeObj.w,edgeObj.name)}},{"./lodash":75}],73:[function(require,module,exports){module.exports={Graph:require("./graph"),version:require("./version")}},{"./graph":72,"./version":76}],74:[function(require,module,exports){var _=require("./lodash"),Graph=require("./graph");module.exports={write:write,read:read};function write(g){var json={options:{directed:g.isDirected(),multigraph:g.isMultigraph(),compound:g.isCompound()},nodes:writeNodes(g),edges:writeEdges(g)};if(!_.isUndefined(g.graph())){json.value=_.clone(g.graph())}return json}function writeNodes(g){return _.map(g.nodes(),function(v){var nodeValue=g.node(v),parent=g.parent(v),node={v:v};if(!_.isUndefined(nodeValue)){node.value=nodeValue}if(!_.isUndefined(parent)){node.parent=parent}return node})}function writeEdges(g){return _.map(g.edges(),function(e){var edgeValue=g.edge(e),edge={v:e.v,w:e.w};if(!_.isUndefined(e.name)){edge.name=e.name}if(!_.isUndefined(edgeValue)){edge.value=edgeValue}return edge})}function read(json){var g=new Graph(json.options).setGraph(json.value);_.each(json.nodes,function(entry){g.setNode(entry.v,entry.value);if(entry.parent){g.setParent(entry.v,entry.parent)}});_.each(json.edges,function(entry){g.setEdge({v:entry.v,w:entry.w,name:entry.name},entry.value)});return g}},{"./graph":72,"./lodash":75}],75:[function(require,module,exports){module.exports=require(20)},{"/Users/cpettitt/projects/dagre-d3/lib/lodash.js":20,lodash:77}],76:[function(require,module,exports){module.exports="1.0.1"},{}],77:[function(require,module,exports){(function(global){(function(){var undefined;var arrayPool=[],objectPool=[];var idCounter=0;var keyPrefix=+new Date+"";var largeArraySize=75;var maxPoolSize=40;var whitespace=" \f "+"\n\r\u2028\u2029"+" ᠎              ";var reEmptyStringLeading=/\b__p \+= '';/g,reEmptyStringMiddle=/\b(__p \+=) '' \+/g,reEmptyStringTrailing=/(__e\(.*?\)|\b__t\)) \+\n'';/g;var reEsTemplate=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;var reFlags=/\w*$/;var reFuncName=/^\s*function[ \n\r\t]+\w/;var reInterpolate=/<%=([\s\S]+?)%>/g;var reLeadingSpacesAndZeros=RegExp("^["+whitespace+"]*0+(?=.$)");var reNoMatch=/($^)/;var reThis=/\bthis\b/;var reUnescapedString=/['\n\r\t\u2028\u2029\\]/g;var contextProps=["Array","Boolean","Date","Function","Math","Number","Object","RegExp","String","_","attachEvent","clearTimeout","isFinite","isNaN","parseInt","setTimeout"];var templateCounter=0;var argsClass="[object Arguments]",arrayClass="[object Array]",boolClass="[object Boolean]",dateClass="[object Date]",funcClass="[object Function]",numberClass="[object Number]",objectClass="[object Object]",regexpClass="[object RegExp]",stringClass="[object String]";var cloneableClasses={};cloneableClasses[funcClass]=false;cloneableClasses[argsClass]=cloneableClasses[arrayClass]=cloneableClasses[boolClass]=cloneableClasses[dateClass]=cloneableClasses[numberClass]=cloneableClasses[objectClass]=cloneableClasses[regexpClass]=cloneableClasses[stringClass]=true;var debounceOptions={leading:false,maxWait:0,trailing:false};var descriptor={configurable:false,enumerable:false,value:null,writable:false};var objectTypes={"boolean":false,"function":true,object:true,number:false,string:false,undefined:false};var stringEscapes={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};var root=objectTypes[typeof window]&&window||this;var freeExports=objectTypes[typeof exports]&&exports&&!exports.nodeType&&exports;var freeModule=objectTypes[typeof module]&&module&&!module.nodeType&&module;var moduleExports=freeModule&&freeModule.exports===freeExports&&freeExports;var freeGlobal=objectTypes[typeof global]&&global;if(freeGlobal&&(freeGlobal.global===freeGlobal||freeGlobal.window===freeGlobal)){root=freeGlobal}function baseIndexOf(array,value,fromIndex){var index=(fromIndex||0)-1,length=array?array.length:0;while(++index-1?0:-1:cache?0:-1}function cachePush(value){var cache=this.cache,type=typeof value;if(type=="boolean"||value==null){cache[value]=true}else{if(type!="number"&&type!="string"){type="object"}var key=type=="number"?value:keyPrefix+value,typeCache=cache[type]||(cache[type]={});if(type=="object"){(typeCache[key]||(typeCache[key]=[])).push(value)}else{typeCache[key]=true}}}function charAtCallback(value){return value.charCodeAt(0)}function compareAscending(a,b){var ac=a.criteria,bc=b.criteria,index=-1,length=ac.length;while(++indexother||typeof value=="undefined"){return 1}if(value/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:reInterpolate,variable:"",imports:{_:lodash}};function baseBind(bindData){var func=bindData[0],partialArgs=bindData[2],thisArg=bindData[4];function bound(){if(partialArgs){var args=slice(partialArgs);push.apply(args,arguments)}if(this instanceof bound){var thisBinding=baseCreate(func.prototype),result=func.apply(thisBinding,args||arguments);return isObject(result)?result:thisBinding}return func.apply(thisArg,args||arguments)}setBindData(bound,bindData);return bound}function baseClone(value,isDeep,callback,stackA,stackB){if(callback){var result=callback(value);if(typeof result!="undefined"){return result}}var isObj=isObject(value);if(isObj){var className=toString.call(value);if(!cloneableClasses[className]){return value}var ctor=ctorByClass[className];switch(className){case boolClass:case dateClass:return new ctor(+value);case numberClass:case stringClass:return new ctor(value);case regexpClass:result=ctor(value.source,reFlags.exec(value));result.lastIndex=value.lastIndex;return result}}else{return value}var isArr=isArray(value);if(isDeep){var initedStack=!stackA;stackA||(stackA=getArray());stackB||(stackB=getArray());var length=stackA.length;while(length--){if(stackA[length]==value){return stackB[length]}}result=isArr?ctor(value.length):{}}else{result=isArr?slice(value):assign({},value)}if(isArr){if(hasOwnProperty.call(value,"index")){result.index=value.index}if(hasOwnProperty.call(value,"input")){result.input=value.input}}if(!isDeep){return result}stackA.push(value);stackB.push(result);(isArr?forEach:forOwn)(value,function(objValue,key){result[key]=baseClone(objValue,isDeep,callback,stackA,stackB)});if(initedStack){releaseArray(stackA);releaseArray(stackB)}return result}function baseCreate(prototype,properties){return isObject(prototype)?nativeCreate(prototype):{}}if(!nativeCreate){baseCreate=function(){function Object(){}return function(prototype){if(isObject(prototype)){Object.prototype=prototype;var result=new Object;Object.prototype=null}return result||context.Object()}}()}function baseCreateCallback(func,thisArg,argCount){if(typeof func!="function"){return identity}if(typeof thisArg=="undefined"||!("prototype"in func)){return func}var bindData=func.__bindData__;if(typeof bindData=="undefined"){if(support.funcNames){bindData=!func.name}bindData=bindData||!support.funcDecomp;if(!bindData){var source=fnToString.call(func);if(!support.funcNames){bindData=!reFuncName.test(source)}if(!bindData){bindData=reThis.test(source);setBindData(func,bindData)}}}if(bindData===false||bindData!==true&&bindData[1]&1){return func}switch(argCount){case 1:return function(value){return func.call(thisArg,value)};case 2:return function(a,b){return func.call(thisArg,a,b)};case 3:return function(value,index,collection){return func.call(thisArg,value,index,collection)};case 4:return function(accumulator,value,index,collection){return func.call(thisArg,accumulator,value,index,collection)}}return bind(func,thisArg)}function baseCreateWrapper(bindData){var func=bindData[0],bitmask=bindData[1],partialArgs=bindData[2],partialRightArgs=bindData[3],thisArg=bindData[4],arity=bindData[5];var isBind=bitmask&1,isBindKey=bitmask&2,isCurry=bitmask&4,isCurryBound=bitmask&8,key=func;function bound(){var thisBinding=isBind?thisArg:this;if(partialArgs){var args=slice(partialArgs);push.apply(args,arguments)}if(partialRightArgs||isCurry){args||(args=slice(arguments));if(partialRightArgs){push.apply(args,partialRightArgs)}if(isCurry&&args.length=largeArraySize&&indexOf===baseIndexOf,result=[];if(isLarge){var cache=createCache(values);if(cache){indexOf=cacheIndexOf;values=cache}else{isLarge=false}}while(++index-1}})}}stackA.pop();stackB.pop();if(initedStack){releaseArray(stackA);releaseArray(stackB)}return result}function baseMerge(object,source,callback,stackA,stackB){(isArray(source)?forEach:forOwn)(source,function(source,key){var found,isArr,result=source,value=object[key];if(source&&((isArr=isArray(source))||isPlainObject(source))){var stackLength=stackA.length;while(stackLength--){if(found=stackA[stackLength]==source){value=stackB[stackLength];break}}if(!found){var isShallow;if(callback){result=callback(value,source);if(isShallow=typeof result!="undefined"){value=result}}if(!isShallow){value=isArr?isArray(value)?value:[]:isPlainObject(value)?value:{}}stackA.push(source);stackB.push(value);if(!isShallow){baseMerge(value,source,callback,stackA,stackB)}}}else{if(callback){result=callback(value,source);if(typeof result=="undefined"){result=source}}if(typeof result!="undefined"){value=result}}object[key]=value})}function baseRandom(min,max){return min+floor(nativeRandom()*(max-min+1))}function baseUniq(array,isSorted,callback){var index=-1,indexOf=getIndexOf(),length=array?array.length:0,result=[];var isLarge=!isSorted&&length>=largeArraySize&&indexOf===baseIndexOf,seen=callback||isLarge?getArray():result;if(isLarge){var cache=createCache(seen);indexOf=cacheIndexOf;seen=cache}while(++index":">",'"':""","'":"'"};var htmlUnescapes=invert(htmlEscapes);var reEscapedHtml=RegExp("("+keys(htmlUnescapes).join("|")+")","g"),reUnescapedHtml=RegExp("["+keys(htmlEscapes).join("")+"]","g");var assign=function(object,source,guard){var index,iterable=object,result=iterable;if(!iterable)return result;var args=arguments,argsIndex=0,argsLength=typeof guard=="number"?2:args.length;if(argsLength>3&&typeof args[argsLength-2]=="function"){var callback=baseCreateCallback(args[--argsLength-1],args[argsLength--],2)}else if(argsLength>2&&typeof args[argsLength-1]=="function"){callback=args[--argsLength]}while(++argsIndex3&&typeof args[length-2]=="function"){var callback=baseCreateCallback(args[--length-1],args[length--],2)}else if(length>2&&typeof args[length-1]=="function"){callback=args[--length]}var sources=slice(arguments,1,length),index=-1,stackA=getArray(),stackB=getArray();while(++index-1}else if(typeof length=="number"){result=(isString(collection)?collection.indexOf(target,fromIndex):indexOf(collection,target,fromIndex))>-1}else{forOwn(collection,function(value){if(++index>=fromIndex){return!(result=value===target)}})}return result}var countBy=createAggregator(function(result,value,key){hasOwnProperty.call(result,key)?result[key]++:result[key]=1});function every(collection,callback,thisArg){var result=true;callback=lodash.createCallback(callback,thisArg,3);var index=-1,length=collection?collection.length:0;if(typeof length=="number"){while(++indexresult){result=value}}}else{callback=callback==null&&isString(collection)?charAtCallback:lodash.createCallback(callback,thisArg,3);forEach(collection,function(value,index,collection){var current=callback(value,index,collection);if(current>computed){computed=current;result=value}})}return result}function min(collection,callback,thisArg){var computed=Infinity,result=computed;if(typeof callback!="function"&&thisArg&&thisArg[callback]===collection){callback=null}if(callback==null&&isArray(collection)){var index=-1,length=collection.length;while(++index=largeArraySize&&createCache(argsIndex?args[argsIndex]:seen))}}var array=args[0],index=-1,length=array?array.length:0,result=[];outer:while(++index>>1;callback(array[mid])1?arguments:arguments[0],index=-1,length=array?max(pluck(array,"length")):0,result=Array(length<0?0:length);while(++index2?createWrapper(func,17,slice(arguments,2),null,thisArg):createWrapper(func,1,null,null,thisArg)}function bindAll(object){var funcs=arguments.length>1?baseFlatten(arguments,true,false,1):functions(object),index=-1,length=funcs.length;while(++index2?createWrapper(key,19,slice(arguments,2),null,object):createWrapper(key,3,null,null,object)}function compose(){var funcs=arguments,length=funcs.length;while(length--){if(!isFunction(funcs[length])){throw new TypeError}}return function(){var args=arguments,length=funcs.length;while(length--){args=[funcs[length].apply(this,args)]}return args[0]}}function curry(func,arity){arity=typeof arity=="number"?arity:+arity||func.length;return createWrapper(func,4,null,null,null,arity)}function debounce(func,wait,options){var args,maxTimeoutId,result,stamp,thisArg,timeoutId,trailingCall,lastCalled=0,maxWait=false,trailing=true;if(!isFunction(func)){throw new TypeError}wait=nativeMax(0,wait)||0;if(options===true){var leading=true;trailing=false}else if(isObject(options)){leading=options.leading;maxWait="maxWait"in options&&(nativeMax(wait,options.maxWait)||0);trailing="trailing"in options?options.trailing:trailing}var delayed=function(){var remaining=wait-(now()-stamp);if(remaining<=0){if(maxTimeoutId){clearTimeout(maxTimeoutId)}var isCalled=trailingCall;maxTimeoutId=timeoutId=trailingCall=undefined;if(isCalled){lastCalled=now();result=func.apply(thisArg,args);if(!timeoutId&&!maxTimeoutId){args=thisArg=null}}}else{timeoutId=setTimeout(delayed,remaining)}};var maxDelayed=function(){if(timeoutId){clearTimeout(timeoutId)}maxTimeoutId=timeoutId=trailingCall=undefined;if(trailing||maxWait!==wait){lastCalled=now();result=func.apply(thisArg,args);if(!timeoutId&&!maxTimeoutId){args=thisArg=null}}};return function(){args=arguments;stamp=now();thisArg=this;trailingCall=trailing&&(timeoutId||!leading);if(maxWait===false){var leadingCall=leading&&!timeoutId}else{if(!maxTimeoutId&&!leading){lastCalled=stamp}var remaining=maxWait-(stamp-lastCalled),isCalled=remaining<=0;if(isCalled){if(maxTimeoutId){maxTimeoutId=clearTimeout(maxTimeoutId)}lastCalled=stamp;result=func.apply(thisArg,args)}else if(!maxTimeoutId){maxTimeoutId=setTimeout(maxDelayed,remaining)}}if(isCalled&&timeoutId){timeoutId=clearTimeout(timeoutId)}else if(!timeoutId&&wait!==maxWait){timeoutId=setTimeout(delayed,wait)}if(leadingCall){isCalled=true;result=func.apply(thisArg,args)}if(isCalled&&!timeoutId&&!maxTimeoutId){args=thisArg=null}return result}}function defer(func){if(!isFunction(func)){throw new TypeError}var args=slice(arguments,1);return setTimeout(function(){func.apply(undefined,args)},1)}function delay(func,wait){if(!isFunction(func)){throw new TypeError}var args=slice(arguments,2);return setTimeout(function(){func.apply(undefined,args)},wait)}function memoize(func,resolver){if(!isFunction(func)){throw new TypeError}var memoized=function(){var cache=memoized.cache,key=resolver?resolver.apply(this,arguments):keyPrefix+arguments[0];return hasOwnProperty.call(cache,key)?cache[key]:cache[key]=func.apply(this,arguments) };memoized.cache={};return memoized}function once(func){var ran,result;if(!isFunction(func)){throw new TypeError}return function(){if(ran){return result}ran=true;result=func.apply(this,arguments);func=null;return result}}function partial(func){return createWrapper(func,16,slice(arguments,1))}function partialRight(func){return createWrapper(func,32,null,slice(arguments,1))}function throttle(func,wait,options){var leading=true,trailing=true;if(!isFunction(func)){throw new TypeError}if(options===false){leading=false}else if(isObject(options)){leading="leading"in options?options.leading:leading;trailing="trailing"in options?options.trailing:trailing}debounceOptions.leading=leading;debounceOptions.maxWait=wait;debounceOptions.trailing=trailing;return debounce(func,wait,debounceOptions)}function wrap(value,wrapper){return createWrapper(wrapper,16,[value])}function constant(value){return function(){return value}}function createCallback(func,thisArg,argCount){var type=typeof func;if(func==null||type=="function"){return baseCreateCallback(func,thisArg,argCount)}if(type!="object"){return property(func)}var props=keys(func),key=props[0],a=func[key];if(props.length==1&&a===a&&!isObject(a)){return function(object){var b=object[key];return a===b&&(a!==0||1/a==1/b)}}return function(object){var length=props.length,result=false;while(length--){if(!(result=baseIsEqual(object[props[length]],func[props[length]],null,true))){break}}return result}}function escape(string){return string==null?"":String(string).replace(reUnescapedHtml,escapeHtmlChar)}function identity(value){return value}function mixin(object,source,options){var chain=true,methodNames=source&&functions(source);if(!source||!options&&!methodNames.length){if(options==null){options=source}ctor=lodashWrapper;source=object;object=lodash;methodNames=functions(source)}if(options===false){chain=false}else if(isObject(options)&&"chain"in options){chain=options.chain}var ctor=object,isFunc=isFunction(ctor);forEach(methodNames,function(methodName){var func=object[methodName]=source[methodName];if(isFunc){ctor.prototype[methodName]=function(){var chainAll=this.__chain__,value=this.__wrapped__,args=[value];push.apply(args,arguments);var result=func.apply(object,args);if(chain||chainAll){if(value===result&&isObject(result)){return this}result=new ctor(result);result.__chain__=chainAll}return result}}})}function noConflict(){context._=oldDash;return this}function noop(){}var now=isNative(now=Date.now)&&now||function(){return(new Date).getTime()};var parseInt=nativeParseInt(whitespace+"08")==8?nativeParseInt:function(value,radix){return nativeParseInt(isString(value)?value.replace(reLeadingSpacesAndZeros,""):value,radix||0)};function property(key){return function(object){return object[key]}}function random(min,max,floating){var noMin=min==null,noMax=max==null;if(floating==null){if(typeof min=="boolean"&&noMax){floating=min;min=1}else if(!noMax&&typeof max=="boolean"){floating=max;noMax=true}}if(noMin&&noMax){max=1}min=+min||0;if(noMax){max=min;min=0}else{max=+max||0}if(floating||min%1||max%1){var rand=nativeRandom();return nativeMin(min+rand*(max-min+parseFloat("1e-"+((rand+"").length-1))),max)}return baseRandom(min,max)}function result(object,key){if(object){var value=object[key];return isFunction(value)?object[key]():value}}function template(text,data,options){var settings=lodash.templateSettings;text=String(text||"");options=defaults({},options,settings);var imports=defaults({},options.imports,settings.imports),importsKeys=keys(imports),importsValues=values(imports);var isEvaluating,index=0,interpolate=options.interpolate||reNoMatch,source="__p += '";var reDelimiters=RegExp((options.escape||reNoMatch).source+"|"+interpolate.source+"|"+(interpolate===reInterpolate?reEsTemplate:reNoMatch).source+"|"+(options.evaluate||reNoMatch).source+"|$","g");text.replace(reDelimiters,function(match,escapeValue,interpolateValue,esTemplateValue,evaluateValue,offset){interpolateValue||(interpolateValue=esTemplateValue);source+=text.slice(index,offset).replace(reUnescapedString,escapeStringChar);if(escapeValue){source+="' +\n__e("+escapeValue+") +\n'"}if(evaluateValue){isEvaluating=true;source+="';\n"+evaluateValue+";\n__p += '"}if(interpolateValue){source+="' +\n((__t = ("+interpolateValue+")) == null ? '' : __t) +\n'"}index=offset+match.length;return match});source+="';\n";var variable=options.variable,hasVariable=variable;if(!hasVariable){variable="obj";source="with ("+variable+") {\n"+source+"\n}\n"}source=(isEvaluating?source.replace(reEmptyStringLeading,""):source).replace(reEmptyStringMiddle,"$1").replace(reEmptyStringTrailing,"$1;");source="function("+variable+") {\n"+(hasVariable?"":variable+" || ("+variable+" = {});\n")+"var __t, __p = '', __e = _.escape"+(isEvaluating?", __j = Array.prototype.join;\n"+"function print() { __p += __j.call(arguments, '') }\n":";\n")+source+"return __p\n}";var sourceURL="\n/*\n//# sourceURL="+(options.sourceURL||"/lodash/template/source["+templateCounter++ +"]")+"\n*/";try{var result=Function(importsKeys,"return "+source+sourceURL).apply(undefined,importsValues)}catch(e){e.source=source;throw e}if(data){return result(data)}result.source=source;return result}function times(n,callback,thisArg){n=(n=+n)>-1?n:0;var index=-1,result=Array(n);callback=baseCreateCallback(callback,thisArg,1);while(++indexy&&A.push("'"+this.terminals_[E]+"'");$=p.showPosition?"Parse error on line "+(l+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[k]||k)+"'":"Parse error on line "+(l+1)+": Unexpected "+(k==u?"end of input":"'"+(this.terminals_[k]||k)+"'"),this.parseError($,{text:p.match,token:this.terminals_[k]||k,line:p.yylineno,loc:g,expected:A})}if(v[0]instanceof Array&&v.length>1)throw new Error("Parse Error: multiple actions possible at state: "+b+", token: "+k);switch(v[0]){case 1:n.push(k),s.push(p.yytext),i.push(p.yylloc),n.push(v[1]),k=null,x?(k=x,x=null):(h=p.yyleng,o=p.yytext,l=p.yylineno,g=p.yylloc,c>0&&c--);break;case 2:if(w=this.productions_[v[1]][1],O.$=s[s.length-w],O._$={first_line:i[i.length-(w||1)].first_line,last_line:i[i.length-1].last_line,first_column:i[i.length-(w||1)].first_column,last_column:i[i.length-1].last_column},_&&(O._$.range=[i[i.length-(w||1)].range[0],i[i.length-1].range[1]]),S=this.performAction.apply(O,[o,h,l,f.yy,v[1],s,i].concat(d)),"undefined"!=typeof S)return S;w&&(n=n.slice(0,-1*w*2),s=s.slice(0,-1*w),i=i.slice(0,-1*w)),n.push(this.productions_[v[1]][0]),s.push(O.$),i.push(O._$),I=a[n[n.length-2]][n[n.length-1]],n.push(I);break;case 3:return!0}}return!0}},O=function(){var t={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t;var e=t.match(/(?:\r\n?|\n).*/g);return e?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,r=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var s=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[s[0],s[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var r,n,s;if(this.options.backtrack_lexer&&(s={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(s.yylloc.range=this.yylloc.range.slice(0))),n=t[0].match(/(?:\r\n?|\n).*/g),n&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],r=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var i in s)this[i]=s[i];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var t,e,r,n;this._more||(this.yytext="",this.match="");for(var s=this._currentRules(),i=0;ie[0].length)){if(e=r,n=i,this.options.backtrack_lexer){if(t=this.test_match(r,s[i]),t!==!1)return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?(t=this.test_match(e,s[n]),t!==!1?t:!1):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t?t:this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){var t=this.conditionStack.length-1;return t>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return t=this.conditionStack.length-1-Math.abs(t||0),t>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(t,e,r,n){switch(r){case 0:return 37;case 1:return 8;case 2:return 10;case 3:return 10;case 4:return 39;case 5:return 29;case 6:return"BRKT";case 7:return 44;case 8:return 44;case 9:return 44;case 10:return 43;case 11:return 11;case 12:return 41;case 13:return 34;case 14:return 32;case 15:return 33;case 16:return 35;case 17:return 27;case 18:return 28;case 19:return 36;case 20:return 21;case 21:return 22;case 22:return 18;case 23:return 20;case 24:return 23;case 25:return 24;case 26:return 9;case 27:return"NEWLINE";case 28:return 6}},rules:[/^(?:style\b)/,/^(?:graph\b)/,/^(?:LR\b)/,/^(?:TD\b)/,/^(?:#[a-f0-9]+)/,/^(?:[0-9]+)/,/^(?:#)/,/^(?:px\b)/,/^(?:pt\b)/,/^(?:dot\b)/,/^(?::)/,/^(?:;)/,/^(?:,)/,/^(?:--[x])/,/^(?:-->)/,/^(?:--[o])/,/^(?:---)/,/^(?:-)/,/^(?:[a-zåäöæøA-ZÅÄÖÆØ]+)/,/^(?:\|)/,/^(?:\()/,/^(?:\))/,/^(?:\[)/,/^(?:\])/,/^(?:\{)/,/^(?:\})/,/^(?:\s)/,/^(?:\n)/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28],inclusive:!0}}};return t}();return A.lexer=O,t.prototype=A,A.Parser=t,new t}();"undefined"!=typeof require&&"undefined"!=typeof exports&&(exports.parser=parser,exports.Parser=parser.Parser,exports.parse=function(){return parser.parse.apply(parser,arguments)},exports.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),process.exit(1));var e=require("fs").readFileSync(require("path").normalize(t[1]),"utf8");return exports.parser.parse(e)},"undefined"!=typeof module&&require.main===module&&exports.main(process.argv.slice(1)));var mermaid;"undefined"==typeof mermaid&&(mermaid={}),mermaid.vertices={},mermaid.edges=[],mermaid.graph={addVertex:function(t,e,r,n){console.log("Got node "+t+" "+r+" "+e+" styles: "+JSON.stringify(n)),"undefined"==typeof mermaid.vertices[t]&&(mermaid.vertices[t]={id:t,styles:[]}),"undefined"!=typeof e&&(mermaid.vertices[t].text=e),"undefined"!=typeof r&&(mermaid.vertices[t].type=r),"undefined"!=typeof n&&null!==n&&(console.log("Adding style: "+n),n.forEach(function(e){mermaid.vertices[t].styles.push(e)}))},getVertices:function(){return mermaid.vertices},addLink:function(t,e,r,n){var s={start:t,end:e,type:void 0,text:""},n=r.text;"undefined"!=typeof n&&(s.text=n),"undefined"!=typeof r&&(s.type=r.type),mermaid.edges.push(s)},updateLink:function(t,e){var r=t.substr(1);console.log("Got link style for "+r+" style "+e),mermaid.edges[r].style=e},setDirection:function(t){mermaid.direction=t},getEdges:function(){return mermaid.edges},clear:function(){mermaid.vertices={},mermaid.edges=[]},defaultStyle:function(){return"fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;fill:#ffa;stroke: #666;"}};var mermaid;"undefined"==typeof mermaid&&(mermaid={}),mermaid.addVertices=function(t,e){var r=Object.keys(t);r.forEach(function(r){var n,s=t[r];console.log(s.styles.length);var i,a="";for(i=0;i',this.drawChart(s,r)}},mermaid.init(); \ No newline at end of file +var parser=function(){function t(){this.yy={}}var e=function(t,e,r,n){for(r=r||{},n=t.length;n--;r[t[n]]=e);return r},r=[1,7],n=[2,10],i=[1,15],s=[1,16],a=[1,11],o=[6,9],h=[11,28,29,37],l=[11,32,33,34,35],c=[9,11,18,20,21,22,23,24,32,33,34,35,36],u=[9,11,18,20,21,22,23,24,28,29,32,33,34,35,36],y=[9,11,18,20,21,22,23,24,27,28,29,32,33,34,35,36],d=[28,29],p=[28,29,36],f=[20,22,24,36],m=[1,66],g=[1,63],_=[1,61],k=[1,64],x=[1,67],b=[1,62],v=[1,65],S=[1,70],E=[11,41],w=[9,11,27,28,29,39,41,43,44],I={trace:function(){},yy:{},symbols_:{error:2,expressions:3,graphConfig:4,statements:5,EOF:6,spaceList:7,GRAPH:8,SPACE:9,DIR:10,SEMI:11,statement:12,verticeStatement:13,styleStatement:14,vertex:15,link:16,alphaNum:17,SQS:18,text:19,SQE:20,PS:21,PE:22,DIAMOND_START:23,DIAMOND_STOP:24,alphaNumStatement:25,alphaNumToken:26,MINUS:27,ALPHA:28,NUM:29,linkStatement:30,arrowText:31,ARROW_POINT:32,ARROW_CIRCLE:33,ARROW_CROSS:34,ARROW_OPEN:35,PIPE:36,STYLE:37,stylesOpt:38,HEX:39,style:40,COMMA:41,styleComponent:42,COLON:43,UNIT:44,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",8:"GRAPH",9:"SPACE",10:"DIR",11:"SEMI",18:"SQS",20:"SQE",21:"PS",22:"PE",23:"DIAMOND_START",24:"DIAMOND_STOP",27:"MINUS",28:"ALPHA",29:"NUM",32:"ARROW_POINT",33:"ARROW_CIRCLE",34:"ARROW_CROSS",35:"ARROW_OPEN",36:"PIPE",37:"STYLE",39:"HEX",41:"COMMA",43:"COLON",44:"UNIT"},productions_:[0,[3,3],[3,4],[4,4],[5,3],[5,1],[7,2],[7,1],[12,2],[12,2],[13,0],[13,3],[13,1],[15,4],[15,4],[15,4],[15,1],[17,1],[17,2],[25,1],[25,3],[26,1],[26,1],[16,2],[16,1],[30,1],[30,1],[30,1],[30,1],[31,3],[19,3],[19,2],[19,1],[14,5],[14,5],[38,1],[38,3],[40,1],[40,2],[42,1],[42,1],[42,1],[42,1],[42,1],[42,1],[42,1]],performAction:function(t,e,r,n,i,s){var a=s.length-1;switch(i){case 2:this.$=s[a-3];break;case 3:console.log("In graph config"),n.setDirection(s[a-1]),this.$=s[a-1];break;case 11:console.log("In vertexStatement"),n.addLink(s[a-2],s[a],s[a-1]),this.$="oy";break;case 12:console.log("In vertexStatement ... "),this.$="yo";break;case 13:this.$=s[a-3],n.addVertex(s[a-3],s[a-1],"square");break;case 14:this.$=s[a-3],n.addVertex(s[a-3],s[a-1],"round");break;case 15:this.$=s[a-3],n.addVertex(s[a-3],s[a-1],"diamond");break;case 16:console.log("In vertex:"+s[a]),this.$=s[a],n.addVertex(s[a]);break;case 17:case 21:case 22:case 37:this.$=s[a];break;case 18:this.$=s[a-1]+""+s[a];break;case 19:console.log("Found token (statement): "+s[a]),this.$=s[a];break;case 20:this.$=s[a-2]+"-"+s[a];break;case 23:s[a-1].text=s[a],this.$=s[a-1];break;case 24:case 32:this.$=s[a];break;case 25:this.$={type:"arrow"};break;case 26:this.$={type:"arrow_circle"};break;case 27:this.$={type:"arrow_cross"};break;case 28:this.$={type:"arrow_open"};break;case 29:console.log("Nice link text here: "+s[a-1]),this.$=s[a-1];break;case 30:this.$=s[a-2]+" "+s[a];break;case 31:this.$=s[a-1];break;case 33:this.$=s[a-4],n.addVertex(s[a-2],void 0,void 0,s[a]);break;case 34:console.log("In parser - style: "+s[a]),this.$=s[a-4],n.updateLink(s[a-2],s[a]);break;case 35:this.$=[s[a]];break;case 36:s[a-2].push(s[a]),this.$=s[a-2];break;case 38:this.$=s[a-1]+s[a];break;case 39:case 40:case 41:case 42:case 43:case 44:case 45:this.$=s[a]}},table:[{3:1,4:2,8:[1,3]},{1:[3]},{5:4,7:5,9:r,11:n,12:6,13:8,14:9,15:10,17:12,25:13,26:14,28:i,29:s,37:a},{9:[1,17]},{6:[1,18],7:19,9:r},{5:20,11:n,12:6,13:8,14:9,15:10,17:12,25:13,26:14,28:i,29:s,37:a},e(o,[2,5]),e(h,[2,7],{7:21,9:r}),{11:[1,22]},{11:[1,23]},{11:[2,12],16:24,30:25,32:[1,26],33:[1,27],34:[1,28],35:[1,29]},{9:[1,30]},e(l,[2,16],{18:[1,31],21:[1,32],23:[1,33]}),e(c,[2,17],{25:13,26:14,17:34,28:i,29:s}),e(u,[2,19],{27:[1,35]}),e(y,[2,21]),e(y,[2,22]),{10:[1,36]},{1:[2,1]},{11:n,12:37,13:8,14:9,15:10,17:12,25:13,26:14,28:i,29:s,37:a},{6:[1,38],7:19,9:r},e(h,[2,6]),e(o,[2,8]),e(o,[2,9]),{15:39,17:12,25:13,26:14,28:i,29:s},e(d,[2,24],{31:40,36:[1,41]}),e(p,[2,25]),e(p,[2,26]),e(p,[2,27]),e(p,[2,28]),{17:42,25:13,26:14,28:i,29:s,39:[1,43]},{17:45,19:44,25:13,26:14,28:i,29:s},{17:45,19:46,25:13,26:14,28:i,29:s},{17:45,19:47,25:13,26:14,28:i,29:s},e(c,[2,18]),{26:48,28:i,29:s},{11:[1,49]},e(o,[2,4]),{1:[2,2]},{11:[2,11]},e(d,[2,23]),{17:45,19:50,25:13,26:14,28:i,29:s},{9:[1,51]},{9:[1,52]},{20:[1,53]},e(f,[2,32],{9:[1,54]}),{22:[1,55]},{24:[1,56]},e(u,[2,20]),e([9,11,28,29,37],[2,3]),{36:[1,57]},{9:m,27:g,28:_,29:k,38:58,39:x,40:59,42:60,43:b,44:v},{9:m,27:g,28:_,29:k,38:68,39:x,40:59,42:60,43:b,44:v},e(l,[2,13]),e(f,[2,31],{25:13,26:14,17:45,19:69,28:i,29:s}),e(l,[2,14]),e(l,[2,15]),e(d,[2,29]),{11:[2,33],41:S},e(E,[2,35],{42:71,9:m,27:g,28:_,29:k,39:x,43:b,44:v}),e(w,[2,37]),e(w,[2,39]),e(w,[2,40]),e(w,[2,41]),e(w,[2,42]),e(w,[2,43]),e(w,[2,44]),e(w,[2,45]),{11:[2,34],41:S},e(f,[2,30]),{9:m,27:g,28:_,29:k,39:x,40:72,42:60,43:b,44:v},e(w,[2,38]),e(E,[2,36],{42:71,9:m,27:g,28:_,29:k,39:x,43:b,44:v})],defaultActions:{18:[2,1],38:[2,2],39:[2,11]},parseError:function(t,e){if(!e.recoverable)throw new Error(t);this.trace(t)},parse:function(t){function e(){var t;return t=p.lex()||y,"number"!=typeof t&&(t=r.symbols_[t]||t),t}var r=this,n=[0],i=[null],s=[],a=this.table,o="",h=0,l=0,c=0,u=2,y=1,d=s.slice.call(arguments,1),p=Object.create(this.lexer),f={yy:{}};for(var m in this.yy)Object.prototype.hasOwnProperty.call(this.yy,m)&&(f.yy[m]=this.yy[m]);p.setInput(t,f.yy),f.yy.lexer=p,f.yy.parser=this,"undefined"==typeof p.yylloc&&(p.yylloc={});var g=p.yylloc;s.push(g);var _=p.options&&p.options.ranges;this.parseError="function"==typeof f.yy.parseError?f.yy.parseError:Object.getPrototypeOf(this).parseError;for(var k,x,b,v,S,E,w,I,O,A={};;){if(b=n[n.length-1],this.defaultActions[b]?v=this.defaultActions[b]:((null===k||"undefined"==typeof k)&&(k=e()),v=a[b]&&a[b][k]),"undefined"==typeof v||!v.length||!v[0]){var $="";O=[];for(E in a[b])this.terminals_[E]&&E>u&&O.push("'"+this.terminals_[E]+"'");$=p.showPosition?"Parse error on line "+(h+1)+":\n"+p.showPosition()+"\nExpecting "+O.join(", ")+", got '"+(this.terminals_[k]||k)+"'":"Parse error on line "+(h+1)+": Unexpected "+(k==y?"end of input":"'"+(this.terminals_[k]||k)+"'"),this.parseError($,{text:p.match,token:this.terminals_[k]||k,line:p.yylineno,loc:g,expected:O})}if(v[0]instanceof Array&&v.length>1)throw new Error("Parse Error: multiple actions possible at state: "+b+", token: "+k);switch(v[0]){case 1:n.push(k),i.push(p.yytext),s.push(p.yylloc),n.push(v[1]),k=null,x?(k=x,x=null):(l=p.yyleng,o=p.yytext,h=p.yylineno,g=p.yylloc,c>0&&c--);break;case 2:if(w=this.productions_[v[1]][1],A.$=i[i.length-w],A._$={first_line:s[s.length-(w||1)].first_line,last_line:s[s.length-1].last_line,first_column:s[s.length-(w||1)].first_column,last_column:s[s.length-1].last_column},_&&(A._$.range=[s[s.length-(w||1)].range[0],s[s.length-1].range[1]]),S=this.performAction.apply(A,[o,l,h,f.yy,v[1],i,s].concat(d)),"undefined"!=typeof S)return S;w&&(n=n.slice(0,-1*w*2),i=i.slice(0,-1*w),s=s.slice(0,-1*w)),n.push(this.productions_[v[1]][0]),i.push(A.$),s.push(A._$),I=a[n[n.length-2]][n[n.length-1]],n.push(I);break;case 3:return!0}}return!0}},O=function(){var t={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t;var e=t.match(/(?:\r\n?|\n).*/g);return e?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,r=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var r,n,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),n=t[0].match(/(?:\r\n?|\n).*/g),n&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],r=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var s in i)this[s]=i[s];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var t,e,r,n;this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),s=0;se[0].length)){if(e=r,n=s,this.options.backtrack_lexer){if(t=this.test_match(r,i[s]),t!==!1)return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?(t=this.test_match(e,i[n]),t!==!1?t:!1):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t?t:this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){var t=this.conditionStack.length-1;return t>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return t=this.conditionStack.length-1-Math.abs(t||0),t>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(t,e,r,n){switch(r){case 0:return 37;case 1:return 8;case 2:return 10;case 3:return 10;case 4:return 39;case 5:return 29;case 6:return"BRKT";case 7:return 44;case 8:return 44;case 9:return 44;case 10:return 43;case 11:return 11;case 12:return 41;case 13:return 34;case 14:return 32;case 15:return 33;case 16:return 35;case 17:return 27;case 18:return 28;case 19:return 36;case 20:return 21;case 21:return 22;case 22:return 18;case 23:return 20;case 24:return 23;case 25:return 24;case 26:return 9;case 27:return"NEWLINE";case 28:return 6}},rules:[/^(?:style\b)/,/^(?:graph\b)/,/^(?:LR\b)/,/^(?:TD\b)/,/^(?:#[a-f0-9]+)/,/^(?:[0-9]+)/,/^(?:#)/,/^(?:px\b)/,/^(?:pt\b)/,/^(?:dot\b)/,/^(?::)/,/^(?:;)/,/^(?:,)/,/^(?:--[x])/,/^(?:-->)/,/^(?:--[o])/,/^(?:---)/,/^(?:-)/,/^(?:[a-zåäöæøA-ZÅÄÖÆØ]+)/,/^(?:\|)/,/^(?:\()/,/^(?:\))/,/^(?:\[)/,/^(?:\])/,/^(?:\{)/,/^(?:\})/,/^(?:\s)/,/^(?:\n)/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28],inclusive:!0}}};return t}();return I.lexer=O,t.prototype=I,I.Parser=t,new t}();"undefined"!=typeof require&&"undefined"!=typeof exports&&(exports.parser=parser,exports.Parser=parser.Parser,exports.parse=function(){return parser.parse.apply(parser,arguments)},exports.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),process.exit(1));var e=require("fs").readFileSync(require("path").normalize(t[1]),"utf8");return exports.parser.parse(e)},"undefined"!=typeof module&&require.main===module&&exports.main(process.argv.slice(1)));var mermaid;"undefined"==typeof mermaid&&(mermaid={}),mermaid.vertices={},mermaid.edges=[],mermaid.graph={addVertex:function(t,e,r,n){console.log("Got node "+t+" "+r+" "+e+" styles: "+JSON.stringify(n)),"undefined"==typeof mermaid.vertices[t]&&(mermaid.vertices[t]={id:t,styles:[]}),"undefined"!=typeof e&&(mermaid.vertices[t].text=e),"undefined"!=typeof r&&(mermaid.vertices[t].type=r),"undefined"!=typeof n&&null!==n&&n.forEach(function(e){mermaid.vertices[t].styles.push(e)})},addLink:function(t,e,r,n){var i={start:t,end:e,type:void 0,text:""},n=r.text;"undefined"!=typeof n&&(i.text=n),"undefined"!=typeof r&&(i.type=r.type),mermaid.edges.push(i)},updateLink:function(t,e){var r=t.substr(1);mermaid.edges[r].style=e},setDirection:function(t){mermaid.direction=t},getVertices:function(){return mermaid.vertices},getEdges:function(){return mermaid.edges},clear:function(){mermaid.vertices={},mermaid.edges=[]},defaultStyle:function(){return"fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;fill:#ffa;stroke: #666;"}};var mermaid;"undefined"==typeof mermaid&&(mermaid={}),mermaid.addVertices=function(t,e){var r=Object.keys(t);r.forEach(function(r){var n,i,s=t[r],a="";for(i=0;i',this.drawChart(s,r)}},document.addEventListener("DOMContentLoaded",function(){mermaid.init()},!1); \ No newline at end of file diff --git a/dist/mermaid.slim.js b/dist/mermaid.slim.js index ff5c23266..093e2eba4 100644 --- a/dist/mermaid.slim.js +++ b/dist/mermaid.slim.js @@ -72,12 +72,12 @@ } */ var parser = (function(){ -var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,7],$V1=[2,10],$V2=[1,15],$V3=[1,16],$V4=[1,11],$V5=[6,9],$V6=[11,28,29,37],$V7=[11,32,33,34,35],$V8=[9,11,18,20,21,22,23,24,27,32,33,34,35,36],$V9=[9,11,18,20,21,22,23,24,27,28,29,32,33,34,35,36],$Va=[28,29],$Vb=[28,29,36],$Vc=[20,22,24,36],$Vd=[1,67],$Ve=[1,64],$Vf=[1,62],$Vg=[1,65],$Vh=[1,68],$Vi=[1,63],$Vj=[1,66],$Vk=[1,72],$Vl=[11,41],$Vm=[9,11,27,28,29,39,41,43,44]; +var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,7],$V1=[2,10],$V2=[1,15],$V3=[1,16],$V4=[1,11],$V5=[6,9],$V6=[11,28,29,37],$V7=[11,32,33,34,35],$V8=[9,11,18,20,21,22,23,24,32,33,34,35,36],$V9=[9,11,18,20,21,22,23,24,28,29,32,33,34,35,36],$Va=[9,11,18,20,21,22,23,24,27,28,29,32,33,34,35,36],$Vb=[28,29],$Vc=[28,29,36],$Vd=[20,22,24,36],$Ve=[1,66],$Vf=[1,63],$Vg=[1,61],$Vh=[1,64],$Vi=[1,67],$Vj=[1,62],$Vk=[1,65],$Vl=[1,70],$Vm=[11,41],$Vn=[9,11,27,28,29,39,41,43,44]; var parser = {trace: function trace() { }, yy: {}, symbols_: {"error":2,"expressions":3,"graphConfig":4,"statements":5,"EOF":6,"spaceList":7,"GRAPH":8,"SPACE":9,"DIR":10,"SEMI":11,"statement":12,"verticeStatement":13,"styleStatement":14,"vertex":15,"link":16,"alphaNum":17,"SQS":18,"text":19,"SQE":20,"PS":21,"PE":22,"DIAMOND_START":23,"DIAMOND_STOP":24,"alphaNumStatement":25,"alphaNumToken":26,"MINUS":27,"ALPHA":28,"NUM":29,"linkStatement":30,"arrowText":31,"ARROW_POINT":32,"ARROW_CIRCLE":33,"ARROW_CROSS":34,"ARROW_OPEN":35,"PIPE":36,"STYLE":37,"stylesOpt":38,"HEX":39,"style":40,"COMMA":41,"styleComponent":42,"COLON":43,"UNIT":44,"$accept":0,"$end":1}, terminals_: {2:"error",6:"EOF",8:"GRAPH",9:"SPACE",10:"DIR",11:"SEMI",18:"SQS",20:"SQE",21:"PS",22:"PE",23:"DIAMOND_START",24:"DIAMOND_STOP",27:"MINUS",28:"ALPHA",29:"NUM",32:"ARROW_POINT",33:"ARROW_CIRCLE",34:"ARROW_CROSS",35:"ARROW_OPEN",36:"PIPE",37:"STYLE",39:"HEX",41:"COMMA",43:"COLON",44:"UNIT"}, -productions_: [0,[3,3],[3,4],[4,4],[5,3],[5,1],[7,2],[7,1],[12,2],[12,2],[13,0],[13,3],[13,1],[15,4],[15,4],[15,4],[15,1],[17,1],[17,2],[25,1],[25,3],[26,1],[26,1],[16,2],[16,1],[30,1],[30,1],[30,1],[30,1],[31,3],[19,3],[19,3],[19,2],[19,1],[14,5],[14,5],[38,1],[38,3],[40,1],[40,2],[42,1],[42,1],[42,1],[42,1],[42,1],[42,1],[42,1]], +productions_: [0,[3,3],[3,4],[4,4],[5,3],[5,1],[7,2],[7,1],[12,2],[12,2],[13,0],[13,3],[13,1],[15,4],[15,4],[15,4],[15,1],[17,1],[17,2],[25,1],[25,3],[26,1],[26,1],[16,2],[16,1],[30,1],[30,1],[30,1],[30,1],[31,3],[19,3],[19,2],[19,1],[14,5],[14,5],[38,1],[38,3],[40,1],[40,2],[42,1],[42,1],[42,1],[42,1],[42,1],[42,1],[42,1]], performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { /* this == yyval */ @@ -107,7 +107,7 @@ break; case 16: console.log('In vertex:'+$$[$0]); this.$ = $$[$0];yy.addVertex($$[$0]); break; -case 17: case 21: case 22: case 38: +case 17: case 21: case 22: case 37: this.$=$$[$0]; break; case 18: @@ -122,7 +122,7 @@ break; case 23: $$[$0-1].text = $$[$0];this.$ = $$[$0-1]; break; -case 24: case 33: +case 24: case 32: this.$ = $$[$0]; break; case 25: @@ -144,32 +144,29 @@ case 30: this.$ = $$[$0-2] + ' ' +$$[$0]; break; case 31: -this.$ = $$[$0-2] + '-' +$$[$0]; -break; -case 32: this.$ = $$[$0-1]; break; -case 34: +case 33: this.$ = $$[$0-4];yy.addVertex($$[$0-2],undefined,undefined,$$[$0]); break; -case 35: +case 34: console.log('In parser - style: '+$$[$0]);this.$ = $$[$0-4];yy.updateLink($$[$0-2],$$[$0]); break; -case 36: +case 35: this.$ = [$$[$0]] break; -case 37: +case 36: $$[$0-2].push($$[$0]);this.$ = $$[$0-2]; break; -case 39: +case 38: this.$ = $$[$0-1] + $$[$0]; break; -case 40: case 41: case 42: case 43: case 44: case 45: case 46: +case 39: case 40: case 41: case 42: case 43: case 44: case 45: this.$=$$[$0] break; } }, -table: [{3:1,4:2,8:[1,3]},{1:[3]},{5:4,7:5,9:$V0,11:$V1,12:6,13:8,14:9,15:10,17:12,25:13,26:14,28:$V2,29:$V3,37:$V4},{9:[1,17]},{6:[1,18],7:19,9:$V0},{5:20,11:$V1,12:6,13:8,14:9,15:10,17:12,25:13,26:14,28:$V2,29:$V3,37:$V4},o($V5,[2,5]),o($V6,[2,7],{7:21,9:$V0}),{11:[1,22]},{11:[1,23]},{11:[2,12],16:24,30:25,32:[1,26],33:[1,27],34:[1,28],35:[1,29]},{9:[1,30]},o($V7,[2,16],{18:[1,31],21:[1,32],23:[1,33]}),o($V8,[2,17],{25:13,26:14,17:34,28:$V2,29:$V3}),o([9,11,18,20,21,22,23,24,28,29,32,33,34,35,36],[2,19],{27:[1,35]}),o($V9,[2,21]),o($V9,[2,22]),{10:[1,36]},{1:[2,1]},{11:$V1,12:37,13:8,14:9,15:10,17:12,25:13,26:14,28:$V2,29:$V3,37:$V4},{6:[1,38],7:19,9:$V0},o($V6,[2,6]),o($V5,[2,8]),o($V5,[2,9]),{15:39,17:12,25:13,26:14,28:$V2,29:$V3},o($Va,[2,24],{31:40,36:[1,41]}),o($Vb,[2,25]),o($Vb,[2,26]),o($Vb,[2,27]),o($Vb,[2,28]),{17:42,25:13,26:14,28:$V2,29:$V3,39:[1,43]},{17:45,19:44,25:13,26:14,28:$V2,29:$V3},{17:45,19:46,25:13,26:14,28:$V2,29:$V3},{17:45,19:47,25:13,26:14,28:$V2,29:$V3},o($V8,[2,18]),{26:48,28:$V2,29:$V3},{11:[1,49]},o($V5,[2,4]),{1:[2,2]},{11:[2,11]},o($Va,[2,23]),{17:45,19:50,25:13,26:14,28:$V2,29:$V3},{9:[1,51]},{9:[1,52]},{20:[1,53]},o($Vc,[2,33],{9:[1,54],27:[1,55]}),{22:[1,56]},{24:[1,57]},o($V9,[2,20]),o([9,11,28,29,37],[2,3]),{36:[1,58]},{9:$Vd,27:$Ve,28:$Vf,29:$Vg,38:59,39:$Vh,40:60,42:61,43:$Vi,44:$Vj},{9:$Vd,27:$Ve,28:$Vf,29:$Vg,38:69,39:$Vh,40:60,42:61,43:$Vi,44:$Vj},o($V7,[2,13]),o($Vc,[2,32],{25:13,26:14,17:45,19:70,28:$V2,29:$V3}),{17:45,19:71,25:13,26:14,28:$V2,29:$V3},o($V7,[2,14]),o($V7,[2,15]),o($Va,[2,29]),{11:[2,34],41:$Vk},o($Vl,[2,36],{42:73,9:$Vd,27:$Ve,28:$Vf,29:$Vg,39:$Vh,43:$Vi,44:$Vj}),o($Vm,[2,38]),o($Vm,[2,40]),o($Vm,[2,41]),o($Vm,[2,42]),o($Vm,[2,43]),o($Vm,[2,44]),o($Vm,[2,45]),o($Vm,[2,46]),{11:[2,35],41:$Vk},o($Vc,[2,30]),o($Vc,[2,31]),{9:$Vd,27:$Ve,28:$Vf,29:$Vg,39:$Vh,40:74,42:61,43:$Vi,44:$Vj},o($Vm,[2,39]),o($Vl,[2,37],{42:73,9:$Vd,27:$Ve,28:$Vf,29:$Vg,39:$Vh,43:$Vi,44:$Vj})], +table: [{3:1,4:2,8:[1,3]},{1:[3]},{5:4,7:5,9:$V0,11:$V1,12:6,13:8,14:9,15:10,17:12,25:13,26:14,28:$V2,29:$V3,37:$V4},{9:[1,17]},{6:[1,18],7:19,9:$V0},{5:20,11:$V1,12:6,13:8,14:9,15:10,17:12,25:13,26:14,28:$V2,29:$V3,37:$V4},o($V5,[2,5]),o($V6,[2,7],{7:21,9:$V0}),{11:[1,22]},{11:[1,23]},{11:[2,12],16:24,30:25,32:[1,26],33:[1,27],34:[1,28],35:[1,29]},{9:[1,30]},o($V7,[2,16],{18:[1,31],21:[1,32],23:[1,33]}),o($V8,[2,17],{25:13,26:14,17:34,28:$V2,29:$V3}),o($V9,[2,19],{27:[1,35]}),o($Va,[2,21]),o($Va,[2,22]),{10:[1,36]},{1:[2,1]},{11:$V1,12:37,13:8,14:9,15:10,17:12,25:13,26:14,28:$V2,29:$V3,37:$V4},{6:[1,38],7:19,9:$V0},o($V6,[2,6]),o($V5,[2,8]),o($V5,[2,9]),{15:39,17:12,25:13,26:14,28:$V2,29:$V3},o($Vb,[2,24],{31:40,36:[1,41]}),o($Vc,[2,25]),o($Vc,[2,26]),o($Vc,[2,27]),o($Vc,[2,28]),{17:42,25:13,26:14,28:$V2,29:$V3,39:[1,43]},{17:45,19:44,25:13,26:14,28:$V2,29:$V3},{17:45,19:46,25:13,26:14,28:$V2,29:$V3},{17:45,19:47,25:13,26:14,28:$V2,29:$V3},o($V8,[2,18]),{26:48,28:$V2,29:$V3},{11:[1,49]},o($V5,[2,4]),{1:[2,2]},{11:[2,11]},o($Vb,[2,23]),{17:45,19:50,25:13,26:14,28:$V2,29:$V3},{9:[1,51]},{9:[1,52]},{20:[1,53]},o($Vd,[2,32],{9:[1,54]}),{22:[1,55]},{24:[1,56]},o($V9,[2,20]),o([9,11,28,29,37],[2,3]),{36:[1,57]},{9:$Ve,27:$Vf,28:$Vg,29:$Vh,38:58,39:$Vi,40:59,42:60,43:$Vj,44:$Vk},{9:$Ve,27:$Vf,28:$Vg,29:$Vh,38:68,39:$Vi,40:59,42:60,43:$Vj,44:$Vk},o($V7,[2,13]),o($Vd,[2,31],{25:13,26:14,17:45,19:69,28:$V2,29:$V3}),o($V7,[2,14]),o($V7,[2,15]),o($Vb,[2,29]),{11:[2,33],41:$Vl},o($Vm,[2,35],{42:71,9:$Ve,27:$Vf,28:$Vg,29:$Vh,39:$Vi,43:$Vj,44:$Vk}),o($Vn,[2,37]),o($Vn,[2,39]),o($Vn,[2,40]),o($Vn,[2,41]),o($Vn,[2,42]),o($Vn,[2,43]),o($Vn,[2,44]),o($Vn,[2,45]),{11:[2,34],41:$Vl},o($Vd,[2,30]),{9:$Ve,27:$Vf,28:$Vg,29:$Vh,39:$Vi,40:72,42:60,43:$Vj,44:$Vk},o($Vn,[2,38]),o($Vm,[2,36],{42:71,9:$Ve,27:$Vf,28:$Vg,29:$Vh,39:$Vi,43:$Vj,44:$Vk})], defaultActions: {18:[2,1],38:[2,2],39:[2,11]}, parseError: function parseError(str, hash) { if (hash.recoverable) { @@ -748,7 +745,7 @@ mermaid.edges = []; mermaid.graph = { /** - * + * Function called by parser when a node definition has been found * @param id * @param text * @param type @@ -767,16 +764,19 @@ mermaid.graph = { } if(typeof style !== 'undefined'){ if(style !== null){ - console.log('Adding style: '+style); style.forEach(function(s){ mermaid.vertices[id].styles.push(s); }); } } }, - getVertices:function(){ - return mermaid.vertices; - }, + /** + * Function called by parser when a link/edge definition has been found + * @param start + * @param end + * @param type + * @param linktext + */ addLink: function (start, end, type, linktext) { var edge = {start:start, end:end, type:undefined, text:''}; var linktext = type.text; @@ -788,24 +788,49 @@ mermaid.graph = { edge.type = type.type; } mermaid.edges.push(edge); - //console.log('Got link from ' + start + ' to ' + end + ' type:' + type.type + ' linktext:' + linktext); }, + /** + * Updates a link with a style + * @param pos + * @param style + */ updateLink: function (pos, style) { - //mermaid.edges.push(edge); var position = pos.substr(1); - console.log('Got link style for ' + position + ' style ' + style); mermaid.edges[position].style = style; }, + /** + * Called by parser when a graph definition is found, stores the direction of the chart. + * @param dir + */ setDirection: function(dir){ mermaid.direction = dir; }, + /** + * Retrieval function for fetching the found nodes after parsing has completed. + * @returns {{}|*|mermaid.vertices} + */ + getVertices:function(){ + return mermaid.vertices; + }, + /** + * Retrieval function for fetching the found links after parsing has completed. + * @returns {{}|*|mermaid.edges} + */ getEdges: function () { return mermaid.edges; }, + + /** + * Clears the internal graph db so that a new graph can be parsed. + */ clear:function(){ mermaid.vertices = {}; mermaid.edges = []; }, + /** + * + * @returns {string} + */ defaultStyle:function(){ return "fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;fill:#ffa;stroke: #666;"; } @@ -818,28 +843,28 @@ if (typeof mermaid === 'undefined') { } /** - * Function used by parser to store vertices/nodes found in graph script. - * @param vert - * @param g + * Function that adds the vertices found in the graph definition to the graph to be rendered. + * @param vert Object containing the vertices. + * @param g The graph that is to be drawn. */ mermaid.addVertices = function (vert, g) { var keys = Object.keys(vert); + // Iterate through each item in the vertice object (containing all the vertices found) in the graph definition keys.forEach(function (id) { var vertice = vert[id]; var verticeText; - - console.log(vertice.styles.length); - var i; var style = ''; + // Create a compund style definiton from the style definitions found for the node in the graph definition for (i = 0; i < vertice.styles.length; i++) { if (typeof vertice.styles[i] !== 'undefined') { style = style + vertice.styles[i] + ';'; } } + // Use vertice id as text in the box if no text is provided by the graph definition if (vertice.text === undefined) { verticeText = vertice.id; } @@ -847,12 +872,7 @@ mermaid.addVertices = function (vert, g) { verticeText = vertice.text; } - - if (style === '') { - //style = graph.defaultStyle(); - } - - console.log('g.setNode("' + vertice.id + '", { label: "' + verticeText + '" });'); + // Create the node in the graph nased on defined form if (vertice.type === 'round') { g.setNode(vertice.id, {label: verticeText, rx: 5, ry: 5, style: style}); } else { @@ -865,31 +885,23 @@ mermaid.addVertices = function (vert, g) { }); }; +/** + * Add edges to graph based on parsed graph defninition + * @param edges + * @param g + */ mermaid.addEdges = function (edges, g) { edges.forEach(function (edge) { - var type, style; - if(typeof edge.type === 'undefined'){ - type = 'arrow'; - }else{ - type = edge.type; - } - if(typeof edge.style === 'undefined'){ - style = 'arrow'; - }else{ - type = edge.type; - } - - if(type === 'arrow_open'){ + // Set link type for rendering + if(edge.type === 'arrow_open'){ aHead = 'none'; } else{ aHead = 'vee'; } - - var edgeText; - //console.log(vertice); + // Add the edge to the graph if (edge.text === 'undefined') { if(typeof edge.style === 'undefined'){ g.setEdge(edge.start, edge.end,{ arrowheadStyle: "fill: #333", arrowhead: aHead}); @@ -898,7 +910,6 @@ mermaid.addEdges = function (edges, g) { style: edge.style, arrowheadStyle: "fill: #333", arrowhead: aHead }); } - } else { if(typeof edge.style === 'undefined'){ @@ -909,39 +920,28 @@ mermaid.addEdges = function (edges, g) { }); } } - console.log('g.setEdge("' + edge.start + '","' + edge.end + '") ---'); - }); }; +/** + * Draws a chart in the tag with id: id based on the graph definition in text. + * @param text + * @param id + */ mermaid.drawChart = function (text, id) { - - console.log('drawing char with id:' + id); - console.log(text); mermaid.graph.clear(); parser.yy = mermaid.graph; - var err = function () { - console.log('Syntax error!!!'); - }; - + // Parse the graph definition parser.parse(text); - var vert = mermaid.graph.getVertices(); - var edges = mermaid.graph.getEdges(); - - console.log(edges); - - var keys = Object.keys(vert); - + // Fetch the default direction, use TD if none was found var dir; dir = mermaid.direction; if(typeof dir === 'undefined'){ dir='TD'; } - - // Create the input mermaid.graph var g = new dagreD3.graphlib.Graph() .setGraph({ @@ -953,7 +953,9 @@ mermaid.drawChart = function (text, id) { return {}; }); - console.log(g); + // Fetch the verices/nodes and edges/links from the parsed graph definition + var vert = mermaid.graph.getVertices(); + var edges = mermaid.graph.getEdges(); this.addVertices(vert, g); this.addEdges(edges, g); @@ -961,7 +963,7 @@ mermaid.drawChart = function (text, id) { // Create the renderer var render = new dagreD3.render(); - // Add our custom shape + // Add custom shape for rhombus type of boc (decision) render.shapes().question = function (parent, bbox, node) { var w = bbox.width, h = bbox.height * 3, @@ -1016,6 +1018,9 @@ mermaid.drawChart = function (text, id) { svg.attr("height", g.graph().height + 40); }; +/** + * Go through the document and find the chart definitions in there and render the charts + */ mermaid.init = function () { var arr = document.querySelectorAll('.mermaid'); @@ -1037,4 +1042,10 @@ mermaid.init = function () { } ; }; -mermaid.init(); \ No newline at end of file + +/** + * Wait for coument loaded before starting the execution + */ +document.addEventListener('DOMContentLoaded', function(){ + mermaid.init(); + }, false); \ No newline at end of file diff --git a/dist/mermaid.slim.min.js b/dist/mermaid.slim.min.js index 4db5f90b1..e7bd0060d 100644 --- a/dist/mermaid.slim.min.js +++ b/dist/mermaid.slim.min.js @@ -1 +1 @@ -var parser=function(){function t(){this.yy={}}var e=function(t,e,r,n){for(r=r||{},n=t.length;n--;r[t[n]]=e);return r},r=[1,7],n=[2,10],s=[1,15],i=[1,16],a=[1,11],o=[6,9],l=[11,28,29,37],h=[11,32,33,34,35],c=[9,11,18,20,21,22,23,24,27,32,33,34,35,36],y=[9,11,18,20,21,22,23,24,27,28,29,32,33,34,35,36],u=[28,29],d=[28,29,36],p=[20,22,24,36],f=[1,67],m=[1,64],g=[1,62],_=[1,65],k=[1,68],x=[1,63],b=[1,66],v=[1,72],S=[11,41],E=[9,11,27,28,29,39,41,43,44],w={trace:function(){},yy:{},symbols_:{error:2,expressions:3,graphConfig:4,statements:5,EOF:6,spaceList:7,GRAPH:8,SPACE:9,DIR:10,SEMI:11,statement:12,verticeStatement:13,styleStatement:14,vertex:15,link:16,alphaNum:17,SQS:18,text:19,SQE:20,PS:21,PE:22,DIAMOND_START:23,DIAMOND_STOP:24,alphaNumStatement:25,alphaNumToken:26,MINUS:27,ALPHA:28,NUM:29,linkStatement:30,arrowText:31,ARROW_POINT:32,ARROW_CIRCLE:33,ARROW_CROSS:34,ARROW_OPEN:35,PIPE:36,STYLE:37,stylesOpt:38,HEX:39,style:40,COMMA:41,styleComponent:42,COLON:43,UNIT:44,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",8:"GRAPH",9:"SPACE",10:"DIR",11:"SEMI",18:"SQS",20:"SQE",21:"PS",22:"PE",23:"DIAMOND_START",24:"DIAMOND_STOP",27:"MINUS",28:"ALPHA",29:"NUM",32:"ARROW_POINT",33:"ARROW_CIRCLE",34:"ARROW_CROSS",35:"ARROW_OPEN",36:"PIPE",37:"STYLE",39:"HEX",41:"COMMA",43:"COLON",44:"UNIT"},productions_:[0,[3,3],[3,4],[4,4],[5,3],[5,1],[7,2],[7,1],[12,2],[12,2],[13,0],[13,3],[13,1],[15,4],[15,4],[15,4],[15,1],[17,1],[17,2],[25,1],[25,3],[26,1],[26,1],[16,2],[16,1],[30,1],[30,1],[30,1],[30,1],[31,3],[19,3],[19,3],[19,2],[19,1],[14,5],[14,5],[38,1],[38,3],[40,1],[40,2],[42,1],[42,1],[42,1],[42,1],[42,1],[42,1],[42,1]],performAction:function(t,e,r,n,s,i){var a=i.length-1;switch(s){case 2:this.$=i[a-3];break;case 3:console.log("In graph config"),n.setDirection(i[a-1]),this.$=i[a-1];break;case 11:console.log("In vertexStatement"),n.addLink(i[a-2],i[a],i[a-1]),this.$="oy";break;case 12:console.log("In vertexStatement ... "),this.$="yo";break;case 13:this.$=i[a-3],n.addVertex(i[a-3],i[a-1],"square");break;case 14:this.$=i[a-3],n.addVertex(i[a-3],i[a-1],"round");break;case 15:this.$=i[a-3],n.addVertex(i[a-3],i[a-1],"diamond");break;case 16:console.log("In vertex:"+i[a]),this.$=i[a],n.addVertex(i[a]);break;case 17:case 21:case 22:case 38:this.$=i[a];break;case 18:this.$=i[a-1]+""+i[a];break;case 19:console.log("Found token (statement): "+i[a]),this.$=i[a];break;case 20:this.$=i[a-2]+"-"+i[a];break;case 23:i[a-1].text=i[a],this.$=i[a-1];break;case 24:case 33:this.$=i[a];break;case 25:this.$={type:"arrow"};break;case 26:this.$={type:"arrow_circle"};break;case 27:this.$={type:"arrow_cross"};break;case 28:this.$={type:"arrow_open"};break;case 29:console.log("Nice link text here: "+i[a-1]),this.$=i[a-1];break;case 30:this.$=i[a-2]+" "+i[a];break;case 31:this.$=i[a-2]+"-"+i[a];break;case 32:this.$=i[a-1];break;case 34:this.$=i[a-4],n.addVertex(i[a-2],void 0,void 0,i[a]);break;case 35:console.log("In parser - style: "+i[a]),this.$=i[a-4],n.updateLink(i[a-2],i[a]);break;case 36:this.$=[i[a]];break;case 37:i[a-2].push(i[a]),this.$=i[a-2];break;case 39:this.$=i[a-1]+i[a];break;case 40:case 41:case 42:case 43:case 44:case 45:case 46:this.$=i[a]}},table:[{3:1,4:2,8:[1,3]},{1:[3]},{5:4,7:5,9:r,11:n,12:6,13:8,14:9,15:10,17:12,25:13,26:14,28:s,29:i,37:a},{9:[1,17]},{6:[1,18],7:19,9:r},{5:20,11:n,12:6,13:8,14:9,15:10,17:12,25:13,26:14,28:s,29:i,37:a},e(o,[2,5]),e(l,[2,7],{7:21,9:r}),{11:[1,22]},{11:[1,23]},{11:[2,12],16:24,30:25,32:[1,26],33:[1,27],34:[1,28],35:[1,29]},{9:[1,30]},e(h,[2,16],{18:[1,31],21:[1,32],23:[1,33]}),e(c,[2,17],{25:13,26:14,17:34,28:s,29:i}),e([9,11,18,20,21,22,23,24,28,29,32,33,34,35,36],[2,19],{27:[1,35]}),e(y,[2,21]),e(y,[2,22]),{10:[1,36]},{1:[2,1]},{11:n,12:37,13:8,14:9,15:10,17:12,25:13,26:14,28:s,29:i,37:a},{6:[1,38],7:19,9:r},e(l,[2,6]),e(o,[2,8]),e(o,[2,9]),{15:39,17:12,25:13,26:14,28:s,29:i},e(u,[2,24],{31:40,36:[1,41]}),e(d,[2,25]),e(d,[2,26]),e(d,[2,27]),e(d,[2,28]),{17:42,25:13,26:14,28:s,29:i,39:[1,43]},{17:45,19:44,25:13,26:14,28:s,29:i},{17:45,19:46,25:13,26:14,28:s,29:i},{17:45,19:47,25:13,26:14,28:s,29:i},e(c,[2,18]),{26:48,28:s,29:i},{11:[1,49]},e(o,[2,4]),{1:[2,2]},{11:[2,11]},e(u,[2,23]),{17:45,19:50,25:13,26:14,28:s,29:i},{9:[1,51]},{9:[1,52]},{20:[1,53]},e(p,[2,33],{9:[1,54],27:[1,55]}),{22:[1,56]},{24:[1,57]},e(y,[2,20]),e([9,11,28,29,37],[2,3]),{36:[1,58]},{9:f,27:m,28:g,29:_,38:59,39:k,40:60,42:61,43:x,44:b},{9:f,27:m,28:g,29:_,38:69,39:k,40:60,42:61,43:x,44:b},e(h,[2,13]),e(p,[2,32],{25:13,26:14,17:45,19:70,28:s,29:i}),{17:45,19:71,25:13,26:14,28:s,29:i},e(h,[2,14]),e(h,[2,15]),e(u,[2,29]),{11:[2,34],41:v},e(S,[2,36],{42:73,9:f,27:m,28:g,29:_,39:k,43:x,44:b}),e(E,[2,38]),e(E,[2,40]),e(E,[2,41]),e(E,[2,42]),e(E,[2,43]),e(E,[2,44]),e(E,[2,45]),e(E,[2,46]),{11:[2,35],41:v},e(p,[2,30]),e(p,[2,31]),{9:f,27:m,28:g,29:_,39:k,40:74,42:61,43:x,44:b},e(E,[2,39]),e(S,[2,37],{42:73,9:f,27:m,28:g,29:_,39:k,43:x,44:b})],defaultActions:{18:[2,1],38:[2,2],39:[2,11]},parseError:function(t,e){if(!e.recoverable)throw new Error(t);this.trace(t)},parse:function(t){function e(){var t;return t=p.lex()||u,"number"!=typeof t&&(t=r.symbols_[t]||t),t}var r=this,n=[0],s=[null],i=[],a=this.table,o="",l=0,h=0,c=0,y=2,u=1,d=i.slice.call(arguments,1),p=Object.create(this.lexer),f={yy:{}};for(var m in this.yy)Object.prototype.hasOwnProperty.call(this.yy,m)&&(f.yy[m]=this.yy[m]);p.setInput(t,f.yy),f.yy.lexer=p,f.yy.parser=this,"undefined"==typeof p.yylloc&&(p.yylloc={});var g=p.yylloc;i.push(g);var _=p.options&&p.options.ranges;this.parseError="function"==typeof f.yy.parseError?f.yy.parseError:Object.getPrototypeOf(this).parseError;for(var k,x,b,v,S,E,w,I,A,O={};;){if(b=n[n.length-1],this.defaultActions[b]?v=this.defaultActions[b]:((null===k||"undefined"==typeof k)&&(k=e()),v=a[b]&&a[b][k]),"undefined"==typeof v||!v.length||!v[0]){var $="";A=[];for(E in a[b])this.terminals_[E]&&E>y&&A.push("'"+this.terminals_[E]+"'");$=p.showPosition?"Parse error on line "+(l+1)+":\n"+p.showPosition()+"\nExpecting "+A.join(", ")+", got '"+(this.terminals_[k]||k)+"'":"Parse error on line "+(l+1)+": Unexpected "+(k==u?"end of input":"'"+(this.terminals_[k]||k)+"'"),this.parseError($,{text:p.match,token:this.terminals_[k]||k,line:p.yylineno,loc:g,expected:A})}if(v[0]instanceof Array&&v.length>1)throw new Error("Parse Error: multiple actions possible at state: "+b+", token: "+k);switch(v[0]){case 1:n.push(k),s.push(p.yytext),i.push(p.yylloc),n.push(v[1]),k=null,x?(k=x,x=null):(h=p.yyleng,o=p.yytext,l=p.yylineno,g=p.yylloc,c>0&&c--);break;case 2:if(w=this.productions_[v[1]][1],O.$=s[s.length-w],O._$={first_line:i[i.length-(w||1)].first_line,last_line:i[i.length-1].last_line,first_column:i[i.length-(w||1)].first_column,last_column:i[i.length-1].last_column},_&&(O._$.range=[i[i.length-(w||1)].range[0],i[i.length-1].range[1]]),S=this.performAction.apply(O,[o,h,l,f.yy,v[1],s,i].concat(d)),"undefined"!=typeof S)return S;w&&(n=n.slice(0,-1*w*2),s=s.slice(0,-1*w),i=i.slice(0,-1*w)),n.push(this.productions_[v[1]][0]),s.push(O.$),i.push(O._$),I=a[n[n.length-2]][n[n.length-1]],n.push(I);break;case 3:return!0}}return!0}},I=function(){var t={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t;var e=t.match(/(?:\r\n?|\n).*/g);return e?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,r=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var s=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[s[0],s[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var r,n,s;if(this.options.backtrack_lexer&&(s={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(s.yylloc.range=this.yylloc.range.slice(0))),n=t[0].match(/(?:\r\n?|\n).*/g),n&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],r=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var i in s)this[i]=s[i];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var t,e,r,n;this._more||(this.yytext="",this.match="");for(var s=this._currentRules(),i=0;ie[0].length)){if(e=r,n=i,this.options.backtrack_lexer){if(t=this.test_match(r,s[i]),t!==!1)return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?(t=this.test_match(e,s[n]),t!==!1?t:!1):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t?t:this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){var t=this.conditionStack.length-1;return t>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return t=this.conditionStack.length-1-Math.abs(t||0),t>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(t,e,r,n){switch(r){case 0:return 37;case 1:return 8;case 2:return 10;case 3:return 10;case 4:return 39;case 5:return 29;case 6:return"BRKT";case 7:return 44;case 8:return 44;case 9:return 44;case 10:return 43;case 11:return 11;case 12:return 41;case 13:return 34;case 14:return 32;case 15:return 33;case 16:return 35;case 17:return 27;case 18:return 28;case 19:return 36;case 20:return 21;case 21:return 22;case 22:return 18;case 23:return 20;case 24:return 23;case 25:return 24;case 26:return 9;case 27:return"NEWLINE";case 28:return 6}},rules:[/^(?:style\b)/,/^(?:graph\b)/,/^(?:LR\b)/,/^(?:TD\b)/,/^(?:#[a-f0-9]+)/,/^(?:[0-9]+)/,/^(?:#)/,/^(?:px\b)/,/^(?:pt\b)/,/^(?:dot\b)/,/^(?::)/,/^(?:;)/,/^(?:,)/,/^(?:--[x])/,/^(?:-->)/,/^(?:--[o])/,/^(?:---)/,/^(?:-)/,/^(?:[a-zåäöæøA-ZÅÄÖÆØ]+)/,/^(?:\|)/,/^(?:\()/,/^(?:\))/,/^(?:\[)/,/^(?:\])/,/^(?:\{)/,/^(?:\})/,/^(?:\s)/,/^(?:\n)/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28],inclusive:!0}}};return t}();return w.lexer=I,t.prototype=w,w.Parser=t,new t}();"undefined"!=typeof require&&"undefined"!=typeof exports&&(exports.parser=parser,exports.Parser=parser.Parser,exports.parse=function(){return parser.parse.apply(parser,arguments)},exports.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),process.exit(1));var e=require("fs").readFileSync(require("path").normalize(t[1]),"utf8");return exports.parser.parse(e)},"undefined"!=typeof module&&require.main===module&&exports.main(process.argv.slice(1)));var mermaid;"undefined"==typeof mermaid&&(mermaid={}),mermaid.vertices={},mermaid.edges=[],mermaid.graph={addVertex:function(t,e,r,n){console.log("Got node "+t+" "+r+" "+e+" styles: "+JSON.stringify(n)),"undefined"==typeof mermaid.vertices[t]&&(mermaid.vertices[t]={id:t,styles:[]}),"undefined"!=typeof e&&(mermaid.vertices[t].text=e),"undefined"!=typeof r&&(mermaid.vertices[t].type=r),"undefined"!=typeof n&&null!==n&&(console.log("Adding style: "+n),n.forEach(function(e){mermaid.vertices[t].styles.push(e)}))},getVertices:function(){return mermaid.vertices},addLink:function(t,e,r,n){var s={start:t,end:e,type:void 0,text:""},n=r.text;"undefined"!=typeof n&&(s.text=n),"undefined"!=typeof r&&(s.type=r.type),mermaid.edges.push(s)},updateLink:function(t,e){var r=t.substr(1);console.log("Got link style for "+r+" style "+e),mermaid.edges[r].style=e},setDirection:function(t){mermaid.direction=t},getEdges:function(){return mermaid.edges},clear:function(){mermaid.vertices={},mermaid.edges=[]},defaultStyle:function(){return"fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;fill:#ffa;stroke: #666;"}};var mermaid;"undefined"==typeof mermaid&&(mermaid={}),mermaid.addVertices=function(t,e){var r=Object.keys(t);r.forEach(function(r){var n,s=t[r];console.log(s.styles.length);var i,a="";for(i=0;i',this.drawChart(s,r)}},mermaid.init(); \ No newline at end of file +var parser=function(){function t(){this.yy={}}var e=function(t,e,r,n){for(r=r||{},n=t.length;n--;r[t[n]]=e);return r},r=[1,7],n=[2,10],i=[1,15],s=[1,16],a=[1,11],o=[6,9],h=[11,28,29,37],l=[11,32,33,34,35],c=[9,11,18,20,21,22,23,24,32,33,34,35,36],u=[9,11,18,20,21,22,23,24,28,29,32,33,34,35,36],y=[9,11,18,20,21,22,23,24,27,28,29,32,33,34,35,36],d=[28,29],p=[28,29,36],f=[20,22,24,36],m=[1,66],g=[1,63],_=[1,61],k=[1,64],x=[1,67],b=[1,62],v=[1,65],S=[1,70],E=[11,41],w=[9,11,27,28,29,39,41,43,44],I={trace:function(){},yy:{},symbols_:{error:2,expressions:3,graphConfig:4,statements:5,EOF:6,spaceList:7,GRAPH:8,SPACE:9,DIR:10,SEMI:11,statement:12,verticeStatement:13,styleStatement:14,vertex:15,link:16,alphaNum:17,SQS:18,text:19,SQE:20,PS:21,PE:22,DIAMOND_START:23,DIAMOND_STOP:24,alphaNumStatement:25,alphaNumToken:26,MINUS:27,ALPHA:28,NUM:29,linkStatement:30,arrowText:31,ARROW_POINT:32,ARROW_CIRCLE:33,ARROW_CROSS:34,ARROW_OPEN:35,PIPE:36,STYLE:37,stylesOpt:38,HEX:39,style:40,COMMA:41,styleComponent:42,COLON:43,UNIT:44,$accept:0,$end:1},terminals_:{2:"error",6:"EOF",8:"GRAPH",9:"SPACE",10:"DIR",11:"SEMI",18:"SQS",20:"SQE",21:"PS",22:"PE",23:"DIAMOND_START",24:"DIAMOND_STOP",27:"MINUS",28:"ALPHA",29:"NUM",32:"ARROW_POINT",33:"ARROW_CIRCLE",34:"ARROW_CROSS",35:"ARROW_OPEN",36:"PIPE",37:"STYLE",39:"HEX",41:"COMMA",43:"COLON",44:"UNIT"},productions_:[0,[3,3],[3,4],[4,4],[5,3],[5,1],[7,2],[7,1],[12,2],[12,2],[13,0],[13,3],[13,1],[15,4],[15,4],[15,4],[15,1],[17,1],[17,2],[25,1],[25,3],[26,1],[26,1],[16,2],[16,1],[30,1],[30,1],[30,1],[30,1],[31,3],[19,3],[19,2],[19,1],[14,5],[14,5],[38,1],[38,3],[40,1],[40,2],[42,1],[42,1],[42,1],[42,1],[42,1],[42,1],[42,1]],performAction:function(t,e,r,n,i,s){var a=s.length-1;switch(i){case 2:this.$=s[a-3];break;case 3:console.log("In graph config"),n.setDirection(s[a-1]),this.$=s[a-1];break;case 11:console.log("In vertexStatement"),n.addLink(s[a-2],s[a],s[a-1]),this.$="oy";break;case 12:console.log("In vertexStatement ... "),this.$="yo";break;case 13:this.$=s[a-3],n.addVertex(s[a-3],s[a-1],"square");break;case 14:this.$=s[a-3],n.addVertex(s[a-3],s[a-1],"round");break;case 15:this.$=s[a-3],n.addVertex(s[a-3],s[a-1],"diamond");break;case 16:console.log("In vertex:"+s[a]),this.$=s[a],n.addVertex(s[a]);break;case 17:case 21:case 22:case 37:this.$=s[a];break;case 18:this.$=s[a-1]+""+s[a];break;case 19:console.log("Found token (statement): "+s[a]),this.$=s[a];break;case 20:this.$=s[a-2]+"-"+s[a];break;case 23:s[a-1].text=s[a],this.$=s[a-1];break;case 24:case 32:this.$=s[a];break;case 25:this.$={type:"arrow"};break;case 26:this.$={type:"arrow_circle"};break;case 27:this.$={type:"arrow_cross"};break;case 28:this.$={type:"arrow_open"};break;case 29:console.log("Nice link text here: "+s[a-1]),this.$=s[a-1];break;case 30:this.$=s[a-2]+" "+s[a];break;case 31:this.$=s[a-1];break;case 33:this.$=s[a-4],n.addVertex(s[a-2],void 0,void 0,s[a]);break;case 34:console.log("In parser - style: "+s[a]),this.$=s[a-4],n.updateLink(s[a-2],s[a]);break;case 35:this.$=[s[a]];break;case 36:s[a-2].push(s[a]),this.$=s[a-2];break;case 38:this.$=s[a-1]+s[a];break;case 39:case 40:case 41:case 42:case 43:case 44:case 45:this.$=s[a]}},table:[{3:1,4:2,8:[1,3]},{1:[3]},{5:4,7:5,9:r,11:n,12:6,13:8,14:9,15:10,17:12,25:13,26:14,28:i,29:s,37:a},{9:[1,17]},{6:[1,18],7:19,9:r},{5:20,11:n,12:6,13:8,14:9,15:10,17:12,25:13,26:14,28:i,29:s,37:a},e(o,[2,5]),e(h,[2,7],{7:21,9:r}),{11:[1,22]},{11:[1,23]},{11:[2,12],16:24,30:25,32:[1,26],33:[1,27],34:[1,28],35:[1,29]},{9:[1,30]},e(l,[2,16],{18:[1,31],21:[1,32],23:[1,33]}),e(c,[2,17],{25:13,26:14,17:34,28:i,29:s}),e(u,[2,19],{27:[1,35]}),e(y,[2,21]),e(y,[2,22]),{10:[1,36]},{1:[2,1]},{11:n,12:37,13:8,14:9,15:10,17:12,25:13,26:14,28:i,29:s,37:a},{6:[1,38],7:19,9:r},e(h,[2,6]),e(o,[2,8]),e(o,[2,9]),{15:39,17:12,25:13,26:14,28:i,29:s},e(d,[2,24],{31:40,36:[1,41]}),e(p,[2,25]),e(p,[2,26]),e(p,[2,27]),e(p,[2,28]),{17:42,25:13,26:14,28:i,29:s,39:[1,43]},{17:45,19:44,25:13,26:14,28:i,29:s},{17:45,19:46,25:13,26:14,28:i,29:s},{17:45,19:47,25:13,26:14,28:i,29:s},e(c,[2,18]),{26:48,28:i,29:s},{11:[1,49]},e(o,[2,4]),{1:[2,2]},{11:[2,11]},e(d,[2,23]),{17:45,19:50,25:13,26:14,28:i,29:s},{9:[1,51]},{9:[1,52]},{20:[1,53]},e(f,[2,32],{9:[1,54]}),{22:[1,55]},{24:[1,56]},e(u,[2,20]),e([9,11,28,29,37],[2,3]),{36:[1,57]},{9:m,27:g,28:_,29:k,38:58,39:x,40:59,42:60,43:b,44:v},{9:m,27:g,28:_,29:k,38:68,39:x,40:59,42:60,43:b,44:v},e(l,[2,13]),e(f,[2,31],{25:13,26:14,17:45,19:69,28:i,29:s}),e(l,[2,14]),e(l,[2,15]),e(d,[2,29]),{11:[2,33],41:S},e(E,[2,35],{42:71,9:m,27:g,28:_,29:k,39:x,43:b,44:v}),e(w,[2,37]),e(w,[2,39]),e(w,[2,40]),e(w,[2,41]),e(w,[2,42]),e(w,[2,43]),e(w,[2,44]),e(w,[2,45]),{11:[2,34],41:S},e(f,[2,30]),{9:m,27:g,28:_,29:k,39:x,40:72,42:60,43:b,44:v},e(w,[2,38]),e(E,[2,36],{42:71,9:m,27:g,28:_,29:k,39:x,43:b,44:v})],defaultActions:{18:[2,1],38:[2,2],39:[2,11]},parseError:function(t,e){if(!e.recoverable)throw new Error(t);this.trace(t)},parse:function(t){function e(){var t;return t=p.lex()||y,"number"!=typeof t&&(t=r.symbols_[t]||t),t}var r=this,n=[0],i=[null],s=[],a=this.table,o="",h=0,l=0,c=0,u=2,y=1,d=s.slice.call(arguments,1),p=Object.create(this.lexer),f={yy:{}};for(var m in this.yy)Object.prototype.hasOwnProperty.call(this.yy,m)&&(f.yy[m]=this.yy[m]);p.setInput(t,f.yy),f.yy.lexer=p,f.yy.parser=this,"undefined"==typeof p.yylloc&&(p.yylloc={});var g=p.yylloc;s.push(g);var _=p.options&&p.options.ranges;this.parseError="function"==typeof f.yy.parseError?f.yy.parseError:Object.getPrototypeOf(this).parseError;for(var k,x,b,v,S,E,w,I,O,A={};;){if(b=n[n.length-1],this.defaultActions[b]?v=this.defaultActions[b]:((null===k||"undefined"==typeof k)&&(k=e()),v=a[b]&&a[b][k]),"undefined"==typeof v||!v.length||!v[0]){var $="";O=[];for(E in a[b])this.terminals_[E]&&E>u&&O.push("'"+this.terminals_[E]+"'");$=p.showPosition?"Parse error on line "+(h+1)+":\n"+p.showPosition()+"\nExpecting "+O.join(", ")+", got '"+(this.terminals_[k]||k)+"'":"Parse error on line "+(h+1)+": Unexpected "+(k==y?"end of input":"'"+(this.terminals_[k]||k)+"'"),this.parseError($,{text:p.match,token:this.terminals_[k]||k,line:p.yylineno,loc:g,expected:O})}if(v[0]instanceof Array&&v.length>1)throw new Error("Parse Error: multiple actions possible at state: "+b+", token: "+k);switch(v[0]){case 1:n.push(k),i.push(p.yytext),s.push(p.yylloc),n.push(v[1]),k=null,x?(k=x,x=null):(l=p.yyleng,o=p.yytext,h=p.yylineno,g=p.yylloc,c>0&&c--);break;case 2:if(w=this.productions_[v[1]][1],A.$=i[i.length-w],A._$={first_line:s[s.length-(w||1)].first_line,last_line:s[s.length-1].last_line,first_column:s[s.length-(w||1)].first_column,last_column:s[s.length-1].last_column},_&&(A._$.range=[s[s.length-(w||1)].range[0],s[s.length-1].range[1]]),S=this.performAction.apply(A,[o,l,h,f.yy,v[1],i,s].concat(d)),"undefined"!=typeof S)return S;w&&(n=n.slice(0,-1*w*2),i=i.slice(0,-1*w),s=s.slice(0,-1*w)),n.push(this.productions_[v[1]][0]),i.push(A.$),s.push(A._$),I=a[n[n.length-2]][n[n.length-1]],n.push(I);break;case 3:return!0}}return!0}},O=function(){var t={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t;var e=t.match(/(?:\r\n?|\n).*/g);return e?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,r=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var n=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var i=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===n.length?this.yylloc.first_column:0)+n[n.length-r.length].length-r[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[i[0],i[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var r,n,i;if(this.options.backtrack_lexer&&(i={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(i.yylloc.range=this.yylloc.range.slice(0))),n=t[0].match(/(?:\r\n?|\n).*/g),n&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],r=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),r)return r;if(this._backtrack){for(var s in i)this[s]=i[s];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var t,e,r,n;this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),s=0;se[0].length)){if(e=r,n=s,this.options.backtrack_lexer){if(t=this.test_match(r,i[s]),t!==!1)return t;if(this._backtrack){e=!1;continue}return!1}if(!this.options.flex)break}return e?(t=this.test_match(e,i[n]),t!==!1?t:!1):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t?t:this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){var t=this.conditionStack.length-1;return t>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return t=this.conditionStack.length-1-Math.abs(t||0),t>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t)},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(t,e,r,n){switch(r){case 0:return 37;case 1:return 8;case 2:return 10;case 3:return 10;case 4:return 39;case 5:return 29;case 6:return"BRKT";case 7:return 44;case 8:return 44;case 9:return 44;case 10:return 43;case 11:return 11;case 12:return 41;case 13:return 34;case 14:return 32;case 15:return 33;case 16:return 35;case 17:return 27;case 18:return 28;case 19:return 36;case 20:return 21;case 21:return 22;case 22:return 18;case 23:return 20;case 24:return 23;case 25:return 24;case 26:return 9;case 27:return"NEWLINE";case 28:return 6}},rules:[/^(?:style\b)/,/^(?:graph\b)/,/^(?:LR\b)/,/^(?:TD\b)/,/^(?:#[a-f0-9]+)/,/^(?:[0-9]+)/,/^(?:#)/,/^(?:px\b)/,/^(?:pt\b)/,/^(?:dot\b)/,/^(?::)/,/^(?:;)/,/^(?:,)/,/^(?:--[x])/,/^(?:-->)/,/^(?:--[o])/,/^(?:---)/,/^(?:-)/,/^(?:[a-zåäöæøA-ZÅÄÖÆØ]+)/,/^(?:\|)/,/^(?:\()/,/^(?:\))/,/^(?:\[)/,/^(?:\])/,/^(?:\{)/,/^(?:\})/,/^(?:\s)/,/^(?:\n)/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28],inclusive:!0}}};return t}();return I.lexer=O,t.prototype=I,I.Parser=t,new t}();"undefined"!=typeof require&&"undefined"!=typeof exports&&(exports.parser=parser,exports.Parser=parser.Parser,exports.parse=function(){return parser.parse.apply(parser,arguments)},exports.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),process.exit(1));var e=require("fs").readFileSync(require("path").normalize(t[1]),"utf8");return exports.parser.parse(e)},"undefined"!=typeof module&&require.main===module&&exports.main(process.argv.slice(1)));var mermaid;"undefined"==typeof mermaid&&(mermaid={}),mermaid.vertices={},mermaid.edges=[],mermaid.graph={addVertex:function(t,e,r,n){console.log("Got node "+t+" "+r+" "+e+" styles: "+JSON.stringify(n)),"undefined"==typeof mermaid.vertices[t]&&(mermaid.vertices[t]={id:t,styles:[]}),"undefined"!=typeof e&&(mermaid.vertices[t].text=e),"undefined"!=typeof r&&(mermaid.vertices[t].type=r),"undefined"!=typeof n&&null!==n&&n.forEach(function(e){mermaid.vertices[t].styles.push(e)})},addLink:function(t,e,r,n){var i={start:t,end:e,type:void 0,text:""},n=r.text;"undefined"!=typeof n&&(i.text=n),"undefined"!=typeof r&&(i.type=r.type),mermaid.edges.push(i)},updateLink:function(t,e){var r=t.substr(1);mermaid.edges[r].style=e},setDirection:function(t){mermaid.direction=t},getVertices:function(){return mermaid.vertices},getEdges:function(){return mermaid.edges},clear:function(){mermaid.vertices={},mermaid.edges=[]},defaultStyle:function(){return"fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;fill:#ffa;stroke: #666;"}};var mermaid;"undefined"==typeof mermaid&&(mermaid={}),mermaid.addVertices=function(t,e){var r=Object.keys(t);r.forEach(function(r){var n,i,s=t[r],a="";for(i=0;i',this.drawChart(s,r)}},document.addEventListener("DOMContentLoaded",function(){mermaid.init()},!1); \ No newline at end of file diff --git a/src/backup/flow.js b/node_modules/jison/node_modules/ebnf-parser/transform-parser.js similarity index 82% rename from src/backup/flow.js rename to node_modules/jison/node_modules/ebnf-parser/transform-parser.js index 05d756170..4ef719575 100644 --- a/src/backup/flow.js +++ b/node_modules/jison/node_modules/ebnf-parser/transform-parser.js @@ -1,4 +1,4 @@ -/* parser generated by jison 0.4.15 */ +/* parser generated by jison 0.4.11 */ /* Returns a Parser object of the following structure: @@ -71,37 +71,39 @@ recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error) } */ -var parser = (function(){ -var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,4],$V1=[5,8]; +var ebnf = (function(){ var parser = {trace: function trace() { }, yy: {}, -symbols_: {"error":2,"expressions":3,"id":4,"EOF":5,"flow":6,"STYLE":7,"MINUS":8,"word":9,"ALPHA":10,"$accept":0,"$end":1}, -terminals_: {2:"error",5:"EOF",7:"STYLE",8:"MINUS",10:"ALPHA"}, -productions_: [0,[3,2],[6,1],[6,1],[4,3],[4,1],[9,1]], +symbols_: {"error":2,"production":3,"handle":4,"EOF":5,"handle_list":6,"|":7,"expression_suffix":8,"expression":9,"suffix":10,"ALIAS":11,"symbol":12,"(":13,")":14,"*":15,"?":16,"+":17,"$accept":0,"$end":1}, +terminals_: {2:"error",5:"EOF",7:"|",11:"ALIAS",12:"symbol",13:"(",14:")",15:"*",16:"?",17:"+"}, +productions_: [0,[3,2],[6,1],[6,3],[4,0],[4,2],[8,3],[8,2],[9,1],[9,3],[10,0],[10,1],[10,1],[10,1]], performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { /* this == yyval */ var $0 = $$.length - 1; switch (yystate) { -case 1: -return $$[$0-1]; +case 1: return $$[$0-1]; break; -case 2: -this.$='key'; +case 2: this.$ = [$$[$0]]; break; -case 3: -this.$=$$[$0]; +case 3: $$[$0-2].push($$[$0]); break; -case 4: -this.$=$$[$0-2]+'-'+$$[$0] +case 4: this.$ = []; break; -case 5: case 6: -this.$=$$[$0] +case 5: $$[$0-1].push($$[$0]); +break; +case 6: this.$ = ['xalias', $$[$0-1], $$[$0-2], $$[$0]]; +break; +case 7: if ($$[$0]) this.$ = [$$[$0], $$[$0-1]]; else this.$ = $$[$0-1]; +break; +case 8: this.$ = ['symbol', $$[$0]]; +break; +case 9: this.$ = ['()', $$[$0-1]]; break; } }, -table: [{3:1,4:2,9:3,10:$V0},{1:[3]},{5:[1,5],8:[1,6]},o($V1,[2,5]),o($V1,[2,6]),{1:[2,1]},{9:7,10:$V0},o($V1,[2,4])], -defaultActions: {5:[2,1]}, +table: [{3:1,4:2,5:[2,4],12:[2,4],13:[2,4]},{1:[3]},{5:[1,3],8:4,9:5,12:[1,6],13:[1,7]},{1:[2,1]},{5:[2,5],7:[2,5],12:[2,5],13:[2,5],14:[2,5]},{5:[2,10],7:[2,10],10:8,11:[2,10],12:[2,10],13:[2,10],14:[2,10],15:[1,9],16:[1,10],17:[1,11]},{5:[2,8],7:[2,8],11:[2,8],12:[2,8],13:[2,8],14:[2,8],15:[2,8],16:[2,8],17:[2,8]},{4:13,6:12,7:[2,4],12:[2,4],13:[2,4],14:[2,4]},{5:[2,7],7:[2,7],11:[1,14],12:[2,7],13:[2,7],14:[2,7]},{5:[2,11],7:[2,11],11:[2,11],12:[2,11],13:[2,11],14:[2,11]},{5:[2,12],7:[2,12],11:[2,12],12:[2,12],13:[2,12],14:[2,12]},{5:[2,13],7:[2,13],11:[2,13],12:[2,13],13:[2,13],14:[2,13]},{7:[1,16],14:[1,15]},{7:[2,2],8:4,9:5,12:[1,6],13:[1,7],14:[2,2]},{5:[2,6],7:[2,6],12:[2,6],13:[2,6],14:[2,6]},{5:[2,9],7:[2,9],11:[2,9],12:[2,9],13:[2,9],14:[2,9],15:[2,9],16:[2,9],17:[2,9]},{4:17,7:[2,4],12:[2,4],13:[2,4],14:[2,4]},{7:[2,3],8:4,9:5,12:[1,6],13:[1,7],14:[2,3]}], +defaultActions: {3:[2,1]}, parseError: function parseError(str, hash) { if (hash.recoverable) { this.trace(str); @@ -110,26 +112,20 @@ parseError: function parseError(str, hash) { } }, parse: function parse(input) { - var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; + var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; var args = lstack.slice.call(arguments, 1); - var lexer = Object.create(this.lexer); - var sharedState = { yy: {} }; - for (var k in this.yy) { - if (Object.prototype.hasOwnProperty.call(this.yy, k)) { - sharedState.yy[k] = this.yy[k]; - } + this.lexer.setInput(input); + this.lexer.yy = this.yy; + this.yy.lexer = this.lexer; + this.yy.parser = this; + if (typeof this.lexer.yylloc == 'undefined') { + this.lexer.yylloc = {}; } - lexer.setInput(input, sharedState.yy); - sharedState.yy.lexer = lexer; - sharedState.yy.parser = this; - if (typeof lexer.yylloc == 'undefined') { - lexer.yylloc = {}; - } - var yyloc = lexer.yylloc; + var yyloc = this.lexer.yylloc; lstack.push(yyloc); - var ranges = lexer.options && lexer.options.ranges; - if (typeof sharedState.yy.parseError === 'function') { - this.parseError = sharedState.yy.parseError; + var ranges = this.lexer.options && this.lexer.options.ranges; + if (typeof this.yy.parseError === 'function') { + this.parseError = this.yy.parseError; } else { this.parseError = Object.getPrototypeOf(this).parseError; } @@ -138,15 +134,14 @@ parse: function parse(input) { vstack.length = vstack.length - n; lstack.length = lstack.length - n; } - _token_stack: - function lex() { - var token; - token = lexer.lex() || EOF; - if (typeof token !== 'number') { - token = self.symbols_[token] || token; - } - return token; + function lex() { + var token; + token = self.lexer.lex() || EOF; + if (typeof token !== 'number') { + token = self.symbols_[token] || token; } + return token; + } var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; while (true) { state = stack[stack.length - 1]; @@ -166,15 +161,15 @@ parse: function parse(input) { expected.push('\'' + this.terminals_[p] + '\''); } } - if (lexer.showPosition) { - errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; + if (this.lexer.showPosition) { + errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + this.lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; } else { errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); } - console.log(errStr, { - text: lexer.match, + this.parseError(errStr, { + text: this.lexer.match, token: this.terminals_[symbol] || symbol, - line: lexer.yylineno, + line: this.lexer.yylineno, loc: yyloc, expected: expected }); @@ -185,15 +180,15 @@ parse: function parse(input) { switch (action[0]) { case 1: stack.push(symbol); - vstack.push(lexer.yytext); - lstack.push(lexer.yylloc); + vstack.push(this.lexer.yytext); + lstack.push(this.lexer.yylloc); stack.push(action[1]); symbol = null; if (!preErrorSymbol) { - yyleng = lexer.yyleng; - yytext = lexer.yytext; - yylineno = lexer.yylineno; - yyloc = lexer.yylloc; + yyleng = this.lexer.yyleng; + yytext = this.lexer.yytext; + yylineno = this.lexer.yylineno; + yyloc = this.lexer.yylloc; if (recovering > 0) { recovering--; } @@ -221,7 +216,7 @@ parse: function parse(input) { yytext, yyleng, yylineno, - sharedState.yy, + this.yy, action[1], vstack, lstack @@ -246,13 +241,9 @@ parse: function parse(input) { } return true; }}; - -define('parser/flow',function(){ - console.log('bcs123'); - return parser; -});/* generated by jison-lex 0.3.4 */ +/* generated by jison-lex 0.2.1 */ var lexer = (function(){ -var lexer = ({ +var lexer = { EOF:1, @@ -265,8 +256,7 @@ parseError:function parseError(str, hash) { }, // resets the lexer, sets new input -setInput:function (input, yy) { - this.yy = yy || this.yy || {}; +setInput:function (input) { this._input = input; this._more = this._backtrack = this.done = false; this.yylineno = this.yyleng = 0; @@ -314,7 +304,7 @@ unput:function (ch) { var lines = ch.split(/(?:\r\n?|\n)/g); this._input = ch + this._input; - this.yytext = this.yytext.substr(0, this.yytext.length - len); + this.yytext = this.yytext.substr(0, this.yytext.length - len - 1); //this.yyleng -= len; this.offset -= len; var oldLines = this.match.split(/(?:\r\n?|\n)/g); @@ -576,61 +566,40 @@ stateStackSize:function stateStackSize() { }, options: {}, performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { + var YYSTATE=YY_START; switch($avoiding_name_collisions) { -case 0:return 7; +case 0:/* skip whitespace */ break; -case 1:return 10; +case 1:return 12; break; -case 2:return 'HEX'; +case 2:yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 11; break; -case 3:return 'NUM'; +case 3:return 12; break; -case 4:return 'UNIT'; +case 4:return 12; break; -case 5:return 'UNIT'; +case 5:return 'bar'; break; -case 6:return 'UNIT'; +case 6:return 13; break; -case 7:return 'COLON'; +case 7:return 14; break; -case 8:return 8; +case 8:return 15; break; -case 9:return ';'; +case 9:return 16; break; -case 10:return 'COMMA'; +case 10:return 7; break; -case 11:return 'ARROW_CROSS'; +case 11:return 17; break; -case 12:return 'ARROW_POINT'; -break; -case 13:return 'ARROW_CIRCLE'; -break; -case 14:return 'PIPE'; -break; -case 15:return 'PS'; -break; -case 16:return 'PE'; -break; -case 17:return 'SQS'; -break; -case 18:return 'SQE'; -break; -case 19:return 'DIAMOND_START' -break; -case 20:return 'DIAMOND_STOP' -break; -case 21:return 'SPACE'; -break; -case 22:return 'NEWLINE'; -break; -case 23:return 5; +case 12:return 5; break; } }, -rules: [/^(?:style\b)/,/^(?:[a-zåäöæøA-ZÅÄÖÆØ]+)/,/^(?:#[a-f0-9]+)/,/^(?:[0-9]+)/,/^(?:px\b)/,/^(?:pt\b)/,/^(?:dot\b)/,/^(?::)/,/^(?:-)/,/^(?:;)/,/^(?:,)/,/^(?:[x])/,/^(?:>)/,/^(?:[o])/,/^(?:\|)/,/^(?:\()/,/^(?:\))/,/^(?:\[)/,/^(?:\])/,/^(?:\{)/,/^(?:\})/,/^(?:\s)/,/^(?:\n)/,/^(?:$)/], -conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23],"inclusive":true}} -}); +rules: [/^(?:\s+)/,/^(?:([a-zA-Z][a-zA-Z0-9_-]*))/,/^(?:\[([a-zA-Z][a-zA-Z0-9_-]*)\])/,/^(?:'[^']*')/,/^(?:\.)/,/^(?:bar\b)/,/^(?:\()/,/^(?:\))/,/^(?:\*)/,/^(?:\?)/,/^(?:\|)/,/^(?:\+)/,/^(?:$)/], +conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12],"inclusive":true}} +}; return lexer; })(); parser.lexer = lexer; @@ -643,9 +612,9 @@ return new Parser; if (typeof require !== 'undefined' && typeof exports !== 'undefined') { -exports.parser = parser; -exports.Parser = parser.Parser; -exports.parse = function () { return parser.parse.apply(parser, arguments); }; +exports.parser = ebnf; +exports.Parser = ebnf.Parser; +exports.parse = function () { return ebnf.parse.apply(ebnf, arguments); }; exports.main = function commonjsMain(args) { if (!args[1]) { console.log('Usage: '+args[0]+' FILE'); @@ -657,4 +626,4 @@ exports.main = function commonjsMain(args) { if (typeof module !== 'undefined' && require.main === module) { exports.main(process.argv.slice(1)); } -} +} \ No newline at end of file diff --git a/src/backup/dagreTest.jsp b/src/backup/dagreTest.jsp deleted file mode 100644 index 1c7d616a5..000000000 --- a/src/backup/dagreTest.jsp +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Created by knut on 14-11-08. - */ - -var dagre = require("dagre"); - -// Create a new directed graph -var g = new dagre.graphlib.Graph(); - -// Set an object for the graph label -g.setGraph({}); - -// Default to assigning a new object as a label for each new edge. -g.setDefaultEdgeLabel(function() { return {}; }); - -// Add nodes to the graph. The first argument is the node id. The second is -// metadata about the node. In this case we're going to add labels to each of -// our nodes. -g.setNode("kspacey", { label: "Kevin Spacey", width: 144, height: 100 }); -g.setNode("swilliams", { label: "Saul Williams", width: 160, height: 100 }); -g.setNode("bpitt", { label: "Brad Pitt", width: 108, height: 100 }); -g.setNode("hford", { label: "Harrison Ford", width: 168, height: 100 }); -g.setNode("lwilson", { label: "Luke Wilson", width: 144, height: 100 }); -g.setNode("kbacon", { label: "Kevin Bacon", width: 121, height: 100 }); - -// Add edges to the graph. -g.setEdge("kspacey", "swilliams"); -g.setEdge("swilliams", "kbacon"); -g.setEdge("bpitt", "kbacon"); -g.setEdge("hford", "lwilson"); -g.setEdge("lwilson", "kbacon"); - -dagre.layout(g); - -g.nodes().forEach(function(v) { - console.log("Node " + v + ": " + JSON.stringify(g.node(v))); -}); -g.edges().forEach(function(e) { - console.log("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(g.edge(e))); -}); - - var benv = require('benv'); - benv.setup(); - benv.require('./lib/d3.v3.min.js'); - benv.require('./lib/dagre-d3.min.js'); - benv.require('./lib/flow.js'); - - document.body.innerHTML='
a-->b;
;'; - benv.require('./src/main.js'); \ No newline at end of file diff --git a/src/backup/flow.jison b/src/backup/flow.jison deleted file mode 100644 index 3b1faf083..000000000 --- a/src/backup/flow.jison +++ /dev/null @@ -1,69 +0,0 @@ -/* description: Parses end executes mathematical expressions. */ - -/* lexical grammar */ -%lex - -%% -"style" return 'STYLE'; -[a-zåäöæøA-ZÅÄÖÆØ]+ return 'ALPHA'; -\#[a-f0-9]+ return 'HEX'; -[0-9]+ return 'NUM'; -"px" return 'UNIT'; -"pt" return 'UNIT'; -"dot" return 'UNIT'; -":" return 'COLON'; -\- return 'MINUS'; -";" return ';'; -"," return 'COMMA'; -[x] return 'ARROW_CROSS'; -">" return 'ARROW_POINT'; -[o] return 'ARROW_CIRCLE'; -"|" return 'PIPE'; -"(" return 'PS'; -")" return 'PE'; -"[" return 'SQS'; -"]" return 'SQE'; -"{" return 'DIAMOND_START' -"}" return 'DIAMOND_STOP' -\s return 'SPACE'; -\n return 'NEWLINE'; -<> return 'EOF'; - -/lex - -/* operator associations and precedence */ - -%left '^' - -%start expressions - -%% /* language grammar */ - -expressions - : id EOF - {return $1;} - ; - -flow: id - {$$='key';} - | STYLE - {$$=$1;} - ; - -id: id MINUS word - {$$=$1+'-'+$3} - | word - {$$=$1} - ; - -word: ALPHA - {$$=$1} - ; - - - -%% -define('parser/flow',function(){ - console.log('bcs123'); - return parser; -}); \ No newline at end of file diff --git a/src/backup/flow.spec.js b/src/backup/flow.spec.js deleted file mode 100644 index 61d4e8ab0..000000000 --- a/src/backup/flow.spec.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Created by knut on 14-11-03. - */ -define('parser/flow.spec',['parser/graph','parser/flow'],function(graph, p){ - - describe('when parsing ',function(){ - beforeEach(function(){ - graph.clear(); - p.yy = graph; - /*p.parse.parseError= function parseError(str, hash) { - console.log(str); - }*/ - }); - - it('should handle a nodes and edges',function(){ - var res = p.parse('apa-apa-åäö'); - console.log('Done parsing:' + res); - }); - }); - -}); - diff --git a/src/backup/graph.js b/src/backup/graph.js deleted file mode 100644 index 5946dac5e..000000000 --- a/src/backup/graph.js +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Created by knut on 14-11-03. - */ -define('parser/graph',function() { - var vertices = {}; - var edges = []; - var graph = { - addVertex: function (id, text, type, style) { - console.log('Got node ' + id + ' ' + type + ' ' + text + ' styles: ' + JSON.stringify(style)); - if(typeof vertices[id] === 'undefined'){ - vertices[id]={id:id, styles:[]}; - } - if(typeof text !== 'undefined'){ - vertices[id].text = text; - } - if(typeof type !== 'undefined'){ - vertices[id].type = type; - } - if(typeof style !== 'undefined'){ - if(style !== null){ - console.log('Adding style: '+style); - style.forEach(function(s){ - vertices[id].styles.push(s); - }); - } - } - }, - getVertices:function(){ - return vertices; - }, - addLink: function (start, end, type, linktext) { - var edge = {start:start, end:end, type:type.type, text:''}; - if(typeof linktext !== 'undefined'){ - edge.text = linktext; - } - edges.push(edge); - //console.log('Got link from ' + start + ' to ' + end + ' type:' + type.type + ' linktext:' + linktext); - }, - getEdges: function () { - return edges; - }, - clear:function(){ - vertices = {}; - edges = []; - }, - defaultStyle:function(){ - return "fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;fill:#ffa;stroke: #666;"; - } - }; - - return graph; -}); diff --git a/src/backup/init.js b/src/backup/init.js deleted file mode 100644 index 33192954d..000000000 --- a/src/backup/init.js +++ /dev/null @@ -1,14 +0,0 @@ - -require.config({ - // Karma serves files from '/base' - baseUrl: './' - -}); - -require(['../mermaid'],function(mermaid){ - mermaid.init(); -}); - - - -console.log('Init running'); \ No newline at end of file diff --git a/src/backup/mermaid.js b/src/backup/mermaid.js deleted file mode 100644 index 445844c01..000000000 --- a/src/backup/mermaid.js +++ /dev/null @@ -1,169 +0,0 @@ -/** - * Created by knut on 14-11-06. - */ -// Now we're ready to require JointJS and write our application code. -define('mermaid',['../parser/graph','parser/mermaid'],function(graph,parser){ - var addVertices = function(vert,g){ - var keys = Object.keys(vert); - - keys.forEach(function(id){ - var vertice = vert[id]; - var verticeText; - - - console.log(vertice.styles.length); - - var i; - var style=''; - for(i=0;i'+ - ''+ - ''; - - - drawChart(chartText,id); - }; - } - - }; - return mermaid; -}); \ No newline at end of file diff --git a/src/graph.js b/src/graph.js index f20fb8f6c..eb79abef8 100644 --- a/src/graph.js +++ b/src/graph.js @@ -10,7 +10,7 @@ mermaid.edges = []; mermaid.graph = { /** - * + * Function called by parser when a node definition has been found * @param id * @param text * @param type @@ -29,16 +29,19 @@ mermaid.graph = { } if(typeof style !== 'undefined'){ if(style !== null){ - console.log('Adding style: '+style); style.forEach(function(s){ mermaid.vertices[id].styles.push(s); }); } } }, - getVertices:function(){ - return mermaid.vertices; - }, + /** + * Function called by parser when a link/edge definition has been found + * @param start + * @param end + * @param type + * @param linktext + */ addLink: function (start, end, type, linktext) { var edge = {start:start, end:end, type:undefined, text:''}; var linktext = type.text; @@ -50,24 +53,49 @@ mermaid.graph = { edge.type = type.type; } mermaid.edges.push(edge); - //console.log('Got link from ' + start + ' to ' + end + ' type:' + type.type + ' linktext:' + linktext); }, + /** + * Updates a link with a style + * @param pos + * @param style + */ updateLink: function (pos, style) { - //mermaid.edges.push(edge); var position = pos.substr(1); - console.log('Got link style for ' + position + ' style ' + style); mermaid.edges[position].style = style; }, + /** + * Called by parser when a graph definition is found, stores the direction of the chart. + * @param dir + */ setDirection: function(dir){ mermaid.direction = dir; }, + /** + * Retrieval function for fetching the found nodes after parsing has completed. + * @returns {{}|*|mermaid.vertices} + */ + getVertices:function(){ + return mermaid.vertices; + }, + /** + * Retrieval function for fetching the found links after parsing has completed. + * @returns {{}|*|mermaid.edges} + */ getEdges: function () { return mermaid.edges; }, + + /** + * Clears the internal graph db so that a new graph can be parsed. + */ clear:function(){ mermaid.vertices = {}; mermaid.edges = []; }, + /** + * + * @returns {string} + */ defaultStyle:function(){ return "fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;fill:#ffa;stroke: #666;"; } diff --git a/src/main.js b/src/main.js index c909cd94a..a8a9a70b5 100644 --- a/src/main.js +++ b/src/main.js @@ -4,28 +4,28 @@ if (typeof mermaid === 'undefined') { } /** - * Function used by parser to store vertices/nodes found in graph script. - * @param vert - * @param g + * Function that adds the vertices found in the graph definition to the graph to be rendered. + * @param vert Object containing the vertices. + * @param g The graph that is to be drawn. */ mermaid.addVertices = function (vert, g) { var keys = Object.keys(vert); + // Iterate through each item in the vertice object (containing all the vertices found) in the graph definition keys.forEach(function (id) { var vertice = vert[id]; var verticeText; - - console.log(vertice.styles.length); - var i; var style = ''; + // Create a compund style definiton from the style definitions found for the node in the graph definition for (i = 0; i < vertice.styles.length; i++) { if (typeof vertice.styles[i] !== 'undefined') { style = style + vertice.styles[i] + ';'; } } + // Use vertice id as text in the box if no text is provided by the graph definition if (vertice.text === undefined) { verticeText = vertice.id; } @@ -33,12 +33,7 @@ mermaid.addVertices = function (vert, g) { verticeText = vertice.text; } - - if (style === '') { - //style = graph.defaultStyle(); - } - - console.log('g.setNode("' + vertice.id + '", { label: "' + verticeText + '" });'); + // Create the node in the graph nased on defined form if (vertice.type === 'round') { g.setNode(vertice.id, {label: verticeText, rx: 5, ry: 5, style: style}); } else { @@ -51,31 +46,23 @@ mermaid.addVertices = function (vert, g) { }); }; +/** + * Add edges to graph based on parsed graph defninition + * @param edges + * @param g + */ mermaid.addEdges = function (edges, g) { edges.forEach(function (edge) { - var type, style; - if(typeof edge.type === 'undefined'){ - type = 'arrow'; - }else{ - type = edge.type; - } - if(typeof edge.style === 'undefined'){ - style = 'arrow'; - }else{ - type = edge.type; - } - - if(type === 'arrow_open'){ + // Set link type for rendering + if(edge.type === 'arrow_open'){ aHead = 'none'; } else{ aHead = 'vee'; } - - var edgeText; - //console.log(vertice); + // Add the edge to the graph if (edge.text === 'undefined') { if(typeof edge.style === 'undefined'){ g.setEdge(edge.start, edge.end,{ arrowheadStyle: "fill: #333", arrowhead: aHead}); @@ -84,7 +71,6 @@ mermaid.addEdges = function (edges, g) { style: edge.style, arrowheadStyle: "fill: #333", arrowhead: aHead }); } - } else { if(typeof edge.style === 'undefined'){ @@ -95,39 +81,28 @@ mermaid.addEdges = function (edges, g) { }); } } - console.log('g.setEdge("' + edge.start + '","' + edge.end + '") ---'); - }); }; +/** + * Draws a chart in the tag with id: id based on the graph definition in text. + * @param text + * @param id + */ mermaid.drawChart = function (text, id) { - - console.log('drawing char with id:' + id); - console.log(text); mermaid.graph.clear(); parser.yy = mermaid.graph; - var err = function () { - console.log('Syntax error!!!'); - }; - + // Parse the graph definition parser.parse(text); - var vert = mermaid.graph.getVertices(); - var edges = mermaid.graph.getEdges(); - - console.log(edges); - - var keys = Object.keys(vert); - + // Fetch the default direction, use TD if none was found var dir; dir = mermaid.direction; if(typeof dir === 'undefined'){ dir='TD'; } - - // Create the input mermaid.graph var g = new dagreD3.graphlib.Graph() .setGraph({ @@ -139,7 +114,9 @@ mermaid.drawChart = function (text, id) { return {}; }); - console.log(g); + // Fetch the verices/nodes and edges/links from the parsed graph definition + var vert = mermaid.graph.getVertices(); + var edges = mermaid.graph.getEdges(); this.addVertices(vert, g); this.addEdges(edges, g); @@ -147,7 +124,7 @@ mermaid.drawChart = function (text, id) { // Create the renderer var render = new dagreD3.render(); - // Add our custom shape + // Add custom shape for rhombus type of boc (decision) render.shapes().question = function (parent, bbox, node) { var w = bbox.width, h = bbox.height * 3, @@ -202,6 +179,9 @@ mermaid.drawChart = function (text, id) { svg.attr("height", g.graph().height + 40); }; +/** + * Go through the document and find the chart definitions in there and render the charts + */ mermaid.init = function () { var arr = document.querySelectorAll('.mermaid'); @@ -223,4 +203,10 @@ mermaid.init = function () { } ; }; -mermaid.init(); \ No newline at end of file + +/** + * Wait for coument loaded before starting the execution + */ +document.addEventListener('DOMContentLoaded', function(){ + mermaid.init(); + }, false); \ No newline at end of file diff --git a/src/parser/flow.jison b/src/parser/flow.jison index 0cb88780e..1fad5dd7b 100644 --- a/src/parser/flow.jison +++ b/src/parser/flow.jison @@ -52,7 +52,7 @@ expressions graphConfig : GRAPH SPACE DIR SEMI - { console.log('In graph config');yy.setDirection($3);$$ = $3;} + { yy.setDirection($3);$$ = $3;} ; statements @@ -72,9 +72,9 @@ statement verticeStatement: | vertex link vertex - { console.log('In vertexStatement');yy.addLink($1,$3,$2);$$ = 'oy'} + { yy.addLink($1,$3,$2);$$ = 'oy'} | vertex - {console.log('In vertexStatement ... ');$$ = 'yo';} + {$$ = 'yo';} ; vertex: alphaNum SQS text SQE @@ -84,7 +84,7 @@ vertex: alphaNum SQS text SQE | alphaNum DIAMOND_START text DIAMOND_STOP {$$ = $1;yy.addVertex($1,$3,'diamond');} | alphaNum - {console.log('In vertex:'+$1); $$ = $1;yy.addVertex($1);} + {$$ = $1;yy.addVertex($1);} ; alphaNum @@ -96,7 +96,7 @@ alphaNum alphaNumStatement : alphaNumToken - {console.log('Found token (statement): '+$1);$$=$1;} + {$$=$1;} | alphaNumToken MINUS alphaNumToken {$$=$1+'-'+$3;} ; @@ -126,16 +126,14 @@ linkStatement: ARROW_POINT arrowText: PIPE text PIPE - {console.log('Nice link text here: '+$2);$$ = $2;} + {$$ = $2;} ; // Characters and spaces text: alphaNum SPACE text {$$ = $1 + ' ' +$3;} - | alphaNum MINUS text - {$$ = $1 + '-' +$3;} - | alphaNum SPACE - {$$ = $1;} + | alphaNum spaceList MINUS spaceList text + {$$ = $1 + ' - ' +$5;} | alphaNum {$$ = $1;} ; @@ -143,7 +141,7 @@ text: alphaNum SPACE text styleStatement:STYLE SPACE alphaNum SPACE stylesOpt {$$ = $1;yy.addVertex($3,undefined,undefined,$5);} | STYLE SPACE HEX SPACE stylesOpt - {console.log('In parser - style: '+$5);$$ = $1;yy.updateLink($3,$5);} + {$$ = $1;yy.updateLink($3,$5);} ; stylesOpt: style @@ -173,7 +171,4 @@ styleComponent: ALPHA | HEX {$$=$1} ; -%% -/*define('parser/mermaid',function(){ - return parser; -});*/ \ No newline at end of file +%% \ No newline at end of file diff --git a/src/parser/flow.js b/src/parser/flow.js index 3033c31af..4c9f31651 100644 --- a/src/parser/flow.js +++ b/src/parser/flow.js @@ -72,12 +72,12 @@ } */ var parser = (function(){ -var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,7],$V1=[2,10],$V2=[1,15],$V3=[1,16],$V4=[1,11],$V5=[6,9],$V6=[11,28,29,37],$V7=[11,32,33,34,35],$V8=[9,11,18,20,21,22,23,24,27,32,33,34,35,36],$V9=[9,11,18,20,21,22,23,24,27,28,29,32,33,34,35,36],$Va=[28,29],$Vb=[28,29,36],$Vc=[20,22,24,36],$Vd=[1,67],$Ve=[1,64],$Vf=[1,62],$Vg=[1,65],$Vh=[1,68],$Vi=[1,63],$Vj=[1,66],$Vk=[1,72],$Vl=[11,41],$Vm=[9,11,27,28,29,39,41,43,44]; +var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,7],$V1=[2,10],$V2=[1,15],$V3=[1,16],$V4=[1,11],$V5=[6,9],$V6=[11,27,28,29,37],$V7=[2,7],$V8=[11,32,33,34,35],$V9=[9,11,18,20,21,22,23,24,32,33,34,35,36],$Va=[9,11,18,20,21,22,23,24,28,29,32,33,34,35,36],$Vb=[9,11,18,20,21,22,23,24,27,28,29,32,33,34,35,36],$Vc=[28,29],$Vd=[28,29,36],$Ve=[20,22,24,36],$Vf=[1,67],$Vg=[1,64],$Vh=[1,62],$Vi=[1,65],$Vj=[1,68],$Vk=[1,63],$Vl=[1,66],$Vm=[1,72],$Vn=[11,41],$Vo=[9,11,27,28,29,39,41,43,44]; var parser = {trace: function trace() { }, yy: {}, symbols_: {"error":2,"expressions":3,"graphConfig":4,"statements":5,"EOF":6,"spaceList":7,"GRAPH":8,"SPACE":9,"DIR":10,"SEMI":11,"statement":12,"verticeStatement":13,"styleStatement":14,"vertex":15,"link":16,"alphaNum":17,"SQS":18,"text":19,"SQE":20,"PS":21,"PE":22,"DIAMOND_START":23,"DIAMOND_STOP":24,"alphaNumStatement":25,"alphaNumToken":26,"MINUS":27,"ALPHA":28,"NUM":29,"linkStatement":30,"arrowText":31,"ARROW_POINT":32,"ARROW_CIRCLE":33,"ARROW_CROSS":34,"ARROW_OPEN":35,"PIPE":36,"STYLE":37,"stylesOpt":38,"HEX":39,"style":40,"COMMA":41,"styleComponent":42,"COLON":43,"UNIT":44,"$accept":0,"$end":1}, terminals_: {2:"error",6:"EOF",8:"GRAPH",9:"SPACE",10:"DIR",11:"SEMI",18:"SQS",20:"SQE",21:"PS",22:"PE",23:"DIAMOND_START",24:"DIAMOND_STOP",27:"MINUS",28:"ALPHA",29:"NUM",32:"ARROW_POINT",33:"ARROW_CIRCLE",34:"ARROW_CROSS",35:"ARROW_OPEN",36:"PIPE",37:"STYLE",39:"HEX",41:"COMMA",43:"COLON",44:"UNIT"}, -productions_: [0,[3,3],[3,4],[4,4],[5,3],[5,1],[7,2],[7,1],[12,2],[12,2],[13,0],[13,3],[13,1],[15,4],[15,4],[15,4],[15,1],[17,1],[17,2],[25,1],[25,3],[26,1],[26,1],[16,2],[16,1],[30,1],[30,1],[30,1],[30,1],[31,3],[19,3],[19,3],[19,2],[19,1],[14,5],[14,5],[38,1],[38,3],[40,1],[40,2],[42,1],[42,1],[42,1],[42,1],[42,1],[42,1],[42,1]], +productions_: [0,[3,3],[3,4],[4,4],[5,3],[5,1],[7,2],[7,1],[12,2],[12,2],[13,0],[13,3],[13,1],[15,4],[15,4],[15,4],[15,1],[17,1],[17,2],[25,1],[25,3],[26,1],[26,1],[16,2],[16,1],[30,1],[30,1],[30,1],[30,1],[31,3],[19,3],[19,5],[19,1],[14,5],[14,5],[38,1],[38,3],[40,1],[40,2],[42,1],[42,1],[42,1],[42,1],[42,1],[42,1],[42,1]], performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { /* this == yyval */ @@ -107,7 +107,7 @@ break; case 16: console.log('In vertex:'+$$[$0]); this.$ = $$[$0];yy.addVertex($$[$0]); break; -case 17: case 21: case 22: case 38: +case 17: case 21: case 22: case 37: this.$=$$[$0]; break; case 18: @@ -122,7 +122,7 @@ break; case 23: $$[$0-1].text = $$[$0];this.$ = $$[$0-1]; break; -case 24: case 33: +case 24: case 32: this.$ = $$[$0]; break; case 25: @@ -144,32 +144,29 @@ case 30: this.$ = $$[$0-2] + ' ' +$$[$0]; break; case 31: -this.$ = $$[$0-2] + '-' +$$[$0]; +this.$ = $$[$0-4] + ' - ' +$$[$0]; break; -case 32: -this.$ = $$[$0-1]; -break; -case 34: +case 33: this.$ = $$[$0-4];yy.addVertex($$[$0-2],undefined,undefined,$$[$0]); break; -case 35: +case 34: console.log('In parser - style: '+$$[$0]);this.$ = $$[$0-4];yy.updateLink($$[$0-2],$$[$0]); break; -case 36: +case 35: this.$ = [$$[$0]] break; -case 37: +case 36: $$[$0-2].push($$[$0]);this.$ = $$[$0-2]; break; -case 39: +case 38: this.$ = $$[$0-1] + $$[$0]; break; -case 40: case 41: case 42: case 43: case 44: case 45: case 46: +case 39: case 40: case 41: case 42: case 43: case 44: case 45: this.$=$$[$0] break; } }, -table: [{3:1,4:2,8:[1,3]},{1:[3]},{5:4,7:5,9:$V0,11:$V1,12:6,13:8,14:9,15:10,17:12,25:13,26:14,28:$V2,29:$V3,37:$V4},{9:[1,17]},{6:[1,18],7:19,9:$V0},{5:20,11:$V1,12:6,13:8,14:9,15:10,17:12,25:13,26:14,28:$V2,29:$V3,37:$V4},o($V5,[2,5]),o($V6,[2,7],{7:21,9:$V0}),{11:[1,22]},{11:[1,23]},{11:[2,12],16:24,30:25,32:[1,26],33:[1,27],34:[1,28],35:[1,29]},{9:[1,30]},o($V7,[2,16],{18:[1,31],21:[1,32],23:[1,33]}),o($V8,[2,17],{25:13,26:14,17:34,28:$V2,29:$V3}),o([9,11,18,20,21,22,23,24,28,29,32,33,34,35,36],[2,19],{27:[1,35]}),o($V9,[2,21]),o($V9,[2,22]),{10:[1,36]},{1:[2,1]},{11:$V1,12:37,13:8,14:9,15:10,17:12,25:13,26:14,28:$V2,29:$V3,37:$V4},{6:[1,38],7:19,9:$V0},o($V6,[2,6]),o($V5,[2,8]),o($V5,[2,9]),{15:39,17:12,25:13,26:14,28:$V2,29:$V3},o($Va,[2,24],{31:40,36:[1,41]}),o($Vb,[2,25]),o($Vb,[2,26]),o($Vb,[2,27]),o($Vb,[2,28]),{17:42,25:13,26:14,28:$V2,29:$V3,39:[1,43]},{17:45,19:44,25:13,26:14,28:$V2,29:$V3},{17:45,19:46,25:13,26:14,28:$V2,29:$V3},{17:45,19:47,25:13,26:14,28:$V2,29:$V3},o($V8,[2,18]),{26:48,28:$V2,29:$V3},{11:[1,49]},o($V5,[2,4]),{1:[2,2]},{11:[2,11]},o($Va,[2,23]),{17:45,19:50,25:13,26:14,28:$V2,29:$V3},{9:[1,51]},{9:[1,52]},{20:[1,53]},o($Vc,[2,33],{9:[1,54],27:[1,55]}),{22:[1,56]},{24:[1,57]},o($V9,[2,20]),o([9,11,28,29,37],[2,3]),{36:[1,58]},{9:$Vd,27:$Ve,28:$Vf,29:$Vg,38:59,39:$Vh,40:60,42:61,43:$Vi,44:$Vj},{9:$Vd,27:$Ve,28:$Vf,29:$Vg,38:69,39:$Vh,40:60,42:61,43:$Vi,44:$Vj},o($V7,[2,13]),o($Vc,[2,32],{25:13,26:14,17:45,19:70,28:$V2,29:$V3}),{17:45,19:71,25:13,26:14,28:$V2,29:$V3},o($V7,[2,14]),o($V7,[2,15]),o($Va,[2,29]),{11:[2,34],41:$Vk},o($Vl,[2,36],{42:73,9:$Vd,27:$Ve,28:$Vf,29:$Vg,39:$Vh,43:$Vi,44:$Vj}),o($Vm,[2,38]),o($Vm,[2,40]),o($Vm,[2,41]),o($Vm,[2,42]),o($Vm,[2,43]),o($Vm,[2,44]),o($Vm,[2,45]),o($Vm,[2,46]),{11:[2,35],41:$Vk},o($Vc,[2,30]),o($Vc,[2,31]),{9:$Vd,27:$Ve,28:$Vf,29:$Vg,39:$Vh,40:74,42:61,43:$Vi,44:$Vj},o($Vm,[2,39]),o($Vl,[2,37],{42:73,9:$Vd,27:$Ve,28:$Vf,29:$Vg,39:$Vh,43:$Vi,44:$Vj})], +table: [{3:1,4:2,8:[1,3]},{1:[3]},{5:4,7:5,9:$V0,11:$V1,12:6,13:8,14:9,15:10,17:12,25:13,26:14,28:$V2,29:$V3,37:$V4},{9:[1,17]},{6:[1,18],7:19,9:$V0},{5:20,11:$V1,12:6,13:8,14:9,15:10,17:12,25:13,26:14,28:$V2,29:$V3,37:$V4},o($V5,[2,5]),o($V6,$V7,{7:21,9:$V0}),{11:[1,22]},{11:[1,23]},{11:[2,12],16:24,30:25,32:[1,26],33:[1,27],34:[1,28],35:[1,29]},{9:[1,30]},o($V8,[2,16],{18:[1,31],21:[1,32],23:[1,33]}),o($V9,[2,17],{25:13,26:14,17:34,28:$V2,29:$V3}),o($Va,[2,19],{27:[1,35]}),o($Vb,[2,21]),o($Vb,[2,22]),{10:[1,36]},{1:[2,1]},{11:$V1,12:37,13:8,14:9,15:10,17:12,25:13,26:14,28:$V2,29:$V3,37:$V4},{6:[1,38],7:19,9:$V0},o($V6,[2,6]),o($V5,[2,8]),o($V5,[2,9]),{15:39,17:12,25:13,26:14,28:$V2,29:$V3},o($Vc,[2,24],{31:40,36:[1,41]}),o($Vd,[2,25]),o($Vd,[2,26]),o($Vd,[2,27]),o($Vd,[2,28]),{17:42,25:13,26:14,28:$V2,29:$V3,39:[1,43]},{17:45,19:44,25:13,26:14,28:$V2,29:$V3},{17:45,19:46,25:13,26:14,28:$V2,29:$V3},{17:45,19:47,25:13,26:14,28:$V2,29:$V3},o($V9,[2,18]),{26:48,28:$V2,29:$V3},{11:[1,49]},o($V5,[2,4]),{1:[2,2]},{11:[2,11]},o($Vc,[2,23]),{17:45,19:50,25:13,26:14,28:$V2,29:$V3},{9:[1,51]},{9:[1,52]},{20:[1,53]},o($Ve,[2,32],{7:55,9:[1,54]}),{22:[1,56]},{24:[1,57]},o($Va,[2,20]),o([9,11,28,29,37],[2,3]),{36:[1,58]},{9:$Vf,27:$Vg,28:$Vh,29:$Vi,38:59,39:$Vj,40:60,42:61,43:$Vk,44:$Vl},{9:$Vf,27:$Vg,28:$Vh,29:$Vi,38:69,39:$Vj,40:60,42:61,43:$Vk,44:$Vl},o($V8,[2,13]),{7:21,9:$V0,17:45,19:70,25:13,26:14,27:$V7,28:$V2,29:$V3},{27:[1,71]},o($V8,[2,14]),o($V8,[2,15]),o($Vc,[2,29]),{11:[2,33],41:$Vm},o($Vn,[2,35],{42:73,9:$Vf,27:$Vg,28:$Vh,29:$Vi,39:$Vj,43:$Vk,44:$Vl}),o($Vo,[2,37]),o($Vo,[2,39]),o($Vo,[2,40]),o($Vo,[2,41]),o($Vo,[2,42]),o($Vo,[2,43]),o($Vo,[2,44]),o($Vo,[2,45]),{11:[2,34],41:$Vm},o($Ve,[2,30]),{7:74,9:$V0},{9:$Vf,27:$Vg,28:$Vh,29:$Vi,39:$Vj,40:75,42:61,43:$Vk,44:$Vl},o($Vo,[2,38]),{17:45,19:76,25:13,26:14,28:$V2,29:$V3},o($Vn,[2,36],{42:73,9:$Vf,27:$Vg,28:$Vh,29:$Vi,39:$Vj,43:$Vk,44:$Vl}),o($Ve,[2,31])], defaultActions: {18:[2,1],38:[2,2],39:[2,11]}, parseError: function parseError(str, hash) { if (hash.recoverable) { diff --git a/src/parser/flow.spec.js b/src/parser/flow.spec.js index ca1d8d8f1..d0c170cac 100644 --- a/src/parser/flow.spec.js +++ b/src/parser/flow.spec.js @@ -145,6 +145,15 @@ describe('when parsing ',function(){ expect(vert['C'].type).toBe('diamond'); expect(vert['C'].text).toBe('Chimpansen hoppar åäö-ÅÄÖ'); }); + it('should handle text in vertices with åäö, minus and space',function(){ + var res = parser.parse('graph TD;A-->C{Chimpansen hoppar åäö - ÅÄÖ};'); + + var vert = parser.yy.getVertices(); + var edges = parser.yy.getEdges(); + + expect(vert['C'].type).toBe('diamond'); + expect(vert['C'].text).toBe('Chimpansen hoppar åäö - ÅÄÖ'); + }); it('should handle a single node',function(){ // Silly but syntactically correct diff --git a/src/parser/test.txt b/src/parser/test.txt deleted file mode 100644 index 2dba4f294..000000000 --- a/src/parser/test.txt +++ /dev/null @@ -1,1573 +0,0 @@ -grammar ECMAScript; - -options { - // Allow any char but \uFFFF (16 bit -1) - charVocabulary='\u0000'..'\uFFFE'; -} -/* this comes from section A.5 but is really the starting point, so -* it is present here. -*/ -program: - sourceElements EOF - ; - -/* A.1 Lexical Grammar */ - -sourceCharacter: - /* any unicode character */ - /* see section 6 */ - SOURCE_CHAR - ; - -inputElementDiv: - whiteSpace - | lineTerminator - | comment - | token - | divPunctuator - ; - -inputElementRegExp: - whiteSpace - | lineTerminator - | comment - | token - | regularExpressionLiteral - ; - -whiteSpace: - TAB - | VT - | FF - | SP - | NBSP - | USP - ; - -lineTerminator: - | LF - | CR - | LS - | PS - ; - -comment: - multiLineComment - | singleLineComment - ; - -multiLineComment: - '/*' multiLineCommentChars '*/' - ; - -multiLineCommentChars: - multiLineNotAsterikChar multiLineCommentChars - | ASTERISK postAsterikCommentChars - ; - -postAsterikCommentChars: - multiLineNotForwardSlashOrAsterikChar multiLineCommentChars - | ASTERISK postAsterikCommentChars - ; - -multiLineNotAsterikChar: - sourceCharacter /* but not ASTERISK */ - ; - -multiLineNotForwardSlashOrAsterikChar: - sourceCharacter /* but not FORWARD-SLASH or ASTERISK */ - ; - -singleLineComment: - '//' singleLineCommentChars - ; - -singleLineCommentChars: - singleLineCommentChar singleLineCommentChars - ; - -singleLineCommentChar: - sourceCharacter /* but not lineTerminator */ - ; - -token: - reservedWord - | identifier - /* syntactic predicate used to disambiguate between DOT on ALT 3 and ALT 5 */ - | (DOT decimalDigits)=> numericLiteral - /* syntactic predicate used to disambiguate between APOSTROPHE on ALT 4 and ALT 5 */ - | (APOSTROPHE (singleStringCharacters)? APOSTROPHE)=> stringLiteral - | punctuator - ; - -reservedWord: - keyword - | futureReservedWord - | nullLiteral - | booleanLiteral - ; - -keyword: - 'break' | 'case' | 'catch' | 'continue' | 'default' | 'delete' | 'do' - | 'else' | 'finally' | 'for' | 'function' | 'if' | 'in' | 'instanceof' - | 'new' | 'return' | 'switch' | 'this' | 'throw' | 'try' | 'typeof' - | 'var' | 'void' | 'while' | 'with' - ; - -futureReservedWord: - 'abstract' | 'boolean' | 'byte' | 'char' | 'class' | 'const' | 'debugger' | 'double' - | 'enum' | 'export' | 'extends' | 'final' | 'float' | 'goto' | 'implements' | 'import' - | 'int' | 'interface' | 'long' | 'native' | 'package' | 'private' | 'protected' | 'public' - | 'short' | 'static' | 'super' | 'synchronized' | 'throws' | 'transient' | 'volatile' - ; - -identifier: - identifierName /* but not reservedWord */ - ; - -identifierName: - /* - * left factorization: - * - * SPEC: - * identifierStart - * | identifierName identifierPart - * -> - * ((identifierStart)+ (identifierPart)?)+ - */ - identifierStart (identifierPart)* - ; - -identifierStart: - unicodeLetter - | DOLLAR - | UNDERSCORE - | unicodeEscapeSequence - ; - -identifierPart: - /* syntactic predicate to remove non-determinism upon alts 1 and 5 - * - always choose the identifierStart when possible - */ - (unicodeEscapeSequence identifierPart)=> identifierStart - | unicodeCombiningMark - | unicodeDigit - | unicodeConnectorPunctuation - | unicodeEscapeSequence - ; - -unicodeLetter: - /* any character in the unicode categories: - "uppercase letter (Lu)", - "lowercase letter (Li)", - "titlecase letter (Lt)", - "modifier letter (Lm)", - "other letter (lo)", - "letter number (NI)" */ - UNICODE_LETTER - ; - -unicodeCombiningMark: - /* any character in the unicode categories: - "non-spacing mark (Mn)" - "combining spacing mark (Mc)" - */ - UNICODE_NONSPACING_MARK - | UNICODE_COMBINING_MARK - ; - -unicodeDigit: - /* any character in the unicode category "decimal number (Nd)" */ - UNICODE_DIGIT - ; - -unicodeConnectorPunctuation: - /* any character in the unicode category "connector punctuation (Pc)" */ - UNICODE_CONNECTOR_PUNCTUATION - ; - -unicodeEscapeSequence: - '\\u' hexDigit hexDigit hexDigit hexDigit - ; - -hexDigit: - /* explicitly enumerated in grammar */ - HEXDIGIT - ; - -punctuator: - LBRACE | RBRACE | LPAREN | RPAREN | LBRACK | RBRACK - | DOT | SEMI | APOSTROPHE | LT | GT | LTEQ - | GTEQ | EQ2 | NOTEQ | EQ3 | NOTEQ2 - | PLUS | MINUS | STAR | PERCENT | PLUS2 | MINUS2 - | LSHIFT | RSHIFT | GT3 | AMPER | PIPE | CAROT - | EXCLAMATION | TILDE | AMPER2 | PIPE2 | QUESTION | COLON - | EQ | PLUSEQ | MINUSEQ | TIMESEQ | PERCENTEQ | LSHIFTEQ - | RSHIFTEQ | GT3EQ | AMPEREQ | PIPEEQ | CAROTEQ - ; - -divPunctuator: - DIVIDE - | DIVIDEEQ - ; - -literal: - nullLiteral - | booleanLiteral - | numericLiteral - | stringLiteral - ; - -nullLiteral: - 'null' - ; - -booleanLiteral: - 'true' - | 'false' - ; - - -numericLiteral: - decimalLiteral - | hexIntegerLiteral - ; - -decimalLiteral: - /* - * SPEC: - * decimalIntegerLiteral DOT (decimalDigits)? (exponentPart)? - * | DOT decimalDigits (exponentPart)? - * | decimalIntegerLiteral (exponentPart)? - * -> - */ - decimalIntegerLiteral decimalIntegerLiteralTail - | DOT decimalDigits (exponentPart)? - ; - -decimalIntegerLiteralTail: - /* this is necessary because of the way the grammar gets parsed */ - DOT (decimalDigits)? (exponentPart)? - | exponentPart - ; - -decimalIntegerLiteral: - ZERO - | NON_ZERO_DIGIT (decimalDigits)? - ; - -decimalDigits: - /* - * SPEC: - * decimalDigit - * | decimalDigits decimalDigit - * => - * (decimalDigits)+ - */ - (decimalDigit)+ - ; - -decimalDigit: - DIGIT /* grammar has each one explicitely listed */ - ; - -exponentIndicator: - EXPONENT_INDICATOR /* grammar has both e and E listed */ - ; - -signedInteger: - decimalDigits - | PLUS decimalDigits - | MINUS decimalDigits - ; - -hexIntegerLiteral: - /* - * SPEC: - * '0x' hexDigit - * | '0X' hexDigit - * | hexIntegerLiteral hexDigit - * -> - * ('0x'|'0X') (hexDigit)+ - */ - ('0x'|'0X') (hexDigit)+ - ; - -stringLiteral: - QUOTE (doubleStringCharacters)? QUOTE - | APOSTROPHE (singleStringCharacters)? APOSTROPHE - ; - -doubleStringCharacters: - doubleStringCharacter (doubleStringCharacters)? - ; - -singleStringCharacters: - singleStringCharacter (singleStringCharacters)? - ; - -doubleStringCharacter: - sourceCharacter /* but not double quote or backslash or line terminator */ - BSLASH escapeSequence - ; - -singleStringCharacter: - sourceCharacter /* but not single quote or backslash or line terminator */ - | BSLASH escapeSequence - ; - -escapeSequence: - characterEscapeSequence - | ZERO /* [lookahead not a member of decimalDigit] */ - | hexEscapeSequence - | unicodeEscapeSequence - ; - -characterEscapeSequence: - singleEscapeCharacter - | nonEscapeCharacter - ; - -singleEscapeCharacter: - APOSTROPHE | QUOTE | BSLASH | LOWER_B | LOWER_F | LOWER_N | LOWER_R | LOWER_T | LOWER_V - ; - -nonEscapeCharacter: - sourceCharacter /* but not escapeCharacter or lineTerminator */ - ; - -escapeCharacter: - singleEscapeCharacter - | decimalDigit - | LOWER_X - | LOWER_U - ; - -hexEscapeSequence: - LOWER_X hexDigit hexDigit - ; - -/* defined above -unicodeEscapeSequence: - LOWER_U hexDigit hexDigit hexDigit hexDigit - ;*/ - -regularExpressionLiteral: - SLASH regularExpressionBody SLASH regularExpressionFlags - ; - -regularExpressionBody: - regularExpressionFirstChar regularExpressionChars - ; - -regularExpressionChars: - /* [empty] */ - /* - * SPEC: regularExpressionChars regularExpressionChar - * ->: regularExpressionChar regularExpressionChars - */ - regularExpressionChar regularExpressionChars - ; - -regularExpressionFirstChar: - nonTerminator /* but not * or \ or / */ - | backslashSequence - ; - -regularExpressionChar: - nonTerminator /* but not * or \ or / */ - | backslashSequence - ; - -backslashSequence: - BSLASH nonTerminator - ; - -nonTerminator: - sourceCharacter /* but not lineTerminator */ - ; - -regularExpressionFlags: - /* - * SPEC: - * [empty] | regularExpressionFlags identifierPart - * -> - * (identifierPart|)* - */ - (identifierPart)* - ; - -/* A.2 Number Conversions */ - -stringNumericLiteral: - /* - * SPEC: - * (strWhiteSpace)? - * | (strWhiteSpace)? strNumericLiteral (strWhiteSpace)? - */ - (strWhiteSpace)? (strNumericLiteral (strWhiteSpace)?)? - ; - -strWhiteSpace: - strWhiteSpaceChar (strWhiteSpace)? - ; - -strWhiteSpaceChar: - TAB | SP | NBSP | FF | VT | CR | LF | LS | PS | USP - ; - -strNumericLiteral: - strDecimalLiteral - | hexIntegerLiteral - ; - -strDecimalLiteral: - strUnsignedDecimalLiteral - | PLUS strUnsignedDecimalLiteral - | MINUS strUnsignedDecimalLiteral - ; - -strUnsignedDecimalLiteral: - /* - * SPEC: - * 'Infinity' - * | decimalDigits DOT (decimalDigits)? (exponentPart)? - * | DOT decimalDigits (exponentPart)? - * | decimalDigits (exponentPart)? - */ - 'Infinity' - /* syntactic predicate used to remove nondet between ALTs 2 and 4 */ - | (decimalDigits DOT)=> decimalDigits DOT (decimalDigits)? (exponentPart)? - | DOT decimalDigits (exponentPart)? - | decimalDigits (exponentPart)? - ; - -/* defined above -decimalDigits: - decimalDigit - | decimalDigits decimalDigit - ;*/ - -/* decimalDigit: - DIGIT // grammar has them explicitly enumerated - ;*/ - -exponentPart: - exponentIndicator signedInteger - ; - -/* redefined above -exponentIndicator: - EXPONENT_INDICATOR - ;*/ - -/* redefined above -signedInteger: - decimalDigits - | PLUS decimalDigits - | MINUS decimalDigits - ;*/ - -/* redefined above -hexIntegerLiteral: - '0x' hexDigit - | '0X' hexDigit - | hexIntegerLiteral hexDigit - ;*/ - -/* redefined above -hexDigit: - HEXDIGIT // grammar has them explicitely enumerated - ; */ - -/* A.3 Expressions */ - -primaryExpression: - 'this' - | identifier - | literal - | arrayLiteral - | objectLiteral - | LPAREN expression RPAREN - ; - -arrayLiteral: - /* - * SPEC: - * LBRACK (elision)? RBRACK - * | LBRACK elementList RBRACK - * | LBRACK elementList COMMA (elision)? RBRACK - */ - LBRACK ( - (elision)? - | elementList (COMMA (elision)?)? - ) RBRACK - ; - -elementList: - /* - * SPEC: - * (elision)? assignmentExpression - * | elementList COMMA (elision)? assignmentExpression - */ - (elision)? assignmentExpression (elementListTail)* - ; - -elementListTail: - COMMA (elision)? assignmentExpression - ; - -elision: - /* - * SPEC: - * COMMA - * | elision COMMA - * -> - * (COMMA)+ - */ - (COMMA)+ - ; - -objectLiteral: - /* - * SPEC: - * LBRACE RBRACE - * | LBRACE propertyNameAndValueList RBRACE - */ - LBRACE (propertyNameAndValueList)? RBRACE - ; - -propertyNameAndValueList: - /* - * SPEC: - * propertyName COLON assignmentExpression - * | propertyNameAndValueList COMMA propertyName COLON assignmentExpression - */ - propertyName COLON assignmentExpression (propertyNameAndValueListTail)* - ; - -propertyNameAndValueListTail: - COMMA propertyName COLON assignmentExpression - ; - -propertyName: - identifier - | stringLiteral - | numericLiteral - ; - -memberExpression: - /* - * SPEC: - * primaryExpression - * | functionExpression - * | memberExpression LBRACK expression RBRACK - * | memberExpression DOT identifier - * | 'new' memberExpression arguments - * -> - */ - ( primaryExpression - | functionExpression - | 'new' memberExpression arguments - ) (memberExpressionTail)* - ; - -memberExpressionTail: - /* SPEC: not a part of formal grammar */ - LBRACK expression RBRACK - | DOT identifier - ; - -newExpression: - /* - * SPEC: - * memberExpression - * | 'new' newExpression - */ - /* syntactic predicate added to resolve between nondet in ALTs 1 and 2 */ - ('new' newExpression)=> 'new' newExpression - | memberExpression - ; - -callExpression: - /* - * SPEC: - * memberExpression arguments - * | callExpression arguments - * | callExpression LBRACK expression RBRACK - * | callExpression DOT identifier - */ - memberExpression arguments (callExpressionTail)* - ; - -callExpressionTail: - arguments - | LBRACK expression RBRACK - | DOT identifier - ; - -arguments: - /* - * SPEC: - * LPAREN RPAREN - * | LPAREN argumentList RPAREN - */ - LPAREN (argumentList)? RPAREN - ; - -argumentList: - /* - * SPEC: - * assignmentExpression - * | argumentList COMMA assignmentExpression - */ - assignmentExpression (argumentListTail)* - ; - -argumentListTail: - COMMA assignmentExpression - ; - -leftHandSideExpression: - /* - * SPEC: - * newExpression - * | callExpression - */ - ('new' newExpression)=> newExpression - | callExpression - ; - -postfixExpression: - /* - * SPEC: - * leftHandSideExpression - * | leftHandSideExpression / no line terminator here / PLUS2 - * | leftHandSideExpression / no line terminator here / MINUS2 - */ - leftHandSideExpression (PLUS2|MINUS2)? - ; - -unaryExpression: - postfixExpression - | 'delete' unaryExpression - | 'void' unaryExpression - | 'typeof' unaryExpression - | PLUS2 unaryExpression - | MINUS2 unaryExpression - | PLUS unaryExpression - | MINUS unaryExpression - | TILDE unaryExpression - | EXCLAMATION unaryExpression - ; - -multiplicativeExpression: - /* - * SPEC: - * unaryExpression - * | multiplicativeExpression ASTERISK unaryExpression - * | multiplicativeExpression DIVIDE unaryExpression - * | multiplicativeExpression PERCENT unaryExpression - */ - unaryExpression (multiplicativeExpressionTail)* - ; - -multiplicativeExpressionTail: - ASTERISK unaryExpression - | DIVIDE unaryExpression - | PERCENT unaryExpression - ; - -additiveExpression: - /* - * SPEC: - * multiplicativeExpression - * | additiveExpression PLUS multiplicativeExpression - * | additiveExpression MINUS multiplicativeExpression - */ - multiplicativeExpression (additiveExpressionTail)* - ; - -additiveExpressionTail: - PLUS multiplicativeExpression - | MINUS multiplicativeExpression - ; - -shiftExpression: - /* - * SPEC: - * additiveExpression - * | shiftExpression LSHIFT additiveExpression - * | shiftExpression RSHIFT additiveExpression - * | shiftExpression GT3 additiveExpression - */ - additiveExpression (shiftExpressionTail)* - ; - -shiftExpressionTail: - LSHIFT additiveExpression - | RSHIFT additiveExpression - | GT3 additiveExpression - ; - -relationalExpression: - /* - * SPEC: - * shiftExpression - * | relationalExpression LT shiftExpression - * | relationalExpression GT shiftExpression - * | relationalExpression LTEQ shiftExpression - * | relationalExpression GTEQ shiftExpression - * | relationalExpression 'instanceof' shiftExpression - * | relationalExpression 'in' shiftExpression - */ - shiftExpression (relationalExpressionTail)* - ; - -relationalExpressionTail: - LT shiftExpression - | GT shiftExpression - | LTEQ shiftExpression - | GTEQ shiftExpression - | 'instanceof' shiftExpression - | 'in' shiftExpression - ; - -relationalExpressionNoln: - shiftExpression - | relationalExpression (LT|GT|LTEQ|GTEQ|'instanceof') shiftExpression - ; - -equalityExpression: - /* - * SPEC: - * relationalExpression - * | equalityExpression (EQ2|NOTEQQ|EQ3|NOTEQQ2) relationalExpression - */ - relationalExpression (equalityExpressionTail)* - ; - -equalityExpressionTail: - (EQ2|NOTEQ|EQ3|NOTEQ2) relationalExpression - ; - -equalityExpressionNoln: - /* - * SPEC: - * relationalExpressionNoln - * | equalityExpressionNoln (EQ2|NOTEQQ|EQ3|NOTEQQ2) relationalExpressionNoln - */ - relationalExpressionNoln (equalityExpressionNolnTail)* - ; - -equalityExpressionNolnTail: - (EQ2|NOTEQ|EQ3|NOTEQ2) relationalExpressionNoln - ; - -bitwiseAndExpression: - /* - * SPEC: - * equalityExpression - * | bitwiseAndExpression AMPER equalityExpression - */ - equalityExpression (bitwiseAndExpressionTail)* - ; - -bitwiseAndExpressionTail: - AMPER equalityExpression - ; - -bitwiseAndExpressionNoln: - /* - * SPEC: - * equalityExpressionNoln - * | bitwiseAndExpressionNoln AMPER equalityExpressionNoln - */ - equalityExpressionNoln (bitwiseAndExpressionNolnTail)* - ; - -bitwiseAndExpressionNolnTail: - AMPER equalityExpressionNoln - ; - -bitwiseXorExpression: - /* - * SPEC: - * bitwiseAndExpression - * | bitwiseXorExpression CAROT bitwiseAndExpression - */ - bitwiseAndExpression (bitwiseXorExpressionTail)* - ; - -bitwiseXorExpressionTail: - CAROT bitwiseAndExpression - ; - -bitwiseXorExpressionNoln: - /* - * SPEC: - * bitwiseAndExpressionNoln - * | bitwiseXorExpressionNoln CAROT bitwiseAndExpressionNoln - */ - bitwiseAndExpressionNoln (bitwiseXorExpressionNolnTail)* - ; - -bitwiseXorExpressionNolnTail: - CAROT bitwiseAndExpressionNoln - ; - -bitwiseOrExpression: - /* - * SPEC: - * bitwiseXorExpression - * | bitwiseOrExpression PIPE bitwiseXorExpression - */ - bitwiseXorExpression (bitwiseOrExpressionTail)* - ; - -bitwiseOrExpressionTail: - PIPE bitwiseXorExpression - ; - -bitwiseOrExpressionNoln: - /* - * SPEC: - * bitwiseXorExpressionNoln - * | bitwiseOrExpressionNoln PIPE bitwiseXorExpressionNoln - */ - bitwiseXorExpressionNoln (bitwiseOrExpressionNolnTail)* - ; - -bitwiseOrExpressionNolnTail: - PIPE bitwiseOrExpressionNolnTail - ; - -logicalAndExpression: - bitwiseOrExpression - | logicalAndExpressionNoln AMPER2 bitwiseOrExpression - ; - -logicalAndExpressionNoln: - /* - * SPEC: - * bitwiseOrExpressionNoln - * | logicalAndExpressionNoln AMPER2 bitwiseOrExpressionNoln - */ - bitwiseOrExpressionNoln (logicalAndExpressionNolnTail)* - ; - -logicalAndExpressionNolnTail: - AMPER2 bitwiseOrExpressionNoln - ; - -logicalOrExpression: - /* - * SPEC: - * logicalAndExpression - * | logicalOrExpression '||' logicalAndExpression - */ - logicalAndExpression (logicalOrExpressionTail)* - ; - -logicalOrExpressionTail: - '||' logicalAndExpression - ; - -logicalOrExpressionNoln: - /* - * SPEC: - * logicalAndExpressionNoln - * | logicalOrExpressionNoln '||' logicalAndExpressionNoln - */ - logicalAndExpressionNoln (logicalOrExpressionNolnTail)* - ; - -logicalOrExpressionNolnTail: - '||' logicalAndExpressionNoln - ; - -conditionalExpression: - logicalOrExpression - | logicalOrExpression QUESTION assignmentExpression COLON assignmentExpression - ; - -conditionalExpressionNoln: - logicalOrExpressionNoln - | logicalOrExpressionNoln QUESTION assignmentExpressionNoln COLON assignmentExpressionNoln - ; - -assignmentExpression: - /* - * SPEC: - * conditionalExpression - * | leftHandSideExpression assignmentOperator assignmentExpression - */ - (leftHandSideExpression assignmentOperator) => - leftHandSideExpression assignmentOperator assignmentExpression - | conditionalExpression - ; - -assignmentExpressionNoln: - conditionalExpressionNoln - | leftHandSideExpression assignmentOperator assignmentExpressionNoln - ; - -assignmentOperator: - /* note that in the grammar these are listed out explicitely */ - EQ | TIMESEQ | DIVIDEEQ | PERCENTEQ | PLUSEQ | MINUSEQ | LSHIFTEQ | RSHIFTEQ - | GT3EQ | AMPEREQ | CAROTEQ | PIPEEQ - ; - -expression: - /* - * SPEC: - * assignmentExpression - * | expression COMMA assignmentExpression - */ - assignmentExpression (expressionTail)* - ; - -expressionTail: - COMMA assignmentExpression - ; - -expressionNoln: - /* - * SPEC: - * assignmentExpressionNoln - * | expressionNoln COMMA assignmentExpressionNoln - */ - assignmentExpressionNoln (expressionNolnTail)* - ; - -expressionNolnTail: - COMMA assignmentExpressionNoln - ; - -/* A.4 Statements */ - -statement: - block - | variableStatement - | emptyStatement - | expressionStatement - | ifStatement - | iterationStatement - | continueStatement - | breakStatement - | returnStatement - | withStatement - | labelledStatement - | switchStatement - | throwStatement - | tryStatement - ; - -block: - LBRACE (statementList)? RBRACE - ; - -statementList: - /* - * SPEC: - * statement - * | statementList statement - */ - (statement)+ - ; - -variableStatement: - 'var' variableDeclarationList SEMI - ; - -variableDeclarationList: - /* - * SPEC: - * variableDeclaration - * | variableDeclarationList COMMA variableDeclaration - */ - variableDeclaration (variableDeclarationTail)* - ; - -variableDeclarationTail: - COMMA variableDeclaration - ; - -variableDeclarationListNoln: - /* - * SPEC: - * variableDeclarationNoln - * | variableDeclarationListNoln COMMA variableDeclarationNoln - */ - variableDeclarationNoln (variableDeclarationListNolnTail)* - ; - -variableDeclarationListNolnTail: - COMMA variableDeclarationNoln - ; - -variableDeclaration: - identifier (initialiser)? - ; - -variableDeclarationNoln: - identifier (initialiserNoln)? - ; - -initialiser: - EQ assignmentExpression - ; - -initialiserNoln: - EQ assignmentExpressionNoln - ; - -emptyStatement: - ; - -expressionStatement: - /* [lookahead not a member of {{, function}} */ expression SEMI - ; - -ifStatement: - 'if' LPAREN expression RPAREN statement 'else' statement - | 'if' LPAREN expression RPAREN statement - ; - -iterationStatement: - 'do' statement 'while' LPAREN expression RPAREN SEMI - | 'while' LPAREN expression RPAREN statement - | 'for' LPAREN ( - (expressionNoln)? SEMI (expression)? SEMI (expression)? RPAREN statement - | 'var' variableDeclarationListNoln SEMI (expression)? SEMI (expression)? RPAREN statement - | leftHandSideExpression 'in' expression RPAREN statement - | 'var' variableDeclarationNoln 'in' expression RPAREN statement - ) - ; - -continueStatement: - 'continue' /* [ no line terminator here ] */ (identifier)? SEMI - ; - -breakStatement: - 'break' /* [ no line terminator here ] */ (identifier)? SEMI - ; - -returnStatement: - 'return' /* [no line terminator here] */ (expression)? SEMI - ; - -withStatement: - 'with' LPAREN expression RPAREN statement - ; - -switchStatement: - 'switch' LPAREN expression RPAREN caseBlock - ; - -caseBlock: - LBRACE (caseClauses)? RBRACE - | LBRACE (caseClauses)? defaultClause (caseClauses)? RBRACE - ; - -caseClauses: - /* - * SPEC: - * caseClause - * | caseClauses caseClause - */ - (caseClause)+ - ; - -caseClause: - 'case' expression COLON (statementList)? - ; - -defaultClause: - 'default' COLON (statementList)? - ; - -labelledStatement: - identifier COLON statement - ; - -throwStatement: - 'throw' /* [no line terminator here] */ expression SEMI - ; - -tryStatement: - 'try' block catch_ - | 'try' block finally_ - | 'try' block catch_ finally_ - ; - -catch_: - 'catch' LPAREN identifier RPAREN block - ; - -finally_: - 'finally' block - ; - -/* A.5 Functions and Programs */ - -functionDeclaration: - 'function' identifier LPAREN (formalParameterList)? LBRACE functionBody RBRACE - ; - -functionExpression: - 'function' (identifier)? LPAREN (formalParameterList)? LBRACE functionBody RBRACE - ; - -formalParameterList: - /* - * SPEC: - * identifier - * | formalParameterList COMMA identifier - */ - identifier (formalParameterListTail)* - ; - -formalParameterListTail: - COMMA identifier - ; - -functionBody: - sourceElements - ; - -/* -* program is actually the starting element for the grammar so I have commented -* out this one and then copied it to the very beginning as that is what the -* start really is. -*/ -/*program: - sourceElements - ;*/ - -sourceElements: - /* - * SPEC: - * sourceStatement - * | sourceElements sourceElement - */ - (sourceElement)+ - ; - -sourceElement: - statement - | functionDeclaration - ; - -/* A.6 URI character classes */ - -uri: - (uriCharacters)? - ; - -uriCharacters: - uriCharacter (uriCharacters)? - ; - -uriCharacter: - uriReserved - | uriUnescaped - | uriEscaped - ; - -uriReserved: - SEMI | SLASH | QUESTION | COLON | AT | AMPER | EQ | PLUS | DOLLAR | COMMA - ; - -uriUnescaped: - uriAlpha - | decimalDigit - | uriMark - ; - -uriEscaped: - PERCENT hexDigit hexDigit - ; - -uriAlpha: - ALPHA_CHARACTER /* consists of a-zA-Z */ - ; - -uriMark: - MINUS | UNDERSCORE | DOT | EXCLAMATION | TILDE | ASTERISK | APOSTROPHE | LPAREN | RPAREN - ; - -/* A.7 Regular Exrpessions */ - -patter: - disjunction - ; - -disjunction: - alternative - | alternative PIPE disjunction - ; - -alternative: - /* - * SPEC: - * -empty- - *| alternative term - */ - (term)* - ; - -term: - assertion - | atom - | atom quantifier - ; - -assertion: - CAROT - | DOLLAR - | '\\b' /* double check this - looks like a space in the manual? */ - | '\\B' /* double check this - looks like a space in the manual? */ - ; - -quantifier: - quantifierPrefix - | quantifierPrefix QUESTION - ; - -quantifierPrefix: - ASTERISK - | PLUS - | QUESTION - | LBRACE decimalDigits RBRACE - | LBRACE decimalDigits COMMA RBRACE - | LBRACE decimalDigits COMMA decimalDigits RBRACE - ; - -atom: - patternCharacter - | DOT - | BSLASH atomEscape - | characterClass - | LPAREN ((COLON|EQ|EXCLAMATION)? disjunction) RPAREN - ; - -patternCharacter: - sourceCharacter /* but not any of: - ^ $ \ . * + ? ( ) [ ] { } | - */ - ; - -atomEscape: - decimalEscape - | characterEscape - | characterClassEscape - ; - -characterEscape: - controlEscape - | LOWER_C controlLetter - | hexEscapeSequence - | unicodeEscapeSequence - | identityEscape - ; - -controlEscape: - CONTROL_ESCAPE_CHAR /* one of: fnrtv */ - ; - -controlLetter: - /* one of: a-z A-Z */ - LOWER_ALPHA_CHAR - | UPPER_ALPHA_CHAR - ; - -identityEscape: - sourceCharacter /* but not identifierPart */ - ; - -characterClassEscape: - 'd' | 'D' | 's' | 'S' | 'w' | 'W' - ; - -decimalEscape: - decimalIntegerLiteral /* lookahead not a member of decimalDigit */ - ; - -characterClass: - /* [ [lookahead not a member of {^}] ClassRanges ] - | [ ^ classRanges ] - */ - ; - -classRanges: - /* empty */ - | nonemptyClassRanges - ; - -nonemptyClassRanges: - classAtom - | classAtom nonemptyClassRangesNoDash - | classAtom MINUS classAtom classRanges - ; - -nonemptyClassRangesNoDash: - classAtom - | classAtomNoDash nonemptyClassRangesNoDash - | classAtomNoDash MINUS classAtom classRanges - ; - -classAtom: - MINUS - | classAtomNoDash - ; - -classAtomNoDash: - sourceCharacter /* but not one of: \ ] - */ - | BSLASH classEscape - ; - -classEscape: - decimalEscape - | LOWER_B - | characterEscape - | characterClassEscape - ; - - - -/* a few basic characters and other things that I am going to see */ - -SEMI: ';'; -MPER: '&'; -//DASH: '-'; -EQ: '='; -COMMA: ','; -SLASH: '/'; -BSLASH: '\\'; -LBRACK: '['; -RBRACK: ']'; -LBRACE: '{'; -RBRACE: '}'; -LPAREN: '('; -RPAREN: ')'; -APOSTROPHE: '\''; -QUOTE: '"'; -QUESTION: '?'; -COLON: ':'; -ASTERISK: '*'; -AT : '@'; -AMPER : '&'; -PLUS : '+'; -MINUS:'-'; -DOLLAR : '$'; -UNDERSCORE:'_'; -DOT : '.'; -LT : '<'; -GT : '>'; -LTEQ: '<='; -GTEQ : '>='; -EQ2 : '=='; -NOTEQ: '!='; -EQ3 : '==='; -NOTEQ2: '!=='; -STAR:'*'; -PERCENT : '%'; -PLUS2:'++'; -MINUS2:'--'; -LSHIFT:'<<'; -RSHIFT:'>>'; -GT3:'>>>'; -PIPE : '|'; -CAROT : '^'; -EXCLAMATION: '!'; -TILDE:'~'; -AMPER2:'&&'; -PIPE2 : '||'; -PLUSEQ:'+='; -MINUSEQ:'-='; -TIMESEQ:'*='; -PERCENTEQ:'%='; -LSHIFTEQ:'<<='; -RSHIFTEQ: '>>='; -GT3EQ : '>>>='; -AMPEREQ:'&='; -PIPEEQ : '|='; -CAROTEQ : '^='; -DIVIDE : '/'; -DIVIDEEQ: '/='; - -ZERO : '0'; -NON_ZERO_DIGIT - : ('1'..'9'); -DIGIT : ('0'..'9'); -EXPONENT_INDICATOR - : 'e'|'E'; - -CONTROL_ESCAPE_CHAR - : 'f'|'n'|'r'|'t'|'v'; /* one of: fnrtv */ - -LOWER_B: 'b'; -LOWER_C : 'c'; -LOWER_F: 'f'; -LOWER_N: 'n'; -LOWER_R: 'r'; -LOWER_T: 't'; -LOWER_V: 'v'; -LOWER_X: 'x'; -LOWER_U: 'u'; - -ALPHA_CHARACTER - : ('a'..'z')|('A'..'Z'); -LOWER_ALPHA_CHAR - : ('a'..'z'); - -UPPER_ALPHA_CHAR - : ('a'..'z'); - -WS: // ignore white space as it doesn't matter - ( ' ' | '\r' '\n' {newline();}| '\n' {newline();} | '\t' ) { $setType(Token.SKIP); } - ; - -SOURCE_CHAR: ('\u0000'..'\uFFFE'); -TAB: '\u0009'; -VT: '\u000b'; -FF: '\u000c'; -SP: '\u0020'; -NBSP: '\u00a0'; -USP: '\u1680' // OGHAM SPACE MARK - | '\u2000' // EN QUAD - | '\u2001' // EM QUAD - | '\u2002' // EN SPACE - | '\u2003' // EM SPACE - | '\u2004' // THREE-PER-EM SPACE - | '\u2005' // FOUR-PER-EM SPACE - | '\u2006' // SIX-PER-EM SPACE - | '\u2007' // FIGURE SPACE - | '\u2008' // PUNCTUATION SPACE - | '\u2009' // THIN SPACE - | '\u200A' // HAIR SPACE - | '\u200B' // ZERO WIDTH SPACE - | '\u202F' // NARROW NO-BREAK SPACE - | '\u3000' // IDEOGRAPHIC SPACE - ; - -LF: '\u000a'; // line feed -CR: '\u000d'; // carriage return -LS: '\u2028'; // line separator -PS: '\u2029'; // paragraph separator - -UNICODE_LETTER: - ('\u0041'..'\u005A') | ('\u0061'..'\u007A') | '\u00AA' | '\u00B5' - | '\u00BA' | ('\u00C0'..'\u00D6') | ('\u00D8'..'\u00F6') | ('\u00F8'..'\u021F') - | ('\u0222'..'\u0233') | ('\u0250'..'\u02AD') | ('\u02B0'..'\u02B8') | ('\u02BB'..'\u02C1') - | ('\u02D0'..'\u02D1') | ('\u02E0'..'\u02E4') | '\u02EE' | '\u037A' - | '\u0386' | ('\u0388'..'\u038A') | '\u038C' | ('\u038E'..'\u03A1') - | ('\u03A3'..'\u03CE') | ('\u03D0'..'\u03D7') | ('\u03DA'..'\u03F3') | ('\u0400'..'\u0481') - | ('\u048C'..'\u04C4') | ('\u04C7'..'\u04C8') | ('\u04CB'..'\u04CC') | ('\u04D0'..'\u04F5') - | ('\u04F8'..'\u04F9') | ('\u0531'..'\u0556') | '\u0559' |('\u0561'..'\u0587') - | ('\u05D0'..'\u05EA') | ('\u05F0'..'\u05F2') | ('\u0621'..'\u063A') |('\u0640'..'\u064A') - | ('\u0671'..'\u06D3') | '\u06D5' | ('\u06E5'..'\u06E6') |('\u06FA'..'\u06FC') - | '\u0710' | ('\u0712'..'\u072C') | ('\u0780'..'\u07A5') |('\u0905'..'\u0939') - | '\u093D' | '\u0950' | ('\u0958'..'\u0961') |('\u0985'..'\u098C') - | ('\u098F'..'\u0990') | ('\u0993'..'\u09A8') | ('\u09AA'..'\u09B0') | '\u09B2' - | ('\u09B6'..'\u09B9') | ('\u09DC'..'\u09DD') | ('\u09DF'..'\u09E1') |('\u09F0'..'\u09F1') - | ('\u0A05'..'\u0A0A') | ('\u0A0F'..'\u0A10') | ('\u0A13'..'\u0A28') |('\u0A2A'..'\u0A30') - | ('\u0A32'..'\u0A33') | ('\u0A35'..'\u0A36') | ('\u0A38'..'\u0A39') |('\u0A59'..'\u0A5C') - | '\u0A5E' | ('\u0A72'..'\u0A74') | ('\u0A85'..'\u0A8B') | '\u0A8D' - | ('\u0A8F'..'\u0A91') | ('\u0A93'..'\u0AA8') | ('\u0AAA'..'\u0AB0') |('\u0AB2'..'\u0AB3') - | ('\u0AB5'..'\u0AB9') | '\u0ABD' | '\u0AD0' | '\u0AE0' - | ('\u0B05'..'\u0B0C') | ('\u0B0F'..'\u0B10') | ('\u0B13'..'\u0B28') |('\u0B2A'..'\u0B30') - | ('\u0B32'..'\u0B33') | ('\u0B36'..'\u0B39') | '\u0B3D' |('\u0B5C'..'\u0B5D') - | ('\u0B5F'..'\u0B61') | ('\u0B85'..'\u0B8A') | ('\u0B8E'..'\u0B90') |('\u0B92'..'\u0B95') - | ('\u0B99'..'\u0B9A') | '\u0B9C' | ('\u0B9E'..'\u0B9F') |('\u0BA3'..'\u0BA4') - | ('\u0BA8'..'\u0BAA') | ('\u0BAE'..'\u0BB5') | ('\u0BB7'..'\u0BB9') |('\u0C05'..'\u0C0C') - | ('\u0C0E'..'\u0C10') | ('\u0C12'..'\u0C28') | ('\u0C2A'..'\u0C33') |('\u0C35'..'\u0C39') - | ('\u0C60'..'\u0C61') | ('\u0C85'..'\u0C8C') | ('\u0C8E'..'\u0C90') |('\u0C92'..'\u0CA8') - | ('\u0CAA'..'\u0CB3') | ('\u0CB5'..'\u0CB9') | '\u0CDE' |('\u0CE0'..'\u0CE1') - | ('\u0D05'..'\u0D0C') | ('\u0D0E'..'\u0D10') | ('\u0D12'..'\u0D28') |('\u0D2A'..'\u0D39') - | ('\u0D60'..'\u0D61') | ('\u0D85'..'\u0D96') | ('\u0D9A'..'\u0DB1') |('\u0DB3'..'\u0DBB') - | '\u0DBD' | ('\u0DC0'..'\u0DC6') | ('\u0E01'..'\u0E30') |('\u0E32'..'\u0E33') - | ('\u0E40'..'\u0E46') | ('\u0E81'..'\u0E82') | '\u0E84' |('\u0E87'..'\u0E88') - | '\u0E8A' | '\u0E8D' | ('\u0E94'..'\u0E97') |('\u0E99'..'\u0E9F') - | ('\u0EA1'..'\u0EA3') | '\u0EA5' | '\u0EA7' |('\u0EAA'..'\u0EAB') - | ('\u0EAD'..'\u0EB0') | ('\u0EB2'..'\u0EB3') | ('\u0EBD'..'\u0EC4') | '\u0EC6' - | ('\u0EDC'..'\u0EDD') | '\u0F00' | ('\u0F40'..'\u0F6A') |('\u0F88'..'\u0F8B') - | ('\u1000'..'\u1021') | ('\u1023'..'\u1027') | ('\u1029'..'\u102A') |('\u1050'..'\u1055') - | ('\u10A0'..'\u10C5') | ('\u10D0'..'\u10F6') | ('\u1100'..'\u1159') |('\u115F'..'\u11A2') - | ('\u11A8'..'\u11F9') | ('\u1200'..'\u1206') | ('\u1208'..'\u1246') | '\u1248' - | ('\u124A'..'\u124D') | ('\u1250'..'\u1256') | '\u1258' |('\u125A'..'\u125D') - | ('\u1260'..'\u1286') | '\u1288' | ('\u128A'..'\u128D') |('\u1290'..'\u12AE') - | '\u12B0' | ('\u12B2'..'\u12B5') | ('\u12B8'..'\u12BE') | '\u12C0' - | ('\u12C2'..'\u12C5') | ('\u12C8'..'\u12CE') | ('\u12D0'..'\u12D6') |('\u12D8'..'\u12EE') - | ('\u12F0'..'\u130E') | '\u1310' | ('\u1312'..'\u1315') |('\u1318'..'\u131E') - | ('\u1320'..'\u1346') | ('\u1348'..'\u135A') | ('\u13A0'..'\u13B0') |('\u13B1'..'\u13F4') - | ('\u1401'..'\u1676') | ('\u1681'..'\u169A') | ('\u16A0'..'\u16EA') |('\u1780'..'\u17B3') - | ('\u1820'..'\u1877') | ('\u1880'..'\u18A8') | ('\u1E00'..'\u1E9B') |('\u1EA0'..'\u1EE0') - | ('\u1EE1'..'\u1EF9') | ('\u1F00'..'\u1F15') | ('\u1F18'..'\u1F1D') |('\u1F20'..'\u1F39') - | ('\u1F3A'..'\u1F45') | ('\u1F48'..'\u1F4D') | ('\u1F50'..'\u1F57') | '\u1F59' - | '\u1F5B' | '\u1F5D' | ('\u1F5F'..'\u1F7D') | ('\u1F80'..'\u1FB4') - | ('\u1FB6'..'\u1FBC') | '\u1FBE' | ('\u1FC2'..'\u1FC4') | ('\u1FC6'..'\u1FCC') - | ('\u1FD0'..'\u1FD3') | ('\u1FD6'..'\u1FDB') | ('\u1FE0'..'\u1FEC') | ('\u1FF2'..'\u1FF4') - | ('\u1FF6'..'\u1FFC') | '\u207F' | '\u2102' | '\u2107' - | ('\u210A'..'\u2113') | '\u2115' | ('\u2119'..'\u211D') | '\u2124' - | '\u2126' | '\u2128' | ('\u212A'..'\u212D') | ('\u212F'..'\u2131') - | ('\u2133'..'\u2139') | ('\u2160'..'\u2183') | ('\u3005'..'\u3007') | ('\u3021'..'\u3029') - | ('\u3031'..'\u3035') | ('\u3038'..'\u303A') | ('\u3041'..'\u3094') | ('\u309D'..'\u309E') - | ('\u30A1'..'\u30FA') | ('\u30FC'..'\u30FE') | ('\u3105'..'\u312C') | ('\u3131'..'\u318E') - | ('\u31A0'..'\u31B7') | '\u3400' | '\u4DB5' | '\u4E00' - | '\u9FA5' | ('\uA000'..'\uA48C') | '\uAC00' | '\uD7A3' - | ('\uF900'..'\uFA2D') | ('\uFB00'..'\uFB06') | ('\uFB13'..'\uFB17') | '\uFB1D' - | ('\uFB1F'..'\uFB28') | ('\uFB2A'..'\uFB36') | ('\uFB38'..'\uFB3C') | '\uFB3E' - | ('\uFB40'..'\uFB41') | ('\uFB43'..'\uFB44') | ('\uFB46'..'\uFBB1') | ('\uFBD3'..'\uFD3D') - | ('\uFD50'..'\uFD8F') | ('\uFD92'..'\uFDC7') | ('\uFDF0'..'\uFDFB') | ('\uFE70'..'\uFE72') - | '\uFE74' | ('\uFE76'..'\uFEFC') | ('\uFF21'..'\uFF3A') | ('\uFF41'..'\uFF5A') - | ('\uFF66'..'\uFFBE') | ('\uFFC2'..'\uFFC7') | ('\uFFCA'..'\uFFCF') | ('\uFFD2'..'\uFFD7') - | ('\uFFDA'..'\uFFDC') - ; - -HEXDIGIT: ('0'..'9')|('a'..'f')|('A'..'F'); - -UNICODE_DIGIT: - ('\u0030'..'\u0039') | ('\u0660'..'\u0669') | ('\u06F0'..'\u06F9') | ('\u0966'..'\u096F') - | ('\u09E6'..'\u09EF') | ('\u0A66'..'\u0A6F') | ('\u0AE6'..'\u0AEF') | ('\u0B66'..'\u0B6F') - | ('\u0BE7'..'\u0BEF') | ('\u0C66'..'\u0C6F') | ('\u0CE6'..'\u0CEF') | ('\u0D66'..'\u0D6F') - | ('\u0E50'..'\u0E59') | ('\u0ED0'..'\u0ED9') | ('\u0F20'..'\u0F29') | ('\u1040'..'\u1049') - | ('\u1369'..'\u1371') | ('\u17E0'..'\u17E9') | ('\u1810'..'\u1819') | ('\uFF10'..'\uFF19') - ; - -UNICODE_NONSPACING_MARK - : ('\u0300'..'\u036F'); // And more... see: http://www.fileformat.info/info/unicode/category/Mn/list.htm - -UNICODE_COMBINING_MARK: // Appears to be bogus... see: http://www.fileformat.info/info/unicode/category/Mc/list.htm - ('\u0300'..'\u034E') | ('\u0360'..'\u0362') | ('\u0483'..'\u0486') | ('\u0591'..'\u05A1') - | ('\u05A3'..'\u05B9') | ('\u05BB'..'\u05BD') | '\u05BF' | ('\u05C1'..'\u05C2') - | '\u05C4' | ('\u064B'..'\u0655') | '\u0670' | ('\u06D6'..'\u06DC') - | ('\u06DF'..'\u06E4') | ('\u06E7'..'\u06E8') | ('\u06EA'..'\u06ED') | '\u0711' - | ('\u0730'..'\u074A') | ('\u07A6'..'\u07B0') | ('\u0901'..'\u0903') | '\u093C' - | ('\u093E'..'\u094D') | ('\u0951'..'\u0954') | ('\u0962'..'\u0963') | ('\u0981'..'\u0983') - | ('\u09BC'..'\u09C4') | ('\u09C7'..'\u09C8') | ('\u09CB'..'\u09CD') | '\u09D7' - | ('\u09E2'..'\u09E3') | '\u0A02' | '\u0A3C' | ('\u0A3E'..'\u0A42') - | ('\u0A47'..'\u0A48') | ('\u0A4B'..'\u0A4D') | ('\u0A70'..'\u0A71') | ('\u0A81'..'\u0A83') - | '\u0ABC' | ('\u0ABE'..'\u0AC5') | ('\u0AC7'..'\u0AC9') | ('\u0ACB'..'\u0ACD') - | ('\u0B01'..'\u0B03') | '\u0B3C' | ('\u0B3E'..'\u0B43') | ('\u0B47'..'\u0B48') - | ('\u0B4B'..'\u0B4D') | ('\u0B56'..'\u0B57') | ('\u0B82'..'\u0B83') | ('\u0BBE'..'\u0BC2') - | ('\u0BC6'..'\u0BC8') | ('\u0BCA'..'\u0BCD') | '\u0BD7' | ('\u0C01'..'\u0C03') - | ('\u0C3E'..'\u0C44') | ('\u0C46'..'\u0C48') | ('\u0C4A'..'\u0C4D') | ('\u0C55'..'\u0C56') - | ('\u0C82'..'\u0C83') | ('\u0CBE'..'\u0CC4') | ('\u0CC6'..'\u0CC8') | ('\u0CCA'..'\u0CCD') - | ('\u0CD5'..'\u0CD6') | ('\u0D02'..'\u0D03') | ('\u0D3E'..'\u0D43') | ('\u0D46'..'\u0D48') - | ('\u0D4A'..'\u0D4D') | '\u0D57' | ('\u0D82'..'\u0D83') | '\u0DCA' - | ('\u0DCF'..'\u0DD4') | '\u0DD6' | ('\u0DD8'..'\u0DDF') | ('\u0DF2'..'\u0DF3') - | '\u0E31' | ('\u0E34'..'\u0E3A') | ('\u0E47'..'\u0E4E') | '\u0EB1' - | ('\u0EB4'..'\u0EB9') | ('\u0EBB'..'\u0EBC') | ('\u0EC8'..'\u0ECD') | ('\u0F18'..'\u0F19') - | '\u0F35' | '\u0F37' | '\u0F39' | ('\u0F3E'..'\u0F3F') - | ('\u0F71'..'\u0F84') | ('\u0F86'..'\u0F87') | ('\u0F90'..'\u0F97') | ('\u0F99'..'\u0FBC') - | '\u0FC6' | ('\u102C'..'\u1032') | ('\u1036'..'\u1039') | ('\u1056'..'\u1059') - | ('\u17B4'..'\u17D3') | '\u18A9' | ('\u20D0'..'\u20DC') | '\u20E1' - | ('\u302A'..'\u302F') | ('\u3099'..'\u309A') | '\uFB1E' | ('\uFE20'..'\uFE23') - ; - -UNICODE_CONNECTOR_PUNCTUATION: - '\u005F' | ('\u203F'..'\u2040') | '\u30FB' | ('\uFE33'..'\uFE34') | ('\uFE4D'..'\uFE4F') - | '\uFF3F' | '\uFF65' - ; \ No newline at end of file diff --git a/test/web.html b/test/web.html index d26a1445d..ec16a13d6 100644 --- a/test/web.html +++ b/test/web.html @@ -28,6 +28,7 @@ } +
@@ -53,8 +54,7 @@
graph LR; - A---|This is the text|B; + A---|This is the 123 s -text|B;
- \ No newline at end of file