Skip to content

Instantly share code, notes, and snippets.

@flaviocysne
Last active April 29, 2016 19:43
Show Gist options
  • Save flaviocysne/eb2b8197d00dc1adbaa8ceeb481dfa30 to your computer and use it in GitHub Desktop.
Save flaviocysne/eb2b8197d00dc1adbaa8ceeb481dfa30 to your computer and use it in GitHub Desktop.
Angular-UI - UI Bootstrap - Dateparser - PEGjs Parser & Expression for uibDateParser's format codes
var uibDateParser_parser = (function() {
"use strict";
/*
* Generated by PEG.js 0.9.0.
*
* http://pegjs.org/
*/
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);
function peg$parse(input) {
var options = arguments.length > 1 ? arguments[1] : {},
parser = this,
peg$FAILED = {},
peg$startRuleFunctions = { Expression: peg$parseExpression },
peg$startRuleFunction = peg$parseExpression,
peg$c0 = "yyyy",
peg$c1 = { type: "literal", value: "yyyy", description: "\"yyyy\"" },
peg$c2 = "yy",
peg$c3 = { type: "literal", value: "yy", description: "\"yy\"" },
peg$c4 = "y",
peg$c5 = { type: "literal", value: "y", description: "\"y\"" },
peg$c6 = "MMMM",
peg$c7 = { type: "literal", value: "MMMM", description: "\"MMMM\"" },
peg$c8 = "MMM",
peg$c9 = { type: "literal", value: "MMM", description: "\"MMM\"" },
peg$c10 = "MM",
peg$c11 = { type: "literal", value: "MM", description: "\"MM\"" },
peg$c12 = "M!",
peg$c13 = { type: "literal", value: "M!", description: "\"M!\"" },
peg$c14 = "M",
peg$c15 = { type: "literal", value: "M", description: "\"M\"" },
peg$c16 = "EEEE",
peg$c17 = { type: "literal", value: "EEEE", description: "\"EEEE\"" },
peg$c18 = "EEE",
peg$c19 = { type: "literal", value: "EEE", description: "\"EEE\"" },
peg$c20 = "ww",
peg$c21 = { type: "literal", value: "ww", description: "\"ww\"" },
peg$c22 = "w",
peg$c23 = { type: "literal", value: "w", description: "\"w\"" },
peg$c24 = "dd",
peg$c25 = { type: "literal", value: "dd", description: "\"dd\"" },
peg$c26 = "d!",
peg$c27 = { type: "literal", value: "d!", description: "\"d!\"" },
peg$c28 = "d",
peg$c29 = { type: "literal", value: "d", description: "\"d\"" },
peg$c30 = "HH",
peg$c31 = { type: "literal", value: "HH", description: "\"HH\"" },
peg$c32 = "H",
peg$c33 = { type: "literal", value: "H", description: "\"H\"" },
peg$c34 = "hh",
peg$c35 = { type: "literal", value: "hh", description: "\"hh\"" },
peg$c36 = "h",
peg$c37 = { type: "literal", value: "h", description: "\"h\"" },
peg$c38 = "mm",
peg$c39 = { type: "literal", value: "mm", description: "\"mm\"" },
peg$c40 = "m",
peg$c41 = { type: "literal", value: "m", description: "\"m\"" },
peg$c42 = "sss",
peg$c43 = { type: "literal", value: "sss", description: "\"sss\"" },
peg$c44 = "ss",
peg$c45 = { type: "literal", value: "ss", description: "\"ss\"" },
peg$c46 = "s",
peg$c47 = { type: "literal", value: "s", description: "\"s\"" },
peg$c48 = "a",
peg$c49 = { type: "literal", value: "a", description: "\"a\"" },
peg$c50 = "ZZ",
peg$c51 = { type: "literal", value: "ZZ", description: "\"ZZ\"" },
peg$c52 = "Z",
peg$c53 = { type: "literal", value: "Z", description: "\"Z\"" },
peg$c54 = "GGGG",
peg$c55 = { type: "literal", value: "GGGG", description: "\"GGGG\"" },
peg$c56 = "GGG",
peg$c57 = { type: "literal", value: "GGG", description: "\"GGG\"" },
peg$c58 = "GG",
peg$c59 = { type: "literal", value: "GG", description: "\"GG\"" },
peg$c60 = "G",
peg$c61 = { type: "literal", value: "G", description: "\"G\"" },
peg$c62 = "fullDate",
peg$c63 = { type: "literal", value: "fullDate", description: "\"fullDate\"" },
peg$c64 = "longDate",
peg$c65 = { type: "literal", value: "longDate", description: "\"longDate\"" },
peg$c66 = "medium",
peg$c67 = { type: "literal", value: "medium", description: "\"medium\"" },
peg$c68 = "mediumDate",
peg$c69 = { type: "literal", value: "mediumDate", description: "\"mediumDate\"" },
peg$c70 = "mediumTime",
peg$c71 = { type: "literal", value: "mediumTime", description: "\"mediumTime\"" },
peg$c72 = "short",
peg$c73 = { type: "literal", value: "short", description: "\"short\"" },
peg$c74 = "shortDate",
peg$c75 = { type: "literal", value: "shortDate", description: "\"shortDate\"" },
peg$c76 = "shortTime",
peg$c77 = { type: "literal", value: "shortTime", description: "\"shortTime\"" },
peg$c78 = "'",
peg$c79 = { type: "literal", value: "'", description: "\"'\"" },
peg$c80 = /^[^']/,
peg$c81 = { type: "class", value: "[^']", description: "[^']" },
peg$c82 = function(expr) { return text(); },
peg$c83 = "\"",
peg$c84 = { type: "literal", value: "\"", description: "\"\\\"\"" },
peg$c85 = /^[^"]/,
peg$c86 = { type: "class", value: "[^\"]", description: "[^\"]" },
peg$c87 = /^[ \t\r\n]/,
peg$c88 = { type: "class", value: "[ \\t\\r\\n]", description: "[ \\t\\r\\n]" },
peg$c89 = function() { return text(); },
peg$currPos = 0,
peg$savedPos = 0,
peg$posDetailsCache = [{ 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$savedPos, peg$currPos);
}
function location() {
return peg$computeLocation(peg$savedPos, peg$currPos);
}
function expected(description) {
throw peg$buildException(
null,
[{ type: "other", description: description }],
input.substring(peg$savedPos, peg$currPos),
peg$computeLocation(peg$savedPos, peg$currPos)
);
}
function error(message) {
throw peg$buildException(
message,
null,
input.substring(peg$savedPos, peg$currPos),
peg$computeLocation(peg$savedPos, peg$currPos)
);
}
function peg$computePosDetails(pos) {
var details = peg$posDetailsCache[pos],
p, ch;
if (details) {
return details;
} else {
p = pos - 1;
while (!peg$posDetailsCache[p]) {
p--;
}
details = peg$posDetailsCache[p];
details = {
line: details.line,
column: details.column,
seenCR: details.seenCR
};
while (p < pos) {
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;
}
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$buildException(message, expected, found, location) {
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(/[\u0100-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); })
.replace(/[\u1000-\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.";
}
if (expected !== null) {
cleanupExpected(expected);
}
return new peg$SyntaxError(
message !== null ? message : buildMessage(expected, found),
expected,
found,
location
);
}
function peg$parseExpression() {
var s0, s1, s2, s3, s4;
s0 = [];
s1 = peg$currPos;
s2 = peg$parseWhitespace();
if (s2 === peg$FAILED) {
s2 = null;
}
if (s2 !== peg$FAILED) {
s3 = peg$parseTerm();
if (s3 !== peg$FAILED) {
s4 = peg$parseWhitespace();
if (s4 === peg$FAILED) {
s4 = null;
}
if (s4 !== peg$FAILED) {
s2 = [s2, s3, s4];
s1 = s2;
} else {
peg$currPos = s1;
s1 = peg$FAILED;
}
} else {
peg$currPos = s1;
s1 = peg$FAILED;
}
} else {
peg$currPos = s1;
s1 = peg$FAILED;
}
while (s1 !== peg$FAILED) {
s0.push(s1);
s1 = peg$currPos;
s2 = peg$parseWhitespace();
if (s2 === peg$FAILED) {
s2 = null;
}
if (s2 !== peg$FAILED) {
s3 = peg$parseTerm();
if (s3 !== peg$FAILED) {
s4 = peg$parseWhitespace();
if (s4 === peg$FAILED) {
s4 = null;
}
if (s4 !== peg$FAILED) {
s2 = [s2, s3, s4];
s1 = s2;
} else {
peg$currPos = s1;
s1 = peg$FAILED;
}
} else {
peg$currPos = s1;
s1 = peg$FAILED;
}
} else {
peg$currPos = s1;
s1 = peg$FAILED;
}
}
return s0;
}
function peg$parseTerm() {
var s0;
s0 = peg$parseLiteral();
if (s0 === peg$FAILED) {
s0 = peg$parseYearFull();
if (s0 === peg$FAILED) {
s0 = peg$parseYearShort();
if (s0 === peg$FAILED) {
s0 = peg$parseYearAny();
if (s0 === peg$FAILED) {
s0 = peg$parseMonthFullName();
if (s0 === peg$FAILED) {
s0 = peg$parseMonthShortName();
if (s0 === peg$FAILED) {
s0 = peg$parseMonthZeroPad();
if (s0 === peg$FAILED) {
s0 = peg$parseMonthOptionalPad();
if (s0 === peg$FAILED) {
s0 = peg$parseMonth();
if (s0 === peg$FAILED) {
s0 = peg$parseWeekFullName();
if (s0 === peg$FAILED) {
s0 = peg$parseWeekShortName();
if (s0 === peg$FAILED) {
s0 = peg$parseWeekNumberZeroPad();
if (s0 === peg$FAILED) {
s0 = peg$parseWeekNumber();
if (s0 === peg$FAILED) {
s0 = peg$parseDayOfMonthZeroPad();
if (s0 === peg$FAILED) {
s0 = peg$parseDayOfMonthOptionalPad();
if (s0 === peg$FAILED) {
s0 = peg$parseDayOfMonth();
if (s0 === peg$FAILED) {
s0 = peg$parseMillisecond();
if (s0 === peg$FAILED) {
s0 = peg$parseSecondZeroPad();
if (s0 === peg$FAILED) {
s0 = peg$parseSecond();
if (s0 === peg$FAILED) {
s0 = peg$parseAmPm();
if (s0 === peg$FAILED) {
s0 = peg$parseTimezoneWithColon();
if (s0 === peg$FAILED) {
s0 = peg$parseTimezone();
if (s0 === peg$FAILED) {
s0 = peg$parseEraFullName();
if (s0 === peg$FAILED) {
s0 = peg$parseEraShortName();
if (s0 === peg$FAILED) {
s0 = peg$parseFormatName();
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return s0;
}
function peg$parseYearFull() {
var s0;
if (input.substr(peg$currPos, 4) === peg$c0) {
s0 = peg$c0;
peg$currPos += 4;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c1); }
}
return s0;
}
function peg$parseYearShort() {
var s0;
if (input.substr(peg$currPos, 2) === peg$c2) {
s0 = peg$c2;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c3); }
}
return s0;
}
function peg$parseYearAny() {
var s0;
if (input.charCodeAt(peg$currPos) === 121) {
s0 = peg$c4;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c5); }
}
return s0;
}
function peg$parseMonthFullName() {
var s0;
if (input.substr(peg$currPos, 4) === peg$c6) {
s0 = peg$c6;
peg$currPos += 4;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c7); }
}
return s0;
}
function peg$parseMonthShortName() {
var s0;
if (input.substr(peg$currPos, 3) === peg$c8) {
s0 = peg$c8;
peg$currPos += 3;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c9); }
}
return s0;
}
function peg$parseMonthZeroPad() {
var s0;
if (input.substr(peg$currPos, 2) === peg$c10) {
s0 = peg$c10;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c11); }
}
return s0;
}
function peg$parseMonthOptionalPad() {
var s0;
if (input.substr(peg$currPos, 2) === peg$c12) {
s0 = peg$c12;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c13); }
}
return s0;
}
function peg$parseMonth() {
var s0;
if (input.charCodeAt(peg$currPos) === 77) {
s0 = peg$c14;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c15); }
}
return s0;
}
function peg$parseWeekFullName() {
var s0;
if (input.substr(peg$currPos, 4) === peg$c16) {
s0 = peg$c16;
peg$currPos += 4;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c17); }
}
return s0;
}
function peg$parseWeekShortName() {
var s0;
if (input.substr(peg$currPos, 3) === peg$c18) {
s0 = peg$c18;
peg$currPos += 3;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c19); }
}
return s0;
}
function peg$parseWeekNumberZeroPad() {
var s0;
if (input.substr(peg$currPos, 2) === peg$c20) {
s0 = peg$c20;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c21); }
}
return s0;
}
function peg$parseWeekNumber() {
var s0;
if (input.charCodeAt(peg$currPos) === 119) {
s0 = peg$c22;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c23); }
}
return s0;
}
function peg$parseDayOfMonthZeroPad() {
var s0;
if (input.substr(peg$currPos, 2) === peg$c24) {
s0 = peg$c24;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c25); }
}
return s0;
}
function peg$parseDayOfMonthOptionalPad() {
var s0;
if (input.substr(peg$currPos, 2) === peg$c26) {
s0 = peg$c26;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c27); }
}
return s0;
}
function peg$parseDayOfMonth() {
var s0;
if (input.charCodeAt(peg$currPos) === 100) {
s0 = peg$c28;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c29); }
}
return s0;
}
function peg$parseHour24ZeroPad() {
var s0;
if (input.substr(peg$currPos, 2) === peg$c30) {
s0 = peg$c30;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c31); }
}
return s0;
}
function peg$parseHour24() {
var s0;
if (input.charCodeAt(peg$currPos) === 72) {
s0 = peg$c32;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c33); }
}
return s0;
}
function peg$parseHour12ZeroPad() {
var s0;
if (input.substr(peg$currPos, 2) === peg$c34) {
s0 = peg$c34;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c35); }
}
return s0;
}
function peg$parseHour12() {
var s0;
if (input.charCodeAt(peg$currPos) === 104) {
s0 = peg$c36;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c37); }
}
return s0;
}
function peg$parseMinuteZeroPad() {
var s0;
if (input.substr(peg$currPos, 2) === peg$c38) {
s0 = peg$c38;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c39); }
}
return s0;
}
function peg$parseMinute() {
var s0;
if (input.charCodeAt(peg$currPos) === 109) {
s0 = peg$c40;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c41); }
}
return s0;
}
function peg$parseMillisecond() {
var s0;
if (input.substr(peg$currPos, 3) === peg$c42) {
s0 = peg$c42;
peg$currPos += 3;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c43); }
}
return s0;
}
function peg$parseSecondZeroPad() {
var s0;
if (input.substr(peg$currPos, 2) === peg$c44) {
s0 = peg$c44;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c45); }
}
return s0;
}
function peg$parseSecond() {
var s0;
if (input.charCodeAt(peg$currPos) === 115) {
s0 = peg$c46;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c47); }
}
return s0;
}
function peg$parseAmPm() {
var s0;
if (input.charCodeAt(peg$currPos) === 97) {
s0 = peg$c48;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c49); }
}
return s0;
}
function peg$parseTimezoneWithColon() {
var s0;
if (input.substr(peg$currPos, 2) === peg$c50) {
s0 = peg$c50;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c51); }
}
return s0;
}
function peg$parseTimezone() {
var s0;
if (input.charCodeAt(peg$currPos) === 90) {
s0 = peg$c52;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c53); }
}
return s0;
}
function peg$parseEraFullName() {
var s0;
if (input.substr(peg$currPos, 4) === peg$c54) {
s0 = peg$c54;
peg$currPos += 4;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c55); }
}
return s0;
}
function peg$parseEraShortName() {
var s0;
if (input.substr(peg$currPos, 3) === peg$c56) {
s0 = peg$c56;
peg$currPos += 3;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c57); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c58) {
s0 = peg$c58;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c59); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 71) {
s0 = peg$c60;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c61); }
}
}
}
return s0;
}
function peg$parseFormatName() {
var s0;
if (input.substr(peg$currPos, 8) === peg$c62) {
s0 = peg$c62;
peg$currPos += 8;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c63); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 8) === peg$c64) {
s0 = peg$c64;
peg$currPos += 8;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c65); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 6) === peg$c66) {
s0 = peg$c66;
peg$currPos += 6;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c67); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 10) === peg$c68) {
s0 = peg$c68;
peg$currPos += 10;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c69); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 10) === peg$c70) {
s0 = peg$c70;
peg$currPos += 10;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c71); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 5) === peg$c72) {
s0 = peg$c72;
peg$currPos += 5;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c73); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 9) === peg$c74) {
s0 = peg$c74;
peg$currPos += 9;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c75); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 9) === peg$c76) {
s0 = peg$c76;
peg$currPos += 9;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c77); }
}
}
}
}
}
}
}
}
return s0;
}
function peg$parseLiteral() {
var s0, s1, s2, s3;
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 39) {
s1 = peg$c78;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c79); }
}
if (s1 !== peg$FAILED) {
s2 = [];
if (peg$c80.test(input.charAt(peg$currPos))) {
s3 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c81); }
}
while (s3 !== peg$FAILED) {
s2.push(s3);
if (peg$c80.test(input.charAt(peg$currPos))) {
s3 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c81); }
}
}
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 39) {
s3 = peg$c78;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c79); }
}
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c82(s2);
s0 = s1;
} 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.charCodeAt(peg$currPos) === 34) {
s1 = peg$c83;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c84); }
}
if (s1 !== peg$FAILED) {
s2 = [];
if (peg$c85.test(input.charAt(peg$currPos))) {
s3 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c86); }
}
while (s3 !== peg$FAILED) {
s2.push(s3);
if (peg$c85.test(input.charAt(peg$currPos))) {
s3 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c86); }
}
}
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 34) {
s3 = peg$c83;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c84); }
}
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c82(s2);
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$parseWhitespace() {
var s0, s1, s2;
s0 = peg$currPos;
s1 = [];
if (peg$c87.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c88); }
}
while (s2 !== peg$FAILED) {
s1.push(s2);
if (peg$c87.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c88); }
}
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c89();
}
s0 = s1;
return s0;
}
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 < input.length ? input.charAt(peg$maxFailPos) : null,
peg$maxFailPos < input.length
? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
: peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
);
}
}
return {
SyntaxError: peg$SyntaxError,
parse: peg$parse
};
})();
Expression
= (Whitespace? Term Whitespace?)*
Term
= Literal
/ YearFull
/ YearShort
/ YearAny
/ MonthFullName
/ MonthShortName
/ MonthZeroPad
/ MonthOptionalPad
/ Month
/ WeekFullName
/ WeekShortName
/ WeekNumberZeroPad
/ WeekNumber
/ DayOfMonthZeroPad
/ DayOfMonthOptionalPad
/ DayOfMonth
/ Millisecond
/ SecondZeroPad
/ Second
/ AmPm
/ TimezoneWithColon
/ Timezone
/ EraFullName
/ EraShortName
/ FormatName
YearFull
= "yyyy"
YearShort
= "yy"
YearAny
= "y"
MonthFullName
= "MMMM"
MonthShortName
= "MMM"
MonthZeroPad
= "MM"
MonthOptionalPad
= "M!"
Month
= "M"
WeekFullName
= "EEEE"
WeekShortName
= "EEE"
WeekNumberZeroPad
= "ww"
WeekNumber
= "w"
DayOfMonthZeroPad
= "dd"
DayOfMonthOptionalPad
= "d!"
DayOfMonth
= "d"
Hour24ZeroPad
= "HH"
Hour24
= "H"
Hour12ZeroPad
= "hh"
Hour12
= "h"
MinuteZeroPad
= "mm"
Minute
= "m"
Millisecond
= "sss"
SecondZeroPad
= "ss"
Second
= "s"
AmPm
= "a"
TimezoneWithColon
= "ZZ"
Timezone
= "Z"
EraFullName
= "GGGG"
EraShortName
= "GGG"
/ "GG"
/ "G"
FormatName
= "fullDate"
/ "longDate"
/ "medium"
/ "mediumDate"
/ "mediumTime"
/ "short"
/ "shortDate"
/ "shortTime"
Literal
= "'" expr:( [^']* ) "'" { return text(); }
/ '"' expr:( [^"]* ) '"' { return text(); }
Whitespace
= ( [ \t\r\n]* ) { return text(); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment