fliphub-monorepo
Version:
the builder of builders
1,466 lines (1,394 loc) • 74 kB
JavaScript
module.exports = (function() {
/*
* Generated by PEG.js 0.8.0.
*
* http://pegjs.majda.cz/
*/
function peg$subclass(child, parent) {
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor();
}
function SyntaxError(message, expected, found, offset, line, column) {
this.message = message;
this.expected = expected;
this.found = found;
this.offset = offset;
this.line = line;
this.column = column;
this.name = "SyntaxError";
}
peg$subclass(SyntaxError, Error);
function parse(input) {
var options = arguments.length > 1 ? arguments[1] : {},
peg$FAILED = {},
peg$startRuleFunctions = { start: peg$parsestart },
peg$startRuleFunction = peg$parsestart,
peg$c0 = peg$FAILED,
peg$c1 = [],
peg$c2 = function(pretext, tags, posttext) {
var val = [];
if (pretext.length > 0) {val.push(pretext);}
tags.forEach(function(tag){
val.push(tag[0]);
})
if (posttext.length > 0) {val.push(posttext);}
return val;
},
peg$c3 = "<",
peg$c4 = { type: "literal", value: "<", description: "\"<\"" },
peg$c5 = void 0,
peg$c6 = /^[^\/]/,
peg$c7 = { type: "class", value: "[^\\/]", description: "[^\\/]" },
peg$c8 = /^[^ >]/,
peg$c9 = { type: "class", value: "[^ >]", description: "[^ >]" },
peg$c10 = ">",
peg$c11 = { type: "literal", value: ">", description: "\">\"" },
peg$c12 = function(tagName, attrs, content, closeTagName) {
var node = {};
tagName = tagName.join('').trim();
if (tagName !== closeTagName) { throw new g._Error('Mismatched Open & Close Tags', null, null, null, g._lineNumber(), g._columnNumber()); }
node.tag = tagName;
if (attrs) {
node.attributes = attrs;
}
if (content) {
if (content instanceof Array) {
node.children = content;
} else {
node.children = [content];
}
}
return node;
},
peg$c13 = function(tagName, attrs, content) {
throw new g._Error('Invalid Empty Tag', null, null, null, g._lineNumber(), g._columnNumber());
},
peg$c14 = "<!",
peg$c15 = { type: "literal", value: "<!", description: "\"<!\"" },
peg$c16 = /^[^\-]/,
peg$c17 = { type: "class", value: "[^\\-]", description: "[^\\-]" },
peg$c18 = /^[^>]/,
peg$c19 = { type: "class", value: "[^>]", description: "[^>]" },
peg$c20 = function(DOCTYPER) {return "<!" + DOCTYPER.join('') + ">";},
peg$c21 = "<![CDATA[",
peg$c22 = { type: "literal", value: "<![CDATA[", description: "\"<![CDATA[\"" },
peg$c23 = "]]>",
peg$c24 = { type: "literal", value: "]]>", description: "\"]]>\"" },
peg$c25 = function(data) {return "<![CDATA[" + data.join('') + "]]>";},
peg$c26 = function(char) {return char;},
peg$c27 = { type: "other", description: "TagClose" },
peg$c28 = "</",
peg$c29 = { type: "literal", value: "</", description: "\"</\"" },
peg$c30 = function(tagCloseName) {return tagCloseName.join('').trim();},
peg$c31 = /^[^ \/>]/,
peg$c32 = { type: "class", value: "[^ \\/>]", description: "[^ \\/>]" },
peg$c33 = "/>",
peg$c34 = { type: "literal", value: "/>", description: "\"/>\"" },
peg$c35 = function(tagName, attrs) {
var node = {};
node.tag = tagName.join('').trim();
if (attrs) {
node.attributes = attrs;
}
return node;
},
peg$c36 = function(tagName, attrs) {
var node = {};
node.tag = tagName;
if (attrs) {
node.attributes = attrs;
}
return node;
},
peg$c37 = "br",
peg$c38 = { type: "literal", value: "br", description: "\"br\"" },
peg$c39 = "hr",
peg$c40 = { type: "literal", value: "hr", description: "\"hr\"" },
peg$c41 = "meta",
peg$c42 = { type: "literal", value: "meta", description: "\"meta\"" },
peg$c43 = "link",
peg$c44 = { type: "literal", value: "link", description: "\"link\"" },
peg$c45 = "base",
peg$c46 = { type: "literal", value: "base", description: "\"base\"" },
peg$c47 = "img",
peg$c48 = { type: "literal", value: "img", description: "\"img\"" },
peg$c49 = "embed",
peg$c50 = { type: "literal", value: "embed", description: "\"embed\"" },
peg$c51 = "param",
peg$c52 = { type: "literal", value: "param", description: "\"param\"" },
peg$c53 = "area",
peg$c54 = { type: "literal", value: "area", description: "\"area\"" },
peg$c55 = "col",
peg$c56 = { type: "literal", value: "col", description: "\"col\"" },
peg$c57 = "input",
peg$c58 = { type: "literal", value: "input", description: "\"input\"" },
peg$c59 = "BR",
peg$c60 = { type: "literal", value: "BR", description: "\"BR\"" },
peg$c61 = "HR",
peg$c62 = { type: "literal", value: "HR", description: "\"HR\"" },
peg$c63 = "META",
peg$c64 = { type: "literal", value: "META", description: "\"META\"" },
peg$c65 = "LINK",
peg$c66 = { type: "literal", value: "LINK", description: "\"LINK\"" },
peg$c67 = "BASE",
peg$c68 = { type: "literal", value: "BASE", description: "\"BASE\"" },
peg$c69 = "IMG",
peg$c70 = { type: "literal", value: "IMG", description: "\"IMG\"" },
peg$c71 = "EMBED",
peg$c72 = { type: "literal", value: "EMBED", description: "\"EMBED\"" },
peg$c73 = "PARAM",
peg$c74 = { type: "literal", value: "PARAM", description: "\"PARAM\"" },
peg$c75 = "AREA",
peg$c76 = { type: "literal", value: "AREA", description: "\"AREA\"" },
peg$c77 = "COL",
peg$c78 = { type: "literal", value: "COL", description: "\"COL\"" },
peg$c79 = "INPUT",
peg$c80 = { type: "literal", value: "INPUT", description: "\"INPUT\"" },
peg$c81 = function(c1, c2) {
var content = [];
//c1 = c1.join('');
if (c1.length > 0) {content.push(c1);}
var tag, text;
c2.forEach(function(chain) {
tag = chain[0];
text = chain[2];
content.push(tag);
if (text.length > 0) {content.push(text);}
})
if (content.length === 0) {return null;}
return content;
},
peg$c82 = function(text) {
if (text.length <= 0) {return null;}
return text;
},
peg$c83 = /^[^<]/,
peg$c84 = { type: "class", value: "[^<]", description: "[^<]" },
peg$c85 = function(s) {
var text = '';
s.forEach(function(match){
if (match) {
if (typeof match === 'string') {
text += match;
}
else {
text += match[0];
}
}
})
return text;
},
peg$c86 = function(chains) {
var attrs = {};
var key, val;
chains.forEach(function(chain){
key = chain[0][0];
val = chain[0][1];
if (key === 'style') {
attrs.style = {};
val.split(';').forEach(function(s){
s = s.split(':');
if (s.length === 2) {
attrs.style[s[0].trim()] = s[1].trim();
}
})
}
else if (key === 'class') {
attrs.class = [];
val.split(' ').forEach(function(className){
className = className.trim();
if (className.length > 0) {
attrs.class.push(className);
}
})
}
else {
attrs[key] = val;
}
})
if (Object.keys(attrs).length === 0) {return null;}
return attrs;
},
peg$c87 = /^[^ =]/,
peg$c88 = { type: "class", value: "[^ =]", description: "[^ =]" },
peg$c89 = function(key, val) {
return [key.join(''), val];
},
peg$c90 = /^[a-zA-Z0-9\-_]/,
peg$c91 = { type: "class", value: "[a-zA-Z0-9\\-_]", description: "[a-zA-Z0-9\\-_]" },
peg$c92 = function(key) {
return [key.join(''), true];
},
peg$c93 = "=\"",
peg$c94 = { type: "literal", value: "=\"", description: "\"=\\\"\"" },
peg$c95 = /^[^"]/,
peg$c96 = { type: "class", value: "[^\"]", description: "[^\"]" },
peg$c97 = "\"",
peg$c98 = { type: "literal", value: "\"", description: "\"\\\"\"" },
peg$c99 = function(val) {return val.join('').trim();},
peg$c100 = "='",
peg$c101 = { type: "literal", value: "='", description: "\"='\"" },
peg$c102 = /^[^']/,
peg$c103 = { type: "class", value: "[^']", description: "[^']" },
peg$c104 = "'",
peg$c105 = { type: "literal", value: "'", description: "\"'\"" },
peg$c106 = "=",
peg$c107 = { type: "literal", value: "=", description: "\"=\"" },
peg$c108 = "false",
peg$c109 = { type: "literal", value: "false", description: "\"false\"" },
peg$c110 = function() {return false;},
peg$c111 = "true",
peg$c112 = { type: "literal", value: "true", description: "\"true\"" },
peg$c113 = function() {return true;},
peg$c114 = { type: "any", description: "any character" },
peg$c115 = { type: "other", description: "whitespace" },
peg$c116 = /^[\t\x0B\f \xA0\uFEFF]/,
peg$c117 = { type: "class", value: "[\\t\\x0B\\f \\xA0\\uFEFF]", description: "[\\t\\x0B\\f \\xA0\\uFEFF]" },
peg$c118 = /^[\n\r\u2028\u2029]/,
peg$c119 = { type: "class", value: "[\\n\\r\\u2028\\u2029]", description: "[\\n\\r\\u2028\\u2029]" },
peg$c120 = "\n",
peg$c121 = { type: "literal", value: "\n", description: "\"\\n\"" },
peg$c122 = "\r\n",
peg$c123 = { type: "literal", value: "\r\n", description: "\"\\r\\n\"" },
peg$c124 = "\r",
peg$c125 = { type: "literal", value: "\r", description: "\"\\r\"" },
peg$c126 = "\u2028",
peg$c127 = { type: "literal", value: "\u2028", description: "\"\\u2028\"" },
peg$c128 = "\u2029",
peg$c129 = { type: "literal", value: "\u2029", description: "\"\\u2029\"" },
peg$c130 = { type: "other", description: "comment" },
peg$c131 = function() {return null;},
peg$c132 = "<!--",
peg$c133 = { type: "literal", value: "<!--", description: "\"<!--\"" },
peg$c134 = "-->",
peg$c135 = { type: "literal", value: "-->", description: "\"-->\"" },
peg$currPos = 0,
peg$reportedPos = 0,
peg$cachedPos = 0,
peg$cachedPosDetails = { line: 1, column: 1, seenCR: false },
peg$maxFailPos = 0,
peg$maxFailExpected = [],
peg$silentFails = 0,
peg$result;
if ("startRule" in options) {
if (!(options.startRule in peg$startRuleFunctions)) {
throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
}
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
}
function text() {
return input.substring(peg$reportedPos, peg$currPos);
}
function offset() {
return peg$reportedPos;
}
function line() {
return peg$computePosDetails(peg$reportedPos).line;
}
function column() {
return peg$computePosDetails(peg$reportedPos).column;
}
function expected(description) {
throw peg$buildException(
null,
[{ type: "other", description: description }],
peg$reportedPos
);
}
function error(message) {
throw peg$buildException(message, null, peg$reportedPos);
}
function peg$computePosDetails(pos) {
function advance(details, startPos, endPos) {
var p, ch;
for (p = startPos; p < endPos; p++) {
ch = input.charAt(p);
if (ch === "\n") {
if (!details.seenCR) { details.line++; }
details.column = 1;
details.seenCR = false;
} else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
details.line++;
details.column = 1;
details.seenCR = true;
} else {
details.column++;
details.seenCR = false;
}
}
}
if (peg$cachedPos !== pos) {
if (peg$cachedPos > pos) {
peg$cachedPos = 0;
peg$cachedPosDetails = { line: 1, column: 1, seenCR: false };
}
advance(peg$cachedPosDetails, peg$cachedPos, pos);
peg$cachedPos = pos;
}
return peg$cachedPosDetails;
}
function peg$fail(expected) {
if (peg$currPos < peg$maxFailPos) { return; }
if (peg$currPos > peg$maxFailPos) {
peg$maxFailPos = peg$currPos;
peg$maxFailExpected = [];
}
peg$maxFailExpected.push(expected);
}
function peg$buildException(message, expected, pos) {
function cleanupExpected(expected) {
var i = 1;
expected.sort(function(a, b) {
if (a.description < b.description) {
return -1;
} else if (a.description > b.description) {
return 1;
} else {
return 0;
}
});
while (i < expected.length) {
if (expected[i - 1] === expected[i]) {
expected.splice(i, 1);
} else {
i++;
}
}
}
function buildMessage(expected, found) {
function stringEscape(s) {
function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }
return s
.replace(/\\/g, '\\\\')
.replace(/"/g, '\\"')
.replace(/\x08/g, '\\b')
.replace(/\t/g, '\\t')
.replace(/\n/g, '\\n')
.replace(/\f/g, '\\f')
.replace(/\r/g, '\\r')
.replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
.replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); })
.replace(/[\u0180-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); })
.replace(/[\u1080-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); });
}
var expectedDescs = new Array(expected.length),
expectedDesc, foundDesc, i;
for (i = 0; i < expected.length; i++) {
expectedDescs[i] = expected[i].description;
}
expectedDesc = expected.length > 1
? expectedDescs.slice(0, -1).join(", ")
+ " or "
+ expectedDescs[expected.length - 1]
: expectedDescs[0];
foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input";
return "Expected " + expectedDesc + " but " + foundDesc + " found.";
}
var posDetails = peg$computePosDetails(pos),
found = pos < input.length ? input.charAt(pos) : null;
if (expected !== null) {
cleanupExpected(expected);
}
return new SyntaxError(
message !== null ? message : buildMessage(expected, found),
expected,
found,
pos,
posDetails.line,
posDetails.column
);
}
function peg$parsestart() {
var s0;
s0 = peg$parseTags();
return s0;
}
function peg$parseTags() {
var s0, s1, s2, s3, s4, s5, s6;
s0 = peg$currPos;
s1 = peg$parse__();
if (s1 !== peg$FAILED) {
s2 = peg$parseNotTagContent();
if (s2 !== peg$FAILED) {
s3 = [];
s4 = peg$currPos;
s5 = peg$parseTag();
if (s5 !== peg$FAILED) {
s6 = peg$parse__();
if (s6 !== peg$FAILED) {
s5 = [s5, s6];
s4 = s5;
} else {
peg$currPos = s4;
s4 = peg$c0;
}
} else {
peg$currPos = s4;
s4 = peg$c0;
}
while (s4 !== peg$FAILED) {
s3.push(s4);
s4 = peg$currPos;
s5 = peg$parseTag();
if (s5 !== peg$FAILED) {
s6 = peg$parse__();
if (s6 !== peg$FAILED) {
s5 = [s5, s6];
s4 = s5;
} else {
peg$currPos = s4;
s4 = peg$c0;
}
} else {
peg$currPos = s4;
s4 = peg$c0;
}
}
if (s3 !== peg$FAILED) {
s4 = peg$parseNotTagContent();
if (s4 !== peg$FAILED) {
s5 = peg$parse__();
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c2(s2, s3, s4);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
return s0;
}
function peg$parseTag() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10;
s0 = peg$parseDoctypeTag();
if (s0 === peg$FAILED) {
s0 = peg$parseEmptyTag();
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 60) {
s1 = peg$c3;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c4); }
}
if (s1 !== peg$FAILED) {
s2 = peg$currPos;
peg$silentFails++;
if (peg$c6.test(input.charAt(peg$currPos))) {
s3 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c7); }
}
peg$silentFails--;
if (s3 !== peg$FAILED) {
peg$currPos = s2;
s2 = peg$c5;
} else {
s2 = peg$c0;
}
if (s2 !== peg$FAILED) {
s3 = peg$parse__();
if (s3 !== peg$FAILED) {
s4 = [];
if (peg$c8.test(input.charAt(peg$currPos))) {
s5 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c9); }
}
if (s5 !== peg$FAILED) {
while (s5 !== peg$FAILED) {
s4.push(s5);
if (peg$c8.test(input.charAt(peg$currPos))) {
s5 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c9); }
}
}
} else {
s4 = peg$c0;
}
if (s4 !== peg$FAILED) {
s5 = peg$parseAttributes();
if (s5 !== peg$FAILED) {
s6 = peg$parse__();
if (s6 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 62) {
s7 = peg$c10;
peg$currPos++;
} else {
s7 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c11); }
}
if (s7 !== peg$FAILED) {
s8 = peg$parse__();
if (s8 !== peg$FAILED) {
s9 = peg$parseTagContent();
if (s9 !== peg$FAILED) {
s10 = peg$parseTagClose();
if (s10 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c12(s4, s5, s9, s10);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
if (s0 === peg$FAILED) {
s0 = peg$parseInvalidEmptyTag();
}
}
}
return s0;
}
function peg$parseInvalidEmptyTag() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 60) {
s1 = peg$c3;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c4); }
}
if (s1 !== peg$FAILED) {
s2 = peg$currPos;
peg$silentFails++;
if (peg$c6.test(input.charAt(peg$currPos))) {
s3 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c7); }
}
peg$silentFails--;
if (s3 !== peg$FAILED) {
peg$currPos = s2;
s2 = peg$c5;
} else {
s2 = peg$c0;
}
if (s2 !== peg$FAILED) {
s3 = peg$parse__();
if (s3 !== peg$FAILED) {
s4 = [];
if (peg$c8.test(input.charAt(peg$currPos))) {
s5 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c9); }
}
if (s5 !== peg$FAILED) {
while (s5 !== peg$FAILED) {
s4.push(s5);
if (peg$c8.test(input.charAt(peg$currPos))) {
s5 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c9); }
}
}
} else {
s4 = peg$c0;
}
if (s4 !== peg$FAILED) {
s5 = peg$parseAttributes();
if (s5 !== peg$FAILED) {
s6 = peg$parse__();
if (s6 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 62) {
s7 = peg$c10;
peg$currPos++;
} else {
s7 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c11); }
}
if (s7 !== peg$FAILED) {
s8 = peg$parse__();
if (s8 !== peg$FAILED) {
s9 = peg$parseTagContent();
if (s9 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c13(s4, s5, s9);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
return s0;
}
function peg$parseDoctypeTag() {
var s0, s1, s2, s3, s4;
s0 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c14) {
s1 = peg$c14;
peg$currPos += 2;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c15); }
}
if (s1 !== peg$FAILED) {
s2 = peg$currPos;
peg$silentFails++;
if (peg$c16.test(input.charAt(peg$currPos))) {
s3 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c17); }
}
peg$silentFails--;
if (s3 !== peg$FAILED) {
peg$currPos = s2;
s2 = peg$c5;
} else {
s2 = peg$c0;
}
if (s2 !== peg$FAILED) {
s3 = [];
if (peg$c18.test(input.charAt(peg$currPos))) {
s4 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c19); }
}
if (s4 !== peg$FAILED) {
while (s4 !== peg$FAILED) {
s3.push(s4);
if (peg$c18.test(input.charAt(peg$currPos))) {
s4 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c19); }
}
}
} else {
s3 = peg$c0;
}
if (s3 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 62) {
s4 = peg$c10;
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c11); }
}
if (s4 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c20(s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
return s0;
}
function peg$parseCData() {
var s0, s1, s2, s3;
s0 = peg$currPos;
if (input.substr(peg$currPos, 9) === peg$c21) {
s1 = peg$c21;
peg$currPos += 9;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c22); }
}
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parseCDataSourceChar();
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parseCDataSourceChar();
}
if (s2 !== peg$FAILED) {
if (input.substr(peg$currPos, 3) === peg$c23) {
s3 = peg$c23;
peg$currPos += 3;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c24); }
}
if (s3 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c25(s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
return s0;
}
function peg$parseCDataSourceChar() {
var s0, s1, s2;
s0 = peg$currPos;
s1 = peg$currPos;
peg$silentFails++;
if (input.substr(peg$currPos, 3) === peg$c23) {
s2 = peg$c23;
peg$currPos += 3;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c24); }
}
peg$silentFails--;
if (s2 === peg$FAILED) {
s1 = peg$c5;
} else {
peg$currPos = s1;
s1 = peg$c0;
}
if (s1 !== peg$FAILED) {
s2 = peg$parseSourceCharacter();
if (s2 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c26(s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
return s0;
}
function peg$parseTagClose() {
var s0, s1, s2, s3, s4, s5;
peg$silentFails++;
s0 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c28) {
s1 = peg$c28;
peg$currPos += 2;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c29); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parse__();
if (s2 !== peg$FAILED) {
s3 = [];
if (peg$c8.test(input.charAt(peg$currPos))) {
s4 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c9); }
}
if (s4 !== peg$FAILED) {
while (s4 !== peg$FAILED) {
s3.push(s4);
if (peg$c8.test(input.charAt(peg$currPos))) {
s4 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c9); }
}
}
} else {
s3 = peg$c0;
}
if (s3 !== peg$FAILED) {
s4 = peg$parse__();
if (s4 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 62) {
s5 = peg$c10;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c11); }
}
if (s5 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c30(s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c27); }
}
return s0;
}
function peg$parseEmptyTag() {
var s0, s1, s2, s3, s4, s5, s6, s7;
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 60) {
s1 = peg$c3;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c4); }
}
if (s1 !== peg$FAILED) {
s2 = peg$currPos;
peg$silentFails++;
if (peg$c6.test(input.charAt(peg$currPos))) {
s3 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c7); }
}
peg$silentFails--;
if (s3 !== peg$FAILED) {
peg$currPos = s2;
s2 = peg$c5;
} else {
s2 = peg$c0;
}
if (s2 !== peg$FAILED) {
s3 = peg$parse__();
if (s3 !== peg$FAILED) {
s4 = [];
if (peg$c31.test(input.charAt(peg$currPos))) {
s5 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c32); }
}
if (s5 !== peg$FAILED) {
while (s5 !== peg$FAILED) {
s4.push(s5);
if (peg$c31.test(input.charAt(peg$currPos))) {
s5 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c32); }
}
}
} else {
s4 = peg$c0;
}
if (s4 !== peg$FAILED) {
s5 = peg$parseAttributes();
if (s5 !== peg$FAILED) {
s6 = peg$parse__();
if (s6 !== peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c33) {
s7 = peg$c33;
peg$currPos += 2;
} else {
s7 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c34); }
}
if (s7 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c35(s4, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 60) {
s1 = peg$c3;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c4); }
}
if (s1 !== peg$FAILED) {
s2 = peg$currPos;
peg$silentFails++;
if (peg$c6.test(input.charAt(peg$currPos))) {
s3 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c7); }
}
peg$silentFails--;
if (s3 !== peg$FAILED) {
peg$currPos = s2;
s2 = peg$c5;
} else {
s2 = peg$c0;
}
if (s2 !== peg$FAILED) {
s3 = peg$parse__();
if (s3 !== peg$FAILED) {
s4 = peg$parseEmptyTagName();
if (s4 !== peg$FAILED) {
s5 = peg$parseAttributes();
if (s5 !== peg$FAILED) {
s6 = peg$parse__();
if (s6 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 62) {
s7 = peg$c10;
peg$currPos++;
} else {
s7 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c11); }
}
if (s7 !== peg$FAILED) {
peg$reportedPos = s0;
s1 = peg$c36(s4, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
} else {
peg$currPos = s0;
s0 = peg$c0;
}
}
return s0;
}
function peg$parseEmptyTagName() {
var s0;
if (input.substr(peg$currPos, 2) === peg$c37) {
s0 = peg$c37;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c38); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c39) {
s0 = peg$c39;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c40); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 4) === peg$c41) {
s0 = peg$c41;
peg$currPos += 4;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c42); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 4) === peg$c43) {
s0 = peg$c43;
peg$currPos += 4;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c44); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 4) === peg$c45) {
s0 = peg$c45;
peg$currPos += 4;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c46); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 4) === peg$c41) {
s0 = peg$c41;
peg$currPos += 4;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c42); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 3) === peg$c47) {
s0 = peg$c47;
peg$currPos += 3;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c48); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 5) === peg$c49) {
s0 = peg$c49;
peg$currPos += 5;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c50); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 5) === peg$c51) {
s0 = peg$c51;
peg$currPos += 5;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c52); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 4) === peg$c53) {
s0 = peg$c53;
peg$currPos += 4;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c54); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 3) === peg$c55) {
s0 = peg$c55;
peg$currPos += 3;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c56); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 5) === peg$c57) {
s0 = peg$c57;
peg$currPos += 5;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c58); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c59) {
s0 = peg$c59;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c60); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c61) {
s0 = peg$c61;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c62); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 4) === peg$c63) {
s0 = peg$c63;
peg$currPos += 4;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c64); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 4) === peg$c65) {
s0 = peg$c65;
peg$currPos += 4;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c66); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 4) === peg$c67) {
s0 = peg$c67;
peg$currPos += 4;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c68); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 4) === peg$c63) {
s0 = peg$c63;
peg$currPos += 4;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c64); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 3) === peg$c69) {
s0 = peg$c69;
peg$currPos += 3;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c70); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 5) === peg$c71) {
s0 = peg$c71;
peg$currPos += 5;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c72); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 5) === peg$c73) {
s0 = peg$c73;
peg$currPos += 5;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c74); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 4) === peg$c75) {
s0 = peg$c75;
peg$currPos += 4;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c76); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 3) === peg$c77) {
s0 = peg$c77;
peg$currPos += 3;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c78); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 5) === peg$c79) {
s0 = peg$c79;
peg$currPos += 5;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c80); }
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return s0;
}
function peg$parseTagContent() {
var s0, s1, s2, s3, s4, s5, s6;
s0 = peg$currPos;
s1 = peg$parseNotTagContent();
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$currPos;
s4 = peg$parseTag();
if (s4 !== peg$FAILED) {
s5 = peg$parse__();
if (s5 !== peg$FAILED) {
s6 = peg$parseNotTagContent();
if (s6 !== peg$FAILED) {
s4 = [s4, s5, s6];
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$c0;
}
} else {
peg$currPos = s3;
s3 = peg$c0;
}
} else {
peg$currPos = s3;
s3 = peg$c0;
}
if (s3 !== peg$FAILED) {
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$currPos;
s4 = peg$parseTag();
if (s4 !== peg$FAILED) {
s5 = peg$parse__();
if (s5 !== peg$FAILED) {
s6 = peg$parseNotTagContent();
if (s6 !== peg$FAILED) {
s4 = [s4, s5, s6];
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$c0;
}
} else {
peg$currPos = s3;
s3 = peg$c0;
}
} else {
peg$currPos = s3;
s3 = peg$c0;
}
}
} else {
s2 = peg$c0;
}
if (s2 !== peg$