From a5fc9043763a8c0f58005e96c262c741a2cd21aa Mon Sep 17 00:00:00 2001 From: Forrest Oliphant Date: Thu, 16 Apr 2015 09:10:41 -0400 Subject: [PATCH 1/3] parseFloat numerical metadata https://github.com/the-grid/the-graph/issues/208 --- grammar/fbp.peg | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/grammar/fbp.peg b/grammar/fbp.peg index 5df3084..43abee6 100644 --- a/grammar/fbp.peg +++ b/grammar/fbp.peg @@ -29,7 +29,12 @@ if (item.length === 1) { item = ['routes', item[0]]; } - metadata[item[0]] = item[1]; + var key = item[0]; + var value = item[1]; + if (key==='x' || key==='y') { + value = parseFloat(value); + } + metadata[key] = value; } nodes[nodeName].metadata=metadata; } From 348b9fe3b87792f5abc3aca9e5ad9dd31898f297 Mon Sep 17 00:00:00 2001 From: forresto Date: Thu, 16 Apr 2015 09:41:35 -0400 Subject: [PATCH 2/3] spec for node x/y metadata --- spec/fbp.coffee | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/fbp.coffee b/spec/fbp.coffee index e859b81..37aa263 100644 --- a/spec/fbp.coffee +++ b/spec/fbp.coffee @@ -303,6 +303,25 @@ describe 'FBP parser', -> chai.expect(graphData.inports).to.be.an 'undefined' chai.expect(graphData.outports).to.be.an 'undefined' + describe 'with FBP string containing node x/y metadata', -> + fbpData = """ + Read(ReadFile) OUT -> IN Display(Output:foo=bar,x=17,y=42) + """ + graphData = null + it 'should produce a graph JSON object', -> + graphData = parser.parse fbpData + chai.expect(graphData).to.be.an 'object' + it 'should contain nodes with numerical x/y metadata', -> + chai.expect(graphData.processes).to.eql + Read: + component: 'ReadFile' + Display: + component: 'Output' + metadata: + foo: 'bar' + x: 17 + y: 42 + describe 'with an invalid FBP string', -> fbpData = """ 'foo' -> Display(Output) From 79e8a13892b1cbc9f94cf82e0ce34b347023959d Mon Sep 17 00:00:00 2001 From: forresto Date: Thu, 16 Apr 2015 09:59:24 -0400 Subject: [PATCH 3/3] grunt-peg options changed --- Gruntfile.coffee | 4 +- lib/fbp.js | 2924 ++++++++++++++++++++++------------------------ 2 files changed, 1408 insertions(+), 1520 deletions(-) diff --git a/Gruntfile.coffee b/Gruntfile.coffee index 7f39ae5..fefd2e0 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -6,8 +6,8 @@ module.exports = -> # Generate library from Peg grammar peg: fbp: - grammar: 'grammar/fbp.peg' - outputFile: 'lib/fbp.js' + src: 'grammar/fbp.peg' + dest: 'lib/fbp.js' # Build the browser Component noflo_browser: diff --git a/lib/fbp.js b/lib/fbp.js index f671eed..0d198e1 100644 --- a/lib/fbp.js +++ b/lib/fbp.js @@ -1,1779 +1,1667 @@ -module.exports = (function(){ +module.exports = (function() { /* - * Generated by PEG.js 0.7.0. + * Generated by PEG.js 0.8.0. * * http://pegjs.majda.cz/ */ - - function quote(s) { - /* - * ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a - * string literal except for the closing quote character, backslash, - * carriage return, line separator, paragraph separator, and line feed. - * Any character may appear in the form of an escape sequence. - * - * For portability, we also escape escape all control and non-ASCII - * characters. Note that "\0" and "\v" escape sequences are not used - * because JSHint does not like the first and IE the second. - */ - return '"' + s - .replace(/\\/g, '\\\\') // backslash - .replace(/"/g, '\\"') // closing quote character - .replace(/\x08/g, '\\b') // backspace - .replace(/\t/g, '\\t') // horizontal tab - .replace(/\n/g, '\\n') // line feed - .replace(/\f/g, '\\f') // form feed - .replace(/\r/g, '\\r') // carriage return - .replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g, escape) - + '"'; + + function peg$subclass(child, parent) { + function ctor() { this.constructor = child; } + ctor.prototype = parent.prototype; + child.prototype = new ctor(); } - - var result = { - /* - * Parses the input with a generated parser. If the parsing is successfull, - * returns a value explicitly or implicitly specified by the grammar from - * which the parser was generated (see |PEG.buildParser|). If the parsing is - * unsuccessful, throws |PEG.parser.SyntaxError| describing the error. - */ - parse: function(input, startRule) { - var parseFunctions = { - "start": parse_start, - "line": parse_line, - "LineTerminator": parse_LineTerminator, - "comment": parse_comment, - "connection": parse_connection, - "bridge": parse_bridge, - "leftlet": parse_leftlet, - "iip": parse_iip, - "rightlet": parse_rightlet, - "node": parse_node, - "component": parse_component, - "compMeta": parse_compMeta, - "port": parse_port, - "portWithIndex": parse_portWithIndex, - "anychar": parse_anychar, - "iipchar": parse_iipchar, - "_": parse__, - "__": parse___ - }; - - if (startRule !== undefined) { - if (parseFunctions[startRule] === undefined) { - throw new Error("Invalid rule name: " + quote(startRule) + "."); - } - } else { - startRule = "start"; + + function SyntaxError(message, expected, found, offset, line, column) { + this.message = message; + this.expected = expected; + this.found = found; + this.offset = offset; + this.line = line; + this.column = column; + + this.name = "SyntaxError"; + } + + peg$subclass(SyntaxError, Error); + + function parse(input) { + var options = arguments.length > 1 ? arguments[1] : {}, + + peg$FAILED = {}, + + peg$startRuleFunctions = { start: peg$parsestart }, + peg$startRuleFunction = peg$parsestart, + + peg$c0 = [], + peg$c1 = function() { return parser.getResult(); }, + peg$c2 = peg$FAILED, + peg$c3 = "EXPORT=", + peg$c4 = { type: "literal", value: "EXPORT=", description: "\"EXPORT=\"" }, + peg$c5 = /^[A-Za-z.0-9_]/, + peg$c6 = { type: "class", value: "[A-Za-z.0-9_]", description: "[A-Za-z.0-9_]" }, + peg$c7 = ":", + peg$c8 = { type: "literal", value: ":", description: "\":\"" }, + peg$c9 = /^[A-Z0-9_]/, + peg$c10 = { type: "class", value: "[A-Z0-9_]", description: "[A-Z0-9_]" }, + peg$c11 = null, + peg$c12 = function(priv, pub) {return parser.registerExports(priv.join(""),pub.join(""))}, + peg$c13 = "INPORT=", + peg$c14 = { type: "literal", value: "INPORT=", description: "\"INPORT=\"" }, + peg$c15 = /^[A-Za-z0-9_]/, + peg$c16 = { type: "class", value: "[A-Za-z0-9_]", description: "[A-Za-z0-9_]" }, + peg$c17 = ".", + peg$c18 = { type: "literal", value: ".", description: "\".\"" }, + peg$c19 = function(node, port, pub) {return parser.registerInports(node.join(""),port.join(""),pub.join(""))}, + peg$c20 = "OUTPORT=", + peg$c21 = { type: "literal", value: "OUTPORT=", description: "\"OUTPORT=\"" }, + peg$c22 = function(node, port, pub) {return parser.registerOutports(node.join(""),port.join(""),pub.join(""))}, + peg$c23 = /^[\n\r\u2028\u2029]/, + peg$c24 = { type: "class", value: "[\\n\\r\\u2028\\u2029]", description: "[\\n\\r\\u2028\\u2029]" }, + peg$c25 = function(edges) {return parser.registerEdges(edges);}, + peg$c26 = ",", + peg$c27 = { type: "literal", value: ",", description: "\",\"" }, + peg$c28 = "#", + peg$c29 = { type: "literal", value: "#", description: "\"#\"" }, + peg$c30 = "->", + peg$c31 = { type: "literal", value: "->", description: "\"->\"" }, + peg$c32 = function(x, y) { return [x,y]; }, + peg$c33 = function(x, proc, y) { return [{"tgt":{process:proc, port:x}},{"src":{process:proc, port:y}}]; }, + peg$c34 = function(proc, port) { return {"src":{process:proc, port:port}} }, + peg$c35 = function(proc, port) { return {"src":{process:proc, port:port.port, index: port.index}} }, + peg$c36 = "'", + peg$c37 = { type: "literal", value: "'", description: "\"'\"" }, + peg$c38 = function(iip) { return {"data":iip.join("")} }, + peg$c39 = function(port, proc) { return {"tgt":{process:proc, port:port}} }, + peg$c40 = function(port, proc) { return {"tgt":{process:proc, port:port.port, index: port.index}} }, + peg$c41 = /^[a-zA-Z0-9_]/, + peg$c42 = { type: "class", value: "[a-zA-Z0-9_]", description: "[a-zA-Z0-9_]" }, + peg$c43 = function(node, comp) { if(comp){parser.addNode(node.join(""),comp);}; return node.join("")}, + peg$c44 = "(", + peg$c45 = { type: "literal", value: "(", description: "\"(\"" }, + peg$c46 = /^[a-zA-Z\/\-0-9_]/, + peg$c47 = { type: "class", value: "[a-zA-Z\\/\\-0-9_]", description: "[a-zA-Z\\/\\-0-9_]" }, + peg$c48 = ")", + peg$c49 = { type: "literal", value: ")", description: "\")\"" }, + peg$c50 = function(comp, meta) { var o = {}; comp ? o.comp = comp.join("") : o.comp = ''; meta ? o.meta = meta.join("").split(',') : null; return o; }, + peg$c51 = /^[a-zA-Z\/=_,0-9]/, + peg$c52 = { type: "class", value: "[a-zA-Z\\/=_,0-9]", description: "[a-zA-Z\\/=_,0-9]" }, + peg$c53 = function(meta) {return meta}, + peg$c54 = /^[A-Z.0-9_]/, + peg$c55 = { type: "class", value: "[A-Z.0-9_]", description: "[A-Z.0-9_]" }, + peg$c56 = function(portname) {return portname.join("").toLowerCase()}, + peg$c57 = "[", + peg$c58 = { type: "literal", value: "[", description: "\"[\"" }, + peg$c59 = /^[0-9]/, + peg$c60 = { type: "class", value: "[0-9]", description: "[0-9]" }, + peg$c61 = "]", + peg$c62 = { type: "literal", value: "]", description: "\"]\"" }, + peg$c63 = function(portname, portindex) {return { port: portname.join("").toLowerCase(), index: parseInt(portindex.join('')) }}, + peg$c64 = /^[^\n\r\u2028\u2029]/, + peg$c65 = { type: "class", value: "[^\\n\\r\\u2028\\u2029]", description: "[^\\n\\r\\u2028\\u2029]" }, + peg$c66 = /^[\\]/, + peg$c67 = { type: "class", value: "[\\\\]", description: "[\\\\]" }, + peg$c68 = /^[']/, + peg$c69 = { type: "class", value: "[']", description: "[']" }, + peg$c70 = function() { return "'"; }, + peg$c71 = /^[^']/, + peg$c72 = { type: "class", value: "[^']", description: "[^']" }, + peg$c73 = " ", + peg$c74 = { type: "literal", value: " ", description: "\" \"" }, + + peg$currPos = 0, + peg$reportedPos = 0, + peg$cachedPos = 0, + peg$cachedPosDetails = { line: 1, column: 1, seenCR: false }, + peg$maxFailPos = 0, + peg$maxFailExpected = [], + peg$silentFails = 0, + + peg$result; + + if ("startRule" in options) { + if (!(options.startRule in peg$startRuleFunctions)) { + throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); } - - var pos = 0; - var reportFailures = 0; - var rightmostFailuresPos = 0; - var rightmostFailuresExpected = []; - - function padLeft(input, padding, length) { - var result = input; - - var padLength = length - input.length; - for (var i = 0; i < padLength; i++) { - result = padding + result; + + peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; + } + + function text() { + return input.substring(peg$reportedPos, peg$currPos); + } + + function offset() { + return peg$reportedPos; + } + + function line() { + return peg$computePosDetails(peg$reportedPos).line; + } + + function column() { + return peg$computePosDetails(peg$reportedPos).column; + } + + function expected(description) { + throw peg$buildException( + null, + [{ type: "other", description: description }], + peg$reportedPos + ); + } + + function error(message) { + throw peg$buildException(message, null, peg$reportedPos); + } + + function peg$computePosDetails(pos) { + function advance(details, startPos, endPos) { + var p, ch; + + for (p = startPos; p < endPos; p++) { + ch = input.charAt(p); + if (ch === "\n") { + if (!details.seenCR) { details.line++; } + details.column = 1; + details.seenCR = false; + } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") { + details.line++; + details.column = 1; + details.seenCR = true; + } else { + details.column++; + details.seenCR = false; + } } - - return result; } - - function escape(ch) { - var charCode = ch.charCodeAt(0); - var escapeChar; - var length; - - if (charCode <= 0xFF) { - escapeChar = 'x'; - length = 2; - } else { - escapeChar = 'u'; - length = 4; - } - - return '\\' + escapeChar + padLeft(charCode.toString(16).toUpperCase(), '0', length); + + if (peg$cachedPos !== pos) { + if (peg$cachedPos > pos) { + peg$cachedPos = 0; + peg$cachedPosDetails = { line: 1, column: 1, seenCR: false }; + } + advance(peg$cachedPosDetails, peg$cachedPos, pos); + peg$cachedPos = pos; } - - function matchFailed(failure) { - if (pos < rightmostFailuresPos) { - return; - } - - if (pos > rightmostFailuresPos) { - rightmostFailuresPos = pos; - rightmostFailuresExpected = []; - } - - rightmostFailuresExpected.push(failure); + + return peg$cachedPosDetails; + } + + function peg$fail(expected) { + if (peg$currPos < peg$maxFailPos) { return; } + + if (peg$currPos > peg$maxFailPos) { + peg$maxFailPos = peg$currPos; + peg$maxFailExpected = []; } - - function parse_start() { - var result0, result1; - var pos0; - - pos0 = pos; - result0 = []; - result1 = parse_line(); - while (result1 !== null) { - result0.push(result1); - result1 = parse_line(); - } - if (result0 !== null) { - result0 = (function(offset) { return parser.getResult(); })(pos0); - } - if (result0 === null) { - pos = pos0; + + peg$maxFailExpected.push(expected); + } + + function peg$buildException(message, expected, pos) { + function cleanupExpected(expected) { + var i = 1; + + expected.sort(function(a, b) { + if (a.description < b.description) { + return -1; + } else if (a.description > b.description) { + return 1; + } else { + return 0; + } + }); + + while (i < expected.length) { + if (expected[i - 1] === expected[i]) { + expected.splice(i, 1); + } else { + i++; + } } - return result0; } - - function parse_line() { - var result0, result1, result2, result3, result4, result5, result6, result7, result8; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse__(); - if (result0 !== null) { - if (input.substr(pos, 7) === "EXPORT=") { - result1 = "EXPORT="; - pos += 7; + + function buildMessage(expected, found) { + function stringEscape(s) { + function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); } + + return s + .replace(/\\/g, '\\\\') + .replace(/"/g, '\\"') + .replace(/\x08/g, '\\b') + .replace(/\t/g, '\\t') + .replace(/\n/g, '\\n') + .replace(/\f/g, '\\f') + .replace(/\r/g, '\\r') + .replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) + .replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); }) + .replace(/[\u0180-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); }) + .replace(/[\u1080-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); }); + } + + var expectedDescs = new Array(expected.length), + expectedDesc, foundDesc, i; + + for (i = 0; i < expected.length; i++) { + expectedDescs[i] = expected[i].description; + } + + expectedDesc = expected.length > 1 + ? expectedDescs.slice(0, -1).join(", ") + + " or " + + expectedDescs[expected.length - 1] + : expectedDescs[0]; + + foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input"; + + return "Expected " + expectedDesc + " but " + foundDesc + " found."; + } + + var posDetails = peg$computePosDetails(pos), + found = pos < input.length ? input.charAt(pos) : null; + + if (expected !== null) { + cleanupExpected(expected); + } + + return new SyntaxError( + message !== null ? message : buildMessage(expected, found), + expected, + found, + pos, + posDetails.line, + posDetails.column + ); + } + + function peg$parsestart() { + var s0, s1, s2; + + s0 = peg$currPos; + s1 = []; + s2 = peg$parseline(); + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$parseline(); + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c1(); + } + s0 = s1; + + return s0; + } + + function peg$parseline() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; + + s0 = peg$currPos; + s1 = peg$parse_(); + if (s1 !== peg$FAILED) { + if (input.substr(peg$currPos, 7) === peg$c3) { + s2 = peg$c3; + peg$currPos += 7; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c4); } + } + if (s2 !== peg$FAILED) { + s3 = []; + if (peg$c5.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"EXPORT=\""); - } + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } } - if (result1 !== null) { - if (/^[A-Za-z.0-9_]/.test(input.charAt(pos))) { - result3 = input.charAt(pos); - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("[A-Za-z.0-9_]"); + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + if (peg$c5.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } } } - if (result3 !== null) { - result2 = []; - while (result3 !== null) { - result2.push(result3); - if (/^[A-Za-z.0-9_]/.test(input.charAt(pos))) { - result3 = input.charAt(pos); - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("[A-Za-z.0-9_]"); - } - } - } + } else { + s3 = peg$c2; + } + if (s3 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 58) { + s4 = peg$c7; + peg$currPos++; } else { - result2 = null; + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c8); } } - if (result2 !== null) { - if (input.charCodeAt(pos) === 58) { - result3 = ":"; - pos++; + if (s4 !== peg$FAILED) { + s5 = []; + if (peg$c9.test(input.charAt(peg$currPos))) { + s6 = input.charAt(peg$currPos); + peg$currPos++; } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c10); } } - if (result3 !== null) { - if (/^[A-Z0-9_]/.test(input.charAt(pos))) { - result5 = input.charAt(pos); - pos++; - } else { - result5 = null; - if (reportFailures === 0) { - matchFailed("[A-Z0-9_]"); + if (s6 !== peg$FAILED) { + while (s6 !== peg$FAILED) { + s5.push(s6); + if (peg$c9.test(input.charAt(peg$currPos))) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c10); } } } - if (result5 !== null) { - result4 = []; - while (result5 !== null) { - result4.push(result5); - if (/^[A-Z0-9_]/.test(input.charAt(pos))) { - result5 = input.charAt(pos); - pos++; - } else { - result5 = null; - if (reportFailures === 0) { - matchFailed("[A-Z0-9_]"); - } - } + } else { + s5 = peg$c2; + } + if (s5 !== peg$FAILED) { + s6 = peg$parse_(); + if (s6 !== peg$FAILED) { + s7 = peg$parseLineTerminator(); + if (s7 === peg$FAILED) { + s7 = peg$c11; } - } else { - result4 = null; - } - if (result4 !== null) { - result5 = parse__(); - if (result5 !== null) { - result6 = parse_LineTerminator(); - result6 = result6 !== null ? result6 : ""; - if (result6 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6]; - } else { - result0 = null; - pos = pos1; - } + if (s7 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c12(s3, s5); + s0 = s1; } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, priv, pub) {return parser.registerExports(priv.join(""),pub.join(""))})(pos0, result0[2], result0[4]); + peg$currPos = s0; + s0 = peg$c2; } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - pos1 = pos; - result0 = parse__(); - if (result0 !== null) { - if (input.substr(pos, 7) === "INPORT=") { - result1 = "INPORT="; - pos += 7; + } else { + peg$currPos = s0; + s0 = peg$c2; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parse_(); + if (s1 !== peg$FAILED) { + if (input.substr(peg$currPos, 7) === peg$c13) { + s2 = peg$c13; + peg$currPos += 7; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c14); } + } + if (s2 !== peg$FAILED) { + s3 = []; + if (peg$c15.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"INPORT=\""); - } + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c16); } } - if (result1 !== null) { - if (/^[A-Za-z0-9_]/.test(input.charAt(pos))) { - result3 = input.charAt(pos); - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("[A-Za-z0-9_]"); + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + if (peg$c15.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c16); } } } - if (result3 !== null) { - result2 = []; - while (result3 !== null) { - result2.push(result3); - if (/^[A-Za-z0-9_]/.test(input.charAt(pos))) { - result3 = input.charAt(pos); - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("[A-Za-z0-9_]"); - } - } - } + } else { + s3 = peg$c2; + } + if (s3 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s4 = peg$c17; + peg$currPos++; } else { - result2 = null; + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c18); } } - if (result2 !== null) { - if (input.charCodeAt(pos) === 46) { - result3 = "."; - pos++; + if (s4 !== peg$FAILED) { + s5 = []; + if (peg$c9.test(input.charAt(peg$currPos))) { + s6 = input.charAt(peg$currPos); + peg$currPos++; } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c10); } } - if (result3 !== null) { - if (/^[A-Z0-9_]/.test(input.charAt(pos))) { - result5 = input.charAt(pos); - pos++; - } else { - result5 = null; - if (reportFailures === 0) { - matchFailed("[A-Z0-9_]"); + if (s6 !== peg$FAILED) { + while (s6 !== peg$FAILED) { + s5.push(s6); + if (peg$c9.test(input.charAt(peg$currPos))) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c10); } } } - if (result5 !== null) { - result4 = []; - while (result5 !== null) { - result4.push(result5); - if (/^[A-Z0-9_]/.test(input.charAt(pos))) { - result5 = input.charAt(pos); - pos++; - } else { - result5 = null; - if (reportFailures === 0) { - matchFailed("[A-Z0-9_]"); - } - } - } + } else { + s5 = peg$c2; + } + if (s5 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 58) { + s6 = peg$c7; + peg$currPos++; } else { - result4 = null; + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c8); } } - if (result4 !== null) { - if (input.charCodeAt(pos) === 58) { - result5 = ":"; - pos++; + if (s6 !== peg$FAILED) { + s7 = []; + if (peg$c9.test(input.charAt(peg$currPos))) { + s8 = input.charAt(peg$currPos); + peg$currPos++; } else { - result5 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } + s8 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c10); } } - if (result5 !== null) { - if (/^[A-Z0-9_]/.test(input.charAt(pos))) { - result7 = input.charAt(pos); - pos++; - } else { - result7 = null; - if (reportFailures === 0) { - matchFailed("[A-Z0-9_]"); + if (s8 !== peg$FAILED) { + while (s8 !== peg$FAILED) { + s7.push(s8); + if (peg$c9.test(input.charAt(peg$currPos))) { + s8 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s8 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c10); } } } - if (result7 !== null) { - result6 = []; - while (result7 !== null) { - result6.push(result7); - if (/^[A-Z0-9_]/.test(input.charAt(pos))) { - result7 = input.charAt(pos); - pos++; - } else { - result7 = null; - if (reportFailures === 0) { - matchFailed("[A-Z0-9_]"); - } - } + } else { + s7 = peg$c2; + } + if (s7 !== peg$FAILED) { + s8 = peg$parse_(); + if (s8 !== peg$FAILED) { + s9 = peg$parseLineTerminator(); + if (s9 === peg$FAILED) { + s9 = peg$c11; } - } else { - result6 = null; - } - if (result6 !== null) { - result7 = parse__(); - if (result7 !== null) { - result8 = parse_LineTerminator(); - result8 = result8 !== null ? result8 : ""; - if (result8 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8]; - } else { - result0 = null; - pos = pos1; - } + if (s9 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c19(s3, s5, s7); + s0 = s1; } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, node, port, pub) {return parser.registerInports(node.join(""),port.join(""),pub.join(""))})(pos0, result0[2], result0[4], result0[6]); + peg$currPos = s0; + s0 = peg$c2; } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - pos1 = pos; - result0 = parse__(); - if (result0 !== null) { - if (input.substr(pos, 8) === "OUTPORT=") { - result1 = "OUTPORT="; - pos += 8; + } else { + peg$currPos = s0; + s0 = peg$c2; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parse_(); + if (s1 !== peg$FAILED) { + if (input.substr(peg$currPos, 8) === peg$c20) { + s2 = peg$c20; + peg$currPos += 8; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c21); } + } + if (s2 !== peg$FAILED) { + s3 = []; + if (peg$c15.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"OUTPORT=\""); - } + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c16); } } - if (result1 !== null) { - if (/^[A-Za-z0-9_]/.test(input.charAt(pos))) { - result3 = input.charAt(pos); - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("[A-Za-z0-9_]"); + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + if (peg$c15.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c16); } } } - if (result3 !== null) { - result2 = []; - while (result3 !== null) { - result2.push(result3); - if (/^[A-Za-z0-9_]/.test(input.charAt(pos))) { - result3 = input.charAt(pos); - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("[A-Za-z0-9_]"); - } - } - } + } else { + s3 = peg$c2; + } + if (s3 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s4 = peg$c17; + peg$currPos++; } else { - result2 = null; + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c18); } } - if (result2 !== null) { - if (input.charCodeAt(pos) === 46) { - result3 = "."; - pos++; + if (s4 !== peg$FAILED) { + s5 = []; + if (peg$c9.test(input.charAt(peg$currPos))) { + s6 = input.charAt(peg$currPos); + peg$currPos++; } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c10); } } - if (result3 !== null) { - if (/^[A-Z0-9_]/.test(input.charAt(pos))) { - result5 = input.charAt(pos); - pos++; - } else { - result5 = null; - if (reportFailures === 0) { - matchFailed("[A-Z0-9_]"); + if (s6 !== peg$FAILED) { + while (s6 !== peg$FAILED) { + s5.push(s6); + if (peg$c9.test(input.charAt(peg$currPos))) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c10); } } } - if (result5 !== null) { - result4 = []; - while (result5 !== null) { - result4.push(result5); - if (/^[A-Z0-9_]/.test(input.charAt(pos))) { - result5 = input.charAt(pos); - pos++; - } else { - result5 = null; - if (reportFailures === 0) { - matchFailed("[A-Z0-9_]"); - } - } - } + } else { + s5 = peg$c2; + } + if (s5 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 58) { + s6 = peg$c7; + peg$currPos++; } else { - result4 = null; + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c8); } } - if (result4 !== null) { - if (input.charCodeAt(pos) === 58) { - result5 = ":"; - pos++; + if (s6 !== peg$FAILED) { + s7 = []; + if (peg$c9.test(input.charAt(peg$currPos))) { + s8 = input.charAt(peg$currPos); + peg$currPos++; } else { - result5 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } + s8 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c10); } } - if (result5 !== null) { - if (/^[A-Z0-9_]/.test(input.charAt(pos))) { - result7 = input.charAt(pos); - pos++; - } else { - result7 = null; - if (reportFailures === 0) { - matchFailed("[A-Z0-9_]"); + if (s8 !== peg$FAILED) { + while (s8 !== peg$FAILED) { + s7.push(s8); + if (peg$c9.test(input.charAt(peg$currPos))) { + s8 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s8 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c10); } } } - if (result7 !== null) { - result6 = []; - while (result7 !== null) { - result6.push(result7); - if (/^[A-Z0-9_]/.test(input.charAt(pos))) { - result7 = input.charAt(pos); - pos++; - } else { - result7 = null; - if (reportFailures === 0) { - matchFailed("[A-Z0-9_]"); - } - } + } else { + s7 = peg$c2; + } + if (s7 !== peg$FAILED) { + s8 = peg$parse_(); + if (s8 !== peg$FAILED) { + s9 = peg$parseLineTerminator(); + if (s9 === peg$FAILED) { + s9 = peg$c11; } - } else { - result6 = null; - } - if (result6 !== null) { - result7 = parse__(); - if (result7 !== null) { - result8 = parse_LineTerminator(); - result8 = result8 !== null ? result8 : ""; - if (result8 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8]; - } else { - result0 = null; - pos = pos1; - } + if (s9 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c22(s3, s5, s7); + s0 = s1; } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } - if (result0 !== null) { - result0 = (function(offset, node, port, pub) {return parser.registerOutports(node.join(""),port.join(""),pub.join(""))})(pos0, result0[2], result0[4], result0[6]); - } - if (result0 === null) { - pos = pos0; + } else { + peg$currPos = s0; + s0 = peg$c2; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parsecomment(); + if (s1 !== peg$FAILED) { + if (peg$c23.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c24); } + } + if (s2 === peg$FAILED) { + s2 = peg$c11; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c2; + } + } else { + peg$currPos = s0; + s0 = peg$c2; } - if (result0 === null) { - pos0 = pos; - result0 = parse_comment(); - if (result0 !== null) { - if (/^[\n\r\u2028\u2029]/.test(input.charAt(pos))) { - result1 = input.charAt(pos); - pos++; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parse_(); + if (s1 !== peg$FAILED) { + if (peg$c23.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[\\n\\r\\u2028\\u2029]"); - } + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c24); } } - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - result0 = [result0, result1]; + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; } else { - result0 = null; - pos = pos0; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos0; + peg$currPos = s0; + s0 = peg$c2; } - if (result0 === null) { - pos0 = pos; - result0 = parse__(); - if (result0 !== null) { - if (/^[\n\r\u2028\u2029]/.test(input.charAt(pos))) { - result1 = input.charAt(pos); - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[\\n\\r\\u2028\\u2029]"); - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - pos1 = pos; - result0 = parse__(); - if (result0 !== null) { - result1 = parse_connection(); - if (result1 !== null) { - result2 = parse__(); - if (result2 !== null) { - result3 = parse_LineTerminator(); - result3 = result3 !== null ? result3 : ""; - if (result3 !== null) { - result0 = [result0, result1, result2, result3]; - } else { - result0 = null; - pos = pos1; - } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parse_(); + if (s1 !== peg$FAILED) { + s2 = peg$parseconnection(); + if (s2 !== peg$FAILED) { + s3 = peg$parse_(); + if (s3 !== peg$FAILED) { + s4 = peg$parseLineTerminator(); + if (s4 === peg$FAILED) { + s4 = peg$c11; + } + if (s4 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c25(s2); + s0 = s1; } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, edges) {return parser.registerEdges(edges);})(pos0, result0[1]); - } - if (result0 === null) { - pos = pos0; + peg$currPos = s0; + s0 = peg$c2; } + } else { + peg$currPos = s0; + s0 = peg$c2; } } } } } - return result0; } - - function parse_LineTerminator() { - var result0, result1, result2, result3; - var pos0; - - pos0 = pos; - result0 = parse__(); - if (result0 !== null) { - if (input.charCodeAt(pos) === 44) { - result1 = ","; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\",\""); - } + + return s0; + } + + function peg$parseLineTerminator() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + s1 = peg$parse_(); + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 44) { + s2 = peg$c26; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c27); } + } + if (s2 === peg$FAILED) { + s2 = peg$c11; + } + if (s2 !== peg$FAILED) { + s3 = peg$parsecomment(); + if (s3 === peg$FAILED) { + s3 = peg$c11; } - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - result2 = parse_comment(); - result2 = result2 !== null ? result2 : ""; - if (result2 !== null) { - if (/^[\n\r\u2028\u2029]/.test(input.charAt(pos))) { - result3 = input.charAt(pos); - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("[\\n\\r\\u2028\\u2029]"); - } - } - result3 = result3 !== null ? result3 : ""; - if (result3 !== null) { - result0 = [result0, result1, result2, result3]; - } else { - result0 = null; - pos = pos0; - } + if (s3 !== peg$FAILED) { + if (peg$c23.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c24); } + } + if (s4 === peg$FAILED) { + s4 = peg$c11; + } + if (s4 !== peg$FAILED) { + s1 = [s1, s2, s3, s4]; + s0 = s1; } else { - result0 = null; - pos = pos0; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos0; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos0; + peg$currPos = s0; + s0 = peg$c2; } - return result0; + } else { + peg$currPos = s0; + s0 = peg$c2; } - - function parse_comment() { - var result0, result1, result2, result3; - var pos0; - - pos0 = pos; - result0 = parse__(); - if (result0 !== null) { - if (input.charCodeAt(pos) === 35) { - result1 = "#"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"#\""); - } + + return s0; + } + + function peg$parsecomment() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + s1 = peg$parse_(); + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 35) { + s2 = peg$c28; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c29); } + } + if (s2 !== peg$FAILED) { + s3 = []; + s4 = peg$parseanychar(); + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$parseanychar(); } - if (result1 !== null) { - result2 = []; - result3 = parse_anychar(); - while (result3 !== null) { - result2.push(result3); - result3 = parse_anychar(); - } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos0; - } + if (s3 !== peg$FAILED) { + s1 = [s1, s2, s3]; + s0 = s1; } else { - result0 = null; - pos = pos0; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos0; + peg$currPos = s0; + s0 = peg$c2; } - return result0; + } else { + peg$currPos = s0; + s0 = peg$c2; } - - function parse_connection() { - var result0, result1, result2, result3, result4; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_bridge(); - if (result0 !== null) { - result1 = parse__(); - if (result1 !== null) { - if (input.substr(pos, 2) === "->") { - result2 = "->"; - pos += 2; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"->\""); - } - } - if (result2 !== null) { - result3 = parse__(); - if (result3 !== null) { - result4 = parse_connection(); - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos1; - } + + return s0; + } + + function peg$parseconnection() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = peg$parsebridge(); + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + if (s2 !== peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c30) { + s3 = peg$c30; + peg$currPos += 2; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c31); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parse_(); + if (s4 !== peg$FAILED) { + s5 = peg$parseconnection(); + if (s5 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c32(s1, s5); + s0 = s1; } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, x, y) { return [x,y]; })(pos0, result0[0], result0[4]); + peg$currPos = s0; + s0 = peg$c2; } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - result0 = parse_bridge(); - } - return result0; + } else { + peg$currPos = s0; + s0 = peg$c2; } - - function parse_bridge() { - var result0, result1, result2, result3, result4; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_port(); - if (result0 !== null) { - result1 = parse__(); - if (result1 !== null) { - result2 = parse_node(); - if (result2 !== null) { - result3 = parse__(); - if (result3 !== null) { - result4 = parse_port(); - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos1; - } + if (s0 === peg$FAILED) { + s0 = peg$parsebridge(); + } + + return s0; + } + + function peg$parsebridge() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = peg$parseport(); + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + if (s2 !== peg$FAILED) { + s3 = peg$parsenode(); + if (s3 !== peg$FAILED) { + s4 = peg$parse_(); + if (s4 !== peg$FAILED) { + s5 = peg$parseport(); + if (s5 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c33(s1, s3, s5); + s0 = s1; } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, x, proc, y) { return [{"tgt":{process:proc, port:x}},{"src":{process:proc, port:y}}]; })(pos0, result0[0], result0[2], result0[4]); + peg$currPos = s0; + s0 = peg$c2; } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - result0 = parse_iip(); - if (result0 === null) { - result0 = parse_rightlet(); - if (result0 === null) { - result0 = parse_leftlet(); - } + } else { + peg$currPos = s0; + s0 = peg$c2; + } + if (s0 === peg$FAILED) { + s0 = peg$parseiip(); + if (s0 === peg$FAILED) { + s0 = peg$parserightlet(); + if (s0 === peg$FAILED) { + s0 = peg$parseleftlet(); } } - return result0; } - - function parse_leftlet() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_node(); - if (result0 !== null) { - result1 = parse__(); - if (result1 !== null) { - result2 = parse_port(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } + + return s0; + } + + function peg$parseleftlet() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parsenode(); + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + if (s2 !== peg$FAILED) { + s3 = peg$parseport(); + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c34(s1, s3); + s0 = s1; } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, proc, port) { return {"src":{process:proc, port:port}} })(pos0, result0[0], result0[2]); + peg$currPos = s0; + s0 = peg$c2; } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - pos1 = pos; - result0 = parse_node(); - if (result0 !== null) { - result1 = parse__(); - if (result1 !== null) { - result2 = parse_portWithIndex(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } + } else { + peg$currPos = s0; + s0 = peg$c2; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parsenode(); + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + if (s2 !== peg$FAILED) { + s3 = peg$parseportWithIndex(); + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c35(s1, s3); + s0 = s1; } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, proc, port) { return {"src":{process:proc, port:port.port, index: port.index}} })(pos0, result0[0], result0[2]); - } - if (result0 === null) { - pos = pos0; + peg$currPos = s0; + s0 = peg$c2; } - } - return result0; - } - - function parse_iip() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.charCodeAt(pos) === 39) { - result0 = "'"; - pos++; } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"'\""); - } + peg$currPos = s0; + s0 = peg$c2; } - if (result0 !== null) { - result1 = []; - result2 = parse_iipchar(); - while (result2 !== null) { - result1.push(result2); - result2 = parse_iipchar(); + } + + return s0; + } + + function peg$parseiip() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 39) { + s1 = peg$c36; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c37); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parseiipchar(); + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parseiipchar(); + } + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 39) { + s3 = peg$c36; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c37); } } - if (result1 !== null) { - if (input.charCodeAt(pos) === 39) { - result2 = "'"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"'\""); - } - } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c38(s2); + s0 = s1; } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, iip) { return {"data":iip.join("")} })(pos0, result0[1]); - } - if (result0 === null) { - pos = pos0; + peg$currPos = s0; + s0 = peg$c2; } - return result0; + } else { + peg$currPos = s0; + s0 = peg$c2; } - - function parse_rightlet() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_port(); - if (result0 !== null) { - result1 = parse__(); - if (result1 !== null) { - result2 = parse_node(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } + + return s0; + } + + function peg$parserightlet() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parseport(); + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + if (s2 !== peg$FAILED) { + s3 = peg$parsenode(); + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c39(s1, s3); + s0 = s1; } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, port, proc) { return {"tgt":{process:proc, port:port}} })(pos0, result0[0], result0[2]); - } - if (result0 === null) { - pos = pos0; + peg$currPos = s0; + s0 = peg$c2; } - if (result0 === null) { - pos0 = pos; - pos1 = pos; - result0 = parse_portWithIndex(); - if (result0 !== null) { - result1 = parse__(); - if (result1 !== null) { - result2 = parse_node(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } + } else { + peg$currPos = s0; + s0 = peg$c2; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseportWithIndex(); + if (s1 !== peg$FAILED) { + s2 = peg$parse_(); + if (s2 !== peg$FAILED) { + s3 = peg$parsenode(); + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c40(s1, s3); + s0 = s1; } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } - if (result0 !== null) { - result0 = (function(offset, port, proc) { return {"tgt":{process:proc, port:port.port, index: port.index}} })(pos0, result0[0], result0[2]); - } - if (result0 === null) { - pos = pos0; + } else { + peg$currPos = s0; + s0 = peg$c2; + } + } + + return s0; + } + + function peg$parsenode() { + var s0, s1, s2; + + s0 = peg$currPos; + s1 = []; + if (peg$c41.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c42); } + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + if (peg$c41.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c42); } } } - return result0; + } else { + s1 = peg$c2; } - - function parse_node() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (/^[a-zA-Z0-9_]/.test(input.charAt(pos))) { - result1 = input.charAt(pos); - pos++; + if (s1 !== peg$FAILED) { + s2 = peg$parsecomponent(); + if (s2 === peg$FAILED) { + s2 = peg$c11; + } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c43(s1, s2); + s0 = s1; } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[a-zA-Z0-9_]"); - } + peg$currPos = s0; + s0 = peg$c2; } - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - if (/^[a-zA-Z0-9_]/.test(input.charAt(pos))) { - result1 = input.charAt(pos); - pos++; + } else { + peg$currPos = s0; + s0 = peg$c2; + } + + return s0; + } + + function peg$parsecomponent() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 40) { + s1 = peg$c44; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c45); } + } + if (s1 !== peg$FAILED) { + s2 = []; + if (peg$c46.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c47); } + } + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + if (peg$c46.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[a-zA-Z0-9_]"); - } + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c47); } } } } else { - result0 = null; + s2 = peg$c2; } - if (result0 !== null) { - result1 = parse_component(); - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; + if (s2 === peg$FAILED) { + s2 = peg$c11; } - if (result0 !== null) { - result0 = (function(offset, node, comp) { if(comp){parser.addNode(node.join(""),comp);}; return node.join("")})(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_component() { - var result0, result1, result2, result3; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.charCodeAt(pos) === 40) { - result0 = "("; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"(\""); + if (s2 !== peg$FAILED) { + s3 = peg$parsecompMeta(); + if (s3 === peg$FAILED) { + s3 = peg$c11; } - } - if (result0 !== null) { - if (/^[a-zA-Z\/\-0-9_]/.test(input.charAt(pos))) { - result2 = input.charAt(pos); - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("[a-zA-Z\\/\\-0-9_]"); - } - } - if (result2 !== null) { - result1 = []; - while (result2 !== null) { - result1.push(result2); - if (/^[a-zA-Z\/\-0-9_]/.test(input.charAt(pos))) { - result2 = input.charAt(pos); - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("[a-zA-Z\\/\\-0-9_]"); - } - } + if (s3 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 41) { + s4 = peg$c48; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c49); } } - } else { - result1 = null; - } - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - result2 = parse_compMeta(); - result2 = result2 !== null ? result2 : ""; - if (result2 !== null) { - if (input.charCodeAt(pos) === 41) { - result3 = ")"; - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("\")\""); - } - } - if (result3 !== null) { - result0 = [result0, result1, result2, result3]; - } else { - result0 = null; - pos = pos1; - } + if (s4 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c50(s2, s3); + s0 = s1; } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } - if (result0 !== null) { - result0 = (function(offset, comp, meta) { var o = {}; comp ? o.comp = comp.join("") : o.comp = ''; meta ? o.meta = meta.join("").split(',') : null; return o; })(pos0, result0[1], result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; + } else { + peg$currPos = s0; + s0 = peg$c2; } - - function parse_compMeta() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.charCodeAt(pos) === 58) { - result0 = ":"; - pos++; + + return s0; + } + + function peg$parsecompMeta() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 58) { + s1 = peg$c7; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c8); } + } + if (s1 !== peg$FAILED) { + s2 = []; + if (peg$c51.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result0 !== null) { - if (/^[a-zA-Z\/=_,0-9]/.test(input.charAt(pos))) { - result2 = input.charAt(pos); - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("[a-zA-Z\\/=_,0-9]"); - } - } - if (result2 !== null) { - result1 = []; - while (result2 !== null) { - result1.push(result2); - if (/^[a-zA-Z\/=_,0-9]/.test(input.charAt(pos))) { - result2 = input.charAt(pos); - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("[a-zA-Z\\/=_,0-9]"); - } - } + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c52); } + } + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + if (peg$c51.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c52); } } - } else { - result1 = null; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; } } else { - result0 = null; - pos = pos1; + s2 = peg$c2; } - if (result0 !== null) { - result0 = (function(offset, meta) {return meta})(pos0, result0[1]); - } - if (result0 === null) { - pos = pos0; + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c53(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c2; } - return result0; + } else { + peg$currPos = s0; + s0 = peg$c2; } - - function parse_port() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (/^[A-Z.0-9_]/.test(input.charAt(pos))) { - result1 = input.charAt(pos); - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[A-Z.0-9_]"); + + return s0; + } + + function peg$parseport() { + var s0, s1, s2; + + s0 = peg$currPos; + s1 = []; + if (peg$c54.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c55); } + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + if (peg$c54.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c55); } } } - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - if (/^[A-Z.0-9_]/.test(input.charAt(pos))) { - result1 = input.charAt(pos); - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[A-Z.0-9_]"); - } - } - } + } else { + s1 = peg$c2; + } + if (s1 !== peg$FAILED) { + s2 = peg$parse__(); + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c56(s1); + s0 = s1; } else { - result0 = null; + peg$currPos = s0; + s0 = peg$c2; } - if (result0 !== null) { - result1 = parse___(); - if (result1 !== null) { - result0 = [result0, result1]; + } else { + peg$currPos = s0; + s0 = peg$c2; + } + + return s0; + } + + function peg$parseportWithIndex() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = []; + if (peg$c54.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c55); } + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + if (peg$c54.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; } else { - result0 = null; - pos = pos1; + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c55); } } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, portname) {return portname.join("").toLowerCase()})(pos0, result0[0]); - } - if (result0 === null) { - pos = pos0; } - return result0; + } else { + s1 = peg$c2; } - - function parse_portWithIndex() { - var result0, result1, result2, result3, result4; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (/^[A-Z.0-9_]/.test(input.charAt(pos))) { - result1 = input.charAt(pos); - pos++; + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 91) { + s2 = peg$c57; + peg$currPos++; } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[A-Z.0-9_]"); + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c58); } + } + if (s2 !== peg$FAILED) { + s3 = []; + if (peg$c59.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c60); } } - } - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - if (/^[A-Z.0-9_]/.test(input.charAt(pos))) { - result1 = input.charAt(pos); - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[A-Z.0-9_]"); + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + if (peg$c59.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c60); } } } - } - } else { - result0 = null; - } - if (result0 !== null) { - if (input.charCodeAt(pos) === 91) { - result1 = "["; - pos++; } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"[\""); - } + s3 = peg$c2; } - if (result1 !== null) { - if (/^[0-9]/.test(input.charAt(pos))) { - result3 = input.charAt(pos); - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("[0-9]"); - } - } - if (result3 !== null) { - result2 = []; - while (result3 !== null) { - result2.push(result3); - if (/^[0-9]/.test(input.charAt(pos))) { - result3 = input.charAt(pos); - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("[0-9]"); - } - } - } + if (s3 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 93) { + s4 = peg$c61; + peg$currPos++; } else { - result2 = null; + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c62); } } - if (result2 !== null) { - if (input.charCodeAt(pos) === 93) { - result3 = "]"; - pos++; + if (s4 !== peg$FAILED) { + s5 = peg$parse__(); + if (s5 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c63(s1, s3); + s0 = s1; } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("\"]\""); - } - } - if (result3 !== null) { - result4 = parse___(); - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; + peg$currPos = s0; + s0 = peg$c2; } } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, portname, portindex) {return { port: portname.join("").toLowerCase(), index: parseInt(portindex.join('')) }})(pos0, result0[0], result0[2]); + peg$currPos = s0; + s0 = peg$c2; } - if (result0 === null) { - pos = pos0; - } - return result0; + } else { + peg$currPos = s0; + s0 = peg$c2; } - - function parse_anychar() { - var result0; - - if (/^[^\n\r\u2028\u2029]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[^\\n\\r\\u2028\\u2029]"); - } - } - return result0; + + return s0; + } + + function peg$parseanychar() { + var s0; + + if (peg$c64.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c65); } } - - function parse_iipchar() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (/^[\\]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; + + return s0; + } + + function peg$parseiipchar() { + var s0, s1, s2; + + s0 = peg$currPos; + if (peg$c66.test(input.charAt(peg$currPos))) { + s1 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c67); } + } + if (s1 !== peg$FAILED) { + if (peg$c68.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[\\\\]"); - } + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c69); } } - if (result0 !== null) { - if (/^[']/.test(input.charAt(pos))) { - result1 = input.charAt(pos); - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[']"); - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c70(); + s0 = s1; } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { return "'"; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - if (/^[^']/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[^']"); - } - } + peg$currPos = s0; + s0 = peg$c2; } - return result0; + } else { + peg$currPos = s0; + s0 = peg$c2; } - - function parse__() { - var result0, result1; - - result0 = []; - if (input.charCodeAt(pos) === 32) { - result1 = " "; - pos++; + if (s0 === peg$FAILED) { + if (peg$c71.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\" \""); - } + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c72); } } - while (result1 !== null) { - result0.push(result1); - if (input.charCodeAt(pos) === 32) { - result1 = " "; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\" \""); - } - } - } - result0 = result0 !== null ? result0 : ""; - return result0; } - - function parse___() { - var result0, result1; - - if (input.charCodeAt(pos) === 32) { - result1 = " "; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\" \""); - } - } - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - if (input.charCodeAt(pos) === 32) { - result1 = " "; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\" \""); - } - } - } + + return s0; + } + + function peg$parse_() { + var s0, s1; + + s0 = []; + if (input.charCodeAt(peg$currPos) === 32) { + s1 = peg$c73; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c74); } + } + while (s1 !== peg$FAILED) { + s0.push(s1); + if (input.charCodeAt(peg$currPos) === 32) { + s1 = peg$c73; + peg$currPos++; } else { - result0 = null; + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c74); } } - return result0; } - - - function cleanupExpected(expected) { - expected.sort(); - - var lastExpected = null; - var cleanExpected = []; - for (var i = 0; i < expected.length; i++) { - if (expected[i] !== lastExpected) { - cleanExpected.push(expected[i]); - lastExpected = expected[i]; - } - } - return cleanExpected; + if (s0 === peg$FAILED) { + s0 = peg$c11; } - - function computeErrorPosition() { - /* - * The first idea was to use |String.split| to break the input up to the - * error position along newlines and derive the line and column from - * there. However IE's |split| implementation is so broken that it was - * enough to prevent it. - */ - - var line = 1; - var column = 1; - var seenCR = false; - - for (var i = 0; i < Math.max(pos, rightmostFailuresPos); i++) { - var ch = input.charAt(i); - if (ch === "\n") { - if (!seenCR) { line++; } - column = 1; - seenCR = false; - } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") { - line++; - column = 1; - seenCR = true; + + return s0; + } + + function peg$parse__() { + var s0, s1; + + s0 = []; + if (input.charCodeAt(peg$currPos) === 32) { + s1 = peg$c73; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c74); } + } + if (s1 !== peg$FAILED) { + while (s1 !== peg$FAILED) { + s0.push(s1); + if (input.charCodeAt(peg$currPos) === 32) { + s1 = peg$c73; + peg$currPos++; } else { - column++; - seenCR = false; + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c74); } } } - - return { line: line, column: column }; + } else { + s0 = peg$c2; } - - - var parser, edges, nodes; - - parser = this; - delete parser.exports; - delete parser.inports; - delete parser.outports; - - edges = parser.edges = []; - - nodes = {}; - - parser.addNode = function (nodeName, comp) { - if (!nodes[nodeName]) { - nodes[nodeName] = {} - } - if (!!comp.comp) { - nodes[nodeName].component = comp.comp; - } - if (!!comp.meta) { - var metadata = {}; - for (var i = 0; i < comp.meta.length; i++) { - var item = comp.meta[i].split('='); - if (item.length === 1) { - item = ['routes', item[0]]; - } - metadata[item[0]] = item[1]; - } - nodes[nodeName].metadata=metadata; - } - - } - - parser.getResult = function () { - return {processes:nodes, connections:parser.processEdges(), exports:parser.exports, inports: parser.inports, outports: parser.outports}; - } - - var flatten = function (array, isShallow) { - var index = -1, - length = array ? array.length : 0, - result = []; - - while (++index < length) { - var value = array[index]; - - if (value instanceof Array) { - Array.prototype.push.apply(result, isShallow ? value : flatten(value)); + + return s0; + } + + + var parser, edges, nodes; + + parser = this; + delete parser.exports; + delete parser.inports; + delete parser.outports; + + edges = parser.edges = []; + + nodes = {}; + + parser.addNode = function (nodeName, comp) { + if (!nodes[nodeName]) { + nodes[nodeName] = {} + } + if (!!comp.comp) { + nodes[nodeName].component = comp.comp; + } + if (!!comp.meta) { + var metadata = {}; + for (var i = 0; i < comp.meta.length; i++) { + var item = comp.meta[i].split('='); + if (item.length === 1) { + item = ['routes', item[0]]; } - else { - result.push(value); + var key = item[0]; + var value = item[1]; + if (key==='x' || key==='y') { + value = parseFloat(value); } + metadata[key] = value; } - return result; - } - - parser.registerExports = function (priv, pub) { - if (!parser.exports) { - parser.exports = []; - } - parser.exports.push({private:priv.toLowerCase(), public:pub.toLowerCase()}) + nodes[nodeName].metadata=metadata; } - parser.registerInports = function (node, port, pub) { - if (!parser.inports) { - parser.inports = {}; + + } + + parser.getResult = function () { + return {processes:nodes, connections:parser.processEdges(), exports:parser.exports, inports: parser.inports, outports: parser.outports}; + } + + var flatten = function (array, isShallow) { + var index = -1, + length = array ? array.length : 0, + result = []; + + while (++index < length) { + var value = array[index]; + + if (value instanceof Array) { + Array.prototype.push.apply(result, isShallow ? value : flatten(value)); } - parser.inports[pub.toLowerCase()] = {process:node, port:port.toLowerCase()} - } - parser.registerOutports = function (node, port, pub) { - if (!parser.outports) { - parser.outports = {}; + else { + result.push(value); } - parser.outports[pub.toLowerCase()] = {process:node, port:port.toLowerCase()} } + return result; + } - parser.registerEdges = function (edges) { - - edges.forEach(function (o, i) { - parser.edges.push(o); - }); - } - - parser.processEdges = function () { - var flats, grouped; - flats = flatten(parser.edges); - grouped = []; - var current = {}; - flats.forEach(function (o, i) { - if (i % 2 !== 0) { - var pair = grouped[grouped.length - 1]; - pair.tgt = o.tgt; - return; - } - grouped.push(o); - }); - return grouped; + parser.registerExports = function (priv, pub) { + if (!parser.exports) { + parser.exports = []; } - - - var result = parseFunctions[startRule](); - - /* - * The parser is now in one of the following three states: - * - * 1. The parser successfully parsed the whole input. - * - * - |result !== null| - * - |pos === input.length| - * - |rightmostFailuresExpected| may or may not contain something - * - * 2. The parser successfully parsed only a part of the input. - * - * - |result !== null| - * - |pos < input.length| - * - |rightmostFailuresExpected| may or may not contain something - * - * 3. The parser did not successfully parse any part of the input. - * - * - |result === null| - * - |pos === 0| - * - |rightmostFailuresExpected| contains at least one failure - * - * All code following this comment (including called functions) must - * handle these states. - */ - if (result === null || pos !== input.length) { - var offset = Math.max(pos, rightmostFailuresPos); - var found = offset < input.length ? input.charAt(offset) : null; - var errorPosition = computeErrorPosition(); - - throw new this.SyntaxError( - cleanupExpected(rightmostFailuresExpected), - found, - offset, - errorPosition.line, - errorPosition.column - ); + parser.exports.push({private:priv.toLowerCase(), public:pub.toLowerCase()}) } - - return result; - }, - - /* Returns the parser source code. */ - toSource: function() { return this._source; } - }; - - /* Thrown when a parser encounters a syntax error. */ - - result.SyntaxError = function(expected, found, offset, line, column) { - function buildMessage(expected, found) { - var expectedHumanized, foundHumanized; - - switch (expected.length) { - case 0: - expectedHumanized = "end of input"; - break; - case 1: - expectedHumanized = expected[0]; - break; - default: - expectedHumanized = expected.slice(0, expected.length - 1).join(", ") - + " or " - + expected[expected.length - 1]; + parser.registerInports = function (node, port, pub) { + if (!parser.inports) { + parser.inports = {}; + } + parser.inports[pub.toLowerCase()] = {process:node, port:port.toLowerCase()} } - - foundHumanized = found ? quote(found) : "end of input"; - - return "Expected " + expectedHumanized + " but " + foundHumanized + " found."; + parser.registerOutports = function (node, port, pub) { + if (!parser.outports) { + parser.outports = {}; + } + parser.outports[pub.toLowerCase()] = {process:node, port:port.toLowerCase()} + } + + parser.registerEdges = function (edges) { + + edges.forEach(function (o, i) { + parser.edges.push(o); + }); + } + + parser.processEdges = function () { + var flats, grouped; + flats = flatten(parser.edges); + grouped = []; + var current = {}; + flats.forEach(function (o, i) { + if (i % 2 !== 0) { + var pair = grouped[grouped.length - 1]; + pair.tgt = o.tgt; + return; + } + grouped.push(o); + }); + return grouped; + } + + + peg$result = peg$startRuleFunction(); + + if (peg$result !== peg$FAILED && peg$currPos === input.length) { + return peg$result; + } else { + if (peg$result !== peg$FAILED && peg$currPos < input.length) { + peg$fail({ type: "end", description: "end of input" }); + } + + throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos); } - - this.name = "SyntaxError"; - this.expected = expected; - this.found = found; - this.message = buildMessage(expected, found); - this.offset = offset; - this.line = line; - this.column = column; + } + + return { + SyntaxError: SyntaxError, + parse: parse }; - - result.SyntaxError.prototype = Error.prototype; - - return result; })(); \ No newline at end of file