2013-06-10 22:55:27 +00:00
|
|
|
module.exports = (function() {
|
|
|
|
/*
|
|
|
|
* Generated by PEG.js 0.7.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(expected, found, offset, line, column) {
|
|
|
|
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 expectedDesc, foundDesc;
|
|
|
|
|
|
|
|
switch (expected.length) {
|
|
|
|
case 0:
|
|
|
|
expectedDesc = "end of input";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
expectedDesc = expected[0];
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
expectedDesc = expected.slice(0, -1).join(", ")
|
|
|
|
+ " or "
|
|
|
|
+ expected[expected.length - 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input";
|
|
|
|
|
|
|
|
return "Expected " + expectedDesc + " but " + foundDesc + " found.";
|
|
|
|
}
|
|
|
|
|
|
|
|
this.expected = expected;
|
|
|
|
this.found = found;
|
|
|
|
this.offset = offset;
|
|
|
|
this.line = line;
|
|
|
|
this.column = column;
|
|
|
|
|
|
|
|
this.name = "SyntaxError";
|
|
|
|
this.message = buildMessage(expected, found);
|
|
|
|
}
|
|
|
|
|
|
|
|
peg$subclass(SyntaxError, Error);
|
|
|
|
|
|
|
|
function parse(input) {
|
|
|
|
var options = arguments.length > 1 ? arguments[1] : {},
|
|
|
|
|
|
|
|
peg$startRuleFunctions = { document: peg$parsedocument },
|
|
|
|
peg$startRuleFunction = peg$parsedocument,
|
|
|
|
|
|
|
|
peg$c0 = [],
|
|
|
|
peg$c1 = function(ps) { return { unit: "block", name: "document", content: ps }; },
|
|
|
|
peg$c2 = "tag_start",
|
|
|
|
peg$c3 = null,
|
|
|
|
peg$c4 = ":",
|
|
|
|
peg$c5 = "\":\"",
|
2013-06-11 16:05:32 +00:00
|
|
|
peg$c6 = function(b, n) { return is_valid_block_type(b); },
|
|
|
|
peg$c7 = "",
|
|
|
|
peg$c8 = function(b, n) { return {type: b, name: n }; },
|
|
|
|
peg$c9 = "/",
|
|
|
|
peg$c10 = "\"/\"",
|
|
|
|
peg$c11 = "tagname",
|
|
|
|
peg$c12 = /^[a-zA-Z]/,
|
|
|
|
peg$c13 = "[a-zA-Z]",
|
|
|
|
peg$c14 = function(t) { return t.join(''); },
|
|
|
|
peg$c15 = /^[a-zA-Z:\/]/,
|
|
|
|
peg$c16 = "[a-zA-Z:\\/]",
|
|
|
|
peg$c17 = "{",
|
|
|
|
peg$c18 = "\"{\"",
|
|
|
|
peg$c19 = "}",
|
|
|
|
peg$c20 = "\"}\"",
|
|
|
|
peg$c21 = "\n",
|
|
|
|
peg$c22 = "\"\\n\"",
|
|
|
|
peg$c23 = "\r\n",
|
|
|
|
peg$c24 = "\"\\r\\n\"",
|
|
|
|
peg$c25 = "\r",
|
|
|
|
peg$c26 = "\"\\r\"",
|
|
|
|
peg$c27 = "\u2028",
|
|
|
|
peg$c28 = "\"\\u2028\"",
|
|
|
|
peg$c29 = "\u2029",
|
|
|
|
peg$c30 = "\"\\u2029\"",
|
|
|
|
peg$c31 = "any character",
|
|
|
|
peg$c32 = function(c) {return c},
|
|
|
|
peg$c33 = function(bs) { return { unit: 'text', content: bs.join('') } },
|
|
|
|
peg$c34 = "variable",
|
|
|
|
peg$c35 = function(t) { return { unit: 'variable', name: t }; },
|
|
|
|
peg$c36 = function(t, ps, n) { return (t.type == n.type) && (t.name == n.name) },
|
|
|
|
peg$c37 = function(t, ps, n) { return {unit: 'block', type:t.type, name:t.name, content: ps } },
|
2013-06-10 22:55:27 +00:00
|
|
|
|
|
|
|
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 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$cleanupExpected(expected) {
|
|
|
|
var i = 0;
|
|
|
|
|
|
|
|
expected.sort();
|
|
|
|
|
|
|
|
while (i < expected.length) {
|
|
|
|
if (expected[i - 1] === expected[i]) {
|
|
|
|
expected.splice(i, 1);
|
|
|
|
} else {
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function peg$parsedocument() {
|
|
|
|
var s0, s1, s2;
|
|
|
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
s1 = [];
|
|
|
|
s2 = peg$parsepart();
|
|
|
|
while (s2 !== null) {
|
|
|
|
s1.push(s2);
|
|
|
|
s2 = peg$parsepart();
|
|
|
|
}
|
|
|
|
if (s1 !== null) {
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
s1 = peg$c1(s1);
|
|
|
|
}
|
|
|
|
if (s1 === null) {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = s1;
|
|
|
|
} else {
|
|
|
|
s0 = s1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return s0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function peg$parsepart() {
|
|
|
|
var s0;
|
|
|
|
|
|
|
|
s0 = peg$parseblock();
|
|
|
|
if (s0 === null) {
|
|
|
|
s0 = peg$parsevariable();
|
|
|
|
if (s0 === null) {
|
|
|
|
s0 = peg$parsetext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return s0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function peg$parsetag_start() {
|
2013-06-11 16:05:32 +00:00
|
|
|
var s0, s1, s2, s3, s4, s5, s6;
|
2013-06-10 22:55:27 +00:00
|
|
|
|
|
|
|
peg$silentFails++;
|
|
|
|
s0 = peg$currPos;
|
|
|
|
s1 = peg$parseld();
|
|
|
|
if (s1 !== null) {
|
|
|
|
s2 = peg$parsetagname();
|
|
|
|
if (s2 !== null) {
|
|
|
|
if (input.charCodeAt(peg$currPos) === 58) {
|
|
|
|
s3 = peg$c4;
|
|
|
|
peg$currPos++;
|
|
|
|
} else {
|
|
|
|
s3 = null;
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c5); }
|
|
|
|
}
|
|
|
|
if (s3 !== null) {
|
|
|
|
s4 = peg$parsetagname();
|
|
|
|
if (s4 !== null) {
|
|
|
|
s5 = peg$parserd();
|
|
|
|
if (s5 !== null) {
|
2013-06-11 16:05:32 +00:00
|
|
|
peg$reportedPos = peg$currPos;
|
|
|
|
s6 = peg$c6(s2,s4);
|
|
|
|
if (s6) {
|
|
|
|
s6 = peg$c7;
|
2013-06-10 22:55:27 +00:00
|
|
|
} else {
|
2013-06-11 16:05:32 +00:00
|
|
|
s6 = peg$c3;
|
|
|
|
}
|
|
|
|
if (s6 !== null) {
|
|
|
|
peg$reportedPos = s0;
|
|
|
|
s1 = peg$c8(s2,s4);
|
|
|
|
if (s1 === null) {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = s1;
|
|
|
|
} else {
|
|
|
|
s0 = s1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = peg$c3;
|
2013-06-10 22:55:27 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = peg$c3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = peg$c3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = peg$c3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = peg$c3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = peg$c3;
|
|
|
|
}
|
|
|
|
peg$silentFails--;
|
|
|
|
if (s0 === null) {
|
|
|
|
s1 = null;
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c2); }
|
|
|
|
}
|
|
|
|
|
|
|
|
return s0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function peg$parsetag_end() {
|
|
|
|
var s0, s1, s2, s3, s4, s5, s6;
|
|
|
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
s1 = peg$parseld();
|
|
|
|
if (s1 !== null) {
|
|
|
|
if (input.charCodeAt(peg$currPos) === 47) {
|
2013-06-11 16:05:32 +00:00
|
|
|
s2 = peg$c9;
|
2013-06-10 22:55:27 +00:00
|
|
|
peg$currPos++;
|
|
|
|
} else {
|
|
|
|
s2 = null;
|
2013-06-11 16:05:32 +00:00
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c10); }
|
2013-06-10 22:55:27 +00:00
|
|
|
}
|
|
|
|
if (s2 !== null) {
|
|
|
|
s3 = peg$parsetagname();
|
|
|
|
if (s3 !== null) {
|
|
|
|
if (input.charCodeAt(peg$currPos) === 58) {
|
|
|
|
s4 = peg$c4;
|
|
|
|
peg$currPos++;
|
|
|
|
} else {
|
|
|
|
s4 = null;
|
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c5); }
|
|
|
|
}
|
|
|
|
if (s4 !== null) {
|
|
|
|
s5 = peg$parsetagname();
|
|
|
|
if (s5 !== null) {
|
|
|
|
s6 = peg$parserd();
|
|
|
|
if (s6 !== null) {
|
|
|
|
peg$reportedPos = s0;
|
2013-06-11 16:05:32 +00:00
|
|
|
s1 = peg$c8(s3,s5);
|
2013-06-10 22:55:27 +00:00
|
|
|
if (s1 === null) {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = s1;
|
|
|
|
} else {
|
|
|
|
s0 = s1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = peg$c3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = peg$c3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = peg$c3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = peg$c3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = peg$c3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = peg$c3;
|
|
|
|
}
|
|
|
|
|
|
|
|
return s0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function peg$parsetagname() {
|
|
|
|
var s0, s1, s2;
|
|
|
|
|
|
|
|
peg$silentFails++;
|
|
|
|
s0 = peg$currPos;
|
|
|
|
s1 = [];
|
2013-06-11 16:05:32 +00:00
|
|
|
if (peg$c12.test(input.charAt(peg$currPos))) {
|
2013-06-10 22:55:27 +00:00
|
|
|
s2 = input.charAt(peg$currPos);
|
|
|
|
peg$currPos++;
|
|
|
|
} else {
|
|
|
|
s2 = null;
|
2013-06-11 16:05:32 +00:00
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c13); }
|
2013-06-10 22:55:27 +00:00
|
|
|
}
|
|
|
|
if (s2 !== null) {
|
|
|
|
while (s2 !== null) {
|
|
|
|
s1.push(s2);
|
2013-06-11 16:05:32 +00:00
|
|
|
if (peg$c12.test(input.charAt(peg$currPos))) {
|
2013-06-10 22:55:27 +00:00
|
|
|
s2 = input.charAt(peg$currPos);
|
|
|
|
peg$currPos++;
|
|
|
|
} else {
|
|
|
|
s2 = null;
|
2013-06-11 16:05:32 +00:00
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c13); }
|
2013-06-10 22:55:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
s1 = peg$c3;
|
|
|
|
}
|
|
|
|
if (s1 !== null) {
|
|
|
|
peg$reportedPos = s0;
|
2013-06-11 16:05:32 +00:00
|
|
|
s1 = peg$c14(s1);
|
2013-06-10 22:55:27 +00:00
|
|
|
}
|
|
|
|
if (s1 === null) {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = s1;
|
|
|
|
} else {
|
|
|
|
s0 = s1;
|
|
|
|
}
|
|
|
|
peg$silentFails--;
|
|
|
|
if (s0 === null) {
|
|
|
|
s1 = null;
|
2013-06-11 16:05:32 +00:00
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c11); }
|
2013-06-10 22:55:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return s0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function peg$parsetag() {
|
|
|
|
var s0, s1, s2, s3, s4, s5, s6;
|
|
|
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
s1 = peg$parseld();
|
|
|
|
if (s1 !== null) {
|
|
|
|
s2 = [];
|
|
|
|
s3 = peg$currPos;
|
|
|
|
s4 = peg$currPos;
|
|
|
|
peg$silentFails++;
|
|
|
|
s5 = peg$parserd();
|
|
|
|
peg$silentFails--;
|
|
|
|
if (s5 === null) {
|
2013-06-11 16:05:32 +00:00
|
|
|
s4 = peg$c7;
|
2013-06-10 22:55:27 +00:00
|
|
|
} else {
|
|
|
|
peg$currPos = s4;
|
|
|
|
s4 = peg$c3;
|
|
|
|
}
|
|
|
|
if (s4 !== null) {
|
|
|
|
s5 = peg$currPos;
|
|
|
|
peg$silentFails++;
|
|
|
|
s6 = peg$parseeol();
|
|
|
|
peg$silentFails--;
|
|
|
|
if (s6 === null) {
|
2013-06-11 16:05:32 +00:00
|
|
|
s5 = peg$c7;
|
2013-06-10 22:55:27 +00:00
|
|
|
} else {
|
|
|
|
peg$currPos = s5;
|
|
|
|
s5 = peg$c3;
|
|
|
|
}
|
|
|
|
if (s5 !== null) {
|
2013-06-11 16:05:32 +00:00
|
|
|
if (peg$c15.test(input.charAt(peg$currPos))) {
|
2013-06-10 22:55:27 +00:00
|
|
|
s6 = input.charAt(peg$currPos);
|
|
|
|
peg$currPos++;
|
|
|
|
} else {
|
|
|
|
s6 = null;
|
2013-06-11 16:05:32 +00:00
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c16); }
|
2013-06-10 22:55:27 +00:00
|
|
|
}
|
|
|
|
if (s6 !== null) {
|
|
|
|
s4 = [s4, s5, s6];
|
|
|
|
s3 = s4;
|
|
|
|
} else {
|
|
|
|
peg$currPos = s3;
|
|
|
|
s3 = peg$c3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s3;
|
|
|
|
s3 = peg$c3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s3;
|
|
|
|
s3 = peg$c3;
|
|
|
|
}
|
|
|
|
if (s3 !== null) {
|
|
|
|
while (s3 !== null) {
|
|
|
|
s2.push(s3);
|
|
|
|
s3 = peg$currPos;
|
|
|
|
s4 = peg$currPos;
|
|
|
|
peg$silentFails++;
|
|
|
|
s5 = peg$parserd();
|
|
|
|
peg$silentFails--;
|
|
|
|
if (s5 === null) {
|
2013-06-11 16:05:32 +00:00
|
|
|
s4 = peg$c7;
|
2013-06-10 22:55:27 +00:00
|
|
|
} else {
|
|
|
|
peg$currPos = s4;
|
|
|
|
s4 = peg$c3;
|
|
|
|
}
|
|
|
|
if (s4 !== null) {
|
|
|
|
s5 = peg$currPos;
|
|
|
|
peg$silentFails++;
|
|
|
|
s6 = peg$parseeol();
|
|
|
|
peg$silentFails--;
|
|
|
|
if (s6 === null) {
|
2013-06-11 16:05:32 +00:00
|
|
|
s5 = peg$c7;
|
2013-06-10 22:55:27 +00:00
|
|
|
} else {
|
|
|
|
peg$currPos = s5;
|
|
|
|
s5 = peg$c3;
|
|
|
|
}
|
|
|
|
if (s5 !== null) {
|
2013-06-11 16:05:32 +00:00
|
|
|
if (peg$c15.test(input.charAt(peg$currPos))) {
|
2013-06-10 22:55:27 +00:00
|
|
|
s6 = input.charAt(peg$currPos);
|
|
|
|
peg$currPos++;
|
|
|
|
} else {
|
|
|
|
s6 = null;
|
2013-06-11 16:05:32 +00:00
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c16); }
|
2013-06-10 22:55:27 +00:00
|
|
|
}
|
|
|
|
if (s6 !== null) {
|
|
|
|
s4 = [s4, s5, s6];
|
|
|
|
s3 = s4;
|
|
|
|
} else {
|
|
|
|
peg$currPos = s3;
|
|
|
|
s3 = peg$c3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s3;
|
|
|
|
s3 = peg$c3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s3;
|
|
|
|
s3 = peg$c3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
s2 = peg$c3;
|
|
|
|
}
|
|
|
|
if (s2 !== null) {
|
|
|
|
s3 = peg$parserd();
|
|
|
|
if (s3 !== null) {
|
|
|
|
s1 = [s1, s2, s3];
|
|
|
|
s0 = s1;
|
|
|
|
} else {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = peg$c3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = peg$c3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = peg$c3;
|
|
|
|
}
|
|
|
|
|
|
|
|
return s0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function peg$parseld() {
|
|
|
|
var s0;
|
|
|
|
|
|
|
|
if (input.charCodeAt(peg$currPos) === 123) {
|
2013-06-11 16:05:32 +00:00
|
|
|
s0 = peg$c17;
|
2013-06-10 22:55:27 +00:00
|
|
|
peg$currPos++;
|
|
|
|
} else {
|
|
|
|
s0 = null;
|
2013-06-11 16:05:32 +00:00
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c18); }
|
2013-06-10 22:55:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return s0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function peg$parserd() {
|
|
|
|
var s0;
|
|
|
|
|
|
|
|
if (input.charCodeAt(peg$currPos) === 125) {
|
2013-06-11 16:05:32 +00:00
|
|
|
s0 = peg$c19;
|
2013-06-10 22:55:27 +00:00
|
|
|
peg$currPos++;
|
|
|
|
} else {
|
|
|
|
s0 = null;
|
2013-06-11 16:05:32 +00:00
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c20); }
|
2013-06-10 22:55:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return s0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function peg$parseeol() {
|
|
|
|
var s0;
|
|
|
|
|
|
|
|
if (input.charCodeAt(peg$currPos) === 10) {
|
2013-06-11 16:05:32 +00:00
|
|
|
s0 = peg$c21;
|
2013-06-10 22:55:27 +00:00
|
|
|
peg$currPos++;
|
|
|
|
} else {
|
|
|
|
s0 = null;
|
2013-06-11 16:05:32 +00:00
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c22); }
|
2013-06-10 22:55:27 +00:00
|
|
|
}
|
|
|
|
if (s0 === null) {
|
2013-06-11 16:05:32 +00:00
|
|
|
if (input.substr(peg$currPos, 2) === peg$c23) {
|
|
|
|
s0 = peg$c23;
|
2013-06-10 22:55:27 +00:00
|
|
|
peg$currPos += 2;
|
|
|
|
} else {
|
|
|
|
s0 = null;
|
2013-06-11 16:05:32 +00:00
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c24); }
|
2013-06-10 22:55:27 +00:00
|
|
|
}
|
|
|
|
if (s0 === null) {
|
|
|
|
if (input.charCodeAt(peg$currPos) === 13) {
|
2013-06-11 16:05:32 +00:00
|
|
|
s0 = peg$c25;
|
2013-06-10 22:55:27 +00:00
|
|
|
peg$currPos++;
|
|
|
|
} else {
|
|
|
|
s0 = null;
|
2013-06-11 16:05:32 +00:00
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c26); }
|
2013-06-10 22:55:27 +00:00
|
|
|
}
|
|
|
|
if (s0 === null) {
|
|
|
|
if (input.charCodeAt(peg$currPos) === 8232) {
|
2013-06-11 16:05:32 +00:00
|
|
|
s0 = peg$c27;
|
2013-06-10 22:55:27 +00:00
|
|
|
peg$currPos++;
|
|
|
|
} else {
|
|
|
|
s0 = null;
|
2013-06-11 16:05:32 +00:00
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c28); }
|
2013-06-10 22:55:27 +00:00
|
|
|
}
|
|
|
|
if (s0 === null) {
|
|
|
|
if (input.charCodeAt(peg$currPos) === 8233) {
|
2013-06-11 16:05:32 +00:00
|
|
|
s0 = peg$c29;
|
2013-06-10 22:55:27 +00:00
|
|
|
peg$currPos++;
|
|
|
|
} else {
|
|
|
|
s0 = null;
|
2013-06-11 16:05:32 +00:00
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c30); }
|
2013-06-10 22:55:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return s0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function peg$parsetext() {
|
|
|
|
var s0, s1, s2, s3, s4;
|
|
|
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
s1 = [];
|
|
|
|
s2 = peg$currPos;
|
|
|
|
s3 = peg$currPos;
|
|
|
|
peg$silentFails++;
|
|
|
|
s4 = peg$parsetag();
|
|
|
|
peg$silentFails--;
|
|
|
|
if (s4 === null) {
|
2013-06-11 16:05:32 +00:00
|
|
|
s3 = peg$c7;
|
2013-06-10 22:55:27 +00:00
|
|
|
} else {
|
|
|
|
peg$currPos = s3;
|
|
|
|
s3 = peg$c3;
|
|
|
|
}
|
|
|
|
if (s3 !== null) {
|
|
|
|
if (input.length > peg$currPos) {
|
|
|
|
s4 = input.charAt(peg$currPos);
|
|
|
|
peg$currPos++;
|
|
|
|
} else {
|
|
|
|
s4 = null;
|
2013-06-11 16:05:32 +00:00
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c31); }
|
2013-06-10 22:55:27 +00:00
|
|
|
}
|
|
|
|
if (s4 !== null) {
|
|
|
|
peg$reportedPos = s2;
|
2013-06-11 16:05:32 +00:00
|
|
|
s3 = peg$c32(s4);
|
2013-06-10 22:55:27 +00:00
|
|
|
if (s3 === null) {
|
|
|
|
peg$currPos = s2;
|
|
|
|
s2 = s3;
|
|
|
|
} else {
|
|
|
|
s2 = s3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s2;
|
|
|
|
s2 = peg$c3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s2;
|
|
|
|
s2 = peg$c3;
|
|
|
|
}
|
|
|
|
if (s2 !== null) {
|
|
|
|
while (s2 !== null) {
|
|
|
|
s1.push(s2);
|
|
|
|
s2 = peg$currPos;
|
|
|
|
s3 = peg$currPos;
|
|
|
|
peg$silentFails++;
|
|
|
|
s4 = peg$parsetag();
|
|
|
|
peg$silentFails--;
|
|
|
|
if (s4 === null) {
|
2013-06-11 16:05:32 +00:00
|
|
|
s3 = peg$c7;
|
2013-06-10 22:55:27 +00:00
|
|
|
} else {
|
|
|
|
peg$currPos = s3;
|
|
|
|
s3 = peg$c3;
|
|
|
|
}
|
|
|
|
if (s3 !== null) {
|
|
|
|
if (input.length > peg$currPos) {
|
|
|
|
s4 = input.charAt(peg$currPos);
|
|
|
|
peg$currPos++;
|
|
|
|
} else {
|
|
|
|
s4 = null;
|
2013-06-11 16:05:32 +00:00
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c31); }
|
2013-06-10 22:55:27 +00:00
|
|
|
}
|
|
|
|
if (s4 !== null) {
|
|
|
|
peg$reportedPos = s2;
|
2013-06-11 16:05:32 +00:00
|
|
|
s3 = peg$c32(s4);
|
2013-06-10 22:55:27 +00:00
|
|
|
if (s3 === null) {
|
|
|
|
peg$currPos = s2;
|
|
|
|
s2 = s3;
|
|
|
|
} else {
|
|
|
|
s2 = s3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s2;
|
|
|
|
s2 = peg$c3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s2;
|
|
|
|
s2 = peg$c3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
s1 = peg$c3;
|
|
|
|
}
|
|
|
|
if (s1 !== null) {
|
|
|
|
peg$reportedPos = s0;
|
2013-06-11 16:05:32 +00:00
|
|
|
s1 = peg$c33(s1);
|
2013-06-10 22:55:27 +00:00
|
|
|
}
|
|
|
|
if (s1 === null) {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = s1;
|
|
|
|
} else {
|
|
|
|
s0 = s1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return s0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function peg$parsevariable() {
|
|
|
|
var s0, s1, s2, s3;
|
|
|
|
|
|
|
|
peg$silentFails++;
|
|
|
|
s0 = peg$currPos;
|
|
|
|
s1 = peg$parseld();
|
|
|
|
if (s1 !== null) {
|
|
|
|
s2 = peg$parsetagname();
|
|
|
|
if (s2 !== null) {
|
|
|
|
s3 = peg$parserd();
|
|
|
|
if (s3 !== null) {
|
|
|
|
peg$reportedPos = s0;
|
2013-06-11 16:05:32 +00:00
|
|
|
s1 = peg$c35(s2);
|
2013-06-10 22:55:27 +00:00
|
|
|
if (s1 === null) {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = s1;
|
|
|
|
} else {
|
|
|
|
s0 = s1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = peg$c3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = peg$c3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = peg$c3;
|
|
|
|
}
|
|
|
|
peg$silentFails--;
|
|
|
|
if (s0 === null) {
|
|
|
|
s1 = null;
|
2013-06-11 16:05:32 +00:00
|
|
|
if (peg$silentFails === 0) { peg$fail(peg$c34); }
|
2013-06-10 22:55:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return s0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function peg$parseblock() {
|
|
|
|
var s0, s1, s2, s3, s4;
|
|
|
|
|
|
|
|
s0 = peg$currPos;
|
|
|
|
s1 = peg$parsetag_start();
|
|
|
|
if (s1 !== null) {
|
|
|
|
s2 = [];
|
|
|
|
s3 = peg$parsepart();
|
|
|
|
while (s3 !== null) {
|
|
|
|
s2.push(s3);
|
|
|
|
s3 = peg$parsepart();
|
|
|
|
}
|
|
|
|
if (s2 !== null) {
|
|
|
|
s3 = peg$parsetag_end();
|
|
|
|
if (s3 !== null) {
|
|
|
|
peg$reportedPos = peg$currPos;
|
2013-06-11 16:05:32 +00:00
|
|
|
s4 = peg$c36(s1,s2,s3);
|
2013-06-10 22:55:27 +00:00
|
|
|
if (s4) {
|
2013-06-11 16:05:32 +00:00
|
|
|
s4 = peg$c7;
|
2013-06-10 22:55:27 +00:00
|
|
|
} else {
|
|
|
|
s4 = peg$c3;
|
|
|
|
}
|
|
|
|
if (s4 !== null) {
|
|
|
|
peg$reportedPos = s0;
|
2013-06-11 16:05:32 +00:00
|
|
|
s1 = peg$c37(s1,s2,s3);
|
2013-06-10 22:55:27 +00:00
|
|
|
if (s1 === null) {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = s1;
|
|
|
|
} else {
|
|
|
|
s0 = s1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = peg$c3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = peg$c3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = peg$c3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
peg$currPos = s0;
|
|
|
|
s0 = peg$c3;
|
|
|
|
}
|
|
|
|
|
|
|
|
return s0;
|
|
|
|
}
|
|
|
|
|
2013-06-11 16:05:32 +00:00
|
|
|
|
2013-06-11 16:24:41 +00:00
|
|
|
var _VALID_BLOCK_TYPES = ['if', 'when', 'template', 'many', 'block'];
|
2013-06-11 16:05:32 +00:00
|
|
|
var _VBT_LENGTH = _VALID_BLOCK_TYPES.length;
|
|
|
|
|
|
|
|
function is_valid_block_type(b) {
|
2013-06-12 16:51:00 +00:00
|
|
|
for(var i = 0; i < _VBT_LENGTH; i++) {
|
2013-06-11 16:05:32 +00:00
|
|
|
if (_VALID_BLOCK_TYPES[i] == b) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-10 22:55:27 +00:00
|
|
|
peg$result = peg$startRuleFunction();
|
|
|
|
|
|
|
|
if (peg$result !== null && peg$currPos === input.length) {
|
|
|
|
return peg$result;
|
|
|
|
} else {
|
|
|
|
peg$cleanupExpected(peg$maxFailExpected);
|
|
|
|
peg$reportedPos = Math.max(peg$currPos, peg$maxFailPos);
|
|
|
|
|
|
|
|
throw new SyntaxError(
|
|
|
|
peg$maxFailExpected,
|
|
|
|
peg$reportedPos < input.length ? input.charAt(peg$reportedPos) : null,
|
|
|
|
peg$reportedPos,
|
|
|
|
peg$computePosDetails(peg$reportedPos).line,
|
|
|
|
peg$computePosDetails(peg$reportedPos).column
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
SyntaxError: SyntaxError,
|
|
|
|
parse : parse
|
|
|
|
};
|
|
|
|
})();
|