UNPKG

ng-tql

Version:

A domain specific language that extends SQL and allows visual metaprogramming

1,688 lines (1,576 loc) 59.1 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 = { TQLCode: peg$parseTQLCode }, peg$startRuleFunction = peg$parseTQLCode, peg$c0 = peg$otherExpectation("TQL code"), peg$c1 = function(fields) { var declarations = fields.map(typeChecker); checkDuplication(declarations); return declarations; }, peg$c2 = peg$otherExpectation("field declaration"), peg$c3 = "declare", peg$c4 = peg$literalExpectation("declare", true), peg$c5 = function(name, type, picture, value, description) { return { kind: 'FieldDecl', name: name, type: type, picture: picture, value: value, description: description } }, peg$c6 = peg$otherExpectation("identifier"), peg$c7 = /^[_a-z]/i, peg$c8 = peg$classExpectation(["_", ["a", "z"]], false, true), peg$c9 = /^[_a-z0-9]/i, peg$c10 = peg$classExpectation(["_", ["a", "z"], ["0", "9"]], false, true), peg$c11 = function(x, xs) { return [x].concat(xs).join(''); }, peg$c12 = peg$otherExpectation("assignment"), peg$c13 = ":=", peg$c14 = peg$literalExpectation(":=", false), peg$c15 = function(v) { return v; }, peg$c16 = peg$otherExpectation("type declaration"), peg$c17 = ":", peg$c18 = peg$literalExpectation(":", false), peg$c19 = function(type) { return type; }, peg$c20 = peg$otherExpectation("type"), peg$c21 = "int", peg$c22 = peg$literalExpectation("int", true), peg$c23 = function() { return ['int']; }, peg$c24 = "double", peg$c25 = peg$literalExpectation("double", true), peg$c26 = function() { return ['double']; }, peg$c27 = "varchar", peg$c28 = peg$literalExpectation("varchar", true), peg$c29 = function() { return ['varchar']; }, peg$c30 = "date", peg$c31 = peg$literalExpectation("date", true), peg$c32 = function() { return ['date']; }, peg$c33 = "nat", peg$c34 = peg$literalExpectation("nat", true), peg$c35 = function() { return ['nat']; }, peg$c36 = "bool", peg$c37 = peg$literalExpectation("bool", true), peg$c38 = function() { return ['bool']; }, peg$c39 = "symbol", peg$c40 = peg$literalExpectation("symbol", true), peg$c41 = function() { return ['symbol']; }, peg$c42 = "char", peg$c43 = peg$literalExpectation("char", true), peg$c44 = "(", peg$c45 = peg$literalExpectation("(", false), peg$c46 = ")", peg$c47 = peg$literalExpectation(")", false), peg$c48 = function(n) { return ['char', { size: n }] }, peg$c49 = "range", peg$c50 = peg$literalExpectation("range", true), peg$c51 = ",", peg$c52 = peg$literalExpectation(",", false), peg$c53 = function(from, to) { return ['range', { from: from, to: to }]; }, peg$c54 = peg$otherExpectation("picture"), peg$c55 = "picture", peg$c56 = peg$literalExpectation("picture", true), peg$c57 = function(s) { return s; }, peg$c58 = peg$otherExpectation("value"), peg$c59 = function(d) { return { type: 'date', value: d }; }, peg$c60 = function(n) { return { type: 'number', value: n }; }, peg$c61 = function(i) { return { type: 'symbol', value: i }; }, peg$c62 = function(s) { return { type: 'string', value: s }; }, peg$c63 = function(b) { return { type: 'bool', value: b }; }, peg$c64 = peg$otherExpectation("number"), peg$c65 = peg$otherExpectation("integer"), peg$c66 = /^[+\-]/, peg$c67 = peg$classExpectation(["+", "-"], false, false), peg$c68 = /^[0-9]/, peg$c69 = peg$classExpectation([["0", "9"]], false, false), peg$c70 = function(sig, xss) { return parseInt((sig || '') + xss.join(''), 10); }, peg$c71 = peg$otherExpectation("double"), peg$c72 = ".", peg$c73 = peg$literalExpectation(".", false), peg$c74 = function(base, rest) { return parseFloat(base.toString() + '.' + rest.join('')); }, peg$c75 = peg$otherExpectation("string"), peg$c76 = "'", peg$c77 = peg$literalExpectation("'", false), peg$c78 = peg$anyExpectation(), peg$c79 = function(w) { return w; }, peg$c80 = function(chr) { return chr.join(''); }, peg$c81 = peg$otherExpectation("bool"), peg$c82 = ".t.", peg$c83 = peg$literalExpectation(".t.", true), peg$c84 = function() { return true; }, peg$c85 = ".f.", peg$c86 = peg$literalExpectation(".f.", true), peg$c87 = function() { return false; }, peg$c88 = peg$otherExpectation("date"), peg$c89 = function(day, month, year, time) { // Ensure valid day and month if (day < 0) { throw new Error('Day of date must be positive'); } if (year < 0) { throw new Error('Year of date must be positive'); } return null !== time ? new Date(year, monthToJS(month), day, time.hour, time.minute, time.seconds) : new Date(year, monthToJS(month), day); }, peg$c90 = peg$otherExpectation("time"), peg$c91 = function(hour, minute, s) { return s; }, peg$c92 = function(hour, minute, seconds) { if (hour < 0 || hour > 23) { throw new Error('Hour of time must be between 0 and 23'); } if (minute < 0 || minute > 59) { throw new Error('Minute of time must be between 0 and 59') } if (seconds < 0 || seconds > 59) { throw new Error('Seconds of time must be between 0 and 59'); } return { hour: hour, minute: minute, seconds: seconds || 0 }; }, peg$c93 = peg$otherExpectation("month"), peg$c94 = "jan", peg$c95 = peg$literalExpectation("jan", true), peg$c96 = "feb", peg$c97 = peg$literalExpectation("feb", true), peg$c98 = "mar", peg$c99 = peg$literalExpectation("mar", true), peg$c100 = "apr", peg$c101 = peg$literalExpectation("apr", true), peg$c102 = "may", peg$c103 = peg$literalExpectation("may", true), peg$c104 = "jun", peg$c105 = peg$literalExpectation("jun", true), peg$c106 = "jul", peg$c107 = peg$literalExpectation("jul", true), peg$c108 = "ago", peg$c109 = peg$literalExpectation("ago", true), peg$c110 = "sep", peg$c111 = peg$literalExpectation("sep", true), peg$c112 = "oct", peg$c113 = peg$literalExpectation("oct", true), peg$c114 = "nov", peg$c115 = peg$literalExpectation("nov", true), peg$c116 = "dec", peg$c117 = peg$literalExpectation("dec", true), peg$c118 = peg$otherExpectation("description"), peg$c119 = "{", peg$c120 = peg$literalExpectation("{", false), peg$c121 = "}", peg$c122 = peg$literalExpectation("}", false), peg$c123 = function(c) { return c; }, peg$c124 = function(chr) { return chr.join('').trim(); }, peg$c125 = peg$otherExpectation("optional whitespace"), peg$c126 = /^[ \t\r\n]/, peg$c127 = peg$classExpectation([" ", "\t", "\r", "\n"], false, false), peg$c128 = peg$otherExpectation("obligatory whitespace"), 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$parseTQLCode() { var s0, s1, s2; peg$silentFails++; s0 = peg$currPos; s1 = []; s2 = peg$parseFieldDecl(); while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parseFieldDecl(); } if (s1 !== peg$FAILED) { s2 = peg$parse_(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c1(s1); 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$c0); } } return s0; } function peg$parseFieldDecl() { var s0, s1, s2, s3, s4, s5, s6, s7, s8; peg$silentFails++; s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { if (input.substr(peg$currPos, 7).toLowerCase() === peg$c3) { s2 = input.substr(peg$currPos, 7); peg$currPos += 7; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c4); } } if (s2 !== peg$FAILED) { s3 = peg$parse__(); if (s3 !== peg$FAILED) { s4 = peg$parseIdent(); if (s4 !== peg$FAILED) { s5 = peg$parseTypeDecl(); if (s5 === peg$FAILED) { s5 = null; } if (s5 !== peg$FAILED) { s6 = peg$parsePicture(); if (s6 === peg$FAILED) { s6 = null; } if (s6 !== peg$FAILED) { s7 = peg$parseAssignment(); if (s7 === peg$FAILED) { s7 = null; } if (s7 !== peg$FAILED) { s8 = peg$parseDescription(); if (s8 === peg$FAILED) { s8 = null; } if (s8 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c5(s4, s5, s6, s7, s8); 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; } } 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$c2); } } return s0; } function peg$parseIdent() { var s0, s1, s2, s3; peg$silentFails++; s0 = peg$currPos; if (peg$c7.test(input.charAt(peg$currPos))) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c8); } } if (s1 !== peg$FAILED) { s2 = []; if (peg$c9.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c10); } } while (s3 !== peg$FAILED) { s2.push(s3); if (peg$c9.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c10); } } } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c11(s1, 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$c6); } } return s0; } function peg$parseAssignment() { var s0, s1, s2, s3, s4; peg$silentFails++; s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c13) { s2 = peg$c13; peg$currPos += 2; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c14); } } if (s2 !== peg$FAILED) { s3 = peg$parse_(); if (s3 !== peg$FAILED) { s4 = peg$parseValue(); if (s4 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c15(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; } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c12); } } return s0; } function peg$parseTypeDecl() { var s0, s1, s2, s3, s4; peg$silentFails++; s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { s2 = peg$c17; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c18); } } if (s2 !== peg$FAILED) { s3 = peg$parse_(); if (s3 !== peg$FAILED) { s4 = peg$parseType(); if (s4 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c19(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; } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c16); } } return s0; } function peg$parseType() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; peg$silentFails++; s0 = peg$currPos; if (input.substr(peg$currPos, 3).toLowerCase() === peg$c21) { s1 = input.substr(peg$currPos, 3); peg$currPos += 3; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c22); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c23(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.substr(peg$currPos, 6).toLowerCase() === peg$c24) { s1 = input.substr(peg$currPos, 6); peg$currPos += 6; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c25); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c26(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.substr(peg$currPos, 7).toLowerCase() === peg$c27) { s1 = input.substr(peg$currPos, 7); peg$currPos += 7; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c28); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c29(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.substr(peg$currPos, 4).toLowerCase() === peg$c30) { s1 = input.substr(peg$currPos, 4); peg$currPos += 4; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c31); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c32(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.substr(peg$currPos, 3).toLowerCase() === peg$c33) { s1 = input.substr(peg$currPos, 3); peg$currPos += 3; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c34); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c35(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.substr(peg$currPos, 4).toLowerCase() === peg$c36) { s1 = input.substr(peg$currPos, 4); peg$currPos += 4; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c37); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c38(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.substr(peg$currPos, 6).toLowerCase() === peg$c39) { s1 = input.substr(peg$currPos, 6); peg$currPos += 6; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c40); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c41(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.substr(peg$currPos, 4).toLowerCase() === peg$c42) { s1 = input.substr(peg$currPos, 4); peg$currPos += 4; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c43); } } if (s1 !== peg$FAILED) { s2 = peg$parse_(); if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 40) { s3 = peg$c44; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c45); } } if (s3 !== peg$FAILED) { s4 = peg$parse_(); if (s4 !== peg$FAILED) { s5 = peg$parseInt(); if (s5 !== peg$FAILED) { s6 = peg$parse_(); if (s6 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { s7 = peg$c46; peg$currPos++; } else { s7 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c47); } } if (s7 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c48(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; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.substr(peg$currPos, 5).toLowerCase() === peg$c49) { s1 = input.substr(peg$currPos, 5); peg$currPos += 5; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c50); } } if (s1 !== peg$FAILED) { s2 = peg$parse_(); if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 40) { s3 = peg$c44; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c45); } } if (s3 !== peg$FAILED) { s4 = peg$parse_(); if (s4 !== peg$FAILED) { s5 = peg$parseInt(); if (s5 !== peg$FAILED) { s6 = peg$parse_(); if (s6 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 44) { s7 = peg$c51; peg$currPos++; } else { s7 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c52); } } if (s7 !== peg$FAILED) { s8 = peg$parse_(); if (s8 !== peg$FAILED) { s9 = peg$parseInt(); if (s9 !== peg$FAILED) { s10 = peg$parse_(); if (s10 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { s11 = peg$c46; peg$currPos++; } else { s11 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c47); } } if (s11 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c53(s5, s9); 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; } } 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; } } else { peg$currPos = s0; s0 = peg$FAILED; } } } } } } } } } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c20); } } return s0; } function peg$parsePicture() { var s0, s1, s2, s3, s4; peg$silentFails++; s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { if (input.substr(peg$currPos, 7).toLowerCase() === peg$c55) { s2 = input.substr(peg$currPos, 7); peg$currPos += 7; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c56); } } if (s2 !== peg$FAILED) { s3 = peg$parse__(); if (s3 !== peg$FAILED) { s4 = peg$parseString(); if (s4 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c57(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; } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c54); } } return s0; } function peg$parseValue() { var s0, s1; peg$silentFails++; s0 = peg$currPos; s1 = peg$parseDate(); if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c59(s1); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parseNumber(); if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c60(s1); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parseIdent(); if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c61(s1); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parseString(); if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c62(s1); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parseBool(); if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c63(s1); } s0 = s1; } } } } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c58); } } return s0; } function peg$parseNumber() { var s0, s1; peg$silentFails++; s0 = peg$parseDouble(); if (s0 === peg$FAILED) { s0 = peg$parseInt(); } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c64); } } return s0; } function peg$parseInt() { var s0, s1, s2, s3; peg$silentFails++; s0 = peg$currPos; if (peg$c66.test(input.charAt(peg$currPos))) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c67); } } if (s1 === peg$FAILED) { s1 = null; } if (s1 !== peg$FAILED) { s2 = []; if (peg$c68.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c69); } } if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); if (peg$c68.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c69); } } } } else { s2 = peg$FAILED; } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c70(s1, 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$c65); } } return s0; } function peg$parseDouble() { var s0, s1, s2, s3, s4; peg$silentFails++; s0 = peg$currPos; s1 = peg$parseInt(); if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 46) { s2 = peg$c72; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c73); } } if (s2 !== peg$FAILED) { s3 = []; if (peg$c68.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c69); } } if (s4 !== peg$FAILED) { while (s4 !== peg$FAILED) { s3.push(s4); if (peg$c68.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c69); } } } } else { s3 = peg$FAILED; } if (s3 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c74(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; } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c71); } } return s0; } function peg$parseString() { var s0, s1, s2, s3, s4, s5; peg$silentFails++; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 39) { s1 = peg$c76; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c77); } } if (s1 !== peg$FAILED) { s2 = []; s3 = peg$currPos; s4 = peg$currPos; peg$silentFails++; if (input.charCodeAt(peg$currPos) === 39) { s5 = peg$c76; peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c77); } } peg$silentFails--; if (s5 === peg$FAILED) { s4 = void 0; } else { peg$currPos = s4; s4 = peg$FAILED; } if (s4 !== peg$FAILED) { if (input.length > peg$currPos) { s5 = input.charAt(peg$currPos); peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c78); } } if (s5 !== peg$FAILED) { peg$savedPos = s3; s4 = peg$c79(s5); s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$currPos; s4 = peg$currPos; peg$silentFails++; if (input.charCodeAt(peg$currPos) === 39) { s5 = peg$c76; peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c77); } } peg$silentFails--; if (s5 === peg$FAILED) { s4 = void 0; } else { peg$currPos = s4; s4 = peg$FAILED; } if (s4 !== peg$FAILED) { if (input.length > peg$currPos) { s5 = input.charAt(peg$currPos); peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c78); } } if (s5 !== peg$FAILED) { peg$savedPos = s3; s4 = peg$c79(s5); s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 39) { s3 = peg$c76; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c77); } } if (s3 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c80(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$c75); } } return s0; } function peg$parseBool() { var s0, s1; peg$silentFails++; s0 = peg$currPos; if (input.substr(peg$currPos, 3).toLowerCase() === peg$c82) { s1 = input.substr(peg$currPos, 3); peg$currPos += 3; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c83); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c84(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.substr(peg$currPos, 3).toLowerCase() === peg$c85) { s1 = input.substr(peg$currPos, 3); peg$currPos += 3; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c86); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c87(); } s0 = s1; } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c81); } } return s0; } function peg$parseDate() { var s0, s1, s2, s3, s4, s5, s6; peg$silentFails++; s0 = peg$currPos; s1 = peg$parseInt(); if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { s3 = peg$parseMonth(); if (s3 !== peg$FAILED) { s4 = peg$parse__(); if (s4 !== peg$FAILED) { s5 = peg$parseInt(); if (s5 !== peg$FAILED) { s6 = peg$parseTime(); if (s6 === peg$FAILED) { s6 = null; } if (s6 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c89(s1, s3, s5, s6); 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; } } else { peg$currPos = s0; s0 = peg$FAILED; } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c88); } } return s0; } function peg$parseTime() { var s0, s1, s2, s3, s4, s5, s6, s7; peg$silentFails++; s0 = peg$currPos; s1 = peg$parse__(); if (s1 !== peg$FAILED) { s2 = peg$parseInt(); if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { s3 = peg$c17; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c18); } } if (s3 !== peg$FAILED) { s4 = peg$parseInt(); if (s4 !== peg$FAILED) { s5 = peg$currPos; if (input.charCodeAt(peg$currPos) === 58) { s6 = peg$c17; peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c18); } } if (s6 !== peg$FAILED) { s7 = peg$parseInt(); if (s7 !== peg$FAILED) { peg$savedPos = s5; s6 = peg$c91(s2, s4, s7); s5 = s6; } else { peg$currPos = s5; s5 = peg$FAILED; } } else { peg$currPos = s5; s5 = peg$FAILED; } if (s5 === peg$FAILED) { s5 = null; } if (s5 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c92(s2, s4, 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; } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c90); } } return s0; } function peg$parseMonth() { var s0, s1; peg$silentFails++; if (input.substr(peg$currPos, 3).toLowerCase() === peg$c94) { s0 = input.substr(peg$currPos, 3); peg$currPos += 3; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c95); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 3).toLowerCase() === peg$c96) { s0 = input.substr(peg$currPos, 3); peg$currPos += 3; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c97); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 3).toLowerCase() === peg$c98) { s0 = input.substr(peg$currPos, 3); peg$currPos += 3; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c99); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 3).toLowerCase() === peg$c100) { s0 = input.substr(peg$currPos, 3); peg$currPos += 3; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c101); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 3).toLowerCase() === peg$c102) { s0 = input.substr(peg$currPos, 3); peg$currPos += 3; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c103); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 3).toLowerCase() === peg$c104) { s0 = input.substr(peg$currPos, 3); peg$currPos += 3; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c105); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 3).toLowerCase() === peg$c106) { s0 = input.substr(peg$currPos, 3); peg$currPos += 3; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c107); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 3).toLowerCase() === peg$c108) { s0 = input.substr(peg$currPos, 3); peg$currPos += 3; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c109); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 3).toLowerCase() === peg$c110) { s0 = input.substr(peg$currPos, 3); peg$currPos += 3; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c111); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 3).toLowerCase() === peg$c112) { s0 = input.substr(peg$currPos, 3); peg$currPos += 3; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c113); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 3).toLowerCase() === peg$c114) { s0 = input.substr(peg$currPos, 3); peg$currPos += 3; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c115); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 3).toLowerCase() === peg$c116) { s0 = input.substr(peg$currPos, 3); peg$currPos += 3; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c117); } } } } } } } } } } } } } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c93); } } return s0; } function peg$parseDescription() { var s0, s1, s2, s3, s4, s5, s6; peg$silentFails++; s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 123) { s2 = peg$c119; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c120); } } if (s2 !== peg$FAILED) { s3 = []; s4 = peg$currPos; s5 = peg$currPos; peg$silentFails++; if (input.charCodeAt(peg$currPos) === 125) { s6 = peg$c121; peg$currPos++; } else