versescript
Version:
VerseScript is specifically built for microtron AI's AR/VR Verse platform. VerseScript was made to develop apps on verse, however it can be used for more generic usage. It works well in any javascript project, imports javascript functions or classes to be
1,599 lines (1,497 loc) • 184 kB
JavaScript
/*
* 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 = { start: peg$parsestart, expression: peg$parseexpression },
peg$startRuleFunction = peg$parsestart,
peg$c0 = function(program) {
return locationInfo(location(), "Program", { type: "Program", body: program });
},
peg$c1 = "import",
peg$c2 = peg$literalExpectation("import", false),
peg$c3 = "{",
peg$c4 = peg$literalExpectation("{", false),
peg$c5 = "}",
peg$c6 = peg$literalExpectation("}", false),
peg$c7 = "from",
peg$c8 = peg$literalExpectation("from", false),
peg$c9 = ";",
peg$c10 = peg$literalExpectation(";", false),
peg$c11 = function(importSpecifiers, source) {
return locationInfo(location(), "ImportDeclaration", { type: "importDeclaration", specifiers: importSpecifiers, source });
},
peg$c12 = "as",
peg$c13 = peg$literalExpectation("as", false),
peg$c14 = function(name) {
return locationInfo(location(), "ImportSpecifier", { type: "importSpecifier", name, alias: alias || name });
},
peg$c15 = "export",
peg$c16 = peg$literalExpectation("export", false),
peg$c17 = function(declaration) {
return locationInfo(location(), "ExportDeclaration", { type: "exportDeclaration", declaration });
},
peg$c18 = function(exportSpecifiers) {
return locationInfo(location(), "ExportDeclaration", { type: "exportDeclaration", specifiers: exportSpecifiers });
},
peg$c19 = function(name) {
return locationInfo(location(), "ExportSpecifier", { type: "exportSpecifier", name, alias: alias || name });
},
peg$c20 = "try",
peg$c21 = peg$literalExpectation("try", false),
peg$c22 = "catch",
peg$c23 = peg$literalExpectation("catch", false),
peg$c24 = "(",
peg$c25 = peg$literalExpectation("(", false),
peg$c26 = ")",
peg$c27 = peg$literalExpectation(")", false),
peg$c28 = function(tryBlock, errorParam, catchBlock) {
return locationInfo(location(), "TryCatchStatement", {
type: "tryCatchStatement",
tryBlock,
catchBlock,
errorParam
});
},
peg$c29 = function(expansion) {
return locationInfo(location(), "ExpressionStatement", { type: "expressionStatement", expression: expansion });
},
peg$c30 = function(expr) {
return locationInfo(location(), "ExpressionStatement", {
type: "expressionStatement",
expression: expr
});
},
peg$c31 = function(expr) { return expr; },
peg$c32 = "=",
peg$c33 = peg$literalExpectation("=", false),
peg$c34 = function(left, right) {
return locationInfo(location(), "Assignment", { type: "assignment", left, right });
},
peg$c35 = "||",
peg$c36 = peg$literalExpectation("||", false),
peg$c37 = function(head, tail) {
return tail.reduce((result, element) =>
locationInfo(location(), "LogicalOr", {
type: "logicalOr",
left: result,
right: element[3]
}), head);
},
peg$c38 = "&&",
peg$c39 = peg$literalExpectation("&&", false),
peg$c40 = function(head, tail) {
return tail.reduce((result, element) =>
locationInfo(location(), "LogicalAnd", {
type: "logicalAnd",
left: result,
right: element[3]
}), head);
},
peg$c41 = "<=",
peg$c42 = peg$literalExpectation("<=", false),
peg$c43 = ">=",
peg$c44 = peg$literalExpectation(">=", false),
peg$c45 = "==",
peg$c46 = peg$literalExpectation("==", false),
peg$c47 = "!=",
peg$c48 = peg$literalExpectation("!=", false),
peg$c49 = "<",
peg$c50 = peg$literalExpectation("<", false),
peg$c51 = ">",
peg$c52 = peg$literalExpectation(">", false),
peg$c53 = function(head, tail) {
return tail.reduce((result, element) =>
locationInfo(location(), "Comparison", {
type: "comparison",
operator: element[1],
left: result,
right: element[3]
}), head);
},
peg$c54 = "+",
peg$c55 = peg$literalExpectation("+", false),
peg$c56 = "-",
peg$c57 = peg$literalExpectation("-", false),
peg$c58 = function(head, tail) {
return tail.reduce((result, element) =>
locationInfo(location(), "Addition", {
type: "addition",
operator: element[1],
left: result,
right: element[3]
}), head);
},
peg$c59 = "*",
peg$c60 = peg$literalExpectation("*", false),
peg$c61 = "/",
peg$c62 = peg$literalExpectation("/", false),
peg$c63 = "%",
peg$c64 = peg$literalExpectation("%", false),
peg$c65 = function(head, tail) {
return tail.reduce((result, element) =>
locationInfo(location(), "Multiplication", {
type: "multiplication",
operator: element[1],
left: result,
right: element[3]
}), head);
},
peg$c66 = "!",
peg$c67 = peg$literalExpectation("!", false),
peg$c68 = "typeof",
peg$c69 = peg$literalExpectation("typeof", false),
peg$c70 = function(operator, right) {
return locationInfo(location(), "Unary", { type: "unary", operator, right });
},
peg$c71 = "[",
peg$c72 = peg$literalExpectation("[", false),
peg$c73 = "]",
peg$c74 = peg$literalExpectation("]", false),
peg$c75 = ".",
peg$c76 = peg$literalExpectation(".", false),
peg$c77 = "++",
peg$c78 = peg$literalExpectation("++", false),
peg$c79 = "--",
peg$c80 = peg$literalExpectation("--", false),
peg$c81 = function(head, tail) {
return tail.reduce((result, element) => {
if (element[1][0] === "(") {
return locationInfo(location(), "FunctionCall", { type: "functionCall", callee: result, arguments: element[1][2] });
} else if (element[1][0] === "[") {
return locationInfo(location(), "MemberExpression", { type: "memberExpression", object: result, property: element[1][2], computed: true });
} else if (element[1][0] === ".") {
return locationInfo(location(), "MemberExpression", { type: "memberExpression", object: result, property: element[1][2], computed: false });
} else if (element[1] === "++") {
return locationInfo(location(), "UpdateExpression", { type: "updateExpression", operator: "++", argument: result, prefix: false });
} else if (element[1] === "--") {
return locationInfo(location(), "UpdateExpression", { type: "updateExpression", operator: "--", argument: result, prefix: false });
}
}, head);
},
peg$c82 = "self",
peg$c83 = peg$literalExpectation("self", false),
peg$c84 = function() { return locationInfo(location(), "Self", { type: "self" }); },
peg$c85 = function(head, tail) {
return tail.reduce((result, element) => {
if (element[0] === ".") {
return locationInfo(location(), "MemberExpression", {
type: "memberExpression",
object: result,
property: element[1],
computed: false
});
} else {
return locationInfo(location(), "MemberExpression", {
type: "memberExpression",
object: result,
property: element[2],
computed: true
});
}
}, head);
},
peg$c86 = "@",
peg$c87 = peg$literalExpectation("@", false),
peg$c88 = function(name, args) {
return locationInfo(location(), "Decorator", {
type: "decorator",
name,
arguments: args || []
});
},
peg$c89 = function(args) {
return args || [];
},
peg$c90 = function(expression) { return expression; },
peg$c91 = "new",
peg$c92 = peg$literalExpectation("new", false),
peg$c93 = function(className, args) {
return locationInfo(location(), "ObjectCreation", { type: "objectCreation", className, arguments: args });
},
peg$c94 = function(elements) {
return locationInfo(location(), "ArrayLiteral", { type: "arrayLiteral", elements: elements || [] });
},
peg$c95 = ",",
peg$c96 = peg$literalExpectation(",", false),
peg$c97 = function(head, tail) {
return [head, ...tail.map(element => element[3])];
},
peg$c98 = function(properties) {
return locationInfo(location(), "ObjectLiteral", { type: "objectLiteral", properties: properties || [] });
},
peg$c99 = ":",
peg$c100 = peg$literalExpectation(":", false),
peg$c101 = function(key, value) {
return locationInfo(location(), "ObjectProperty", {
type: "objectProperty",
key: key.type === "identifier" ? key.name : key.value,
value
});
},
peg$c102 = /^[a-zA-Z_]/,
peg$c103 = peg$classExpectation([["a", "z"], ["A", "Z"], "_"], false, false),
peg$c104 = /^[a-zA-Z0-9_]/,
peg$c105 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"], "_"], false, false),
peg$c106 = function(name) {
return locationInfo(location(), "Identifier", { type: "identifier", name: text() });
},
peg$c107 = "function",
peg$c108 = peg$literalExpectation("function", false),
peg$c109 = "class",
peg$c110 = peg$literalExpectation("class", false),
peg$c111 = "extends",
peg$c112 = peg$literalExpectation("extends", false),
peg$c113 = "constructor",
peg$c114 = peg$literalExpectation("constructor", false),
peg$c115 = "var",
peg$c116 = peg$literalExpectation("var", false),
peg$c117 = "let",
peg$c118 = peg$literalExpectation("let", false),
peg$c119 = "const",
peg$c120 = peg$literalExpectation("const", false),
peg$c121 = "if",
peg$c122 = peg$literalExpectation("if", false),
peg$c123 = "else",
peg$c124 = peg$literalExpectation("else", false),
peg$c125 = "for",
peg$c126 = peg$literalExpectation("for", false),
peg$c127 = "while",
peg$c128 = peg$literalExpectation("while", false),
peg$c129 = "return",
peg$c130 = peg$literalExpectation("return", false),
peg$c131 = "throw",
peg$c132 = peg$literalExpectation("throw", false),
peg$c133 = "true",
peg$c134 = peg$literalExpectation("true", false),
peg$c135 = "false",
peg$c136 = peg$literalExpectation("false", false),
peg$c137 = "null",
peg$c138 = peg$literalExpectation("null", false),
peg$c139 = "macro",
peg$c140 = peg$literalExpectation("macro", false),
peg$c141 = "async",
peg$c142 = peg$literalExpectation("async", false),
peg$c143 = "await",
peg$c144 = peg$literalExpectation("await", false),
peg$c145 = function() {
return locationInfo(location(), "NullLiteral", { type: "nullLiteral", value: null });
},
peg$c146 = /^[0-9]/,
peg$c147 = peg$classExpectation([["0", "9"]], false, false),
peg$c148 = function(digits) {
return locationInfo(location(), "Integer", { type: "integer", value: parseInt(digits.join(""), 10) });
},
peg$c149 = function(digits, fractional) {
return locationInfo(location(), "Float", { type: "float", value: parseFloat(digits.join("") + "." + fractional.join("")) });
},
peg$c150 = "\"",
peg$c151 = peg$literalExpectation("\"", false),
peg$c152 = /^[^"\\]/,
peg$c153 = peg$classExpectation(["\"", "\\"], true, false),
peg$c154 = function(chars) {
return locationInfo(location(), "String", { type: "string", value: chars.join("") });
},
peg$c155 = function() {
return locationInfo(location(), "Boolean", { type: "boolean", value: text() === "true" });
},
peg$c156 = "'",
peg$c157 = peg$literalExpectation("'", false),
peg$c158 = /^[^'\\]/,
peg$c159 = peg$classExpectation(["'", "\\"], true, false),
peg$c160 = function(char) {
return locationInfo(location(), "Char", { type: "char", value: char });
},
peg$c161 = "\\",
peg$c162 = peg$literalExpectation("\\", false),
peg$c163 = /^["\\\/bfnrt]/,
peg$c164 = peg$classExpectation(["\"", "\\", "/", "b", "f", "n", "r", "t"], false, false),
peg$c165 = "u",
peg$c166 = peg$literalExpectation("u", false),
peg$c167 = /^[0-9a-fA-F]/,
peg$c168 = peg$classExpectation([["0", "9"], ["a", "f"], ["A", "F"]], false, false),
peg$c169 = function() {4},
peg$c170 = function(digits) {
return String.fromCharCode(parseInt(digits.join(""), 16));
},
peg$c171 = function(head, tail) {
const args = head ? [head] : [];
return args.concat(tail.map(element => element[3]));
},
peg$c172 = function(kind, id, initialization) {
return locationInfo(location(), "VariableDeclaration", {
type: "variableDeclaration",
kind,
id,
init: initialization ? initialization[2] : null
});
},
peg$c173 = function(test, consequent, else_clause) {
return locationInfo(location(), "IfStatement", {
type: "ifStatement",
test: test,
consequent: consequent,
alternate: else_clause ? else_clause[2] : null
});
},
peg$c174 = function(init, test, update, body) {
return locationInfo(location(), "ForLoop", {
type: "forLoop",
init: init || null,
test: test || null,
update: update || null,
body
});
},
peg$c175 = function(test, body) {
return locationInfo(location(), "WhileLoop", { type: "whileLoop", test, body });
},
peg$c176 = function(value) {
return locationInfo(location(), "ReturnStatement", { type: "returnStatement", value });
},
peg$c177 = function(value) {
return locationInfo(location(), "ThrowStatement", { type: "throwStatement", value });
},
peg$c178 = function(statements) { return statements; },
peg$c179 = function(async, name, params, body) {
return locationInfo(location(), "FunctionDefinition", {
type: "functionDefinition",
name,
params,
body,
isAsync: !!async
});
},
peg$c180 = function(async, name, params, body) {
return locationInfo(location(), "FunctionExpression", {
type: "functionExpression",
name: name || null,
params,
body,
isAsync: !!async
});
},
peg$c181 = function(decorators, name, extendsClause, constructor, members) {
return locationInfo(location(), "ClassDefinition", {
type: "classDefinition",
decorators,
name,
superClass: extendsClause ? extendsClause[2] : null,
constructor: constructor || { type: "constructorDefinition", params: [], body: [] },
members
});
},
peg$c182 = function(params, body) {
return locationInfo(location(), "ConstructorDefinition", { type: "constructorDefinition", params, body });
},
peg$c183 = function(decorators, async, name, params, body) {
return locationInfo(location(), "MethodDefinition", {
type: "methodDefinition",
decorators,
name,
params,
body,
isAsync: !!async
});
},
peg$c184 = function(expression) {
return locationInfo(location(), "AwaitExpression", {
type: "awaitExpression",
argument: expression
});
},
peg$c185 = function(name, initializer) {
return locationInfo(location(), "PropertyDefinition", {
type: "propertyDefinition",
name,
value: initializer ? initializer[2] : null
});
},
peg$c186 = function(head, tail) {
const params = head ? [head] : [];
return params.concat(tail.map(element => element[3]));
},
peg$c187 = function(name, params, body) {
return locationInfo(location(), "MacroDefinition", { type: "macroDefinition", name, params, body });
},
peg$c188 = "#",
peg$c189 = peg$literalExpectation("#", false),
peg$c190 = function(name, args) {
return locationInfo(location(), "MacroExpansion", { type: "macroExpansion", name, arguments: args || [] });
},
peg$c191 = /^[^}]/,
peg$c192 = peg$classExpectation(["}"], true, false),
peg$c193 = function(chars) { return chars.join("").trim(); },
peg$c194 = /^[ \t\n\r]/,
peg$c195 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false),
peg$c196 = "//",
peg$c197 = peg$literalExpectation("//", false),
peg$c198 = /^[^\n]/,
peg$c199 = peg$classExpectation(["\n"], true, false),
peg$c200 = "/*",
peg$c201 = peg$literalExpectation("/*", false),
peg$c202 = "*/",
peg$c203 = peg$literalExpectation("*/", false),
peg$c204 = peg$anyExpectation(),
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, s2, s3;
s0 = peg$currPos;
s1 = peg$parse_();
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parsemoduleItem();
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parsemoduleItem();
}
if (s2 !== peg$FAILED) {
s3 = peg$parse_();
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c0(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$parsemoduleItem() {
var s0;
s0 = peg$parseimportDeclaration();
if (s0 === peg$FAILED) {
s0 = peg$parseexportDeclaration();
if (s0 === peg$FAILED) {
s0 = peg$parsestatement();
}
}
return s0;
}
function peg$parseimportDeclaration() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14;
s0 = peg$currPos;
if (input.substr(peg$currPos, 6) === peg$c1) {
s1 = peg$c1;
peg$currPos += 6;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c2); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parse__();
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 123) {
s3 = peg$c3;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c4); }
}
if (s3 !== peg$FAILED) {
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
s5 = [];
s6 = peg$parseimportSpecifier();
while (s6 !== peg$FAILED) {
s5.push(s6);
s6 = peg$parseimportSpecifier();
}
if (s5 !== peg$FAILED) {
s6 = peg$parse_();
if (s6 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 125) {
s7 = peg$c5;
peg$currPos++;
} else {
s7 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c6); }
}
if (s7 !== peg$FAILED) {
s8 = peg$parse__();
if (s8 !== peg$FAILED) {
if (input.substr(peg$currPos, 4) === peg$c7) {
s9 = peg$c7;
peg$currPos += 4;
} else {
s9 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c8); }
}
if (s9 !== peg$FAILED) {
s10 = peg$parse__();
if (s10 !== peg$FAILED) {
s11 = peg$parsestring();
if (s11 !== peg$FAILED) {
s12 = peg$parse_();
if (s12 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 59) {
s13 = peg$c9;
peg$currPos++;
} else {
s13 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c10); }
}
if (s13 !== peg$FAILED) {
s14 = peg$parse_();
if (s14 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c11(s5, s11);
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;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parseimportSpecifier() {
var s0, s1, s2, s3, s4, s5, s6;
s0 = peg$currPos;
s1 = peg$parseidentifier();
if (s1 !== peg$FAILED) {
s2 = peg$parse__();
if (s2 !== peg$FAILED) {
s3 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c12) {
s4 = peg$c12;
peg$currPos += 2;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c13); }
}
if (s4 !== peg$FAILED) {
s5 = peg$parse__();
if (s5 !== peg$FAILED) {
s6 = peg$parseidentifier();
if (s6 !== peg$FAILED) {
s4 = [s4, s5, s6];
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
if (s3 === peg$FAILED) {
s3 = null;
}
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c14(s1);
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$parseexportDeclaration() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10;
s0 = peg$currPos;
if (input.substr(peg$currPos, 6) === peg$c15) {
s1 = peg$c15;
peg$currPos += 6;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c16); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parse__();
if (s2 !== peg$FAILED) {
s3 = peg$parsevariableDeclaration();
if (s3 === peg$FAILED) {
s3 = peg$parsefunctionDefinition();
if (s3 === peg$FAILED) {
s3 = peg$parseclassDefinition();
}
}
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c17(s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.substr(peg$currPos, 6) === peg$c15) {
s1 = peg$c15;
peg$currPos += 6;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c16); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parse__();
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 123) {
s3 = peg$c3;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c4); }
}
if (s3 !== peg$FAILED) {
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
s5 = [];
s6 = peg$parseexportSpecifier();
while (s6 !== peg$FAILED) {
s5.push(s6);
s6 = peg$parseexportSpecifier();
}
if (s5 !== peg$FAILED) {
s6 = peg$parse_();
if (s6 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 125) {
s7 = peg$c5;
peg$currPos++;
} else {
s7 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c6); }
}
if (s7 !== peg$FAILED) {
s8 = peg$parse_();
if (s8 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 59) {
s9 = peg$c9;
peg$currPos++;
} else {
s9 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c10); }
}
if (s9 !== peg$FAILED) {
s10 = peg$parse_();
if (s10 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c18(s5);
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;
}
}
return s0;
}
function peg$parseexportSpecifier() {
var s0, s1, s2, s3, s4, s5, s6;
s0 = peg$currPos;
s1 = peg$parseidentifier();
if (s1 !== peg$FAILED) {
s2 = peg$parse__();
if (s2 !== peg$FAILED) {
s3 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c12) {
s4 = peg$c12;
peg$currPos += 2;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c13); }
}
if (s4 !== peg$FAILED) {
s5 = peg$parse__();
if (s5 !== peg$FAILED) {
s6 = peg$parseidentifier();
if (s6 !== peg$FAILED) {
s4 = [s4, s5, s6];
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
if (s3 === peg$FAILED) {
s3 = null;
}
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c19(s1);
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$parsestatement() {
var s0;
s0 = peg$parsetryCatchStatement();
if (s0 === peg$FAILED) {
s0 = peg$parsemacroDefinition();
if (s0 === peg$FAILED) {
s0 = peg$parsevariableDeclaration();
if (s0 === peg$FAILED) {
s0 = peg$parseexpressionStatement();
if (s0 === peg$FAILED) {
s0 = peg$parseifStatement();
if (s0 === peg$FAILED) {
s0 = peg$parseforLoop();
if (s0 === peg$FAILED) {
s0 = peg$parsewhileLoop();
if (s0 === peg$FAILED) {
s0 = peg$parsereturnStatement();
if (s0 === peg$FAILED) {
s0 = peg$parsethrowStatement();
if (s0 === peg$FAILED) {
s0 = peg$parsefunctionDefinition();
if (s0 === peg$FAILED) {
s0 = peg$parseclassDefinition();
if (s0 === peg$FAILED) {
s0 = peg$parsemacroExpansionStatement();
}
}
}
}
}
}
}
}
}
}
}
return s0;
}
function peg$parsetryCatchStatement() {
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13;
s0 = peg$currPos;
if (input.substr(peg$currPos, 3) === peg$c20) {
s1 = peg$c20;
peg$currPos += 3;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c21); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
s3 = peg$parseblock();
if (s3 !== peg$FAILED) {
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
if (input.substr(peg$currPos, 5) === peg$c22) {
s5 = peg$c22;
peg$currPos += 5;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c23); }
}
if (s5 !== peg$FAILED) {
s6 = peg$parse_();
if (s6 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 40) {
s7 = peg$c24;
peg$currPos++;
} else {
s7 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c25); }
}
if (s7 !== peg$FAILED) {
s8 = peg$parse_();
if (s8 !== peg$FAILED) {
s9 = peg$parseidentifier();
if (s9 !== peg$FAILED) {
s10 = peg$parse_();
if (s10 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 41) {
s11 = peg$c26;
peg$currPos++;
} else {
s11 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c27); }
}
if (s11 !== peg$FAILED) {
s12 = peg$parse_();
if (s12 !== peg$FAILED) {
s13 = peg$parseblock();
if (s13 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c28(s3, s9, s13);
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;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parsemacroExpansionStatement() {
var s0, s1, s2, s3, s4;
s0 = peg$currPos;
s1 = peg$parsemacroExpansion();
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 59) {
s3 = peg$c9;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c10); }
}
if (s3 !== peg$FAILED) {
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c29(s1);
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;
}
return s0;
}
function peg$parseexpressionStatement() {
var s0, s1, s2, s3, s4;
s0 = peg$currPos;
s1 = peg$parseexpression();
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 59) {
s3 = peg$c9;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c10); }
}
if (s3 !== peg$FAILED) {
s4 = peg$parse_();
if (s4 !== 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;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parseexpression() {
var s0, s1, s2, s3;
s0 = peg$currPos;
s1 = peg$parse_();
if (s1 !== peg$FAILED) {
s2 = peg$parseassignment();
if (s2 === peg$FAILED) {
s2 = peg$parselogicalOr();
if (s2 === peg$FAILED) {
s2 = peg$parsemacroExpansion();
}
}
if (s2 !== peg$FAILED) {
s3 = peg$parse_();
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c31(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$parseassignment() {
var s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
s1 = peg$parseleftHandSide();
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 61) {
s3 = peg$c32;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c33); }
}
if (s3 !== peg$FAILED) {
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
s5 = peg$parseexpression();
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c34(s1, s5);
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;
}
return s0;
}
function peg$parseleftHandSide() {
var s0;
s0 = peg$parsememberExpression();
if (s0 === peg$FAILED) {
s0 = peg$parseidentifier();
}
return s0;
}
function peg$parselogicalOr() {
var s0, s1, s2, s3, s4, s5, s6, s7;
s0 = peg$currPos;
s1 = peg$parselogicalAnd();
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$currPos;
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c35) {
s5 = peg$c35;
peg$currPos += 2;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c36); }
}
if (s5 !== peg$FAILED) {
s6 = peg$parse_();
if (s6 !== peg$FAILED) {
s7 = peg$parselogicalAnd();
if (s7 !== peg$FAILED) {
s4 = [s4, s5, s6, s7];
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} 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$parse_();
if (s4 !== peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c35) {
s5 = peg$c35;
peg$currPos += 2;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c36); }
}
if (s5 !== peg$FAILED) {
s6 = peg$parse_();
if (s6 !== peg$FAILED) {
s7 = peg$parselogicalAnd();
if (s7 !== peg$FAILED) {
s4 = [s4, s5, s6, s7];
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
}
if (s2 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c37(s1, s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parselogicalAnd() {
var s0, s1, s2, s3, s4, s5, s6, s7;
s0 = peg$currPos;
s1 = peg$parsecomparison();
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$currPos;
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c38) {
s5 = peg$c38;
peg$currPos += 2;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c39); }
}
if (s5 !== peg$FAILED) {
s6 = peg$parse_();
if (s6 !== peg$FAILED) {
s7 = peg$parsecomparison();
if (s7 !== peg$FAILED) {
s4 = [s4, s5, s6, s7];
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;