edtf
Version:
Extended Date Time Format (EDTF) / ISO 8601-2 Parser and Library
916 lines (804 loc) • 80.3 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var nearley = require('nearley');
function assert(value, message) {
return equal(!!value, true, message ||
`expected "${value}" to be ok`)
}
function equal(actual, expected, message) {
// eslint-disable-next-line eqeqeq
if (actual == expected)
return true
if (Number.isNaN(actual) && Number.isNaN(expected))
return true
throw new Error(message ||
`expected "${actual}" to equal "${expected}"`)
}
assert.equal = equal;
const DAY$1 = /^days?$/i;
const MONTH$1 = /^months?$/i;
const YEAR$1 = /^years?$/i;
const SYMBOL = /^[xX]$/;
const SYMBOLS = /[xX]/g;
const PATTERN = /^[0-9xXdDmMyY]{8}$/;
const YYYYMMDD = 'YYYYMMDD'.split('');
const MAXDAYS = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
const { floor: floor$2, pow, max, min } = Math;
/**
* Bitmasks are used to set Unspecified, Uncertain and
* Approximate flags for a Date. The bitmask for one
* feature corresponds to a numeric value based on the
* following pattern:
*
* YYYYMMDD
* --------
* Day 00000011
* Month 00001100
* Year 11110000
*
*/
class Bitmask {
static test(a, b) {
return this.convert(a) & this.convert(b)
}
static convert(value = 0) { // eslint-disable-line complexity
value = value || 0;
if (value instanceof Bitmask) return value.value
switch (typeof value) {
case 'number': return value
case 'boolean': return value ? Bitmask.YMD : 0
case 'string':
if (DAY$1.test(value)) return Bitmask.DAY
if (MONTH$1.test(value)) return Bitmask.MONTH
if (YEAR$1.test(value)) return Bitmask.YEAR
if (PATTERN.test(value)) return Bitmask.compute(value)
// fall through!
default:
throw new Error(`invalid value: ${value}`)
}
}
static compute(value) {
return value.split('').reduce((memo, c, idx) =>
(memo | (SYMBOL.test(c) ? pow(2, idx) : 0)), 0)
}
static values(mask, digit = 0, normalize = true) {
let num = Bitmask.numbers(mask, digit).split('');
let values = [Number(num.slice(0, 4).join(''))];
if (num.length > 4) values.push(Number(num.slice(4, 6).join('')));
if (num.length > 6) values.push(Number(num.slice(6, 8).join('')));
return normalize ? Bitmask.normalize(values) : values
}
static numbers(mask, digit = 0) {
return mask.replace(SYMBOLS, digit)
}
static normalize(values) {
if (values.length > 1)
values[1] = min(11, max(0, values[1] - 1));
if (values.length > 2)
values[2] = min(MAXDAYS[values[1]] || NaN, max(1, values[2]));
return values
}
constructor(value = 0) {
this.value = Bitmask.convert(value);
}
test(value = 0) {
return this.value & Bitmask.convert(value)
}
bit(k) {
return this.value & pow(2, k)
}
get day() { return this.test(Bitmask.DAY) }
get month() { return this.test(Bitmask.MONTH) }
get year() { return this.test(Bitmask.YEAR) }
add(value) {
return (this.value = this.value | Bitmask.convert(value)), this
}
set(value = 0) {
return (this.value = Bitmask.convert(value)), this
}
mask(input = YYYYMMDD, offset = 0, symbol = 'X') {
return input.map((c, idx) => this.bit(offset + idx) ? symbol : c)
}
masks(values, symbol = 'X') {
let offset = 0;
return values.map(value => {
let mask = this.mask(value.split(''), offset, symbol);
offset = offset + mask.length;
return mask.join('')
})
}
// eslint-disable-next-line complexity
max([year, month, day]) {
if (!year) return []
year = Number(
(this.test(Bitmask.YEAR)) ? this.masks([year], '9')[0] : year
);
if (!month) return [year]
month = Number(month) - 1;
switch (this.test(Bitmask.MONTH)) {
case Bitmask.MONTH:
month = 11;
break
case Bitmask.MX:
month = (month < 9) ? 8 : 11;
break
case Bitmask.XM:
month = (month + 1) % 10;
month = (month < 3) ? month + 9 : month - 1;
break
}
if (!day) return [year, month]
day = Number(day);
switch (this.test(Bitmask.DAY)) {
case Bitmask.DAY:
day = MAXDAYS[month];
break
case Bitmask.DX:
day = min(MAXDAYS[month], day + (9 - (day % 10)));
break
case Bitmask.XD:
day = day % 10;
if (month === 1) {
day = (day === 9 && !leap(year)) ? day + 10 : day + 20;
} else {
day = (day < 2) ? day + 30 : day + 20;
if (day > MAXDAYS[month]) day = day - 10;
}
break
}
if (month === 1 && day > 28 && !leap(year)) {
day = 28;
}
return [year, month, day]
}
// eslint-disable-next-line complexity
min([year, month, day]) {
if (!year) return []
year = Number(
(this.test(Bitmask.YEAR)) ? this.masks([year], '0')[0] : year
);
if (month == null) return [year]
month = Number(month) - 1;
switch (this.test(Bitmask.MONTH)) {
case Bitmask.MONTH:
case Bitmask.XM:
month = 0;
break
case Bitmask.MX:
month = (month < 9) ? 0 : 9;
break
}
if (!day) return [year, month]
day = Number(day);
switch (this.test(Bitmask.DAY)) {
case Bitmask.DAY:
day = 1;
break
case Bitmask.DX:
day = max(1, floor$2(day / 10) * 10);
break
case Bitmask.XD:
day = max(1, day % 10);
break
}
return [year, month, day]
}
marks(values, symbol = '?') {
return values
.map((value, idx) => [
this.qualified(idx * 2) ? symbol : '',
value,
this.qualified(idx * 2 + 1) ? symbol : ''
].join(''))
}
qualified(idx) { // eslint-disable-line complexity
switch (idx) {
case 1:
return this.value === Bitmask.YEAR ||
(this.value & Bitmask.YEAR) && !(this.value & Bitmask.MONTH)
case 2:
return this.value === Bitmask.MONTH ||
(this.value & Bitmask.MONTH) && !(this.value & Bitmask.YEAR)
case 3:
return this.value === Bitmask.YM
case 4:
return this.value === Bitmask.DAY ||
(this.value & Bitmask.DAY) && (this.value !== Bitmask.YMD)
case 5:
return this.value === Bitmask.YMD
default:
return false
}
}
qualify(idx) {
return (this.value = this.value | Bitmask.UA[idx]), this
}
toJSON() {
return this.value
}
toString(symbol = 'X') {
return this.masks(['YYYY', 'MM', 'DD'], symbol).join('-')
}
}
Bitmask.prototype.is = Bitmask.prototype.test;
function leap(year) {
if (year % 4 > 0) return false
if (year % 100 > 0) return true
if (year % 400 > 0) return false
return true
}
Bitmask.DAY = Bitmask.D = Bitmask.compute('yyyymmxx');
Bitmask.MONTH = Bitmask.M = Bitmask.compute('yyyyxxdd');
Bitmask.YEAR = Bitmask.Y = Bitmask.compute('xxxxmmdd');
Bitmask.MD = Bitmask.M | Bitmask.D;
Bitmask.YMD = Bitmask.Y | Bitmask.MD;
Bitmask.YM = Bitmask.Y | Bitmask.M;
Bitmask.YYXX = Bitmask.compute('yyxxmmdd');
Bitmask.YYYX = Bitmask.compute('yyyxmmdd');
Bitmask.XXXX = Bitmask.compute('xxxxmmdd');
Bitmask.DX = Bitmask.compute('yyyymmdx');
Bitmask.XD = Bitmask.compute('yyyymmxd');
Bitmask.MX = Bitmask.compute('yyyymxdd');
Bitmask.XM = Bitmask.compute('yyyyxmdd');
/*
* Map each UA symbol position to a mask.
*
* ~YYYY~-~MM~-~DD~
* 0 1 2 3 4 5
*/
Bitmask.UA = [
Bitmask.YEAR,
Bitmask.YEAR, // YEAR !DAY
Bitmask.MONTH,
Bitmask.YM,
Bitmask.DAY, // YEARDAY
Bitmask.YMD
];
const defaults = {
level: 2,
offset: true,
types: [],
seasonIntervals: false,
seasonUncertainty: false
};
const { assign: assign$1 } = Object;
function num(data) {
return Number(Array.isArray(data) ? data.join('') : data)
}
function join(data) {
return data.join('')
}
function zero() { return 0 }
function nothing() { return null }
function pick(...args) {
return args.length === 1 ?
data => data[args[0]] :
data => concat(data, args)
}
function pluck(...args) {
return data => args.map(i => data[i])
}
function concat(data, idx = data.keys()) {
return Array.from(idx)
.reduce((memo, i) => data[i] !== null ? memo.concat(data[i]) : memo, [])
}
function merge(...args) {
if (typeof args[args.length - 1] === 'object')
var extra = args.pop();
return data => assign$1(args.reduce((a, i) => assign$1(a, data[i]), {}), extra)
}
function interval(level) {
return data => ({
values: [data[0], data[2]],
type: 'Interval',
level
})
}
function masked(type = 'unspecified', symbol = 'X', normalize = true) {
return (data, _, reject) => {
data = data.join('');
let negative = data.startsWith('-');
let mask = data.replace(/-/g, '');
if (mask.indexOf(symbol) === -1) return reject
let values = Bitmask.values(mask, 0, normalize);
if (negative) values[0] = -values[0];
return {
values, [type]: Bitmask.compute(mask)
}
}
}
function date$6(values, level = 0, extra = null) {
return assign$1({
type: 'Date',
level,
values: Bitmask.normalize(values.map(Number))
}, extra)
}
function year(values, level = 1, extra = null) {
return assign$1({
type: 'Year',
level,
values: values.map(Number)
}, extra)
}
function century(value, level = 0) {
return {
type: 'Century',
level,
values: [value]
}
}
function decade(value, level = 2) {
return {
type: 'Decade',
level,
values: [value]
}
}
function datetime(data) {
let offset = data[3];
let values = Bitmask.normalize(data[0].map(Number)).concat(data[2]);
if (offset == null && !!defaults.offset) {
if (typeof defaults.offset === 'number') {
offset = defaults.offset;
} else {
offset = new Date(...values).getTimezoneOffset();
}
}
return {
level: 0,
offset,
type: 'Date',
values
}
}
function season(values, level = 1) {
return {
type: 'Season',
level,
values: values.map(Number)
}
}
function list(data) {
return assign$1({ values: data[1], level: 2 }, data[0], data[2])
}
function qualified(fn, level = 2) {
return ([parts], _, reject) => {
let q = {
uncertain: new Bitmask(), approximate: new Bitmask()
};
let values = parts
.map(([lhs, part, rhs], idx) => {
for (let ua in lhs) q[ua].qualify(idx * 2);
for (let ua in rhs) q[ua].qualify(1 + idx * 2);
return part
});
return (!q.uncertain.value && !q.approximate.value) ?
reject : {
...fn(values, level),
uncertain: q.uncertain.value,
approximate: q.approximate.value
}
}
}
// Generated automatically by nearley, version 2.20.1
// http://github.com/Hardmath123/nearley
function id(x) { return x[0]; }
const {
DAY, MONTH, YEAR, YMD, YM, MD, YYXX, YYYX, XXXX
} = Bitmask;
let ParserRules = [
{"name": "edtf", "symbols": ["L0"], "postprocess": id},
{"name": "edtf", "symbols": ["L1"], "postprocess": id},
{"name": "edtf", "symbols": ["L2"], "postprocess": id},
{"name": "edtf", "symbols": ["L3"], "postprocess": id},
{"name": "L0", "symbols": ["date_time"], "postprocess": id},
{"name": "L0", "symbols": ["century"], "postprocess": id},
{"name": "L0", "symbols": ["L0i"], "postprocess": id},
{"name": "L0i", "symbols": ["date_time", {"literal":"/"}, "date_time"], "postprocess": interval(0)},
{"name": "century", "symbols": ["positive_century"], "postprocess": data => century(data[0])},
{"name": "century$string$1", "symbols": [{"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "century", "symbols": ["century$string$1"], "postprocess": data => century(0)},
{"name": "century", "symbols": [{"literal":"-"}, "positive_century"], "postprocess": data => century(-data[1])},
{"name": "positive_century", "symbols": ["positive_digit", "digit"], "postprocess": num},
{"name": "positive_century", "symbols": [{"literal":"0"}, "positive_digit"], "postprocess": num},
{"name": "date_time", "symbols": ["date"], "postprocess": id},
{"name": "date_time", "symbols": ["datetime"], "postprocess": id},
{"name": "date", "symbols": ["year"], "postprocess": data => date$6(data)},
{"name": "date", "symbols": ["year_month"], "postprocess": data => date$6(data[0])},
{"name": "date", "symbols": ["year_month_day"], "postprocess": data => date$6(data[0])},
{"name": "year", "symbols": ["positive_year"], "postprocess": id},
{"name": "year", "symbols": ["negative_year"], "postprocess": id},
{"name": "year$string$1", "symbols": [{"literal":"0"}, {"literal":"0"}, {"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "year", "symbols": ["year$string$1"], "postprocess": join},
{"name": "positive_year", "symbols": ["positive_digit", "digit", "digit", "digit"], "postprocess": join},
{"name": "positive_year", "symbols": [{"literal":"0"}, "positive_digit", "digit", "digit"], "postprocess": join},
{"name": "positive_year$string$1", "symbols": [{"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "positive_year", "symbols": ["positive_year$string$1", "positive_digit", "digit"], "postprocess": join},
{"name": "positive_year$string$2", "symbols": [{"literal":"0"}, {"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "positive_year", "symbols": ["positive_year$string$2", "positive_digit"], "postprocess": join},
{"name": "negative_year", "symbols": [{"literal":"-"}, "positive_year"], "postprocess": join},
{"name": "year_month", "symbols": ["year", {"literal":"-"}, "month"], "postprocess": pick(0, 2)},
{"name": "year_month_day", "symbols": ["year", {"literal":"-"}, "month_day"], "postprocess": pick(0, 2)},
{"name": "month", "symbols": ["d01_12"], "postprocess": id},
{"name": "month_day", "symbols": ["m31", {"literal":"-"}, "day"], "postprocess": pick(0, 2)},
{"name": "month_day", "symbols": ["m30", {"literal":"-"}, "d01_30"], "postprocess": pick(0, 2)},
{"name": "month_day$string$1", "symbols": [{"literal":"0"}, {"literal":"2"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "month_day", "symbols": ["month_day$string$1", {"literal":"-"}, "d01_29"], "postprocess": pick(0, 2)},
{"name": "day", "symbols": ["d01_31"], "postprocess": id},
{"name": "datetime$ebnf$1$subexpression$1", "symbols": ["timezone"], "postprocess": id},
{"name": "datetime$ebnf$1", "symbols": ["datetime$ebnf$1$subexpression$1"], "postprocess": id},
{"name": "datetime$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "datetime", "symbols": ["year_month_day", {"literal":"T"}, "time", "datetime$ebnf$1"], "postprocess": datetime},
{"name": "time", "symbols": ["hours", {"literal":":"}, "minutes", {"literal":":"}, "seconds", "milliseconds"], "postprocess": pick(0, 2, 4, 5)},
{"name": "time", "symbols": ["hours", {"literal":":"}, "minutes"], "postprocess": pick(0, 2)},
{"name": "time$string$1", "symbols": [{"literal":"2"}, {"literal":"4"}, {"literal":":"}, {"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "time$ebnf$1$string$1", "symbols": [{"literal":":"}, {"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "time$ebnf$1", "symbols": ["time$ebnf$1$string$1"], "postprocess": id},
{"name": "time$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "time", "symbols": ["time$string$1", "time$ebnf$1"], "postprocess": () => [24, 0, 0]},
{"name": "hours", "symbols": ["d00_23"], "postprocess": num},
{"name": "minutes", "symbols": ["d00_59"], "postprocess": num},
{"name": "seconds", "symbols": ["d00_59"], "postprocess": num},
{"name": "milliseconds", "symbols": []},
{"name": "milliseconds", "symbols": [{"literal":"."}, "d3s"], "postprocess": data => num(data.slice(1))},
{"name": "timezone", "symbols": [{"literal":"Z"}], "postprocess": zero},
{"name": "timezone$subexpression$1", "symbols": [{"literal":"-"}]},
{"name": "timezone$subexpression$1", "symbols": [{"literal":"−"}]},
{"name": "timezone", "symbols": ["timezone$subexpression$1", "offset"], "postprocess": data => -data[1]},
{"name": "timezone", "symbols": [{"literal":"+"}, "positive_offset"], "postprocess": pick(1)},
{"name": "positive_offset", "symbols": ["offset"], "postprocess": id},
{"name": "positive_offset$string$1", "symbols": [{"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "positive_offset$ebnf$1", "symbols": [{"literal":":"}], "postprocess": id},
{"name": "positive_offset$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "positive_offset$string$2", "symbols": [{"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "positive_offset", "symbols": ["positive_offset$string$1", "positive_offset$ebnf$1", "positive_offset$string$2"], "postprocess": zero},
{"name": "positive_offset$subexpression$1$string$1", "symbols": [{"literal":"1"}, {"literal":"2"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "positive_offset$subexpression$1", "symbols": ["positive_offset$subexpression$1$string$1"]},
{"name": "positive_offset$subexpression$1$string$2", "symbols": [{"literal":"1"}, {"literal":"3"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "positive_offset$subexpression$1", "symbols": ["positive_offset$subexpression$1$string$2"]},
{"name": "positive_offset$ebnf$2", "symbols": [{"literal":":"}], "postprocess": id},
{"name": "positive_offset$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "positive_offset", "symbols": ["positive_offset$subexpression$1", "positive_offset$ebnf$2", "minutes"], "postprocess": data => num(data[0]) * 60 + data[2]},
{"name": "positive_offset$string$3", "symbols": [{"literal":"1"}, {"literal":"4"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "positive_offset$ebnf$3", "symbols": [{"literal":":"}], "postprocess": id},
{"name": "positive_offset$ebnf$3", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "positive_offset$string$4", "symbols": [{"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "positive_offset", "symbols": ["positive_offset$string$3", "positive_offset$ebnf$3", "positive_offset$string$4"], "postprocess": () => 840},
{"name": "positive_offset", "symbols": ["d00_14"], "postprocess": data => num(data[0]) * 60},
{"name": "offset$ebnf$1", "symbols": [{"literal":":"}], "postprocess": id},
{"name": "offset$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "offset", "symbols": ["d01_11", "offset$ebnf$1", "minutes"], "postprocess": data => num(data[0]) * 60 + data[2]},
{"name": "offset$string$1", "symbols": [{"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "offset$ebnf$2", "symbols": [{"literal":":"}], "postprocess": id},
{"name": "offset$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "offset", "symbols": ["offset$string$1", "offset$ebnf$2", "d01_59"], "postprocess": data => num(data[2])},
{"name": "offset$string$2", "symbols": [{"literal":"1"}, {"literal":"2"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "offset$ebnf$3", "symbols": [{"literal":":"}], "postprocess": id},
{"name": "offset$ebnf$3", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "offset$string$3", "symbols": [{"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "offset", "symbols": ["offset$string$2", "offset$ebnf$3", "offset$string$3"], "postprocess": () => 720},
{"name": "offset", "symbols": ["d01_12"], "postprocess": data => num(data[0]) * 60},
{"name": "L1", "symbols": ["L1d"], "postprocess": id},
{"name": "L1", "symbols": ["L1Y"], "postprocess": id},
{"name": "L1", "symbols": ["L1S"], "postprocess": id},
{"name": "L1", "symbols": ["L1i"], "postprocess": id},
{"name": "L1d", "symbols": ["date_ua"], "postprocess": id},
{"name": "L1d", "symbols": ["L1X"], "postprocess": merge(0, { type: 'Date', level: 1 })},
{"name": "date_ua", "symbols": ["date", "UA"], "postprocess": merge(0, 1, { level: 1 })},
{"name": "L1i", "symbols": ["L1i_date", {"literal":"/"}, "L1i_date"], "postprocess": interval(1)},
{"name": "L1i", "symbols": ["date_time", {"literal":"/"}, "L1i_date"], "postprocess": interval(1)},
{"name": "L1i", "symbols": ["L1i_date", {"literal":"/"}, "date_time"], "postprocess": interval(1)},
{"name": "L1i_date", "symbols": [], "postprocess": nothing},
{"name": "L1i_date", "symbols": ["date_ua"], "postprocess": id},
{"name": "L1i_date", "symbols": ["INFINITY"], "postprocess": id},
{"name": "INFINITY$string$1", "symbols": [{"literal":"."}, {"literal":"."}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "INFINITY", "symbols": ["INFINITY$string$1"], "postprocess": () => Infinity},
{"name": "L1X$string$1", "symbols": [{"literal":"-"}, {"literal":"X"}, {"literal":"X"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "L1X", "symbols": ["nd4", {"literal":"-"}, "md", "L1X$string$1"], "postprocess": masked()},
{"name": "L1X$string$2", "symbols": [{"literal":"-"}, {"literal":"X"}, {"literal":"X"}, {"literal":"-"}, {"literal":"X"}, {"literal":"X"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "L1X", "symbols": ["nd4", "L1X$string$2"], "postprocess": masked()},
{"name": "L1X$string$3", "symbols": [{"literal":"X"}, {"literal":"X"}, {"literal":"X"}, {"literal":"X"}, {"literal":"-"}, {"literal":"X"}, {"literal":"X"}, {"literal":"-"}, {"literal":"X"}, {"literal":"X"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "L1X", "symbols": ["L1X$string$3"], "postprocess": masked()},
{"name": "L1X$string$4", "symbols": [{"literal":"-"}, {"literal":"X"}, {"literal":"X"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "L1X", "symbols": ["nd4", "L1X$string$4"], "postprocess": masked()},
{"name": "L1X$string$5", "symbols": [{"literal":"X"}, {"literal":"X"}, {"literal":"X"}, {"literal":"X"}, {"literal":"-"}, {"literal":"X"}, {"literal":"X"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "L1X", "symbols": ["L1X$string$5"], "postprocess": masked()},
{"name": "L1X$string$6", "symbols": [{"literal":"X"}, {"literal":"X"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "L1X", "symbols": ["nd2", "L1X$string$6"], "postprocess": masked()},
{"name": "L1X", "symbols": ["nd3", {"literal":"X"}], "postprocess": masked()},
{"name": "L1X$string$7", "symbols": [{"literal":"X"}, {"literal":"X"}, {"literal":"X"}, {"literal":"X"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "L1X", "symbols": ["L1X$string$7"], "postprocess": masked()},
{"name": "L1Y", "symbols": [{"literal":"Y"}, "d5+"], "postprocess": data => year([num(data[1])], 1)},
{"name": "L1Y$string$1", "symbols": [{"literal":"Y"}, {"literal":"-"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "L1Y", "symbols": ["L1Y$string$1", "d5+"], "postprocess": data => year([-num(data[1])], 1)},
{"name": "UA", "symbols": [{"literal":"?"}], "postprocess": () => ({ uncertain: true })},
{"name": "UA", "symbols": [{"literal":"~"}], "postprocess": () => ({ approximate: true })},
{"name": "UA", "symbols": [{"literal":"%"}], "postprocess": () => ({ approximate: true, uncertain: true })},
{"name": "L1S", "symbols": ["year", {"literal":"-"}, "d21_24"], "postprocess": d => season([d[0], d[2]], 1)},
{"name": "L2", "symbols": ["L2d"], "postprocess": id},
{"name": "L2", "symbols": ["L2Y"], "postprocess": id},
{"name": "L2", "symbols": ["L2S"], "postprocess": id},
{"name": "L2", "symbols": ["L2D"], "postprocess": id},
{"name": "L2", "symbols": ["L2C"], "postprocess": id},
{"name": "L2", "symbols": ["L2i"], "postprocess": id},
{"name": "L2", "symbols": ["set"], "postprocess": id},
{"name": "L2", "symbols": ["list"], "postprocess": id},
{"name": "L2d", "symbols": ["ua_date"], "postprocess": id},
{"name": "L2d", "symbols": ["L2X"], "postprocess": merge(0, { type: 'Date', level: 2 })},
{"name": "L2D", "symbols": ["decade"], "postprocess": id},
{"name": "L2D", "symbols": ["decade", "UA"], "postprocess": merge(0, 1)},
{"name": "L2C", "symbols": ["century"], "postprocess": id},
{"name": "L2C", "symbols": ["century", "UA"], "postprocess": merge(0, 1, {level: 2})},
{"name": "ua_date", "symbols": ["ua_year"], "postprocess": qualified(date$6)},
{"name": "ua_date", "symbols": ["ua_year_month"], "postprocess": qualified(date$6)},
{"name": "ua_date", "symbols": ["ua_year_month_day"], "postprocess": qualified(date$6)},
{"name": "ua_year", "symbols": ["UA", "year"], "postprocess": data => [data]},
{"name": "ua_year_month$macrocall$2", "symbols": ["year"]},
{"name": "ua_year_month$macrocall$1$ebnf$1", "symbols": ["UA"], "postprocess": id},
{"name": "ua_year_month$macrocall$1$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "ua_year_month$macrocall$1$ebnf$2", "symbols": ["UA"], "postprocess": id},
{"name": "ua_year_month$macrocall$1$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "ua_year_month$macrocall$1", "symbols": ["ua_year_month$macrocall$1$ebnf$1", "ua_year_month$macrocall$2", "ua_year_month$macrocall$1$ebnf$2"]},
{"name": "ua_year_month$macrocall$4", "symbols": ["month"]},
{"name": "ua_year_month$macrocall$3$ebnf$1", "symbols": ["UA"], "postprocess": id},
{"name": "ua_year_month$macrocall$3$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "ua_year_month$macrocall$3$ebnf$2", "symbols": ["UA"], "postprocess": id},
{"name": "ua_year_month$macrocall$3$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "ua_year_month$macrocall$3", "symbols": ["ua_year_month$macrocall$3$ebnf$1", "ua_year_month$macrocall$4", "ua_year_month$macrocall$3$ebnf$2"]},
{"name": "ua_year_month", "symbols": ["ua_year_month$macrocall$1", {"literal":"-"}, "ua_year_month$macrocall$3"], "postprocess": pluck(0, 2)},
{"name": "ua_year_month_day$macrocall$2", "symbols": ["year"]},
{"name": "ua_year_month_day$macrocall$1$ebnf$1", "symbols": ["UA"], "postprocess": id},
{"name": "ua_year_month_day$macrocall$1$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "ua_year_month_day$macrocall$1$ebnf$2", "symbols": ["UA"], "postprocess": id},
{"name": "ua_year_month_day$macrocall$1$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "ua_year_month_day$macrocall$1", "symbols": ["ua_year_month_day$macrocall$1$ebnf$1", "ua_year_month_day$macrocall$2", "ua_year_month_day$macrocall$1$ebnf$2"]},
{"name": "ua_year_month_day", "symbols": ["ua_year_month_day$macrocall$1", {"literal":"-"}, "ua_month_day"], "postprocess": data => [data[0], ...data[2]]},
{"name": "ua_month_day$macrocall$2", "symbols": ["m31"]},
{"name": "ua_month_day$macrocall$1$ebnf$1", "symbols": ["UA"], "postprocess": id},
{"name": "ua_month_day$macrocall$1$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "ua_month_day$macrocall$1$ebnf$2", "symbols": ["UA"], "postprocess": id},
{"name": "ua_month_day$macrocall$1$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "ua_month_day$macrocall$1", "symbols": ["ua_month_day$macrocall$1$ebnf$1", "ua_month_day$macrocall$2", "ua_month_day$macrocall$1$ebnf$2"]},
{"name": "ua_month_day$macrocall$4", "symbols": ["day"]},
{"name": "ua_month_day$macrocall$3$ebnf$1", "symbols": ["UA"], "postprocess": id},
{"name": "ua_month_day$macrocall$3$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "ua_month_day$macrocall$3$ebnf$2", "symbols": ["UA"], "postprocess": id},
{"name": "ua_month_day$macrocall$3$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "ua_month_day$macrocall$3", "symbols": ["ua_month_day$macrocall$3$ebnf$1", "ua_month_day$macrocall$4", "ua_month_day$macrocall$3$ebnf$2"]},
{"name": "ua_month_day", "symbols": ["ua_month_day$macrocall$1", {"literal":"-"}, "ua_month_day$macrocall$3"], "postprocess": pluck(0, 2)},
{"name": "ua_month_day$macrocall$6", "symbols": ["m30"]},
{"name": "ua_month_day$macrocall$5$ebnf$1", "symbols": ["UA"], "postprocess": id},
{"name": "ua_month_day$macrocall$5$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "ua_month_day$macrocall$5$ebnf$2", "symbols": ["UA"], "postprocess": id},
{"name": "ua_month_day$macrocall$5$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "ua_month_day$macrocall$5", "symbols": ["ua_month_day$macrocall$5$ebnf$1", "ua_month_day$macrocall$6", "ua_month_day$macrocall$5$ebnf$2"]},
{"name": "ua_month_day$macrocall$8", "symbols": ["d01_30"]},
{"name": "ua_month_day$macrocall$7$ebnf$1", "symbols": ["UA"], "postprocess": id},
{"name": "ua_month_day$macrocall$7$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "ua_month_day$macrocall$7$ebnf$2", "symbols": ["UA"], "postprocess": id},
{"name": "ua_month_day$macrocall$7$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "ua_month_day$macrocall$7", "symbols": ["ua_month_day$macrocall$7$ebnf$1", "ua_month_day$macrocall$8", "ua_month_day$macrocall$7$ebnf$2"]},
{"name": "ua_month_day", "symbols": ["ua_month_day$macrocall$5", {"literal":"-"}, "ua_month_day$macrocall$7"], "postprocess": pluck(0, 2)},
{"name": "ua_month_day$macrocall$10$string$1", "symbols": [{"literal":"0"}, {"literal":"2"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "ua_month_day$macrocall$10", "symbols": ["ua_month_day$macrocall$10$string$1"]},
{"name": "ua_month_day$macrocall$9$ebnf$1", "symbols": ["UA"], "postprocess": id},
{"name": "ua_month_day$macrocall$9$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "ua_month_day$macrocall$9$ebnf$2", "symbols": ["UA"], "postprocess": id},
{"name": "ua_month_day$macrocall$9$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "ua_month_day$macrocall$9", "symbols": ["ua_month_day$macrocall$9$ebnf$1", "ua_month_day$macrocall$10", "ua_month_day$macrocall$9$ebnf$2"]},
{"name": "ua_month_day$macrocall$12", "symbols": ["d01_29"]},
{"name": "ua_month_day$macrocall$11$ebnf$1", "symbols": ["UA"], "postprocess": id},
{"name": "ua_month_day$macrocall$11$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "ua_month_day$macrocall$11$ebnf$2", "symbols": ["UA"], "postprocess": id},
{"name": "ua_month_day$macrocall$11$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "ua_month_day$macrocall$11", "symbols": ["ua_month_day$macrocall$11$ebnf$1", "ua_month_day$macrocall$12", "ua_month_day$macrocall$11$ebnf$2"]},
{"name": "ua_month_day", "symbols": ["ua_month_day$macrocall$9", {"literal":"-"}, "ua_month_day$macrocall$11"], "postprocess": pluck(0, 2)},
{"name": "L2X", "symbols": ["dx4"], "postprocess": masked()},
{"name": "L2X", "symbols": ["dx4", {"literal":"-"}, "mx"], "postprocess": masked()},
{"name": "L2X", "symbols": ["dx4", {"literal":"-"}, "mdx"], "postprocess": masked()},
{"name": "mdx", "symbols": ["m31x", {"literal":"-"}, "d31x"], "postprocess": join},
{"name": "mdx", "symbols": ["m30x", {"literal":"-"}, "d30x"], "postprocess": join},
{"name": "mdx$string$1", "symbols": [{"literal":"0"}, {"literal":"2"}, {"literal":"-"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "mdx", "symbols": ["mdx$string$1", "d29x"], "postprocess": join},
{"name": "L2i", "symbols": ["L2i_date", {"literal":"/"}, "L2i_date"], "postprocess": interval(2)},
{"name": "L2i", "symbols": ["date_time", {"literal":"/"}, "L2i_date"], "postprocess": interval(2)},
{"name": "L2i", "symbols": ["L2i_date", {"literal":"/"}, "date_time"], "postprocess": interval(2)},
{"name": "L2i_date", "symbols": [], "postprocess": nothing},
{"name": "L2i_date", "symbols": ["ua_date"], "postprocess": id},
{"name": "L2i_date", "symbols": ["L2X"], "postprocess": id},
{"name": "L2i_date", "symbols": ["INFINITY"], "postprocess": id},
{"name": "L2Y", "symbols": ["exp_year"], "postprocess": id},
{"name": "L2Y", "symbols": ["exp_year", "significant_digits"], "postprocess": merge(0, 1)},
{"name": "L2Y", "symbols": ["L1Y", "significant_digits"], "postprocess": merge(0, 1, { level: 2 })},
{"name": "L2Y", "symbols": ["year", "significant_digits"], "postprocess": data => year([data[0]], 2, data[1])},
{"name": "significant_digits", "symbols": [{"literal":"S"}, "positive_digit"], "postprocess": data => ({ significant: num(data[1]) })},
{"name": "exp_year", "symbols": [{"literal":"Y"}, "exp"], "postprocess": data => year([data[1]], 2)},
{"name": "exp_year$string$1", "symbols": [{"literal":"Y"}, {"literal":"-"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "exp_year", "symbols": ["exp_year$string$1", "exp"], "postprocess": data => year([-data[1]], 2)},
{"name": "exp", "symbols": ["digits", {"literal":"E"}, "digits"], "postprocess": data => num(data[0]) * Math.pow(10, num(data[2]))},
{"name": "L2S", "symbols": ["year", {"literal":"-"}, "d25_41"], "postprocess": d => season([d[0], d[2]], 2)},
{"name": "decade", "symbols": ["positive_decade"], "postprocess": data => decade(data[0])},
{"name": "decade$string$1", "symbols": [{"literal":"0"}, {"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "decade", "symbols": ["decade$string$1"], "postprocess": () => decade(0)},
{"name": "decade", "symbols": [{"literal":"-"}, "positive_decade"], "postprocess": data => decade(-data[1])},
{"name": "positive_decade", "symbols": ["positive_digit", "digit", "digit"], "postprocess": num},
{"name": "positive_decade", "symbols": [{"literal":"0"}, "positive_digit", "digit"], "postprocess": num},
{"name": "positive_decade$string$1", "symbols": [{"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "positive_decade", "symbols": ["positive_decade$string$1", "positive_digit"], "postprocess": num},
{"name": "set", "symbols": ["LSB", "OL", "RSB"], "postprocess": list},
{"name": "list", "symbols": ["LLB", "OL", "RLB"], "postprocess": list},
{"name": "LSB", "symbols": [{"literal":"["}], "postprocess": () => ({ type: 'Set' })},
{"name": "LSB$string$1", "symbols": [{"literal":"["}, {"literal":"."}, {"literal":"."}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "LSB", "symbols": ["LSB$string$1"], "postprocess": () => ({ type: 'Set', earlier: true })},
{"name": "LLB", "symbols": [{"literal":"{"}], "postprocess": () => ({ type: 'List' })},
{"name": "LLB$string$1", "symbols": [{"literal":"{"}, {"literal":"."}, {"literal":"."}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "LLB", "symbols": ["LLB$string$1"], "postprocess": () => ({ type: 'List', earlier: true })},
{"name": "RSB", "symbols": [{"literal":"]"}], "postprocess": nothing},
{"name": "RSB$string$1", "symbols": [{"literal":"."}, {"literal":"."}, {"literal":"]"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "RSB", "symbols": ["RSB$string$1"], "postprocess": () => ({ later: true })},
{"name": "RLB", "symbols": [{"literal":"}"}], "postprocess": nothing},
{"name": "RLB$string$1", "symbols": [{"literal":"."}, {"literal":"."}, {"literal":"}"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "RLB", "symbols": ["RLB$string$1"], "postprocess": () => ({ later: true })},
{"name": "OL", "symbols": ["LI"], "postprocess": data => [data[0]]},
{"name": "OL", "symbols": ["OL", "_", {"literal":","}, "_", "LI"], "postprocess": data => [...data[0], data[4]]},
{"name": "LI", "symbols": ["date"], "postprocess": id},
{"name": "LI", "symbols": ["ua_date"], "postprocess": id},
{"name": "LI", "symbols": ["L2X"], "postprocess": id},
{"name": "LI", "symbols": ["consecutives"], "postprocess": id},
{"name": "consecutives$string$1", "symbols": [{"literal":"."}, {"literal":"."}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "consecutives", "symbols": ["year_month_day", "consecutives$string$1", "year_month_day"], "postprocess": d => [date$6(d[0]), date$6(d[2])]},
{"name": "consecutives$string$2", "symbols": [{"literal":"."}, {"literal":"."}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "consecutives", "symbols": ["year_month", "consecutives$string$2", "year_month"], "postprocess": d => [date$6(d[0]), date$6(d[2])]},
{"name": "consecutives$string$3", "symbols": [{"literal":"."}, {"literal":"."}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "consecutives", "symbols": ["year", "consecutives$string$3", "year"], "postprocess": d => [date$6([d[0]]), date$6([d[2]])]},
{"name": "L3", "symbols": ["L3i"], "postprocess": id},
{"name": "L3", "symbols": ["L3S"], "postprocess": id},
{"name": "L3i", "symbols": ["L3s", {"literal":"/"}, "L3s"], "postprocess": interval(3)},
{"name": "L3s", "symbols": ["L1S"], "postprocess": id},
{"name": "L3s", "symbols": ["L2S"], "postprocess": id},
{"name": "L3s", "symbols": ["L3S"], "postprocess": id},
{"name": "L3S", "symbols": ["ua_season"], "postprocess": qualified(season, 3)},
{"name": "L3S", "symbols": ["xx_season"], "postprocess": merge(0, { type: 'Season', level: 3 })},
{"name": "ua_season$macrocall$2", "symbols": ["year"]},
{"name": "ua_season$macrocall$1$ebnf$1", "symbols": ["UA"], "postprocess": id},
{"name": "ua_season$macrocall$1$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "ua_season$macrocall$1$ebnf$2", "symbols": ["UA"], "postprocess": id},
{"name": "ua_season$macrocall$1$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "ua_season$macrocall$1", "symbols": ["ua_season$macrocall$1$ebnf$1", "ua_season$macrocall$2", "ua_season$macrocall$1$ebnf$2"]},
{"name": "ua_season$macrocall$4", "symbols": ["d21_41"]},
{"name": "ua_season$macrocall$3$ebnf$1", "symbols": ["UA"], "postprocess": id},
{"name": "ua_season$macrocall$3$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "ua_season$macrocall$3$ebnf$2", "symbols": ["UA"], "postprocess": id},
{"name": "ua_season$macrocall$3$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}},
{"name": "ua_season$macrocall$3", "symbols": ["ua_season$macrocall$3$ebnf$1", "ua_season$macrocall$4", "ua_season$macrocall$3$ebnf$2"]},
{"name": "ua_season", "symbols": ["ua_season$macrocall$1", {"literal":"-"}, "ua_season$macrocall$3"], "postprocess": pluck(0, 2)},
{"name": "xx_season", "symbols": ["dx4", {"literal":"-"}, "d21_41"], "postprocess": masked('unspecified', 'X', false)},
{"name": "digit", "symbols": ["positive_digit"], "postprocess": id},
{"name": "digit", "symbols": [{"literal":"0"}], "postprocess": id},
{"name": "digits", "symbols": ["digit"], "postprocess": id},
{"name": "digits", "symbols": ["digits", "digit"], "postprocess": join},
{"name": "nd4", "symbols": ["d4"]},
{"name": "nd4", "symbols": [{"literal":"-"}, "d4"], "postprocess": join},
{"name": "nd3", "symbols": ["d3"]},
{"name": "nd3", "symbols": [{"literal":"-"}, "d3"], "postprocess": join},
{"name": "nd2", "symbols": ["d2"]},
{"name": "nd2", "symbols": [{"literal":"-"}, "d2"], "postprocess": join},
{"name": "d4", "symbols": ["d2", "d2"], "postprocess": join},
{"name": "d3", "symbols": ["d2", "digit"], "postprocess": join},
{"name": "d2", "symbols": ["digit", "digit"], "postprocess": join},
{"name": "d3s", "symbols": ["digit"], "postprocess": id},
{"name": "d3s", "symbols": ["d2"], "postprocess": id},
{"name": "d3s", "symbols": ["d3"], "postprocess": id},
{"name": "d3s", "symbols": ["d3", "digits"], "postprocess": pick(0)},
{"name": "d5+", "symbols": ["positive_digit", "d3", "digits"], "postprocess": num},
{"name": "d1x", "symbols": [/[1-9X]/], "postprocess": id},
{"name": "dx", "symbols": ["d1x"], "postprocess": id},
{"name": "dx", "symbols": [{"literal":"0"}], "postprocess": id},
{"name": "dx2", "symbols": ["dx", "dx"], "postprocess": join},
{"name": "dx4", "symbols": ["dx2", "dx2"], "postprocess": join},
{"name": "dx4", "symbols": [{"literal":"-"}, "dx2", "dx2"], "postprocess": join},
{"name": "md", "symbols": ["m31"], "postprocess": id},
{"name": "md", "symbols": ["m30"], "postprocess": id},
{"name": "md$string$1", "symbols": [{"literal":"0"}, {"literal":"2"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "md", "symbols": ["md$string$1"], "postprocess": id},
{"name": "mx", "symbols": [{"literal":"0"}, "d1x"], "postprocess": join},
{"name": "mx", "symbols": [/[1X]/, /[012X]/], "postprocess": join},
{"name": "m31x", "symbols": [/[0X]/, /[13578X]/], "postprocess": join},
{"name": "m31x", "symbols": [/[1X]/, /[02]/], "postprocess": join},
{"name": "m31x$string$1", "symbols": [{"literal":"1"}, {"literal":"X"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "m31x", "symbols": ["m31x$string$1"], "postprocess": id},
{"name": "m30x", "symbols": [/[0X]/, /[469]/], "postprocess": join},
{"name": "m30x$string$1", "symbols": [{"literal":"1"}, {"literal":"1"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "m30x", "symbols": ["m30x$string$1"], "postprocess": join},
{"name": "d29x", "symbols": [{"literal":"0"}, "d1x"], "postprocess": join},
{"name": "d29x", "symbols": [/[1-2X]/, "dx"], "postprocess": join},
{"name": "d30x", "symbols": ["d29x"], "postprocess": join},
{"name": "d30x$string$1", "symbols": [{"literal":"3"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "d30x", "symbols": ["d30x$string$1"], "postprocess": id},
{"name": "d31x", "symbols": ["d30x"], "postprocess": id},
{"name": "d31x", "symbols": [{"literal":"3"}, /[1X]/], "postprocess": join},
{"name": "positive_digit", "symbols": [/[1-9]/], "postprocess": id},
{"name": "m31$subexpression$1$string$1", "symbols": [{"literal":"0"}, {"literal":"1"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "m31$subexpression$1", "symbols": ["m31$subexpression$1$string$1"]},
{"name": "m31$subexpression$1$string$2", "symbols": [{"literal":"0"}, {"literal":"3"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "m31$subexpression$1", "symbols": ["m31$subexpression$1$string$2"]},
{"name": "m31$subexpression$1$string$3", "symbols": [{"literal":"0"}, {"literal":"5"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "m31$subexpression$1", "symbols": ["m31$subexpression$1$string$3"]},
{"name": "m31$subexpression$1$string$4", "symbols": [{"literal":"0"}, {"literal":"7"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "m31$subexpression$1", "symbols": ["m31$subexpression$1$string$4"]},
{"name": "m31$subexpression$1$string$5", "symbols": [{"literal":"0"}, {"literal":"8"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "m31$subexpression$1", "symbols": ["m31$subexpression$1$string$5"]},
{"name": "m31$subexpression$1$string$6", "symbols": [{"literal":"1"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "m31$subexpression$1", "symbols": ["m31$subexpression$1$string$6"]},
{"name": "m31$subexpression$1$string$7", "symbols": [{"literal":"1"}, {"literal":"2"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "m31$subexpression$1", "symbols": ["m31$subexpression$1$string$7"]},
{"name": "m31", "symbols": ["m31$subexpression$1"], "postprocess": id},
{"name": "m30$subexpression$1$string$1", "symbols": [{"literal":"0"}, {"literal":"4"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "m30$subexpression$1", "symbols": ["m30$subexpression$1$string$1"]},
{"name": "m30$subexpression$1$string$2", "symbols": [{"literal":"0"}, {"literal":"6"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "m30$subexpression$1", "symbols": ["m30$subexpression$1$string$2"]},
{"name": "m30$subexpression$1$string$3", "symbols": [{"literal":"0"}, {"literal":"9"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "m30$subexpression$1", "symbols": ["m30$subexpression$1$string$3"]},
{"name": "m30$subexpression$1$string$4", "symbols": [{"literal":"1"}, {"literal":"1"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "m30$subexpression$1", "symbols": ["m30$subexpression$1$string$4"]},
{"name": "m30", "symbols": ["m30$subexpression$1"], "postprocess": id},
{"name": "d01_11", "symbols": [{"literal":"0"}, "positive_digit"], "postprocess": join},
{"name": "d01_11", "symbols": [{"literal":"1"}, /[0-1]/], "postprocess": join},
{"name": "d01_12", "symbols": ["d01_11"], "postprocess": id},
{"name": "d01_12$string$1", "symbols": [{"literal":"1"}, {"literal":"2"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "d01_12", "symbols": ["d01_12$string$1"], "postprocess": id},
{"name": "d01_13", "symbols": ["d01_12"], "postprocess": id},
{"name": "d01_13$string$1", "symbols": [{"literal":"1"}, {"literal":"3"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "d01_13", "symbols": ["d01_13$string$1"], "postprocess": id},
{"name": "d00_14$string$1", "symbols": [{"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "d00_14", "symbols": ["d00_14$string$1"], "postprocess": id},
{"name": "d00_14", "symbols": ["d01_13"], "postprocess": id},
{"name": "d00_14$string$2", "symbols": [{"literal":"1"}, {"literal":"4"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "d00_14", "symbols": ["d00_14$string$2"], "postprocess": id},
{"name": "d00_23$string$1", "symbols": [{"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "d00_23", "symbols": ["d00_23$string$1"], "postprocess": id},
{"name": "d00_23", "symbols": ["d01_23"], "postprocess": id},
{"name": "d01_23", "symbols": [{"literal":"0"}, "positive_digit"], "postprocess": join},
{"name": "d01_23", "symbols": [{"literal":"1"}, "digit"], "postprocess": join},
{"name": "d01_23", "symbols": [{"literal":"2"}, /[0-3]/], "postprocess": join},
{"name": "d01_29", "symbols": [{"literal":"0"}, "positive_digit"], "postprocess": join},
{"name": "d01_29", "symbols": [/[1-2]/, "digit"], "postprocess": join},
{"name": "d01_30", "symbols": ["d01_29"], "postprocess": id},
{"name": "d01_30$string$1", "symbols": [{"literal":"3"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "d01_30", "symbols": ["d01_30$string$1"], "postprocess": id},
{"name": "d01_31", "symbols": ["d01_30"], "postprocess": id},
{"name": "d01_31$string$1", "symbols": [{"literal":"3"}, {"literal":"1"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "d01_31", "symbols": ["d01_31$string$1"], "postprocess": id},
{"name": "d00_59$string$1", "symbols": [{"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "d00_59", "symbols": ["d00_59$string$1"], "postprocess": id},
{"name": "d00_59", "symbols": ["d01_59"], "postprocess": id},
{"name": "d01_59", "symbols": ["d01_29"], "postprocess": id},
{"name": "d01_59", "symbols": [/[345]/, "digit"], "postprocess": join},
{"name": "d21_24", "symbols": [{"literal":"2"}, /[1-4]/], "postprocess": join},
{"name": "d25_41", "symbols": [{"literal":"2"}, /[5-9]/], "postprocess": join},
{"name": "d25_41", "symbols": [{"literal":"3"}, "digit"], "postprocess": join},
{"name": "d25_41", "symbols": [{"literal":"4"}, /[01]/], "postprocess": join},
{"name": "d21_41", "symbols": ["d21_24"], "postprocess": id},
{"name": "d21_41", "symbols": ["d25_41"], "postprocess": id},
{"name": "_$ebnf$1", "symbols": []},
{"name": "_$ebnf$1", "symbols": ["_$ebnf$1", {"literal":" "}], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
{"name": "_", "symbols": ["_$ebnf$1"]}
];
let ParserStart = "edtf";
var grammar = { ParserRules, ParserStart };
function byLevel(a, b) {
return a.level < b.level ? -1 : a.level > b.level ? 1 : 0
}
function limit(results, constraints = {}) {
if (!results.length) return results
let {
level,
types,
seasonIntervals,
seasonUncertainty
} = { ...defaults, ...constraints };
return results.filter(res => {
if (seasonIntervals && isSeasonInterval(res))
return true
if (seasonUncertainty && is