diff --git a/.gitignore b/.gitignore index febbb5c..07e6e47 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ /node_modules -/build diff --git a/lib/cli.js b/lib/cli.js index ff87673..8def045 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -1,5 +1,5 @@ var fs = require('fs'); -var trigParser = require('../build/parsers/trig'); +var trigParser = require('./parsers/trig'); function streamToString(stream, encoding, callback) { var bufs = []; diff --git a/lib/index.js b/lib/index.js index 038d40a..97a7cde 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1 +1 @@ -module.exports.trig = require('../build/parsers/trig'); +module.exports.trig = require('./parsers/trig'); diff --git a/lib/parsers/trig.js b/lib/parsers/trig.js new file mode 100644 index 0000000..9cbf964 --- /dev/null +++ b/lib/parsers/trig.js @@ -0,0 +1,4073 @@ +module.exports = (function() { + /* + * Generated by PEG.js 0.8.0. + * + * http://pegjs.majda.cz/ + */ + + function peg$subclass(child, parent) { + function ctor() { this.constructor = child; } + ctor.prototype = parent.prototype; + child.prototype = new ctor(); + } + + function SyntaxError(message, expected, found, offset, line, column) { + this.message = message; + this.expected = expected; + this.found = found; + this.offset = offset; + this.line = line; + this.column = column; + + this.name = "SyntaxError"; + } + + peg$subclass(SyntaxError, Error); + + function parse(input) { + var options = arguments.length > 1 ? arguments[1] : {}, + + peg$FAILED = {}, + + peg$startRuleFunctions = { trigDoc: peg$parsetrigDoc }, + peg$startRuleFunction = peg$parsetrigDoc, + + peg$c0 = peg$FAILED, + peg$c1 = [], + peg$c2 = function(data) { + var currentContext = {}, currentGraph = []; + var result = [ + {'@context': currentContext, '@graph': currentGraph} + ]; + var vocab = null; + for (var item of data) { + var ctxItem = item['@context']; + if (ctxItem) { + if (currentGraph.length !== 0) { + currentContext = {}; + currentGraph = []; + result.push( + {'@context': currentContext, '@graph': currentGraph} + ); + } + assign(currentContext, ctxItem); + vocab = currentContext['@vocab']; + } else { + var id = item['@id']; + if (id && id[0] === ':') { + item['@id'] = vocab + id.substring(1); + } + currentGraph.push(item); + } + } + return result.length === 1? result[0] : result; + }, + peg$c3 = "GRAPH", + peg$c4 = { type: "literal", value: "GRAPH", description: "\"GRAPH\"" }, + peg$c5 = ".", + peg$c6 = { type: "literal", value: ".", description: "\".\"" }, + peg$c7 = function(pos) { return pos; }, + peg$c8 = function(subject, pairs) { + return reducePairs(subject, pairs); + }, + peg$c9 = null, + peg$c10 = function(bnpairs, pos) { + return pos? reducePairs(bnpairs, pos) : bnpairs; + }, + peg$c11 = function(collection, pos) { + return pos? reducePairs(bnpairs, pos) : bnpairs; + }, + peg$c12 = "{", + peg$c13 = { type: "literal", value: "{", description: "\"{\"" }, + peg$c14 = "}", + peg$c15 = { type: "literal", value: "}", description: "\"}\"" }, + peg$c16 = "@prefix", + peg$c17 = { type: "literal", value: "@prefix", description: "\"@prefix\"" }, + peg$c18 = function(pfx, iriref) { + return prefix(pfx, iriref); + }, + peg$c19 = "@base", + peg$c20 = { type: "literal", value: "@base", description: "\"@base\"" }, + peg$c21 = function() { + return base(iriref); + }, + peg$c22 = "prefix", + peg$c23 = { type: "literal", value: "PREFIX", description: "\"PREFIX\"" }, + peg$c24 = "base", + peg$c25 = { type: "literal", value: "BASE", description: "\"BASE\"" }, + peg$c26 = function(iriref) { + return base(iriref); + }, + peg$c27 = ";", + peg$c28 = { type: "literal", value: ";", description: "\";\"" }, + peg$c29 = function(vol) { return vol; }, + peg$c30 = function(verb, objectList, rest) { + function toPair(verb, objectList) { + var po = {}; + po[verb] = objectList; + return po; + } + var po = toPair(verb, objectList); + var pairs = [po]; + for (var pair of rest) { + //if (pair === null) continue + po = toPair(pair[0], pair[1]); + pairs.push(po); + } + return pairs; + }, + peg$c31 = ",", + peg$c32 = { type: "literal", value: ",", description: "\",\"" }, + peg$c33 = function(object) { return object; }, + peg$c34 = function(first, remainder) { + if (remainder.length > 0) { + var objects = [first]; + for (var object of remainder) { + objects.push(object); + } + return objects; + } else { + return first; + } + }, + peg$c35 = "a", + peg$c36 = { type: "literal", value: "a", description: "\"a\"" }, + peg$c37 = function() {return '@type'; }, + peg$c38 = function(verb) { + return verb; + }, + peg$c39 = function(literal) { + return literal; + }, + peg$c40 = "[", + peg$c41 = { type: "literal", value: "[", description: "\"[\"" }, + peg$c42 = "]", + peg$c43 = { type: "literal", value: "]", description: "\"]\"" }, + peg$c44 = function(pos) { + return reducePairs({}, pos); + }, + peg$c45 = "(", + peg$c46 = { type: "literal", value: "(", description: "\"(\"" }, + peg$c47 = ")", + peg$c48 = { type: "literal", value: ")", description: "\")\"" }, + peg$c49 = function(collection) { + return {'@list': collection}; + }, + peg$c50 = "^^", + peg$c51 = { type: "literal", value: "^^", description: "\"^^\"" }, + peg$c52 = function(datatype) { return {'@type': datatype}; }, + peg$c53 = function(rdfliteral, tag) { + var value = rdfliteral; + if (tag !== null) { + value = {'@value': rdfliteral}; + assign(value, tag); + } + return value; + }, + peg$c54 = "true", + peg$c55 = { type: "literal", value: "true", description: "\"true\"" }, + peg$c56 = function() { return true; }, + peg$c57 = "false", + peg$c58 = { type: "literal", value: "false", description: "\"false\"" }, + peg$c59 = function() { return false; }, + peg$c60 = function(value) { + return value; + }, + peg$c61 = function(iri) { + return iri; + }, + peg$c62 = function(bnode) { + return bnode; + }, + peg$c63 = "<", + peg$c64 = { type: "literal", value: "<", description: "\"<\"" }, + peg$c65 = /^[^\0- <>"{}|\^`\\]/, + peg$c66 = { type: "class", value: "[^\\0- <>\"{}|\\^`\\\\]", description: "[^\\0- <>\"{}|\\^`\\\\]" }, + peg$c67 = ">", + peg$c68 = { type: "literal", value: ">", description: "\">\"" }, + peg$c69 = function(iriref) { + return {"@id": iriref.join('')}; + }, + peg$c70 = ":", + peg$c71 = { type: "literal", value: ":", description: "\":\"" }, + peg$c72 = function(pfx) { + return pfx; + }, + peg$c73 = function(ns, l) { + return (ns === null? '' : ns + ':') + l; + }, + peg$c74 = "_:", + peg$c75 = { type: "literal", value: "_:", description: "\"_:\"" }, + peg$c76 = /^[0-9]/, + peg$c77 = { type: "class", value: "[0-9]", description: "[0-9]" }, + peg$c78 = function(lead, first, rest) { + var bid = lead; + if (first) + bid += first.join(''); + if (rest) + bid += first.join(''); + return {'@id': bid}; + }, + peg$c79 = "@", + peg$c80 = { type: "literal", value: "@", description: "\"@\"" }, + peg$c81 = /^[a-zA-Z]/, + peg$c82 = { type: "class", value: "[a-zA-Z]", description: "[a-zA-Z]" }, + peg$c83 = "-", + peg$c84 = { type: "literal", value: "-", description: "\"-\"" }, + peg$c85 = /^[a-zA-Z0-9]/, + peg$c86 = { type: "class", value: "[a-zA-Z0-9]", description: "[a-zA-Z0-9]" }, + peg$c87 = function(tag, subtag) { + var sub = (subtag.length? subtag.map(function (it) { + return it[0] + it[1].join(''); }).join('') : ''); + return {"@language": tag.join('') + sub}; + }, + peg$c88 = /^[+\-]/, + peg$c89 = { type: "class", value: "[+\\-]", description: "[+\\-]" }, + peg$c90 = function(sign, digits) { + var i = parseInt(digits.join(''), 10); + if (sign === '-') + i = -1 * i; + return i; + }, + peg$c91 = /^[eE]/, + peg$c92 = { type: "class", value: "[eE]", description: "[eE]" }, + peg$c93 = "\"", + peg$c94 = { type: "literal", value: "\"", description: "\"\\\"\"" }, + peg$c95 = /^[^"\\\n\r]/, + peg$c96 = { type: "class", value: "[^\"\\\\\\n\\r]", description: "[^\"\\\\\\n\\r]" }, + peg$c97 = function(value) { + return value.join(''); + }, + peg$c98 = "'", + peg$c99 = { type: "literal", value: "'", description: "\"'\"" }, + peg$c100 = /^[^'\\\n\r]/, + peg$c101 = { type: "class", value: "[^'\\\\\\n\\r]", description: "[^'\\\\\\n\\r]" }, + peg$c102 = "'''", + peg$c103 = { type: "literal", value: "'''", description: "\"'''\"" }, + peg$c104 = "''", + peg$c105 = { type: "literal", value: "''", description: "\"''\"" }, + peg$c106 = /^[^'\\]/, + peg$c107 = { type: "class", value: "[^'\\\\]", description: "[^'\\\\]" }, + peg$c108 = "\"\"\"", + peg$c109 = { type: "literal", value: "\"\"\"", description: "\"\\\"\\\"\\\"\"" }, + peg$c110 = "\"\"", + peg$c111 = { type: "literal", value: "\"\"", description: "\"\\\"\\\"\"" }, + peg$c112 = /^[^"\\]/, + peg$c113 = { type: "class", value: "[^\"\\\\]", description: "[^\"\\\\]" }, + peg$c114 = "\\u", + peg$c115 = { type: "literal", value: "\\u", description: "\"\\\\u\"" }, + peg$c116 = "\\U", + peg$c117 = { type: "literal", value: "\\U", description: "\"\\\\U\"" }, + peg$c118 = "\\", + peg$c119 = { type: "literal", value: "\\", description: "\"\\\\\"" }, + peg$c120 = /^[tbnrf"'\\]/, + peg$c121 = { type: "class", value: "[tbnrf\"'\\\\]", description: "[tbnrf\"'\\\\]" }, + peg$c122 = " ", + peg$c123 = { type: "literal", value: " ", description: "\" \"" }, + peg$c124 = "\t", + peg$c125 = { type: "literal", value: "\t", description: "\"\\t\"" }, + peg$c126 = "\r", + peg$c127 = { type: "literal", value: "\r", description: "\"\\r\"" }, + peg$c128 = "\n", + peg$c129 = { type: "literal", value: "\n", description: "\"\\n\"" }, + peg$c130 = function() { return {}; }, + peg$c131 = /^[A-Z]/, + peg$c132 = { type: "class", value: "[A-Z]", description: "[A-Z]" }, + peg$c133 = /^[a-z]/, + peg$c134 = { type: "class", value: "[a-z]", description: "[a-z]" }, + peg$c135 = /^[\xC0-\xD6]/, + peg$c136 = { type: "class", value: "[\\xC0-\\xD6]", description: "[\\xC0-\\xD6]" }, + peg$c137 = /^[\xD8-\xF6]/, + peg$c138 = { type: "class", value: "[\\xD8-\\xF6]", description: "[\\xD8-\\xF6]" }, + peg$c139 = /^[\xF8-\u02FF]/, + peg$c140 = { type: "class", value: "[\\xF8-\\u02FF]", description: "[\\xF8-\\u02FF]" }, + peg$c141 = /^[\u0370-\u037D]/, + peg$c142 = { type: "class", value: "[\\u0370-\\u037D]", description: "[\\u0370-\\u037D]" }, + peg$c143 = /^[\u037F-\u1FFF]/, + peg$c144 = { type: "class", value: "[\\u037F-\\u1FFF]", description: "[\\u037F-\\u1FFF]" }, + peg$c145 = /^[\u200C-\u200D]/, + peg$c146 = { type: "class", value: "[\\u200C-\\u200D]", description: "[\\u200C-\\u200D]" }, + peg$c147 = /^[\u2070-\u218F]/, + peg$c148 = { type: "class", value: "[\\u2070-\\u218F]", description: "[\\u2070-\\u218F]" }, + peg$c149 = /^[\u2C00-\u2FEF]/, + peg$c150 = { type: "class", value: "[\\u2C00-\\u2FEF]", description: "[\\u2C00-\\u2FEF]" }, + peg$c151 = /^[\u3001-\uD7FF]/, + peg$c152 = { type: "class", value: "[\\u3001-\\uD7FF]", description: "[\\u3001-\\uD7FF]" }, + peg$c153 = /^[\uF900-\uFDCF]/, + peg$c154 = { type: "class", value: "[\\uF900-\\uFDCF]", description: "[\\uF900-\\uFDCF]" }, + peg$c155 = /^[\uFDF0-\uFFFD]/, + peg$c156 = { type: "class", value: "[\\uFDF0-\\uFFFD]", description: "[\\uFDF0-\\uFFFD]" }, + peg$c157 = "_", + peg$c158 = { type: "literal", value: "_", description: "\"_\"" }, + peg$c159 = "\xB7", + peg$c160 = { type: "literal", value: "\xB7", description: "\"\\xB7\"" }, + peg$c161 = /^[\u0300-\u036F]/, + peg$c162 = { type: "class", value: "[\\u0300-\\u036F]", description: "[\\u0300-\\u036F]" }, + peg$c163 = /^[\u203F-\u2040]/, + peg$c164 = { type: "class", value: "[\\u203F-\\u2040]", description: "[\\u203F-\\u2040]" }, + peg$c165 = function(base, other) { + return base.join('') + (other? other.join('') : ''); + }, + peg$c166 = function(chars, last) { + return (chars? chars.join('') : '') + last; + }, + peg$c167 = function(chars, other) { + return chars.join('') + (other? other.join('') : ''); + }, + peg$c168 = "%", + peg$c169 = { type: "literal", value: "%", description: "\"%\"" }, + peg$c170 = /^[A-F]/, + peg$c171 = { type: "class", value: "[A-F]", description: "[A-F]" }, + peg$c172 = /^[a-f]/, + peg$c173 = { type: "class", value: "[a-f]", description: "[a-f]" }, + peg$c174 = "~", + peg$c175 = { type: "literal", value: "~", description: "\"~\"" }, + peg$c176 = "!", + peg$c177 = { type: "literal", value: "!", description: "\"!\"" }, + peg$c178 = "$", + peg$c179 = { type: "literal", value: "$", description: "\"$\"" }, + peg$c180 = "&", + peg$c181 = { type: "literal", value: "&", description: "\"&\"" }, + peg$c182 = "*", + peg$c183 = { type: "literal", value: "*", description: "\"*\"" }, + peg$c184 = "+", + peg$c185 = { type: "literal", value: "+", description: "\"+\"" }, + peg$c186 = "=", + peg$c187 = { type: "literal", value: "=", description: "\"=\"" }, + peg$c188 = "/", + peg$c189 = { type: "literal", value: "/", description: "\"/\"" }, + peg$c190 = "?", + peg$c191 = { type: "literal", value: "?", description: "\"?\"" }, + peg$c192 = "#", + peg$c193 = { type: "literal", value: "#", description: "\"#\"" }, + peg$c194 = /^[^\r\n]/, + peg$c195 = { type: "class", value: "[^\\r\\n]", description: "[^\\r\\n]" }, + peg$c196 = /^[\r\n]/, + peg$c197 = { type: "class", value: "[\\r\\n]", description: "[\\r\\n]" }, + + 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 + "\"."); + } + + 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; + } + } + } + + 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; + } + + return peg$cachedPosDetails; + } + + function peg$fail(expected) { + if (peg$currPos < peg$maxFailPos) { return; } + + if (peg$currPos > peg$maxFailPos) { + peg$maxFailPos = peg$currPos; + peg$maxFailExpected = []; + } + + 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++; + } + } + } + + 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$parsetrigDoc() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parseIGNORE(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$parsedirective(); + if (s3 === peg$FAILED) { + s3 = peg$parseblock(); + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$parsedirective(); + if (s3 === peg$FAILED) { + s3 = peg$parseblock(); + } + } + if (s2 !== peg$FAILED) { + s3 = peg$parseIGNORE(); + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c2(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseblock() { + var s0, s1, s2, s3; + + s0 = peg$parsetriplesOrGraph(); + if (s0 === peg$FAILED) { + s0 = peg$parsewrappedGraph(); + if (s0 === peg$FAILED) { + s0 = peg$parsetriples2(); + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 5) === peg$c3) { + s1 = peg$c3; + peg$currPos += 5; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c4); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parselabelOrSubject(); + if (s2 !== peg$FAILED) { + s3 = peg$parsewrappedGraph(); + if (s3 !== peg$FAILED) { + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } + } + } + + return s0; + } + + function peg$parsetriplesOrGraph() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + s1 = peg$parselabelOrSubject(); + if (s1 !== peg$FAILED) { + s2 = peg$parsewrappedGraph(); + if (s2 === peg$FAILED) { + s2 = peg$currPos; + s3 = peg$parsepredicateObjectList(); + if (s3 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s4 = peg$c5; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } + } + if (s4 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c7(s3); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c0; + } + } else { + peg$currPos = s2; + s2 = peg$c0; + } + } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c8(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parsetriples2() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parseblankNodePropertyList(); + if (s1 !== peg$FAILED) { + s2 = peg$parsepredicateObjectList(); + if (s2 === peg$FAILED) { + s2 = peg$c9; + } + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s3 = peg$c5; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } + } + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c10(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parsecollection(); + if (s1 !== peg$FAILED) { + s2 = peg$parsepredicateObjectList(); + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s3 = peg$c5; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } + } + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c11(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } + + return s0; + } + + function peg$parsewrappedGraph() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 123) { + s1 = peg$c12; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c13); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parsetriplesBlock(); + if (s2 === peg$FAILED) { + s2 = peg$c9; + } + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 125) { + s3 = peg$c14; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c15); } + } + if (s3 !== peg$FAILED) { + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parsetriplesBlock() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + s1 = peg$parsetriples(); + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 46) { + s3 = peg$c5; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parsetriplesBlock(); + if (s4 === peg$FAILED) { + s4 = peg$c9; + } + if (s4 !== peg$FAILED) { + s3 = [s3, s4]; + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c0; + } + } else { + peg$currPos = s2; + s2 = peg$c0; + } + if (s2 === peg$FAILED) { + s2 = peg$c9; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parselabelOrSubject() { + var s0; + + s0 = peg$parseiri(); + if (s0 === peg$FAILED) { + s0 = peg$parseBlankNode(); + } + + return s0; + } + + function peg$parsedirective() { + var s0; + + s0 = peg$parseprefixID(); + if (s0 === peg$FAILED) { + s0 = peg$parsebase(); + if (s0 === peg$FAILED) { + s0 = peg$parsesparqlPrefix(); + if (s0 === peg$FAILED) { + s0 = peg$parsesparqlBase(); + } + } + } + + return s0; + } + + function peg$parseprefixID() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 7) === peg$c16) { + s1 = peg$c16; + peg$currPos += 7; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c17); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseIGNORE(); + if (s2 !== peg$FAILED) { + s3 = peg$parsePNAME_NS(); + if (s3 !== peg$FAILED) { + s4 = peg$parseIGNORE(); + if (s4 !== peg$FAILED) { + s5 = peg$parseIRIREF(); + if (s5 !== peg$FAILED) { + s6 = peg$parseIGNORE(); + if (s6 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s7 = peg$c5; + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } + } + if (s7 !== peg$FAILED) { + s8 = peg$parseIGNORE(); + if (s8 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c18(s3, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parsebase() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 5) === peg$c19) { + s1 = peg$c19; + peg$currPos += 5; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c20); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseIGNORE(); + if (s2 !== peg$FAILED) { + s3 = peg$parseIRIREF(); + if (s3 !== peg$FAILED) { + s4 = peg$parseIGNORE(); + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s5 = peg$c5; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } + } + if (s5 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c21(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parsesparqlPrefix() { + var s0, s1, s2, s3, s4, s5, s6; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 6).toLowerCase() === peg$c22) { + s1 = input.substr(peg$currPos, 6); + peg$currPos += 6; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c23); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseIGNORE(); + if (s2 !== peg$FAILED) { + s3 = peg$parsePNAME_NS(); + if (s3 !== peg$FAILED) { + s4 = peg$parseIGNORE(); + if (s4 !== peg$FAILED) { + s5 = peg$parseIRIREF(); + if (s5 !== peg$FAILED) { + s6 = peg$parseIGNORE(); + if (s6 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c18(s3, s5); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parsesparqlBase() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 4).toLowerCase() === peg$c24) { + s1 = input.substr(peg$currPos, 4); + peg$currPos += 4; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c25); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseIGNORE(); + if (s2 !== peg$FAILED) { + s3 = peg$parseIRIREF(); + if (s3 !== peg$FAILED) { + s4 = peg$parseIGNORE(); + if (s4 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c26(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parsetriples() { + var s0, s1, s2; + + s0 = peg$currPos; + s1 = peg$parsesubject(); + if (s1 !== peg$FAILED) { + s2 = peg$parsepredicateObjectList(); + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + s1 = peg$parseblankNodePropertyList(); + if (s1 !== peg$FAILED) { + s2 = peg$parsepredicateObjectList(); + if (s2 === peg$FAILED) { + s2 = peg$c9; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } + + return s0; + } + + function peg$parsepredicateObjectList() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8; + + s0 = peg$currPos; + s1 = peg$parseverb(); + if (s1 !== peg$FAILED) { + s2 = peg$parseobjectList(); + if (s2 !== peg$FAILED) { + s3 = []; + s4 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 59) { + s5 = peg$c27; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c28); } + } + if (s5 !== peg$FAILED) { + s6 = peg$currPos; + s7 = peg$parseverb(); + if (s7 !== peg$FAILED) { + s8 = peg$parseobjectList(); + if (s8 !== peg$FAILED) { + s7 = [s7, s8]; + s6 = s7; + } else { + peg$currPos = s6; + s6 = peg$c0; + } + } else { + peg$currPos = s6; + s6 = peg$c0; + } + if (s6 === peg$FAILED) { + s6 = peg$c9; + } + if (s6 !== peg$FAILED) { + peg$reportedPos = s4; + s5 = peg$c29(s6); + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$c0; + } + } else { + peg$currPos = s4; + s4 = peg$c0; + } + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 59) { + s5 = peg$c27; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c28); } + } + if (s5 !== peg$FAILED) { + s6 = peg$currPos; + s7 = peg$parseverb(); + if (s7 !== peg$FAILED) { + s8 = peg$parseobjectList(); + if (s8 !== peg$FAILED) { + s7 = [s7, s8]; + s6 = s7; + } else { + peg$currPos = s6; + s6 = peg$c0; + } + } else { + peg$currPos = s6; + s6 = peg$c0; + } + if (s6 === peg$FAILED) { + s6 = peg$c9; + } + if (s6 !== peg$FAILED) { + peg$reportedPos = s4; + s5 = peg$c29(s6); + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$c0; + } + } else { + peg$currPos = s4; + s4 = peg$c0; + } + } + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c30(s1, s2, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseobjectList() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + s0 = peg$currPos; + s1 = peg$parseobject(); + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + s4 = peg$parseIGNORE(); + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 44) { + s5 = peg$c31; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c32); } + } + if (s5 !== peg$FAILED) { + s6 = peg$parseIGNORE(); + if (s6 !== peg$FAILED) { + s7 = peg$parseobject(); + if (s7 !== peg$FAILED) { + peg$reportedPos = s3; + s4 = peg$c33(s7); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$c0; + } + } else { + peg$currPos = s3; + s3 = peg$c0; + } + } else { + peg$currPos = s3; + s3 = peg$c0; + } + } else { + peg$currPos = s3; + s3 = peg$c0; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + s4 = peg$parseIGNORE(); + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 44) { + s5 = peg$c31; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c32); } + } + if (s5 !== peg$FAILED) { + s6 = peg$parseIGNORE(); + if (s6 !== peg$FAILED) { + s7 = peg$parseobject(); + if (s7 !== peg$FAILED) { + peg$reportedPos = s3; + s4 = peg$c33(s7); + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$c0; + } + } else { + peg$currPos = s3; + s3 = peg$c0; + } + } else { + peg$currPos = s3; + s3 = peg$c0; + } + } else { + peg$currPos = s3; + s3 = peg$c0; + } + } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c34(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseverb() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parseIGNORE(); + if (s1 !== peg$FAILED) { + s2 = peg$parseiri(); + if (s2 === peg$FAILED) { + s2 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 97) { + s3 = peg$c35; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c36); } + } + if (s3 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c37(); + } + s2 = s3; + } + if (s2 !== peg$FAILED) { + s3 = peg$parseIGNORE(); + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c38(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parsesubject() { + var s0; + + s0 = peg$parseiri(); + if (s0 === peg$FAILED) { + s0 = peg$parseblank(); + } + + return s0; + } + + function peg$parseobject() { + var s0; + + s0 = peg$parseiri(); + if (s0 === peg$FAILED) { + s0 = peg$parseblank(); + if (s0 === peg$FAILED) { + s0 = peg$parseblankNodePropertyList(); + if (s0 === peg$FAILED) { + s0 = peg$parseliteral(); + } + } + } + + return s0; + } + + function peg$parseliteral() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parseIGNORE(); + if (s1 !== peg$FAILED) { + s2 = peg$parseRDFLiteral(); + if (s2 === peg$FAILED) { + s2 = peg$parseNumericLiteral(); + if (s2 === peg$FAILED) { + s2 = peg$parseBooleanLiteral(); + } + } + if (s2 !== peg$FAILED) { + s3 = peg$parseIGNORE(); + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c39(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseblank() { + var s0; + + s0 = peg$parseBlankNode(); + if (s0 === peg$FAILED) { + s0 = peg$parsecollection(); + } + + return s0; + } + + function peg$parseblankNodePropertyList() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + s1 = peg$parseIGNORE(); + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 91) { + s2 = peg$c40; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c41); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parsepredicateObjectList(); + if (s3 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 93) { + s4 = peg$c42; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c43); } + } + if (s4 !== peg$FAILED) { + s5 = peg$parseIGNORE(); + if (s5 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c44(s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parsecollection() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + s0 = peg$currPos; + s1 = peg$parseIGNORE(); + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 40) { + s2 = peg$c45; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c46); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parseIGNORE(); + if (s3 !== peg$FAILED) { + s4 = []; + s5 = peg$parseobject(); + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parseobject(); + } + if (s4 !== peg$FAILED) { + s5 = peg$parseIGNORE(); + if (s5 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 41) { + s6 = peg$c47; + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c48); } + } + if (s6 !== peg$FAILED) { + s7 = peg$parseIGNORE(); + if (s7 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c49(s4); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseNumericLiteral() { + var s0; + + s0 = peg$parseINTEGER(); + if (s0 === peg$FAILED) { + s0 = peg$parseDECIMAL(); + if (s0 === peg$FAILED) { + s0 = peg$parseDOUBLE(); + } + } + + return s0; + } + + function peg$parseRDFLiteral() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + s1 = peg$parseString(); + if (s1 !== peg$FAILED) { + s2 = peg$parseLANGTAG(); + if (s2 === peg$FAILED) { + s2 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c50) { + s3 = peg$c50; + peg$currPos += 2; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c51); } + } + if (s3 !== peg$FAILED) { + s4 = peg$parseiri(); + if (s4 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c52(s4); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c0; + } + } else { + peg$currPos = s2; + s2 = peg$c0; + } + } + if (s2 === peg$FAILED) { + s2 = peg$c9; + } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c53(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseBooleanLiteral() { + var s0, s1; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 4) === peg$c54) { + s1 = peg$c54; + peg$currPos += 4; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c55); } + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c56(); + } + s0 = s1; + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 5) === peg$c57) { + s1 = peg$c57; + peg$currPos += 5; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c58); } + } + if (s1 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c59(); + } + s0 = s1; + } + + return s0; + } + + function peg$parseString() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parseIGNORE(); + if (s1 !== peg$FAILED) { + s2 = peg$parseSTRING_LITERAL_QUOTE(); + if (s2 === peg$FAILED) { + s2 = peg$parseSTRING_LITERAL_SINGLE_QUOTE(); + if (s2 === peg$FAILED) { + s2 = peg$parseSTRING_LITERAL_LONG_SINGLE_QUOTE(); + if (s2 === peg$FAILED) { + s2 = peg$parseSTRING_LITERAL_LONG_QUOTE(); + } + } + } + if (s2 !== peg$FAILED) { + s3 = peg$parseIGNORE(); + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c60(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseiri() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parseIGNORE(); + if (s1 !== peg$FAILED) { + s2 = peg$parseIRIREF(); + if (s2 === peg$FAILED) { + s2 = peg$parsePrefixedName(); + } + if (s2 !== peg$FAILED) { + s3 = peg$parseIGNORE(); + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c61(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parsePrefixedName() { + var s0; + + s0 = peg$parsePNAME_LN(); + if (s0 === peg$FAILED) { + s0 = peg$parsePNAME_NS(); + } + + return s0; + } + + function peg$parseBlankNode() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + s1 = peg$parseIGNORE(); + if (s1 !== peg$FAILED) { + s2 = peg$parseBLANK_NODE_LABEL(); + if (s2 === peg$FAILED) { + s2 = peg$parseANON(); + } + if (s2 !== peg$FAILED) { + s3 = peg$parseIGNORE(); + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c62(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseIRIREF() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 60) { + s1 = peg$c63; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c64); } + } + if (s1 !== peg$FAILED) { + s2 = []; + if (peg$c65.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c66); } + } + if (s3 === peg$FAILED) { + s3 = peg$parseUCHAR(); + } + while (s3 !== peg$FAILED) { + s2.push(s3); + if (peg$c65.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c66); } + } + if (s3 === peg$FAILED) { + s3 = peg$parseUCHAR(); + } + } + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 62) { + s3 = peg$c67; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c68); } + } + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c69(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parsePNAME_NS() { + var s0, s1, s2; + + s0 = peg$currPos; + s1 = peg$parsePN_PREFIX(); + if (s1 === peg$FAILED) { + s1 = peg$c9; + } + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 58) { + s2 = peg$c70; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c71); } + } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c72(s1); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parsePNAME_LN() { + var s0, s1, s2; + + s0 = peg$currPos; + s1 = peg$parsePNAME_NS(); + if (s1 !== peg$FAILED) { + s2 = peg$parsePN_LOCAL(); + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c73(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseBLANK_NODE_LABEL() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c74) { + s1 = peg$c74; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c75); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parsePN_CHARS_U(); + if (s2 === peg$FAILED) { + if (peg$c76.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + } + if (s2 !== peg$FAILED) { + s3 = peg$currPos; + s4 = []; + s5 = peg$parsePN_CHARS(); + if (s5 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s5 = peg$c5; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } + } + } + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$parsePN_CHARS(); + if (s5 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s5 = peg$c5; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } + } + } + } + if (s4 !== peg$FAILED) { + s5 = peg$parsePN_CHARS(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$c0; + } + } else { + peg$currPos = s3; + s3 = peg$c0; + } + if (s3 === peg$FAILED) { + s3 = peg$c9; + } + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c78(s1, s2, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseLANGTAG() { + var s0, s1, s2, s3, s4, s5, s6, s7; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 64) { + s1 = peg$c79; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c80); } + } + if (s1 !== peg$FAILED) { + s2 = []; + if (peg$c81.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } + } + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + if (peg$c81.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c82); } + } + } + } else { + s2 = peg$c0; + } + if (s2 !== peg$FAILED) { + s3 = []; + s4 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 45) { + s5 = peg$c83; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c84); } + } + if (s5 !== peg$FAILED) { + s6 = []; + if (peg$c85.test(input.charAt(peg$currPos))) { + s7 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c86); } + } + if (s7 !== peg$FAILED) { + while (s7 !== peg$FAILED) { + s6.push(s7); + if (peg$c85.test(input.charAt(peg$currPos))) { + s7 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c86); } + } + } + } else { + s6 = peg$c0; + } + if (s6 !== peg$FAILED) { + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$c0; + } + } else { + peg$currPos = s4; + s4 = peg$c0; + } + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 45) { + s5 = peg$c83; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c84); } + } + if (s5 !== peg$FAILED) { + s6 = []; + if (peg$c85.test(input.charAt(peg$currPos))) { + s7 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c86); } + } + if (s7 !== peg$FAILED) { + while (s7 !== peg$FAILED) { + s6.push(s7); + if (peg$c85.test(input.charAt(peg$currPos))) { + s7 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c86); } + } + } + } else { + s6 = peg$c0; + } + if (s6 !== peg$FAILED) { + s5 = [s5, s6]; + s4 = s5; + } else { + peg$currPos = s4; + s4 = peg$c0; + } + } else { + peg$currPos = s4; + s4 = peg$c0; + } + } + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c87(s2, s3); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseINTEGER() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (peg$c88.test(input.charAt(peg$currPos))) { + s1 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c89); } + } + if (s1 === peg$FAILED) { + s1 = peg$c9; + } + if (s1 !== peg$FAILED) { + s2 = []; + if (peg$c76.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + if (s3 !== peg$FAILED) { + while (s3 !== peg$FAILED) { + s2.push(s3); + if (peg$c76.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + } + } else { + s2 = peg$c0; + } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c90(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseDECIMAL() { + var s0, s1, s2, s3, s4, s5, s6; + + s0 = peg$currPos; + if (peg$c88.test(input.charAt(peg$currPos))) { + s1 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c89); } + } + if (s1 === peg$FAILED) { + s1 = peg$c9; + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + s3 = []; + if (peg$c76.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + while (s4 !== peg$FAILED) { + s3.push(s4); + if (peg$c76.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + } + if (s3 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s4 = peg$c5; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } + } + if (s4 !== peg$FAILED) { + s5 = []; + if (peg$c76.test(input.charAt(peg$currPos))) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + if (s6 !== peg$FAILED) { + while (s6 !== peg$FAILED) { + s5.push(s6); + if (peg$c76.test(input.charAt(peg$currPos))) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + } + } else { + s5 = peg$c0; + } + if (s5 !== peg$FAILED) { + s3 = [s3, s4, s5]; + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c0; + } + } else { + peg$currPos = s2; + s2 = peg$c0; + } + } else { + peg$currPos = s2; + s2 = peg$c0; + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseDOUBLE() { + var s0, s1, s2, s3, s4, s5, s6; + + s0 = peg$currPos; + if (peg$c88.test(input.charAt(peg$currPos))) { + s1 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c89); } + } + if (s1 === peg$FAILED) { + s1 = peg$c9; + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + s3 = []; + if (peg$c76.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + if (peg$c76.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + } + } else { + s3 = peg$c0; + } + if (s3 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s4 = peg$c5; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } + } + if (s4 !== peg$FAILED) { + s5 = []; + if (peg$c76.test(input.charAt(peg$currPos))) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + while (s6 !== peg$FAILED) { + s5.push(s6); + if (peg$c76.test(input.charAt(peg$currPos))) { + s6 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + } + if (s5 !== peg$FAILED) { + s6 = peg$parseEXPONENT(); + if (s6 !== peg$FAILED) { + s3 = [s3, s4, s5, s6]; + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c0; + } + } else { + peg$currPos = s2; + s2 = peg$c0; + } + } else { + peg$currPos = s2; + s2 = peg$c0; + } + } else { + peg$currPos = s2; + s2 = peg$c0; + } + if (s2 === peg$FAILED) { + s2 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 46) { + s3 = peg$c5; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } + } + if (s3 !== peg$FAILED) { + s4 = []; + if (peg$c76.test(input.charAt(peg$currPos))) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + if (s5 !== peg$FAILED) { + while (s5 !== peg$FAILED) { + s4.push(s5); + if (peg$c76.test(input.charAt(peg$currPos))) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + } + } else { + s4 = peg$c0; + } + if (s4 !== peg$FAILED) { + s5 = peg$parseEXPONENT(); + if (s5 !== peg$FAILED) { + s3 = [s3, s4, s5]; + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c0; + } + } else { + peg$currPos = s2; + s2 = peg$c0; + } + } else { + peg$currPos = s2; + s2 = peg$c0; + } + if (s2 === peg$FAILED) { + s2 = peg$currPos; + s3 = []; + if (peg$c76.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + if (peg$c76.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + } + } else { + s3 = peg$c0; + } + if (s3 !== peg$FAILED) { + s4 = peg$parseEXPONENT(); + if (s4 !== peg$FAILED) { + s3 = [s3, s4]; + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c0; + } + } else { + peg$currPos = s2; + s2 = peg$c0; + } + } + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseEXPONENT() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + if (peg$c91.test(input.charAt(peg$currPos))) { + s1 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c92); } + } + if (s1 !== peg$FAILED) { + if (peg$c88.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c89); } + } + if (s2 === peg$FAILED) { + s2 = peg$c9; + } + if (s2 !== peg$FAILED) { + s3 = []; + if (peg$c76.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + if (s4 !== peg$FAILED) { + while (s4 !== peg$FAILED) { + s3.push(s4); + if (peg$c76.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + } + } else { + s3 = peg$c0; + } + if (s3 !== peg$FAILED) { + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseSTRING_LITERAL_QUOTE() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 34) { + s1 = peg$c93; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c94); } + } + if (s1 !== peg$FAILED) { + s2 = []; + if (peg$c95.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c96); } + } + if (s3 === peg$FAILED) { + s3 = peg$parseECHAR(); + if (s3 === peg$FAILED) { + s3 = peg$parseUCHAR(); + } + } + while (s3 !== peg$FAILED) { + s2.push(s3); + if (peg$c95.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c96); } + } + if (s3 === peg$FAILED) { + s3 = peg$parseECHAR(); + if (s3 === peg$FAILED) { + s3 = peg$parseUCHAR(); + } + } + } + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 34) { + s3 = peg$c93; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c94); } + } + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c97(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseSTRING_LITERAL_SINGLE_QUOTE() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 39) { + s1 = peg$c98; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c99); } + } + if (s1 !== peg$FAILED) { + s2 = []; + if (peg$c100.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c101); } + } + if (s3 === peg$FAILED) { + s3 = peg$parseECHAR(); + if (s3 === peg$FAILED) { + s3 = peg$parseUCHAR(); + } + } + while (s3 !== peg$FAILED) { + s2.push(s3); + if (peg$c100.test(input.charAt(peg$currPos))) { + s3 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c101); } + } + if (s3 === peg$FAILED) { + s3 = peg$parseECHAR(); + if (s3 === peg$FAILED) { + s3 = peg$parseUCHAR(); + } + } + } + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 39) { + s3 = peg$c98; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c99); } + } + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c97(s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseSTRING_LITERAL_LONG_SINGLE_QUOTE() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 3) === peg$c102) { + s1 = peg$c102; + peg$currPos += 3; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c103); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 39) { + s4 = peg$c98; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c99); } + } + if (s4 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c104) { + s4 = peg$c104; + peg$currPos += 2; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c105); } + } + } + if (s4 === peg$FAILED) { + s4 = peg$c9; + } + if (s4 !== peg$FAILED) { + if (peg$c106.test(input.charAt(peg$currPos))) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c107); } + } + if (s5 === peg$FAILED) { + s5 = peg$parseECHAR(); + if (s5 === peg$FAILED) { + s5 = peg$parseUCHAR(); + } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$c0; + } + } else { + peg$currPos = s3; + s3 = peg$c0; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 39) { + s4 = peg$c98; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c99); } + } + if (s4 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c104) { + s4 = peg$c104; + peg$currPos += 2; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c105); } + } + } + if (s4 === peg$FAILED) { + s4 = peg$c9; + } + if (s4 !== peg$FAILED) { + if (peg$c106.test(input.charAt(peg$currPos))) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c107); } + } + if (s5 === peg$FAILED) { + s5 = peg$parseECHAR(); + if (s5 === peg$FAILED) { + s5 = peg$parseUCHAR(); + } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$c0; + } + } else { + peg$currPos = s3; + s3 = peg$c0; + } + } + if (s2 !== peg$FAILED) { + if (input.substr(peg$currPos, 3) === peg$c102) { + s3 = peg$c102; + peg$currPos += 3; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c103); } + } + if (s3 !== peg$FAILED) { + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseSTRING_LITERAL_LONG_QUOTE() { + var s0, s1, s2, s3, s4, s5; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 3) === peg$c108) { + s1 = peg$c108; + peg$currPos += 3; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c109); } + } + if (s1 !== peg$FAILED) { + s2 = []; + s3 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 34) { + s4 = peg$c93; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c94); } + } + if (s4 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c110) { + s4 = peg$c110; + peg$currPos += 2; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c111); } + } + } + if (s4 === peg$FAILED) { + s4 = peg$c9; + } + if (s4 !== peg$FAILED) { + if (peg$c112.test(input.charAt(peg$currPos))) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c113); } + } + if (s5 === peg$FAILED) { + s5 = peg$parseECHAR(); + if (s5 === peg$FAILED) { + s5 = peg$parseUCHAR(); + } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$c0; + } + } else { + peg$currPos = s3; + s3 = peg$c0; + } + while (s3 !== peg$FAILED) { + s2.push(s3); + s3 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 34) { + s4 = peg$c93; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c94); } + } + if (s4 === peg$FAILED) { + if (input.substr(peg$currPos, 2) === peg$c110) { + s4 = peg$c110; + peg$currPos += 2; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c111); } + } + } + if (s4 === peg$FAILED) { + s4 = peg$c9; + } + if (s4 !== peg$FAILED) { + if (peg$c112.test(input.charAt(peg$currPos))) { + s5 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c113); } + } + if (s5 === peg$FAILED) { + s5 = peg$parseECHAR(); + if (s5 === peg$FAILED) { + s5 = peg$parseUCHAR(); + } + } + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$c0; + } + } else { + peg$currPos = s3; + s3 = peg$c0; + } + } + if (s2 !== peg$FAILED) { + if (input.substr(peg$currPos, 3) === peg$c108) { + s3 = peg$c108; + peg$currPos += 3; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c109); } + } + if (s3 !== peg$FAILED) { + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseUCHAR() { + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; + + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c114) { + s1 = peg$c114; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c115); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseHEX(); + if (s2 !== peg$FAILED) { + s3 = peg$parseHEX(); + if (s3 !== peg$FAILED) { + s4 = peg$parseHEX(); + if (s4 !== peg$FAILED) { + s5 = peg$parseHEX(); + if (s5 !== peg$FAILED) { + s1 = [s1, s2, s3, s4, s5]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + if (s0 === peg$FAILED) { + s0 = peg$currPos; + if (input.substr(peg$currPos, 2) === peg$c116) { + s1 = peg$c116; + peg$currPos += 2; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c117); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseHEX(); + if (s2 !== peg$FAILED) { + s3 = peg$parseHEX(); + if (s3 !== peg$FAILED) { + s4 = peg$parseHEX(); + if (s4 !== peg$FAILED) { + s5 = peg$parseHEX(); + if (s5 !== peg$FAILED) { + s6 = peg$parseHEX(); + if (s6 !== peg$FAILED) { + s7 = peg$parseHEX(); + if (s7 !== peg$FAILED) { + s8 = peg$parseHEX(); + if (s8 !== peg$FAILED) { + s9 = peg$parseHEX(); + if (s9 !== peg$FAILED) { + s1 = [s1, s2, s3, s4, s5, s6, s7, s8, s9]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } + + return s0; + } + + function peg$parseECHAR() { + var s0, s1, s2; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 92) { + s1 = peg$c118; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c119); } + } + if (s1 !== peg$FAILED) { + if (peg$c120.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c121); } + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseNIL() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 40) { + s1 = peg$c45; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c46); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseIGNORE(); + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 41) { + s3 = peg$c47; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c48); } + } + if (s3 !== peg$FAILED) { + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseWS() { + var s0; + + if (input.charCodeAt(peg$currPos) === 32) { + s0 = peg$c122; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c123); } + } + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 9) { + s0 = peg$c124; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c125); } + } + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 13) { + s0 = peg$c126; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c127); } + } + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 10) { + s0 = peg$c128; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c129); } + } + } + } + } + + return s0; + } + + function peg$parseANON() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 91) { + s1 = peg$c40; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c41); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseIGNORE(); + if (s2 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 93) { + s3 = peg$c42; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c43); } + } + if (s3 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c130(); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parsePN_CHARS_BASE() { + var s0; + + if (peg$c131.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c132); } + } + if (s0 === peg$FAILED) { + if (peg$c133.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c134); } + } + if (s0 === peg$FAILED) { + if (peg$c135.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c136); } + } + if (s0 === peg$FAILED) { + if (peg$c137.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c138); } + } + if (s0 === peg$FAILED) { + if (peg$c139.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c140); } + } + if (s0 === peg$FAILED) { + if (peg$c141.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c142); } + } + if (s0 === peg$FAILED) { + if (peg$c143.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c144); } + } + if (s0 === peg$FAILED) { + if (peg$c145.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c146); } + } + if (s0 === peg$FAILED) { + if (peg$c147.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c148); } + } + if (s0 === peg$FAILED) { + if (peg$c149.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c150); } + } + if (s0 === peg$FAILED) { + if (peg$c151.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c152); } + } + if (s0 === peg$FAILED) { + if (peg$c153.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c154); } + } + if (s0 === peg$FAILED) { + if (peg$c155.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c156); } + } + } + } + } + } + } + } + } + } + } + } + } + } + + return s0; + } + + function peg$parsePN_CHARS_U() { + var s0, s1; + + s0 = []; + s1 = peg$parsePN_CHARS_BASE(); + if (s1 !== peg$FAILED) { + while (s1 !== peg$FAILED) { + s0.push(s1); + s1 = peg$parsePN_CHARS_BASE(); + } + } else { + s0 = peg$c0; + } + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 95) { + s0 = peg$c157; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c158); } + } + } + + return s0; + } + + function peg$parsePN_CHARS() { + var s0; + + s0 = peg$parsePN_CHARS_U(); + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 45) { + s0 = peg$c83; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c84); } + } + if (s0 === peg$FAILED) { + if (peg$c76.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + if (s0 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 183) { + s0 = peg$c159; + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c160); } + } + if (s0 === peg$FAILED) { + if (peg$c161.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c162); } + } + if (s0 === peg$FAILED) { + if (peg$c163.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c164); } + } + } + } + } + } + } + + return s0; + } + + function peg$parsePN_PREFIX() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + s1 = []; + s2 = peg$parsePN_CHARS_BASE(); + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$parsePN_CHARS_BASE(); + } + } else { + s1 = peg$c0; + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + s3 = []; + s4 = peg$parsePN_CHARS(); + if (s4 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s4 = peg$c5; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } + } + } + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$parsePN_CHARS(); + if (s4 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s4 = peg$c5; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } + } + } + } + if (s3 !== peg$FAILED) { + s4 = peg$parsePN_CHARS(); + if (s4 !== peg$FAILED) { + s3 = [s3, s4]; + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c0; + } + } else { + peg$currPos = s2; + s2 = peg$c0; + } + if (s2 === peg$FAILED) { + s2 = peg$c9; + } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c165(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parsePN_LOCAL() { + var s0, s1, s2, s3, s4; + + s0 = peg$currPos; + s1 = peg$parsePN_CHARS_U(); + if (s1 === peg$FAILED) { + s1 = []; + if (input.charCodeAt(peg$currPos) === 58) { + s2 = peg$c70; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c71); } + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + if (input.charCodeAt(peg$currPos) === 58) { + s2 = peg$c70; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c71); } + } + } + } else { + s1 = peg$c0; + } + if (s1 === peg$FAILED) { + s1 = []; + if (peg$c76.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + if (peg$c76.test(input.charAt(peg$currPos))) { + s2 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + } + } else { + s1 = peg$c0; + } + if (s1 === peg$FAILED) { + s1 = []; + s2 = peg$parsePLX(); + if (s2 !== peg$FAILED) { + while (s2 !== peg$FAILED) { + s1.push(s2); + s2 = peg$parsePLX(); + } + } else { + s1 = peg$c0; + } + } + } + } + if (s1 !== peg$FAILED) { + s2 = peg$currPos; + s3 = []; + s4 = peg$parsePN_CHARS(); + if (s4 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s4 = peg$c5; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } + } + if (s4 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 58) { + s4 = peg$c70; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c71); } + } + if (s4 === peg$FAILED) { + s4 = peg$parsePLX(); + } + } + } + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$parsePN_CHARS(); + if (s4 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s4 = peg$c5; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } + } + if (s4 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 58) { + s4 = peg$c70; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c71); } + } + if (s4 === peg$FAILED) { + s4 = peg$parsePLX(); + } + } + } + } + if (s3 !== peg$FAILED) { + s4 = peg$parsePN_CHARS(); + if (s4 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 58) { + s4 = peg$c70; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c71); } + } + if (s4 === peg$FAILED) { + s4 = peg$parsePLX(); + } + } + if (s4 !== peg$FAILED) { + peg$reportedPos = s2; + s3 = peg$c166(s3, s4); + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$c0; + } + } else { + peg$currPos = s2; + s2 = peg$c0; + } + if (s2 === peg$FAILED) { + s2 = peg$c9; + } + if (s2 !== peg$FAILED) { + peg$reportedPos = s0; + s1 = peg$c167(s1, s2); + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parsePLX() { + var s0; + + s0 = peg$parsePERCENT(); + if (s0 === peg$FAILED) { + s0 = peg$parsePN_LOCAL_ESC(); + } + + return s0; + } + + function peg$parsePERCENT() { + var s0, s1, s2, s3; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 37) { + s1 = peg$c168; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c169); } + } + if (s1 !== peg$FAILED) { + s2 = peg$parseHEX(); + if (s2 !== peg$FAILED) { + s3 = peg$parseHEX(); + if (s3 !== peg$FAILED) { + s1 = [s1, s2, s3]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseHEX() { + var s0; + + if (peg$c76.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c77); } + } + if (s0 === peg$FAILED) { + if (peg$c170.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c171); } + } + if (s0 === peg$FAILED) { + if (peg$c172.test(input.charAt(peg$currPos))) { + s0 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s0 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c173); } + } + } + } + + return s0; + } + + function peg$parsePN_LOCAL_ESC() { + var s0, s1, s2; + + s0 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 92) { + s1 = peg$c118; + peg$currPos++; + } else { + s1 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c119); } + } + if (s1 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 95) { + s2 = peg$c157; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c158); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 126) { + s2 = peg$c174; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c175); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 46) { + s2 = peg$c5; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c6); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 45) { + s2 = peg$c83; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c84); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 33) { + s2 = peg$c176; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c177); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 36) { + s2 = peg$c178; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c179); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 38) { + s2 = peg$c180; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c181); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 39) { + s2 = peg$c98; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c99); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 40) { + s2 = peg$c45; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c46); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 41) { + s2 = peg$c47; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c48); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 42) { + s2 = peg$c182; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c183); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 43) { + s2 = peg$c184; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c185); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 44) { + s2 = peg$c31; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c32); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 59) { + s2 = peg$c27; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c28); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 61) { + s2 = peg$c186; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c187); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 47) { + s2 = peg$c188; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c189); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 63) { + s2 = peg$c190; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c191); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 35) { + s2 = peg$c192; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c193); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 64) { + s2 = peg$c79; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c80); } + } + if (s2 === peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 37) { + s2 = peg$c168; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c169); } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; + } else { + peg$currPos = s0; + s0 = peg$c0; + } + } else { + peg$currPos = s0; + s0 = peg$c0; + } + + return s0; + } + + function peg$parseIGNORE() { + var s0, s1, s2, s3, s4; + + s0 = []; + s1 = peg$parseWS(); + if (s1 === peg$FAILED) { + s1 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 35) { + s2 = peg$c192; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c193); } + } + if (s2 !== peg$FAILED) { + s3 = []; + if (peg$c194.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c195); } + } + while (s4 !== peg$FAILED) { + s3.push(s4); + if (peg$c194.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c195); } + } + } + if (s3 !== peg$FAILED) { + if (peg$c196.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c197); } + } + if (s4 !== peg$FAILED) { + s2 = [s2, s3, s4]; + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$c0; + } + } else { + peg$currPos = s1; + s1 = peg$c0; + } + } else { + peg$currPos = s1; + s1 = peg$c0; + } + } + while (s1 !== peg$FAILED) { + s0.push(s1); + s1 = peg$parseWS(); + if (s1 === peg$FAILED) { + s1 = peg$currPos; + if (input.charCodeAt(peg$currPos) === 35) { + s2 = peg$c192; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c193); } + } + if (s2 !== peg$FAILED) { + s3 = []; + if (peg$c194.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c195); } + } + while (s4 !== peg$FAILED) { + s3.push(s4); + if (peg$c194.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c195); } + } + } + if (s3 !== peg$FAILED) { + if (peg$c196.test(input.charAt(peg$currPos))) { + s4 = input.charAt(peg$currPos); + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c197); } + } + if (s4 !== peg$FAILED) { + s2 = [s2, s3, s4]; + s1 = s2; + } else { + peg$currPos = s1; + s1 = peg$c0; + } + } else { + peg$currPos = s1; + s1 = peg$c0; + } + } else { + peg$currPos = s1; + s1 = peg$c0; + } + } + } + + return s0; + } + + + + function assign(target, source) { + for (var key in source) { + target[key] = source[key]; + } + return target; + } + + function contextItem(key, value) { + var decl = {} + decl[key] = value; + return {'@context': decl}; + } + + function prefix(pfx, iriref) { + return contextItem(pfx || '@vocab', iriref['@id']); + } + + function base(iriref) { + return contextItem('@base', iriref['@id']); + } + + function reducePairs(subject, pairs) { + if (subject === null) { + subject = ''; + } + if (typeof subject === 'string') { + if (subject.indexOf(':') === -1) { + subject = ':' + subject; + } + subject = {'@id': subject}; + } + for (var pair of pairs) { + for (var key in pair) { + var value = pair[key]; + var existing = subject[key]; + if (typeof existing !== 'undefined') { + if (!Array.isArray(existing)) { + existing = [existing]; + } + if (Array.isArray(value.forEach)) { + existing.concat(value); + } else { + existing.push(value); + } + value = existing; + } + subject[key] = value; + } + } + return subject; + } + + + + 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); + } + } + + return { + SyntaxError: SyntaxError, + parse: parse + }; +})(); diff --git a/package.json b/package.json index c6a121b..5ec43ec 100644 --- a/package.json +++ b/package.json @@ -12,17 +12,16 @@ "bugs": { "url": "https://github.com/niklasl/ldtr/issues" }, - "version": "0.1.0", + "version": "0.1.2", "devDependencies": { "pegjs": "^0.8.0", "tape": "^4.0.0" }, - "files": ["build", "lib", "bin"], + "files": ["lib", "bin"], "main": "lib/index.js", "bin": "bin/ldtr", "scripts": { - "build": "npm run peg", - "peg": "pegjs src/parsers/trig.pegjs build/parsers/trig.js", + "peg": "pegjs src/parsers/trig.pegjs lib/parsers/trig.js", "test": "node --harmony --use-strict test/test_trig.js" } } diff --git a/test/test_trig.js b/test/test_trig.js index 2e5abc3..ef6bf5b 100644 --- a/test/test_trig.js +++ b/test/test_trig.js @@ -1,7 +1,7 @@ -let trigParser = require('../build/parsers/trig.js') +var trigParser = require('../lib/parsers/trig.js') try { - let result = trigParser.parse('\ + var result = trigParser.parse('\ @prefix : . \n\ @prefix ns: . \n\ PREFIX xsd: \n\