├── doc └── digraph.png ├── src ├── index.js ├── load.js └── dot-parser.js ├── rollup.config.js ├── example ├── summary.dot └── index.html ├── package.json ├── LICENSE ├── .gitignore ├── README.md └── grammar └── dot.pegjs /doc/digraph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gmamaladze/d3-dot-graph/HEAD/doc/digraph.png -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import load from "./load.js"; 4 | 5 | d3.dot = load; 6 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | input: "src/index.js", 3 | name: "d3dot", 4 | context: "window", 5 | output: { 6 | format: "umd", 7 | file: "build/d3-dot-graph.js" 8 | } 9 | }; 10 | -------------------------------------------------------------------------------- /example/summary.dot: -------------------------------------------------------------------------------- 1 | digraph "summary" { 2 | "ui" -> "java.desktop (java.desktop)"; 3 | "ui" -> "logic"; 4 | "ui" -> "model"; 5 | "logic" -> "data"; 6 | "logic" -> "model"; 7 | "app" -> "logic"; 8 | "app" -> "ui"; 9 | "model" -> "java.xml (java.xml)"; 10 | "data" -> "java.sql (java.sql)"; 11 | "data" -> "model"; 12 | "api" -> "data"; 13 | "api" -> "logic"; 14 | } 15 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "d3-dot-graph", 3 | "version": "1.0.0", 4 | "description": "D3js compatible library to parse and load files in graphviz .dot (graph description language) format.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "mocha test/*.js", 8 | "build": "pegjs --format globals --export-var d3dotparser1 --output src/dot-parser.js grammar/dot.pegjs; rollup -c", 9 | "prepublish": "rollup -c && uglifyjs build/d3-dot-graph.js -c negate_iife=false -m -o build/d3-dot-graph.min.js", 10 | "start": "npm run build" 11 | }, 12 | "keywords": [ 13 | "dot", 14 | "graphviz", 15 | "d3", 16 | "graph" 17 | ], 18 | "repository": { 19 | "type": "git", 20 | "url": "git+https://github.com/gmamaladze/d3-dot-graph.git" 21 | }, 22 | "author": "George Mamaladze", 23 | "license": "MIT", 24 | "bugs": { 25 | "url": "https://github.com/gmamaladze/d3-dot-graph/issues" 26 | }, 27 | "homepage": "https://github.com/gmamaladze/d3-dot-graph#readme", 28 | "dependencies": { 29 | "pegjs": "^0.10.0", 30 | "rollup": "^0.49.2", 31 | "rollup-watch": "^4.3.1" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 George Mamaladze 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # MacOsX 61 | .DS_Store 62 | -------------------------------------------------------------------------------- /src/load.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import "./dot-parser.js"; 4 | 5 | const dotparser = d3dotparser1; 6 | 7 | export default function(url, converter, callback) { 8 | if (arguments.length < 3) callback = converter, converter = simple; 9 | var r = d3 10 | .request(url) 11 | .mimeType("text/vnd.graphviz") 12 | .response(function(xhr) { 13 | return converter(dotparser.parse(xhr.responseText)); }); 14 | return callback ? r.get(callback) : r; 15 | }; 16 | 17 | function simple(dotgraph) { 18 | 19 | let nodeMap = {}; 20 | function addNode(node) { 21 | if (nodeMap[node.id]) return; 22 | nodeMap[node.id] = node; 23 | } 24 | 25 | if (dotgraph.length===0) return null; 26 | let fgraph = dotgraph[0]; 27 | 28 | fgraph.stmts.filter((s) => s.type === "node" ).forEach(addNode); 29 | let edges = fgraph.stmts.filter((s) => s.type === "edge" ); 30 | let links = []; 31 | for(let i=0; i Object.assign({id:n.id}, n.attrs)); 44 | return { 45 | nodes, 46 | links 47 | }; 48 | } 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # d3-dot-graph 2 | 3 | This module provides [D3js][d3js] compatible library to parse and load files in [graphviz][graphviz] [DOT (.dot)][dot] (graph description language) format. 4 | 5 | ## why? 6 | While working on [Java Platform Module System][jpms] migration projects coming with Java 9 (as of August 2017), I am heavily using [jdeps][jdeps] which is generating [DOT (.dot)][dot] files. These are usually visualised using dot tool of [graphviz][graphviz]. 7 | 8 | In most cases it is enough, but I wanted to have nicer [D3js][d3js] visualisation and interaction. 9 | 10 | ## example 11 | 12 | See sample `summary.dot` file generated by [jdeps][jdeps] visualised using [D3js][d3js] here: [index.html][example] 13 | 14 | ![](doc/digraph.png "Sample .dot file generated by jdeps visualised using D3js") 15 | 16 | Inspired by Mike Bostock's [Mobile Patent Suits][mbostock] 17 | 18 | ## usage 19 | 20 | ```js 21 | d3.dot(url, callback); 22 | ``` 23 | 24 | Usage is identical with well known `d3.json([url], [callback])` or `d3.csv([url], [callback])`. 25 | 26 | ```html 27 | 28 | 40 | ``` 41 | 42 | ## parser 43 | 44 | The parser was generated using [PEG.js][pegjs]. The grammer is taken from here [cpettitt/graphlib-dot](https://github.com/cpettitt/graphlib-dot). Thanks to Chris Pettitt. 45 | 46 | You can also use parser independently from loader and converter. 47 | 48 | ## build 49 | 50 | ```shell 51 | npm install #install dependencies and build 52 | npm run build #generate parser, and rollup 53 | 54 | rollup -c -w (rollup --config --watch) #very convenient rolls the whenever sources are changed 55 | ``` 56 | 57 | 58 | [d3js]: https://www.d3js.org 59 | [dot]: https://en.wikipedia.org/wiki/DOT_(graph_description_language) 60 | [pegjs]: https://pegjs.org 61 | [jpms]: http://openjdk.java.net/projects/jigsaw/spec/sotms 62 | [jdeps]: https://docs.oracle.com/javase/9/tools/jdeps.htm 63 | [graphviz]: http://www.graphviz.org 64 | [mbostock]: http://bl.ocks.org/mbostock/1153292 65 | [example]: https://cdn.rawgit.com/gmamaladze/d3-dot-graph/cf08847e/example/index.html 66 | -------------------------------------------------------------------------------- /example/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 24 | 25 | 26 | 27 | 138 | -------------------------------------------------------------------------------- /grammar/dot.pegjs: -------------------------------------------------------------------------------- 1 | // Simplified DOT grammar 2 | // 3 | // Not supported (yet): 4 | // 5 | // * HTML IDs 6 | 7 | { 8 | function merge(a, b, key) { 9 | 10 | function x(a) { 11 | a.forEach(function (b) { 12 | if (!(b[key] in obj)) { 13 | obj[b[key]] = obj[b[key]] || {}; 14 | array.push(obj[b[key]]); 15 | } 16 | Object.keys(b).forEach(function (k) { 17 | obj[b[key]][k] = b[k]; 18 | }); 19 | }); 20 | } 21 | 22 | var array = [], 23 | obj = {}; 24 | 25 | x(a); 26 | x(b); 27 | return array; 28 | } 29 | 30 | var directed; 31 | } 32 | 33 | start 34 | = graphStmt+ 35 | 36 | graphStmt 37 | = _* strict:(strict _)? type:graphType _* id:(id)? _* '{' _* stmts:stmtList? _* '}' _* { 38 | return {type: type, id: id, strict: strict !== null, stmts: stmts}; 39 | } 40 | 41 | stmtList 42 | = first:stmt _* ';'? rest:(_* inner:stmt _* ';'?)* { 43 | var result = [first]; 44 | for (var i = 0; i < rest.length; ++i) { 45 | result.push(rest[i][1]); 46 | } 47 | return result; 48 | } 49 | 50 | stmt 51 | = attrStmt 52 | / edgeStmt 53 | / subgraphStmt 54 | / inlineAttrStmt 55 | / nodeStmt 56 | 57 | attrStmt 58 | = type:(graph / node /edge) _* attrs:attrList { 59 | return { type: "attr", attrType: type, attrs: attrs || {}}; 60 | } 61 | 62 | inlineAttrStmt 63 | = k:id _* '=' _* v:id { 64 | var attrs = {}; 65 | attrs[k] = v; 66 | return { type: "inlineAttr", attrs: attrs }; 67 | } 68 | 69 | nodeStmt 70 | = id:nodeId _* attrs:attrList? { return {type: "node", id: id, attrs: attrs || {}}; } 71 | 72 | edgeStmt 73 | = lhs:(nodeIdOrSubgraph) _* rhs:edgeRHS _* attrs:attrList? { 74 | var elems = [lhs]; 75 | for (var i = 0; i < rhs.length; ++i) { 76 | elems.push(rhs[i]); 77 | } 78 | return { type: "edge", elems: elems, attrs: attrs || {} }; 79 | } 80 | 81 | subgraphStmt 82 | = id:(subgraph _* (id _*)?)? '{' _* stmts:stmtList? _* '}' { 83 | id = (id && id[2]) || []; 84 | return { type: "subgraph", id: id[0], stmts: stmts }; 85 | } 86 | 87 | attrList 88 | = first:attrListBlock rest:(_* attrListBlock)* { 89 | var result = first; 90 | for (var i = 0; i < rest.length; ++i) { 91 | merge(result, rest[i][1]); 92 | } 93 | return result; 94 | } 95 | 96 | attrListBlock 97 | = '[' _* aList:aList? _* ']' { return aList; } 98 | 99 | aList 100 | = first:idDef rest:(_* ','? _* idDef)* { 101 | var result = first; 102 | for (var i = 0; i < rest.length; ++i) { 103 | _.merge(result, rest[i][3]); 104 | } 105 | return result; 106 | } 107 | 108 | edgeRHS 109 | = ("--" !{ return directed; } / "->" &{ return directed; }) _* rhs:(nodeIdOrSubgraph) _* rest:edgeRHS? { 110 | var result = [rhs]; 111 | if (rest) { 112 | for (var i = 0; i < rest.length; ++i) { 113 | result.push(rest[i]); 114 | } 115 | } 116 | return result; 117 | } 118 | 119 | idDef 120 | = k:id v:(_* '=' _* id)? { 121 | var result = {}; 122 | result[k] = v[3]; 123 | return result; 124 | } 125 | 126 | nodeIdOrSubgraph 127 | = subgraphStmt 128 | / id:nodeId { return { type: "node", id: id, attrs: {} }; } 129 | 130 | nodeId 131 | = id:id _* port? { return id; } 132 | 133 | port 134 | = ':' _* id _* (':' _* compassPt)? 135 | 136 | compassPt 137 | = "ne" / "se" / "sw" / "nw" / "n" / "e" / "s" / "w" / "c" / "_" 138 | 139 | id "identifier" 140 | = fst:[a-zA-Z\u0200-\u0377_] rest:[a-zA-Z\u0200-\u0377_0-9]* { return fst + rest.join(""); } 141 | / sign:'-'? dot:'.' after:[0-9]+ { 142 | return (sign || "") + dot + after.join(""); 143 | } 144 | / sign:'-'? before:[0-9]+ after:('.' [0-9]*)? { 145 | return (sign || "") + before.join("") + (after ? after[0] : "") + (after ? after[1].join("") : ""); 146 | } 147 | / '"' id:("\\\"" { return '"'; } / "\\" ch:[^"] { return "\\" + ch; } / [^"])* '"' { 148 | return id.join(""); 149 | } 150 | 151 | node = k:"node"i { return k.toLowerCase(); } 152 | edge = k:"edge"i { return k.toLowerCase(); } 153 | graph = k:"graph"i { return k.toLowerCase(); } 154 | digraph = k:"digraph"i { return k.toLowerCase(); } 155 | subgraph = k:"subgraph"i { return k.toLowerCase(); } 156 | strict = k:"strict"i { return k.toLowerCase(); } 157 | 158 | graphType 159 | = graph:graph / graph:digraph { 160 | directed = graph === "digraph"; 161 | return graph; 162 | } 163 | 164 | whitespace "whitespace" 165 | = [ \t\r\n]+ 166 | 167 | comment "comment" 168 | = "//" ([^\n])* 169 | / "/*" (!"*/" .)* "*/" 170 | 171 | _ 172 | = whitespace 173 | / comment 174 | -------------------------------------------------------------------------------- /src/dot-parser.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Generated by PEG.js 0.10.0. 3 | * 4 | * http://pegjs.org/ 5 | */ 6 | (function(root) { 7 | "use strict"; 8 | 9 | function peg$subclass(child, parent) { 10 | function ctor() { this.constructor = child; } 11 | ctor.prototype = parent.prototype; 12 | child.prototype = new ctor(); 13 | } 14 | 15 | function peg$SyntaxError(message, expected, found, location) { 16 | this.message = message; 17 | this.expected = expected; 18 | this.found = found; 19 | this.location = location; 20 | this.name = "SyntaxError"; 21 | 22 | if (typeof Error.captureStackTrace === "function") { 23 | Error.captureStackTrace(this, peg$SyntaxError); 24 | } 25 | } 26 | 27 | peg$subclass(peg$SyntaxError, Error); 28 | 29 | peg$SyntaxError.buildMessage = function(expected, found) { 30 | var DESCRIBE_EXPECTATION_FNS = { 31 | literal: function(expectation) { 32 | return "\"" + literalEscape(expectation.text) + "\""; 33 | }, 34 | 35 | "class": function(expectation) { 36 | var escapedParts = "", 37 | i; 38 | 39 | for (i = 0; i < expectation.parts.length; i++) { 40 | escapedParts += expectation.parts[i] instanceof Array 41 | ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) 42 | : classEscape(expectation.parts[i]); 43 | } 44 | 45 | return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; 46 | }, 47 | 48 | any: function(expectation) { 49 | return "any character"; 50 | }, 51 | 52 | end: function(expectation) { 53 | return "end of input"; 54 | }, 55 | 56 | other: function(expectation) { 57 | return expectation.description; 58 | } 59 | }; 60 | 61 | function hex(ch) { 62 | return ch.charCodeAt(0).toString(16).toUpperCase(); 63 | } 64 | 65 | function literalEscape(s) { 66 | return s 67 | .replace(/\\/g, '\\\\') 68 | .replace(/"/g, '\\"') 69 | .replace(/\0/g, '\\0') 70 | .replace(/\t/g, '\\t') 71 | .replace(/\n/g, '\\n') 72 | .replace(/\r/g, '\\r') 73 | .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) 74 | .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); 75 | } 76 | 77 | function classEscape(s) { 78 | return s 79 | .replace(/\\/g, '\\\\') 80 | .replace(/\]/g, '\\]') 81 | .replace(/\^/g, '\\^') 82 | .replace(/-/g, '\\-') 83 | .replace(/\0/g, '\\0') 84 | .replace(/\t/g, '\\t') 85 | .replace(/\n/g, '\\n') 86 | .replace(/\r/g, '\\r') 87 | .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) 88 | .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); 89 | } 90 | 91 | function describeExpectation(expectation) { 92 | return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); 93 | } 94 | 95 | function describeExpected(expected) { 96 | var descriptions = new Array(expected.length), 97 | i, j; 98 | 99 | for (i = 0; i < expected.length; i++) { 100 | descriptions[i] = describeExpectation(expected[i]); 101 | } 102 | 103 | descriptions.sort(); 104 | 105 | if (descriptions.length > 0) { 106 | for (i = 1, j = 1; i < descriptions.length; i++) { 107 | if (descriptions[i - 1] !== descriptions[i]) { 108 | descriptions[j] = descriptions[i]; 109 | j++; 110 | } 111 | } 112 | descriptions.length = j; 113 | } 114 | 115 | switch (descriptions.length) { 116 | case 1: 117 | return descriptions[0]; 118 | 119 | case 2: 120 | return descriptions[0] + " or " + descriptions[1]; 121 | 122 | default: 123 | return descriptions.slice(0, -1).join(", ") 124 | + ", or " 125 | + descriptions[descriptions.length - 1]; 126 | } 127 | } 128 | 129 | function describeFound(found) { 130 | return found ? "\"" + literalEscape(found) + "\"" : "end of input"; 131 | } 132 | 133 | return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; 134 | }; 135 | 136 | function peg$parse(input, options) { 137 | options = options !== void 0 ? options : {}; 138 | 139 | var peg$FAILED = {}, 140 | 141 | peg$startRuleFunctions = { start: peg$parsestart }, 142 | peg$startRuleFunction = peg$parsestart, 143 | 144 | peg$c0 = "{", 145 | peg$c1 = peg$literalExpectation("{", false), 146 | peg$c2 = "}", 147 | peg$c3 = peg$literalExpectation("}", false), 148 | peg$c4 = function(strict, type, id, stmts) { 149 | return {type: type, id: id, strict: strict !== null, stmts: stmts}; 150 | }, 151 | peg$c5 = ";", 152 | peg$c6 = peg$literalExpectation(";", false), 153 | peg$c7 = function(first, rest) { 154 | var result = [first]; 155 | for (var i = 0; i < rest.length; ++i) { 156 | result.push(rest[i][1]); 157 | } 158 | return result; 159 | }, 160 | peg$c8 = function(type, attrs) { 161 | return { type: "attr", attrType: type, attrs: attrs || {}}; 162 | }, 163 | peg$c9 = "=", 164 | peg$c10 = peg$literalExpectation("=", false), 165 | peg$c11 = function(k, v) { 166 | var attrs = {}; 167 | attrs[k] = v; 168 | return { type: "inlineAttr", attrs: attrs }; 169 | }, 170 | peg$c12 = function(id, attrs) { return {type: "node", id: id, attrs: attrs || {}}; }, 171 | peg$c13 = function(lhs, rhs, attrs) { 172 | var elems = [lhs]; 173 | for (var i = 0; i < rhs.length; ++i) { 174 | elems.push(rhs[i]); 175 | } 176 | return { type: "edge", elems: elems, attrs: attrs || {} }; 177 | }, 178 | peg$c14 = function(id, stmts) { 179 | id = (id && id[2]) || []; 180 | return { type: "subgraph", id: id[0], stmts: stmts }; 181 | }, 182 | peg$c15 = function(first, rest) { 183 | var result = first; 184 | for (var i = 0; i < rest.length; ++i) { 185 | merge(result, rest[i][1]); 186 | } 187 | return result; 188 | }, 189 | peg$c16 = "[", 190 | peg$c17 = peg$literalExpectation("[", false), 191 | peg$c18 = "]", 192 | peg$c19 = peg$literalExpectation("]", false), 193 | peg$c20 = function(aList) { return aList; }, 194 | peg$c21 = ",", 195 | peg$c22 = peg$literalExpectation(",", false), 196 | peg$c23 = function(first, rest) { 197 | var result = first; 198 | for (var i = 0; i < rest.length; ++i) { 199 | _.merge(result, rest[i][3]); 200 | } 201 | return result; 202 | }, 203 | peg$c24 = "--", 204 | peg$c25 = peg$literalExpectation("--", false), 205 | peg$c26 = function() { return directed; }, 206 | peg$c27 = "->", 207 | peg$c28 = peg$literalExpectation("->", false), 208 | peg$c29 = function(rhs, rest) { 209 | var result = [rhs]; 210 | if (rest) { 211 | for (var i = 0; i < rest.length; ++i) { 212 | result.push(rest[i]); 213 | } 214 | } 215 | return result; 216 | }, 217 | peg$c30 = function(k, v) { 218 | var result = {}; 219 | result[k] = v[3]; 220 | return result; 221 | }, 222 | peg$c31 = function(id) { return { type: "node", id: id, attrs: {} }; }, 223 | peg$c32 = function(id) { return id; }, 224 | peg$c33 = ":", 225 | peg$c34 = peg$literalExpectation(":", false), 226 | peg$c35 = "ne", 227 | peg$c36 = peg$literalExpectation("ne", false), 228 | peg$c37 = "se", 229 | peg$c38 = peg$literalExpectation("se", false), 230 | peg$c39 = "sw", 231 | peg$c40 = peg$literalExpectation("sw", false), 232 | peg$c41 = "nw", 233 | peg$c42 = peg$literalExpectation("nw", false), 234 | peg$c43 = "n", 235 | peg$c44 = peg$literalExpectation("n", false), 236 | peg$c45 = "e", 237 | peg$c46 = peg$literalExpectation("e", false), 238 | peg$c47 = "s", 239 | peg$c48 = peg$literalExpectation("s", false), 240 | peg$c49 = "w", 241 | peg$c50 = peg$literalExpectation("w", false), 242 | peg$c51 = "c", 243 | peg$c52 = peg$literalExpectation("c", false), 244 | peg$c53 = "_", 245 | peg$c54 = peg$literalExpectation("_", false), 246 | peg$c55 = peg$otherExpectation("identifier"), 247 | peg$c56 = /^[a-zA-Z\u0200-\u0377_]/, 248 | peg$c57 = peg$classExpectation([["a", "z"], ["A", "Z"], ["\u0200", "\u0377"], "_"], false, false), 249 | peg$c58 = /^[a-zA-Z\u0200-\u0377_0-9]/, 250 | peg$c59 = peg$classExpectation([["a", "z"], ["A", "Z"], ["\u0200", "\u0377"], "_", ["0", "9"]], false, false), 251 | peg$c60 = function(fst, rest) { return fst + rest.join(""); }, 252 | peg$c61 = "-", 253 | peg$c62 = peg$literalExpectation("-", false), 254 | peg$c63 = ".", 255 | peg$c64 = peg$literalExpectation(".", false), 256 | peg$c65 = /^[0-9]/, 257 | peg$c66 = peg$classExpectation([["0", "9"]], false, false), 258 | peg$c67 = function(sign, dot, after) { 259 | return (sign || "") + dot + after.join(""); 260 | }, 261 | peg$c68 = function(sign, before, after) { 262 | return (sign || "") + before.join("") + (after ? after[0] : "") + (after ? after[1].join("") : ""); 263 | }, 264 | peg$c69 = "\"", 265 | peg$c70 = peg$literalExpectation("\"", false), 266 | peg$c71 = "\\\"", 267 | peg$c72 = peg$literalExpectation("\\\"", false), 268 | peg$c73 = function() { return '"'; }, 269 | peg$c74 = "\\", 270 | peg$c75 = peg$literalExpectation("\\", false), 271 | peg$c76 = /^[^"]/, 272 | peg$c77 = peg$classExpectation(["\""], true, false), 273 | peg$c78 = function(ch) { return "\\" + ch; }, 274 | peg$c79 = function(id) { 275 | return id.join(""); 276 | }, 277 | peg$c80 = "node", 278 | peg$c81 = peg$literalExpectation("node", true), 279 | peg$c82 = function(k) { return k.toLowerCase(); }, 280 | peg$c83 = "edge", 281 | peg$c84 = peg$literalExpectation("edge", true), 282 | peg$c85 = "graph", 283 | peg$c86 = peg$literalExpectation("graph", true), 284 | peg$c87 = "digraph", 285 | peg$c88 = peg$literalExpectation("digraph", true), 286 | peg$c89 = "subgraph", 287 | peg$c90 = peg$literalExpectation("subgraph", true), 288 | peg$c91 = "strict", 289 | peg$c92 = peg$literalExpectation("strict", true), 290 | peg$c93 = function(graph) { 291 | directed = graph === "digraph"; 292 | return graph; 293 | }, 294 | peg$c94 = peg$otherExpectation("whitespace"), 295 | peg$c95 = /^[ \t\r\n]/, 296 | peg$c96 = peg$classExpectation([" ", "\t", "\r", "\n"], false, false), 297 | peg$c97 = peg$otherExpectation("comment"), 298 | peg$c98 = "//", 299 | peg$c99 = peg$literalExpectation("//", false), 300 | peg$c100 = /^[^\n]/, 301 | peg$c101 = peg$classExpectation(["\n"], true, false), 302 | peg$c102 = "/*", 303 | peg$c103 = peg$literalExpectation("/*", false), 304 | peg$c104 = "*/", 305 | peg$c105 = peg$literalExpectation("*/", false), 306 | peg$c106 = peg$anyExpectation(), 307 | 308 | peg$currPos = 0, 309 | peg$savedPos = 0, 310 | peg$posDetailsCache = [{ line: 1, column: 1 }], 311 | peg$maxFailPos = 0, 312 | peg$maxFailExpected = [], 313 | peg$silentFails = 0, 314 | 315 | peg$result; 316 | 317 | if ("startRule" in options) { 318 | if (!(options.startRule in peg$startRuleFunctions)) { 319 | throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); 320 | } 321 | 322 | peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; 323 | } 324 | 325 | function text() { 326 | return input.substring(peg$savedPos, peg$currPos); 327 | } 328 | 329 | function location() { 330 | return peg$computeLocation(peg$savedPos, peg$currPos); 331 | } 332 | 333 | function expected(description, location) { 334 | location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) 335 | 336 | throw peg$buildStructuredError( 337 | [peg$otherExpectation(description)], 338 | input.substring(peg$savedPos, peg$currPos), 339 | location 340 | ); 341 | } 342 | 343 | function error(message, location) { 344 | location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) 345 | 346 | throw peg$buildSimpleError(message, location); 347 | } 348 | 349 | function peg$literalExpectation(text, ignoreCase) { 350 | return { type: "literal", text: text, ignoreCase: ignoreCase }; 351 | } 352 | 353 | function peg$classExpectation(parts, inverted, ignoreCase) { 354 | return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; 355 | } 356 | 357 | function peg$anyExpectation() { 358 | return { type: "any" }; 359 | } 360 | 361 | function peg$endExpectation() { 362 | return { type: "end" }; 363 | } 364 | 365 | function peg$otherExpectation(description) { 366 | return { type: "other", description: description }; 367 | } 368 | 369 | function peg$computePosDetails(pos) { 370 | var details = peg$posDetailsCache[pos], p; 371 | 372 | if (details) { 373 | return details; 374 | } else { 375 | p = pos - 1; 376 | while (!peg$posDetailsCache[p]) { 377 | p--; 378 | } 379 | 380 | details = peg$posDetailsCache[p]; 381 | details = { 382 | line: details.line, 383 | column: details.column 384 | }; 385 | 386 | while (p < pos) { 387 | if (input.charCodeAt(p) === 10) { 388 | details.line++; 389 | details.column = 1; 390 | } else { 391 | details.column++; 392 | } 393 | 394 | p++; 395 | } 396 | 397 | peg$posDetailsCache[pos] = details; 398 | return details; 399 | } 400 | } 401 | 402 | function peg$computeLocation(startPos, endPos) { 403 | var startPosDetails = peg$computePosDetails(startPos), 404 | endPosDetails = peg$computePosDetails(endPos); 405 | 406 | return { 407 | start: { 408 | offset: startPos, 409 | line: startPosDetails.line, 410 | column: startPosDetails.column 411 | }, 412 | end: { 413 | offset: endPos, 414 | line: endPosDetails.line, 415 | column: endPosDetails.column 416 | } 417 | }; 418 | } 419 | 420 | function peg$fail(expected) { 421 | if (peg$currPos < peg$maxFailPos) { return; } 422 | 423 | if (peg$currPos > peg$maxFailPos) { 424 | peg$maxFailPos = peg$currPos; 425 | peg$maxFailExpected = []; 426 | } 427 | 428 | peg$maxFailExpected.push(expected); 429 | } 430 | 431 | function peg$buildSimpleError(message, location) { 432 | return new peg$SyntaxError(message, null, null, location); 433 | } 434 | 435 | function peg$buildStructuredError(expected, found, location) { 436 | return new peg$SyntaxError( 437 | peg$SyntaxError.buildMessage(expected, found), 438 | expected, 439 | found, 440 | location 441 | ); 442 | } 443 | 444 | function peg$parsestart() { 445 | var s0, s1; 446 | 447 | s0 = []; 448 | s1 = peg$parsegraphStmt(); 449 | if (s1 !== peg$FAILED) { 450 | while (s1 !== peg$FAILED) { 451 | s0.push(s1); 452 | s1 = peg$parsegraphStmt(); 453 | } 454 | } else { 455 | s0 = peg$FAILED; 456 | } 457 | 458 | return s0; 459 | } 460 | 461 | function peg$parsegraphStmt() { 462 | var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13; 463 | 464 | s0 = peg$currPos; 465 | s1 = []; 466 | s2 = peg$parse_(); 467 | while (s2 !== peg$FAILED) { 468 | s1.push(s2); 469 | s2 = peg$parse_(); 470 | } 471 | if (s1 !== peg$FAILED) { 472 | s2 = peg$currPos; 473 | s3 = peg$parsestrict(); 474 | if (s3 !== peg$FAILED) { 475 | s4 = peg$parse_(); 476 | if (s4 !== peg$FAILED) { 477 | s3 = [s3, s4]; 478 | s2 = s3; 479 | } else { 480 | peg$currPos = s2; 481 | s2 = peg$FAILED; 482 | } 483 | } else { 484 | peg$currPos = s2; 485 | s2 = peg$FAILED; 486 | } 487 | if (s2 === peg$FAILED) { 488 | s2 = null; 489 | } 490 | if (s2 !== peg$FAILED) { 491 | s3 = peg$parsegraphType(); 492 | if (s3 !== peg$FAILED) { 493 | s4 = []; 494 | s5 = peg$parse_(); 495 | while (s5 !== peg$FAILED) { 496 | s4.push(s5); 497 | s5 = peg$parse_(); 498 | } 499 | if (s4 !== peg$FAILED) { 500 | s5 = peg$parseid(); 501 | if (s5 === peg$FAILED) { 502 | s5 = null; 503 | } 504 | if (s5 !== peg$FAILED) { 505 | s6 = []; 506 | s7 = peg$parse_(); 507 | while (s7 !== peg$FAILED) { 508 | s6.push(s7); 509 | s7 = peg$parse_(); 510 | } 511 | if (s6 !== peg$FAILED) { 512 | if (input.charCodeAt(peg$currPos) === 123) { 513 | s7 = peg$c0; 514 | peg$currPos++; 515 | } else { 516 | s7 = peg$FAILED; 517 | if (peg$silentFails === 0) { peg$fail(peg$c1); } 518 | } 519 | if (s7 !== peg$FAILED) { 520 | s8 = []; 521 | s9 = peg$parse_(); 522 | while (s9 !== peg$FAILED) { 523 | s8.push(s9); 524 | s9 = peg$parse_(); 525 | } 526 | if (s8 !== peg$FAILED) { 527 | s9 = peg$parsestmtList(); 528 | if (s9 === peg$FAILED) { 529 | s9 = null; 530 | } 531 | if (s9 !== peg$FAILED) { 532 | s10 = []; 533 | s11 = peg$parse_(); 534 | while (s11 !== peg$FAILED) { 535 | s10.push(s11); 536 | s11 = peg$parse_(); 537 | } 538 | if (s10 !== peg$FAILED) { 539 | if (input.charCodeAt(peg$currPos) === 125) { 540 | s11 = peg$c2; 541 | peg$currPos++; 542 | } else { 543 | s11 = peg$FAILED; 544 | if (peg$silentFails === 0) { peg$fail(peg$c3); } 545 | } 546 | if (s11 !== peg$FAILED) { 547 | s12 = []; 548 | s13 = peg$parse_(); 549 | while (s13 !== peg$FAILED) { 550 | s12.push(s13); 551 | s13 = peg$parse_(); 552 | } 553 | if (s12 !== peg$FAILED) { 554 | peg$savedPos = s0; 555 | s1 = peg$c4(s2, s3, s5, s9); 556 | s0 = s1; 557 | } else { 558 | peg$currPos = s0; 559 | s0 = peg$FAILED; 560 | } 561 | } else { 562 | peg$currPos = s0; 563 | s0 = peg$FAILED; 564 | } 565 | } else { 566 | peg$currPos = s0; 567 | s0 = peg$FAILED; 568 | } 569 | } else { 570 | peg$currPos = s0; 571 | s0 = peg$FAILED; 572 | } 573 | } else { 574 | peg$currPos = s0; 575 | s0 = peg$FAILED; 576 | } 577 | } else { 578 | peg$currPos = s0; 579 | s0 = peg$FAILED; 580 | } 581 | } else { 582 | peg$currPos = s0; 583 | s0 = peg$FAILED; 584 | } 585 | } else { 586 | peg$currPos = s0; 587 | s0 = peg$FAILED; 588 | } 589 | } else { 590 | peg$currPos = s0; 591 | s0 = peg$FAILED; 592 | } 593 | } else { 594 | peg$currPos = s0; 595 | s0 = peg$FAILED; 596 | } 597 | } else { 598 | peg$currPos = s0; 599 | s0 = peg$FAILED; 600 | } 601 | } else { 602 | peg$currPos = s0; 603 | s0 = peg$FAILED; 604 | } 605 | 606 | return s0; 607 | } 608 | 609 | function peg$parsestmtList() { 610 | var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; 611 | 612 | s0 = peg$currPos; 613 | s1 = peg$parsestmt(); 614 | if (s1 !== peg$FAILED) { 615 | s2 = []; 616 | s3 = peg$parse_(); 617 | while (s3 !== peg$FAILED) { 618 | s2.push(s3); 619 | s3 = peg$parse_(); 620 | } 621 | if (s2 !== peg$FAILED) { 622 | if (input.charCodeAt(peg$currPos) === 59) { 623 | s3 = peg$c5; 624 | peg$currPos++; 625 | } else { 626 | s3 = peg$FAILED; 627 | if (peg$silentFails === 0) { peg$fail(peg$c6); } 628 | } 629 | if (s3 === peg$FAILED) { 630 | s3 = null; 631 | } 632 | if (s3 !== peg$FAILED) { 633 | s4 = []; 634 | s5 = peg$currPos; 635 | s6 = []; 636 | s7 = peg$parse_(); 637 | while (s7 !== peg$FAILED) { 638 | s6.push(s7); 639 | s7 = peg$parse_(); 640 | } 641 | if (s6 !== peg$FAILED) { 642 | s7 = peg$parsestmt(); 643 | if (s7 !== peg$FAILED) { 644 | s8 = []; 645 | s9 = peg$parse_(); 646 | while (s9 !== peg$FAILED) { 647 | s8.push(s9); 648 | s9 = peg$parse_(); 649 | } 650 | if (s8 !== peg$FAILED) { 651 | if (input.charCodeAt(peg$currPos) === 59) { 652 | s9 = peg$c5; 653 | peg$currPos++; 654 | } else { 655 | s9 = peg$FAILED; 656 | if (peg$silentFails === 0) { peg$fail(peg$c6); } 657 | } 658 | if (s9 === peg$FAILED) { 659 | s9 = null; 660 | } 661 | if (s9 !== peg$FAILED) { 662 | s6 = [s6, s7, s8, s9]; 663 | s5 = s6; 664 | } else { 665 | peg$currPos = s5; 666 | s5 = peg$FAILED; 667 | } 668 | } else { 669 | peg$currPos = s5; 670 | s5 = peg$FAILED; 671 | } 672 | } else { 673 | peg$currPos = s5; 674 | s5 = peg$FAILED; 675 | } 676 | } else { 677 | peg$currPos = s5; 678 | s5 = peg$FAILED; 679 | } 680 | while (s5 !== peg$FAILED) { 681 | s4.push(s5); 682 | s5 = peg$currPos; 683 | s6 = []; 684 | s7 = peg$parse_(); 685 | while (s7 !== peg$FAILED) { 686 | s6.push(s7); 687 | s7 = peg$parse_(); 688 | } 689 | if (s6 !== peg$FAILED) { 690 | s7 = peg$parsestmt(); 691 | if (s7 !== peg$FAILED) { 692 | s8 = []; 693 | s9 = peg$parse_(); 694 | while (s9 !== peg$FAILED) { 695 | s8.push(s9); 696 | s9 = peg$parse_(); 697 | } 698 | if (s8 !== peg$FAILED) { 699 | if (input.charCodeAt(peg$currPos) === 59) { 700 | s9 = peg$c5; 701 | peg$currPos++; 702 | } else { 703 | s9 = peg$FAILED; 704 | if (peg$silentFails === 0) { peg$fail(peg$c6); } 705 | } 706 | if (s9 === peg$FAILED) { 707 | s9 = null; 708 | } 709 | if (s9 !== peg$FAILED) { 710 | s6 = [s6, s7, s8, s9]; 711 | s5 = s6; 712 | } else { 713 | peg$currPos = s5; 714 | s5 = peg$FAILED; 715 | } 716 | } else { 717 | peg$currPos = s5; 718 | s5 = peg$FAILED; 719 | } 720 | } else { 721 | peg$currPos = s5; 722 | s5 = peg$FAILED; 723 | } 724 | } else { 725 | peg$currPos = s5; 726 | s5 = peg$FAILED; 727 | } 728 | } 729 | if (s4 !== peg$FAILED) { 730 | peg$savedPos = s0; 731 | s1 = peg$c7(s1, s4); 732 | s0 = s1; 733 | } else { 734 | peg$currPos = s0; 735 | s0 = peg$FAILED; 736 | } 737 | } else { 738 | peg$currPos = s0; 739 | s0 = peg$FAILED; 740 | } 741 | } else { 742 | peg$currPos = s0; 743 | s0 = peg$FAILED; 744 | } 745 | } else { 746 | peg$currPos = s0; 747 | s0 = peg$FAILED; 748 | } 749 | 750 | return s0; 751 | } 752 | 753 | function peg$parsestmt() { 754 | var s0; 755 | 756 | s0 = peg$parseattrStmt(); 757 | if (s0 === peg$FAILED) { 758 | s0 = peg$parseedgeStmt(); 759 | if (s0 === peg$FAILED) { 760 | s0 = peg$parsesubgraphStmt(); 761 | if (s0 === peg$FAILED) { 762 | s0 = peg$parseinlineAttrStmt(); 763 | if (s0 === peg$FAILED) { 764 | s0 = peg$parsenodeStmt(); 765 | } 766 | } 767 | } 768 | } 769 | 770 | return s0; 771 | } 772 | 773 | function peg$parseattrStmt() { 774 | var s0, s1, s2, s3; 775 | 776 | s0 = peg$currPos; 777 | s1 = peg$parsegraph(); 778 | if (s1 === peg$FAILED) { 779 | s1 = peg$parsenode(); 780 | if (s1 === peg$FAILED) { 781 | s1 = peg$parseedge(); 782 | } 783 | } 784 | if (s1 !== peg$FAILED) { 785 | s2 = []; 786 | s3 = peg$parse_(); 787 | while (s3 !== peg$FAILED) { 788 | s2.push(s3); 789 | s3 = peg$parse_(); 790 | } 791 | if (s2 !== peg$FAILED) { 792 | s3 = peg$parseattrList(); 793 | if (s3 !== peg$FAILED) { 794 | peg$savedPos = s0; 795 | s1 = peg$c8(s1, s3); 796 | s0 = s1; 797 | } else { 798 | peg$currPos = s0; 799 | s0 = peg$FAILED; 800 | } 801 | } else { 802 | peg$currPos = s0; 803 | s0 = peg$FAILED; 804 | } 805 | } else { 806 | peg$currPos = s0; 807 | s0 = peg$FAILED; 808 | } 809 | 810 | return s0; 811 | } 812 | 813 | function peg$parseinlineAttrStmt() { 814 | var s0, s1, s2, s3, s4, s5; 815 | 816 | s0 = peg$currPos; 817 | s1 = peg$parseid(); 818 | if (s1 !== peg$FAILED) { 819 | s2 = []; 820 | s3 = peg$parse_(); 821 | while (s3 !== peg$FAILED) { 822 | s2.push(s3); 823 | s3 = peg$parse_(); 824 | } 825 | if (s2 !== peg$FAILED) { 826 | if (input.charCodeAt(peg$currPos) === 61) { 827 | s3 = peg$c9; 828 | peg$currPos++; 829 | } else { 830 | s3 = peg$FAILED; 831 | if (peg$silentFails === 0) { peg$fail(peg$c10); } 832 | } 833 | if (s3 !== peg$FAILED) { 834 | s4 = []; 835 | s5 = peg$parse_(); 836 | while (s5 !== peg$FAILED) { 837 | s4.push(s5); 838 | s5 = peg$parse_(); 839 | } 840 | if (s4 !== peg$FAILED) { 841 | s5 = peg$parseid(); 842 | if (s5 !== peg$FAILED) { 843 | peg$savedPos = s0; 844 | s1 = peg$c11(s1, s5); 845 | s0 = s1; 846 | } else { 847 | peg$currPos = s0; 848 | s0 = peg$FAILED; 849 | } 850 | } else { 851 | peg$currPos = s0; 852 | s0 = peg$FAILED; 853 | } 854 | } else { 855 | peg$currPos = s0; 856 | s0 = peg$FAILED; 857 | } 858 | } else { 859 | peg$currPos = s0; 860 | s0 = peg$FAILED; 861 | } 862 | } else { 863 | peg$currPos = s0; 864 | s0 = peg$FAILED; 865 | } 866 | 867 | return s0; 868 | } 869 | 870 | function peg$parsenodeStmt() { 871 | var s0, s1, s2, s3; 872 | 873 | s0 = peg$currPos; 874 | s1 = peg$parsenodeId(); 875 | if (s1 !== peg$FAILED) { 876 | s2 = []; 877 | s3 = peg$parse_(); 878 | while (s3 !== peg$FAILED) { 879 | s2.push(s3); 880 | s3 = peg$parse_(); 881 | } 882 | if (s2 !== peg$FAILED) { 883 | s3 = peg$parseattrList(); 884 | if (s3 === peg$FAILED) { 885 | s3 = null; 886 | } 887 | if (s3 !== peg$FAILED) { 888 | peg$savedPos = s0; 889 | s1 = peg$c12(s1, s3); 890 | s0 = s1; 891 | } else { 892 | peg$currPos = s0; 893 | s0 = peg$FAILED; 894 | } 895 | } else { 896 | peg$currPos = s0; 897 | s0 = peg$FAILED; 898 | } 899 | } else { 900 | peg$currPos = s0; 901 | s0 = peg$FAILED; 902 | } 903 | 904 | return s0; 905 | } 906 | 907 | function peg$parseedgeStmt() { 908 | var s0, s1, s2, s3, s4, s5; 909 | 910 | s0 = peg$currPos; 911 | s1 = peg$parsenodeIdOrSubgraph(); 912 | if (s1 !== peg$FAILED) { 913 | s2 = []; 914 | s3 = peg$parse_(); 915 | while (s3 !== peg$FAILED) { 916 | s2.push(s3); 917 | s3 = peg$parse_(); 918 | } 919 | if (s2 !== peg$FAILED) { 920 | s3 = peg$parseedgeRHS(); 921 | if (s3 !== peg$FAILED) { 922 | s4 = []; 923 | s5 = peg$parse_(); 924 | while (s5 !== peg$FAILED) { 925 | s4.push(s5); 926 | s5 = peg$parse_(); 927 | } 928 | if (s4 !== peg$FAILED) { 929 | s5 = peg$parseattrList(); 930 | if (s5 === peg$FAILED) { 931 | s5 = null; 932 | } 933 | if (s5 !== peg$FAILED) { 934 | peg$savedPos = s0; 935 | s1 = peg$c13(s1, s3, s5); 936 | s0 = s1; 937 | } else { 938 | peg$currPos = s0; 939 | s0 = peg$FAILED; 940 | } 941 | } else { 942 | peg$currPos = s0; 943 | s0 = peg$FAILED; 944 | } 945 | } else { 946 | peg$currPos = s0; 947 | s0 = peg$FAILED; 948 | } 949 | } else { 950 | peg$currPos = s0; 951 | s0 = peg$FAILED; 952 | } 953 | } else { 954 | peg$currPos = s0; 955 | s0 = peg$FAILED; 956 | } 957 | 958 | return s0; 959 | } 960 | 961 | function peg$parsesubgraphStmt() { 962 | var s0, s1, s2, s3, s4, s5, s6, s7; 963 | 964 | s0 = peg$currPos; 965 | s1 = peg$currPos; 966 | s2 = peg$parsesubgraph(); 967 | if (s2 !== peg$FAILED) { 968 | s3 = []; 969 | s4 = peg$parse_(); 970 | while (s4 !== peg$FAILED) { 971 | s3.push(s4); 972 | s4 = peg$parse_(); 973 | } 974 | if (s3 !== peg$FAILED) { 975 | s4 = peg$currPos; 976 | s5 = peg$parseid(); 977 | if (s5 !== peg$FAILED) { 978 | s6 = []; 979 | s7 = peg$parse_(); 980 | while (s7 !== peg$FAILED) { 981 | s6.push(s7); 982 | s7 = peg$parse_(); 983 | } 984 | if (s6 !== peg$FAILED) { 985 | s5 = [s5, s6]; 986 | s4 = s5; 987 | } else { 988 | peg$currPos = s4; 989 | s4 = peg$FAILED; 990 | } 991 | } else { 992 | peg$currPos = s4; 993 | s4 = peg$FAILED; 994 | } 995 | if (s4 === peg$FAILED) { 996 | s4 = null; 997 | } 998 | if (s4 !== peg$FAILED) { 999 | s2 = [s2, s3, s4]; 1000 | s1 = s2; 1001 | } else { 1002 | peg$currPos = s1; 1003 | s1 = peg$FAILED; 1004 | } 1005 | } else { 1006 | peg$currPos = s1; 1007 | s1 = peg$FAILED; 1008 | } 1009 | } else { 1010 | peg$currPos = s1; 1011 | s1 = peg$FAILED; 1012 | } 1013 | if (s1 === peg$FAILED) { 1014 | s1 = null; 1015 | } 1016 | if (s1 !== peg$FAILED) { 1017 | if (input.charCodeAt(peg$currPos) === 123) { 1018 | s2 = peg$c0; 1019 | peg$currPos++; 1020 | } else { 1021 | s2 = peg$FAILED; 1022 | if (peg$silentFails === 0) { peg$fail(peg$c1); } 1023 | } 1024 | if (s2 !== peg$FAILED) { 1025 | s3 = []; 1026 | s4 = peg$parse_(); 1027 | while (s4 !== peg$FAILED) { 1028 | s3.push(s4); 1029 | s4 = peg$parse_(); 1030 | } 1031 | if (s3 !== peg$FAILED) { 1032 | s4 = peg$parsestmtList(); 1033 | if (s4 === peg$FAILED) { 1034 | s4 = null; 1035 | } 1036 | if (s4 !== peg$FAILED) { 1037 | s5 = []; 1038 | s6 = peg$parse_(); 1039 | while (s6 !== peg$FAILED) { 1040 | s5.push(s6); 1041 | s6 = peg$parse_(); 1042 | } 1043 | if (s5 !== peg$FAILED) { 1044 | if (input.charCodeAt(peg$currPos) === 125) { 1045 | s6 = peg$c2; 1046 | peg$currPos++; 1047 | } else { 1048 | s6 = peg$FAILED; 1049 | if (peg$silentFails === 0) { peg$fail(peg$c3); } 1050 | } 1051 | if (s6 !== peg$FAILED) { 1052 | peg$savedPos = s0; 1053 | s1 = peg$c14(s1, s4); 1054 | s0 = s1; 1055 | } else { 1056 | peg$currPos = s0; 1057 | s0 = peg$FAILED; 1058 | } 1059 | } else { 1060 | peg$currPos = s0; 1061 | s0 = peg$FAILED; 1062 | } 1063 | } else { 1064 | peg$currPos = s0; 1065 | s0 = peg$FAILED; 1066 | } 1067 | } else { 1068 | peg$currPos = s0; 1069 | s0 = peg$FAILED; 1070 | } 1071 | } else { 1072 | peg$currPos = s0; 1073 | s0 = peg$FAILED; 1074 | } 1075 | } else { 1076 | peg$currPos = s0; 1077 | s0 = peg$FAILED; 1078 | } 1079 | 1080 | return s0; 1081 | } 1082 | 1083 | function peg$parseattrList() { 1084 | var s0, s1, s2, s3, s4, s5; 1085 | 1086 | s0 = peg$currPos; 1087 | s1 = peg$parseattrListBlock(); 1088 | if (s1 !== peg$FAILED) { 1089 | s2 = []; 1090 | s3 = peg$currPos; 1091 | s4 = []; 1092 | s5 = peg$parse_(); 1093 | while (s5 !== peg$FAILED) { 1094 | s4.push(s5); 1095 | s5 = peg$parse_(); 1096 | } 1097 | if (s4 !== peg$FAILED) { 1098 | s5 = peg$parseattrListBlock(); 1099 | if (s5 !== peg$FAILED) { 1100 | s4 = [s4, s5]; 1101 | s3 = s4; 1102 | } else { 1103 | peg$currPos = s3; 1104 | s3 = peg$FAILED; 1105 | } 1106 | } else { 1107 | peg$currPos = s3; 1108 | s3 = peg$FAILED; 1109 | } 1110 | while (s3 !== peg$FAILED) { 1111 | s2.push(s3); 1112 | s3 = peg$currPos; 1113 | s4 = []; 1114 | s5 = peg$parse_(); 1115 | while (s5 !== peg$FAILED) { 1116 | s4.push(s5); 1117 | s5 = peg$parse_(); 1118 | } 1119 | if (s4 !== peg$FAILED) { 1120 | s5 = peg$parseattrListBlock(); 1121 | if (s5 !== peg$FAILED) { 1122 | s4 = [s4, s5]; 1123 | s3 = s4; 1124 | } else { 1125 | peg$currPos = s3; 1126 | s3 = peg$FAILED; 1127 | } 1128 | } else { 1129 | peg$currPos = s3; 1130 | s3 = peg$FAILED; 1131 | } 1132 | } 1133 | if (s2 !== peg$FAILED) { 1134 | peg$savedPos = s0; 1135 | s1 = peg$c15(s1, s2); 1136 | s0 = s1; 1137 | } else { 1138 | peg$currPos = s0; 1139 | s0 = peg$FAILED; 1140 | } 1141 | } else { 1142 | peg$currPos = s0; 1143 | s0 = peg$FAILED; 1144 | } 1145 | 1146 | return s0; 1147 | } 1148 | 1149 | function peg$parseattrListBlock() { 1150 | var s0, s1, s2, s3, s4, s5; 1151 | 1152 | s0 = peg$currPos; 1153 | if (input.charCodeAt(peg$currPos) === 91) { 1154 | s1 = peg$c16; 1155 | peg$currPos++; 1156 | } else { 1157 | s1 = peg$FAILED; 1158 | if (peg$silentFails === 0) { peg$fail(peg$c17); } 1159 | } 1160 | if (s1 !== peg$FAILED) { 1161 | s2 = []; 1162 | s3 = peg$parse_(); 1163 | while (s3 !== peg$FAILED) { 1164 | s2.push(s3); 1165 | s3 = peg$parse_(); 1166 | } 1167 | if (s2 !== peg$FAILED) { 1168 | s3 = peg$parseaList(); 1169 | if (s3 === peg$FAILED) { 1170 | s3 = null; 1171 | } 1172 | if (s3 !== peg$FAILED) { 1173 | s4 = []; 1174 | s5 = peg$parse_(); 1175 | while (s5 !== peg$FAILED) { 1176 | s4.push(s5); 1177 | s5 = peg$parse_(); 1178 | } 1179 | if (s4 !== peg$FAILED) { 1180 | if (input.charCodeAt(peg$currPos) === 93) { 1181 | s5 = peg$c18; 1182 | peg$currPos++; 1183 | } else { 1184 | s5 = peg$FAILED; 1185 | if (peg$silentFails === 0) { peg$fail(peg$c19); } 1186 | } 1187 | if (s5 !== peg$FAILED) { 1188 | peg$savedPos = s0; 1189 | s1 = peg$c20(s3); 1190 | s0 = s1; 1191 | } else { 1192 | peg$currPos = s0; 1193 | s0 = peg$FAILED; 1194 | } 1195 | } else { 1196 | peg$currPos = s0; 1197 | s0 = peg$FAILED; 1198 | } 1199 | } else { 1200 | peg$currPos = s0; 1201 | s0 = peg$FAILED; 1202 | } 1203 | } else { 1204 | peg$currPos = s0; 1205 | s0 = peg$FAILED; 1206 | } 1207 | } else { 1208 | peg$currPos = s0; 1209 | s0 = peg$FAILED; 1210 | } 1211 | 1212 | return s0; 1213 | } 1214 | 1215 | function peg$parseaList() { 1216 | var s0, s1, s2, s3, s4, s5, s6, s7; 1217 | 1218 | s0 = peg$currPos; 1219 | s1 = peg$parseidDef(); 1220 | if (s1 !== peg$FAILED) { 1221 | s2 = []; 1222 | s3 = peg$currPos; 1223 | s4 = []; 1224 | s5 = peg$parse_(); 1225 | while (s5 !== peg$FAILED) { 1226 | s4.push(s5); 1227 | s5 = peg$parse_(); 1228 | } 1229 | if (s4 !== peg$FAILED) { 1230 | if (input.charCodeAt(peg$currPos) === 44) { 1231 | s5 = peg$c21; 1232 | peg$currPos++; 1233 | } else { 1234 | s5 = peg$FAILED; 1235 | if (peg$silentFails === 0) { peg$fail(peg$c22); } 1236 | } 1237 | if (s5 === peg$FAILED) { 1238 | s5 = null; 1239 | } 1240 | if (s5 !== peg$FAILED) { 1241 | s6 = []; 1242 | s7 = peg$parse_(); 1243 | while (s7 !== peg$FAILED) { 1244 | s6.push(s7); 1245 | s7 = peg$parse_(); 1246 | } 1247 | if (s6 !== peg$FAILED) { 1248 | s7 = peg$parseidDef(); 1249 | if (s7 !== peg$FAILED) { 1250 | s4 = [s4, s5, s6, s7]; 1251 | s3 = s4; 1252 | } else { 1253 | peg$currPos = s3; 1254 | s3 = peg$FAILED; 1255 | } 1256 | } else { 1257 | peg$currPos = s3; 1258 | s3 = peg$FAILED; 1259 | } 1260 | } else { 1261 | peg$currPos = s3; 1262 | s3 = peg$FAILED; 1263 | } 1264 | } else { 1265 | peg$currPos = s3; 1266 | s3 = peg$FAILED; 1267 | } 1268 | while (s3 !== peg$FAILED) { 1269 | s2.push(s3); 1270 | s3 = peg$currPos; 1271 | s4 = []; 1272 | s5 = peg$parse_(); 1273 | while (s5 !== peg$FAILED) { 1274 | s4.push(s5); 1275 | s5 = peg$parse_(); 1276 | } 1277 | if (s4 !== peg$FAILED) { 1278 | if (input.charCodeAt(peg$currPos) === 44) { 1279 | s5 = peg$c21; 1280 | peg$currPos++; 1281 | } else { 1282 | s5 = peg$FAILED; 1283 | if (peg$silentFails === 0) { peg$fail(peg$c22); } 1284 | } 1285 | if (s5 === peg$FAILED) { 1286 | s5 = null; 1287 | } 1288 | if (s5 !== peg$FAILED) { 1289 | s6 = []; 1290 | s7 = peg$parse_(); 1291 | while (s7 !== peg$FAILED) { 1292 | s6.push(s7); 1293 | s7 = peg$parse_(); 1294 | } 1295 | if (s6 !== peg$FAILED) { 1296 | s7 = peg$parseidDef(); 1297 | if (s7 !== peg$FAILED) { 1298 | s4 = [s4, s5, s6, s7]; 1299 | s3 = s4; 1300 | } else { 1301 | peg$currPos = s3; 1302 | s3 = peg$FAILED; 1303 | } 1304 | } else { 1305 | peg$currPos = s3; 1306 | s3 = peg$FAILED; 1307 | } 1308 | } else { 1309 | peg$currPos = s3; 1310 | s3 = peg$FAILED; 1311 | } 1312 | } else { 1313 | peg$currPos = s3; 1314 | s3 = peg$FAILED; 1315 | } 1316 | } 1317 | if (s2 !== peg$FAILED) { 1318 | peg$savedPos = s0; 1319 | s1 = peg$c23(s1, s2); 1320 | s0 = s1; 1321 | } else { 1322 | peg$currPos = s0; 1323 | s0 = peg$FAILED; 1324 | } 1325 | } else { 1326 | peg$currPos = s0; 1327 | s0 = peg$FAILED; 1328 | } 1329 | 1330 | return s0; 1331 | } 1332 | 1333 | function peg$parseedgeRHS() { 1334 | var s0, s1, s2, s3, s4, s5; 1335 | 1336 | s0 = peg$currPos; 1337 | s1 = peg$currPos; 1338 | if (input.substr(peg$currPos, 2) === peg$c24) { 1339 | s2 = peg$c24; 1340 | peg$currPos += 2; 1341 | } else { 1342 | s2 = peg$FAILED; 1343 | if (peg$silentFails === 0) { peg$fail(peg$c25); } 1344 | } 1345 | if (s2 !== peg$FAILED) { 1346 | peg$savedPos = peg$currPos; 1347 | s3 = peg$c26(); 1348 | if (s3) { 1349 | s3 = peg$FAILED; 1350 | } else { 1351 | s3 = void 0; 1352 | } 1353 | if (s3 !== peg$FAILED) { 1354 | s2 = [s2, s3]; 1355 | s1 = s2; 1356 | } else { 1357 | peg$currPos = s1; 1358 | s1 = peg$FAILED; 1359 | } 1360 | } else { 1361 | peg$currPos = s1; 1362 | s1 = peg$FAILED; 1363 | } 1364 | if (s1 === peg$FAILED) { 1365 | s1 = peg$currPos; 1366 | if (input.substr(peg$currPos, 2) === peg$c27) { 1367 | s2 = peg$c27; 1368 | peg$currPos += 2; 1369 | } else { 1370 | s2 = peg$FAILED; 1371 | if (peg$silentFails === 0) { peg$fail(peg$c28); } 1372 | } 1373 | if (s2 !== peg$FAILED) { 1374 | peg$savedPos = peg$currPos; 1375 | s3 = peg$c26(); 1376 | if (s3) { 1377 | s3 = void 0; 1378 | } else { 1379 | s3 = peg$FAILED; 1380 | } 1381 | if (s3 !== peg$FAILED) { 1382 | s2 = [s2, s3]; 1383 | s1 = s2; 1384 | } else { 1385 | peg$currPos = s1; 1386 | s1 = peg$FAILED; 1387 | } 1388 | } else { 1389 | peg$currPos = s1; 1390 | s1 = peg$FAILED; 1391 | } 1392 | } 1393 | if (s1 !== peg$FAILED) { 1394 | s2 = []; 1395 | s3 = peg$parse_(); 1396 | while (s3 !== peg$FAILED) { 1397 | s2.push(s3); 1398 | s3 = peg$parse_(); 1399 | } 1400 | if (s2 !== peg$FAILED) { 1401 | s3 = peg$parsenodeIdOrSubgraph(); 1402 | if (s3 !== peg$FAILED) { 1403 | s4 = []; 1404 | s5 = peg$parse_(); 1405 | while (s5 !== peg$FAILED) { 1406 | s4.push(s5); 1407 | s5 = peg$parse_(); 1408 | } 1409 | if (s4 !== peg$FAILED) { 1410 | s5 = peg$parseedgeRHS(); 1411 | if (s5 === peg$FAILED) { 1412 | s5 = null; 1413 | } 1414 | if (s5 !== peg$FAILED) { 1415 | peg$savedPos = s0; 1416 | s1 = peg$c29(s3, s5); 1417 | s0 = s1; 1418 | } else { 1419 | peg$currPos = s0; 1420 | s0 = peg$FAILED; 1421 | } 1422 | } else { 1423 | peg$currPos = s0; 1424 | s0 = peg$FAILED; 1425 | } 1426 | } else { 1427 | peg$currPos = s0; 1428 | s0 = peg$FAILED; 1429 | } 1430 | } else { 1431 | peg$currPos = s0; 1432 | s0 = peg$FAILED; 1433 | } 1434 | } else { 1435 | peg$currPos = s0; 1436 | s0 = peg$FAILED; 1437 | } 1438 | 1439 | return s0; 1440 | } 1441 | 1442 | function peg$parseidDef() { 1443 | var s0, s1, s2, s3, s4, s5, s6; 1444 | 1445 | s0 = peg$currPos; 1446 | s1 = peg$parseid(); 1447 | if (s1 !== peg$FAILED) { 1448 | s2 = peg$currPos; 1449 | s3 = []; 1450 | s4 = peg$parse_(); 1451 | while (s4 !== peg$FAILED) { 1452 | s3.push(s4); 1453 | s4 = peg$parse_(); 1454 | } 1455 | if (s3 !== peg$FAILED) { 1456 | if (input.charCodeAt(peg$currPos) === 61) { 1457 | s4 = peg$c9; 1458 | peg$currPos++; 1459 | } else { 1460 | s4 = peg$FAILED; 1461 | if (peg$silentFails === 0) { peg$fail(peg$c10); } 1462 | } 1463 | if (s4 !== peg$FAILED) { 1464 | s5 = []; 1465 | s6 = peg$parse_(); 1466 | while (s6 !== peg$FAILED) { 1467 | s5.push(s6); 1468 | s6 = peg$parse_(); 1469 | } 1470 | if (s5 !== peg$FAILED) { 1471 | s6 = peg$parseid(); 1472 | if (s6 !== peg$FAILED) { 1473 | s3 = [s3, s4, s5, s6]; 1474 | s2 = s3; 1475 | } else { 1476 | peg$currPos = s2; 1477 | s2 = peg$FAILED; 1478 | } 1479 | } else { 1480 | peg$currPos = s2; 1481 | s2 = peg$FAILED; 1482 | } 1483 | } else { 1484 | peg$currPos = s2; 1485 | s2 = peg$FAILED; 1486 | } 1487 | } else { 1488 | peg$currPos = s2; 1489 | s2 = peg$FAILED; 1490 | } 1491 | if (s2 === peg$FAILED) { 1492 | s2 = null; 1493 | } 1494 | if (s2 !== peg$FAILED) { 1495 | peg$savedPos = s0; 1496 | s1 = peg$c30(s1, s2); 1497 | s0 = s1; 1498 | } else { 1499 | peg$currPos = s0; 1500 | s0 = peg$FAILED; 1501 | } 1502 | } else { 1503 | peg$currPos = s0; 1504 | s0 = peg$FAILED; 1505 | } 1506 | 1507 | return s0; 1508 | } 1509 | 1510 | function peg$parsenodeIdOrSubgraph() { 1511 | var s0, s1; 1512 | 1513 | s0 = peg$parsesubgraphStmt(); 1514 | if (s0 === peg$FAILED) { 1515 | s0 = peg$currPos; 1516 | s1 = peg$parsenodeId(); 1517 | if (s1 !== peg$FAILED) { 1518 | peg$savedPos = s0; 1519 | s1 = peg$c31(s1); 1520 | } 1521 | s0 = s1; 1522 | } 1523 | 1524 | return s0; 1525 | } 1526 | 1527 | function peg$parsenodeId() { 1528 | var s0, s1, s2, s3; 1529 | 1530 | s0 = peg$currPos; 1531 | s1 = peg$parseid(); 1532 | if (s1 !== peg$FAILED) { 1533 | s2 = []; 1534 | s3 = peg$parse_(); 1535 | while (s3 !== peg$FAILED) { 1536 | s2.push(s3); 1537 | s3 = peg$parse_(); 1538 | } 1539 | if (s2 !== peg$FAILED) { 1540 | s3 = peg$parseport(); 1541 | if (s3 === peg$FAILED) { 1542 | s3 = null; 1543 | } 1544 | if (s3 !== peg$FAILED) { 1545 | peg$savedPos = s0; 1546 | s1 = peg$c32(s1); 1547 | s0 = s1; 1548 | } else { 1549 | peg$currPos = s0; 1550 | s0 = peg$FAILED; 1551 | } 1552 | } else { 1553 | peg$currPos = s0; 1554 | s0 = peg$FAILED; 1555 | } 1556 | } else { 1557 | peg$currPos = s0; 1558 | s0 = peg$FAILED; 1559 | } 1560 | 1561 | return s0; 1562 | } 1563 | 1564 | function peg$parseport() { 1565 | var s0, s1, s2, s3, s4, s5, s6, s7, s8; 1566 | 1567 | s0 = peg$currPos; 1568 | if (input.charCodeAt(peg$currPos) === 58) { 1569 | s1 = peg$c33; 1570 | peg$currPos++; 1571 | } else { 1572 | s1 = peg$FAILED; 1573 | if (peg$silentFails === 0) { peg$fail(peg$c34); } 1574 | } 1575 | if (s1 !== peg$FAILED) { 1576 | s2 = []; 1577 | s3 = peg$parse_(); 1578 | while (s3 !== peg$FAILED) { 1579 | s2.push(s3); 1580 | s3 = peg$parse_(); 1581 | } 1582 | if (s2 !== peg$FAILED) { 1583 | s3 = peg$parseid(); 1584 | if (s3 !== peg$FAILED) { 1585 | s4 = []; 1586 | s5 = peg$parse_(); 1587 | while (s5 !== peg$FAILED) { 1588 | s4.push(s5); 1589 | s5 = peg$parse_(); 1590 | } 1591 | if (s4 !== peg$FAILED) { 1592 | s5 = peg$currPos; 1593 | if (input.charCodeAt(peg$currPos) === 58) { 1594 | s6 = peg$c33; 1595 | peg$currPos++; 1596 | } else { 1597 | s6 = peg$FAILED; 1598 | if (peg$silentFails === 0) { peg$fail(peg$c34); } 1599 | } 1600 | if (s6 !== peg$FAILED) { 1601 | s7 = []; 1602 | s8 = peg$parse_(); 1603 | while (s8 !== peg$FAILED) { 1604 | s7.push(s8); 1605 | s8 = peg$parse_(); 1606 | } 1607 | if (s7 !== peg$FAILED) { 1608 | s8 = peg$parsecompassPt(); 1609 | if (s8 !== peg$FAILED) { 1610 | s6 = [s6, s7, s8]; 1611 | s5 = s6; 1612 | } else { 1613 | peg$currPos = s5; 1614 | s5 = peg$FAILED; 1615 | } 1616 | } else { 1617 | peg$currPos = s5; 1618 | s5 = peg$FAILED; 1619 | } 1620 | } else { 1621 | peg$currPos = s5; 1622 | s5 = peg$FAILED; 1623 | } 1624 | if (s5 === peg$FAILED) { 1625 | s5 = null; 1626 | } 1627 | if (s5 !== peg$FAILED) { 1628 | s1 = [s1, s2, s3, s4, s5]; 1629 | s0 = s1; 1630 | } else { 1631 | peg$currPos = s0; 1632 | s0 = peg$FAILED; 1633 | } 1634 | } else { 1635 | peg$currPos = s0; 1636 | s0 = peg$FAILED; 1637 | } 1638 | } else { 1639 | peg$currPos = s0; 1640 | s0 = peg$FAILED; 1641 | } 1642 | } else { 1643 | peg$currPos = s0; 1644 | s0 = peg$FAILED; 1645 | } 1646 | } else { 1647 | peg$currPos = s0; 1648 | s0 = peg$FAILED; 1649 | } 1650 | 1651 | return s0; 1652 | } 1653 | 1654 | function peg$parsecompassPt() { 1655 | var s0; 1656 | 1657 | if (input.substr(peg$currPos, 2) === peg$c35) { 1658 | s0 = peg$c35; 1659 | peg$currPos += 2; 1660 | } else { 1661 | s0 = peg$FAILED; 1662 | if (peg$silentFails === 0) { peg$fail(peg$c36); } 1663 | } 1664 | if (s0 === peg$FAILED) { 1665 | if (input.substr(peg$currPos, 2) === peg$c37) { 1666 | s0 = peg$c37; 1667 | peg$currPos += 2; 1668 | } else { 1669 | s0 = peg$FAILED; 1670 | if (peg$silentFails === 0) { peg$fail(peg$c38); } 1671 | } 1672 | if (s0 === peg$FAILED) { 1673 | if (input.substr(peg$currPos, 2) === peg$c39) { 1674 | s0 = peg$c39; 1675 | peg$currPos += 2; 1676 | } else { 1677 | s0 = peg$FAILED; 1678 | if (peg$silentFails === 0) { peg$fail(peg$c40); } 1679 | } 1680 | if (s0 === peg$FAILED) { 1681 | if (input.substr(peg$currPos, 2) === peg$c41) { 1682 | s0 = peg$c41; 1683 | peg$currPos += 2; 1684 | } else { 1685 | s0 = peg$FAILED; 1686 | if (peg$silentFails === 0) { peg$fail(peg$c42); } 1687 | } 1688 | if (s0 === peg$FAILED) { 1689 | if (input.charCodeAt(peg$currPos) === 110) { 1690 | s0 = peg$c43; 1691 | peg$currPos++; 1692 | } else { 1693 | s0 = peg$FAILED; 1694 | if (peg$silentFails === 0) { peg$fail(peg$c44); } 1695 | } 1696 | if (s0 === peg$FAILED) { 1697 | if (input.charCodeAt(peg$currPos) === 101) { 1698 | s0 = peg$c45; 1699 | peg$currPos++; 1700 | } else { 1701 | s0 = peg$FAILED; 1702 | if (peg$silentFails === 0) { peg$fail(peg$c46); } 1703 | } 1704 | if (s0 === peg$FAILED) { 1705 | if (input.charCodeAt(peg$currPos) === 115) { 1706 | s0 = peg$c47; 1707 | peg$currPos++; 1708 | } else { 1709 | s0 = peg$FAILED; 1710 | if (peg$silentFails === 0) { peg$fail(peg$c48); } 1711 | } 1712 | if (s0 === peg$FAILED) { 1713 | if (input.charCodeAt(peg$currPos) === 119) { 1714 | s0 = peg$c49; 1715 | peg$currPos++; 1716 | } else { 1717 | s0 = peg$FAILED; 1718 | if (peg$silentFails === 0) { peg$fail(peg$c50); } 1719 | } 1720 | if (s0 === peg$FAILED) { 1721 | if (input.charCodeAt(peg$currPos) === 99) { 1722 | s0 = peg$c51; 1723 | peg$currPos++; 1724 | } else { 1725 | s0 = peg$FAILED; 1726 | if (peg$silentFails === 0) { peg$fail(peg$c52); } 1727 | } 1728 | if (s0 === peg$FAILED) { 1729 | if (input.charCodeAt(peg$currPos) === 95) { 1730 | s0 = peg$c53; 1731 | peg$currPos++; 1732 | } else { 1733 | s0 = peg$FAILED; 1734 | if (peg$silentFails === 0) { peg$fail(peg$c54); } 1735 | } 1736 | } 1737 | } 1738 | } 1739 | } 1740 | } 1741 | } 1742 | } 1743 | } 1744 | } 1745 | 1746 | return s0; 1747 | } 1748 | 1749 | function peg$parseid() { 1750 | var s0, s1, s2, s3, s4, s5, s6; 1751 | 1752 | peg$silentFails++; 1753 | s0 = peg$currPos; 1754 | if (peg$c56.test(input.charAt(peg$currPos))) { 1755 | s1 = input.charAt(peg$currPos); 1756 | peg$currPos++; 1757 | } else { 1758 | s1 = peg$FAILED; 1759 | if (peg$silentFails === 0) { peg$fail(peg$c57); } 1760 | } 1761 | if (s1 !== peg$FAILED) { 1762 | s2 = []; 1763 | if (peg$c58.test(input.charAt(peg$currPos))) { 1764 | s3 = input.charAt(peg$currPos); 1765 | peg$currPos++; 1766 | } else { 1767 | s3 = peg$FAILED; 1768 | if (peg$silentFails === 0) { peg$fail(peg$c59); } 1769 | } 1770 | while (s3 !== peg$FAILED) { 1771 | s2.push(s3); 1772 | if (peg$c58.test(input.charAt(peg$currPos))) { 1773 | s3 = input.charAt(peg$currPos); 1774 | peg$currPos++; 1775 | } else { 1776 | s3 = peg$FAILED; 1777 | if (peg$silentFails === 0) { peg$fail(peg$c59); } 1778 | } 1779 | } 1780 | if (s2 !== peg$FAILED) { 1781 | peg$savedPos = s0; 1782 | s1 = peg$c60(s1, s2); 1783 | s0 = s1; 1784 | } else { 1785 | peg$currPos = s0; 1786 | s0 = peg$FAILED; 1787 | } 1788 | } else { 1789 | peg$currPos = s0; 1790 | s0 = peg$FAILED; 1791 | } 1792 | if (s0 === peg$FAILED) { 1793 | s0 = peg$currPos; 1794 | if (input.charCodeAt(peg$currPos) === 45) { 1795 | s1 = peg$c61; 1796 | peg$currPos++; 1797 | } else { 1798 | s1 = peg$FAILED; 1799 | if (peg$silentFails === 0) { peg$fail(peg$c62); } 1800 | } 1801 | if (s1 === peg$FAILED) { 1802 | s1 = null; 1803 | } 1804 | if (s1 !== peg$FAILED) { 1805 | if (input.charCodeAt(peg$currPos) === 46) { 1806 | s2 = peg$c63; 1807 | peg$currPos++; 1808 | } else { 1809 | s2 = peg$FAILED; 1810 | if (peg$silentFails === 0) { peg$fail(peg$c64); } 1811 | } 1812 | if (s2 !== peg$FAILED) { 1813 | s3 = []; 1814 | if (peg$c65.test(input.charAt(peg$currPos))) { 1815 | s4 = input.charAt(peg$currPos); 1816 | peg$currPos++; 1817 | } else { 1818 | s4 = peg$FAILED; 1819 | if (peg$silentFails === 0) { peg$fail(peg$c66); } 1820 | } 1821 | if (s4 !== peg$FAILED) { 1822 | while (s4 !== peg$FAILED) { 1823 | s3.push(s4); 1824 | if (peg$c65.test(input.charAt(peg$currPos))) { 1825 | s4 = input.charAt(peg$currPos); 1826 | peg$currPos++; 1827 | } else { 1828 | s4 = peg$FAILED; 1829 | if (peg$silentFails === 0) { peg$fail(peg$c66); } 1830 | } 1831 | } 1832 | } else { 1833 | s3 = peg$FAILED; 1834 | } 1835 | if (s3 !== peg$FAILED) { 1836 | peg$savedPos = s0; 1837 | s1 = peg$c67(s1, s2, s3); 1838 | s0 = s1; 1839 | } else { 1840 | peg$currPos = s0; 1841 | s0 = peg$FAILED; 1842 | } 1843 | } else { 1844 | peg$currPos = s0; 1845 | s0 = peg$FAILED; 1846 | } 1847 | } else { 1848 | peg$currPos = s0; 1849 | s0 = peg$FAILED; 1850 | } 1851 | if (s0 === peg$FAILED) { 1852 | s0 = peg$currPos; 1853 | if (input.charCodeAt(peg$currPos) === 45) { 1854 | s1 = peg$c61; 1855 | peg$currPos++; 1856 | } else { 1857 | s1 = peg$FAILED; 1858 | if (peg$silentFails === 0) { peg$fail(peg$c62); } 1859 | } 1860 | if (s1 === peg$FAILED) { 1861 | s1 = null; 1862 | } 1863 | if (s1 !== peg$FAILED) { 1864 | s2 = []; 1865 | if (peg$c65.test(input.charAt(peg$currPos))) { 1866 | s3 = input.charAt(peg$currPos); 1867 | peg$currPos++; 1868 | } else { 1869 | s3 = peg$FAILED; 1870 | if (peg$silentFails === 0) { peg$fail(peg$c66); } 1871 | } 1872 | if (s3 !== peg$FAILED) { 1873 | while (s3 !== peg$FAILED) { 1874 | s2.push(s3); 1875 | if (peg$c65.test(input.charAt(peg$currPos))) { 1876 | s3 = input.charAt(peg$currPos); 1877 | peg$currPos++; 1878 | } else { 1879 | s3 = peg$FAILED; 1880 | if (peg$silentFails === 0) { peg$fail(peg$c66); } 1881 | } 1882 | } 1883 | } else { 1884 | s2 = peg$FAILED; 1885 | } 1886 | if (s2 !== peg$FAILED) { 1887 | s3 = peg$currPos; 1888 | if (input.charCodeAt(peg$currPos) === 46) { 1889 | s4 = peg$c63; 1890 | peg$currPos++; 1891 | } else { 1892 | s4 = peg$FAILED; 1893 | if (peg$silentFails === 0) { peg$fail(peg$c64); } 1894 | } 1895 | if (s4 !== peg$FAILED) { 1896 | s5 = []; 1897 | if (peg$c65.test(input.charAt(peg$currPos))) { 1898 | s6 = input.charAt(peg$currPos); 1899 | peg$currPos++; 1900 | } else { 1901 | s6 = peg$FAILED; 1902 | if (peg$silentFails === 0) { peg$fail(peg$c66); } 1903 | } 1904 | while (s6 !== peg$FAILED) { 1905 | s5.push(s6); 1906 | if (peg$c65.test(input.charAt(peg$currPos))) { 1907 | s6 = input.charAt(peg$currPos); 1908 | peg$currPos++; 1909 | } else { 1910 | s6 = peg$FAILED; 1911 | if (peg$silentFails === 0) { peg$fail(peg$c66); } 1912 | } 1913 | } 1914 | if (s5 !== peg$FAILED) { 1915 | s4 = [s4, s5]; 1916 | s3 = s4; 1917 | } else { 1918 | peg$currPos = s3; 1919 | s3 = peg$FAILED; 1920 | } 1921 | } else { 1922 | peg$currPos = s3; 1923 | s3 = peg$FAILED; 1924 | } 1925 | if (s3 === peg$FAILED) { 1926 | s3 = null; 1927 | } 1928 | if (s3 !== peg$FAILED) { 1929 | peg$savedPos = s0; 1930 | s1 = peg$c68(s1, s2, s3); 1931 | s0 = s1; 1932 | } else { 1933 | peg$currPos = s0; 1934 | s0 = peg$FAILED; 1935 | } 1936 | } else { 1937 | peg$currPos = s0; 1938 | s0 = peg$FAILED; 1939 | } 1940 | } else { 1941 | peg$currPos = s0; 1942 | s0 = peg$FAILED; 1943 | } 1944 | if (s0 === peg$FAILED) { 1945 | s0 = peg$currPos; 1946 | if (input.charCodeAt(peg$currPos) === 34) { 1947 | s1 = peg$c69; 1948 | peg$currPos++; 1949 | } else { 1950 | s1 = peg$FAILED; 1951 | if (peg$silentFails === 0) { peg$fail(peg$c70); } 1952 | } 1953 | if (s1 !== peg$FAILED) { 1954 | s2 = []; 1955 | s3 = peg$currPos; 1956 | if (input.substr(peg$currPos, 2) === peg$c71) { 1957 | s4 = peg$c71; 1958 | peg$currPos += 2; 1959 | } else { 1960 | s4 = peg$FAILED; 1961 | if (peg$silentFails === 0) { peg$fail(peg$c72); } 1962 | } 1963 | if (s4 !== peg$FAILED) { 1964 | peg$savedPos = s3; 1965 | s4 = peg$c73(); 1966 | } 1967 | s3 = s4; 1968 | if (s3 === peg$FAILED) { 1969 | s3 = peg$currPos; 1970 | if (input.charCodeAt(peg$currPos) === 92) { 1971 | s4 = peg$c74; 1972 | peg$currPos++; 1973 | } else { 1974 | s4 = peg$FAILED; 1975 | if (peg$silentFails === 0) { peg$fail(peg$c75); } 1976 | } 1977 | if (s4 !== peg$FAILED) { 1978 | if (peg$c76.test(input.charAt(peg$currPos))) { 1979 | s5 = input.charAt(peg$currPos); 1980 | peg$currPos++; 1981 | } else { 1982 | s5 = peg$FAILED; 1983 | if (peg$silentFails === 0) { peg$fail(peg$c77); } 1984 | } 1985 | if (s5 !== peg$FAILED) { 1986 | peg$savedPos = s3; 1987 | s4 = peg$c78(s5); 1988 | s3 = s4; 1989 | } else { 1990 | peg$currPos = s3; 1991 | s3 = peg$FAILED; 1992 | } 1993 | } else { 1994 | peg$currPos = s3; 1995 | s3 = peg$FAILED; 1996 | } 1997 | if (s3 === peg$FAILED) { 1998 | if (peg$c76.test(input.charAt(peg$currPos))) { 1999 | s3 = input.charAt(peg$currPos); 2000 | peg$currPos++; 2001 | } else { 2002 | s3 = peg$FAILED; 2003 | if (peg$silentFails === 0) { peg$fail(peg$c77); } 2004 | } 2005 | } 2006 | } 2007 | while (s3 !== peg$FAILED) { 2008 | s2.push(s3); 2009 | s3 = peg$currPos; 2010 | if (input.substr(peg$currPos, 2) === peg$c71) { 2011 | s4 = peg$c71; 2012 | peg$currPos += 2; 2013 | } else { 2014 | s4 = peg$FAILED; 2015 | if (peg$silentFails === 0) { peg$fail(peg$c72); } 2016 | } 2017 | if (s4 !== peg$FAILED) { 2018 | peg$savedPos = s3; 2019 | s4 = peg$c73(); 2020 | } 2021 | s3 = s4; 2022 | if (s3 === peg$FAILED) { 2023 | s3 = peg$currPos; 2024 | if (input.charCodeAt(peg$currPos) === 92) { 2025 | s4 = peg$c74; 2026 | peg$currPos++; 2027 | } else { 2028 | s4 = peg$FAILED; 2029 | if (peg$silentFails === 0) { peg$fail(peg$c75); } 2030 | } 2031 | if (s4 !== peg$FAILED) { 2032 | if (peg$c76.test(input.charAt(peg$currPos))) { 2033 | s5 = input.charAt(peg$currPos); 2034 | peg$currPos++; 2035 | } else { 2036 | s5 = peg$FAILED; 2037 | if (peg$silentFails === 0) { peg$fail(peg$c77); } 2038 | } 2039 | if (s5 !== peg$FAILED) { 2040 | peg$savedPos = s3; 2041 | s4 = peg$c78(s5); 2042 | s3 = s4; 2043 | } else { 2044 | peg$currPos = s3; 2045 | s3 = peg$FAILED; 2046 | } 2047 | } else { 2048 | peg$currPos = s3; 2049 | s3 = peg$FAILED; 2050 | } 2051 | if (s3 === peg$FAILED) { 2052 | if (peg$c76.test(input.charAt(peg$currPos))) { 2053 | s3 = input.charAt(peg$currPos); 2054 | peg$currPos++; 2055 | } else { 2056 | s3 = peg$FAILED; 2057 | if (peg$silentFails === 0) { peg$fail(peg$c77); } 2058 | } 2059 | } 2060 | } 2061 | } 2062 | if (s2 !== peg$FAILED) { 2063 | if (input.charCodeAt(peg$currPos) === 34) { 2064 | s3 = peg$c69; 2065 | peg$currPos++; 2066 | } else { 2067 | s3 = peg$FAILED; 2068 | if (peg$silentFails === 0) { peg$fail(peg$c70); } 2069 | } 2070 | if (s3 !== peg$FAILED) { 2071 | peg$savedPos = s0; 2072 | s1 = peg$c79(s2); 2073 | s0 = s1; 2074 | } else { 2075 | peg$currPos = s0; 2076 | s0 = peg$FAILED; 2077 | } 2078 | } else { 2079 | peg$currPos = s0; 2080 | s0 = peg$FAILED; 2081 | } 2082 | } else { 2083 | peg$currPos = s0; 2084 | s0 = peg$FAILED; 2085 | } 2086 | } 2087 | } 2088 | } 2089 | peg$silentFails--; 2090 | if (s0 === peg$FAILED) { 2091 | s1 = peg$FAILED; 2092 | if (peg$silentFails === 0) { peg$fail(peg$c55); } 2093 | } 2094 | 2095 | return s0; 2096 | } 2097 | 2098 | function peg$parsenode() { 2099 | var s0, s1; 2100 | 2101 | s0 = peg$currPos; 2102 | if (input.substr(peg$currPos, 4).toLowerCase() === peg$c80) { 2103 | s1 = input.substr(peg$currPos, 4); 2104 | peg$currPos += 4; 2105 | } else { 2106 | s1 = peg$FAILED; 2107 | if (peg$silentFails === 0) { peg$fail(peg$c81); } 2108 | } 2109 | if (s1 !== peg$FAILED) { 2110 | peg$savedPos = s0; 2111 | s1 = peg$c82(s1); 2112 | } 2113 | s0 = s1; 2114 | 2115 | return s0; 2116 | } 2117 | 2118 | function peg$parseedge() { 2119 | var s0, s1; 2120 | 2121 | s0 = peg$currPos; 2122 | if (input.substr(peg$currPos, 4).toLowerCase() === peg$c83) { 2123 | s1 = input.substr(peg$currPos, 4); 2124 | peg$currPos += 4; 2125 | } else { 2126 | s1 = peg$FAILED; 2127 | if (peg$silentFails === 0) { peg$fail(peg$c84); } 2128 | } 2129 | if (s1 !== peg$FAILED) { 2130 | peg$savedPos = s0; 2131 | s1 = peg$c82(s1); 2132 | } 2133 | s0 = s1; 2134 | 2135 | return s0; 2136 | } 2137 | 2138 | function peg$parsegraph() { 2139 | var s0, s1; 2140 | 2141 | s0 = peg$currPos; 2142 | if (input.substr(peg$currPos, 5).toLowerCase() === peg$c85) { 2143 | s1 = input.substr(peg$currPos, 5); 2144 | peg$currPos += 5; 2145 | } else { 2146 | s1 = peg$FAILED; 2147 | if (peg$silentFails === 0) { peg$fail(peg$c86); } 2148 | } 2149 | if (s1 !== peg$FAILED) { 2150 | peg$savedPos = s0; 2151 | s1 = peg$c82(s1); 2152 | } 2153 | s0 = s1; 2154 | 2155 | return s0; 2156 | } 2157 | 2158 | function peg$parsedigraph() { 2159 | var s0, s1; 2160 | 2161 | s0 = peg$currPos; 2162 | if (input.substr(peg$currPos, 7).toLowerCase() === peg$c87) { 2163 | s1 = input.substr(peg$currPos, 7); 2164 | peg$currPos += 7; 2165 | } else { 2166 | s1 = peg$FAILED; 2167 | if (peg$silentFails === 0) { peg$fail(peg$c88); } 2168 | } 2169 | if (s1 !== peg$FAILED) { 2170 | peg$savedPos = s0; 2171 | s1 = peg$c82(s1); 2172 | } 2173 | s0 = s1; 2174 | 2175 | return s0; 2176 | } 2177 | 2178 | function peg$parsesubgraph() { 2179 | var s0, s1; 2180 | 2181 | s0 = peg$currPos; 2182 | if (input.substr(peg$currPos, 8).toLowerCase() === peg$c89) { 2183 | s1 = input.substr(peg$currPos, 8); 2184 | peg$currPos += 8; 2185 | } else { 2186 | s1 = peg$FAILED; 2187 | if (peg$silentFails === 0) { peg$fail(peg$c90); } 2188 | } 2189 | if (s1 !== peg$FAILED) { 2190 | peg$savedPos = s0; 2191 | s1 = peg$c82(s1); 2192 | } 2193 | s0 = s1; 2194 | 2195 | return s0; 2196 | } 2197 | 2198 | function peg$parsestrict() { 2199 | var s0, s1; 2200 | 2201 | s0 = peg$currPos; 2202 | if (input.substr(peg$currPos, 6).toLowerCase() === peg$c91) { 2203 | s1 = input.substr(peg$currPos, 6); 2204 | peg$currPos += 6; 2205 | } else { 2206 | s1 = peg$FAILED; 2207 | if (peg$silentFails === 0) { peg$fail(peg$c92); } 2208 | } 2209 | if (s1 !== peg$FAILED) { 2210 | peg$savedPos = s0; 2211 | s1 = peg$c82(s1); 2212 | } 2213 | s0 = s1; 2214 | 2215 | return s0; 2216 | } 2217 | 2218 | function peg$parsegraphType() { 2219 | var s0, s1; 2220 | 2221 | s0 = peg$parsegraph(); 2222 | if (s0 === peg$FAILED) { 2223 | s0 = peg$currPos; 2224 | s1 = peg$parsedigraph(); 2225 | if (s1 !== peg$FAILED) { 2226 | peg$savedPos = s0; 2227 | s1 = peg$c93(s1); 2228 | } 2229 | s0 = s1; 2230 | } 2231 | 2232 | return s0; 2233 | } 2234 | 2235 | function peg$parsewhitespace() { 2236 | var s0, s1; 2237 | 2238 | peg$silentFails++; 2239 | s0 = []; 2240 | if (peg$c95.test(input.charAt(peg$currPos))) { 2241 | s1 = input.charAt(peg$currPos); 2242 | peg$currPos++; 2243 | } else { 2244 | s1 = peg$FAILED; 2245 | if (peg$silentFails === 0) { peg$fail(peg$c96); } 2246 | } 2247 | if (s1 !== peg$FAILED) { 2248 | while (s1 !== peg$FAILED) { 2249 | s0.push(s1); 2250 | if (peg$c95.test(input.charAt(peg$currPos))) { 2251 | s1 = input.charAt(peg$currPos); 2252 | peg$currPos++; 2253 | } else { 2254 | s1 = peg$FAILED; 2255 | if (peg$silentFails === 0) { peg$fail(peg$c96); } 2256 | } 2257 | } 2258 | } else { 2259 | s0 = peg$FAILED; 2260 | } 2261 | peg$silentFails--; 2262 | if (s0 === peg$FAILED) { 2263 | s1 = peg$FAILED; 2264 | if (peg$silentFails === 0) { peg$fail(peg$c94); } 2265 | } 2266 | 2267 | return s0; 2268 | } 2269 | 2270 | function peg$parsecomment() { 2271 | var s0, s1, s2, s3, s4, s5; 2272 | 2273 | peg$silentFails++; 2274 | s0 = peg$currPos; 2275 | if (input.substr(peg$currPos, 2) === peg$c98) { 2276 | s1 = peg$c98; 2277 | peg$currPos += 2; 2278 | } else { 2279 | s1 = peg$FAILED; 2280 | if (peg$silentFails === 0) { peg$fail(peg$c99); } 2281 | } 2282 | if (s1 !== peg$FAILED) { 2283 | s2 = []; 2284 | if (peg$c100.test(input.charAt(peg$currPos))) { 2285 | s3 = input.charAt(peg$currPos); 2286 | peg$currPos++; 2287 | } else { 2288 | s3 = peg$FAILED; 2289 | if (peg$silentFails === 0) { peg$fail(peg$c101); } 2290 | } 2291 | while (s3 !== peg$FAILED) { 2292 | s2.push(s3); 2293 | if (peg$c100.test(input.charAt(peg$currPos))) { 2294 | s3 = input.charAt(peg$currPos); 2295 | peg$currPos++; 2296 | } else { 2297 | s3 = peg$FAILED; 2298 | if (peg$silentFails === 0) { peg$fail(peg$c101); } 2299 | } 2300 | } 2301 | if (s2 !== peg$FAILED) { 2302 | s1 = [s1, s2]; 2303 | s0 = s1; 2304 | } else { 2305 | peg$currPos = s0; 2306 | s0 = peg$FAILED; 2307 | } 2308 | } else { 2309 | peg$currPos = s0; 2310 | s0 = peg$FAILED; 2311 | } 2312 | if (s0 === peg$FAILED) { 2313 | s0 = peg$currPos; 2314 | if (input.substr(peg$currPos, 2) === peg$c102) { 2315 | s1 = peg$c102; 2316 | peg$currPos += 2; 2317 | } else { 2318 | s1 = peg$FAILED; 2319 | if (peg$silentFails === 0) { peg$fail(peg$c103); } 2320 | } 2321 | if (s1 !== peg$FAILED) { 2322 | s2 = []; 2323 | s3 = peg$currPos; 2324 | s4 = peg$currPos; 2325 | peg$silentFails++; 2326 | if (input.substr(peg$currPos, 2) === peg$c104) { 2327 | s5 = peg$c104; 2328 | peg$currPos += 2; 2329 | } else { 2330 | s5 = peg$FAILED; 2331 | if (peg$silentFails === 0) { peg$fail(peg$c105); } 2332 | } 2333 | peg$silentFails--; 2334 | if (s5 === peg$FAILED) { 2335 | s4 = void 0; 2336 | } else { 2337 | peg$currPos = s4; 2338 | s4 = peg$FAILED; 2339 | } 2340 | if (s4 !== peg$FAILED) { 2341 | if (input.length > peg$currPos) { 2342 | s5 = input.charAt(peg$currPos); 2343 | peg$currPos++; 2344 | } else { 2345 | s5 = peg$FAILED; 2346 | if (peg$silentFails === 0) { peg$fail(peg$c106); } 2347 | } 2348 | if (s5 !== peg$FAILED) { 2349 | s4 = [s4, s5]; 2350 | s3 = s4; 2351 | } else { 2352 | peg$currPos = s3; 2353 | s3 = peg$FAILED; 2354 | } 2355 | } else { 2356 | peg$currPos = s3; 2357 | s3 = peg$FAILED; 2358 | } 2359 | while (s3 !== peg$FAILED) { 2360 | s2.push(s3); 2361 | s3 = peg$currPos; 2362 | s4 = peg$currPos; 2363 | peg$silentFails++; 2364 | if (input.substr(peg$currPos, 2) === peg$c104) { 2365 | s5 = peg$c104; 2366 | peg$currPos += 2; 2367 | } else { 2368 | s5 = peg$FAILED; 2369 | if (peg$silentFails === 0) { peg$fail(peg$c105); } 2370 | } 2371 | peg$silentFails--; 2372 | if (s5 === peg$FAILED) { 2373 | s4 = void 0; 2374 | } else { 2375 | peg$currPos = s4; 2376 | s4 = peg$FAILED; 2377 | } 2378 | if (s4 !== peg$FAILED) { 2379 | if (input.length > peg$currPos) { 2380 | s5 = input.charAt(peg$currPos); 2381 | peg$currPos++; 2382 | } else { 2383 | s5 = peg$FAILED; 2384 | if (peg$silentFails === 0) { peg$fail(peg$c106); } 2385 | } 2386 | if (s5 !== peg$FAILED) { 2387 | s4 = [s4, s5]; 2388 | s3 = s4; 2389 | } else { 2390 | peg$currPos = s3; 2391 | s3 = peg$FAILED; 2392 | } 2393 | } else { 2394 | peg$currPos = s3; 2395 | s3 = peg$FAILED; 2396 | } 2397 | } 2398 | if (s2 !== peg$FAILED) { 2399 | if (input.substr(peg$currPos, 2) === peg$c104) { 2400 | s3 = peg$c104; 2401 | peg$currPos += 2; 2402 | } else { 2403 | s3 = peg$FAILED; 2404 | if (peg$silentFails === 0) { peg$fail(peg$c105); } 2405 | } 2406 | if (s3 !== peg$FAILED) { 2407 | s1 = [s1, s2, s3]; 2408 | s0 = s1; 2409 | } else { 2410 | peg$currPos = s0; 2411 | s0 = peg$FAILED; 2412 | } 2413 | } else { 2414 | peg$currPos = s0; 2415 | s0 = peg$FAILED; 2416 | } 2417 | } else { 2418 | peg$currPos = s0; 2419 | s0 = peg$FAILED; 2420 | } 2421 | } 2422 | peg$silentFails--; 2423 | if (s0 === peg$FAILED) { 2424 | s1 = peg$FAILED; 2425 | if (peg$silentFails === 0) { peg$fail(peg$c97); } 2426 | } 2427 | 2428 | return s0; 2429 | } 2430 | 2431 | function peg$parse_() { 2432 | var s0; 2433 | 2434 | s0 = peg$parsewhitespace(); 2435 | if (s0 === peg$FAILED) { 2436 | s0 = peg$parsecomment(); 2437 | } 2438 | 2439 | return s0; 2440 | } 2441 | 2442 | 2443 | function merge(a, b, key) { 2444 | 2445 | function x(a) { 2446 | a.forEach(function (b) { 2447 | if (!(b[key] in obj)) { 2448 | obj[b[key]] = obj[b[key]] || {}; 2449 | array.push(obj[b[key]]); 2450 | } 2451 | Object.keys(b).forEach(function (k) { 2452 | obj[b[key]][k] = b[k]; 2453 | }); 2454 | }); 2455 | } 2456 | 2457 | var array = [], 2458 | obj = {}; 2459 | 2460 | x(a); 2461 | x(b); 2462 | return array; 2463 | } 2464 | 2465 | var directed; 2466 | 2467 | 2468 | peg$result = peg$startRuleFunction(); 2469 | 2470 | if (peg$result !== peg$FAILED && peg$currPos === input.length) { 2471 | return peg$result; 2472 | } else { 2473 | if (peg$result !== peg$FAILED && peg$currPos < input.length) { 2474 | peg$fail(peg$endExpectation()); 2475 | } 2476 | 2477 | throw peg$buildStructuredError( 2478 | peg$maxFailExpected, 2479 | peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, 2480 | peg$maxFailPos < input.length 2481 | ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) 2482 | : peg$computeLocation(peg$maxFailPos, peg$maxFailPos) 2483 | ); 2484 | } 2485 | } 2486 | 2487 | root.d3dotparser1 = { 2488 | SyntaxError: peg$SyntaxError, 2489 | parse: peg$parse 2490 | }; 2491 | })(this); 2492 | --------------------------------------------------------------------------------