UNPKG

@podlite/schema

Version:

AST tools for Podlite markup language

1,165 lines 272 kB
/* * Generated by PEG.js 0.10.0. * * http://pegjs.org/ */ "use strict"; function peg$subclass(child, parent) { function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); } function peg$SyntaxError(message, expected, found, location) { this.message = message; this.expected = expected; this.found = found; this.location = location; this.name = "SyntaxError"; if (typeof Error.captureStackTrace === "function") { Error.captureStackTrace(this, peg$SyntaxError); } } peg$subclass(peg$SyntaxError, Error); peg$SyntaxError.buildMessage = function (expected, found) { var DESCRIBE_EXPECTATION_FNS = { literal: function (expectation) { return "\"" + literalEscape(expectation.text) + "\""; }, "class": function (expectation) { var escapedParts = "", i; for (i = 0; i < expectation.parts.length; i++) { escapedParts += expectation.parts[i] instanceof Array ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) : classEscape(expectation.parts[i]); } return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; }, any: function (expectation) { return "any character"; }, end: function (expectation) { return "end of input"; }, other: function (expectation) { return expectation.description; } }; function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); } function literalEscape(s) { return s .replace(/\\/g, '\\\\') .replace(/"/g, '\\"') .replace(/\0/g, '\\0') .replace(/\t/g, '\\t') .replace(/\n/g, '\\n') .replace(/\r/g, '\\r') .replace(/[\x00-\x0F]/g, function (ch) { return '\\x0' + hex(ch); }) .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { return '\\x' + hex(ch); }); } function classEscape(s) { return s .replace(/\\/g, '\\\\') .replace(/\]/g, '\\]') .replace(/\^/g, '\\^') .replace(/-/g, '\\-') .replace(/\0/g, '\\0') .replace(/\t/g, '\\t') .replace(/\n/g, '\\n') .replace(/\r/g, '\\r') .replace(/[\x00-\x0F]/g, function (ch) { return '\\x0' + hex(ch); }) .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { return '\\x' + hex(ch); }); } function describeExpectation(expectation) { return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); } function describeExpected(expected) { var descriptions = new Array(expected.length), i, j; for (i = 0; i < expected.length; i++) { descriptions[i] = describeExpectation(expected[i]); } descriptions.sort(); if (descriptions.length > 0) { for (i = 1, j = 1; i < descriptions.length; i++) { if (descriptions[i - 1] !== descriptions[i]) { descriptions[j] = descriptions[i]; j++; } } descriptions.length = j; } switch (descriptions.length) { case 1: return descriptions[0]; case 2: return descriptions[0] + " or " + descriptions[1]; default: return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1]; } } function describeFound(found) { return found ? "\"" + literalEscape(found) + "\"" : "end of input"; } return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; }; function peg$parse(input, options) { options = options !== void 0 ? options : {}; var peg$FAILED = {}, peg$startRuleFunctions = { Document: peg$parseDocument }, peg$startRuleFunction = peg$parseDocument, peg$c0 = function (nodes) { return nodes; }, peg$c1 = function () { return !!options.podMode === true; }, peg$c2 = function (n) { return n; }, peg$c3 = peg$anyExpectation(), peg$c4 = function () { return { text: text(), type: 'ambient', location: location() }; }, peg$c5 = /^[ \xA0\u2001\t\f\u2008]/, peg$c6 = peg$classExpectation([" ", "\xA0", "\u2001", "\t", "\f", "\u2008"], false, false), peg$c7 = /^[ \t\f]/, peg$c8 = peg$classExpectation([" ", "\t", "\f"], false, false), peg$c9 = /^[\n\r]/, peg$c10 = peg$classExpectation(["\n", "\r"], false, false), peg$c11 = function (text) { return text; }, peg$c12 = /^[^\n\r]/, peg$c13 = peg$classExpectation(["\n", "\r"], true, false), peg$c14 = "\n", peg$c15 = peg$literalExpectation("\n", false), peg$c16 = "\r", peg$c17 = peg$literalExpectation("\r", false), peg$c18 = function () { return { type: 'blankline' }; }, peg$c19 = "=begin ", peg$c20 = peg$literalExpectation("=begin ", false), peg$c21 = "=end ", peg$c22 = peg$literalExpectation("=end ", false), peg$c23 = "=for ", peg$c24 = peg$literalExpectation("=for ", false), peg$c25 = "=config", peg$c26 = peg$literalExpectation("=config", false), peg$c27 = "=alias", peg$c28 = peg$literalExpectation("=alias", false), peg$c29 = function (name) { return isSupportedBlockName(name); }, peg$c30 = function (name) { return name; }, peg$c31 = "=", peg$c32 = peg$literalExpectation("=", false), peg$c33 = peg$otherExpectation("text"), peg$c34 = function () { return text(); }, peg$c35 = function () { return { type: "para", value: text(), error: true, location: location() }; }, peg$c36 = function (code, codes) { return flattenDeep([code, codes]); }, peg$c37 = function (code) { return [code]; }, peg$c38 = ",", peg$c39 = peg$literalExpectation(",", false), peg$c40 = function (code, codes) { return flattenDeep([code, codes]); }, peg$c41 = /^[a-zA-Z0-9]/, peg$c42 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false), peg$c43 = /^[a-zA-Z0-9_\-]/, peg$c44 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"], "_", "-"], false, false), peg$c45 = "=>", peg$c46 = peg$literalExpectation("=>", false), peg$c47 = function (name, value) { return { [name]: value }; }, peg$c48 = function (pair, pairs) { return { ...pair, ...pairs }; }, peg$c49 = function (code) { return code; }, peg$c50 = ":", peg$c51 = peg$literalExpectation(":", false), peg$c52 = "allow", peg$c53 = peg$literalExpectation("allow", false), peg$c54 = "<", peg$c55 = peg$literalExpectation("<", false), peg$c56 = ">", peg$c57 = peg$literalExpectation(">", false), peg$c58 = function (key, array) { return { value: array, type: "array" }; }, peg$c59 = function (key, value) { return { name: 'allow', ...value }; }, peg$c60 = function (i) { return i; }, peg$c61 = function (all) { return all; }, peg$c62 = function (res) { return [res]; }, peg$c63 = function () { return []; }, peg$c64 = /^[!]/, peg$c65 = peg$classExpectation(["!"], false, false), peg$c66 = "{", peg$c67 = peg$literalExpectation("{", false), peg$c68 = "}", peg$c69 = peg$literalExpectation("}", false), peg$c70 = function (isFalse, key, hash) { return { value: hash }; }, peg$c71 = "[", peg$c72 = peg$literalExpectation("[", false), peg$c73 = function (isFalse, key, array) { return array; }, peg$c74 = "]", peg$c75 = peg$literalExpectation("]", false), peg$c76 = function (isFalse, key) { return [text()]; }, peg$c77 = function (isFalse, key, array) { return { value: array, type: "array" }; }, peg$c78 = function (isFalse, key, array) { return { value: array, type: "array" }; }, peg$c79 = function (isFalse, key, array) { return { value: array, type: "string" }; }, peg$c80 = "(", peg$c81 = peg$literalExpectation("(", false), peg$c82 = function (isFalse, key, array) { // if one element (23) set type to 'value' return (array.length > 1) ? { type: 'array', value: array } : { type: 'value', value: array[0] }; }, peg$c83 = ")", peg$c84 = peg$literalExpectation(")", false), peg$c85 = function (isFalse, key) { return { value: text() }; }, peg$c86 = function (isFalse, key, res) { return { type: "value", ...res }; }, peg$c87 = function (isFalse, key) { return { value: !isFalse, type: "boolean" }; }, peg$c88 = function (isFalse, key, value) { return { name: key, ...value }; }, peg$c89 = function (first, rest) { return rest; }, peg$c90 = function (first, cont) { return flattenDeep([...first, ...cont]); }, peg$c91 = /^[^'"]/, peg$c92 = peg$classExpectation(["'", "\""], true, false), peg$c93 = function (text) { return text; }, peg$c94 = /^[0-9]/, peg$c95 = peg$classExpectation([["0", "9"]], false, false), peg$c96 = /^[\-+]/, peg$c97 = peg$classExpectation(["-", "+"], false, false), peg$c98 = "True", peg$c99 = peg$literalExpectation("True", false), peg$c100 = function () { return true; }, peg$c101 = "False", peg$c102 = peg$literalExpectation("False", false), peg$c103 = function () { return false; }, peg$c104 = ".", peg$c105 = peg$literalExpectation(".", false), peg$c106 = /^[eE]/, peg$c107 = peg$classExpectation(["e", "E"], false, false), peg$c108 = /^["]/, peg$c109 = peg$classExpectation(["\""], false, false), peg$c110 = /^[^"]/, peg$c111 = peg$classExpectation(["\""], true, false), peg$c112 = /^[']/, peg$c113 = peg$classExpectation(["'"], false, false), peg$c114 = /^[^']/, peg$c115 = peg$classExpectation(["'"], true, false), peg$c116 = function (numberFloat) { return parseFloat(numberFloat); }, peg$c117 = function (number) { return parseInt(number, 10); }, peg$c118 = function (vmargin, name, config) { return ((name.match(/code|comment|formula|output|input|markdown|picture|toc|data/)) || isNamedBlock(name)); }, peg$c119 = function (vmargin, name, config, margins, ename) { return vmargin.length === margins.length && name === ename; }, peg$c120 = function (vmargin, name, config, margins, line) { return exludeVMargin(vmargin, `${margins}${line}`); }, peg$c121 = function (vmargin, name, config, content, vmargin2, ename) { return name === ename; }, peg$c122 = function (vmargin, name, config, content, vmargin2, ename) { const type = 'block'; return { type: type, content: content === "" ? [] : [{ type: 'verbatim', value: content.join('') }], name, margin: vmargin }; }, peg$c123 = function (vmargin, name, config, content, vmargin2, res) { return true || vmargin === vmargin2; }, peg$c124 = function (vmargin, name, config, content, vmargin2, res) { return { ...res, text: text(), config, location: location() }; }, peg$c125 = /^[+-=_|]/, peg$c126 = peg$classExpectation([["+", "="], "_", "|"], false, false), peg$c127 = function () { return { type: 'separator', text: text() }; }, peg$c128 = function () { return options.isDelimited; }, peg$c129 = function () { return { type: 'separator', text: text() }; }, peg$c130 = function (t) { return { name: 'row', type: 'text', value: t }; }, peg$c131 = function () { // reset separator count and its accum options.separators = []; return true; }, peg$c132 = function (head, t) { options.separators.push(t.text); return t; }, peg$c133 = function (head, separator, rowtext, t) { options.separators.push(t.text); return t; }, peg$c134 = function (head, separator, rowtext, bseparator) { return [ { name: 'row', type: 'text', value: rowtext }, bseparator ]; }, peg$c135 = function (head, separator, singleRow) { return [singleRow]; }, peg$c136 = function (head, separator, rest) { // if more then 1 separator and it equal - table doesn't have header if (options.separators.length > 1) { // check if separators equal (for table without header) return !options.separators.every(val => val === options.separators[0]); } return true; }, peg$c137 = function (head, separator, rest) { return [ { name: 'head', type: 'text', value: head }, separator, ...flattenDeep(rest) ]; }, peg$c138 = function (rowtest, bseparator) { return [ { name: 'row', type: 'text', value: rowtest }, bseparator ]; }, peg$c139 = function (rest) { return [...flattenDeep(rest)]; }, peg$c140 = function (vmargin, name, config) { return name === 'table'; }, peg$c141 = function (vmargin, name, config) { options.isDelimited = true; return true; }, peg$c142 = function (vmargin, name, config, t) { return t; }, peg$c143 = function (vmargin, name, config, content, vmargin2, ename) { return { type: 'block', content: content, name, margin: vmargin }; }, peg$c144 = function (vmargin, name, config, content, vmargin2, res) { return { ...res, text: text(), config, location: location() }; }, peg$c145 = function (vmargin, name, config, nodes) { return nodes; }, peg$c146 = function (vmargin, name, config, tvmargin, text) { const type = name.match(/pod|nested|item|code|defn/) && (tvmargin.length - vmargin.length) > 0 ? 'code' : 'para'; return { text, margin: tvmargin, type, content: [ { type: type === 'code' ? 'verbatim' : 'text', value: text } ], location: location(), }; }, peg$c147 = function (vmargin, name, config, content, vmargin2, ename) { return { type: 'block', content, name, margin: vmargin, }; }, peg$c148 = function (vmargin, name, config, content, vmargin2, res) { return { ...res, config, location: location(), }; }, peg$c149 = function () { return { text: text(), type: 'para', margin: '', content: [ { type: 'text', value: text() } ], location: location(), }; }, peg$c150 = function () { return { empty: 1 }; }, peg$c151 = /^[s]/, peg$c152 = peg$classExpectation(["s"], false, false), peg$c153 = function (line) { return { text: text(), type: "ambient1" }; }, peg$c154 = function (vmargin, name) { return ((name.match(/code|comment|formula|output|input|markdown|picture|toc|data/)) || isNamedBlock(name)); }, peg$c155 = function (vmargin, name, content) { return { margin: vmargin, type: 'block', content: content === "" ? [] : [{ type: 'verbatim', value: content }], name, config: [], location: location() }; }, peg$c156 = function (vmargin, name) { return name === 'table'; }, peg$c157 = function (vmargin, name) { options.isDelimited = false; return true; }, peg$c158 = function (vmargin, name, content) { return { margin: vmargin, type: 'block', content: content === "" ? [] : content, name, config: [], location: location() }; }, peg$c159 = function (vmargin, name, first_line, content_rest) { const content = (first_line === "\n" ? "" : first_line) + content_rest; return { margin: vmargin, type: 'block', content: content === "" ? [] : [ { type: 'para', text: content, margin: '', content: [ { type: 'text', value: content } ], location: location(), } ], name, location: location() }; }, peg$c160 = "= ", peg$c161 = peg$literalExpectation("= ", false), peg$c162 = function (vmargin, marker, name, replacement) { return { name, type: 'alias', replacement, margin: vmargin }; }, peg$c163 = /^[A-Z]/, peg$c164 = peg$classExpectation([["A", "Z"]], false, false), peg$c165 = "<>", peg$c166 = peg$literalExpectation("<>", false), peg$c167 = function (vmargin, marker, name, config) { return { name, type: 'config', config, margin: vmargin }; }, peg$c168 = function (vmargin, marker, name, config) { return ((name.match(/code|comment|formula|output|input|markdown|picture|toc|data/)) || isNamedBlock(name)); }, peg$c169 = function (vmargin, marker, name, config, content) { return { type: 'block', content: content === "" ? [] : [{ type: 'verbatim', value: content }], name, margin: vmargin, config, location: location() }; }, peg$c170 = function (vmargin, marker, name, config) { return name === 'table'; }, peg$c171 = function (vmargin, marker, name, config) { options.isDelimited = false; return true; }, peg$c172 = function (vmargin, marker, name, config, content) { return { type: 'block', content: content === "" ? [] : content, name, margin: vmargin, config, location: location() }; }, peg$c173 = function (vmargin, marker, name, config, content) { return { type: 'block', content: content === "" ? [] : [ { type: 'para', content: [ { type: 'text', value: content } ], margin: vmargin, text: content, location: location(), } ], name, margin: vmargin, config, location: location() }; }, peg$c174 = /^[a-zA-Z]/, peg$c175 = peg$classExpectation([["a", "z"], ["A", "Z"]], false, false), peg$c176 = peg$otherExpectation("whitespace"), peg$c177 = /^[\r\n \t\f]/, peg$c178 = peg$classExpectation(["\r", "\n", " ", "\t", "\f"], false, false), peg$c179 = peg$otherExpectation("space characters"), peg$currPos = 0, peg$savedPos = 0, peg$posDetailsCache = [{ line: 1, column: 1 }], peg$maxFailPos = 0, peg$maxFailExpected = [], peg$silentFails = 0, peg$result; if ("startRule" in options) { if (!(options.startRule in peg$startRuleFunctions)) { throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); } peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; } function text() { return input.substring(peg$savedPos, peg$currPos); } function location() { return peg$computeLocation(peg$savedPos, peg$currPos); } function expected(description, location) { location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildStructuredError([peg$otherExpectation(description)], input.substring(peg$savedPos, peg$currPos), location); } function error(message, location) { location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildSimpleError(message, location); } function peg$literalExpectation(text, ignoreCase) { return { type: "literal", text: text, ignoreCase: ignoreCase }; } function peg$classExpectation(parts, inverted, ignoreCase) { return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; } function peg$anyExpectation() { return { type: "any" }; } function peg$endExpectation() { return { type: "end" }; } function peg$otherExpectation(description) { return { type: "other", description: description }; } function peg$computePosDetails(pos) { var details = peg$posDetailsCache[pos], p; if (details) { return details; } else { p = pos - 1; while (!peg$posDetailsCache[p]) { p--; } details = peg$posDetailsCache[p]; details = { line: details.line, column: details.column }; while (p < pos) { if (input.charCodeAt(p) === 10) { details.line++; details.column = 1; } else { details.column++; } p++; } peg$posDetailsCache[pos] = details; return details; } } function peg$computeLocation(startPos, endPos) { var startPosDetails = peg$computePosDetails(startPos), endPosDetails = peg$computePosDetails(endPos); return { start: { offset: startPos, line: startPosDetails.line, column: startPosDetails.column }, end: { offset: endPos, line: endPosDetails.line, column: endPosDetails.column } }; } function peg$fail(expected) { if (peg$currPos < peg$maxFailPos) { return; } if (peg$currPos > peg$maxFailPos) { peg$maxFailPos = peg$currPos; peg$maxFailExpected = []; } peg$maxFailExpected.push(expected); } function peg$buildSimpleError(message, location) { return new peg$SyntaxError(message, null, null, location); } function peg$buildStructuredError(expected, found, location) { return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected, found), expected, found, location); } function peg$parseDocument() { var s0, s1, s2; s0 = peg$currPos; s1 = []; s2 = peg$parseElement(); while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parseElement(); } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c0(s1); } s0 = s1; return s0; } function peg$parseElement() { var s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$parsedelimitedBlockRaw(); if (s0 === peg$FAILED) { s0 = peg$parsedelimitedBlockTable(); if (s0 === peg$FAILED) { s0 = peg$parsedelimitedBlock(); if (s0 === peg$FAILED) { s0 = peg$parseparagraphBlockRaw(); if (s0 === peg$FAILED) { s0 = peg$parseparagraphBlockTable(); if (s0 === peg$FAILED) { s0 = peg$parseparagraphBlock(); if (s0 === peg$FAILED) { s0 = peg$parsealiasDirective(); if (s0 === peg$FAILED) { s0 = peg$parseconfigDirective(); if (s0 === peg$FAILED) { s0 = peg$parseabbreviatedBlockRaw(); if (s0 === peg$FAILED) { s0 = peg$parseabbreviatedBlockTable(); if (s0 === peg$FAILED) { s0 = peg$parseabbreviatedBlock(); if (s0 === peg$FAILED) { s0 = peg$currPos; peg$savedPos = peg$currPos; s1 = peg$c1(); if (s1) { s1 = void 0; } else { s1 = peg$FAILED; } if (s1 !== peg$FAILED) { s2 = peg$parsetextBlock(); if (s2 === peg$FAILED) { s2 = peg$parseblankline(); if (s2 === peg$FAILED) { s2 = peg$parseerror_para(); } } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c2(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$currPos; s2 = []; s3 = peg$currPos; s4 = peg$currPos; peg$silentFails++; s5 = peg$currPos; s6 = peg$parsemarkers(); if (s6 !== peg$FAILED) { s7 = peg$parsestrictIdentifier(); if (s7 !== peg$FAILED) { s6 = [s6, s7]; s5 = s6; } else { peg$currPos = s5; s5 = peg$FAILED; } } else { peg$currPos = s5; s5 = peg$FAILED; } if (s5 === peg$FAILED) { s5 = peg$parsemarkerAbbreviatedBlock(); } peg$silentFails--; if (s5 === peg$FAILED) { s4 = void 0; } else { peg$currPos = s4; s4 = peg$FAILED; } if (s4 !== peg$FAILED) { if (input.length > peg$currPos) { s5 = input.charAt(peg$currPos); peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c3); } } if (s5 !== peg$FAILED) { s4 = [s4, s5]; s3 = s4; } 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$currPos; peg$silentFails++; s5 = peg$currPos; s6 = peg$parsemarkers(); if (s6 !== peg$FAILED) { s7 = peg$parsestrictIdentifier(); if (s7 !== peg$FAILED) { s6 = [s6, s7]; s5 = s6; } else { peg$currPos = s5; s5 = peg$FAILED; } } else { peg$currPos = s5; s5 = peg$FAILED; } if (s5 === peg$FAILED) { s5 = peg$parsemarkerAbbreviatedBlock(); } peg$silentFails--; if (s5 === peg$FAILED) { s4 = void 0; } else { peg$currPos = s4; s4 = peg$FAILED; } if (s4 !== peg$FAILED) { if (input.length > peg$currPos) { s5 = input.charAt(peg$currPos); peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c3); } } if (s5 !== peg$FAILED) { s4 = [s4, s5]; s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } } else { s2 = peg$FAILED; } if (s2 !== peg$FAILED) { s1 = input.substring(s1, peg$currPos); } else { s1 = s2; } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c4(); } s0 = s1; } } } } } } } } } } } } return s0; } function peg$parsehs() { var s0; if (peg$c5.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c6); } } return s0; } function peg$parse_() { var s0, s1; s0 = []; if (peg$c7.test(input.charAt(peg$currPos))) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c8); } } while (s1 !== peg$FAILED) { s0.push(s1); if (peg$c7.test(input.charAt(peg$currPos))) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c8); } } } return s0; } function peg$parseEndline() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$currPos; s2 = []; s3 = peg$parsehs(); while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parsehs(); } if (s2 !== peg$FAILED) { if (peg$c9.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c10); } } if (s3 !== peg$FAILED) { s2 = [s2, s3]; s1 = s2; } else { peg$currPos = s1; s1 = peg$FAILED; } } else { peg$currPos = s1; s1 = peg$FAILED; } if (s1 !== peg$FAILED) { s0 = input.substring(s0, peg$currPos); } else { s0 = s1; } return s0; } function peg$parseLineOfText() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$currPos; s2 = []; s3 = peg$parsechar(); if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parsechar(); } } else { s2 = peg$FAILED; } if (s2 !== peg$FAILED) { s1 = input.substring(s1, peg$currPos); } else { s1 = s2; } if (s1 !== peg$FAILED) { s2 = peg$parseEOL(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c11(s1); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsechar() { var s0; if (peg$c12.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c13); } } return s0; } function peg$parsenewline() { var s0, s1, s2; if (input.charCodeAt(peg$currPos) === 10) { s0 = peg$c14; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c15); } } if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 13) { s1 = peg$c16; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c17); } } if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 10) { s2 = peg$c14; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c15); } } if (s2 === peg$FAILED) { s2 = null; } if (s2 !== peg$FAILED) { s1 = [s1, s2]; s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } return s0; } function peg$parseEOL() { var s0, s1; s0 = peg$parsenewline(); if (s0 === peg$FAILED) { s0 = peg$currPos; peg$silentFails++; if (input.length > peg$currPos) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c3); } } peg$silentFails--; if (s1 === peg$FAILED) { s0 = void 0; } else { peg$currPos = s0; s0 = peg$FAILED; } } return s0; } function peg$parseemptyline() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$currPos; s2 = []; s3 = peg$parsehs(); while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parsehs(); } if (s2 !== peg$FAILED) { if (peg$c9.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c10); } } if (s3 !== peg$FAILED) { s2 = [s2, s3]; s1 = s2; } else { peg$currPos = s1; s1 = peg$FAILED; } } else { peg$currPos = s1; s1 = peg$FAILED; } if (s1 !== peg$FAILED) { s0 = input.substring(s0, peg$currPos); } else { s0 = s1; } return s0; } function peg$parseblankline() { var s0, s1, s2, s3, s4; s0 = peg$currPos; s1 = peg$currPos; s2 = peg$currPos; s3 = []; s4 = peg$parsehs(); while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$parsehs(); } if (s3 !== peg$FAILED) { if (peg$c9.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c10); } } if (s4 !== peg$FAILED) { s3 = [s3, s4]; s2 = s3; } else { peg$currPos = s2; s2 = peg$FAILED; } } else { peg$currPos = s2; s2 = peg$FAILED; } if (s2 !== peg$FAILED) { s1 = input.substring(s1, peg$currPos); } else { s1 = s2; } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c18(); } s0 = s1; return s0; } function peg$parsemarkerBegin() { var s0; if (input.substr(peg$currPos, 7) === peg$c19) { s0 = peg$c19; peg$currPos += 7; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c20); } } return s0; } function peg$parsemarkerEnd() { var s0; if (input.substr(peg$currPos, 5) === peg$c21) { s0 = peg$c21; peg$currPos += 5; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c22); } } return s0; } function peg$parsemarkerFor() { var s0; if (input.substr(peg$currPos, 5) === peg$c23) { s0 = peg$c23; peg$currPos += 5; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c24); } } return s0; } function peg$parsemarkerConfig() { var s0; if (input.substr(peg$currPos, 7) === peg$c25) { s0 = peg$c25; peg$currPos += 7; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c26); } } return s0; } function peg$parsemarkerAlias() { var s0; if (input.substr(peg$currPos, 6) === peg$c27) { s0 = peg$c27; peg$currPos += 6; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c28); } } return s0; } function peg$parsestrictIdentifier() { var s0, s1, s2; s0 = peg$currPos; s1 = peg$parseidentifier(); if (s1 !== peg$FAILED) { peg$savedPos = peg$currPos; s2 = peg$c29(s1); if (s2) { s2 = void 0; } else { s2 = peg$FAILED; } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c30(s1); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsemarkerAbbreviatedBlock() { var s0, s1, s2; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 61) { s1 = peg$c31; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c32); } } if (s1 !== peg$FAILED) { s2 = peg$parsestrictIdentifier(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c30(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsemarkers() { var s0; s0 = peg$parsemarkerBegin(); if (s0 === peg$FAILED) { s0 = peg$parsemarkerEnd(); if (s0 === peg$FAILED) { s0 = peg$parsemarkerFor(); if (s0 === peg$FAILED) { s0 = peg$parsemarkerConfig(); if (s0 === peg$FAILED) { s0 = peg$parsemarkerAlias(); } } } } return s0; } function peg$parseText() { var s0, s1, s2; peg$silentFails++; s0 = peg$currPos; s1 = []; s2 = peg$parsechar(); if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parsechar(); } } else { s1 = peg$FAILED; } if (s1 !== peg$FAILED) { s0 = input.substring(s0, peg$currPos); } else { s0 = s1; } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c33); } } retu