UNPKG

translate-maker

Version:

Lightweight translation module. Internationalize your great project.

2,139 lines (1,915 loc) 55.9 kB
/* * Generated by PEG.js 0.10.0. * * http://pegjs.org/ */ "use strict"; function peg$subclass(child, parent) { function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); } function peg$SyntaxError(message, expected, found, location) { this.message = message; this.expected = expected; this.found = found; this.location = location; this.name = "SyntaxError"; if (typeof Error.captureStackTrace === "function") { Error.captureStackTrace(this, peg$SyntaxError); } } peg$subclass(peg$SyntaxError, Error); peg$SyntaxError.buildMessage = function(expected, found) { var DESCRIBE_EXPECTATION_FNS = { literal: function(expectation) { return "\"" + literalEscape(expectation.text) + "\""; }, "class": function(expectation) { var escapedParts = "", i; for (i = 0; i < expectation.parts.length; i++) { escapedParts += expectation.parts[i] instanceof Array ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) : classEscape(expectation.parts[i]); } return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; }, any: function(expectation) { return "any character"; }, end: function(expectation) { return "end of input"; }, other: function(expectation) { return expectation.description; } }; function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); } function literalEscape(s) { return s .replace(/\\/g, '\\\\') .replace(/"/g, '\\"') .replace(/\0/g, '\\0') .replace(/\t/g, '\\t') .replace(/\n/g, '\\n') .replace(/\r/g, '\\r') .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); } function classEscape(s) { return s .replace(/\\/g, '\\\\') .replace(/\]/g, '\\]') .replace(/\^/g, '\\^') .replace(/-/g, '\\-') .replace(/\0/g, '\\0') .replace(/\t/g, '\\t') .replace(/\n/g, '\\n') .replace(/\r/g, '\\r') .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); }); } function describeExpectation(expectation) { return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); } function describeExpected(expected) { var descriptions = new Array(expected.length), i, j; for (i = 0; i < expected.length; i++) { descriptions[i] = describeExpectation(expected[i]); } descriptions.sort(); if (descriptions.length > 0) { for (i = 1, j = 1; i < descriptions.length; i++) { if (descriptions[i - 1] !== descriptions[i]) { descriptions[j] = descriptions[i]; j++; } } descriptions.length = j; } switch (descriptions.length) { case 1: return descriptions[0]; case 2: return descriptions[0] + " or " + descriptions[1]; default: return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1]; } } function describeFound(found) { return found ? "\"" + literalEscape(found) + "\"" : "end of input"; } return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; }; function peg$parse(input, options) { options = options !== void 0 ? options : {}; var peg$FAILED = {}, peg$startRuleFunctions = { start: peg$parsestart }, peg$startRuleFunction = peg$parsestart, peg$c0 = /^[ \t\n\r]/, peg$c1 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false), peg$c2 = peg$otherExpectation("whitespace"), peg$c3 = peg$otherExpectation("optionalWhitespace"), peg$c4 = "false", peg$c5 = peg$literalExpectation("false", false), peg$c6 = function() { return false; }, peg$c7 = "null", peg$c8 = peg$literalExpectation("null", false), peg$c9 = function() { return null; }, peg$c10 = "undefined", peg$c11 = peg$literalExpectation("undefined", false), peg$c12 = function() { return void 0; }, peg$c13 = "true", peg$c14 = peg$literalExpectation("true", false), peg$c15 = function() { return true; }, peg$c16 = peg$otherExpectation("number"), peg$c17 = "-", peg$c18 = peg$literalExpectation("-", false), peg$c19 = function() { return parseFloat(text()); }, peg$c20 = /^[0-9]/, peg$c21 = peg$classExpectation([["0", "9"]], false, false), peg$c22 = /^[0-9a-f]/i, peg$c23 = peg$classExpectation([["0", "9"], ["a", "f"]], false, true), peg$c24 = /^[eE]/, peg$c25 = peg$classExpectation(["e", "E"], false, false), peg$c26 = "+", peg$c27 = peg$literalExpectation("+", false), peg$c28 = ".", peg$c29 = peg$literalExpectation(".", false), peg$c30 = "0", peg$c31 = peg$literalExpectation("0", false), peg$c32 = /^[1-9]/, peg$c33 = peg$classExpectation([["1", "9"]], false, false), peg$c34 = /^[a-z0-9_]/i, peg$c35 = peg$classExpectation([["a", "z"], ["0", "9"], "_"], false, true), peg$c36 = /^[a-z0-9\-_]/i, peg$c37 = peg$classExpectation([["a", "z"], ["0", "9"], "-", "_"], false, true), peg$c38 = peg$otherExpectation("property"), peg$c39 = peg$otherExpectation("reference"), peg$c40 = function(path) { return { type: 'reference', path }; }, peg$c41 = peg$otherExpectation("variable"), peg$c42 = "$", peg$c43 = peg$literalExpectation("$", false), peg$c44 = function(reference) { return { type: 'variable', path: reference.path }; }, peg$c45 = function(reference, variable) { return { type: 'combination', path: [reference, variable] }; }, peg$c46 = "\\n", peg$c47 = peg$literalExpectation("\\n", false), peg$c48 = function() { return '\n' }, peg$c49 = "\\t", peg$c50 = peg$literalExpectation("\\t", false), peg$c51 = function() { return '\t' }, peg$c52 = "\\r", peg$c53 = peg$literalExpectation("\\r", false), peg$c54 = function() { return '\r' }, peg$c55 = "\\\\", peg$c56 = peg$literalExpectation("\\\\", false), peg$c57 = function() { return '\\' }, peg$c58 = "\\u", peg$c59 = peg$literalExpectation("\\u", false), peg$c60 = function(digits) { return String.fromCharCode(parseInt(digits, 16)); }, peg$c61 = /^[^{}:,# \t\n\r\\]/, peg$c62 = peg$classExpectation(["{", "}", ":", ",", "#", " ", "\t", "\n", "\r", "\\"], true, false), peg$c63 = "\\{", peg$c64 = peg$literalExpectation("\\{", false), peg$c65 = function() { return '\u007B'; }, peg$c66 = "\\}", peg$c67 = peg$literalExpectation("\\}", false), peg$c68 = function() { return '\u007D'; }, peg$c69 = "\\#", peg$c70 = peg$literalExpectation("\\#", false), peg$c71 = function() { return '\\#'; }, peg$c72 = /^[:,]/, peg$c73 = peg$classExpectation([":", ","], false, false), peg$c74 = "#", peg$c75 = peg$literalExpectation("#", false), peg$c76 = function() { return { type: 'smart' } }, peg$c77 = function(chars) { return chars.join(''); }, peg$c78 = /^[^"\\]/, peg$c79 = peg$classExpectation(["\"", "\\"], true, false), peg$c80 = "\\\"", peg$c81 = peg$literalExpectation("\\\"", false), peg$c82 = function() { return '"'; }, peg$c83 = peg$otherExpectation("string"), peg$c84 = "\"", peg$c85 = peg$literalExpectation("\"", false), peg$c86 = function(chars) { return chars.join(""); }, peg$c87 = /^[^'\\]/, peg$c88 = peg$classExpectation(["'", "\\"], true, false), peg$c89 = "\\'", peg$c90 = peg$literalExpectation("\\'", false), peg$c91 = function() { return "'"; }, peg$c92 = "'", peg$c93 = peg$literalExpectation("'", false), peg$c94 = "{", peg$c95 = peg$literalExpectation("{", false), peg$c96 = "}", peg$c97 = peg$literalExpectation("}", false), peg$c98 = function(value) { return { type: 'pair', key: null, value }; }, peg$c99 = ":", peg$c100 = peg$literalExpectation(":", false), peg$c101 = function(key, value) { value.key = key; return value; }, peg$c102 = peg$otherExpectation("argument"), peg$c103 = peg$otherExpectation("extended argument"), peg$c104 = function(values) { return { type: 'main', values }; }, peg$c105 = function(value) { return { type: 'text', value }; }, peg$c106 = "as", peg$c107 = peg$literalExpectation("as", false), peg$c108 = function(from, to) { return { from, to: to.path }; }, peg$c109 = ",", peg$c110 = peg$literalExpectation(",", false), peg$c111 = function(as) { return as; }, peg$c112 = function(first, other) { return { type: 'as', args: [first].concat(other) }; }, peg$c113 = function(key, value) { return { key, value }; }, peg$c114 = function(meta) { return meta; }, peg$c115 = function(meta, other) { return [meta].concat(other); }, peg$c116 = function(arg) { return arg; }, peg$c117 = function(arg, args) { return [arg].concat(args); }, peg$c118 = function(metadata, args) { return { args, metadata }; }, peg$c119 = function(type, argsMetadata) { return { type, args: argsMetadata && argsMetadata.args, metadata: argsMetadata && argsMetadata.metadata }; }, peg$c120 = "|", peg$c121 = peg$literalExpectation("|", false), peg$c122 = function(filter) { return filter; }, peg$c123 = /^[,|]/, peg$c124 = peg$classExpectation([",", "|"], false, false), peg$c125 = function(filter, other) { return [filter].concat(other); }, peg$c126 = function(path, filters) { return { type: path.type, path: path.path, filters }; }, peg$currPos = 0, peg$savedPos = 0, peg$posDetailsCache = [{ line: 1, column: 1 }], 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$savedPos, peg$currPos); } function location() { return peg$computeLocation(peg$savedPos, peg$currPos); } function expected(description, location) { location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) throw peg$buildStructuredError( [peg$otherExpectation(description)], input.substring(peg$savedPos, peg$currPos), location ); } function error(message, location) { location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) throw peg$buildSimpleError(message, location); } function peg$literalExpectation(text, ignoreCase) { return { type: "literal", text: text, ignoreCase: ignoreCase }; } function peg$classExpectation(parts, inverted, ignoreCase) { return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; } function peg$anyExpectation() { return { type: "any" }; } function peg$endExpectation() { return { type: "end" }; } function peg$otherExpectation(description) { return { type: "other", description: description }; } function peg$computePosDetails(pos) { var details = peg$posDetailsCache[pos], p; if (details) { return details; } else { p = pos - 1; while (!peg$posDetailsCache[p]) { p--; } details = peg$posDetailsCache[p]; details = { line: details.line, column: details.column }; while (p < pos) { if (input.charCodeAt(p) === 10) { details.line++; details.column = 1; } else { details.column++; } p++; } peg$posDetailsCache[pos] = details; return details; } } function peg$computeLocation(startPos, endPos) { var startPosDetails = peg$computePosDetails(startPos), endPosDetails = peg$computePosDetails(endPos); return { start: { offset: startPos, line: startPosDetails.line, column: startPosDetails.column }, end: { offset: endPos, line: endPosDetails.line, column: endPosDetails.column } }; } 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$buildSimpleError(message, location) { return new peg$SyntaxError(message, null, null, location); } function peg$buildStructuredError(expected, found, location) { return new peg$SyntaxError( peg$SyntaxError.buildMessage(expected, found), expected, found, location ); } function peg$parsestart() { var s0; s0 = peg$parseparse(); return s0; } function peg$parsewsChar() { var s0; if (peg$c0.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c1); } } return s0; } function peg$parsews() { var s0, s1; peg$silentFails++; s0 = []; if (peg$c0.test(input.charAt(peg$currPos))) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c1); } } if (s1 !== peg$FAILED) { while (s1 !== peg$FAILED) { s0.push(s1); if (peg$c0.test(input.charAt(peg$currPos))) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c1); } } } } else { s0 = peg$FAILED; } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c2); } } return s0; } function peg$parse_() { var s0, s1, s2; peg$silentFails++; s0 = peg$currPos; s1 = []; s2 = peg$parsews(); while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parsews(); } if (s1 !== peg$FAILED) { s0 = input.substring(s0, peg$currPos); } else { s0 = s1; } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c3); } } return s0; } function peg$parsefalse() { var s0, s1; s0 = peg$currPos; if (input.substr(peg$currPos, 5) === peg$c4) { s1 = peg$c4; peg$currPos += 5; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c5); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c6(); } s0 = s1; return s0; } function peg$parsenull() { var s0, s1; s0 = peg$currPos; if (input.substr(peg$currPos, 4) === peg$c7) { s1 = peg$c7; peg$currPos += 4; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c8); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c9(); } s0 = s1; return s0; } function peg$parseundefined() { var s0, s1; s0 = peg$currPos; if (input.substr(peg$currPos, 9) === peg$c10) { s1 = peg$c10; peg$currPos += 9; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c11); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c12(); } s0 = s1; return s0; } function peg$parsetrue() { var s0, s1; s0 = peg$currPos; if (input.substr(peg$currPos, 4) === peg$c13) { s1 = peg$c13; peg$currPos += 4; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c14); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c15(); } s0 = s1; return s0; } function peg$parsenumber() { var s0, s1, s2, s3, s4; peg$silentFails++; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 45) { s1 = peg$c17; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c18); } } if (s1 === peg$FAILED) { s1 = null; } if (s1 !== peg$FAILED) { s2 = peg$parseint(); if (s2 !== peg$FAILED) { s3 = peg$parsefrac(); if (s3 === peg$FAILED) { s3 = null; } if (s3 !== peg$FAILED) { s4 = peg$parseexp(); if (s4 === peg$FAILED) { s4 = null; } if (s4 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c19(); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c16); } } return s0; } function peg$parsedigit() { var s0; if (peg$c20.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c21); } } return s0; } function peg$parsehexDigit() { var s0; if (peg$c22.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c23); } } return s0; } function peg$parseexp() { var s0, s1, s2, s3, s4; s0 = peg$currPos; if (peg$c24.test(input.charAt(peg$currPos))) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c25); } } if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 45) { s2 = peg$c17; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c18); } } if (s2 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 43) { s2 = peg$c26; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c27); } } } if (s2 === peg$FAILED) { s2 = null; } if (s2 !== peg$FAILED) { s3 = []; s4 = peg$parsedigit(); if (s4 !== peg$FAILED) { while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$parsedigit(); } } else { s3 = peg$FAILED; } if (s3 !== peg$FAILED) { s1 = [s1, s2, s3]; s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsefrac() { var s0, s1, s2, s3; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 46) { s1 = peg$c28; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c29); } } if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parsedigit(); if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parsedigit(); } } else { s2 = peg$FAILED; } if (s2 !== peg$FAILED) { s1 = [s1, s2]; s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parseint() { var s0, s1, s2, s3; if (input.charCodeAt(peg$currPos) === 48) { s0 = peg$c30; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c31); } } if (s0 === peg$FAILED) { s0 = peg$currPos; if (peg$c32.test(input.charAt(peg$currPos))) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c33); } } if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parsedigit(); while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parsedigit(); } if (s2 !== peg$FAILED) { s1 = [s1, s2]; s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } return s0; } function peg$parsepropFirstChar() { var s0; if (peg$c34.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c35); } } return s0; } function peg$parsepropOtherChar() { var s0; if (peg$c36.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c37); } } return s0; } function peg$parseproperty() { var s0, s1, s2, s3, s4; peg$silentFails++; s0 = peg$currPos; s1 = peg$currPos; s2 = peg$parsepropFirstChar(); if (s2 !== peg$FAILED) { s3 = []; s4 = peg$parsepropOtherChar(); while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$parsepropOtherChar(); } if (s3 !== peg$FAILED) { s2 = [s2, s3]; s1 = s2; } else { peg$currPos = s1; s1 = peg$FAILED; } } else { peg$currPos = s1; s1 = peg$FAILED; } if (s1 !== peg$FAILED) { s0 = input.substring(s0, peg$currPos); } else { s0 = s1; } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c38); } } return s0; } function peg$parsereferencePath() { var s0, s1, s2, s3, s4, s5, s6, s7; peg$silentFails++; s0 = peg$currPos; s1 = peg$currPos; s2 = peg$currPos; s3 = peg$parseproperty(); if (s3 !== peg$FAILED) { s4 = []; s5 = peg$currPos; if (input.charCodeAt(peg$currPos) === 46) { s6 = peg$c28; peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c29); } } if (s6 !== peg$FAILED) { s7 = peg$parseproperty(); if (s7 !== peg$FAILED) { s6 = [s6, s7]; s5 = s6; } else { peg$currPos = s5; s5 = peg$FAILED; } } else { peg$currPos = s5; s5 = peg$FAILED; } while (s5 !== peg$FAILED) { s4.push(s5); s5 = peg$currPos; if (input.charCodeAt(peg$currPos) === 46) { s6 = peg$c28; peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c29); } } if (s6 !== peg$FAILED) { s7 = peg$parseproperty(); if (s7 !== peg$FAILED) { s6 = [s6, s7]; s5 = s6; } else { peg$currPos = s5; s5 = peg$FAILED; } } else { peg$currPos = s5; s5 = peg$FAILED; } } if (s4 !== peg$FAILED) { s3 = [s3, s4]; s2 = s3; } else { peg$currPos = s2; s2 = peg$FAILED; } } else { peg$currPos = s2; s2 = peg$FAILED; } if (s2 !== peg$FAILED) { s1 = input.substring(s1, peg$currPos); } else { s1 = s2; } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c40(s1); } s0 = s1; peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c39); } } return s0; } function peg$parsevariablePath() { var s0, s1, s2; peg$silentFails++; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 36) { s1 = peg$c42; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c43); } } if (s1 !== peg$FAILED) { s2 = peg$parsereferencePath(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c44(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c41); } } return s0; } function peg$parsereferenceVariablePath() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parsereferencePath(); if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 46) { s2 = peg$c28; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c29); } } if (s2 !== peg$FAILED) { s3 = peg$parsevariablePath(); if (s3 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c45(s1, s3); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsepath() { var s0; s0 = peg$parsevariablePath(); if (s0 === peg$FAILED) { s0 = peg$parsereferenceVariablePath(); if (s0 === peg$FAILED) { s0 = peg$parsereferencePath(); } } return s0; } function peg$parsenewLine() { var s0, s1; s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c46) { s1 = peg$c46; peg$currPos += 2; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c47); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c48(); } s0 = s1; return s0; } function peg$parsetab() { var s0, s1; s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c49) { s1 = peg$c49; peg$currPos += 2; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c50); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c51(); } s0 = s1; return s0; } function peg$parsereturn() { var s0, s1; s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c52) { s1 = peg$c52; peg$currPos += 2; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c53); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c54(); } s0 = s1; return s0; } function peg$parsebackslash() { var s0, s1; s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c55) { s1 = peg$c55; peg$currPos += 2; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c56); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c57(); } s0 = s1; return s0; } function peg$parseescapedToReal() { var s0; s0 = peg$parsebackslash(); if (s0 === peg$FAILED) { s0 = peg$parsenewLine(); if (s0 === peg$FAILED) { s0 = peg$parsetab(); if (s0 === peg$FAILED) { s0 = peg$parsereturn(); } } } return s0; } function peg$parseunicodeToString() { var s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c58) { s1 = peg$c58; peg$currPos += 2; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c59); } } if (s1 !== peg$FAILED) { s2 = peg$currPos; s3 = peg$currPos; s4 = peg$parsehexDigit(); if (s4 !== peg$FAILED) { s5 = peg$parsehexDigit(); if (s5 !== peg$FAILED) { s6 = peg$parsehexDigit(); if (s6 !== peg$FAILED) { s7 = peg$parsehexDigit(); if (s7 !== peg$FAILED) { s4 = [s4, s5, s6, s7]; s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } if (s3 !== peg$FAILED) { s2 = input.substring(s2, peg$currPos); } else { s2 = s3; } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c60(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parseparamChar() { var s0, s1; if (peg$c61.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c62); } } if (s0 === peg$FAILED) { s0 = peg$parsebackslash(); if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c63) { s1 = peg$c63; peg$currPos += 2; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c64); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c65(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c66) { s1 = peg$c66; peg$currPos += 2; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c67); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c68(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c69) { s1 = peg$c69; peg$currPos += 2; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c70); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c71(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$parseunicodeToString(); } } } } } return s0; } function peg$parsevisibleChar() { var s0; s0 = peg$parseparamChar(); if (s0 === peg$FAILED) { if (peg$c72.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c73); } } } return s0; } function peg$parsechar() { var s0; s0 = peg$parsevisibleChar(); if (s0 === peg$FAILED) { s0 = peg$parsewsChar(); } return s0; } function peg$parsesmartVariable() { var s0, s1; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 35) { s1 = peg$c74; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c75); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c76(); } s0 = s1; return s0; } function peg$parseparamString() { var s0, s1, s2; s0 = peg$currPos; s1 = []; s2 = peg$parseparamChar(); if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parseparamChar(); } } else { s1 = peg$FAILED; } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c77(s1); } s0 = s1; return s0; } function peg$parsevisibleString() { var s0, s1, s2; s0 = peg$currPos; s1 = []; s2 = peg$parsevisibleChar(); if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parsevisibleChar(); } } else { s1 = peg$FAILED; } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c77(s1); } s0 = s1; return s0; } function peg$parsestring() { var s0, s1, s2; s0 = peg$currPos; s1 = []; s2 = peg$parsechar(); if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parsechar(); } } else { s1 = peg$FAILED; } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c77(s1); } s0 = s1; return s0; } function peg$parseescapedChar1() { var s0, s1; if (peg$c78.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c79); } } if (s0 === peg$FAILED) { s0 = peg$parseescapedToReal(); if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c80) { s1 = peg$c80; peg$currPos += 2; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c81); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c82(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$parseunicodeToString(); } } } return s0; } function peg$parseeascapedString1() { var s0, s1, s2, s3; peg$silentFails++; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 34) { s1 = peg$c84; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c85); } } if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parseescapedChar1(); while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parseescapedChar1(); } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { s3 = peg$c84; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c85); } } if (s3 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c86(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c83); } } return s0; } function peg$parseescapedChar2() { var s0, s1; if (peg$c87.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c88); } } if (s0 === peg$FAILED) { s0 = peg$parseescapedToReal(); if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c89) { s1 = peg$c89; peg$currPos += 2; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c90); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c91(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$parseunicodeToString(); } } } return s0; } function peg$parseeascapedString2() { var s0, s1, s2, s3; peg$silentFails++; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 39) { s1 = peg$c92; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c93); } } if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parseescapedChar2(); while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parseescapedChar2(); } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 39) { s3 = peg$c92; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c93); } } if (s3 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c86(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c83); } } return s0; } function peg$parseeascapedString() { var s0; s0 = peg$parseeascapedString1(); if (s0 === peg$FAILED) { s0 = peg$parseeascapedString2(); } return s0; } function peg$parsekey() { var s0; s0 = peg$parseeascapedString(); if (s0 === peg$FAILED) { s0 = peg$parseparamString(); } return s0; } function peg$parseparseValue() { var s0, s1, s2, s3, s4; s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 123) { s2 = peg$c94; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c95); } } if (s2 !== peg$FAILED) { s3 = peg$parseparse(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { s4 = peg$c96; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c97); } } if (s4 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c98(s3); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsekeyValueParse() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { s2 = peg$parsekey(); if (s2 !== peg$FAILED) { s3 = peg$parse_(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { s4 = peg$c99; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c100); } } if (s4 === peg$FAILED) { s4 = null; } if (s4 !== peg$FAILED) { s5 = peg$parseparseValue(); if (s5 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c101(s2, s5); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsearg() { var s0, s1; peg$silentFails++; s0 = peg$parsefalse(); if (s0 === peg$FAILED) { s0 = peg$parsenull(); if (s0 === peg$FAILED) { s0 = peg$parseundefined(); if (s0 === peg$FAILED) { s0 = peg$parsetrue(); if (s0 === peg$FAILED) { s0 = peg$parsenumber(); if (s0 === peg$FAILED) { s0 = peg$parseeascapedString(); if (s0 === peg$FAILED) { s0 = peg$parsepath(); } } } } } } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c102); } } return s0; } function peg$parseargExt() { var s0, s1; peg$silentFails++; s0 = peg$parsekeyValueParse(); if (s0 === peg$FAILED) { s0 = peg$parseparseValue(); if (s0 === peg$FAILED) { s0 = peg$parsearg(); } } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c103); } } return s0; } function peg$parseparse() { var s0, s1, s2; s0 = peg$currPos; s1 = []; s2 = peg$parsestringFormat(); if (s2 === peg$FAILED) { s2 = peg$parsesmartVariable(); if (s2 === peg$FAILED) { s2 = peg$parselogicFormat(); } } while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parsestringFormat(); if (s2 === peg$FAILED) { s2 = peg$parsesmartVariable(); if (s2 === peg$FAILED) { s2 = peg$parselogicFormat(); } } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c104(s1); } s0 = s1; return s0; } function peg$parsestringFormat() { var s0, s1; s0 = peg$currPos; s1 = peg$parsestring(); if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c105(s1); } s0 = s1; return s0; } function peg$parseas() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; s1 = peg$parsepath(); if (s1 !== peg$FAILED) { s2 = peg$parse_(); if (s2 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c106) { s3 = peg$c106; peg$currPos += 2; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c107); } } if (s3 !== peg$FAILED) { s4 = peg$parse_(); if (s4 !== peg$FAILED) { s5 = peg$parsereferencePath(); if (s5 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c108(s1, s5); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parseasOther() { var s0, s1, s2, s3, s4; s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 44) { s2 = peg$c109; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c110); } } if (s2 !== peg$FAILED) { s3 = peg$parse_(); if (s3 !== peg$FAILED) { s4 = peg$parseas(); if (s4 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c111(s4); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parseasForm() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parseas(); if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parseasOther(); while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parseasOther(); } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c112(s1, s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsevalue() { var s0; s0 = peg$parseeascapedString(); if (s0 === peg$FAILED) { s0 = peg$parsevisibleString(); } return s0; } function peg$parsemeta() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; s1 = peg$parsekey(); if (s1 !== peg$FAILED) { s2 = peg$parse_(); if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { s3 = peg$c99; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c100); } } if (s3 !== peg$FAILED) { s4 = peg$parse_(); if (s4 !== peg$FAILED) { s5 = peg$parsearg(); if (s5 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c113(s1, s5); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsemetaOther() { var s0, s1, s2; s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { s2 = peg$parsemeta(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c114(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsemetadata() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parsemeta(); if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parsemetaOther(); while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parsemetaOther(); } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c115(s1, s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parseargExtOther() { var s0, s1, s2, s3, s4; s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 44) { s2 = peg$c109; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c110); } } if (s2 === peg$FAILED) { s2 = null; } if (s2 !== peg$FAILED) { s3 = peg$parse_(); if (s3 !== peg$FAILED) { s4 = peg$parseargExt(); if (s4 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c116(s4); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parseargsExt() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parseargExt(); if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parseargExtOther(); while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parseargExtOther(); } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c117(s1, s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parseargsMetadata() { var s0, s1, s2, s3, s4, s5, s6; s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 44) { s2 = peg$c109; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c110); } } if (s2 !== peg$FAILED) { s3 = peg$parse_(); if (s3 !== peg$FAILED) { s4 = peg$parsemetadata(); if (s4 === peg$FAILED) { s4 = null; } if (s4 !== peg$FAILED)