UNPKG

bible-passage-reference-parser

Version:

Identifies and parses Bible references (like John 3:16) in over 40 languages.

1,252 lines 193 kB
// build/bcv_grammar.js var peg$SyntaxError = class extends SyntaxError { constructor(message, expected, found, location) { super(message); this.expected = expected; this.found = found; this.location = location; this.name = "SyntaxError"; } format(sources) { let str = "Error: " + this.message; if (this.location) { let src = null; const st = sources.find((s2) => s2.source === this.location.source); if (st) { src = st.text.split(/\r\n|\n|\r/g); } const s = this.location.start; const offset_s = this.location.source && typeof this.location.source.offset === "function" ? this.location.source.offset(s) : s; const loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column; if (src) { const e = this.location.end; const filler = "".padEnd(offset_s.line.toString().length, " "); const line = src[s.line - 1]; const last = s.line === e.line ? e.column : line.length + 1; const hatLen = last - s.column || 1; str += "\n --> " + loc + "\n" + filler + " |\n" + offset_s.line + " | " + line + "\n" + filler + " | " + "".padEnd(s.column - 1, " ") + "".padEnd(hatLen, "^"); } else { str += "\n at " + loc; } } return str; } static buildMessage(expected, found) { function hex(ch) { return ch.codePointAt(0).toString(16).toUpperCase(); } const nonPrintable = Object.prototype.hasOwnProperty.call(RegExp.prototype, "unicode") ? new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]", "gu") : null; function unicodeEscape(s) { if (nonPrintable) { return s.replace(nonPrintable, (ch) => "\\u{" + hex(ch) + "}"); } return s; } function literalEscape(s) { return unicodeEscape(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, (ch) => "\\x0" + hex(ch)).replace(/[\x10-\x1F\x7F-\x9F]/g, (ch) => "\\x" + hex(ch))); } function classEscape(s) { return unicodeEscape(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, (ch) => "\\x0" + hex(ch)).replace(/[\x10-\x1F\x7F-\x9F]/g, (ch) => "\\x" + hex(ch))); } const DESCRIBE_EXPECTATION_FNS = { literal(expectation) { return '"' + literalEscape(expectation.text) + '"'; }, class(expectation) { const escapedParts = expectation.parts.map( (part) => Array.isArray(part) ? classEscape(part[0]) + "-" + classEscape(part[1]) : classEscape(part) ); return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]" + (expectation.unicode ? "u" : ""); }, any() { return "any character"; }, end() { return "end of input"; }, other(expectation) { return expectation.description; } }; function describeExpectation(expectation) { return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); } function describeExpected(expected2) { const descriptions = expected2.map(describeExpectation); descriptions.sort(); if (descriptions.length > 0) { let j = 1; for (let i = 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(found2) { return found2 ? '"' + literalEscape(found2) + '"' : "end of input"; } return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; } }; function peg$parse(input, options) { options = options !== void 0 ? options : {}; const peg$FAILED = {}; const peg$source = options.grammarSource; const peg$startRuleFunctions = { start: peg$parsestart }; let peg$startRuleFunction = peg$parsestart; const peg$c0 = "("; const peg$c1 = ")"; const peg$c2 = ""; const peg$c3 = "/"; const peg$c4 = ","; const peg$c5 = "."; const peg$c6 = "-"; const peg$c7 = "$ordinal"; const peg$c8 = "/1"; const peg$c9 = "$ff_value"; const peg$c10 = "$next_value"; const peg$c11 = "/9"; const peg$c12 = "/2"; const peg$c13 = ".1"; const peg$c14 = "$ab"; const peg$c15 = "$c_explicit_value"; const peg$c16 = "$c_sep_value"; const peg$c17 = "$v_explicit_value"; const peg$c18 = "$cv_sep"; const peg$c19 = "$cv_sep_weak"; const peg$c20 = "$sequence_sep_value"; const peg$c21 = "$range_sep"; const peg$c22 = "$title_value"; const peg$c23 = "$in_book_of"; const peg$c24 = ""; const peg$c25 = "$integer_value"; const peg$c26 = "$space"; const peg$r0 = /^[1-8]/; const peg$r1 = /^[0-9]/; const peg$r2 = /^[([]/; const peg$r3 = /^[)\]]/; const peg$r4 = /^[^\x1F\x1E([]/; const peg$e0 = peg$literalExpectation("(", false); const peg$e1 = peg$literalExpectation(")", false); const peg$e2 = peg$literalExpectation("", false); const peg$e3 = peg$literalExpectation("/", false); const peg$e4 = peg$classExpectation([["1", "8"]], false, false, false); const peg$e5 = peg$literalExpectation(",", false); const peg$e6 = peg$literalExpectation(".", false); const peg$e7 = peg$literalExpectation("-", false); const peg$e8 = peg$literalExpectation("$ordinal", false); const peg$e9 = peg$literalExpectation("/1", false); const peg$e10 = peg$literalExpectation("$ff_value", false); const peg$e11 = peg$literalExpectation("$next_value", false); const peg$e12 = peg$literalExpectation("/9", false); const peg$e13 = peg$literalExpectation("/2", false); const peg$e14 = peg$literalExpectation(".1", false); const peg$e15 = peg$classExpectation([["0", "9"]], false, false, false); const peg$e16 = peg$literalExpectation("$ab", false); const peg$e17 = peg$literalExpectation("$c_explicit_value", false); const peg$e18 = peg$literalExpectation("$c_sep_value", false); const peg$e19 = peg$literalExpectation("$v_explicit_value", false); const peg$e20 = peg$literalExpectation("$cv_sep", false); const peg$e21 = peg$literalExpectation("$cv_sep_weak", false); const peg$e22 = peg$literalExpectation("$sequence_sep_value", false); const peg$e23 = peg$literalExpectation("$range_sep", false); const peg$e24 = peg$literalExpectation("$title_value", false); const peg$e25 = peg$literalExpectation("$in_book_of", false); const peg$e26 = peg$classExpectation(["(", "["], false, false, false); const peg$e27 = peg$classExpectation([")", "]"], false, false, false); const peg$e28 = peg$literalExpectation("", false); const peg$e29 = peg$literalExpectation("$integer_value", false); const peg$e30 = peg$classExpectation(["", "", "(", "["], true, false, false); const peg$e31 = peg$literalExpectation("$space", false); function peg$f0(val_1, sep_val, seq_post) { if (sep_val && sep_val.type && sep_val.type === "c_explicit") seq_post.explicit_context = "c"; return [seq_post]; } function peg$f1(val_1, val_2) { val_2.unshift([val_1]); const r = range(); return { type: "sequence", value: val_2, indices: [r.start, r.end - 1] }; } function peg$f2(sep_val_1, val_1, sep_val, seq_post) { if (sep_val && sep_val.type && sep_val.type === "c_explicit") seq_post.explicit_context = "c"; return [seq_post]; } function peg$f3(sep_val_1, val_1, val_2) { if (typeof val_2 === "undefined") val_2 = []; if (sep_val_1 && sep_val_1.type && sep_val_1.type === "c_explicit") val_1.explicit_context = "c"; val_2.unshift([val_1]); const r = range(); return { type: "sequence_post_enclosed", value: val_2, indices: [r.start, r.end - 1] }; } function peg$f4(val_1, val_2) { if (val_1.length && val_1.length === 2) val_1 = val_1[0]; const r = range(); return { type: "range", value: [val_1, val_2], indices: [r.start, r.end - 1] }; } function peg$f5(val) { const r = range(); return { type: "b", value: val.value, indices: [r.start, r.end - 1] }; } function peg$f6(val_1, val_2) { const r = range(); return { type: "bc", value: [val_1, val_2], indices: [r.start, r.end - 1] }; } function peg$f7(val_1, val_2) { const r = range(); return { type: "bc", value: [val_1, val_2], indices: [r.start, r.end - 1] }; } function peg$f8(val_1) { return val_1.value[1].value[0].partial == null; } function peg$f9(val_1, val_2) { const r = range(); return { type: "bc_title", value: [val_1, val_2], indices: [r.start, r.end - 1] }; } function peg$f10(val_1, val_2) { const r = range(); return { type: "bcv", value: [val_1, val_2], indices: [r.start, r.end - 1] }; } function peg$f11(val_1) { return val_1.value[1].value[0].partial == null; } function peg$f12(val_1, val_2) { const r = range(); return { type: "bcv", value: [val_1, val_2], indices: [r.start, r.end - 1] }; } function peg$f13(val_1) { return val_1.value[1].value[0].partial == null; } function peg$f14(val_1, val_2) { const r = range(); return { type: "bcv", value: [val_1, val_2], indices: [r.start, r.end - 1] }; } function peg$f15(val_1, val_2) { return val_2.value[0].partial == null; } function peg$f16(val_1, val_2, val_3, val_4) { const r = range(); return { type: "range", value: [{ type: "bcv", value: [{ type: "bc", value: [val_1, val_2], indices: [val_1.indices[0], val_2.indices[1]] }, val_3], indices: [val_1.indices[0], val_3.indices[1]] }, val_4], indices: [r.start, r.end - 1] }; } function peg$f17(val_1, val_2) { const r = range(); return { type: "bv", value: [val_1, val_2], indices: [r.start, r.end - 1] }; } function peg$f18(val) { const r = range(); return { type: "c", value: [val], indices: [r.start, r.end - 1] }; } function peg$f19(val_1) { return val_1.value[0].partial == null; } function peg$f20(val_1, val_2) { const r = range(); return { type: "bc", value: [val_2, val_1], indices: [r.start, r.end - 1] }; } function peg$f21(val_1) { return val_1.value[0].partial == null; } function peg$f22(val_1, val_2, val_3) { const r = range(); return { type: "cb_range", value: [val_3, val_1, val_2], indices: [r.start, r.end - 1] }; } function peg$f23(val_1, val_2) { const r = range(); return { type: "bcv", value: [val_1, val_2], indices: [r.start, r.end - 1] }; } function peg$f24(val_1, val_2) { const r = range(); return { type: "bc", value: [val_2, val_1], indices: [r.start, r.end - 1] }; } function peg$f25(val_1, val_2) { const r = range(); return { type: "bcv", value: [val_1, val_2], indices: [r.start, r.end - 1] }; } function peg$f26(val) { const r = range(); return { type: "c_psalm", value: val.value, indices: [r.start, r.end - 1] }; } function peg$f27(val_1, val_2) { const r = range(); return { type: "cv_psalm", value: [val_1, val_2], indices: [r.start, r.end - 1] }; } function peg$f28(val_1) { return val_1.value[0].partial == null; } function peg$f29(val_1, val_2) { const r = range(); return { type: "c_title", value: [val_1, val_2], indices: [r.start, r.end - 1] }; } function peg$f30(val_1) { return val_1.value[0].partial == null; } function peg$f31(val_1, val_2) { const r = range(); return { type: "cv", value: [val_1, val_2], indices: [r.start, r.end - 1] }; } function peg$f32(val_1) { return val_1.value[0].partial == null; } function peg$f33(val_1, val_2) { const r = range(); return { type: "cv", value: [val_1, val_2], indices: [r.start, r.end - 1] }; } function peg$f34(val_1) { const r = range(); return { type: "ff", value: [val_1], indices: [r.start, r.end - 1] }; } function peg$f35(val_1) { const r = range(); return { type: "next_v", value: [val_1], indices: [r.start, r.end - 1] }; } function peg$f36(val_1, val_2) { const r = range(); return { type: "integer_title", value: [val_1, val_2], indices: [r.start, r.end - 1] }; } function peg$f37(val) { const r = range(); return { type: "context", value: val.value, indices: [r.start, r.end - 1] }; } function peg$f38(val) { const r = range(); return { type: "b", value: val.value, indices: [r.start, r.end - 1] }; } function peg$f39(val) { const r = range(); return { type: "bc", value: [val, { type: "c", value: [{ type: "integer", value: 151, indices: [r.end - 2, r.end - 1] }], indices: [r.end - 2, r.end - 1] }], indices: [r.start, r.end - 1] }; } function peg$f40(val_1, val_2) { const r = range(); return { type: "bcv", value: [val_1, { type: "v", value: [val_2], indices: [val_2.indices[0], val_2.indices[1]] }], indices: [r.start, r.end - 1] }; } function peg$f41(val) { const r = range(); return { type: "v", value: [val], indices: [r.start, r.end - 1] }; } function peg$f42() { return { type: "c_explicit" }; } function peg$f43() { return { type: "c_explicit" }; } function peg$f44() { return { type: "v_explicit" }; } function peg$f45() { return ""; } function peg$f46(val) { const r = range(); return { type: "title", value: [val], indices: [r.start, r.end - 1] }; } function peg$f47(val) { const r = range(); return { type: "translation_sequence", value: val, indices: [r.start, r.end - 1] }; } function peg$f48(val) { const r = range(); return { type: "translation_sequence", value: val, indices: [r.start, r.end - 1] }; } function peg$f49(val) { const r = range(); return { type: "translation", value: val.value, indices: [r.start, r.end - 1] }; } function peg$f50(val_1, val_2) { const r = range(); return { type: "integer", value: parseInt(val_1.join(""), 10), partial: val_2 != null ? val_2[1].join("") : null, indices: [r.start, r.end - 1] }; } function peg$f51(val) { const r = range(); return { type: "integer", value: parseInt(val.join(""), 10), indices: [r.start, r.end - 1] }; } function peg$f52(val) { const r = range(); return { type: "word", value: val.join(""), indices: [r.start, r.end - 1] }; } function peg$f53(val) { const r = range(); return { type: "stop", value: val, indices: [r.start, r.end - 1] }; } let peg$currPos = options.peg$currPos | 0; let peg$savedPos = peg$currPos; const peg$posDetailsCache = [{ line: 1, column: 1 }]; let peg$maxFailPos = peg$currPos; let peg$maxFailExpected = options.peg$maxFailExpected || []; let peg$silentFails = options.peg$silentFails | 0; let peg$result; if (options.startRule) { 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 offset() { return peg$savedPos; } function range() { return { source: peg$source, start: peg$savedPos, end: peg$currPos }; } function location() { return peg$computeLocation(peg$savedPos, peg$currPos); } function expected(description, location2) { location2 = location2 !== void 0 ? location2 : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildStructuredError( [peg$otherExpectation(description)], input.substring(peg$savedPos, peg$currPos), location2 ); } function error(message, location2) { location2 = location2 !== void 0 ? location2 : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildSimpleError(message, location2); } function peg$getUnicode(pos = peg$currPos) { const cp = input.codePointAt(pos); if (cp === void 0) { return ""; } return String.fromCodePoint(cp); } function peg$literalExpectation(text2, ignoreCase) { return { type: "literal", text: text2, ignoreCase }; } function peg$classExpectation(parts, inverted, ignoreCase, unicode) { return { type: "class", parts, inverted, ignoreCase, unicode }; } function peg$anyExpectation() { return { type: "any" }; } function peg$endExpectation() { return { type: "end" }; } function peg$otherExpectation(description) { return { type: "other", description }; } function peg$computePosDetails(pos) { let details = peg$posDetailsCache[pos]; let p; if (details) { return details; } else { if (pos >= peg$posDetailsCache.length) { p = peg$posDetailsCache.length - 1; } else { p = pos; while (!peg$posDetailsCache[--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, offset2) { const startPosDetails = peg$computePosDetails(startPos); const endPosDetails = peg$computePosDetails(endPos); const res = { source: peg$source, start: { offset: startPos, line: startPosDetails.line, column: startPosDetails.column }, end: { offset: endPos, line: endPosDetails.line, column: endPosDetails.column } }; if (offset2 && peg$source && typeof peg$source.offset === "function") { res.start = peg$source.offset(res.start); res.end = peg$source.offset(res.end); } return res; } function peg$fail(expected2) { if (peg$currPos < peg$maxFailPos) { return; } if (peg$currPos > peg$maxFailPos) { peg$maxFailPos = peg$currPos; peg$maxFailExpected = []; } peg$maxFailExpected.push(expected2); } function peg$buildSimpleError(message, location2) { return new peg$SyntaxError(message, null, null, location2); } function peg$buildStructuredError(expected2, found, location2) { return new peg$SyntaxError( peg$SyntaxError.buildMessage(expected2, found), expected2, found, location2 ); } function peg$parsestart() { let s0, s1; s0 = []; s1 = peg$parsebcv_hyphen_range(); if (s1 === peg$FAILED) { s1 = peg$parsesequence(); if (s1 === peg$FAILED) { s1 = peg$parsecb_range(); if (s1 === peg$FAILED) { s1 = peg$parserange(); if (s1 === peg$FAILED) { s1 = peg$parsenext_v(); if (s1 === peg$FAILED) { s1 = peg$parseff(); if (s1 === peg$FAILED) { s1 = peg$parsebcv_comma(); if (s1 === peg$FAILED) { s1 = peg$parsebc_title(); if (s1 === peg$FAILED) { s1 = peg$parseps151_bcv(); if (s1 === peg$FAILED) { s1 = peg$parsebcv(); if (s1 === peg$FAILED) { s1 = peg$parsebcv_weak(); if (s1 === peg$FAILED) { s1 = peg$parseps151_bc(); if (s1 === peg$FAILED) { s1 = peg$parsebc(); if (s1 === peg$FAILED) { s1 = peg$parsecv_psalm(); if (s1 === peg$FAILED) { s1 = peg$parsebv(); if (s1 === peg$FAILED) { s1 = peg$parsec_psalm(); if (s1 === peg$FAILED) { s1 = peg$parseb(); if (s1 === peg$FAILED) { s1 = peg$parsecbv(); if (s1 === peg$FAILED) { s1 = peg$parsecbv_ordinal(); if (s1 === peg$FAILED) { s1 = peg$parsecb(); if (s1 === peg$FAILED) { s1 = peg$parsecb_ordinal(); if (s1 === peg$FAILED) { s1 = peg$parsetranslation_sequence_enclosed(); if (s1 === peg$FAILED) { s1 = peg$parsetranslation_sequence(); if (s1 === peg$FAILED) { s1 = peg$parsesequence_sep(); if (s1 === peg$FAILED) { s1 = peg$parsec_title(); if (s1 === peg$FAILED) { s1 = peg$parseinteger_title(); if (s1 === peg$FAILED) { s1 = peg$parsecv(); if (s1 === peg$FAILED) { s1 = peg$parsecv_weak(); if (s1 === peg$FAILED) { s1 = peg$parseinteger(); if (s1 === peg$FAILED) { s1 = peg$parsec(); if (s1 === peg$FAILED) { s1 = peg$parsev(); if (s1 === peg$FAILED) { s1 = peg$parseword(); if (s1 === peg$FAILED) { s1 = peg$parseword_parenthesis(); if (s1 === peg$FAILED) { s1 = peg$parsecontext(); } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } if (s1 !== peg$FAILED) { while (s1 !== peg$FAILED) { s0.push(s1); s1 = peg$parsebcv_hyphen_range(); if (s1 === peg$FAILED) { s1 = peg$parsesequence(); if (s1 === peg$FAILED) { s1 = peg$parsecb_range(); if (s1 === peg$FAILED) { s1 = peg$parserange(); if (s1 === peg$FAILED) { s1 = peg$parsenext_v(); if (s1 === peg$FAILED) { s1 = peg$parseff(); if (s1 === peg$FAILED) { s1 = peg$parsebcv_comma(); if (s1 === peg$FAILED) { s1 = peg$parsebc_title(); if (s1 === peg$FAILED) { s1 = peg$parseps151_bcv(); if (s1 === peg$FAILED) { s1 = peg$parsebcv(); if (s1 === peg$FAILED) { s1 = peg$parsebcv_weak(); if (s1 === peg$FAILED) { s1 = peg$parseps151_bc(); if (s1 === peg$FAILED) { s1 = peg$parsebc(); if (s1 === peg$FAILED) { s1 = peg$parsecv_psalm(); if (s1 === peg$FAILED) { s1 = peg$parsebv(); if (s1 === peg$FAILED) { s1 = peg$parsec_psalm(); if (s1 === peg$FAILED) { s1 = peg$parseb(); if (s1 === peg$FAILED) { s1 = peg$parsecbv(); if (s1 === peg$FAILED) { s1 = peg$parsecbv_ordinal(); if (s1 === peg$FAILED) { s1 = peg$parsecb(); if (s1 === peg$FAILED) { s1 = peg$parsecb_ordinal(); if (s1 === peg$FAILED) { s1 = peg$parsetranslation_sequence_enclosed(); if (s1 === peg$FAILED) { s1 = peg$parsetranslation_sequence(); if (s1 === peg$FAILED) { s1 = peg$parsesequence_sep(); if (s1 === peg$FAILED) { s1 = peg$parsec_title(); if (s1 === peg$FAILED) { s1 = peg$parseinteger_title(); if (s1 === peg$FAILED) { s1 = peg$parsecv(); if (s1 === peg$FAILED) { s1 = peg$parsecv_weak(); if (s1 === peg$FAILED) { s1 = peg$parseinteger(); if (s1 === peg$FAILED) { s1 = peg$parsec(); if (s1 === peg$FAILED) { s1 = peg$parsev(); if (s1 === peg$FAILED) { s1 = peg$parseword(); if (s1 === peg$FAILED) { s1 = peg$parseword_parenthesis(); if (s1 === peg$FAILED) { s1 = peg$parsecontext(); } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } else { s0 = peg$FAILED; } return s0; } function peg$parsesequence() { let s0, s1, s2, s3, s4, s5; s0 = peg$currPos; s1 = peg$parsecb_range(); if (s1 === peg$FAILED) { s1 = peg$parsebcv_hyphen_range(); if (s1 === peg$FAILED) { s1 = peg$parserange(); if (s1 === peg$FAILED) { s1 = peg$parsenext_v(); if (s1 === peg$FAILED) { s1 = peg$parseff(); if (s1 === peg$FAILED) { s1 = peg$parsebcv_comma(); if (s1 === peg$FAILED) { s1 = peg$parsebc_title(); if (s1 === peg$FAILED) { s1 = peg$parseps151_bcv(); if (s1 === peg$FAILED) { s1 = peg$parsebcv(); if (s1 === peg$FAILED) { s1 = peg$parsebcv_weak(); if (s1 === peg$FAILED) { s1 = peg$parseps151_bc(); if (s1 === peg$FAILED) { s1 = peg$parsebc(); if (s1 === peg$FAILED) { s1 = peg$parsecv_psalm(); if (s1 === peg$FAILED) { s1 = peg$parsebv(); if (s1 === peg$FAILED) { s1 = peg$parsec_psalm(); if (s1 === peg$FAILED) { s1 = peg$parseb(); if (s1 === peg$FAILED) { s1 = peg$parsecbv(); if (s1 === peg$FAILED) { s1 = peg$parsecbv_ordinal(); if (s1 === peg$FAILED) { s1 = peg$parsecb(); if (s1 === peg$FAILED) { s1 = peg$parsecb_ordinal(); if (s1 === peg$FAILED) { s1 = peg$parsecontext(); } } } } } } } } } } } } } } } } } } } } if (s1 !== peg$FAILED) { s2 = []; s3 = peg$currPos; s4 = peg$parsec_sep(); if (s4 === peg$FAILED) { s4 = peg$parsesequence_sep(); if (s4 === peg$FAILED) { s4 = null; } } if (s4 !== peg$FAILED) { s5 = peg$parsesequence_post(); if (s5 !== peg$FAILED) { peg$savedPos = s3; s3 = peg$f0(s1, s4, s5); } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$currPos; s4 = peg$parsec_sep(); if (s4 === peg$FAILED) { s4 = peg$parsesequence_sep(); if (s4 === peg$FAILED) { s4 = null; } } if (s4 !== peg$FAILED) { s5 = peg$parsesequence_post(); if (s5 !== peg$FAILED) { peg$savedPos = s3; s3 = peg$f0(s1, s4, s5); } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } } else { s2 = peg$FAILED; } if (s2 !== peg$FAILED) { peg$savedPos = s0; s0 = peg$f1(s1, s2); } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsesequence_post_enclosed() { let s0, s1, s2, s3, s4, s5, s6, s7, s8; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 40) { s1 = peg$c0; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e0); } } if (s1 !== peg$FAILED) { s2 = peg$parsesp(); s3 = peg$parsec_sep(); if (s3 === peg$FAILED) { s3 = peg$parsesequence_sep(); if (s3 === peg$FAILED) { s3 = null; } } if (s3 !== peg$FAILED) { s4 = peg$parsesequence_post(); if (s4 !== peg$FAILED) { s5 = []; s6 = peg$currPos; s7 = peg$parsec_sep(); if (s7 === peg$FAILED) { s7 = peg$parsesequence_sep(); if (s7 === peg$FAILED) { s7 = null; } } if (s7 !== peg$FAILED) { s8 = peg$parsesequence_post(); if (s8 !== peg$FAILED) { peg$savedPos = s6; s6 = peg$f2(s3, s4, s7, s8); } else { peg$currPos = s6; s6 = peg$FAILED; } } else { peg$currPos = s6; s6 = peg$FAILED; } while (s6 !== peg$FAILED) { s5.push(s6); s6 = peg$currPos; s7 = peg$parsec_sep(); if (s7 === peg$FAILED) { s7 = peg$parsesequence_sep(); if (s7 === peg$FAILED) { s7 = null; } } if (s7 !== peg$FAILED) { s8 = peg$parsesequence_post(); if (s8 !== peg$FAILED) { peg$savedPos = s6; s6 = peg$f2(s3, s4, s7, s8); } else { peg$currPos = s6; s6 = peg$FAILED; } } else { peg$currPos = s6; s6 = peg$FAILED; } } s6 = peg$parsesp(); if (input.charCodeAt(peg$currPos) === 41) { s7 = peg$c1; peg$currPos++; } else { s7 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e1); } } if (s7 !== peg$FAILED) { peg$savedPos = s0; s0 = peg$f3(s3, s4, s5); } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsesequence_post() { let s0; s0 = peg$parsesequence_post_enclosed(); if (s0 === peg$FAILED) { s0 = peg$parsecb_range(); if (s0 === peg$FAILED) { s0 = peg$parsebcv_hyphen_range(); if (s0 === peg$FAILED) { s0 = peg$parserange(); if (s0 === peg$FAILED) { s0 = peg$parsenext_v(); if (s0 === peg$FAILED) { s0 = peg$parseff(); if (s0 === peg$FAILED) { s0 = peg$parsebcv_comma(); if (s0 === peg$FAILED) { s0 = peg$parsebc_title(); if (s0 === peg$FAILED) { s0 = peg$parseps151_bcv(); if (s0 === peg$FAILED) { s0 = peg$parsebcv(); if (s0 === peg$FAILED) { s0 = peg$parsebcv_weak(); if (s0 === peg$FAILED) { s0 = peg$parseps151_bc(); if (s0 === peg$FAILED) { s0 = peg$parsebc(); if (s0 === peg$FAILED) { s0 = peg$parsecv_psalm(); if (s0 === peg$FAILED) { s0 = peg$parsebv(); if (s0 === peg$FAILED) { s0 = peg$parsec_psalm(); if (s0 === peg$FAILED) { s0 = peg$parseb(); if (s0 === peg$FAILED) { s0 = peg$parsecbv(); if (s0 === peg$FAILED) { s0 = peg$parsecbv_ordinal(); if (s0 === peg$FAILED) { s0 = peg$parsecb(); if (s0 === peg$FAILED) { s0 = peg$parsecb_ordinal(); if (s0 === peg$FAILED) { s0 = peg$parsec_title(); if (s0 === peg$FAILED) { s0 = peg$parseinteger_title(); if (s0 === peg$FAILED) { s0 = peg$parsecv(); if (s0 === peg$FAILED) { s0 = peg$parsecv_weak(); if (s0 === peg$FAILED) { s0 = peg$parseinteger(); if (s0 === peg$FAILED) { s0 = peg$parsec(); if (s0 === peg$FAILED) { s0 = peg$parsev(); } } } } } } } } } } } } } } } } } } } } } } } } } } } return s0; } function peg$parserange() { let s0, s1, s2, s3, s4, s5, s6; s0 = peg$currPos; s1 = peg$parsebcv_comma(); if (s1 === peg$FAILED) { s1 = peg$parsebc_title(); if (s1 === peg$FAILED) { s1 = peg$parseps151_bcv(); if (s1 === peg$FAILED) { s1 = peg$parsebcv(); if (s1 === peg$FAILED) { s1 = peg$parsebcv_weak(); if (s1 === peg$FAILED) { s1 = peg$parseps151_bc(); if (s1 === peg$FAILED) { s1 = peg$parsebc(); if (s1 === peg$FAILED) { s1 = peg$parsecv_psalm(); if (s1 === peg$FAILED) { s1 = peg$parsebv(); if (s1 === peg$FAILED) { s1 = peg$currPos; s2 = peg$parseb(); if (s2 !== peg$FAILED) { s3 = peg$currPos; peg$silentFails++; s4 = peg$currPos; s5 = peg$parserange_sep(); if (s5 !== peg$FAILED) { s6 = peg$parsebcv_comma(); if (s6 === peg$FAILED) { s6 = peg$parsebc_title(); if (s6 === peg$FAILED) { s6 = peg$parseps151_bcv(); if (s6 === peg$FAILED) { s6 = peg$parsebcv(); if (s6 === peg$FAILED) { s6 = peg$parsebcv_weak(); if (s6 === peg$FAILED) { s6 = peg$parseps151_bc(); if (s6 === peg$FAILED) { s6 = peg$parsebc(); if (s6 === peg$FAILED) { s6 = peg$parsebv(); if (s6 === peg$FAILED) { s6 = peg$parseb(); } } } } } } } } if (s6 !== peg$FAILED) { s5 = [s5, s6]; s4 = s5; } else { peg$currPos = s4; s4 = peg$FAILED; } } else { peg$currPos = s4; s4 = peg$FAILED; } peg$silentFails--; if (s4 !== peg$FAILED) { peg$currPos = s3; s3 = void 0; } else { s3 = peg$FAILED; } if (s3 !== peg$FAILED) { s2 = [s2, s3]; s1 = s2; } else { peg$currPos = s1; s1 = peg$FAILED; } } else { peg$currPos = s1; s1 = peg$FAILED; } if (s1 === peg$FAILED) { s1 = peg$parsecbv(); if (s1 === peg$FAILED) { s1 = peg$parsecbv_ordinal(); if (s1 === peg$FAILED) { s1 = peg$parsec_psalm(); if (s1 === peg$FAILED) { s1 = peg$parsecb(); if (s1 === peg$FAILED) { s1 = peg$parsecb_ordinal(); if (s1 === peg$FAILED) { s1 = peg$parsec_title(); if (s1 === peg$FAILED) { s1 = peg$parseinteger_title(); if (s1 === peg$FAILED) { s1 = peg$parsecv(); if (s1 === peg$FAILED) { s1 = peg$parsecv_weak(); if (s1 === peg$FAILED) { s1 = peg$parseinteger(); if (s1 === peg$FAILED) { s1 = peg$parsec(); if (s1 === peg$FAILED) { s1 = peg$parsev(); } } } } } } } } } } } } } } } } } } } } } if (s1 !== peg$FAILED) { s2 = peg$parserange_sep(); if (s2 !== peg$FAILED) { s3 = peg$parsenext_v(); if (s3 === peg$FAILED) { s3 = peg$parseff(); if (s3 === peg$FAILED) { s3 = peg$parsebcv_comma(); if (s3 === peg$FAILED) { s3 = peg$parsebc_title(); if (s3 === peg$FAILED) { s3 = peg$parseps151_bcv(); if (s3 === peg$FAILED) { s3 = peg$parsebcv(); if (s3 === peg$FAILED) { s3 = peg$parsebcv_weak(); if (s3 === peg$FAILED) { s3 = peg$parseps151_bc(); if (s3 === peg$FAILED) { s3 = peg$parsebc(); if (s3 === peg$FAILED) { s3 = peg$parsecv_psalm(); if (s3 === peg$FAILED) { s3 = peg$parsebv(); if (s3 === peg$FAILED) { s3 = peg$parseb(); if (s3 === peg$FAILED) { s3 = peg$parsecbv(); if (s3 === peg$FAILED) { s3 = peg$parsecbv_ordinal(); if (s3 === peg$FAILED) { s3 = peg$parsec_psalm(); if (s3 === peg$FAILED) { s3 = peg$parsecb(); if (s3 === peg$FAILED) { s3 = peg$parsecb_ordinal(); if (s3 === peg$FAILED) { s3 = peg$parsec_title(); if (s3 === peg$FAILED) { s3 = peg$parseinteger_title(); if (s3 === peg$FAILED) { s3 = peg$parsecv(); if (s3 === peg$FAILED) { s3 = peg$parseinteger(); if (s3 === peg$FAILED) { s3 = peg$parsecv_weak(); if (s3 === peg$FAILED) { s3 = peg$parsec(); if (s3 === peg$FAILED) { s3 = peg$parsev(); } } } } } } } } } } } } } } } } } } } } } } } if (s3 !== peg$FAILED) { peg$savedPos = s0; s0 = peg$f4(s1, s3); } else { peg$currPos = s0; s0 = p