velocity-template-engine
Version:
velocity template engine
1,754 lines (1,611 loc) • 157 kB
JavaScript
var func_1517991408747 = new (function () { /*
* Generated by PEG.js 0.10.0.
*
* http://pegjs.org/
*/
(function(root) {
"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 = { start: peg$parsestart },
peg$startRuleFunction = peg$parsestart,
peg$c0 = function(s) {
return s;
},
peg$c1 = peg$otherExpectation("0"),
peg$c2 = function(s) {
return {
s: s,
_: '0'
};
},
peg$c3 = function() { return text() },
peg$c4 = /^[$#]/,
peg$c5 = peg$classExpectation(["$", "#"], false, false),
peg$c6 = /^[^$#]/,
peg$c7 = peg$classExpectation(["$", "#"], true, false),
peg$c8 = function() { return ''; },
peg$c9 = "#[[",
peg$c10 = peg$literalExpectation("#[[", false),
peg$c11 = "]]#",
peg$c12 = peg$literalExpectation("]]#", false),
peg$c13 = "##",
peg$c14 = peg$literalExpectation("##", false),
peg$c15 = "#*",
peg$c16 = peg$literalExpectation("#*", false),
peg$c17 = "*#",
peg$c18 = peg$literalExpectation("*#", false),
peg$c19 = "#set",
peg$c20 = peg$literalExpectation("#set", false),
peg$c21 = "#foreach",
peg$c22 = peg$literalExpectation("#foreach", false),
peg$c23 = "#if",
peg$c24 = peg$literalExpectation("#if", false),
peg$c25 = "#elseif",
peg$c26 = peg$literalExpectation("#elseif", false),
peg$c27 = "#{else}",
peg$c28 = peg$literalExpectation("#{else}", false),
peg$c29 = "#else",
peg$c30 = peg$literalExpectation("#else", false),
peg$c31 = /^[0-9a-zA-Z_\-]/,
peg$c32 = peg$classExpectation([["0", "9"], ["a", "z"], ["A", "Z"], "_", "-"], false, false),
peg$c33 = "#define",
peg$c34 = peg$literalExpectation("#define", false),
peg$c35 = "#macro",
peg$c36 = peg$literalExpectation("#macro", false),
peg$c37 = "#end",
peg$c38 = peg$literalExpectation("#end", false),
peg$c39 = "#{end}",
peg$c40 = peg$literalExpectation("#{end}", false),
peg$c41 = function(t) {
return t;
},
peg$c42 = peg$anyExpectation(),
peg$c43 = function() {
return '';
},
peg$c44 = function(s) { return s; },
peg$c45 = peg$otherExpectation("1"),
peg$c46 = function(e, s, elifs, el) {
return {
e: e,
s: s,
elifs: (elifs && elifs.length) ? elifs : undefined,
el: el || undefined,
_: '1'
};
},
peg$c47 = function(e, s) {
return {
e: e,
s: s
};
},
peg$c48 = peg$otherExpectation("23"),
peg$c49 = "$",
peg$c50 = peg$literalExpectation("$", false),
peg$c51 = function(body, s) {
return {
body: body,
s: s,
_: '23'
};
},
peg$c52 = peg$otherExpectation("24"),
peg$c53 = function(name, param, s) {
var params = [];
if (param && param.length) {
for (var i = 0, len = param.length; i < len; i++) {
params.push(param[i][1]);
}
}
return {
name: name,
params: params,
s: s,
_: '24'
};
},
peg$c54 = peg$otherExpectation("25"),
peg$c55 = "#",
peg$c56 = peg$literalExpectation("#", false),
peg$c57 = function(name, args) {
return {
text: text(),
name: name,
args: args,
_: '25'
};
},
peg$c58 = peg$otherExpectation("2"),
peg$c59 = "in",
peg$c60 = peg$literalExpectation("in", false),
peg$c61 = function(id, list) {
return {
id: id,
data: list,
_: '2'
};
},
peg$c62 = peg$otherExpectation("3"),
peg$c63 = function(it, s) {
return {
it: it,
s: s,
_: '3'
};
},
peg$c64 = peg$otherExpectation("4"),
peg$c65 = ".",
peg$c66 = peg$literalExpectation(".", false),
peg$c67 = "[",
peg$c68 = peg$literalExpectation("[", false),
peg$c69 = "(",
peg$c70 = peg$literalExpectation("(", false),
peg$c71 = ",",
peg$c72 = peg$literalExpectation(",", false),
peg$c73 = function(main, tail) {
var tails = [main];
for (var i = 0, len = tail.length; i < len; i++) {
if (tail[i][0] === '.') {
tails.push({
type: 1,
value: tail[i][1]
});
} else if (tail[i][0] === '[') {
tails.push({
type: 2,
value: tail[i][1]
});
} else if (tail[i][0] === '(') {
var params = [];
if (tail[i][1]) {
var ps = tail[i][1];
params.push(ps[0]);
if (ps[1]) {
for (var j = 0, llen = ps[1].length; j < llen; j++) {
params.push(ps[1][j][2]);
}
}
}
tails.push({
type: 3,
value: params
});
}
}
return tails;
},
peg$c74 = "{",
peg$c75 = peg$literalExpectation("{", false),
peg$c76 = function(ref) { return ref; },
peg$c77 = peg$otherExpectation("5"),
peg$c78 = "=",
peg$c79 = peg$literalExpectation("=", false),
peg$c80 = function(body, v) {
return {
body: body,
v: v,
_: '5'
};
},
peg$c81 = "${",
peg$c82 = peg$literalExpectation("${", false),
peg$c83 = function(r1) { return r1; },
peg$c84 = function(r2) { return r2; },
peg$c85 = peg$otherExpectation("6"),
peg$c86 = "!",
peg$c87 = peg$literalExpectation("!", false),
peg$c88 = function(bang, body) {
return {
bang: !!bang || undefined,
body: body,
_: '6'
};
},
peg$c89 = peg$otherExpectation("7"),
peg$c90 = function(ref) {
ref.text = text();
ref._ = '7';
return ref;
},
peg$c91 = peg$otherExpectation("8"),
peg$c92 = function(ref) {
ref._ = '8';
return ref;
},
peg$c93 = /^[a-zA-Z]/,
peg$c94 = peg$classExpectation([["a", "z"], ["A", "Z"]], false, false),
peg$c95 = function() { return text(); },
peg$c96 = function(e) { return e; },
peg$c97 = peg$otherExpectation("9"),
peg$c98 = ":",
peg$c99 = peg$literalExpectation(":", false),
peg$c100 = function(k, v) {
return {
key: k,
val: v
};
},
peg$c101 = peg$otherExpectation("10"),
peg$c102 = function(head, tail) {
var tails = head ? [head] : [];
if (tail.length) {
for (var i = 0, len = tail.length; i < len; i++) {
tails.push(tail[i][2]);
}
}
return {
tail: tails.length ? tails : undefined,
_: '10'
};
},
peg$c103 = peg$otherExpectation("11"),
peg$c104 = "..",
peg$c105 = peg$literalExpectation("..", false),
peg$c106 = function(start, end) {
return {
startExp: start,
endExp: end,
_: '11'
};
},
peg$c107 = peg$otherExpectation("12"),
peg$c108 = function(head, tail) {
var tails = head ? [head] : [];
if (tail.length) {
for (var i = 0, len = tail.length; i < len; i++) {
tails.push(tail[i][2]);
}
}
return {
tail: tails.length ? tails : undefined,
_: '12'
};
},
peg$c109 = "-",
peg$c110 = peg$literalExpectation("-", false),
peg$c111 = function(s1, r) {
if (s1) r._ = '13';
return r;
},
peg$c112 = function(p) {
return {
p: p,
_: '14'
};
},
peg$c113 = /^[!\-]/,
peg$c114 = peg$classExpectation(["!", "-"], false, false),
peg$c115 = function(s2, e) {
return !s2 ? e : {
s: s2,
exp: e,
_: '15'
};
},
peg$c116 = peg$otherExpectation("16"),
peg$c117 = "||",
peg$c118 = peg$literalExpectation("||", false),
peg$c119 = function(head, tail) {
if (!tail.length) return head;
return {
head: head,
tail: tail,
_: '16'
};
},
peg$c120 = peg$otherExpectation("17"),
peg$c121 = "&&",
peg$c122 = peg$literalExpectation("&&", false),
peg$c123 = function(head, tail) {
if (!tail.length) return head;
return {
head: head,
tail: tail,
_: '17'
};
},
peg$c124 = peg$otherExpectation("18"),
peg$c125 = "==",
peg$c126 = peg$literalExpectation("==", false),
peg$c127 = "!=",
peg$c128 = peg$literalExpectation("!=", false),
peg$c129 = function(head, tail) {
if (!tail.length) return head;
return {
head: head,
tail: tail,
_: '18'
};
},
peg$c130 = peg$otherExpectation("19"),
peg$c131 = "<=",
peg$c132 = peg$literalExpectation("<=", false),
peg$c133 = ">=",
peg$c134 = peg$literalExpectation(">=", false),
peg$c135 = "<",
peg$c136 = peg$literalExpectation("<", false),
peg$c137 = ">",
peg$c138 = peg$literalExpectation(">", false),
peg$c139 = function(head, tail) {
if (!tail) return head;
return {
head: head,
tail: tail,
_: '19'
};
},
peg$c140 = peg$otherExpectation("20"),
peg$c141 = "+",
peg$c142 = peg$literalExpectation("+", false),
peg$c143 = function(head, tail) {
if (!tail.length) return head;
return {
head: head,
tail: tail,
_: '20'
};
},
peg$c144 = peg$otherExpectation("21"),
peg$c145 = "*",
peg$c146 = peg$literalExpectation("*", false),
peg$c147 = "/",
peg$c148 = peg$literalExpectation("/", false),
peg$c149 = "%",
peg$c150 = peg$literalExpectation("%", false),
peg$c151 = function(head, tail) {
if (!tail.length) return head;
return {
head: head,
tail: tail,
_: '21'
};
},
peg$c152 = peg$otherExpectation("22"),
peg$c153 = function(chars) {
return {
parts: chars,
_: '22'
};
},
peg$c154 = function(chars_raw) {
return {
parts: [chars_raw.join('')],
_: '22'
};
},
peg$c155 = "\\",
peg$c156 = peg$literalExpectation("\\", false),
peg$c157 = "b",
peg$c158 = peg$literalExpectation("b", false),
peg$c159 = function() { return '\b'; },
peg$c160 = "f",
peg$c161 = peg$literalExpectation("f", false),
peg$c162 = function() { return '\f'; },
peg$c163 = "n",
peg$c164 = peg$literalExpectation("n", false),
peg$c165 = function() { return '\n'; },
peg$c166 = "r",
peg$c167 = peg$literalExpectation("r", false),
peg$c168 = function() { return '\r'; },
peg$c169 = "t",
peg$c170 = peg$literalExpectation("t", false),
peg$c171 = function() { return '\t'; },
peg$c172 = "u",
peg$c173 = peg$literalExpectation("u", false),
peg$c174 = function(digits) {
return String.fromCharCode(parseInt(digits, 16));
},
peg$c175 = function(sequence) { return sequence; },
peg$c176 = "\"",
peg$c177 = peg$literalExpectation("\"", false),
peg$c178 = function() { return '"'; },
peg$c179 = "'",
peg$c180 = peg$literalExpectation("'", false),
peg$c181 = function() { return "'"; },
peg$c182 = /^[1-9]/,
peg$c183 = peg$classExpectation([["1", "9"]], false, false),
peg$c184 = /^[0-9]/,
peg$c185 = peg$classExpectation([["0", "9"]], false, false),
peg$c186 = "0",
peg$c187 = peg$literalExpectation("0", false),
peg$c188 = "true",
peg$c189 = peg$literalExpectation("true", false),
peg$c190 = function() { return true; },
peg$c191 = "false",
peg$c192 = peg$literalExpectation("false", false),
peg$c193 = function() { return false; },
peg$c194 = function() { return parseFloat(text()); },
peg$c195 = function() { return 0; },
peg$c196 = /^[0-9a-f]/i,
peg$c197 = peg$classExpectation([["0", "9"], ["a", "f"]], false, true),
peg$c198 = /^[ \t\n\r\x0B\f]/,
peg$c199 = peg$classExpectation([" ", "\t", "\n", "\r", "\x0B", "\f"], false, false),
peg$c200 = peg$otherExpectation("whitespaces"),
peg$c201 = peg$otherExpectation("whitespace"),
peg$c202 = ")",
peg$c203 = peg$literalExpectation(")", false),
peg$c204 = "]",
peg$c205 = peg$literalExpectation("]", false),
peg$c206 = "}",
peg$c207 = peg$literalExpectation("}", false),
peg$c208 = "\n",
peg$c209 = peg$literalExpectation("\n", false),
peg$c210 = "\r\n",
peg$c211 = peg$literalExpectation("\r\n", false),
peg$c212 = "\r",
peg$c213 = peg$literalExpectation("\r", false),
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$parsestart() {
var s0, s1;
s0 = peg$currPos;
s1 = peg$parseStatements();
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c0(s1);
}
s0 = s1;
return s0;
}
function peg$parseStatements() {
var s0, s1, s2;
peg$silentFails++;
s0 = peg$currPos;
s1 = [];
s2 = peg$parseStatement();
while (s2 !== peg$FAILED) {
s1.push(s2);
s2 = peg$parseStatement();
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c2(s1);
}
s0 = s1;
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c1); }
}
return s0;
}
function peg$parseStatement() {
var s0, s1, s2;
s0 = peg$parseSpecStatement();
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parseS_ELSEIF();
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c3();
}
s0 = s1;
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parseS_ELSE();
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c3();
}
s0 = s1;
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parseS_END();
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c3();
}
s0 = s1;
if (s0 === peg$FAILED) {
if (peg$c4.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c5); }
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = [];
if (peg$c6.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c7); }
}
if (s2 !== peg$FAILED) {
while (s2 !== peg$FAILED) {
s1.push(s2);
if (peg$c6.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c7); }
}
}
} else {
s1 = peg$FAILED;
}
if (s1 !== peg$FAILED) {
s0 = input.substring(s0, peg$currPos);
} else {
s0 = s1;
}
}
}
}
}
}
return s0;
}
function peg$parseSpecStatement() {
var s0, s1;
s0 = peg$parseUnparsedText();
if (s0 === peg$FAILED) {
s0 = peg$parseComments();
if (s0 === peg$FAILED) {
s0 = peg$parseSetStatement();
if (s0 === peg$FAILED) {
s0 = peg$parseForeachStatement();
if (s0 === peg$FAILED) {
s0 = peg$parseIfStatement();
if (s0 === peg$FAILED) {
s0 = peg$parseDefineStatement();
if (s0 === peg$FAILED) {
s0 = peg$parseMacroStatement();
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parseComment();
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c8();
}
s0 = s1;
if (s0 === peg$FAILED) {
s0 = peg$parseMacroExecStatement();
if (s0 === peg$FAILED) {
s0 = peg$parseReferenceRender();
}
}
}
}
}
}
}
}
}
return s0;
}
function peg$parseS_UNPARSED_BEGIN() {
var s0;
if (input.substr(peg$currPos, 3) === peg$c9) {
s0 = peg$c9;
peg$currPos += 3;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c10); }
}
return s0;
}
function peg$parseS_UNPARSED_END() {
var s0;
if (input.substr(peg$currPos, 3) === peg$c11) {
s0 = peg$c11;
peg$currPos += 3;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c12); }
}
return s0;
}
function peg$parseS_COMMENT() {
var s0;
if (input.substr(peg$currPos, 2) === peg$c13) {
s0 = peg$c13;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c14); }
}
return s0;
}
function peg$parseS_COMMENTS_BEGIN() {
var s0;
if (input.substr(peg$currPos, 2) === peg$c15) {
s0 = peg$c15;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c16); }
}
return s0;
}
function peg$parseS_COMMENTS_END() {
var s0;
if (input.substr(peg$currPos, 2) === peg$c17) {
s0 = peg$c17;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c18); }
}
return s0;
}
function peg$parseS_SET() {
var s0;
if (input.substr(peg$currPos, 4) === peg$c19) {
s0 = peg$c19;
peg$currPos += 4;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c20); }
}
return s0;
}
function peg$parseS_FOREACH() {
var s0;
if (input.substr(peg$currPos, 8) === peg$c21) {
s0 = peg$c21;
peg$currPos += 8;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c22); }
}
return s0;
}
function peg$parseS_IF() {
var s0;
if (input.substr(peg$currPos, 3) === peg$c23) {
s0 = peg$c23;
peg$currPos += 3;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c24); }
}
return s0;
}
function peg$parseS_ELSEIF() {
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$parseS_ELSE() {
var s0, s1, s2, s3;
if (input.substr(peg$currPos, 7) === peg$c27) {
s0 = peg$c27;
peg$currPos += 7;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c28); }
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.substr(peg$currPos, 5) === peg$c29) {
s1 = peg$c29;
peg$currPos += 5;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c30); }
}
if (s1 !== peg$FAILED) {
s2 = peg$currPos;
peg$silentFails++;
if (peg$c31.test(input.charAt(peg$currPos))) {
s3 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c32); }
}
peg$silentFails--;
if (s3 === peg$FAILED) {
s2 = void 0;
} else {
peg$currPos = s2;
s2 = peg$FAILED;
}
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$parseS_DEFINE() {
var s0;
if (input.substr(peg$currPos, 7) === peg$c33) {
s0 = peg$c33;
peg$currPos += 7;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c34); }
}
return s0;
}
function peg$parseS_MACRO() {
var s0;
if (input.substr(peg$currPos, 6) === peg$c35) {
s0 = peg$c35;
peg$currPos += 6;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c36); }
}
return s0;
}
function peg$parseS_END() {
var s0;
if (input.substr(peg$currPos, 4) === peg$c37) {
s0 = peg$c37;
peg$currPos += 4;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c38); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 6) === peg$c39) {
s0 = peg$c39;
peg$currPos += 6;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c40); }
}
}
return s0;
}
function peg$parseUnparsedText() {
var s0, s1, s2, s3, s4;
s0 = peg$currPos;
s1 = peg$parseS_UNPARSED_BEGIN();
if (s1 !== peg$FAILED) {
s2 = peg$currPos;
s3 = [];
s4 = peg$parseUnparsedTextInner();
while (s4 !== peg$FAILED) {
s3.push(s4);
s4 = peg$parseUnparsedTextInner();
}
if (s3 !== peg$FAILED) {
s2 = input.substring(s2, peg$currPos);
} else {
s2 = s3;
}
if (s2 !== peg$FAILED) {
s3 = peg$parseS_UNPARSED_END();
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c41(s2);
s0 = s1;
} 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$parseUnparsedTextInner() {
var s0, s1, s2;
s0 = peg$currPos;
s1 = peg$currPos;
peg$silentFails++;
s2 = peg$parseS_UNPARSED_END();
peg$silentFails--;
if (s2 === peg$FAILED) {
s1 = void 0;
} else {
peg$currPos = s1;
s1 = peg$FAILED;
}
if (s1 !== peg$FAILED) {
if (input.length > peg$currPos) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c42); }
}
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$parseComment() {
var s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
s1 = peg$parseS_COMMENT();
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$currPos;
s4 = peg$currPos;
peg$silentFails++;
s5 = peg$parseEOL();
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$c42); }
}
if (s5 !== peg$FAILED) {
s4 = [s4, s5];
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$currPos;
s4 = peg$currPos;
peg$silentFails++;
s5 = peg$parseEOL();
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$c42); }
}
if (s5 !== peg$FAILED) {
s4 = [s4, s5];
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
}
if (s2 !== peg$FAILED) {
s3 = peg$parseEOL();
if (s3 !== peg$FAILED) {
s1 = [s1, s2, s3];
s0 = s1;
} 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$parseComments() {
var s0, s1, s2, s3;
s0 = peg$currPos;
s1 = peg$parseS_COMMENTS_BEGIN();
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parseCommentsInner();
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parseCommentsInner();
}
if (s2 !== peg$FAILED) {
s3 = peg$parseS_COMMENTS_END();
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c43();
s0 = s1;
} 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$parseCommentsInner() {
var s0, s1, s2;
s0 = peg$currPos;
s1 = peg$currPos;
peg$silentFails++;
s2 = peg$parseS_COMMENTS_END();
peg$silentFails--;
if (s2 === peg$FAILED) {
s1 = void 0;
} else {
peg$currPos = s1;
s1 = peg$FAILED;
}
if (s1 !== peg$FAILED) {
if (input.length > peg$currPos) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c42); }
}
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$parseNonIfEndStatement() {
var s0, s1, s2;
s0 = peg$currPos;
s1 = peg$currPos;
peg$silentFails++;
s2 = peg$parseS_ELSEIF();
if (s2 === peg$FAILED) {
s2 = peg$parseS_ELSE();
if (s2 === peg$FAILED) {
s2 = peg$parseS_END();
}
}
peg$silentFails--;
if (s2 === peg$FAILED) {
s1 = void 0;
} else {
peg$currPos = s1;
s1 = peg$FAILED;
}
if (s1 !== peg$FAILED) {
s2 = peg$parseStatement();
if (s2 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c44(s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parseNonEndStatement() {
var s0, s1, s2;
s0 = peg$currPos;
s1 = peg$currPos;
peg$silentFails++;
s2 = peg$parseS_END();
peg$silentFails--;
if (s2 === peg$FAILED) {
s1 = void 0;
} else {
peg$currPos = s1;
s1 = peg$FAILED;
}
if (s1 !== peg$FAILED) {
s2 = peg$parseStatement();
if (s2 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c44(s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parseIfStatement() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12;
peg$silentFails++;
s0 = peg$currPos;
s1 = peg$parseS_IF();
if (s1 !== peg$FAILED) {
s2 = peg$parseL_R_BRAC();
if (s2 !== peg$FAILED) {
s3 = peg$parseExpression();
if (s3 !== peg$FAILED) {
s4 = peg$parseR_R_BRAC();
if (s4 !== peg$FAILED) {
s5 = peg$parse_();
if (s5 !== peg$FAILED) {
s6 = [];
s7 = peg$parseNonIfEndStatement();
while (s7 !== peg$FAILED) {
s6.push(s7);
s7 = peg$parseNonIfEndStatement();
}
if (s6 !== peg$FAILED) {
s7 = peg$parse_();
if (s7 !== peg$FAILED) {
s8 = [];
s9 = peg$parseElseIfStatement();
while (s9 !== peg$FAILED) {
s8.push(s9);
s9 = peg$parseElseIfStatement();
}
if (s8 !== peg$FAILED) {
s9 = peg$parse_();
if (s9 !== peg$FAILED) {
s10 = peg$parseElseStatement();
if (s10 === peg$FAILED) {
s10 = null;
}
if (s10 !== peg$FAILED) {
s11 = peg$parse_();
if (s11 !== peg$FAILED) {
s12 = peg$parseS_END();
if (s12 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c46(s3, s6, s8, s10);
s0 = s1;
} 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;
}
} 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;
}
} 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;
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c45); }
}
return s0;
}
function peg$parseElseIfStatement() {
var s0, s1, s2, s3, s4, s5, s6, s7;
s0 = peg$currPos;
s1 = peg$parseS_ELSEIF();
if (s1 !== peg$FAILED) {
s2 = peg$parseL_R_BRAC();
if (s2 !== peg$FAILED) {
s3 = peg$parseExpression();
if (s3 !== peg$FAILED) {
s4 = peg$parseR_R_BRAC();
if (s4 !== peg$FAILED) {
s5 = peg$parse_();
if (s5 !== peg$FAILED) {
s6 = [];
s7 = peg$parseNonIfEndStatement();
while (s7 !== peg$FAILED) {
s6.push(s7);
s7 = peg$parseNonIfEndStatement();
}
if (s6 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c47(s3, s6);
s0 = s1;
} 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;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parseElseStatement() {
var s0, s1, s2, s3;
s0 = peg$currPos;
s1 = peg$parseS_ELSE();
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parseNonIfEndStatement();
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parseNonIfEndStatement();
}
if (s2 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c44(s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parseDefineStatement() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10;
peg$silentFails++;
s0 = peg$currPos;
s1 = peg$parseS_DEFINE();
if (s1 !== peg$FAILED) {
s2 = peg$parseL_R_BRAC();
if (s2 !== peg$FAILED) {
s3 = peg$parse_();
if (s3 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 36) {
s4 = peg$c49;
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c50); }
}
if (s4 !== peg$FAILED) {
s5 = peg$parseReferenceBody();
if (s5 !== peg$FAILED) {
s6 = peg$parseR_R_BRAC();
if (s6 !== peg$FAILED) {
s7 = peg$parse_();
if (s7 !== peg$FAILED) {
s8 = [];
s9 = peg$parseNonEndStatement();
while (s9 !== peg$FAILED) {
s8.push(s9);
s9 = peg$parseNonEndStatement();
}
if (s8 !== peg$FAILED) {
s9 = peg$parse_();
if (s9 !== peg$FAILED) {
s10 = peg$parseS_END();
if (s10 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c51(s5, s8);
s0 = s1;
} 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;
}
} 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;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c48); }
}
return s0;
}
function peg$parseMacroStatement() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10;
peg$silentFails++;
s0 = peg$currPos;
s1 = peg$parseS_MACRO();
if (s1 !== peg$FAILED) {
s2 = peg$parseL_R_BRAC();
if (s2 !== peg$FAILED) {
s3 = peg$parse_();
if (s3 !== peg$FAILED) {
s4 = peg$parseIdentifier();
if (s4 !== peg$FAILED) {
s5 = [];
s6 = peg$currPos;
s7 = peg$parse__();
if (s7 !== peg$FAILED) {
s8 = peg$parseSingleRefernce();
if (s8 !== peg$FAILED) {
s7 = [s7, s8];
s6 = s7;
} 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$parse__();
if (s7 !== peg$FAILED) {
s8 = peg$parseSingleRefernce();
if (s8 !== peg$FAILED) {
s7 = [s7, s8];
s6 = s7;
} else {
peg$currPos = s6;
s6 = peg$FAILED;
}
} else {
peg$currPos = s6;
s6 = peg$FAILED;
}
}
if (s5 !== peg$FAILED) {
s6 = peg$parseR_R_BRAC();
if (s6 !== peg$FAILED) {
s7 = peg$parse_();
if (s7 !== peg$FAILED) {
s8 = [];
s9 = peg$parseNonEndStatement();
while (s9 !== peg$FAILED) {
s8.push(s9);
s9 = peg$parseNonEndStatement();
}
if (s8 !== peg$FAILED) {
s9 = peg$parse_();
if (s9 !== peg$FAILED) {
s10 = peg$parseS_END();
if (s10 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c53(s4, s5, s8);
s0 = s1;
} 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;
}
} else {
peg$currPos = s0;